1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Fix object clearing

This commit is contained in:
nordsoft
2023-05-04 15:03:18 +04:00
parent 92dcfd1f68
commit 9984351302
3 changed files with 6 additions and 22 deletions

View File

@@ -322,7 +322,6 @@ void CTownRewardableBuilding::newTurn(CRandomGenerator & rand) const
}
if(configuration.resetParameters.visitors)
{
cb->setObjProperty(town->id, ObjProperty::REWARD_CLEARED, indexOnTV);
cb->setObjProperty(town->id, ObjProperty::STRUCTURE_CLEAR_VISITORS, indexOnTV);
}
}
@@ -344,9 +343,6 @@ void CTownRewardableBuilding::setProperty(ui8 what, ui32 val)
case ObjProperty::REWARD_SELECT:
selectedReward = val;
break;
case ObjProperty::REWARD_CLEARED:
onceVisitableObjectCleared = val;
break;
}
}
@@ -359,12 +355,6 @@ void CTownRewardableBuilding::blockingDialogAnswered(const CGHeroInstance *hero,
{
if(visitors.find(hero->id) != visitors.end())
return; // query not for this building
if(answer == 0)
{
cb->setObjProperty(town->id, ObjProperty::STRUCTURE_CLEAR_VISITORS, indexOnTV);
return; // player refused
}
if(answer > 0 && answer-1 < configuration.info.size())
{
@@ -397,7 +387,7 @@ bool CTownRewardableBuilding::wasVisitedBefore(const CGHeroInstance * contextHer
case Rewardable::VISIT_UNLIMITED:
return false;
case Rewardable::VISIT_ONCE:
return onceVisitableObjectCleared;
return !visitors.empty();
case Rewardable::VISIT_PLAYER:
return false; //not supported
case Rewardable::VISIT_BONUS:

View File

@@ -109,9 +109,7 @@ class DLL_LINKAGE CTownRewardableBuilding : public CGTownBuilding, public Reward
{
/// reward selected by player, no serialize
ui16 selectedReward = 0;
bool onceVisitableObjectCleared = false;
std::set<ObjectInstanceID> visitors;
bool wasVisitedBefore(const CGHeroInstance * contextHero) const;
@@ -139,7 +137,6 @@ public:
{
h & static_cast<CGTownBuilding&>(*this);
h & static_cast<Rewardable::Interface&>(*this);
h & onceVisitableObjectCleared;
h & visitors;
}
};

View File

@@ -71,9 +71,6 @@ void CGTownInstance::setPropertyDer(ui8 what, ui32 val)
case ObjProperty::REWARD_RANDOMIZE:
bonusingBuildings[val]->setProperty(ObjProperty::REWARD_RANDOMIZE, 0);
break;
case ObjProperty::REWARD_CLEARED:
bonusingBuildings[val]->setProperty(ObjProperty::REWARD_CLEARED, false);
break;
}
}
CGTownInstance::EFortLevel CGTownInstance::fortLevel() const //0 - none, 1 - fort, 2 - citadel, 3 - castle
@@ -506,15 +503,15 @@ void CGTownInstance::newTurn(CRandomGenerator & rand) const
for(const auto * manaVortex : getBonusingBuildings(BuildingSubID::MANA_VORTEX))
cb->setObjProperty(id, ObjProperty::STRUCTURE_CLEAR_VISITORS, manaVortex->indexOnTV); //reset visitors for Mana Vortex
//get Mana Vortex or Stables bonuses
//same code is in the CGameHandler::buildStructure method
if (visitingHero != nullptr)
cb->visitCastleObjects(this, visitingHero);
if (garrisonHero != nullptr)
cb->visitCastleObjects(this, garrisonHero);
if (tempOwner == PlayerColor::NEUTRAL) //garrison growth for neutral towns
{
std::vector<SlotID> nativeCrits; //slots
@@ -550,7 +547,7 @@ void CGTownInstance::newTurn(CRandomGenerator & rand) const
TQuantity count = creatureGrowth(i);
if (!count) // no dwelling
count = VLC->creh->objects[c]->getGrowth();
count = VLC->creatures()->getByIndex(c)->getGrowth();
{//no lower tiers or above current month