Переглянути джерело

Garrisoned hero is now attached to townAndVis node, not to town itself

Ivan Savenko 3 місяців тому
батько
коміт
9070db4a96

+ 0 - 9
docs/images/Bonus_System_Nodes.gv

@@ -68,13 +68,6 @@ digraph mygraph {
 					<tr><td>Hero that is currently<br/>visiting owned or allied town</td></tr>
 				</table>>
 		]
-		"Garrisoned Hero" [
-			fillcolor="#80808080"
-			label =<<table>
-					<tr><td><b>Garrisoned Hero</b></td></tr>
-					<tr><td>Hero that is currently<br/>placed in a garrison of owned town</td></tr>
-				</table>>
-		]
 		"Wandering Hero" [
 			fillcolor="#80808080"
 			label =<<table>
@@ -253,13 +246,11 @@ digraph mygraph {
 	"Creature Type" -> "Summon in Combat"
 	"Creature Type" -> "Unit in Army"
 
-	"Town" -> "Garrisoned Hero"
 	"Town" -> "Army"
 	"Neutral Army" -> "Army"
 	"Owned Army" -> "Army"
 
 	"Visiting Hero" -> "Hero"
-	"Garrisoned Hero" -> "Hero"
 	"Wandering Hero" -> "Hero"
 	"Hero" -> "Army"
 }

+ 2 - 2
lib/gameState/GameStatePackVisitor.cpp

@@ -1181,7 +1181,7 @@ void GameStatePackVisitor::visitBattleStart(BattleStart & pack)
 		CGTownInstance * town = gs.getTown(pack.info->townID);
 		CGHeroInstance * hero = gs.getHero(pack.info->getSideHero(BattleSide::DEFENDER)->id);
 
-		if (town->getVisitingHero() == hero)
+		if (hero)
 		{
 			hero->detachFrom(town->townAndVis);
 			hero->attachTo(*town);
@@ -1366,7 +1366,7 @@ void GameStatePackVisitor::restorePreBattleState(BattleID battleID)
 		CGTownInstance * town = gs.getTown(currentBattle.townID);
 		CGHeroInstance * hero = gs.getHero(currentBattle.getSideHero(BattleSide::DEFENDER)->id);
 
-		if (town->getVisitingHero() == hero)
+		if (hero)
 		{
 			hero->detachFrom(*town);
 			hero->attachTo(town->townAndVis);

+ 1 - 4
lib/mapObjects/CGHeroInstance.cpp

@@ -1355,10 +1355,7 @@ CBonusSystemNode & CGHeroInstance::whereShouldBeAttached(CGameState & gs)
 	if(visitedTown.hasValue())
 	{
 		auto town = gs.getTown(visitedTown);
-		if(isGarrisoned())
-			return *town;
-		else
-			return town->townAndVis;
+		return town->townAndVis;
 	}
 	else
 		return CArmedInstance::whereShouldBeAttached(gs);