Browse Source

Fix spawned wandering monsters not correctly attached to bonus system

Ivan Savenko 10 months ago
parent
commit
14320fb100
2 changed files with 8 additions and 1 deletions
  1. 3 1
      lib/CCreatureSet.h
  2. 5 0
      lib/networkPacks/NetPacksLib.cpp

+ 3 - 1
lib/CCreatureSet.h

@@ -93,7 +93,9 @@ public:
 		h & static_cast<CArtifactSet&>(*this);
 		h & _armyObj;
 		h & experience;
-		BONUS_TREE_DESERIALIZATION_FIX
+
+		if(!h.saving)
+			deserializationFix();
 	}
 
 	void serializeJson(JsonSerializeFormat & handler);

+ 5 - 0
lib/networkPacks/NetPacksLib.cpp

@@ -1503,6 +1503,11 @@ void NewObject::applyGs(CGameState *gs)
 	gs->map->addBlockVisTiles(newObject);
 	gs->map->calculateGuardingGreaturePositions();
 
+	// attach newly spawned wandering monster to global bonus system node
+	auto newArmy = dynamic_cast<CArmedInstance*>(newObject);
+	if (newArmy)
+		newArmy->whatShouldBeAttached().attachTo(newArmy->whereShouldBeAttached(gs));
+
 	logGlobal->debug("Added object id=%d; name=%s", newObject->id, newObject->getObjectName());
 }