Browse Source

Extending hero info callback

Allow to check battle enemy hero details + adding max spell points to available data
dydzio 9 years ago
parent
commit
d831c087d9
3 changed files with 12 additions and 1 deletions
  1. 10 0
      lib/CGameInfoCallback.cpp
  2. 1 0
      lib/CGameState.cpp
  3. 1 1
      lib/CGameStateFwd.h

+ 10 - 0
lib/CGameInfoCallback.cpp

@@ -273,6 +273,16 @@ bool CGameInfoCallback::getHeroInfo(const CGObjectInstance * hero, InfoAboutHero
 
 	bool accessFlag = hasAccess(h->tempOwner);
 
+	if (!accessFlag && gs->curB) //if it's battle we can get enemy hero full data
+	{
+		ui8 playerSide = gs->curB->playerToSide(*player);
+		if (playerSide >= 0)
+		{
+			if (gs->curB->sides[!playerSide].hero == h)
+				accessFlag = true;
+		}
+	}
+
 	if(!accessFlag && nullptr != selectedObject)
 	{
 		const CGHeroInstance * selectedHero = dynamic_cast<const CGHeroInstance *>(selectedObject);

+ 1 - 0
lib/CGameState.cpp

@@ -3044,6 +3044,7 @@ void InfoAboutHero::initFromHero(const CGHeroInstance *h, bool detailed)
 		details->luck = h->LuckVal();
 		details->morale = h->MoraleVal();
 		details->mana = h->mana;
+		details->manaLimit = h->manaLimit();
 		details->primskills.resize(GameConstants::PRIMARY_SKILLS);
 
 		for (int i = 0; i < GameConstants::PRIMARY_SKILLS ; i++)

+ 1 - 1
lib/CGameStateFwd.h

@@ -48,7 +48,7 @@ public:
 	struct DLL_LINKAGE Details
 	{
 		std::vector<si32> primskills;
-		si32 mana, luck, morale;
+		si32 mana, manaLimit, luck, morale;
 	} *details;
 
 	const CHeroClass *hclass;