Explorar o código

Since filename extensions are omitted, GARRISON.TXT was hiding GARRISON.BMP. I've added a crude workaround (ignore the first file since it's not used).

Fixed #613.
Michał W. Urbańczyk %!s(int64=15) %!d(string=hai) anos
pai
achega
5004c1188b
Modificáronse 3 ficheiros con 9 adicións e 5 borrados
  1. 4 3
      client/CBattleInterface.cpp
  2. 1 1
      client/CBattleInterface.h
  3. 4 1
      hch/CLodHandler.cpp

+ 4 - 3
client/CBattleInterface.cpp

@@ -2921,18 +2921,19 @@ void CBattleInterface::activateStack()
 {
 	activeStack = stackToActivate;
 	stackToActivate = -1;
+	const CStack *s = LOCPLINT->cb->battleGetStackByID(activeStack);
 
 	myTurn = true;
 	if(attackerInt && defenderInt) //hotseat -> need to pick which interface "takes over" as active
-		curInt = attackerInt->playerID == LOCPLINT->cb->battleGetStackByID(activeStack)->owner ? attackerInt : defenderInt;
+		curInt = attackerInt->playerID == s->owner ? attackerInt : defenderInt;
 
 	queue->update();
 	redrawBackgroundWithHexes(activeStack);
-	bWait->block(vstd::contains(curInt->cb->battleGetStackByID(activeStack)->state, WAITING)); //block waiting button if stack has been already waiting
+	bWait->block(vstd::contains(s->state, WAITING)); //block waiting button if stack has been already waiting
 
 	//block cast spell button if hero doesn't have a spellbook
 	bSpell->block(!curInt->cb->battleCanCastSpell());
-	bSurrender->block(!curInt->cb->battleCanFlee());
+	bSurrender->block((curInt == attackerInt ? defendingHeroInstance : attackingHeroInstance) == NULL);
 	bFlee->block(!curInt->cb->battleCanFlee());
 
 	GH.fakeMouseMove();

+ 1 - 1
client/CBattleInterface.h

@@ -385,7 +385,7 @@ private:
 	CBattleHero * attackingHero, * defendingHero; //fighting heroes
 	CStackQueue *queue;
 	CCreatureSet army1, army2; //copy of initial armies (for result window)
-	CGHeroInstance * attackingHeroInstance, * defendingHeroInstance;
+	const CGHeroInstance * attackingHeroInstance, * defendingHeroInstance;
 	std::map< int, CCreatureAnimation * > creAnims; //animations of creatures from fighting armies (order by BattleInfo's stacks' ID)
 	std::map< int, CDefHandler * > idToProjectile; //projectiles of creatures (creatureID, defhandler)
 	std::map< int, CDefHandler * > idToObstacle; //obstacles located on the battlefield

+ 4 - 1
hch/CLodHandler.cpp

@@ -242,7 +242,10 @@ void CLodHandler::init(std::string lodFile, std::string dirName)
 		//format string: upper-case, remove extension
 		std::transform(entry.nameStr.begin(), entry.nameStr.end(), 
 					   entry.nameStr.begin(), toupper);
-					   
+		
+		if(entry.nameStr == "GARRISON.TXT") //crude workaround -> there are both GARRISON.TXT and GARRSION.BMP, since we ommit extensions, first one (not used by VCMI) would overwrite the second
+			continue;
+
 		size_t dotPos = entry.nameStr.find_last_of('.');
 		if ( dotPos < entry.nameStr.size() )
 		{