From f8c67517077262aa8c0f298ff10f1374c2f5e39d Mon Sep 17 00:00:00 2001 From: Arseniy Shestakov Date: Mon, 22 Feb 2016 03:35:38 +0300 Subject: [PATCH] CGameHandler::endBattle: change town ownership when hero lost siege --- server/CGameHandler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 7d8a8b894..a7c4a94ec 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -673,8 +673,12 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer } if(battleResult.data->winner!=1 && hero2) { + auto town = hero2->visitedTown; RemoveObject ro(hero2->id); sendAndApply(&ro); + + if(town && !town->garrisonHero) // TODO: that must be called from CGHeroInstance or CGTownInstance + town->battleFinished(hero1, *battleResult.get()); } //give exp