Pārlūkot izejas kodu

Added a way to obtain ID of newly added Stack

AlexVinS 11 gadi atpakaļ
vecāks
revīzija
f2bf3d7f7b
5 mainītis faili ar 10 papildinājumiem un 6 dzēšanām
  1. 3 3
      lib/CSpellHandler.h
  2. 3 0
      lib/NetPacks.h
  3. 3 0
      lib/NetPacksLib.cpp
  4. 0 2
      lib/SpellMechanics.h
  5. 1 1
      server/CGameHandler.cpp

+ 3 - 3
lib/CSpellHandler.h

@@ -72,9 +72,9 @@ public:
 	struct LevelInfo
 	{
 		std::string description; //descriptions of spell for skill level
-		si32 cost; //per skill level: 0 - none, 1 - basic, etc
-		si32 power; //per skill level: 0 - none, 1 - basic, etc
-		si32 AIValue; //AI values: per skill level: 0 - none, 1 - basic, etc
+		si32 cost;
+		si32 power;
+		si32 AIValue;
 
 		bool smartTarget;
 		bool clearTarget;

+ 3 - 0
lib/NetPacks.h

@@ -1578,6 +1578,9 @@ struct BattleStackAdded : public CPackForClient //3017
 	int amount;
 	int pos;
 	int summoned; //if true, remove it afterwards
+	
+	///Actual stack ID, set on apply, do not serialize
+	int newStackID; 
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{

+ 3 - 0
lib/NetPacksLib.cpp

@@ -1590,6 +1590,7 @@ DLL_LINKAGE void BattleStacksRemoved::applyGs( CGameState *gs )
 
 DLL_LINKAGE void BattleStackAdded::applyGs(CGameState *gs)
 {
+	newStackID = 0;
 	if (!BattleHex(pos).isValid())
 	{
         logNetwork->warnStream() << "No place found for new stack!";
@@ -1603,6 +1604,8 @@ DLL_LINKAGE void BattleStackAdded::applyGs(CGameState *gs)
 
 	gs->curB->localInitStack(addedStack);
 	gs->curB->stacks.push_back(addedStack); //the stack is not "SUMMONED", it is permanent
+	
+	newStackID = addedStack->ID;
 }
 
 DLL_LINKAGE void BattleSetStackProperty::applyGs(CGameState *gs)

+ 0 - 2
lib/SpellMechanics.h

@@ -69,8 +69,6 @@ public:
 	bool battleCast(const SpellCastContext & context) const override; 
 };
 
-
-
 class WallMechanics: public DefaultSpellMechanics
 {
 public:

+ 1 - 1
server/CGameHandler.cpp

@@ -4353,7 +4353,7 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
 			sendAndApply (&bsa);
 
 			BattleSetStackProperty ssp;
-			ssp.stackID = gs->curB->stacks.back()->ID; //how to get recent stack?
+			ssp.stackID = bsa.newStackID;
 			ssp.which = BattleSetStackProperty::CLONED; //using enum values
 			ssp.val = 0;
 			ssp.absolute = 1;