void nofGeologist::SetSign(Resource resources)
{
    RTTR_Assert(resources.getType() != Resource::Fish); // Shall never happen

    // Bestimmte Objekte können gelöscht werden
    NodalObjectType noType = gwg->GetNO(pos)->GetType();
    if(noType != NOP_NOTHING && noType != NOP_ENVIRONMENT)
        return;
    gwg->DestroyNO(pos, false);

    // Schild setzen
    gwg->SetNO(pos, new noSign(pos, resources));

    // If nothing found, there is nothing left to do
    if(resources.getAmount() == 0u)
        return;

    if(!resAlreadyFound[resources.getType()] && !IsSignInArea(resources.getType()))
    {
        const char* msg;
        switch(resources.getType())
        {
            case Resource::Iron: msg = _("Found iron ore"); break;
            case Resource::Gold: msg = _("Found gold"); break;
            case Resource::Coal: msg = _("Found coal"); break;
            case Resource::Granite: msg = _("Found granite"); break;
            case Resource::Water: msg = _("Found water"); break;
            default: RTTR_Assert(false); return;
        }

        if(resources.getType() != Resource::Water || gwg->GetGGS().getSelection(AddonId::EXHAUSTIBLE_WATER) != 1)
        {
            SendPostMessage(player, new PostMsg(GetEvMgr().GetCurrentGF(), msg, PostCategory::Geologist, pos));
        }

        gwg->GetNotifications().publish(ResourceNote(player, pos, resources));
        if(gwg->HasLua())
            gwg->GetLua().EventResourceFound(this->player, pos, resources.getType(), resources.getAmount());
    }
    resAlreadyFound[resources.getType()] = true;
}
Example #2
0
void nofGeologist::SetSign(const unsigned char resources)
{
    // Bestimmte Objekte können gelöscht werden
    noBase* no = gwg->GetNO(pos);

    if(no->GetType() != NOP_NOTHING && no->GetType() != NOP_ENVIRONMENT)
        return;

    // Zierobjekte löschen
    if(no->GetType() == NOP_ENVIRONMENT)
    {
        no->Destroy();
        delete no;
    }

    // Schildtyp und -häufigkeit herausfinden
    unsigned char type, quantity;

    if(resources >= 0x41 && resources <= 0x47)
    {
        // Kohle
        type = 2;
        quantity = (resources - 0x40) / 3;
    }
    else if(resources >= 0x49 && resources <= 0x4F)
    {
        // Eisen
        type = 0;
        quantity = (resources - 0x48) / 3;
    }
    else if(resources >= 0x51 && resources <= 0x57)
    {
        // Gold
        type = 1;
        quantity = (resources - 0x50) / 3;
    }
    else if(resources >= 0x59 && resources <= 0x5F)
    {
        // Granit
        type = 3;
        quantity = (resources - 0x58) / 3;
    }
    else if(resources >= 0x21 && resources <= 0x27)
    {
        // Wasser
        type = 4;
        quantity = (resources - 0x20) / 3;
    }
    else
    {
        // nichts
        type = 5;
        quantity = 0;
    }

    if (type < 5)
    {
        if (!resAlreadyFound[type] && !IsSignInArea(type))
        {
            if(GAMECLIENT.GetPlayerID() == this->player)
            {
                switch(type)
                {
                    case 0: GAMECLIENT.SendPostMessage(new PostMsgWithLocation(_("Found iron ore"), PMC_GEOLOGIST, pos));
                        break;
                    case 1: GAMECLIENT.SendPostMessage(new PostMsgWithLocation(_("Found gold"), PMC_GEOLOGIST, pos));
                        break;
                    case 2: GAMECLIENT.SendPostMessage(new PostMsgWithLocation(_("Found coal"), PMC_GEOLOGIST, pos));
                        break;
                    case 3: GAMECLIENT.SendPostMessage(new PostMsgWithLocation(_("Found granite"), PMC_GEOLOGIST, pos));
                        break;
                    case 4: GAMECLIENT.SendPostMessage(new PostMsgWithLocation(_("Found water"), PMC_GEOLOGIST, pos));
                        break;
                    default:
                        ;
                }
            }
        }
        resAlreadyFound[type] = true;
    }

    gwg->LUA_EventResourceFound(this->player, pos, type, quantity);

    // Schild setzen
    gwg->SetNO(new noSign(pos, type, quantity), pos);


}