1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Fix abandoned map crash

This commit is contained in:
nordsoft 2023-09-03 23:41:57 +04:00
parent e2b5ff13f1
commit 8406e3e4cd
2 changed files with 12 additions and 3 deletions

View File

@ -196,6 +196,8 @@ public:
GameResID producedResource;
ui32 producedQuantity;
std::set<GameResID> abandonedMineResources;
bool isAbandoned() const;
private:
void onHeroVisit(const CGHeroInstance * h) const override;
@ -209,7 +211,6 @@ private:
std::string getObjectName() const override;
std::string getHoverText(PlayerColor player) const override;
bool isAbandoned() const;
public:
template <typename Handler> void serialize(Handler &h, const int version)
{

View File

@ -184,8 +184,16 @@ void Initializer::initialize(CGMine * o)
if(!o) return;
o->tempOwner = defaultPlayer;
o->producedResource = GameResID(o->subID);
o->producedQuantity = o->defaultResProduction();
if(o->isAbandoned())
{
for(auto r = GameResID(0); r < GameResID::COUNT; ++r)
o->abandonedMineResources.insert(r);
}
else
{
o->producedResource = GameResID(o->subID);
o->producedQuantity = o->defaultResProduction();
}
}
void Initializer::initialize(CGResource * o)