Browse Source

Compile fix for Kingdom Overview

Fixed common crash with gained exp, fixed necromancy.
DjWarmonger 14 years ago
parent
commit
2047862eb1
2 changed files with 41 additions and 40 deletions
  1. 19 18
      client/CKingdomInterface.cpp
  2. 22 22
      server/CGameHandler.cpp

+ 19 - 18
client/CKingdomInterface.cpp

@@ -10,6 +10,7 @@
 #include "../lib/CCreatureHandler.h" //creatures name for objects list
 #include "../lib/CGeneralTextHandler.h"
 #include "../lib/CObjectHandler.h" //Hero/Town objects
+#include "../lib/CHeroHandler.h" // only for calculating required xp? worth it?
 #include "AdventureMapButton.h"
 #include "CAnimation.h" //CAnimImage
 #include "CAdvmapInterface.h" //CResDataBar
@@ -435,29 +436,29 @@ InfoBoxCustom::InfoBoxCustom(std::string ValueText, std::string NameText, std::s
 {
 }
 
-std::string InfoBoxCustom::getHoverText()
+std::string InfoBoxCustom::getHoverText()
 {
-	return hoverText;
-}
-
-size_t InfoBoxCustom::getImageIndex()
+	return hoverText;
+}
+
+size_t InfoBoxCustom::getImageIndex()
 {
-	return imageIndex;
-}
-
-std::string InfoBoxCustom::getImageName(InfoBox::InfoSize size)
+	return imageIndex;
+}
+
+std::string InfoBoxCustom::getImageName(InfoBox::InfoSize size)
 {
-	return imageName;
-}
-
-std::string InfoBoxCustom::getNameText()
+	return imageName;
+}
+
+std::string InfoBoxCustom::getNameText()
 {
-	return nameText;
-}
-
-std::string InfoBoxCustom::getValueText()
+	return nameText;
+}
+
+std::string InfoBoxCustom::getValueText()
 {
-	return valueText;
+	return valueText;
 }
 
 bool InfoBoxCustom::prepareMessage(std::string &text, SComponent **comp)

+ 22 - 22
server/CGameHandler.cpp

@@ -414,6 +414,27 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
 		sendAndApply(&iw);
 		sendAndApply(&cs);
 	}
+	// Necromancy if applicable.
+	const CGHeroInstance *winnerHero = battleResult.data->winner != 0 ? hero2 : hero1;
+	const CGHeroInstance *loserHero = battleResult.data->winner != 0 ? hero1 : hero2;
+
+	if (winnerHero) 
+	{
+		CStackBasicDescriptor raisedStack = winnerHero->calculateNecromancy(*battleResult.data);
+
+		// Give raised units to winner and show dialog, if any were raised.
+		if (raisedStack.type) 
+		{
+			TSlot slot = winnerHero->getSlotFor(raisedStack.type);
+
+			if (slot != -1) 
+			{
+				winnerHero->showNecromancyDialog(raisedStack);
+				addToSlot(StackLocation(winnerHero, slot), raisedStack.type, raisedStack.count);
+			}
+		}
+	}
+
 
 	if(!duel)
 	{
@@ -449,27 +470,6 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
 		return;
 	}
 
-	// Necromancy if applicable.
-	const CGHeroInstance *winnerHero = battleResult.data->winner != 0 ? hero2 : hero1;
-	const CGHeroInstance *loserHero = battleResult.data->winner != 0 ? hero1 : hero2;
-
-	if (winnerHero) 
-	{
-		CStackBasicDescriptor raisedStack = winnerHero->calculateNecromancy(*battleResult.data);
-
-		// Give raised units to winner and show dialog, if any were raised.
-		if (raisedStack.type) 
-		{
-			TSlot slot = winnerHero->getSlotFor(raisedStack.type);
-
-			if (slot != -1) 
-			{
-				winnerHero->showNecromancyDialog(raisedStack);
-				addToSlot(StackLocation(winnerHero, slot), raisedStack.type, raisedStack.count);
-			}
-		}
-	}
-
 	if(visitObjectAfterVictory && winnerHero == hero1)
 	{
 		visitObjectOnTile(*getTile(winnerHero->getPosition()), winnerHero);
@@ -506,8 +506,8 @@ void CGameHandler::afterBattleCallback() //object interaction after leveling up
 		(*battleEndCallback)(battleResult.data);
 		delete battleEndCallback;
 		battleEndCallback = 0;
+		delete battleResult.data; //remove only after battle
 	}
-	delete battleResult.data;
 }
 void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CStack *def, int distance, int targetHex)
 {