Bladeren bron

Merge pull request #2750 from Nordsoft91/editor-improvements

Nordsoft91 2 jaren geleden
bovenliggende
commit
a0fead361b

+ 3 - 0
lib/mapObjects/CGObjectInstance.cpp

@@ -341,6 +341,9 @@ void CGObjectInstance::serializeJsonOptions(JsonSerializeFormat & handler)
 
 void CGObjectInstance::serializeJsonOwner(JsonSerializeFormat & handler)
 {
+	if(handler.saving && tempOwner == PlayerColor::NEUTRAL)
+		return;
+	
 	ui8 temp = tempOwner.getNum();
 
 	handler.serializeEnum("owner", temp, PlayerColor::NEUTRAL.getNum(), GameConstants::PLAYER_COLOR_NAMES);

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

+ 13 - 2
mapeditor/inspector/inspector.cpp

@@ -118,7 +118,10 @@ void Initializer::initialize(CGHeroInstance * o)
 	
 	o->tempOwner = defaultPlayer;
 	if(o->ID == Obj::PRISON)
+	{
+		o->subID = 0;
 		o->tempOwner = PlayerColor::NEUTRAL;
+	}
 	
 	if(o->ID == Obj::HERO)
 	{
@@ -184,8 +187,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 = 0; r < GameConstants::RESOURCE_QUANTITY - 1; ++r)
+			o->abandonedMineResources.insert(GameResID(r));
+	}
+	else
+	{
+		o->producedResource = GameResID(o->subID);
+		o->producedQuantity = o->defaultResProduction();
+	}
 }
 
 void Initializer::initialize(CGResource * o)

+ 1 - 0
mapeditor/mapcontroller.cpp

@@ -141,6 +141,7 @@ void MapController::repairMap()
 			{
 				nih->typeName = "prison";
 				nih->subTypeName = "prison";
+				nih->subID = 0;
 			}
 			
 			nih->type = type;