1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-03 14:52:11 +02:00

Clarified code

This commit is contained in:
Ivan Savenko 2024-05-02 17:32:38 +03:00
parent f6e5f09d50
commit 08ce3a8338

View File

@ -332,7 +332,7 @@ int CGCreature::takenAction(const CGHeroInstance *h, bool allowJoin) const
myKindCres.insert(myCreature->getId()); //we myKindCres.insert(myCreature->getId()); //we
myKindCres.insert(myCreature->upgrades.begin(), myCreature->upgrades.end()); //our upgrades myKindCres.insert(myCreature->upgrades.begin(), myCreature->upgrades.end()); //our upgrades
for(auto const & crea : VLC->creh->objects) for(const auto & crea : VLC->creh->objects)
{ {
if(vstd::contains(crea->upgrades, myCreature->getId())) //it's our base creatures if(vstd::contains(crea->upgrades, myCreature->getId())) //it's our base creatures
myKindCres.insert(crea->getId()); myKindCres.insert(crea->getId());
@ -365,8 +365,12 @@ int CGCreature::takenAction(const CGHeroInstance *h, bool allowJoin) const
if(diplomacy + sympathy + 1 >= character) if(diplomacy + sympathy + 1 >= character)
return JOIN_FOR_FREE; return JOIN_FOR_FREE;
else if(diplomacy * 2 + sympathy + 1 >= character) if(diplomacy * 2 + sympathy + 1 >= character)
return VLC->creatures()->getById(getCreature())->getRecruitCost(EGameResID::GOLD) * getStackCount(SlotID(0)); //join for gold {
int32_t recruitCost = VLC->creatures()->getById(getCreature())->getRecruitCost(EGameResID::GOLD);
uint32_t stackCount = getStackCount(SlotID(0));
return recruitCost * stackCount; //join for gold
}
} }
//we are still here - creatures have not joined hero, flee or fight //we are still here - creatures have not joined hero, flee or fight
@ -598,7 +602,7 @@ void CGCreature::giveReward(const CGHeroInstance * h) const
if(!resources.empty()) if(!resources.empty())
{ {
cb->giveResources(h->tempOwner, resources); cb->giveResources(h->tempOwner, resources);
for(auto const & res : GameResID::ALL_RESOURCES()) for(const auto & res : GameResID::ALL_RESOURCES())
{ {
if(resources[res] > 0) if(resources[res] > 0)
iw.components.emplace_back(ComponentType::RESOURCE, res, resources[res]); iw.components.emplace_back(ComponentType::RESOURCE, res, resources[res]);