Browse Source

Fix abandoned map crash

nordsoft 2 years ago
parent
commit
385202a02a
2 changed files with 12 additions and 3 deletions
  1. 2 1
      lib/mapObjects/MiscObjects.h
  2. 10 2
      mapeditor/inspector/inspector.cpp

+ 2 - 1
lib/mapObjects/MiscObjects.h

@@ -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)
 	{

+ 10 - 2
mapeditor/inspector/inspector.cpp

@@ -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)