瀏覽代碼

Development

nordsoft 3 年之前
父節點
當前提交
48925a50f2
共有 5 個文件被更改,包括 17 次插入3 次删除
  1. 1 0
      lib/battle/BattleInfo.cpp
  2. 1 0
      lib/battle/BattleInfo.h
  3. 1 1
      server/CGameHandler.cpp
  4. 10 2
      server/CQuery.cpp
  5. 4 0
      server/CQuery.h

+ 1 - 0
lib/battle/BattleInfo.cpp

@@ -206,6 +206,7 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, TerrainId terrain, const
 	curB->battlefieldType = battlefieldType;
 	curB->round = -2;
 	curB->activeStack = -1;
+	curB->creatureBank = creatureBank;
 
 	if(town)
 	{

+ 1 - 0
lib/battle/BattleInfo.h

@@ -34,6 +34,7 @@ public:
 	si32 round, activeStack;
 	const CGTownInstance * town; //used during town siege, nullptr if this is not a siege (note that fortless town IS also a siege)
 	int3 tile; //for background and bonuses
+	bool creatureBank; //auxilary field, do not serialize
 	std::vector<CStack*> stacks;
 	std::vector<std::shared_ptr<CObstacleInstance> > obstacles;
 	SiegeInfo si;

+ 1 - 1
server/CGameHandler.cpp

@@ -819,7 +819,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance * heroAttacker, con
 		}
 	}
 	
-	auto battleDialogQuery = std::make_shared<CDialogQuery>(this);
+	auto battleDialogQuery = std::make_shared<CBattleDialogQuery>(this, battleQuery->bi);
 	battleResult.data->queryID = battleDialogQuery->queryID;
 	queries.addQuery(battleDialogQuery);
 	sendAndApply(battleResult.data); //after this point casualties objects are destroyed

+ 10 - 2
server/CQuery.cpp

@@ -379,14 +379,22 @@ bool CGarrisonDialogQuery::blocksPack(const CPack * pack) const
 
 	return CDialogQuery::blocksPack(pack);
 }
+	
+CBattleDialogQuery::CBattleDialogQuery(CGameHandler * owner, const BattleInfo * Bi):
+	CDialogQuery(owner)
+{
+	bi = Bi;
+	
+	for(auto & side : bi->sides)
+		addPlayer(side.color);
+}
 
 void CBattleDialogQuery::onRemoval(PlayerColor color)
 {
 	assert(answer);
 	if(*answer == 1)
 	{
-		int a = 0;
-		++a;
+		gh->startBattlePrimary(bi->sides[0].armyObject, bi->sides[1].armyObject, bi->tile, bi->sides[0].hero, bi->sides[1].hero, bi->creatureBank, bi->town);
 	}
 }
 

+ 4 - 0
server/CQuery.h

@@ -147,6 +147,10 @@ public:
 class CBattleDialogQuery : public CDialogQuery
 {
 public:
+	CBattleDialogQuery(CGameHandler * owner, const BattleInfo * Bi);
+	
+	const BattleInfo * bi;
+	
 	virtual void onRemoval(PlayerColor color) override;
 };