From 5cbf5031ea35d4300acb5daa2f8572ace34ea2b2 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Tue, 24 Oct 2023 01:27:52 +0300 Subject: [PATCH] move SetStackEffect to a separate file --- AI/BattleAI/StackWithBonuses.cpp | 1 + cmake_modules/VCMI_lib.cmake | 1 + lib/networkPacks/NetPackVisitor.h | 1 + lib/networkPacks/NetPacksLib.cpp | 1 + lib/networkPacks/PacksForClientBattle.h | 22 ------------- lib/networkPacks/SetStackEffect.h | 42 ++++++++++++++++++++++++ lib/registerTypes/RegisterTypes.h | 1 + lib/spells/BattleSpellMechanics.cpp | 1 + lib/spells/effects/Clone.cpp | 1 + lib/spells/effects/Dispel.cpp | 1 + lib/spells/effects/Timed.cpp | 1 + server/ServerSpellCastEnvironment.cpp | 1 + server/battles/BattleActionProcessor.cpp | 1 + test/game/CGameStateTest.cpp | 1 + test/spells/effects/EffectFixture.cpp | 1 + 15 files changed, 55 insertions(+), 22 deletions(-) create mode 100644 lib/networkPacks/SetStackEffect.h diff --git a/AI/BattleAI/StackWithBonuses.cpp b/AI/BattleAI/StackWithBonuses.cpp index 2de2fd498..7beabf514 100644 --- a/AI/BattleAI/StackWithBonuses.cpp +++ b/AI/BattleAI/StackWithBonuses.cpp @@ -15,6 +15,7 @@ #include "../../lib/CStack.h" #include "../../lib/ScriptHandler.h" #include "../../lib/networkPacks/PacksForClientBattle.h" +#include "../../lib/networkPacks/SetStackEffect.h" #if SCRIPTING_ENABLED using scripting::Pool; diff --git a/cmake_modules/VCMI_lib.cmake b/cmake_modules/VCMI_lib.cmake index 1d7ac1aa2..4654082d6 100644 --- a/cmake_modules/VCMI_lib.cmake +++ b/cmake_modules/VCMI_lib.cmake @@ -488,6 +488,7 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE) ${MAIN_LIB_DIR}/networkPacks/PacksForClientBattle.h ${MAIN_LIB_DIR}/networkPacks/PacksForLobby.h ${MAIN_LIB_DIR}/networkPacks/PacksForServer.h + ${MAIN_LIB_DIR}/networkPacks/SetStackEffect.h ${MAIN_LIB_DIR}/networkPacks/StackLocation.h ${MAIN_LIB_DIR}/pathfinder/INodeStorage.h diff --git a/lib/networkPacks/NetPackVisitor.h b/lib/networkPacks/NetPackVisitor.h index 08f7c13e0..72d8dce9d 100644 --- a/lib/networkPacks/NetPackVisitor.h +++ b/lib/networkPacks/NetPackVisitor.h @@ -13,6 +13,7 @@ #include "PacksForClientBattle.h" #include "PacksForServer.h" #include "PacksForLobby.h" +#include "SetStackEffect.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/networkPacks/NetPacksLib.cpp b/lib/networkPacks/NetPacksLib.cpp index 251c39180..a15553cc5 100644 --- a/lib/networkPacks/NetPacksLib.cpp +++ b/lib/networkPacks/NetPacksLib.cpp @@ -14,6 +14,7 @@ #include "PacksForServer.h" #include "StackLocation.h" #include "PacksForLobby.h" +#include "SetStackEffect.h" #include "NetPackVisitor.h" #include "CGeneralTextHandler.h" #include "CArtHandler.h" diff --git a/lib/networkPacks/PacksForClientBattle.h b/lib/networkPacks/PacksForClientBattle.h index d52ea6483..ad0878fe9 100644 --- a/lib/networkPacks/PacksForClientBattle.h +++ b/lib/networkPacks/PacksForClientBattle.h @@ -398,28 +398,6 @@ struct DLL_LINKAGE BattleSpellCast : public CPackForClient } }; -struct DLL_LINKAGE SetStackEffect : public CPackForClient -{ - void applyGs(CGameState * gs); - void applyBattle(IBattleState * battleState); - - BattleID battleID = BattleID::NONE; - std::vector>> toAdd; - std::vector>> toUpdate; - std::vector>> toRemove; - - void visitTyped(ICPackVisitor & visitor) override; - - template void serialize(Handler & h, const int version) - { - h & battleID; - h & toAdd; - h & toUpdate; - h & toRemove; - assert(battleID != BattleID::NONE); - } -}; - struct DLL_LINKAGE StacksInjured : public CPackForClient { void applyGs(CGameState * gs); diff --git a/lib/networkPacks/SetStackEffect.h b/lib/networkPacks/SetStackEffect.h new file mode 100644 index 000000000..f53b4cfe2 --- /dev/null +++ b/lib/networkPacks/SetStackEffect.h @@ -0,0 +1,42 @@ +/* + * SetStackEffect.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#pragma once + +#include "NetPacksBase.h" + +#include "../bonuses/Bonus.h" + +VCMI_LIB_NAMESPACE_BEGIN + +class IBattleState; + +struct DLL_LINKAGE SetStackEffect : public CPackForClient +{ + void applyGs(CGameState * gs); + void applyBattle(IBattleState * battleState); + + BattleID battleID = BattleID::NONE; + std::vector>> toAdd; + std::vector>> toUpdate; + std::vector>> toRemove; + + void visitTyped(ICPackVisitor & visitor) override; + + template void serialize(Handler & h, const int version) + { + h & battleID; + h & toAdd; + h & toUpdate; + h & toRemove; + assert(battleID != BattleID::NONE); + } +}; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/registerTypes/RegisterTypes.h b/lib/registerTypes/RegisterTypes.h index 7f5c086dc..907361a40 100644 --- a/lib/registerTypes/RegisterTypes.h +++ b/lib/registerTypes/RegisterTypes.h @@ -13,6 +13,7 @@ #include "../networkPacks/PacksForClientBattle.h" #include "../networkPacks/PacksForServer.h" #include "../networkPacks/PacksForLobby.h" +#include "../networkPacks/SetStackEffect.h" #include "../VCMI_Lib.h" #include "../CArtHandler.h" #include "../CCreatureSet.h" diff --git a/lib/spells/BattleSpellMechanics.cpp b/lib/spells/BattleSpellMechanics.cpp index 36ce8dd96..fc333fc93 100644 --- a/lib/spells/BattleSpellMechanics.cpp +++ b/lib/spells/BattleSpellMechanics.cpp @@ -17,6 +17,7 @@ #include "../battle/IBattleState.h" #include "../battle/CBattleInfoCallback.h" #include "../networkPacks/PacksForClientBattle.h" +#include "../networkPacks/SetStackEffect.h" #include "../CStack.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/spells/effects/Clone.cpp b/lib/spells/effects/Clone.cpp index d54d33caf..491fe5023 100644 --- a/lib/spells/effects/Clone.cpp +++ b/lib/spells/effects/Clone.cpp @@ -16,6 +16,7 @@ #include "../../battle/IBattleState.h" #include "../../battle/CUnitState.h" #include "../../networkPacks/PacksForClientBattle.h" +#include "../../networkPacks/SetStackEffect.h" #include "../../serializer/JsonSerializeFormat.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/spells/effects/Dispel.cpp b/lib/spells/effects/Dispel.cpp index c2765cc40..3fb418acd 100644 --- a/lib/spells/effects/Dispel.cpp +++ b/lib/spells/effects/Dispel.cpp @@ -22,6 +22,7 @@ #include "../../battle/Unit.h" #include "../../bonuses/BonusList.h" #include "../../networkPacks/PacksForClientBattle.h" +#include "../../networkPacks/SetStackEffect.h" #include "../../serializer/JsonSerializeFormat.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/spells/effects/Timed.cpp b/lib/spells/effects/Timed.cpp index 33d8e6cdf..e006d37a4 100644 --- a/lib/spells/effects/Timed.cpp +++ b/lib/spells/effects/Timed.cpp @@ -19,6 +19,7 @@ #include "../../battle/Unit.h" #include "../../mapObjects/CGHeroInstance.h" #include "../../networkPacks/PacksForClientBattle.h" +#include "../../networkPacks/SetStackEffect.h" #include "../../serializer/JsonSerializeFormat.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/server/ServerSpellCastEnvironment.cpp b/server/ServerSpellCastEnvironment.cpp index ae57ebbff..b89b9ad8f 100644 --- a/server/ServerSpellCastEnvironment.cpp +++ b/server/ServerSpellCastEnvironment.cpp @@ -16,6 +16,7 @@ #include "../lib/gameState/CGameState.h" #include "../lib/networkPacks/PacksForClientBattle.h" +#include "../lib/networkPacks/SetStackEffect.h" ///ServerSpellCastEnvironment ServerSpellCastEnvironment::ServerSpellCastEnvironment(CGameHandler * gh) diff --git a/server/battles/BattleActionProcessor.cpp b/server/battles/BattleActionProcessor.cpp index 293b119e3..80242a49c 100644 --- a/server/battles/BattleActionProcessor.cpp +++ b/server/battles/BattleActionProcessor.cpp @@ -23,6 +23,7 @@ #include "../../lib/battle/BattleAction.h" #include "../../lib/gameState/CGameState.h" #include "../../lib/networkPacks/PacksForClientBattle.h" +#include "../../lib/networkPacks/SetStackEffect.h" #include "../../lib/spells/AbilityCaster.h" #include "../../lib/spells/CSpellHandler.h" #include "../../lib/spells/ISpellMechanics.h" diff --git a/test/game/CGameStateTest.cpp b/test/game/CGameStateTest.cpp index 42e595eec..02222e712 100644 --- a/test/game/CGameStateTest.cpp +++ b/test/game/CGameStateTest.cpp @@ -18,6 +18,7 @@ #include "../../lib/gameState/CGameState.h" #include "../../lib/networkPacks/PacksForClient.h" #include "../../lib/networkPacks/PacksForClientBattle.h" +#include "../../lib/networkPacks/SetStackEffect.h" #include "../../lib/StartInfo.h" #include "../../lib/TerrainHandler.h" diff --git a/test/spells/effects/EffectFixture.cpp b/test/spells/effects/EffectFixture.cpp index 2b122d85e..88d1ed2f4 100644 --- a/test/spells/effects/EffectFixture.cpp +++ b/test/spells/effects/EffectFixture.cpp @@ -14,6 +14,7 @@ #include #include "../../../lib/networkPacks/PacksForClientBattle.h" +#include "../../../lib/networkPacks/SetStackEffect.h" #include "../../../lib/serializer/JsonDeserializer.h"