浏览代码

* fixed:
- 0.72d #27
- 0.73 #13

mateuszb 16 年之前
父节点
当前提交
9d531b0d84
共有 5 个文件被更改,包括 21 次插入21 次删除
  1. 12 12
      client/CBattleInterface.cpp
  2. 2 2
      client/CBattleInterface.h
  3. 1 7
      client/CPlayerInterface.cpp
  4. 3 0
      client/GUIClasses.cpp
  5. 3 0
      lib/CGameState.cpp

+ 12 - 12
client/CBattleInterface.cpp

@@ -86,11 +86,7 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
 	std::map<int, CStack> stacks = LOCPLINT->cb->battleGetStacks();
 	for(std::map<int, CStack>::iterator b=stacks.begin(); b!=stacks.end(); ++b)
 	{
-		std::pair <int, int> coords = CBattleHex::getXYUnitAnim(b->second.position, b->second.owner == attackingHeroInstance->tempOwner, &b->second);
-		creAnims[b->second.ID] = (new CCreatureAnimation(b->second.creature->animDefName));
-		creAnims[b->second.ID]->setType(2);
-		creAnims[b->second.ID]->pos = genRect(creAnims[b->second.ID]->fullHeight, creAnims[b->second.ID]->fullWidth, coords.first, coords.second);
-		creDir[b->second.ID] = b->second.owner==attackingHeroInstance->tempOwner;
+		newStack(b->second.ID);
 	}
 	//preparing menu background and terrain
 	std::vector< std::string > & backref = graphics->battleBacks[ LOCPLINT->cb->battleGetBattlefieldType() ];
@@ -998,17 +994,21 @@ void CBattleInterface::bConsoleDownf()
 	console->scrollDown();
 }
 
-void CBattleInterface::newStack(CStack stack)
+void CBattleInterface::newStack(int stackID)
 {
-	creAnims[stack.ID] = new CCreatureAnimation(stack.creature->animDefName);
-	creAnims[stack.ID]->setType(2);
-	creDir[stack.ID] = stack.owner==attackingHeroInstance->tempOwner;
+	const CStack * newStack = LOCPLINT->cb->battleGetStackByID(stackID);
+
+	std::pair <int, int> coords = CBattleHex::getXYUnitAnim(newStack->position, newStack->owner == attackingHeroInstance->tempOwner, newStack);
+	creAnims[stackID] = (new CCreatureAnimation(newStack->creature->animDefName));
+	creAnims[stackID]->setType(2);
+	creAnims[stackID]->pos = genRect(creAnims[newStack->ID]->fullHeight, creAnims[newStack->ID]->fullWidth, coords.first, coords.second);
+	creDir[stackID] = newStack->owner == attackingHeroInstance->tempOwner;
 }
 
-void CBattleInterface::stackRemoved(CStack stack)
+void CBattleInterface::stackRemoved(int stackID)
 {
-	delete creAnims[stack.ID];
-	creAnims.erase(stack.ID);
+	delete creAnims[stackID];
+	creAnims.erase(stackID);
 }
 
 void CBattleInterface::stackActivated(int number)

+ 2 - 2
client/CBattleInterface.h

@@ -281,8 +281,8 @@ public:
 	};
 
 	//call-ins
-	void newStack(CStack stack); //new stack appeared on battlefield
-	void stackRemoved(CStack stack); //stack disappeared from batlefiled
+	void newStack(int stackID); //new stack appeared on battlefield
+	void stackRemoved(int stackID); //stack disappeared from batlefiled
 	//void stackKilled(int ID, int dmg, int killed, int IDby, bool byShooting); //stack has been killed (but corpses remain)
 	void stackActivated(int number); //active stack has been changed
 	void stackMoved(int number, int destHex, bool endMoving, int distance); //stack with id number moved to destHex

+ 1 - 7
client/CPlayerInterface.cpp

@@ -976,14 +976,8 @@ void CPlayerInterface::battleStacksHealedRes(const std::vector<std::pair<ui32, u
 
 void CPlayerInterface::battleNewStackAppeared(int stackID)
 {
-	const CStack * newStack = cb->battleGetStackByID(stackID);
-
 	//changing necessary things in battle interface
-	std::pair <int, int> coords = CBattleHex::getXYUnitAnim(newStack->position, newStack->owner == battleInt->attackingHeroInstance->tempOwner, newStack);
-	battleInt->creAnims[newStack->ID] = (new CCreatureAnimation(newStack->creature->animDefName));
-	battleInt->creAnims[newStack->ID]->setType(2);
-	battleInt->creAnims[newStack->ID]->pos = genRect(battleInt->creAnims[newStack->ID]->fullHeight, battleInt->creAnims[newStack->ID]->fullWidth, coords.first, coords.second);
-	battleInt->creDir[newStack->ID] = newStack->owner == battleInt->attackingHeroInstance->tempOwner;
+	battleInt->newStack(stackID);
 }
 
 void CPlayerInterface::battleNewRound(int round) //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn

+ 3 - 0
client/GUIClasses.cpp

@@ -3125,6 +3125,9 @@ void CInGameConsole::keyPressed (const SDL_KeyboardEvent & key)
 		}
 	case SDLK_UP: //up arrow
 		{
+			if(previouslyEntered.size() == 0)
+				break;
+
 			if(prevEntDisp == -1)
 			{
 				prevEntDisp = previouslyEntered.size() - 1;

+ 3 - 0
lib/CGameState.cpp

@@ -411,6 +411,9 @@ std::vector<int> BattleInfo::getAccessibility(int stackID, bool addOccupiable)
 bool BattleInfo::isStackBlocked(int ID)
 {
 	CStack *our = getStack(ID);
+	if(our->hasFeatureOfType(StackFeature::SIEGE_WEAPON)) //siege weapons cannot be blocked
+		return true;
+
 	for(unsigned int i=0; i<stacks.size();i++)
 	{
 		if( !stacks[i]->alive()