Browse Source

Fix minimap updating on hero loss

Ivan Savenko 2 years ago
parent
commit
72fe1fcfa9

+ 6 - 0
client/CPlayerInterface.cpp

@@ -1530,6 +1530,12 @@ void CPlayerInterface::objectRemoved(const CGObjectInstance * obj)
 	}
 }
 
+void CPlayerInterface::objectRemovedAfter()
+{
+	EVENT_HANDLER_CALLED_BY_CLIENT;
+	adventureInt->minimap->update();
+}
+
 void CPlayerInterface::playerBlocked(int reason, bool start)
 {
 	if(reason == PlayerBlocked::EReason::UPCOMING_BATTLE)

+ 1 - 0
client/CPlayerInterface.h

@@ -176,6 +176,7 @@ public:
 	void centerView (int3 pos, int focusTime) override;
 	void objectPropertyChanged(const SetObjectProperty * sop) override;
 	void objectRemoved(const CGObjectInstance *obj) override;
+	void objectRemovedAfter() override;
 	void playerBlocked(int reason, bool start) override;
 	void gameOver(PlayerColor player, const EVictoryLossCheckResult & victoryLossCheckResult) override;
 	void playerStartsTurn(PlayerColor player) override; //called before yourTurn on active itnerface

+ 2 - 0
client/NetPacksClient.cpp

@@ -429,6 +429,8 @@ void ApplyFirstClientNetPackVisitor::visitRemoveObject(RemoveObject & pack)
 void ApplyClientNetPackVisitor::visitRemoveObject(RemoveObject & pack)
 {
 	cl.invalidatePaths();
+	for(auto i=cl.playerint.begin(); i!=cl.playerint.end(); i++)
+		i->second->objectRemovedAfter();
 }
 
 void ApplyFirstClientNetPackVisitor::visitTryMoveHero(TryMoveHero & pack)

+ 1 - 0
lib/IGameEventsReceiver.h

@@ -127,6 +127,7 @@ public:
 	virtual void requestRealized(PackageApplied *pa){};
 	virtual void objectPropertyChanged(const SetObjectProperty * sop){}; //eg. mine has been flagged
 	virtual void objectRemoved(const CGObjectInstance *obj){}; //eg. collected resource, picked artifact, beaten hero
+	virtual void objectRemovedAfter(){}; //eg. collected resource, picked artifact, beaten hero
 	virtual void playerBlocked(int reason, bool start){}; //reason: 0 - upcoming battle
 	virtual void gameOver(PlayerColor player, const EVictoryLossCheckResult & victoryLossCheckResult) {}; //player lost or won the game
 	virtual void playerStartsTurn(PlayerColor player){};

+ 1 - 1
lib/NetPacksLib.cpp

@@ -2016,7 +2016,7 @@ void NewTurn::applyGs(CGameState *gs)
 
 	for(const auto & re : res)
 	{
-		assert(i->first < PlayerColor::PLAYER_LIMIT);
+		assert(re.first < PlayerColor::PLAYER_LIMIT);
 		gs->getPlayerState(re.first)->resources = re.second;
 	}