瀏覽代碼

Merge pull request #3100 from IvanSavenko/split_net_packs

Split netpacks.h into multiple files
Ivan Savenko 2 年之前
父節點
當前提交
0169c65937
共有 100 個文件被更改,包括 3398 次插入3172 次删除
  1. 2 1
      AI/BattleAI/StackWithBonuses.cpp
  2. 5 1
      AI/Nullkiller/AIGateway.cpp
  3. 3 2
      AI/VCAI/VCAI.cpp
  4. 2 1
      CCallback.cpp
  5. 4 2
      client/CPlayerInterface.cpp
  6. 0 1
      client/CServerHandler.cpp
  7. 1 1
      client/ClientCommandManager.cpp
  8. 1 1
      client/ClientNetPackVisitors.h
  9. 1 1
      client/HeroMovementController.cpp
  10. 3 1
      client/LobbyClientNetPackVisitors.h
  11. 0 1
      client/NetPacksLobbyClient.cpp
  12. 1 0
      client/adventureMap/CInfoBar.h
  13. 1 1
      client/battle/BattleEffectsController.cpp
  14. 1 1
      client/battle/BattleInterface.cpp
  15. 1 1
      client/battle/BattleInterfaceClasses.cpp
  16. 1 1
      client/battle/BattleSiegeController.cpp
  17. 1 1
      client/lobby/CLobbyScreen.cpp
  18. 0 1
      client/lobby/CSelectionBase.cpp
  19. 1 1
      client/lobby/OptionsTab.cpp
  20. 0 1
      client/lobby/SelectionTab.cpp
  21. 0 1
      client/mainmenu/CMainMenu.cpp
  22. 1 0
      client/widgets/CArtifactHolder.cpp
  23. 2 1
      client/widgets/CArtifactsOfHeroAltar.cpp
  24. 1 0
      client/widgets/CArtifactsOfHeroBackpack.cpp
  25. 1 0
      client/widgets/CArtifactsOfHeroBase.cpp
  26. 1 0
      client/widgets/CArtifactsOfHeroKingdom.cpp
  27. 2 1
      client/widgets/CArtifactsOfHeroMain.cpp
  28. 1 1
      client/widgets/CComponent.cpp
  29. 1 0
      client/widgets/CGarrisonInt.cpp
  30. 1 0
      client/widgets/CWindowWithArtifacts.cpp
  31. 1 0
      client/windows/CCreatureWindow.cpp
  32. 1 1
      client/windows/CHeroWindow.cpp
  33. 1 0
      client/windows/CTradeWindow.cpp
  34. 17 5
      cmake_modules/VCMI_lib.cmake
  35. 1 1
      lib/CArtifactInstance.cpp
  36. 0 1
      lib/CCreatureSet.cpp
  37. 2 1
      lib/CGameInfoCallback.cpp
  38. 1 1
      lib/CStack.cpp
  39. 1 1
      lib/IGameCallback.cpp
  40. 1 2
      lib/IGameEventsReceiver.h
  41. 0 2778
      lib/NetPacks.h
  42. 0 286
      lib/NetPacksBase.h
  43. 1 1
      lib/battle/BattleInfo.cpp
  44. 1 1
      lib/battle/CBattleInfoCallback.cpp
  45. 2 1
      lib/battle/CBattleInfoEssentials.cpp
  46. 0 1
      lib/battle/CObstacleInstance.cpp
  47. 2 1
      lib/battle/CObstacleInstance.h
  48. 1 1
      lib/battle/CUnitState.cpp
  49. 0 1
      lib/battle/Unit.cpp
  50. 1 2
      lib/events/ApplyDamage.cpp
  51. 5 1
      lib/mapObjects/CBank.cpp
  52. 4 1
      lib/mapObjects/CGCreature.cpp
  53. 4 1
      lib/mapObjects/CGDwelling.cpp
  54. 2 1
      lib/mapObjects/CGHeroInstance.cpp
  55. 1 1
      lib/mapObjects/CGMarket.cpp
  56. 1 1
      lib/mapObjects/CGObjectInstance.cpp
  57. 3 0
      lib/mapObjects/CGObjectInstance.h
  58. 3 1
      lib/mapObjects/CGPandoraBox.cpp
  59. 2 1
      lib/mapObjects/CGTownBuilding.cpp
  60. 4 1
      lib/mapObjects/CGTownInstance.cpp
  61. 1 0
      lib/mapObjects/CObjectHandler.cpp
  62. 2 1
      lib/mapObjects/CQuest.cpp
  63. 2 1
      lib/mapObjects/CRewardableObject.cpp
  64. 2 1
      lib/mapObjects/IObjectInterface.cpp
  65. 5 1
      lib/mapObjects/IObjectInterface.h
  66. 4 1
      lib/mapObjects/MiscObjects.cpp
  67. 2 0
      lib/mapping/MapFormatH3M.cpp
  68. 76 0
      lib/networkPacks/ArtifactLocation.h
  69. 81 0
      lib/networkPacks/BattleChanges.h
  70. 54 0
      lib/networkPacks/Component.h
  71. 22 0
      lib/networkPacks/EInfoWindowMode.h
  72. 28 0
      lib/networkPacks/EOpenWindowMode.h
  73. 33 0
      lib/networkPacks/EntityChanges.h
  74. 5 2
      lib/networkPacks/NetPackVisitor.h
  75. 85 0
      lib/networkPacks/NetPacksBase.h
  76. 6 1
      lib/networkPacks/NetPacksLib.cpp
  77. 1536 0
      lib/networkPacks/PacksForClient.h
  78. 557 0
      lib/networkPacks/PacksForClientBattle.h
  79. 23 24
      lib/networkPacks/PacksForLobby.h
  80. 669 0
      lib/networkPacks/PacksForServer.h
  81. 42 0
      lib/networkPacks/SetStackEffect.h
  82. 40 0
      lib/networkPacks/StackLocation.h
  83. 5 2
      lib/registerTypes/RegisterTypes.h
  84. 0 1
      lib/registerTypes/TypesClientPacks1.cpp
  85. 0 1
      lib/registerTypes/TypesClientPacks2.cpp
  86. 0 1
      lib/registerTypes/TypesLobbyPacks.cpp
  87. 0 1
      lib/registerTypes/TypesMapObjects1.cpp
  88. 0 1
      lib/registerTypes/TypesMapObjects2.cpp
  89. 0 1
      lib/registerTypes/TypesMapObjects3.cpp
  90. 0 1
      lib/registerTypes/TypesServerPacks.cpp
  91. 1 1
      lib/rewardable/Configuration.h
  92. 4 1
      lib/rewardable/Interface.cpp
  93. 1 0
      lib/rewardable/Limiter.cpp
  94. 1 0
      lib/rewardable/Reward.h
  95. 3 3
      lib/spells/AdventureSpellMechanics.cpp
  96. 2 2
      lib/spells/BattleSpellMechanics.cpp
  97. 0 1
      lib/spells/ISpellMechanics.cpp
  98. 0 1
      lib/spells/ObstacleCasterProxy.h
  99. 1 1
      lib/spells/effects/Catapult.cpp
  100. 2 1
      lib/spells/effects/Clone.cpp

+ 2 - 1
AI/BattleAI/StackWithBonuses.cpp

@@ -12,9 +12,10 @@
 
 #include <vcmi/events/EventBus.h>
 
-#include "../../lib/NetPacks.h"
 #include "../../lib/CStack.h"
 #include "../../lib/ScriptHandler.h"
+#include "../../lib/networkPacks/PacksForClientBattle.h"
+#include "../../lib/networkPacks/SetStackEffect.h"
 
 #if SCRIPTING_ENABLED
 using scripting::Pool;

+ 5 - 1
AI/Nullkiller/AIGateway.cpp

@@ -12,14 +12,18 @@
 #include "../../lib/UnlockGuard.h"
 #include "../../lib/mapObjects/MapObjects.h"
 #include "../../lib/mapObjects/ObjectTemplate.h"
+#include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/CHeroHandler.h"
 #include "../../lib/GameSettings.h"
 #include "../../lib/gameState/CGameState.h"
-#include "../../lib/NetPacks.h"
 #include "../../lib/serializer/CTypeList.h"
 #include "../../lib/serializer/BinarySerializer.h"
 #include "../../lib/serializer/BinaryDeserializer.h"
+#include "../../lib/networkPacks/PacksForClient.h"
+#include "../../lib/networkPacks/PacksForClientBattle.h"
+#include "../../lib/networkPacks/PacksForServer.h"
+#include "../../lib/networkPacks/StackLocation.h"
 #include "../../lib/battle/BattleStateInfoForRetreat.h"
 #include "../../lib/battle/BattleInfo.h"
 

+ 3 - 2
AI/VCAI/VCAI.cpp

@@ -21,12 +21,13 @@
 #include "../../lib/CHeroHandler.h"
 #include "../../lib/GameSettings.h"
 #include "../../lib/gameState/CGameState.h"
-#include "../../lib/NetPacksBase.h"
-#include "../../lib/NetPacks.h"
 #include "../../lib/bonuses/CBonusSystemNode.h"
 #include "../../lib/bonuses/Limiters.h"
 #include "../../lib/bonuses/Updaters.h"
 #include "../../lib/bonuses/Propagators.h"
+#include "../../lib/networkPacks/PacksForClient.h"
+#include "../../lib/networkPacks/PacksForClientBattle.h"
+#include "../../lib/networkPacks/PacksForServer.h"
 #include "../../lib/serializer/CTypeList.h"
 #include "../../lib/serializer/BinarySerializer.h"
 #include "../../lib/serializer/BinaryDeserializer.h"

+ 2 - 1
CCallback.cpp

@@ -15,15 +15,16 @@
 #include "client/CPlayerInterface.h"
 #include "client/Client.h"
 #include "lib/mapping/CMap.h"
+#include "lib/mapObjects/CGHeroInstance.h"
 #include "lib/CBuildingHandler.h"
 #include "lib/CGeneralTextHandler.h"
 #include "lib/CHeroHandler.h"
-#include "lib/NetPacks.h"
 #include "lib/CArtHandler.h"
 #include "lib/GameConstants.h"
 #include "lib/CPlayerState.h"
 #include "lib/UnlockGuard.h"
 #include "lib/battle/BattleInfo.h"
+#include "lib/networkPacks/PacksForServer.h"
 
 bool CCallback::teleportHero(const CGHeroInstance *who, const CGTownInstance *where)
 {

+ 4 - 2
client/CPlayerInterface.cpp

@@ -73,8 +73,6 @@
 #include "../lib/CondSh.h"
 #include "../lib/GameConstants.h"
 #include "../lib/JsonNode.h"
-#include "../lib/NetPacks.h" //todo: remove
-#include "../lib/NetPacksBase.h"
 #include "../lib/RoadHandler.h"
 #include "../lib/StartInfo.h"
 #include "../lib/TerrainHandler.h"
@@ -95,6 +93,10 @@
 
 #include "../lib/mapping/CMapHeader.h"
 
+#include "../lib/networkPacks/PacksForClient.h"
+#include "../lib/networkPacks/PacksForClientBattle.h"
+#include "../lib/networkPacks/PacksForServer.h"
+
 #include "../lib/pathfinder/CGPathNode.h"
 
 #include "../lib/serializer/BinaryDeserializer.h"

+ 0 - 1
client/CServerHandler.cpp

@@ -38,7 +38,6 @@
 #include "../lib/CConfigHandler.h"
 #include "../lib/CGeneralTextHandler.h"
 #include "../lib/CThreadHelper.h"
-#include "../lib/NetPackVisitor.h"
 #include "../lib/StartInfo.h"
 #include "../lib/TurnTimerInfo.h"
 #include "../lib/VCMIDirs.h"

+ 1 - 1
client/ClientCommandManager.cpp

@@ -18,7 +18,6 @@
 #include "gui/CGuiHandler.h"
 #include "gui/WindowHandler.h"
 #include "render/IRenderHandler.h"
-#include "../lib/NetPacks.h"
 #include "ClientNetPackVisitors.h"
 #include "../lib/CConfigHandler.h"
 #include "../lib/gameState/CGameState.h"
@@ -28,6 +27,7 @@
 #include "../lib/mapping/CMapService.h"
 #include "../lib/mapping/CMap.h"
 #include "windows/CCastleInterface.h"
+#include "../lib/mapObjects/CGHeroInstance.h"
 #include "render/CAnimation.h"
 #include "../CCallback.h"
 #include "../lib/CGeneralTextHandler.h"

+ 1 - 1
client/ClientNetPackVisitors.h

@@ -9,7 +9,7 @@
  */
 #pragma once
 
-#include "../lib/NetPackVisitor.h"
+#include "../lib/networkPacks/NetPackVisitor.h"
 
 class CClient;
 

+ 1 - 1
client/HeroMovementController.cpp

@@ -24,9 +24,9 @@
 
 #include "../lib/pathfinder/CGPathNode.h"
 #include "../lib/mapObjects/CGHeroInstance.h"
+#include "../lib/networkPacks/PacksForClient.h"
 #include "../lib/RoadHandler.h"
 #include "../lib/TerrainHandler.h"
-#include "../lib/NetPacks.h"
 
 bool HeroMovementController::isHeroMovingThroughGarrison(const CGHeroInstance * hero, const CArmedInstance * garrison) const
 {

+ 3 - 1
client/LobbyClientNetPackVisitors.h

@@ -9,9 +9,11 @@
  */
 #pragma once
 
-#include "../lib/NetPackVisitor.h"
+#include "../lib/networkPacks/NetPackVisitor.h"
+#include "../lib/networkPacks/PacksForLobby.h"
 
 class CClient;
+class CLobbyScreen;
 VCMI_LIB_NAMESPACE_BEGIN
 class CGameState;
 VCMI_LIB_NAMESPACE_END

+ 0 - 1
client/NetPacksLobbyClient.cpp

@@ -27,7 +27,6 @@
 
 #include "../lib/CConfigHandler.h"
 #include "../lib/CGeneralTextHandler.h"
-#include "../lib/NetPacksLobby.h"
 #include "../lib/serializer/Connection.h"
 
 void ApplyOnLobbyHandlerNetPackVisitor::visitLobbyClientConnected(LobbyClientConnected & pack)

+ 1 - 0
client/adventureMap/CInfoBar.h

@@ -12,6 +12,7 @@
 #include "../gui/CIntObject.h"
 #include "CConfigHandler.h"
 #include "../../lib/filesystem/ResourcePath.h"
+#include "../../lib/networkPacks/Component.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 1 - 1
client/battle/BattleEffectsController.cpp

@@ -28,7 +28,7 @@
 #include "../../CCallback.h"
 #include "../../lib/battle/BattleAction.h"
 #include "../../lib/filesystem/ResourcePath.h"
-#include "../../lib/NetPacks.h"
+#include "../../lib/networkPacks/PacksForClientBattle.h"
 #include "../../lib/CStack.h"
 #include "../../lib/IGameEventsReceiver.h"
 #include "../../lib/CGeneralTextHandler.h"

+ 1 - 1
client/battle/BattleInterface.cpp

@@ -40,7 +40,7 @@
 #include "../../lib/CondSh.h"
 #include "../../lib/gameState/InfoAboutArmy.h"
 #include "../../lib/mapObjects/CGTownInstance.h"
-#include "../../lib/NetPacks.h"
+#include "../../lib/networkPacks/PacksForClientBattle.h"
 #include "../../lib/UnlockGuard.h"
 #include "../../lib/TerrainHandler.h"
 #include "../../lib/CThreadHelper.h"

+ 1 - 1
client/battle/BattleInterfaceClasses.cpp

@@ -48,10 +48,10 @@
 #include "../../lib/CGeneralTextHandler.h"
 #include "../../lib/CTownHandler.h"
 #include "../../lib/CHeroHandler.h"
-#include "../../lib/NetPacks.h"
 #include "../../lib/StartInfo.h"
 #include "../../lib/CondSh.h"
 #include "../../lib/mapObjects/CGTownInstance.h"
+#include "../../lib/networkPacks/PacksForClientBattle.h"
 #include "../../lib/TextOperations.h"
 
 void BattleConsole::showAll(Canvas & to)

+ 1 - 1
client/battle/BattleSiegeController.cpp

@@ -26,9 +26,9 @@
 #include "../render/IRenderHandler.h"
 
 #include "../../CCallback.h"
-#include "../../lib/NetPacks.h"
 #include "../../lib/CStack.h"
 #include "../../lib/mapObjects/CGTownInstance.h"
+#include "../../lib/networkPacks/PacksForClientBattle.h"
 
 ImagePath BattleSiegeController::getWallPieceImageName(EWallVisual::EWallVisual what, EWallState state) const
 {

+ 1 - 1
client/lobby/CLobbyScreen.cpp

@@ -25,7 +25,7 @@
 #include "../../CCallback.h"
 
 #include "../CGameInfo.h"
-#include "../../lib/NetPacksLobby.h"
+#include "../../lib/networkPacks/PacksForLobby.h"
 #include "../../lib/CGeneralTextHandler.h"
 #include "../../lib/campaign/CampaignHandler.h"
 #include "../../lib/mapping/CMapInfo.h"

+ 0 - 1
client/lobby/CSelectionBase.cpp

@@ -41,7 +41,6 @@
 #include "../render/IFont.h"
 #include "../render/IRenderHandler.h"
 
-#include "../../lib/NetPacksLobby.h"
 #include "../../lib/CGeneralTextHandler.h"
 #include "../../lib/CHeroHandler.h"
 #include "../../lib/CThreadHelper.h"

+ 1 - 1
client/lobby/OptionsTab.cpp

@@ -34,7 +34,7 @@
 #include "../eventsSDL/InputHandler.h"
 
 #include "../../lib/filesystem/Filesystem.h"
-#include "../../lib/NetPacksLobby.h"
+#include "../../lib/networkPacks/PacksForLobby.h"
 #include "../../lib/CGeneralTextHandler.h"
 #include "../../lib/CArtHandler.h"
 #include "../../lib/CTownHandler.h"

+ 0 - 1
client/lobby/SelectionTab.cpp

@@ -34,7 +34,6 @@
 
 #include "../../CCallback.h"
 
-#include "../../lib/NetPacksLobby.h"
 #include "../../lib/CGeneralTextHandler.h"
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/GameSettings.h"

+ 0 - 1
client/mainmenu/CMainMenu.cpp

@@ -51,7 +51,6 @@
 #include "../../lib/mapping/CMapInfo.h"
 #include "../../lib/VCMIDirs.h"
 #include "../../lib/CStopWatch.h"
-#include "../../lib/NetPacksLobby.h"
 #include "../../lib/CThreadHelper.h"
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/GameConstants.h"

+ 1 - 0
client/widgets/CArtifactHolder.cpp

@@ -26,6 +26,7 @@
 #include "../../lib/CGeneralTextHandler.h"
 #include "../../lib/ArtifactUtils.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
+#include "../../lib/networkPacks/ArtifactLocation.h"
 #include "../../lib/CConfigHandler.h"
 
 void CArtPlace::setInternals(const CArtifactInstance * artInst)

+ 2 - 1
client/widgets/CArtifactsOfHeroAltar.cpp

@@ -16,6 +16,7 @@
 
 #include "../../lib/ArtifactUtils.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
+#include "../../lib/networkPacks/ArtifactLocation.h"
 
 CArtifactsOfHeroAltar::CArtifactsOfHeroAltar(const Point & position)
 	: visibleArtSet(ArtBearer::ArtBearer::HERO)
@@ -109,4 +110,4 @@ void CArtifactsOfHeroAltar::deleteFromVisible(const CArtifactInstance * artInst)
 				getArtPlace(part.slot)->setArtifact(nullptr);
 		}
 	}
-}
+}

+ 1 - 0
client/widgets/CArtifactsOfHeroBackpack.cpp

@@ -18,6 +18,7 @@
 
 #include "../CPlayerInterface.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
+#include "../../lib/networkPacks/ArtifactLocation.h"
 
 #include "../../CCallback.h"
 

+ 1 - 0
client/widgets/CArtifactsOfHeroBase.cpp

@@ -22,6 +22,7 @@
 
 #include "../../lib/ArtifactUtils.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
+#include "../../lib/networkPacks/ArtifactLocation.h"
 
 CArtifactsOfHeroBase::CArtifactsOfHeroBase()
 	: backpackPos(0),

+ 1 - 0
client/widgets/CArtifactsOfHeroKingdom.cpp

@@ -15,6 +15,7 @@
 #include "../CPlayerInterface.h"
 
 #include "../../CCallback.h"
+#include "../../lib/networkPacks/ArtifactLocation.h"
 
 CArtifactsOfHeroKingdom::CArtifactsOfHeroKingdom(ArtPlaceMap ArtWorn, std::vector<ArtPlacePtr> Backpack,
 	std::shared_ptr<CButton> leftScroll, std::shared_ptr<CButton> rightScroll)

+ 2 - 1
client/widgets/CArtifactsOfHeroMain.cpp

@@ -13,6 +13,7 @@
 #include "../CPlayerInterface.h"
 
 #include "../../CCallback.h"
+#include "../../lib/networkPacks/ArtifactLocation.h"
 
 CArtifactsOfHeroMain::CArtifactsOfHeroMain(const Point & position)
 {
@@ -37,4 +38,4 @@ void CArtifactsOfHeroMain::pickUpArtifact(CHeroArtPlace & artPlace)
 {
 	LOCPLINT->cb->swapArtifacts(ArtifactLocation(curHero, artPlace.slot),
 		ArtifactLocation(curHero, ArtifactPosition::TRANSITION_POS));
-}
+}

+ 1 - 1
client/widgets/CComponent.cpp

@@ -31,11 +31,11 @@
 #include "../../lib/ArtifactUtils.h"
 #include "../../lib/CTownHandler.h"
 #include "../../lib/CHeroHandler.h"
+#include "../../lib/networkPacks/Component.h"
 #include "../../lib/spells/CSpellHandler.h"
 #include "../../lib/CCreatureHandler.h"
 #include "../../lib/CSkillHandler.h"
 #include "../../lib/CGeneralTextHandler.h"
-#include "../../lib/NetPacksBase.h"
 #include "../../lib/CArtHandler.h"
 #include "../../lib/CArtifactInstance.h"
 

+ 1 - 0
client/widgets/CGarrisonInt.cpp

@@ -30,6 +30,7 @@
 #include "../../lib/CCreatureHandler.h"
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
+#include "../../lib/networkPacks/ArtifactLocation.h"
 #include "../../lib/TextOperations.h"
 #include "../../lib/gameState/CGameState.h"
 

+ 1 - 0
client/widgets/CWindowWithArtifacts.cpp

@@ -29,6 +29,7 @@
 #include "../../lib/ArtifactUtils.h"
 #include "../../lib/CGeneralTextHandler.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
+#include "../../lib/networkPacks/ArtifactLocation.h"
 #include "../../lib/CConfigHandler.h"
 
 void CWindowWithArtifacts::addSet(CArtifactsOfHeroPtr artSet)

+ 1 - 0
client/windows/CCreatureWindow.cpp

@@ -33,6 +33,7 @@
 #include "../../lib/GameSettings.h"
 #include "../../lib/CHeroHandler.h"
 #include "../../lib/gameState/CGameState.h"
+#include "../../lib/networkPacks/ArtifactLocation.h"
 #include "../../lib/TextOperations.h"
 
 class CCreatureArtifactInstance;

+ 1 - 1
client/windows/CHeroWindow.cpp

@@ -39,7 +39,7 @@
 #include "../lib/CHeroHandler.h"
 #include "../lib/CSkillHandler.h"
 #include "../lib/mapObjects/CGHeroInstance.h"
-#include "../lib/NetPacksBase.h"
+#include "../../lib/networkPacks/ArtifactLocation.h"
 
 void CHeroSwitcher::clickPressed(const Point & cursorPosition)
 {

+ 1 - 0
client/windows/CTradeWindow.cpp

@@ -35,6 +35,7 @@
 #include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/mapObjects/CGTownInstance.h"
 #include "../../lib/mapObjects/CGMarket.h"
+#include "../../lib/networkPacks/ArtifactLocation.h"
 
 CTradeWindow::CTradeableItem::CTradeableItem(Point pos, EType Type, int ID, bool Left, int Serial)
 	: CIntObject(LCLICK | HOVER | SHOW_POPUP, pos),

+ 17 - 5
cmake_modules/VCMI_lib.cmake

@@ -123,6 +123,8 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE)
 		${MAIN_LIB_DIR}/modding/IdentifierStorage.cpp
 		${MAIN_LIB_DIR}/modding/ModUtility.cpp
 
+		${MAIN_LIB_DIR}/networkPacks/NetPacksLib.cpp
+
 		${MAIN_LIB_DIR}/pathfinder/CGPathNode.cpp
 		${MAIN_LIB_DIR}/pathfinder/CPathfinder.cpp
 		${MAIN_LIB_DIR}/pathfinder/NodeStorage.cpp
@@ -255,7 +257,6 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE)
 		${MAIN_LIB_DIR}/JsonRandom.cpp
 		${MAIN_LIB_DIR}/LoadProgress.cpp
 		${MAIN_LIB_DIR}/LogicalExpression.cpp
-		${MAIN_LIB_DIR}/NetPacksLib.cpp
 		${MAIN_LIB_DIR}/MetaString.cpp
 		${MAIN_LIB_DIR}/ObstacleHandler.cpp
 		${MAIN_LIB_DIR}/StartInfo.cpp
@@ -475,6 +476,21 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE)
 		${MAIN_LIB_DIR}/modding/ModScope.h
 		${MAIN_LIB_DIR}/modding/ModUtility.h
 
+		${MAIN_LIB_DIR}/networkPacks/ArtifactLocation.h
+		${MAIN_LIB_DIR}/networkPacks/BattleChanges.h
+		${MAIN_LIB_DIR}/networkPacks/Component.h
+		${MAIN_LIB_DIR}/networkPacks/EInfoWindowMode.h
+		${MAIN_LIB_DIR}/networkPacks/EntityChanges.h
+		${MAIN_LIB_DIR}/networkPacks/EOpenWindowMode.h
+		${MAIN_LIB_DIR}/networkPacks/NetPacksBase.h
+		${MAIN_LIB_DIR}/networkPacks/NetPackVisitor.h
+		${MAIN_LIB_DIR}/networkPacks/PacksForClient.h
+		${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
 		${MAIN_LIB_DIR}/pathfinder/CGPathNode.h
 		${MAIN_LIB_DIR}/pathfinder/CPathfinder.h
@@ -615,10 +631,6 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE)
 		${MAIN_LIB_DIR}/LoadProgress.h
 		${MAIN_LIB_DIR}/LogicalExpression.h
 		${MAIN_LIB_DIR}/MetaString.h
-		${MAIN_LIB_DIR}/NetPacksBase.h
-		${MAIN_LIB_DIR}/NetPacks.h
-		${MAIN_LIB_DIR}/NetPacksLobby.h
-		${MAIN_LIB_DIR}/NetPackVisitor.h
 		${MAIN_LIB_DIR}/ObstacleHandler.h
 		${MAIN_LIB_DIR}/Point.h
 		${MAIN_LIB_DIR}/Rect.h

+ 1 - 1
lib/CArtifactInstance.cpp

@@ -13,7 +13,7 @@
 
 #include "ArtifactUtils.h"
 #include "CArtHandler.h"
-#include "NetPacksBase.h"
+#include "networkPacks/ArtifactLocation.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 0 - 1
lib/CCreatureSet.cpp

@@ -23,7 +23,6 @@
 #include "CHeroHandler.h"
 #include "IBonusTypeHandler.h"
 #include "serializer/JsonSerializeFormat.h"
-#include "NetPacksBase.h"
 
 #include <vcmi/FactionService.h>
 #include <vcmi/Faction.h>

+ 2 - 1
lib/CGameInfoCallback.cpp

@@ -14,10 +14,11 @@
 #include "gameState/InfoAboutArmy.h"
 #include "gameState/SThievesGuildInfo.h"
 #include "gameState/TavernHeroesPool.h"
+#include "gameState/QuestInfo.h"
+#include "mapObjects/CGHeroInstance.h"
 #include "CGeneralTextHandler.h"
 #include "StartInfo.h" // for StartInfo
 #include "battle/BattleInfo.h" // for BattleInfo
-#include "NetPacks.h" // for InfoWindow
 #include "GameSettings.h"
 #include "TerrainHandler.h"
 #include "spells/CSpellHandler.h"

+ 1 - 1
lib/CStack.cpp

@@ -18,7 +18,7 @@
 #include "CGeneralTextHandler.h"
 #include "battle/BattleInfo.h"
 #include "spells/CSpellHandler.h"
-#include "NetPacks.h"
+#include "networkPacks/PacksForClientBattle.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 1 - 1
lib/IGameCallback.cpp

@@ -13,7 +13,6 @@
 #include "CHeroHandler.h" // for CHeroHandler
 #include "spells/CSpellHandler.h"// for CSpell
 #include "CSkillHandler.h"// for CSkill
-#include "NetPacks.h"
 #include "CBonusTypeHandler.h"
 #include "BattleFieldHandler.h"
 #include "ObstacleHandler.h"
@@ -36,6 +35,7 @@
 #include "gameState/CGameState.h"
 #include "gameState/CGameStateCampaign.h"
 #include "gameState/TavernHeroesPool.h"
+#include "gameState/QuestInfo.h"
 #include "mapping/CMap.h"
 #include "modding/CModHandler.h"
 #include "modding/CModInfo.h"

+ 1 - 2
lib/IGameEventsReceiver.h

@@ -9,8 +9,7 @@
  */
 #pragma once
 
-
-#include "NetPacksBase.h"
+#include "networkPacks/EInfoWindowMode.h"
 #include "battle/BattleHex.h"
 #include "GameConstants.h"
 #include "int3.h"

+ 0 - 2778
lib/NetPacks.h

@@ -1,2778 +0,0 @@
-/*
- * NetPacks.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 "ConstTransitivePtr.h"
-#include "MetaString.h"
-#include "ResourceSet.h"
-#include "TurnTimerInfo.h"
-#include "int3.h"
-
-#include "battle/BattleAction.h"
-#include "battle/CObstacleInstance.h"
-#include "gameState/EVictoryLossCheckResult.h"
-#include "gameState/TavernSlot.h"
-#include "gameState/QuestInfo.h"
-#include "mapObjects/CGHeroInstance.h"
-#include "mapping/CMapDefines.h"
-#include "spells/ViewSpellInt.h"
-
-class CClient;
-class CGameHandler;
-
-VCMI_LIB_NAMESPACE_BEGIN
-
-class CGameState;
-class CArtifact;
-class CGObjectInstance;
-class CArtifactInstance;
-struct StackLocation;
-struct ArtSlotInfo;
-struct QuestInfo;
-class IBattleState;
-class BattleInfo;
-
-// This one teleport-specific, but has to be available everywhere in callbacks and netpacks
-// For now it's will be there till teleports code refactored and moved into own file
-using TTeleportExitsList = std::vector<std::pair<ObjectInstanceID, int3>>;
-
-struct DLL_LINKAGE Query : public CPackForClient
-{
-	QueryID queryID; // equals to -1 if it is not an actual query (and should not be answered)
-};
-
-struct StackLocation
-{
-	ConstTransitivePtr<CArmedInstance> army;
-	SlotID slot;
-
-	StackLocation() = default;
-	StackLocation(const CArmedInstance * Army, const SlotID & Slot)
-		: army(const_cast<CArmedInstance *>(Army))  //we are allowed here to const cast -> change will go through one of our packages... do not abuse!
-		, slot(Slot)
-	{
-	}
-
-	DLL_LINKAGE const CStackInstance * getStack();
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & army;
-		h & slot;
-	}
-};
-
-/***********************************************************************************************************/
-struct DLL_LINKAGE PackageApplied : public CPackForClient
-{
-	PackageApplied() = default;
-	PackageApplied(ui8 Result)
-		: result(Result)
-	{
-	}
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	ui8 result = 0; //0 - something went wrong, request hasn't been realized; 1 - OK
-	ui32 packType = 0; //type id of applied package
-	ui32 requestID = 0; //an ID given by client to the request that was applied
-	PlayerColor player;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & result;
-		h & packType;
-		h & requestID;
-		h & player;
-	}
-};
-
-struct DLL_LINKAGE SystemMessage : public CPackForClient
-{
-	SystemMessage(std::string Text)
-		: text(std::move(Text))
-	{
-	}
-	SystemMessage() = default;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	std::string text;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & text;
-	}
-};
-
-struct DLL_LINKAGE PlayerBlocked : public CPackForClient
-{
-	enum EReason { UPCOMING_BATTLE, ONGOING_MOVEMENT };
-	enum EMode { BLOCKADE_STARTED, BLOCKADE_ENDED };
-
-	EReason reason = UPCOMING_BATTLE;
-	EMode startOrEnd = BLOCKADE_STARTED;
-	PlayerColor player;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & reason;
-		h & startOrEnd;
-		h & player;
-	}
-};
-
-struct DLL_LINKAGE PlayerCheated : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	PlayerColor player;
-	bool losingCheatCode = false;
-	bool winningCheatCode = false;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & player;
-		h & losingCheatCode;
-		h & winningCheatCode;
-	}
-};
-
-struct DLL_LINKAGE TurnTimeUpdate : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-	
-	PlayerColor player;
-	TurnTimerInfo turnTimer;
-		
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & player;
-		h & turnTimer;
-	}
-};
-
-struct DLL_LINKAGE PlayerStartsTurn : public Query
-{
-	void applyGs(CGameState * gs) const;
-
-	PlayerColor player;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & queryID;
-		h & player;
-	}
-};
-
-struct DLL_LINKAGE DaysWithoutTown : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	PlayerColor player;
-	std::optional<int32_t> daysWithoutCastle;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & player;
-		h & daysWithoutCastle;
-	}
-};
-
-struct DLL_LINKAGE EntitiesChanged : public CPackForClient
-{
-	std::vector<EntityChanges> changes;
-
-	void applyGs(CGameState * gs);
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & changes;
-	}
-};
-
-struct DLL_LINKAGE SetResources : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	bool abs = true; //false - changes by value; 1 - sets to value
-	PlayerColor player;
-	TResources res; //res[resid] => res amount
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & abs;
-		h & player;
-		h & res;
-	}
-};
-
-struct DLL_LINKAGE SetPrimSkill : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	ui8 abs = 0; //0 - changes by value; 1 - sets to value
-	ObjectInstanceID id;
-	PrimarySkill which = PrimarySkill::ATTACK;
-	si64 val = 0;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & abs;
-		h & id;
-		h & which;
-		h & val;
-	}
-};
-
-struct DLL_LINKAGE SetSecSkill : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	ui8 abs = 0; //0 - changes by value; 1 - sets to value
-	ObjectInstanceID id;
-	SecondarySkill which;
-	ui16 val = 0;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & abs;
-		h & id;
-		h & which;
-		h & val;
-	}
-};
-
-struct DLL_LINKAGE HeroVisitCastle : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	ui8 flags = 0; //1 - start
-	ObjectInstanceID tid, hid;
-
-	bool start() const //if hero is entering castle (if false - leaving)
-	{
-		return flags & 1;
-	}
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & flags;
-		h & tid;
-		h & hid;
-	}
-};
-
-struct DLL_LINKAGE ChangeSpells : public CPackForClient
-{
-	void applyGs(CGameState * gs);
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	ui8 learn = 1; //1 - gives spell, 0 - takes
-	ObjectInstanceID hid;
-	std::set<SpellID> spells;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & learn;
-		h & hid;
-		h & spells;
-	}
-};
-
-struct DLL_LINKAGE SetMana : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	ObjectInstanceID hid;
-	si32 val = 0;
-	bool absolute = true;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & val;
-		h & hid;
-		h & absolute;
-	}
-};
-
-struct DLL_LINKAGE SetMovePoints : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	ObjectInstanceID hid;
-	si32 val = 0;
-	bool absolute = true;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & val;
-		h & hid;
-		h & absolute;
-	}
-};
-
-struct DLL_LINKAGE FoWChange : public CPackForClient
-{
-	void applyGs(CGameState * gs);
-
-	std::unordered_set<int3> tiles;
-	PlayerColor player;
-	ETileVisibility mode;
-	bool waitForDialogs = false;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & tiles;
-		h & player;
-		h & mode;
-		h & waitForDialogs;
-	}
-};
-
-struct DLL_LINKAGE SetAvailableHero : public CPackForClient
-{
-	SetAvailableHero()
-	{
-		army.clearSlots();
-	}
-	void applyGs(CGameState * gs);
-
-	TavernHeroSlot slotID;
-	TavernSlotRole roleID;
-	PlayerColor player;
-	HeroTypeID hid; //HeroTypeID::NONE if no hero
-	CSimpleArmy army;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & slotID;
-		h & roleID;
-		h & player;
-		h & hid;
-		h & army;
-	}
-};
-
-struct DLL_LINKAGE GiveBonus : public CPackForClient
-{
-	enum class ETarget : ui8 { HERO, PLAYER, TOWN, BATTLE };
-	
-	GiveBonus(ETarget Who = ETarget::HERO)
-		:who(Who)
-	{
-	}
-
-	void applyGs(CGameState * gs);
-
-	ETarget who = ETarget::HERO; //who receives bonus
-	si32 id = 0; //hero. town or player id - whoever receives it
-	Bonus bonus;
-	MetaString bdescr;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & bonus;
-		h & id;
-		h & bdescr;
-		h & who;
-		assert(id != -1);
-	}
-};
-
-struct DLL_LINKAGE ChangeObjPos : public CPackForClient
-{
-	void applyGs(CGameState * gs);
-
-	/// Object to move
-	ObjectInstanceID objid;
-	/// New position of visitable tile of an object
-	int3 nPos;
-	/// Player that initiated this action, if any
-	PlayerColor initiator;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & objid;
-		h & nPos;
-		h & initiator;
-	}
-};
-
-struct DLL_LINKAGE PlayerEndsTurn : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	PlayerColor player;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & player;
-	}
-};
-
-struct DLL_LINKAGE PlayerEndsGame : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	PlayerColor player;
-	EVictoryLossCheckResult victoryLossCheckResult;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & player;
-		h & victoryLossCheckResult;
-	}
-};
-
-struct DLL_LINKAGE PlayerReinitInterface : public CPackForClient
-{
-	void applyGs(CGameState * gs);
-
-	std::vector<PlayerColor> players;
-	ui8 playerConnectionId; //PLAYER_AI for AI player
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & players;
-		h & playerConnectionId;
-	}
-};
-
-struct DLL_LINKAGE RemoveBonus : public CPackForClient
-{
-	RemoveBonus(GiveBonus::ETarget Who = GiveBonus::ETarget::HERO)
-		:who(Who)
-	{
-	}
-
-	void applyGs(CGameState * gs);
-
-	GiveBonus::ETarget who; //who receives bonus
-	ui32 whoID = 0; //hero, town or player id - whoever loses bonus
-
-	//vars to identify bonus: its source
-	BonusSource source;
-	BonusSourceID id; //source id
-
-	//used locally: copy of removed bonus
-	Bonus bonus;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & source;
-		h & id;
-		h & who;
-		h & whoID;
-	}
-};
-
-struct DLL_LINKAGE SetCommanderProperty : public CPackForClient
-{
-	enum ECommanderProperty { ALIVE, BONUS, SECONDARY_SKILL, EXPERIENCE, SPECIAL_SKILL };
-
-	void applyGs(CGameState * gs);
-
-	ObjectInstanceID heroid;
-
-	ECommanderProperty which = ALIVE;
-	TExpType amount = 0; //0 for dead, >0 for alive
-	si32 additionalInfo = 0; //for secondary skills choice
-	Bonus accumulatedBonus;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & heroid;
-		h & which;
-		h & amount;
-		h & additionalInfo;
-		h & accumulatedBonus;
-	}
-};
-
-struct DLL_LINKAGE AddQuest : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	PlayerColor player;
-	QuestInfo quest;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & player;
-		h & quest;
-	}
-};
-
-struct DLL_LINKAGE UpdateArtHandlerLists : public CPackForClient
-{
-	std::map<ArtifactID, int> allocatedArtifacts;
-
-	void applyGs(CGameState * gs) const;
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & allocatedArtifacts;
-	}
-};
-
-struct DLL_LINKAGE UpdateMapEvents : public CPackForClient
-{
-	std::list<CMapEvent> events;
-
-	void applyGs(CGameState * gs) const;
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & events;
-	}
-};
-
-struct DLL_LINKAGE UpdateCastleEvents : public CPackForClient
-{
-	ObjectInstanceID town;
-	std::list<CCastleEvent> events;
-
-	void applyGs(CGameState * gs) const;
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & town;
-		h & events;
-	}
-};
-
-struct DLL_LINKAGE ChangeFormation : public CPackForClient
-{
-	ObjectInstanceID hid;
-	ui8 formation = 0;
-
-	void applyGs(CGameState * gs) const;
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & hid;
-		h & formation;
-	}
-};
-
-struct DLL_LINKAGE RemoveObject : public CPackForClient
-{
-	RemoveObject() = default;
-	RemoveObject(const ObjectInstanceID & objectID, const PlayerColor & initiator)
-		: objectID(objectID)
-		, initiator(initiator)
-	{
-	}
-
-	void applyGs(CGameState * gs);
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	/// ID of removed object
-	ObjectInstanceID objectID;
-
-	/// Player that initiated this action, if any
-	PlayerColor initiator;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & objectID;
-		h & initiator;
-	}
-};
-
-struct DLL_LINKAGE TryMoveHero : public CPackForClient
-{
-	void applyGs(CGameState * gs);
-
-	enum EResult
-	{
-		FAILED,
-		SUCCESS,
-		TELEPORTATION,
-		BLOCKING_VISIT,
-		EMBARK,
-		DISEMBARK
-	};
-
-	ObjectInstanceID id;
-	ui32 movePoints = 0;
-	EResult result = FAILED; //uses EResult
-	int3 start, end; //h3m format
-	std::unordered_set<int3> fowRevealed; //revealed tiles
-	std::optional<int3> attackedFrom; // Set when stepping into endangered tile.
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	bool stopMovement() const
-	{
-		return result != SUCCESS && result != EMBARK && result != DISEMBARK && result != TELEPORTATION;
-	}
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & id;
-		h & result;
-		h & start;
-		h & end;
-		h & movePoints;
-		h & fowRevealed;
-		h & attackedFrom;
-	}
-};
-
-struct DLL_LINKAGE NewStructures : public CPackForClient
-{
-	void applyGs(CGameState * gs);
-
-	ObjectInstanceID tid;
-	std::set<BuildingID> bid;
-	si16 builded = 0;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & tid;
-		h & bid;
-		h & builded;
-	}
-};
-
-struct DLL_LINKAGE RazeStructures : public CPackForClient
-{
-	void applyGs(CGameState * gs);
-
-	ObjectInstanceID tid;
-	std::set<BuildingID> bid;
-	si16 destroyed = 0;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & tid;
-		h & bid;
-		h & destroyed;
-	}
-};
-
-struct DLL_LINKAGE SetAvailableCreatures : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	ObjectInstanceID tid;
-	std::vector<std::pair<ui32, std::vector<CreatureID> > > creatures;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & tid;
-		h & creatures;
-	}
-};
-
-struct DLL_LINKAGE SetHeroesInTown : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	ObjectInstanceID tid, visiting, garrison; //id of town, visiting hero, hero in garrison
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & tid;
-		h & visiting;
-		h & garrison;
-	}
-};
-
-struct DLL_LINKAGE HeroRecruited : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	HeroTypeID hid; //subID of hero
-	ObjectInstanceID tid;
-	ObjectInstanceID boatId;
-	int3 tile;
-	PlayerColor player;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & hid;
-		h & tid;
-		h & boatId;
-		h & tile;
-		h & player;
-	}
-};
-
-struct DLL_LINKAGE GiveHero : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	ObjectInstanceID id; //object id
-	ObjectInstanceID boatId;
-	PlayerColor player;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & id;
-		h & boatId;
-		h & player;
-	}
-};
-
-struct DLL_LINKAGE OpenWindow : public Query
-{
-	EOpenWindowMode window;
-	ObjectInstanceID object;
-	ObjectInstanceID visitor;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & queryID;
-		h & window;
-		h & object;
-		h & visitor;
-	}
-};
-
-struct DLL_LINKAGE NewObject : public CPackForClient
-{
-	void applyGs(CGameState * gs);
-
-	/// Object ID to create
-	Obj ID;
-	/// Object secondary ID to create
-	ui32 subID = 0;
-	/// Position of visitable tile of created object
-	int3 targetPos;
-	/// Which player initiated creation of this object
-	PlayerColor initiator;
-
-	ObjectInstanceID createdObjectID; //used locally, filled during applyGs
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & ID;
-		h & subID;
-		h & targetPos;
-		h & initiator;
-	}
-};
-
-struct DLL_LINKAGE SetAvailableArtifacts : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	si32 id = 0; //two variants: id < 0: set artifact pool for Artifact Merchants in towns; id >= 0: set pool for adv. map Black Market (id is the id of Black Market instance then)
-	std::vector<const CArtifact *> arts;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & id;
-		h & arts;
-	}
-};
-
-struct DLL_LINKAGE CGarrisonOperationPack : CPackForClient
-{
-};
-
-struct DLL_LINKAGE ChangeStackCount : CGarrisonOperationPack
-{
-	ObjectInstanceID army;
-	SlotID slot;
-	TQuantity count;
-	bool absoluteValue; //if not -> count will be added (or subtracted if negative)
-
-	void applyGs(CGameState * gs);
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & army;
-		h & slot;
-		h & count;
-		h & absoluteValue;
-	}
-};
-
-struct DLL_LINKAGE SetStackType : CGarrisonOperationPack
-{
-	ObjectInstanceID army;
-	SlotID slot;
-	CreatureID type;
-
-	void applyGs(CGameState * gs);
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & army;
-		h & slot;
-		h & type;
-	}
-};
-
-struct DLL_LINKAGE EraseStack : CGarrisonOperationPack
-{
-	ObjectInstanceID army;
-	SlotID slot;
-
-	void applyGs(CGameState * gs);
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & army;
-		h & slot;
-	}
-};
-
-struct DLL_LINKAGE SwapStacks : CGarrisonOperationPack
-{
-	ObjectInstanceID srcArmy;
-	ObjectInstanceID dstArmy;
-	SlotID srcSlot;
-	SlotID dstSlot;
-
-	void applyGs(CGameState * gs);
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & srcArmy;
-		h & dstArmy;
-		h & srcSlot;
-		h & dstSlot;
-	}
-};
-
-struct DLL_LINKAGE InsertNewStack : CGarrisonOperationPack
-{
-	ObjectInstanceID army;
-	SlotID slot;
-	CreatureID type;
-	TQuantity count = 0;
-
-	void applyGs(CGameState * gs);
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & army;
-		h & slot;
-		h & type;
-		h & count;
-	}
-};
-
-///moves creatures from src stack to dst slot, may be used for merging/splittint/moving stacks
-struct DLL_LINKAGE RebalanceStacks : CGarrisonOperationPack
-{
-	ObjectInstanceID srcArmy;
-	ObjectInstanceID dstArmy;
-	SlotID srcSlot;
-	SlotID dstSlot;
-
-	TQuantity count;
-
-	void applyGs(CGameState * gs);
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & srcArmy;
-		h & dstArmy;
-		h & srcSlot;
-		h & dstSlot;
-		h & count;
-	}
-};
-
-struct DLL_LINKAGE BulkRebalanceStacks : CGarrisonOperationPack
-{
-	std::vector<RebalanceStacks> moves;
-
-	void applyGs(CGameState * gs);
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler>
-	void serialize(Handler & h, const int version)
-	{
-		h & moves;
-	}
-};
-
-struct DLL_LINKAGE BulkSmartRebalanceStacks : CGarrisonOperationPack
-{
-	std::vector<RebalanceStacks> moves;
-	std::vector<ChangeStackCount> changes;
-
-	void applyGs(CGameState * gs);
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler>
-	void serialize(Handler & h, const int version)
-	{
-		h & moves;
-		h & changes;
-	}
-};
-
-struct GetEngagedHeroIds
-{
-	std::optional<ObjectInstanceID> operator()(const ConstTransitivePtr<CGHeroInstance> & h) const
-	{
-		return h->id;
-	}
-	std::optional<ObjectInstanceID> operator()(const ConstTransitivePtr<CStackInstance> & s) const
-	{
-		if(s->armyObj && s->armyObj->ID == Obj::HERO)
-			return s->armyObj->id;
-		return std::optional<ObjectInstanceID>();
-	}
-};
-
-struct DLL_LINKAGE CArtifactOperationPack : CPackForClient
-{
-};
-
-struct DLL_LINKAGE PutArtifact : CArtifactOperationPack
-{
-	PutArtifact() = default;
-	PutArtifact(ArtifactLocation * dst, bool askAssemble = true)
-		: al(*dst), askAssemble(askAssemble)
-	{
-	}
-
-	ArtifactLocation al;
-	bool askAssemble = false;
-	ConstTransitivePtr<CArtifactInstance> art;
-
-	void applyGs(CGameState * gs);
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & al;
-		h & askAssemble;
-		h & art;
-	}
-};
-
-struct DLL_LINKAGE NewArtifact : public CArtifactOperationPack
-{
-	ConstTransitivePtr<CArtifactInstance> art;
-
-	void applyGs(CGameState * gs);
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & art;
-	}
-};
-
-struct DLL_LINKAGE EraseArtifact : CArtifactOperationPack
-{
-	ArtifactLocation al;
-
-	void applyGs(CGameState * gs);
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & al;
-	}
-};
-
-struct DLL_LINKAGE MoveArtifact : CArtifactOperationPack
-{
-	MoveArtifact() = default;
-	MoveArtifact(ArtifactLocation * src, ArtifactLocation * dst, bool askAssemble = true)
-		: src(*src), dst(*dst), askAssemble(askAssemble)
-	{
-	}
-	ArtifactLocation src, dst;
-	bool askAssemble = true;
-
-	void applyGs(CGameState * gs);
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & src;
-		h & dst;
-		h & askAssemble;
-	}
-};
-
-struct DLL_LINKAGE BulkMoveArtifacts : CArtifactOperationPack
-{
-	struct LinkedSlots
-	{
-		ArtifactPosition srcPos;
-		ArtifactPosition dstPos;
-
-		LinkedSlots() = default;
-		LinkedSlots(const ArtifactPosition & srcPos, const ArtifactPosition & dstPos)
-			: srcPos(srcPos)
-			, dstPos(dstPos)
-		{
-		}
-		template <typename Handler> void serialize(Handler & h, const int version)
-		{
-			h & srcPos;
-			h & dstPos;
-		}
-	};
-
-	TArtHolder srcArtHolder;
-	TArtHolder dstArtHolder;
-
-	BulkMoveArtifacts()
-		: swap(false)
-	{
-	}
-	BulkMoveArtifacts(TArtHolder srcArtHolder, TArtHolder dstArtHolder, bool swap)
-		: srcArtHolder(std::move(std::move(srcArtHolder)))
-		, dstArtHolder(std::move(std::move(dstArtHolder)))
-		, swap(swap)
-	{
-	}
-
-	void applyGs(CGameState * gs);
-
-	std::vector<LinkedSlots> artsPack0;
-	std::vector<LinkedSlots> artsPack1;
-	bool swap;
-	CArtifactSet * getSrcHolderArtSet();
-	CArtifactSet * getDstHolderArtSet();
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & artsPack0;
-		h & artsPack1;
-		h & srcArtHolder;
-		h & dstArtHolder;
-		h & swap;
-	}
-};
-
-struct DLL_LINKAGE AssembledArtifact : CArtifactOperationPack
-{
-	ArtifactLocation al; //where assembly will be put
-	CArtifact * builtArt;
-
-	void applyGs(CGameState * gs);
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & al;
-		h & builtArt;
-	}
-};
-
-struct DLL_LINKAGE DisassembledArtifact : CArtifactOperationPack
-{
-	ArtifactLocation al;
-
-	void applyGs(CGameState * gs);
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & al;
-	}
-};
-
-struct DLL_LINKAGE HeroVisit : public CPackForClient
-{
-	PlayerColor player;
-	ObjectInstanceID heroId;
-	ObjectInstanceID objId;
-
-	bool starting; //false -> ending
-
-	void applyGs(CGameState * gs);
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & player;
-		h & heroId;
-		h & objId;
-		h & starting;
-	}
-};
-
-struct DLL_LINKAGE NewTurn : public CPackForClient
-{
-	enum weekType { NORMAL, DOUBLE_GROWTH, BONUS_GROWTH, DEITYOFFIRE, PLAGUE, NO_ACTION };
-
-	void applyGs(CGameState * gs);
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	struct Hero
-	{
-		ObjectInstanceID id;
-		ui32 move, mana; //id is a general serial id
-		template <typename Handler> void serialize(Handler & h, const int version)
-		{
-			h & id;
-			h & move;
-			h & mana;
-		}
-		bool operator<(const Hero & h)const { return id < h.id; }
-	};
-
-	std::set<Hero> heroes; //updates movement and mana points
-	std::map<PlayerColor, TResources> res; //player ID => resource value[res_id]
-	std::map<ObjectInstanceID, SetAvailableCreatures> cres;//creatures to be placed in towns
-	ui32 day = 0;
-	ui8 specialWeek = 0; //weekType
-	CreatureID creatureid; //for creature weeks
-
-	NewTurn() = default;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & heroes;
-		h & cres;
-		h & res;
-		h & day;
-		h & specialWeek;
-		h & creatureid;
-	}
-};
-
-struct DLL_LINKAGE InfoWindow : public CPackForClient //103  - displays simple info window
-{
-	EInfoWindowMode type = EInfoWindowMode::MODAL;
-	MetaString text;
-	std::vector<Component> components;
-	PlayerColor player;
-	ui16 soundID = 0;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & type;
-		h & text;
-		h & components;
-		h & player;
-		h & soundID;
-	}
-	InfoWindow() = default;
-};
-
-namespace ObjProperty
-{
-	enum
-	{
-		OWNER = 1, BLOCKVIS = 2, PRIMARY_STACK_COUNT = 3, VISITORS = 4, VISITED = 5, ID = 6, AVAILABLE_CREATURE = 7, SUBID = 8,
-		MONSTER_COUNT = 10, MONSTER_POWER = 11, MONSTER_EXP = 12, MONSTER_RESTORE_TYPE = 13, MONSTER_REFUSED_JOIN,
-
-		//town-specific
-		STRUCTURE_ADD_VISITING_HERO, STRUCTURE_CLEAR_VISITORS, STRUCTURE_ADD_GARRISONED_HERO,  //changing buildings state
-		BONUS_VALUE_FIRST, BONUS_VALUE_SECOND, //used in Rampart for special building that generates resources (storing resource type and quantity)
-
-		//creature-bank specific
-		BANK_DAYCOUNTER, BANK_RESET, BANK_CLEAR,
-
-		//object with reward
-		REWARD_RANDOMIZE, REWARD_SELECT, REWARD_CLEARED
-	};
-}
-
-struct DLL_LINKAGE SetObjectProperty : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-	ObjectInstanceID id;
-	ui8 what = 0; // see ObjProperty enum
-	ui32 val = 0;
-	SetObjectProperty() = default;
-	SetObjectProperty(const ObjectInstanceID & ID, ui8 What, ui32 Val)
-		: id(ID)
-		, what(What)
-		, val(Val)
-	{
-	}
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & id;
-		h & what;
-		h & val;
-	}
-};
-
-struct DLL_LINKAGE ChangeObjectVisitors : public CPackForClient
-{
-	enum VisitMode
-	{
-		VISITOR_ADD,      // mark hero as one that have visited this object
-		VISITOR_ADD_TEAM, // mark team as one that have visited this object
-		VISITOR_REMOVE,   // unmark visitor, reversed to ADD
-		VISITOR_CLEAR     // clear all visitors from this object (object reset)
-	};
-	ui32 mode = VISITOR_CLEAR; // uses VisitMode enum
-	ObjectInstanceID object;
-	ObjectInstanceID hero; // note: hero owner will be also marked as "visited" this object
-
-	void applyGs(CGameState * gs) const;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	ChangeObjectVisitors() = default;
-
-	ChangeObjectVisitors(ui32 mode, const ObjectInstanceID & object, const ObjectInstanceID & heroID = ObjectInstanceID(-1))
-		: mode(mode)
-		, object(object)
-		, hero(heroID)
-	{
-	}
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & object;
-		h & hero;
-		h & mode;
-	}
-};
-
-struct DLL_LINKAGE PrepareHeroLevelUp : public CPackForClient
-{
-	ObjectInstanceID heroId;
-
-	/// Do not serialize, used by server only
-	std::vector<SecondarySkill> skills;
-
-	void applyGs(CGameState * gs);
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & heroId;
-	}
-};
-
-struct DLL_LINKAGE HeroLevelUp : public Query
-{
-	PlayerColor player;
-	ObjectInstanceID heroId;
-
-	PrimarySkill primskill = PrimarySkill::ATTACK;
-	std::vector<SecondarySkill> skills;
-
-	void applyGs(CGameState * gs) const;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & queryID;
-		h & player;
-		h & heroId;
-		h & primskill;
-		h & skills;
-	}
-};
-
-struct DLL_LINKAGE CommanderLevelUp : public Query
-{
-	PlayerColor player;
-	ObjectInstanceID heroId;
-
-	std::vector<ui32> skills; //0-5 - secondary skills, val-100 - special skill
-
-	void applyGs(CGameState * gs) const;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & queryID;
-		h & player;
-		h & heroId;
-		h & skills;
-	}
-};
-
-//A dialog that requires making decision by player - it may contain components to choose between or has yes/no options
-//Client responds with QueryReply, where answer: 0 - cancel pressed, choice doesn't matter; 1/2/...  - first/second/... component selected and OK pressed
-//Until sending reply player won't be allowed to take any actions
-struct DLL_LINKAGE BlockingDialog : public Query
-{
-	enum { ALLOW_CANCEL = 1, SELECTION = 2 };
-	MetaString text;
-	std::vector<Component> components;
-	PlayerColor player;
-	ui8 flags = 0;
-	ui16 soundID = 0;
-
-	bool cancel() const
-	{
-		return flags & ALLOW_CANCEL;
-	}
-	bool selection() const
-	{
-		return flags & SELECTION;
-	}
-
-	BlockingDialog(bool yesno, bool Selection)
-	{
-		if(yesno) flags |= ALLOW_CANCEL;
-		if(Selection) flags |= SELECTION;
-	}
-	BlockingDialog() = default;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & queryID;
-		h & text;
-		h & components;
-		h & player;
-		h & flags;
-		h & soundID;
-	}
-};
-
-struct DLL_LINKAGE GarrisonDialog : public Query
-{
-	ObjectInstanceID objid, hid;
-	bool removableUnits = false;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & queryID;
-		h & objid;
-		h & hid;
-		h & removableUnits;
-	}
-};
-
-struct DLL_LINKAGE ExchangeDialog : public Query
-{
-	PlayerColor player;
-
-	ObjectInstanceID hero1;
-	ObjectInstanceID hero2;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & queryID;
-		h & player;
-		h & hero1;
-		h & hero2;
-	}
-};
-
-struct DLL_LINKAGE TeleportDialog : public Query
-{
-	TeleportDialog() = default;
-
-	TeleportDialog(const ObjectInstanceID & hero, const TeleportChannelID & Channel)
-		: hero(hero)
-		, channel(Channel)
-	{
-	}
-	ObjectInstanceID hero;
-	TeleportChannelID channel;
-	TTeleportExitsList exits;
-	bool impassable = false;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & queryID;
-		h & hero;
-		h & channel;
-		h & exits;
-		h & impassable;
-	}
-};
-
-struct DLL_LINKAGE MapObjectSelectDialog : public Query
-{
-	PlayerColor player;
-	Component icon;
-	MetaString title;
-	MetaString description;
-	std::vector<ObjectInstanceID> objects;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & queryID;
-		h & player;
-		h & icon;
-		h & title;
-		h & description;
-		h & objects;
-	}
-};
-
-struct DLL_LINKAGE BattleStart : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	BattleID battleID = BattleID::NONE;
-	BattleInfo * info = nullptr;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & info;
-		assert(battleID != BattleID::NONE);
-	}
-};
-
-struct DLL_LINKAGE BattleNextRound : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	BattleID battleID = BattleID::NONE;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		assert(battleID != BattleID::NONE);
-	}
-};
-
-struct DLL_LINKAGE BattleSetActiveStack : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	BattleID battleID = BattleID::NONE;
-	ui32 stack = 0;
-	ui8 askPlayerInterface = true;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & stack;
-		h & askPlayerInterface;
-		assert(battleID != BattleID::NONE);
-	}
-};
-
-struct DLL_LINKAGE BattleCancelled: public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	BattleID battleID = BattleID::NONE;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		assert(battleID != BattleID::NONE);
-	}
-};
-
-struct DLL_LINKAGE BattleResultAccepted : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	struct HeroBattleResults
-	{
-		HeroBattleResults()
-			: hero(nullptr), army(nullptr), exp(0) {}
-
-		CGHeroInstance * hero;
-		CArmedInstance * army;
-		TExpType exp;
-
-		template <typename Handler> void serialize(Handler & h, const int version)
-		{
-			h & hero;
-			h & army;
-			h & exp;
-		}
-	};
-
-	BattleID battleID = BattleID::NONE;
-	std::array<HeroBattleResults, 2> heroResult;
-	ui8 winnerSide;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & heroResult;
-		h & winnerSide;
-		assert(battleID != BattleID::NONE);
-	}
-};
-
-struct DLL_LINKAGE BattleResult : public Query
-{
-	void applyFirstCl(CClient * cl);
-
-	BattleID battleID = BattleID::NONE;
-	EBattleResult result = EBattleResult::NORMAL;
-	ui8 winner = 2; //0 - attacker, 1 - defender, [2 - draw (should be possible?)]
-	std::map<ui32, si32> casualties[2]; //first => casualties of attackers - map crid => number
-	TExpType exp[2] = {0, 0}; //exp for attacker and defender
-	std::set<ArtifactInstanceID> artifacts; //artifacts taken from loser to winner - currently unused
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & queryID;
-		h & result;
-		h & winner;
-		h & casualties[0];
-		h & casualties[1];
-		h & exp;
-		h & artifacts;
-		assert(battleID != BattleID::NONE);
-	}
-};
-
-struct DLL_LINKAGE BattleLogMessage : public CPackForClient
-{
-	BattleID battleID = BattleID::NONE;
-	std::vector<MetaString> lines;
-
-	void applyGs(CGameState * gs);
-	void applyBattle(IBattleState * battleState);
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & lines;
-		assert(battleID != BattleID::NONE);
-	}
-};
-
-struct DLL_LINKAGE BattleStackMoved : public CPackForClient
-{
-	BattleID battleID = BattleID::NONE;
-	ui32 stack = 0;
-	std::vector<BattleHex> tilesToMove;
-	int distance = 0;
-	bool teleporting = false;
-
-	void applyGs(CGameState * gs);
-	void applyBattle(IBattleState * battleState);
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & stack;
-		h & tilesToMove;
-		h & distance;
-		h & teleporting;
-		assert(battleID != BattleID::NONE);
-	}
-};
-
-struct DLL_LINKAGE BattleUnitsChanged : public CPackForClient
-{
-	void applyGs(CGameState * gs);
-	void applyBattle(IBattleState * battleState);
-
-	BattleID battleID = BattleID::NONE;
-	std::vector<UnitChanges> changedStacks;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & changedStacks;
-		assert(battleID != BattleID::NONE);
-	}
-};
-
-struct BattleStackAttacked
-{
-	DLL_LINKAGE void applyGs(CGameState * gs);
-	DLL_LINKAGE void applyBattle(IBattleState * battleState);
-
-	BattleID battleID = BattleID::NONE;
-	ui32 stackAttacked = 0, attackerID = 0;
-	ui32 killedAmount = 0;
-	int64_t damageAmount = 0;
-	UnitChanges newState;
-	enum EFlags { KILLED = 1, SECONDARY = 2, REBIRTH = 4, CLONE_KILLED = 8, SPELL_EFFECT = 16, FIRE_SHIELD = 32, };
-	ui32 flags = 0; //uses EFlags (above)
-	SpellID spellID = SpellID::NONE; //only if flag SPELL_EFFECT is set
-
-	bool killed() const//if target stack was killed
-	{
-		return flags & KILLED || flags & CLONE_KILLED;
-	}
-	bool cloneKilled() const
-	{
-		return flags & CLONE_KILLED;
-	}
-	bool isSecondary() const//if stack was not a primary target (receives no spell effects)
-	{
-		return flags & SECONDARY;
-	}
-	///Attacked with spell (SPELL_LIKE_ATTACK)
-	bool isSpell() const
-	{
-		return flags & SPELL_EFFECT;
-	}
-	bool willRebirth() const//resurrection, e.g. Phoenix
-	{
-		return flags & REBIRTH;
-	}
-	bool fireShield() const
-	{
-		return flags & FIRE_SHIELD;
-	}
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & stackAttacked;
-		h & attackerID;
-		h & newState;
-		h & flags;
-		h & killedAmount;
-		h & damageAmount;
-		h & spellID;
-		assert(battleID != BattleID::NONE);
-	}
-	bool operator<(const BattleStackAttacked & b) const
-	{
-		return stackAttacked < b.stackAttacked;
-	}
-};
-
-struct DLL_LINKAGE BattleAttack : public CPackForClient
-{
-	void applyGs(CGameState * gs);
-	BattleUnitsChanged attackerChanges;
-
-	BattleID battleID = BattleID::NONE;
-	std::vector<BattleStackAttacked> bsa;
-	ui32 stackAttacking = 0;
-	ui32 flags = 0; //uses Eflags (below)
-	enum EFlags { SHOT = 1, COUNTER = 2, LUCKY = 4, UNLUCKY = 8, BALLISTA_DOUBLE_DMG = 16, DEATH_BLOW = 32, SPELL_LIKE = 64, LIFE_DRAIN = 128 };
-
-	BattleHex tile;
-	SpellID spellID = SpellID::NONE; //for SPELL_LIKE
-
-	bool shot() const//distance attack - decrease number of shots
-	{
-		return flags & SHOT;
-	}
-	bool counter() const//is it counterattack?
-	{
-		return flags & COUNTER;
-	}
-	bool lucky() const
-	{
-		return flags & LUCKY;
-	}
-	bool unlucky() const
-	{
-		return flags & UNLUCKY;
-	}
-	bool ballistaDoubleDmg() const //if it's ballista attack and does double dmg
-	{
-		return flags & BALLISTA_DOUBLE_DMG;
-	}
-	bool deathBlow() const
-	{
-		return flags & DEATH_BLOW;
-	}
-	bool spellLike() const
-	{
-		return flags & SPELL_LIKE;
-	}
-	bool lifeDrain() const
-	{
-		return flags & LIFE_DRAIN;
-	}
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & bsa;
-		h & stackAttacking;
-		h & flags;
-		h & tile;
-		h & spellID;
-		h & attackerChanges;
-		assert(battleID != BattleID::NONE);
-	}
-};
-
-struct DLL_LINKAGE StartAction : public CPackForClient
-{
-	StartAction() = default;
-	StartAction(BattleAction act)
-		: ba(std::move(act))
-	{
-	}
-	void applyFirstCl(CClient * cl);
-	void applyGs(CGameState * gs);
-
-	BattleID battleID = BattleID::NONE;
-	BattleAction ba;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & ba;
-		assert(battleID != BattleID::NONE);
-	}
-};
-
-struct DLL_LINKAGE EndAction : public CPackForClient
-{
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	BattleID battleID = BattleID::NONE;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-	}
-};
-
-struct DLL_LINKAGE BattleSpellCast : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	BattleID battleID = BattleID::NONE;
-	bool activeCast = true;
-	ui8 side = 0; //which hero did cast spell: 0 - attacker, 1 - defender
-	SpellID spellID; //id of spell
-	ui8 manaGained = 0; //mana channeling ability
-	BattleHex tile; //destination tile (may not be set in some global/mass spells
-	std::set<ui32> affectedCres; //ids of creatures affected by this spell, generally used if spell does not set any effect (like dispel or cure)
-	std::set<ui32> resistedCres; // creatures that resisted the spell (e.g. Dwarves)
-	std::set<ui32> reflectedCres; // creatures that reflected the spell (e.g. Magic Mirror spell)
-	si32 casterStack = -1; // -1 if not cated by creature, >=0 caster stack ID
-	bool castByHero = true; //if true - spell has been cast by hero, otherwise by a creature
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & side;
-		h & spellID;
-		h & manaGained;
-		h & tile;
-		h & affectedCres;
-		h & resistedCres;
-		h & reflectedCres;
-		h & casterStack;
-		h & castByHero;
-		h & activeCast;
-		assert(battleID != BattleID::NONE);
-	}
-};
-
-struct DLL_LINKAGE SetStackEffect : public CPackForClient
-{
-	void applyGs(CGameState * gs);
-	void applyBattle(IBattleState * battleState);
-
-	BattleID battleID = BattleID::NONE;
-	std::vector<std::pair<ui32, std::vector<Bonus>>> toAdd;
-	std::vector<std::pair<ui32, std::vector<Bonus>>> toUpdate;
-	std::vector<std::pair<ui32, std::vector<Bonus>>> toRemove;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> 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);
-	void applyBattle(IBattleState * battleState);
-
-	BattleID battleID = BattleID::NONE;
-	std::vector<BattleStackAttacked> stacks;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & stacks;
-		assert(battleID != BattleID::NONE);
-	}
-};
-
-struct DLL_LINKAGE BattleResultsApplied : public CPackForClient
-{
-	BattleID battleID = BattleID::NONE;
-	PlayerColor player1, player2;
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & player1;
-		h & player2;
-		assert(battleID != BattleID::NONE);
-	}
-};
-
-struct DLL_LINKAGE BattleObstaclesChanged : public CPackForClient
-{
-	void applyGs(CGameState * gs);
-	void applyBattle(IBattleState * battleState);
-
-	BattleID battleID = BattleID::NONE;
-	std::vector<ObstacleChanges> changes;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & changes;
-		assert(battleID != BattleID::NONE);
-	}
-};
-
-struct DLL_LINKAGE CatapultAttack : public CPackForClient
-{
-	struct AttackInfo
-	{
-		si16 destinationTile;
-		EWallPart attackedPart;
-		ui8 damageDealt;
-
-		template <typename Handler> void serialize(Handler & h, const int version)
-		{
-			h & destinationTile;
-			h & attackedPart;
-			h & damageDealt;
-		}
-	};
-
-	CatapultAttack();
-	~CatapultAttack() override;
-
-	void applyGs(CGameState * gs);
-	void applyBattle(IBattleState * battleState);
-
-	BattleID battleID = BattleID::NONE;
-	std::vector< AttackInfo > attackedParts;
-	int attacker = -1; //if -1, then a spell caused this
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & attackedParts;
-		h & attacker;
-		assert(battleID != BattleID::NONE);
-	}
-};
-
-struct DLL_LINKAGE BattleSetStackProperty : public CPackForClient
-{
-	enum BattleStackProperty { CASTS, ENCHANTER_COUNTER, UNBIND, CLONED, HAS_CLONE };
-
-	void applyGs(CGameState * gs) const;
-
-	BattleID battleID = BattleID::NONE;
-	int stackID = 0;
-	BattleStackProperty which = CASTS;
-	int val = 0;
-	int absolute = 0;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & stackID;
-		h & which;
-		h & val;
-		h & absolute;
-		assert(battleID != BattleID::NONE);
-	}
-
-protected:
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-};
-
-///activated at the beginning of turn
-struct DLL_LINKAGE BattleTriggerEffect : public CPackForClient
-{
-	void applyGs(CGameState * gs) const; //effect
-
-	BattleID battleID = BattleID::NONE;
-	int stackID = 0;
-	int effect = 0; //use corresponding Bonus type
-	int val = 0;
-	int additionalInfo = 0;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & stackID;
-		h & effect;
-		h & val;
-		h & additionalInfo;
-		assert(battleID != BattleID::NONE);
-	}
-
-protected:
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-};
-
-struct DLL_LINKAGE BattleUpdateGateState : public CPackForClient
-{
-	void applyGs(CGameState * gs) const;
-
-	BattleID battleID = BattleID::NONE;
-	EGateState state = EGateState::NONE;
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & battleID;
-		h & state;
-		assert(battleID != BattleID::NONE);
-	}
-
-protected:
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-};
-
-struct DLL_LINKAGE AdvmapSpellCast : public CPackForClient
-{
-	ObjectInstanceID casterID;
-	SpellID spellID;
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & casterID;
-		h & spellID;
-	}
-
-protected:
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-};
-
-struct DLL_LINKAGE ShowWorldViewEx : public CPackForClient
-{
-	PlayerColor player;
-	bool showTerrain; // TODO: send terrain state
-
-	std::vector<ObjectPosInfo> objectPositions;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & player;
-		h & showTerrain;
-		h & objectPositions;
-	}
-
-protected:
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-};
-
-/***********************************************************************************************************/
-
-struct DLL_LINKAGE GamePause : public CPackForServer
-{
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-	}
-};
-
-struct DLL_LINKAGE EndTurn : public CPackForServer
-{
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-	}
-};
-
-struct DLL_LINKAGE DismissHero : public CPackForServer
-{
-	DismissHero() = default;
-	DismissHero(const ObjectInstanceID & HID)
-		: hid(HID)
-	{
-	}
-	ObjectInstanceID hid;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & hid;
-	}
-};
-
-struct DLL_LINKAGE MoveHero : public CPackForServer
-{
-	MoveHero() = default;
-	MoveHero(const int3 & Dest, const ObjectInstanceID & HID, bool Transit)
-		: dest(Dest)
-		, hid(HID)
-		, transit(Transit)
-	{
-	}
-	int3 dest;
-	ObjectInstanceID hid;
-	bool transit = false;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & dest;
-		h & hid;
-		h & transit;
-	}
-};
-
-struct DLL_LINKAGE CastleTeleportHero : public CPackForServer
-{
-	CastleTeleportHero() = default;
-	CastleTeleportHero(const ObjectInstanceID & HID, const ObjectInstanceID & Dest, ui8 Source)
-		: dest(Dest)
-		, hid(HID)
-		, source(Source)
-	{
-	}
-	ObjectInstanceID dest;
-	ObjectInstanceID hid;
-	si8 source = 0; //who give teleporting, 1=castle gate
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & dest;
-		h & hid;
-	}
-};
-
-struct DLL_LINKAGE ArrangeStacks : public CPackForServer
-{
-	ArrangeStacks() = default;
-	ArrangeStacks(ui8 W, const SlotID & P1, const SlotID & P2, const ObjectInstanceID & ID1, const ObjectInstanceID & ID2, si32 VAL)
-		: what(W)
-		, p1(P1)
-		, p2(P2)
-		, id1(ID1)
-		, id2(ID2)
-		, val(VAL)
-	{
-	}
-
-	ui8 what = 0; //1 - swap; 2 - merge; 3 - split
-	SlotID p1, p2; //positions of first and second stack
-	ObjectInstanceID id1, id2; //ids of objects with garrison
-	si32 val = 0;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & what;
-		h & p1;
-		h & p2;
-		h & id1;
-		h & id2;
-		h & val;
-	}
-};
-
-struct DLL_LINKAGE BulkMoveArmy : public CPackForServer
-{
-	SlotID srcSlot;
-	ObjectInstanceID srcArmy;
-	ObjectInstanceID destArmy;
-
-	BulkMoveArmy() = default;
-
-	BulkMoveArmy(const ObjectInstanceID & srcArmy, const ObjectInstanceID & destArmy, const SlotID & srcSlot)
-		: srcArmy(srcArmy)
-		, destArmy(destArmy)
-		, srcSlot(srcSlot)
-	{
-	}
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler>
-	void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & srcSlot;
-		h & srcArmy;
-		h & destArmy;
-	}
-};
-
-struct DLL_LINKAGE BulkSplitStack : public CPackForServer
-{
-	SlotID src;
-	ObjectInstanceID srcOwner;
-	si32 amount = 0;
-
-	BulkSplitStack() = default;
-
-	BulkSplitStack(const ObjectInstanceID & srcOwner, const SlotID & src, si32 howMany)
-		: src(src)
-		, srcOwner(srcOwner)
-		, amount(howMany)
-	{
-	}
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler>
-	void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & src;
-		h & srcOwner;
-		h & amount;
-	}
-};
-
-struct DLL_LINKAGE BulkMergeStacks : public CPackForServer
-{
-	SlotID src;
-	ObjectInstanceID srcOwner;
-
-	BulkMergeStacks() = default;
-
-	BulkMergeStacks(const ObjectInstanceID & srcOwner, const SlotID & src)
-		: src(src)
-		, srcOwner(srcOwner)
-	{
-	}
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler>
-	void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & src;
-		h & srcOwner;
-	}
-};
-
-struct DLL_LINKAGE BulkSmartSplitStack : public CPackForServer
-{
-	SlotID src;
-	ObjectInstanceID srcOwner;
-
-	BulkSmartSplitStack() = default;
-
-	BulkSmartSplitStack(const ObjectInstanceID & srcOwner, const SlotID & src)
-		: src(src)
-		, srcOwner(srcOwner)
-	{
-	}
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler>
-	void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & src;
-		h & srcOwner;
-	}
-};
-
-struct DLL_LINKAGE DisbandCreature : public CPackForServer
-{
-	DisbandCreature() = default;
-	DisbandCreature(const SlotID & Pos, const ObjectInstanceID & ID)
-		: pos(Pos)
-		, id(ID)
-	{
-	}
-	SlotID pos; //stack pos
-	ObjectInstanceID id; //object id
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & pos;
-		h & id;
-	}
-};
-
-struct DLL_LINKAGE BuildStructure : public CPackForServer
-{
-	BuildStructure() = default;
-	BuildStructure(const ObjectInstanceID & TID, const BuildingID & BID)
-		: tid(TID)
-		, bid(BID)
-	{
-	}
-	ObjectInstanceID tid; //town id
-	BuildingID bid; //structure id
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & tid;
-		h & bid;
-	}
-};
-
-struct DLL_LINKAGE RazeStructure : public BuildStructure
-{
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-};
-
-struct DLL_LINKAGE RecruitCreatures : public CPackForServer
-{
-	RecruitCreatures() = default;
-	RecruitCreatures(const ObjectInstanceID & TID, const ObjectInstanceID & DST, const CreatureID & CRID, si32 Amount, si32 Level)
-		: tid(TID)
-		, dst(DST)
-		, crid(CRID)
-		, amount(Amount)
-		, level(Level)
-	{
-	}
-	ObjectInstanceID tid; //dwelling id, or town
-	ObjectInstanceID dst; //destination ID, e.g. hero
-	CreatureID crid;
-	ui32 amount = 0; //creature amount
-	si32 level = 0; //dwelling level to buy from, -1 if any
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & tid;
-		h & dst;
-		h & crid;
-		h & amount;
-		h & level;
-	}
-};
-
-struct DLL_LINKAGE UpgradeCreature : public CPackForServer
-{
-	UpgradeCreature() = default;
-	UpgradeCreature(const SlotID & Pos, const ObjectInstanceID & ID, const CreatureID & CRID)
-		: pos(Pos)
-		, id(ID)
-		, cid(CRID)
-	{
-	}
-	SlotID pos; //stack pos
-	ObjectInstanceID id; //object id
-	CreatureID cid; //id of type to which we want make upgrade
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & pos;
-		h & id;
-		h & cid;
-	}
-};
-
-struct DLL_LINKAGE GarrisonHeroSwap : public CPackForServer
-{
-	GarrisonHeroSwap() = default;
-	GarrisonHeroSwap(const ObjectInstanceID & TID)
-		: tid(TID)
-	{
-	}
-	ObjectInstanceID tid;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & tid;
-	}
-};
-
-struct DLL_LINKAGE ExchangeArtifacts : public CPackForServer
-{
-	ArtifactLocation src, dst;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & src;
-		h & dst;
-	}
-};
-
-struct DLL_LINKAGE BulkExchangeArtifacts : public CPackForServer
-{
-	ObjectInstanceID srcHero;
-	ObjectInstanceID dstHero;
-	bool swap = false;
-	bool equipped = true;
-	bool backpack = true;
-
-	BulkExchangeArtifacts() = default;
-	BulkExchangeArtifacts(const ObjectInstanceID & srcHero, const ObjectInstanceID & dstHero, bool swap, bool equipped, bool backpack)
-		: srcHero(srcHero)
-		, dstHero(dstHero)
-		, swap(swap)
-		, equipped(equipped)
-		, backpack(backpack)
-	{
-	}
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & srcHero;
-		h & dstHero;
-		h & swap;
-		h & equipped;
-		h & backpack;
-	}
-};
-
-struct DLL_LINKAGE AssembleArtifacts : public CPackForServer
-{
-	AssembleArtifacts() = default;
-	AssembleArtifacts(const ObjectInstanceID & _heroID, const ArtifactPosition & _artifactSlot, bool _assemble, const ArtifactID & _assembleTo)
-		: heroID(_heroID)
-		, artifactSlot(_artifactSlot)
-		, assemble(_assemble)
-		, assembleTo(_assembleTo)
-	{
-	}
-	ObjectInstanceID heroID;
-	ArtifactPosition artifactSlot;
-	bool assemble = false; // True to assemble artifact, false to disassemble.
-	ArtifactID assembleTo; // Artifact to assemble into.
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & heroID;
-		h & artifactSlot;
-		h & assemble;
-		h & assembleTo;
-	}
-};
-
-struct DLL_LINKAGE EraseArtifactByClient : public CPackForServer
-{
-	EraseArtifactByClient() = default;
-	EraseArtifactByClient(const ArtifactLocation & al)
-		: al(al)
-	{
-	}
-	ArtifactLocation al;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer&>(*this);
-		h & al;
-	}
-};
-
-struct DLL_LINKAGE BuyArtifact : public CPackForServer
-{
-	BuyArtifact() = default;
-	BuyArtifact(const ObjectInstanceID & HID, const ArtifactID & AID)
-		: hid(HID)
-		, aid(AID)
-	{
-	}
-	ObjectInstanceID hid;
-	ArtifactID aid;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & hid;
-		h & aid;
-	}
-};
-
-struct DLL_LINKAGE TradeOnMarketplace : public CPackForServer
-{
-	ObjectInstanceID marketId;
-	ObjectInstanceID heroId;
-
-	EMarketMode mode = EMarketMode::RESOURCE_RESOURCE;
-	std::vector<ui32> r1, r2; //mode 0: r1 - sold resource, r2 - bought res (exception: when sacrificing art r1 is art id [todo: make r2 preferred slot?]
-	std::vector<ui32> val; //units of sold resource
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & marketId;
-		h & heroId;
-		h & mode;
-		h & r1;
-		h & r2;
-		h & val;
-	}
-};
-
-struct DLL_LINKAGE SetFormation : public CPackForServer
-{
-	SetFormation() = default;
-	;
-	SetFormation(const ObjectInstanceID & HID, ui8 Formation)
-		: hid(HID)
-		, formation(Formation)
-	{
-	}
-	ObjectInstanceID hid;
-	ui8 formation = 0;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & hid;
-		h & formation;
-	}
-};
-
-struct DLL_LINKAGE HireHero : public CPackForServer
-{
-	HireHero() = default;
-	HireHero(HeroTypeID HID, const ObjectInstanceID & TID)
-		: hid(HID)
-		, tid(TID)
-	{
-	}
-	HeroTypeID hid; //available hero serial
-	ObjectInstanceID tid; //town (tavern) id
-	PlayerColor player;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & hid;
-		h & tid;
-		h & player;
-	}
-};
-
-struct DLL_LINKAGE BuildBoat : public CPackForServer
-{
-	ObjectInstanceID objid; //where player wants to buy a boat
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & objid;
-	}
-};
-
-struct DLL_LINKAGE QueryReply : public CPackForServer
-{
-	QueryReply() = default;
-	QueryReply(const QueryID & QID, std::optional<int32_t> Reply)
-		: qid(QID)
-		, reply(Reply)
-	{
-	}
-	QueryID qid;
-	PlayerColor player;
-	std::optional<int32_t> reply;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & qid;
-		h & player;
-		h & reply;
-	}
-};
-
-struct DLL_LINKAGE MakeAction : public CPackForServer
-{
-	MakeAction() = default;
-	MakeAction(BattleAction BA)
-		: ba(std::move(BA))
-	{
-	}
-	BattleAction ba;
-	BattleID battleID;
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & ba;
-		h & battleID;
-	}
-};
-
-struct DLL_LINKAGE DigWithHero : public CPackForServer
-{
-	ObjectInstanceID id; //digging hero id
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & id;
-	}
-};
-
-struct DLL_LINKAGE CastAdvSpell : public CPackForServer
-{
-	ObjectInstanceID hid; //hero id
-	SpellID sid; //spell id
-	int3 pos; //selected tile (not always used)
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & hid;
-		h & sid;
-		h & pos;
-	}
-};
-
-/***********************************************************************************************************/
-
-struct DLL_LINKAGE SaveGame : public CPackForServer
-{
-	SaveGame() = default;
-	SaveGame(std::string Fname)
-		: fname(std::move(Fname))
-	{
-	}
-	std::string fname;
-
-	void applyGs(CGameState * gs) {};
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & fname;
-	}
-};
-
-struct DLL_LINKAGE PlayerMessage : public CPackForServer
-{
-	PlayerMessage() = default;
-	PlayerMessage(std::string Text, const ObjectInstanceID & obj)
-		: text(std::move(Text))
-		, currObj(obj)
-	{
-	}
-
-	void applyGs(CGameState * gs) {};
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	std::string text;
-	ObjectInstanceID currObj; // optional parameter that specifies current object. For cheats :)
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & static_cast<CPackForServer &>(*this);
-		h & text;
-		h & currObj;
-	}
-};
-
-struct DLL_LINKAGE PlayerMessageClient : public CPackForClient
-{
-	PlayerMessageClient() = default;
-	PlayerMessageClient(const PlayerColor & Player, std::string Text)
-		: player(Player)
-		, text(std::move(Text))
-	{
-	}
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	PlayerColor player;
-	std::string text;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & player;
-		h & text;
-	}
-};
-
-struct DLL_LINKAGE CenterView : public CPackForClient
-{
-	PlayerColor player;
-	int3 pos;
-	ui32 focusTime = 0; //ms
-
-	virtual void visitTyped(ICPackVisitor & visitor) override;
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & pos;
-		h & player;
-		h & focusTime;
-	}
-};
-
-VCMI_LIB_NAMESPACE_END

+ 0 - 286
lib/NetPacksBase.h

@@ -1,286 +0,0 @@
-/*
- * NetPacksBase.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 <vcmi/Metatype.h>
-
-#include "ConstTransitivePtr.h"
-#include "GameConstants.h"
-#include "JsonNode.h"
-
-class CClient;
-class CGameHandler;
-class CLobbyScreen;
-class CServerHandler;
-class CVCMIServer;
-
-VCMI_LIB_NAMESPACE_BEGIN
-
-class CGameState;
-class CConnection;
-class CStackBasicDescriptor;
-class CGHeroInstance;
-class CStackInstance;
-class CArmedInstance;
-class CArtifactSet;
-class CBonusSystemNode;
-struct ArtSlotInfo;
-
-class ICPackVisitor;
-
-enum class EInfoWindowMode : uint8_t
-{
-	AUTO,
-	MODAL,
-	INFO
-};
-
-enum class EOpenWindowMode : uint8_t
-{
-	EXCHANGE_WINDOW,
-	RECRUITMENT_FIRST,
-	RECRUITMENT_ALL,
-	SHIPYARD_WINDOW,
-	THIEVES_GUILD,
-	UNIVERSITY_WINDOW,
-	HILL_FORT_WINDOW,
-	MARKET_WINDOW,
-	PUZZLE_MAP,
-	TAVERN_WINDOW
-};
-
-struct DLL_LINKAGE CPack
-{
-	std::shared_ptr<CConnection> c; // Pointer to connection that pack received from
-
-	CPack() = default;
-	virtual ~CPack() = default;
-
-	template <typename Handler> void serialize(Handler &h, const int version)
-	{
-		logNetwork->error("CPack serialized... this should not happen!");
-		assert(false && "CPack serialized");
-	}
-
-	void applyGs(CGameState * gs)
-	{}
-
-	void visit(ICPackVisitor & cpackVisitor);
-
-protected:
-	/// <summary>
-	/// For basic types of netpacks hierarchy like CPackForClient. Called first.
-	/// </summary>
-	virtual void visitBasic(ICPackVisitor & cpackVisitor);
-
-	/// <summary>
-	/// For leaf types of netpacks hierarchy. Called after visitBasic.
-	/// </summary>
-	virtual void visitTyped(ICPackVisitor & cpackVisitor);
-};
-
-struct DLL_LINKAGE CPackForClient : public CPack
-{
-protected:
-	virtual void visitBasic(ICPackVisitor & cpackVisitor) override;
-};
-
-struct DLL_LINKAGE CPackForServer : public CPack
-{
-	mutable PlayerColor player = PlayerColor::NEUTRAL;
-	mutable si32 requestID;
-
-	template <typename Handler> void serialize(Handler &h, const int version)
-	{
-		h & player;
-		h & requestID;
-	}
-
-protected:
-	virtual void visitBasic(ICPackVisitor & cpackVisitor) override;
-};
-
-struct DLL_LINKAGE CPackForLobby : public CPack
-{
-	virtual bool isForServer() const;
-
-protected:
-	virtual void visitBasic(ICPackVisitor & cpackVisitor) override;
-};
-
-struct Component
-{
-	enum class EComponentType : uint8_t 
-	{
-		PRIM_SKILL,
-		SEC_SKILL,
-		RESOURCE,
-		CREATURE,
-		ARTIFACT,
-		EXPERIENCE,
-		SPELL,
-		MORALE,
-		LUCK,
-		BUILDING,
-		HERO_PORTRAIT,
-		FLAG,
-		INVALID //should be last
-	};
-	EComponentType id = EComponentType::INVALID;
-	ui16 subtype = 0; //id==EXPPERIENCE subtype==0 means exp points and subtype==1 levels
-	si32 val = 0; // + give; - take
-	si16 when = 0; // 0 - now; +x - within x days; -x - per x days
-
-	template <typename Handler> void serialize(Handler &h, const int version)
-	{
-		h & id;
-		h & subtype;
-		h & val;
-		h & when;
-	}
-	Component() = default;
-	DLL_LINKAGE explicit Component(const CStackBasicDescriptor &stack);
-	Component(Component::EComponentType Type, ui16 Subtype, si32 Val, si16 When)
-		:id(Type),subtype(Subtype),val(Val),when(When)
-	{
-	}
-};
-
-using TArtHolder = std::variant<ConstTransitivePtr<CGHeroInstance>, ConstTransitivePtr<CStackInstance>>;
-
-struct ArtifactLocation
-{
-	TArtHolder artHolder;//TODO: identify holder by id
-	ArtifactPosition slot = ArtifactPosition::PRE_FIRST;
-
-	ArtifactLocation()
-		: artHolder(ConstTransitivePtr<CGHeroInstance>())
-	{
-	}
-	template<typename T>
-	ArtifactLocation(const T * ArtHolder, ArtifactPosition Slot)
-		: artHolder(const_cast<T *>(ArtHolder)) //we are allowed here to const cast -> change will go through one of our packages... do not abuse!
-		, slot(Slot)
-	{
-	}
-	ArtifactLocation(TArtHolder ArtHolder, const ArtifactPosition & Slot)
-		: artHolder(std::move(std::move(ArtHolder)))
-		, slot(Slot)
-	{
-	}
-
-	template <typename T>
-	bool isHolder(const T *t) const
-	{
-		if(auto ptrToT = std::get<ConstTransitivePtr<T>>(artHolder))
-		{
-			return ptrToT == t;
-		}
-		return false;
-	}
-
-	DLL_LINKAGE void removeArtifact(); // BE CAREFUL, this operation modifies holder (gs)
-
-	DLL_LINKAGE const CArmedInstance *relatedObj() const; //hero or the stack owner
-	DLL_LINKAGE PlayerColor owningPlayer() const;
-	DLL_LINKAGE CArtifactSet *getHolderArtSet();
-	DLL_LINKAGE CBonusSystemNode *getHolderNode();
-	DLL_LINKAGE CArtifactSet *getHolderArtSet() const;
-	DLL_LINKAGE const CBonusSystemNode *getHolderNode() const;
-
-	DLL_LINKAGE const CArtifactInstance *getArt() const;
-	DLL_LINKAGE CArtifactInstance *getArt();
-	DLL_LINKAGE const ArtSlotInfo *getSlot() const;
-	template <typename Handler> void serialize(Handler &h, const int version)
-	{
-		h & artHolder;
-		h & slot;
-	}
-};
-
-class EntityChanges
-{
-public:
-	Metatype metatype = Metatype::UNKNOWN;
-	int32_t entityIndex = 0;
-	JsonNode data;
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & metatype;
-		h & entityIndex;
-		h & data;
-	}
-};
-
-class BattleChanges
-{
-public:
-	enum class EOperation : si8
-	{
-		ADD,
-		RESET_STATE,
-		UPDATE,
-		REMOVE,
-	};
-
-	JsonNode data;
-	EOperation operation = EOperation::RESET_STATE;
-
-	BattleChanges() = default;
-	BattleChanges(EOperation operation_)
-		: operation(operation_)
-	{
-	}
-};
-
-class UnitChanges : public BattleChanges
-{
-public:
-	uint32_t id = 0;
-	int64_t healthDelta = 0;
-
-	UnitChanges() = default;
-	UnitChanges(uint32_t id_, EOperation operation_)
-		: BattleChanges(operation_)
-		, id(id_)
-	{
-	}
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & id;
-		h & healthDelta;
-		h & data;
-		h & operation;
-	}
-};
-
-class ObstacleChanges : public BattleChanges
-{
-public:
-	uint32_t id = 0;
-
-	ObstacleChanges() = default;
-
-	ObstacleChanges(uint32_t id_, EOperation operation_)
-		: BattleChanges(operation_),
-		id(id_)
-	{
-	}
-
-	template <typename Handler> void serialize(Handler & h, const int version)
-	{
-		h & id;
-		h & data;
-		h & operation;
-	}
-};
-
-VCMI_LIB_NAMESPACE_END

+ 1 - 1
lib/battle/BattleInfo.cpp

@@ -9,11 +9,11 @@
  */
 #include "StdInc.h"
 #include "BattleInfo.h"
+#include "CObstacleInstance.h"
 #include "bonuses/Limiters.h"
 #include "bonuses/Updaters.h"
 #include "../CStack.h"
 #include "../CHeroHandler.h"
-#include "../NetPacks.h"
 #include "../filesystem/Filesystem.h"
 #include "../mapObjects/CGTownInstance.h"
 #include "../CGeneralTextHandler.h"

+ 1 - 1
lib/battle/CBattleInfoCallback.cpp

@@ -17,12 +17,12 @@
 #include "CObstacleInstance.h"
 #include "DamageCalculator.h"
 #include "PossiblePlayerBattleAction.h"
-#include "../NetPacks.h"
 #include "../spells/ObstacleCasterProxy.h"
 #include "../spells/ISpellMechanics.h"
 #include "../spells/Problem.h"
 #include "../spells/CSpellHandler.h"
 #include "../mapObjects/CGTownInstance.h"
+#include "../networkPacks/PacksForClientBattle.h"
 #include "../BattleFieldHandler.h"
 #include "../Rect.h"
 

+ 2 - 1
lib/battle/CBattleInfoEssentials.cpp

@@ -11,9 +11,10 @@
 #include "CBattleInfoEssentials.h"
 #include "../CStack.h"
 #include "BattleInfo.h"
-#include "../NetPacks.h"
+#include "CObstacleInstance.h"
 #include "../mapObjects/CGTownInstance.h"
 #include "../gameState/InfoAboutArmy.h"
+#include "../constants/EntityIdentifiers.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 0 - 1
lib/battle/CObstacleInstance.cpp

@@ -13,7 +13,6 @@
 #include "../CTownHandler.h"
 #include "../ObstacleHandler.h"
 #include "../VCMI_Lib.h"
-#include "../NetPacksBase.h"
 
 #include "../serializer/JsonDeserializer.h"
 #include "../serializer/JsonSerializer.h"

+ 2 - 1
lib/battle/CObstacleInstance.h

@@ -9,8 +9,9 @@
  */
 #pragma once
 #include "BattleHex.h"
-#include "NetPacksBase.h"
 #include "../filesystem/ResourcePath.h"
+#include "../networkPacks/BattleChanges.h"
+#include "../constants/EntityIdentifiers.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 1 - 1
lib/battle/CUnitState.cpp

@@ -13,8 +13,8 @@
 
 #include <vcmi/spells/Spell.h>
 
-#include "../NetPacks.h"
 #include "../CCreatureHandler.h"
+#include "../MetaString.h"
 
 #include "../serializer/JsonDeserializer.h"
 #include "../serializer/JsonSerializer.h"

+ 0 - 1
lib/battle/Unit.cpp

@@ -14,7 +14,6 @@
 #include "../VCMI_Lib.h"
 #include "../CGeneralTextHandler.h"
 #include "../MetaString.h"
-#include "../NetPacksBase.h"
 
 #include "../serializer/JsonDeserializer.h"
 #include "../serializer/JsonSerializer.h"

+ 1 - 2
lib/events/ApplyDamage.cpp

@@ -12,8 +12,7 @@
 #include <vcmi/Environment.h>
 
 #include "ApplyDamage.h"
-
-#include "../../lib/NetPacks.h"
+#include "../networkPacks/PacksForClientBattle.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 5 - 1
lib/mapObjects/CBank.cpp

@@ -14,13 +14,17 @@
 #include <vcmi/spells/Spell.h>
 #include <vcmi/spells/Service.h>
 
-#include "../NetPacks.h"
 #include "../CGeneralTextHandler.h"
 #include "../CSoundBase.h"
 #include "../GameSettings.h"
 #include "../CPlayerState.h"
 #include "../mapObjectConstructors/CObjectClassesHandler.h"
 #include "../mapObjectConstructors/CBankInstanceConstructor.h"
+#include "../mapObjects/CGHeroInstance.h"
+#include "../networkPacks/Component.h"
+#include "../networkPacks/PacksForClient.h"
+#include "../networkPacks/PacksForClientBattle.h"
+#include "../MetaString.h"
 #include "../IGameCallback.h"
 #include "../gameState/CGameState.h"
 

+ 4 - 1
lib/mapObjects/CGCreature.cpp

@@ -10,12 +10,15 @@
 
 #include "StdInc.h"
 #include "CGCreature.h"
+#include "CGHeroInstance.h"
 
-#include "../NetPacks.h"
 #include "../CGeneralTextHandler.h"
 #include "../CConfigHandler.h"
 #include "../GameSettings.h"
 #include "../IGameCallback.h"
+#include "../networkPacks/PacksForClient.h"
+#include "../networkPacks/PacksForClientBattle.h"
+#include "../networkPacks/StackLocation.h"
 #include "../serializer/JsonSerializeFormat.h"
 
 VCMI_LIB_NAMESPACE_BEGIN

+ 4 - 1
lib/mapObjects/CGDwelling.cpp

@@ -13,11 +13,14 @@
 #include "../serializer/JsonSerializeFormat.h"
 #include "../mapObjectConstructors/AObjectTypeHandler.h"
 #include "../mapObjectConstructors/CObjectClassesHandler.h"
+#include "../mapObjects/CGHeroInstance.h"
+#include "../networkPacks/StackLocation.h"
+#include "../networkPacks/PacksForClient.h"
+#include "../networkPacks/PacksForClientBattle.h"
 #include "../CTownHandler.h"
 #include "../IGameCallback.h"
 #include "../gameState/CGameState.h"
 #include "../CPlayerState.h"
-#include "../NetPacks.h"
 #include "../GameSettings.h"
 #include "../CConfigHandler.h"
 

+ 2 - 1
lib/mapObjects/CGHeroInstance.cpp

@@ -14,7 +14,6 @@
 #include <vcmi/ServerCallback.h>
 #include <vcmi/spells/Spell.h>
 
-#include "../NetPacks.h"
 #include "../CGeneralTextHandler.h"
 #include "../ArtifactUtils.h"
 #include "../CHeroHandler.h"
@@ -35,6 +34,8 @@
 #include "../mapObjectConstructors/AObjectTypeHandler.h"
 #include "../mapObjectConstructors/CObjectClassesHandler.h"
 #include "../modding/ModScope.h"
+#include "../networkPacks/PacksForClient.h"
+#include "../networkPacks/PacksForClientBattle.h"
 #include "../constants/StringConstants.h"
 #include "../battle/Unit.h"
 

+ 1 - 1
lib/mapObjects/CGMarket.cpp

@@ -11,7 +11,6 @@
 #include "StdInc.h"
 #include "CGMarket.h"
 
-#include "../NetPacks.h"
 #include "../CGeneralTextHandler.h"
 #include "../IGameCallback.h"
 #include "../CCreatureHandler.h"
@@ -20,6 +19,7 @@
 #include "../CSkillHandler.h"
 #include "../mapObjectConstructors/AObjectTypeHandler.h"
 #include "../mapObjectConstructors/CObjectClassesHandler.h"
+#include "../networkPacks/PacksForClient.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 1 - 1
lib/mapObjects/CGObjectInstance.cpp

@@ -17,12 +17,12 @@
 #include "../gameState/CGameState.h"
 #include "../CGeneralTextHandler.h"
 #include "../IGameCallback.h"
-#include "../NetPacks.h"
 #include "../constants/StringConstants.h"
 #include "../TerrainHandler.h"
 #include "../mapObjectConstructors/AObjectTypeHandler.h"
 #include "../mapObjectConstructors/CObjectClassesHandler.h"
 #include "../mapping/CMap.h"
+#include "../networkPacks/PacksForClient.h"
 #include "../serializer/JsonSerializeFormat.h"
 
 VCMI_LIB_NAMESPACE_BEGIN

+ 3 - 0
lib/mapObjects/CGObjectInstance.h

@@ -10,11 +10,14 @@
 #pragma once
 
 #include "IObjectInterface.h"
+#include "../constants/EntityIdentifiers.h"
+#include "../filesystem/ResourcePath.h"
 #include "../int3.h"
 #include "../bonuses/BonusEnum.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 
+struct Component;
 class JsonSerializeFormat;
 class ObjectTemplate;
 class CMap;

+ 3 - 1
lib/mapObjects/CGPandoraBox.cpp

@@ -14,13 +14,15 @@
 #include <vcmi/spells/Spell.h>
 #include <vcmi/spells/Service.h>
 
-#include "../NetPacks.h"
 #include "../CSoundBase.h"
 
 #include "../CSkillHandler.h"
 #include "../StartInfo.h"
 #include "../IGameCallback.h"
 #include "../constants/StringConstants.h"
+#include "../networkPacks/PacksForClient.h"
+#include "../networkPacks/PacksForClientBattle.h"
+#include "../mapObjects/CGHeroInstance.h"
 #include "../serializer/JsonSerializeFormat.h"
 
 VCMI_LIB_NAMESPACE_BEGIN

+ 2 - 1
lib/mapObjects/CGTownBuilding.cpp

@@ -12,9 +12,10 @@
 #include "CGTownBuilding.h"
 #include "CGTownInstance.h"
 #include "../CGeneralTextHandler.h"
-#include "../NetPacks.h"
 #include "../IGameCallback.h"
 #include "../gameState/CGameState.h"
+#include "../mapObjects/CGHeroInstance.h"
+#include "../networkPacks/PacksForClient.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 4 - 1
lib/mapObjects/CGTownInstance.cpp

@@ -14,7 +14,6 @@
 #include "../spells/CSpellHandler.h"
 #include "../bonuses/Bonus.h"
 #include "../battle/IBattleInfoCallback.h"
-#include "../NetPacks.h"
 #include "../CConfigHandler.h"
 #include "../CGeneralTextHandler.h"
 #include "../IGameCallback.h"
@@ -24,7 +23,11 @@
 #include "../TerrainHandler.h"
 #include "../mapObjectConstructors/AObjectTypeHandler.h"
 #include "../mapObjectConstructors/CObjectClassesHandler.h"
+#include "../mapObjects/CGHeroInstance.h"
 #include "../modding/ModScope.h"
+#include "../networkPacks/StackLocation.h"
+#include "../networkPacks/PacksForClient.h"
+#include "../networkPacks/PacksForClientBattle.h"
 #include "../serializer/JsonSerializeFormat.h"
 
 VCMI_LIB_NAMESPACE_BEGIN

+ 1 - 0
lib/mapObjects/CObjectHandler.cpp

@@ -13,6 +13,7 @@
 
 #include "CGObjectInstance.h"
 #include "../filesystem/ResourcePath.h"
+#include "../JsonNode.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 2 - 1
lib/mapObjects/CQuest.cpp

@@ -14,7 +14,6 @@
 #include <vcmi/spells/Spell.h>
 
 #include "../ArtifactUtils.h"
-#include "../NetPacks.h"
 #include "../CSoundBase.h"
 #include "../CGeneralTextHandler.h"
 #include "../CHeroHandler.h"
@@ -26,8 +25,10 @@
 #include "../constants/StringConstants.h"
 #include "../CSkillHandler.h"
 #include "../mapping/CMap.h"
+#include "../mapObjects/CGHeroInstance.h"
 #include "../modding/ModScope.h"
 #include "../modding/ModUtility.h"
+#include "../networkPacks/PacksForClient.h"
 #include "../spells/CSpellHandler.h"
 
 VCMI_LIB_NAMESPACE_BEGIN

+ 2 - 1
lib/mapObjects/CRewardableObject.cpp

@@ -14,9 +14,10 @@
 #include "../CGeneralTextHandler.h"
 #include "../CPlayerState.h"
 #include "../IGameCallback.h"
-#include "../NetPacks.h"
 #include "../mapObjectConstructors/AObjectTypeHandler.h"
 #include "../mapObjectConstructors/CObjectClassesHandler.h"
+#include "../mapObjects/CGHeroInstance.h"
+#include "../networkPacks/PacksForClient.h"
 #include "../serializer/JsonSerializeFormat.h"
 
 VCMI_LIB_NAMESPACE_BEGIN

+ 2 - 1
lib/mapObjects/IObjectInterface.cpp

@@ -14,9 +14,10 @@
 #include "CGTownInstance.h"
 #include "MiscObjects.h"
 
-#include "../NetPacks.h"
 #include "../IGameCallback.h"
 #include "../TerrainHandler.h"
+#include "../mapObjects/CGHeroInstance.h"
+#include "../networkPacks/PacksForClient.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 5 - 1
lib/mapObjects/IObjectInterface.h

@@ -9,18 +9,22 @@
  */
 #pragma once
 
-#include "../NetPacksBase.h"
+#include "../networkPacks/EInfoWindowMode.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 
 struct BattleResult;
 struct UpgradeInfo;
+class BoatId;
 class CGObjectInstance;
 class CRandomGenerator;
+class CStackInstance;
+class CGHeroInstance;
 class IGameCallback;
 class ResourceSet;
 class int3;
 class MetaString;
+class PlayerColor;
 
 class DLL_LINKAGE IObjectInterface
 {

+ 4 - 1
lib/mapObjects/MiscObjects.cpp

@@ -12,7 +12,6 @@
 #include "MiscObjects.h"
 
 #include "../constants/StringConstants.h"
-#include "../NetPacks.h"
 #include "../CGeneralTextHandler.h"
 #include "../CSoundBase.h"
 #include "../CSkillHandler.h"
@@ -24,7 +23,11 @@
 #include "../serializer/JsonSerializeFormat.h"
 #include "../mapObjectConstructors/AObjectTypeHandler.h"
 #include "../mapObjectConstructors/CObjectClassesHandler.h"
+#include "../mapObjects/CGHeroInstance.h"
 #include "../modding/ModScope.h"
+#include "../networkPacks/PacksForClient.h"
+#include "../networkPacks/PacksForClientBattle.h"
+#include "../networkPacks/StackLocation.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 2 - 0
lib/mapping/MapFormatH3M.cpp

@@ -36,6 +36,8 @@
 #include "../mapObjects/MapObjects.h"
 #include "../mapObjects/ObjectTemplate.h"
 #include "../modding/ModScope.h"
+#include "../networkPacks/Component.h"
+#include "../networkPacks/ArtifactLocation.h"
 #include "../spells/CSpellHandler.h"
 
 #include <boost/crc.hpp>

+ 76 - 0
lib/networkPacks/ArtifactLocation.h

@@ -0,0 +1,76 @@
+/*
+ * ArtifactLocation.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 "../ConstTransitivePtr.h"
+#include "../constants/EntityIdentifiers.h"
+
+VCMI_LIB_NAMESPACE_BEGIN
+
+class CGHeroInstance;
+class CStackInstance;
+class CArmedInstance;
+class CArtifactSet;
+class CBonusSystemNode;
+struct ArtSlotInfo;
+
+using TArtHolder = std::variant<ConstTransitivePtr<CGHeroInstance>, ConstTransitivePtr<CStackInstance>>;
+
+struct ArtifactLocation
+{
+	TArtHolder artHolder;//TODO: identify holder by id
+	ArtifactPosition slot = ArtifactPosition::PRE_FIRST;
+
+	ArtifactLocation()
+		: artHolder(ConstTransitivePtr<CGHeroInstance>())
+	{
+	}
+	template<typename T>
+	ArtifactLocation(const T * ArtHolder, ArtifactPosition Slot)
+		: artHolder(const_cast<T *>(ArtHolder)) //we are allowed here to const cast -> change will go through one of our packages... do not abuse!
+		, slot(Slot)
+	{
+	}
+	ArtifactLocation(TArtHolder ArtHolder, const ArtifactPosition & Slot)
+		: artHolder(std::move(std::move(ArtHolder)))
+		, slot(Slot)
+	{
+	}
+
+	template <typename T>
+	bool isHolder(const T *t) const
+	{
+		if(auto ptrToT = std::get<ConstTransitivePtr<T>>(artHolder))
+		{
+			return ptrToT == t;
+		}
+		return false;
+	}
+
+	DLL_LINKAGE void removeArtifact(); // BE CAREFUL, this operation modifies holder (gs)
+
+	DLL_LINKAGE const CArmedInstance *relatedObj() const; //hero or the stack owner
+	DLL_LINKAGE PlayerColor owningPlayer() const;
+	DLL_LINKAGE CArtifactSet *getHolderArtSet();
+	DLL_LINKAGE CBonusSystemNode *getHolderNode();
+	DLL_LINKAGE CArtifactSet *getHolderArtSet() const;
+	DLL_LINKAGE const CBonusSystemNode *getHolderNode() const;
+
+	DLL_LINKAGE const CArtifactInstance *getArt() const;
+	DLL_LINKAGE CArtifactInstance *getArt();
+	DLL_LINKAGE const ArtSlotInfo *getSlot() const;
+	template <typename Handler> void serialize(Handler &h, const int version)
+	{
+		h & artHolder;
+		h & slot;
+	}
+};
+
+VCMI_LIB_NAMESPACE_END

+ 81 - 0
lib/networkPacks/BattleChanges.h

@@ -0,0 +1,81 @@
+/*
+ * BattleChanges.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 "JsonNode.h"
+
+VCMI_LIB_NAMESPACE_BEGIN
+
+class BattleChanges
+{
+public:
+	enum class EOperation : si8
+	{
+		ADD,
+		RESET_STATE,
+		UPDATE,
+		REMOVE,
+	};
+
+	JsonNode data;
+	EOperation operation = EOperation::RESET_STATE;
+
+	BattleChanges() = default;
+	explicit BattleChanges(EOperation operation_)
+		: operation(operation_)
+	{
+	}
+};
+
+class UnitChanges : public BattleChanges
+{
+public:
+	uint32_t id = 0;
+	int64_t healthDelta = 0;
+
+	UnitChanges() = default;
+	UnitChanges(uint32_t id_, EOperation operation_)
+		: BattleChanges(operation_)
+		, id(id_)
+	{
+	}
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & id;
+		h & healthDelta;
+		h & data;
+		h & operation;
+	}
+};
+
+class ObstacleChanges : public BattleChanges
+{
+public:
+	uint32_t id = 0;
+
+	ObstacleChanges() = default;
+
+	ObstacleChanges(uint32_t id_, EOperation operation_)
+		: BattleChanges(operation_),
+		id(id_)
+	{
+	}
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & id;
+		h & data;
+		h & operation;
+	}
+};
+
+VCMI_LIB_NAMESPACE_END
+

+ 54 - 0
lib/networkPacks/Component.h

@@ -0,0 +1,54 @@
+/*
+ * Component.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
+
+VCMI_LIB_NAMESPACE_BEGIN
+
+class CStackBasicDescriptor;
+
+struct Component
+{
+	enum class EComponentType : uint8_t
+	{
+		PRIM_SKILL,
+		SEC_SKILL,
+		RESOURCE,
+		CREATURE,
+		ARTIFACT,
+		EXPERIENCE,
+		SPELL,
+		MORALE,
+		LUCK,
+		BUILDING,
+		HERO_PORTRAIT,
+		FLAG,
+		INVALID //should be last
+	};
+	EComponentType id = EComponentType::INVALID;
+	ui16 subtype = 0; //id==EXPPERIENCE subtype==0 means exp points and subtype==1 levels
+	si32 val = 0; // + give; - take
+	si16 when = 0; // 0 - now; +x - within x days; -x - per x days
+
+	template <typename Handler> void serialize(Handler &h, const int version)
+	{
+		h & id;
+		h & subtype;
+		h & val;
+		h & when;
+	}
+	Component() = default;
+	DLL_LINKAGE explicit Component(const CStackBasicDescriptor &stack);
+	Component(Component::EComponentType Type, ui16 Subtype, si32 Val, si16 When)
+		:id(Type),subtype(Subtype),val(Val),when(When)
+	{
+	}
+};
+
+VCMI_LIB_NAMESPACE_END

+ 22 - 0
lib/networkPacks/EInfoWindowMode.h

@@ -0,0 +1,22 @@
+/*
+ * EInfoWindowMode.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
+
+VCMI_LIB_NAMESPACE_BEGIN
+
+enum class EInfoWindowMode : uint8_t
+{
+	AUTO,
+	MODAL,
+	INFO
+};
+
+VCMI_LIB_NAMESPACE_END
+

+ 28 - 0
lib/networkPacks/EOpenWindowMode.h

@@ -0,0 +1,28 @@
+/*
+ * EOpenWindowMode.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
+
+VCMI_LIB_NAMESPACE_BEGIN
+
+enum class EOpenWindowMode : uint8_t
+{
+	EXCHANGE_WINDOW,
+	RECRUITMENT_FIRST,
+	RECRUITMENT_ALL,
+	SHIPYARD_WINDOW,
+	THIEVES_GUILD,
+	UNIVERSITY_WINDOW,
+	HILL_FORT_WINDOW,
+	MARKET_WINDOW,
+	PUZZLE_MAP,
+	TAVERN_WINDOW
+};
+
+VCMI_LIB_NAMESPACE_END

+ 33 - 0
lib/networkPacks/EntityChanges.h

@@ -0,0 +1,33 @@
+/*
+ * EInfoWindowMode.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 <vcmi/Metatype.h>
+
+#include "../JsonNode.h"
+
+VCMI_LIB_NAMESPACE_BEGIN
+
+class EntityChanges
+{
+public:
+	Metatype metatype = Metatype::UNKNOWN;
+	int32_t entityIndex = 0;
+	JsonNode data;
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & metatype;
+		h & entityIndex;
+		h & data;
+	}
+};
+
+VCMI_LIB_NAMESPACE_END
+

+ 5 - 2
lib/NetPackVisitor.h → lib/networkPacks/NetPackVisitor.h

@@ -9,8 +9,11 @@
  */
 #pragma once
 
-#include "NetPacks.h"
-#include "NetPacksLobby.h"
+#include "PacksForClient.h"
+#include "PacksForClientBattle.h"
+#include "PacksForServer.h"
+#include "PacksForLobby.h"
+#include "SetStackEffect.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 85 - 0
lib/networkPacks/NetPacksBase.h

@@ -0,0 +1,85 @@
+/*
+ * NetPacksBase.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 "../constants/EntityIdentifiers.h"
+
+VCMI_LIB_NAMESPACE_BEGIN
+
+class CGameState;
+class CConnection;
+
+class ICPackVisitor;
+
+struct DLL_LINKAGE CPack
+{
+	std::shared_ptr<CConnection> c; // Pointer to connection that pack received from
+
+	CPack() = default;
+	virtual ~CPack() = default;
+
+	template <typename Handler> void serialize(Handler &h, const int version)
+	{
+		logNetwork->error("CPack serialized... this should not happen!");
+		assert(false && "CPack serialized");
+	}
+
+	void applyGs(CGameState * gs)
+	{}
+
+	void visit(ICPackVisitor & cpackVisitor);
+
+protected:
+	/// <summary>
+	/// For basic types of netpacks hierarchy like CPackForClient. Called first.
+	/// </summary>
+	virtual void visitBasic(ICPackVisitor & cpackVisitor);
+
+	/// <summary>
+	/// For leaf types of netpacks hierarchy. Called after visitBasic.
+	/// </summary>
+	virtual void visitTyped(ICPackVisitor & cpackVisitor);
+};
+
+struct DLL_LINKAGE CPackForClient : public CPack
+{
+protected:
+	void visitBasic(ICPackVisitor & cpackVisitor) override;
+};
+
+struct DLL_LINKAGE Query : public CPackForClient
+{
+	QueryID queryID; // equals to -1 if it is not an actual query (and should not be answered)
+};
+
+struct DLL_LINKAGE CPackForServer : public CPack
+{
+	mutable PlayerColor player = PlayerColor::NEUTRAL;
+	mutable si32 requestID;
+
+	template <typename Handler> void serialize(Handler &h, const int version)
+	{
+		h & player;
+		h & requestID;
+	}
+
+protected:
+	void visitBasic(ICPackVisitor & cpackVisitor) override;
+};
+
+struct DLL_LINKAGE CPackForLobby : public CPack
+{
+	virtual bool isForServer() const;
+
+protected:
+	void visitBasic(ICPackVisitor & cpackVisitor) override;
+};
+
+VCMI_LIB_NAMESPACE_END

+ 6 - 1
lib/NetPacksLib.cpp → lib/networkPacks/NetPacksLib.cpp

@@ -9,7 +9,12 @@
  */
 #include "StdInc.h"
 #include "ArtifactUtils.h"
-#include "NetPacks.h"
+#include "PacksForClient.h"
+#include "PacksForClientBattle.h"
+#include "PacksForServer.h"
+#include "StackLocation.h"
+#include "PacksForLobby.h"
+#include "SetStackEffect.h"
 #include "NetPackVisitor.h"
 #include "CGeneralTextHandler.h"
 #include "CArtHandler.h"

+ 1536 - 0
lib/networkPacks/PacksForClient.h

@@ -0,0 +1,1536 @@
+/*
+ * PacksForClient.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 "ArtifactLocation.h"
+#include "Component.h"
+#include "EInfoWindowMode.h"
+#include "EOpenWindowMode.h"
+#include "EntityChanges.h"
+#include "NetPacksBase.h"
+
+#include "../CCreatureSet.h"
+#include "../MetaString.h"
+#include "../ResourceSet.h"
+#include "../TurnTimerInfo.h"
+#include "../gameState/EVictoryLossCheckResult.h"
+#include "../gameState/QuestInfo.h"
+#include "../gameState/TavernSlot.h"
+#include "../int3.h"
+#include "../mapping/CMapDefines.h"
+#include "../spells/ViewSpellInt.h"
+
+class CClient;
+class CGameHandler;
+
+VCMI_LIB_NAMESPACE_BEGIN
+
+class CGameState;
+class CArtifact;
+class CGObjectInstance;
+class CArtifactInstance;
+struct StackLocation;
+struct ArtSlotInfo;
+struct QuestInfo;
+class IBattleState;
+class BattleInfo;
+
+// This one teleport-specific, but has to be available everywhere in callbacks and netpacks
+// For now it's will be there till teleports code refactored and moved into own file
+using TTeleportExitsList = std::vector<std::pair<ObjectInstanceID, int3>>;
+
+/***********************************************************************************************************/
+struct DLL_LINKAGE PackageApplied : public CPackForClient
+{
+	PackageApplied() = default;
+	explicit PackageApplied(ui8 Result)
+		: result(Result)
+	{
+	}
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	ui8 result = 0; //0 - something went wrong, request hasn't been realized; 1 - OK
+	ui32 packType = 0; //type id of applied package
+	ui32 requestID = 0; //an ID given by client to the request that was applied
+	PlayerColor player;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & result;
+		h & packType;
+		h & requestID;
+		h & player;
+	}
+};
+
+struct DLL_LINKAGE SystemMessage : public CPackForClient
+{
+	explicit SystemMessage(std::string Text)
+		: text(std::move(Text))
+	{
+	}
+	SystemMessage() = default;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	std::string text;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & text;
+	}
+};
+
+struct DLL_LINKAGE PlayerBlocked : public CPackForClient
+{
+	enum EReason { UPCOMING_BATTLE, ONGOING_MOVEMENT };
+	enum EMode { BLOCKADE_STARTED, BLOCKADE_ENDED };
+
+	EReason reason = UPCOMING_BATTLE;
+	EMode startOrEnd = BLOCKADE_STARTED;
+	PlayerColor player;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & reason;
+		h & startOrEnd;
+		h & player;
+	}
+};
+
+struct DLL_LINKAGE PlayerCheated : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	PlayerColor player;
+	bool losingCheatCode = false;
+	bool winningCheatCode = false;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & player;
+		h & losingCheatCode;
+		h & winningCheatCode;
+	}
+};
+
+struct DLL_LINKAGE TurnTimeUpdate : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+	
+	PlayerColor player;
+	TurnTimerInfo turnTimer;
+		
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & player;
+		h & turnTimer;
+	}
+};
+
+struct DLL_LINKAGE PlayerStartsTurn : public Query
+{
+	void applyGs(CGameState * gs) const;
+
+	PlayerColor player;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & queryID;
+		h & player;
+	}
+};
+
+struct DLL_LINKAGE DaysWithoutTown : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	PlayerColor player;
+	std::optional<int32_t> daysWithoutCastle;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & player;
+		h & daysWithoutCastle;
+	}
+};
+
+struct DLL_LINKAGE EntitiesChanged : public CPackForClient
+{
+	std::vector<EntityChanges> changes;
+
+	void applyGs(CGameState * gs);
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & changes;
+	}
+};
+
+struct DLL_LINKAGE SetResources : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	bool abs = true; //false - changes by value; 1 - sets to value
+	PlayerColor player;
+	ResourceSet res; //res[resid] => res amount
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & abs;
+		h & player;
+		h & res;
+	}
+};
+
+struct DLL_LINKAGE SetPrimSkill : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	ui8 abs = 0; //0 - changes by value; 1 - sets to value
+	ObjectInstanceID id;
+	PrimarySkill which = PrimarySkill::ATTACK;
+	si64 val = 0;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & abs;
+		h & id;
+		h & which;
+		h & val;
+	}
+};
+
+struct DLL_LINKAGE SetSecSkill : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	ui8 abs = 0; //0 - changes by value; 1 - sets to value
+	ObjectInstanceID id;
+	SecondarySkill which;
+	ui16 val = 0;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & abs;
+		h & id;
+		h & which;
+		h & val;
+	}
+};
+
+struct DLL_LINKAGE HeroVisitCastle : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	ui8 flags = 0; //1 - start
+	ObjectInstanceID tid, hid;
+
+	bool start() const //if hero is entering castle (if false - leaving)
+	{
+		return flags & 1;
+	}
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & flags;
+		h & tid;
+		h & hid;
+	}
+};
+
+struct DLL_LINKAGE ChangeSpells : public CPackForClient
+{
+	void applyGs(CGameState * gs);
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	ui8 learn = 1; //1 - gives spell, 0 - takes
+	ObjectInstanceID hid;
+	std::set<SpellID> spells;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & learn;
+		h & hid;
+		h & spells;
+	}
+};
+
+struct DLL_LINKAGE SetMana : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	ObjectInstanceID hid;
+	si32 val = 0;
+	bool absolute = true;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & val;
+		h & hid;
+		h & absolute;
+	}
+};
+
+struct DLL_LINKAGE SetMovePoints : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	ObjectInstanceID hid;
+	si32 val = 0;
+	bool absolute = true;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & val;
+		h & hid;
+		h & absolute;
+	}
+};
+
+struct DLL_LINKAGE FoWChange : public CPackForClient
+{
+	void applyGs(CGameState * gs);
+
+	std::unordered_set<int3> tiles;
+	PlayerColor player;
+	ETileVisibility mode;
+	bool waitForDialogs = false;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & tiles;
+		h & player;
+		h & mode;
+		h & waitForDialogs;
+	}
+};
+
+struct DLL_LINKAGE SetAvailableHero : public CPackForClient
+{
+	SetAvailableHero()
+	{
+		army.clearSlots();
+	}
+	void applyGs(CGameState * gs);
+
+	TavernHeroSlot slotID;
+	TavernSlotRole roleID;
+	PlayerColor player;
+	HeroTypeID hid; //HeroTypeID::NONE if no hero
+	CSimpleArmy army;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & slotID;
+		h & roleID;
+		h & player;
+		h & hid;
+		h & army;
+	}
+};
+
+struct DLL_LINKAGE GiveBonus : public CPackForClient
+{
+	enum class ETarget : ui8 { HERO, PLAYER, TOWN, BATTLE };
+	
+	explicit GiveBonus(ETarget Who = ETarget::HERO)
+		:who(Who)
+	{
+	}
+
+	void applyGs(CGameState * gs);
+
+	ETarget who = ETarget::HERO; //who receives bonus
+	si32 id = 0; //hero. town or player id - whoever receives it
+	Bonus bonus;
+	MetaString bdescr;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & bonus;
+		h & id;
+		h & bdescr;
+		h & who;
+		assert(id != -1);
+	}
+};
+
+struct DLL_LINKAGE ChangeObjPos : public CPackForClient
+{
+	void applyGs(CGameState * gs);
+
+	/// Object to move
+	ObjectInstanceID objid;
+	/// New position of visitable tile of an object
+	int3 nPos;
+	/// Player that initiated this action, if any
+	PlayerColor initiator;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & objid;
+		h & nPos;
+		h & initiator;
+	}
+};
+
+struct DLL_LINKAGE PlayerEndsTurn : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	PlayerColor player;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & player;
+	}
+};
+
+struct DLL_LINKAGE PlayerEndsGame : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	PlayerColor player;
+	EVictoryLossCheckResult victoryLossCheckResult;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & player;
+		h & victoryLossCheckResult;
+	}
+};
+
+struct DLL_LINKAGE PlayerReinitInterface : public CPackForClient
+{
+	void applyGs(CGameState * gs);
+
+	std::vector<PlayerColor> players;
+	ui8 playerConnectionId; //PLAYER_AI for AI player
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & players;
+		h & playerConnectionId;
+	}
+};
+
+struct DLL_LINKAGE RemoveBonus : public CPackForClient
+{
+	explicit RemoveBonus(GiveBonus::ETarget Who = GiveBonus::ETarget::HERO)
+		:who(Who)
+	{
+	}
+
+	void applyGs(CGameState * gs);
+
+	GiveBonus::ETarget who; //who receives bonus
+	ui32 whoID = 0; //hero, town or player id - whoever loses bonus
+
+	//vars to identify bonus: its source
+	BonusSource source;
+	BonusSourceID id; //source id
+
+	//used locally: copy of removed bonus
+	Bonus bonus;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & source;
+		h & id;
+		h & who;
+		h & whoID;
+	}
+};
+
+struct DLL_LINKAGE SetCommanderProperty : public CPackForClient
+{
+	enum ECommanderProperty { ALIVE, BONUS, SECONDARY_SKILL, EXPERIENCE, SPECIAL_SKILL };
+
+	void applyGs(CGameState * gs);
+
+	ObjectInstanceID heroid;
+
+	ECommanderProperty which = ALIVE;
+	TExpType amount = 0; //0 for dead, >0 for alive
+	si32 additionalInfo = 0; //for secondary skills choice
+	Bonus accumulatedBonus;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & heroid;
+		h & which;
+		h & amount;
+		h & additionalInfo;
+		h & accumulatedBonus;
+	}
+};
+
+struct DLL_LINKAGE AddQuest : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	PlayerColor player;
+	QuestInfo quest;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & player;
+		h & quest;
+	}
+};
+
+struct DLL_LINKAGE UpdateArtHandlerLists : public CPackForClient
+{
+	std::map<ArtifactID, int> allocatedArtifacts;
+
+	void applyGs(CGameState * gs) const;
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & allocatedArtifacts;
+	}
+};
+
+struct DLL_LINKAGE UpdateMapEvents : public CPackForClient
+{
+	std::list<CMapEvent> events;
+
+	void applyGs(CGameState * gs) const;
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & events;
+	}
+};
+
+struct DLL_LINKAGE UpdateCastleEvents : public CPackForClient
+{
+	ObjectInstanceID town;
+	std::list<CCastleEvent> events;
+
+	void applyGs(CGameState * gs) const;
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & town;
+		h & events;
+	}
+};
+
+struct DLL_LINKAGE ChangeFormation : public CPackForClient
+{
+	ObjectInstanceID hid;
+	ui8 formation = 0;
+
+	void applyGs(CGameState * gs) const;
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & hid;
+		h & formation;
+	}
+};
+
+struct DLL_LINKAGE RemoveObject : public CPackForClient
+{
+	RemoveObject() = default;
+	RemoveObject(const ObjectInstanceID & objectID, const PlayerColor & initiator)
+		: objectID(objectID)
+		, initiator(initiator)
+	{
+	}
+
+	void applyGs(CGameState * gs);
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	/// ID of removed object
+	ObjectInstanceID objectID;
+
+	/// Player that initiated this action, if any
+	PlayerColor initiator;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & objectID;
+		h & initiator;
+	}
+};
+
+struct DLL_LINKAGE TryMoveHero : public CPackForClient
+{
+	void applyGs(CGameState * gs);
+
+	enum EResult
+	{
+		FAILED,
+		SUCCESS,
+		TELEPORTATION,
+		BLOCKING_VISIT,
+		EMBARK,
+		DISEMBARK
+	};
+
+	ObjectInstanceID id;
+	ui32 movePoints = 0;
+	EResult result = FAILED; //uses EResult
+	int3 start, end; //h3m format
+	std::unordered_set<int3> fowRevealed; //revealed tiles
+	std::optional<int3> attackedFrom; // Set when stepping into endangered tile.
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	bool stopMovement() const
+	{
+		return result != SUCCESS && result != EMBARK && result != DISEMBARK && result != TELEPORTATION;
+	}
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & id;
+		h & result;
+		h & start;
+		h & end;
+		h & movePoints;
+		h & fowRevealed;
+		h & attackedFrom;
+	}
+};
+
+struct DLL_LINKAGE NewStructures : public CPackForClient
+{
+	void applyGs(CGameState * gs);
+
+	ObjectInstanceID tid;
+	std::set<BuildingID> bid;
+	si16 builded = 0;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & tid;
+		h & bid;
+		h & builded;
+	}
+};
+
+struct DLL_LINKAGE RazeStructures : public CPackForClient
+{
+	void applyGs(CGameState * gs);
+
+	ObjectInstanceID tid;
+	std::set<BuildingID> bid;
+	si16 destroyed = 0;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & tid;
+		h & bid;
+		h & destroyed;
+	}
+};
+
+struct DLL_LINKAGE SetAvailableCreatures : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	ObjectInstanceID tid;
+	std::vector<std::pair<ui32, std::vector<CreatureID> > > creatures;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & tid;
+		h & creatures;
+	}
+};
+
+struct DLL_LINKAGE SetHeroesInTown : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	ObjectInstanceID tid, visiting, garrison; //id of town, visiting hero, hero in garrison
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & tid;
+		h & visiting;
+		h & garrison;
+	}
+};
+
+struct DLL_LINKAGE HeroRecruited : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	HeroTypeID hid; //subID of hero
+	ObjectInstanceID tid;
+	ObjectInstanceID boatId;
+	int3 tile;
+	PlayerColor player;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & hid;
+		h & tid;
+		h & boatId;
+		h & tile;
+		h & player;
+	}
+};
+
+struct DLL_LINKAGE GiveHero : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	ObjectInstanceID id; //object id
+	ObjectInstanceID boatId;
+	PlayerColor player;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & id;
+		h & boatId;
+		h & player;
+	}
+};
+
+struct DLL_LINKAGE OpenWindow : public Query
+{
+	EOpenWindowMode window;
+	ObjectInstanceID object;
+	ObjectInstanceID visitor;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & queryID;
+		h & window;
+		h & object;
+		h & visitor;
+	}
+};
+
+struct DLL_LINKAGE NewObject : public CPackForClient
+{
+	void applyGs(CGameState * gs);
+
+	/// Object ID to create
+	Obj ID;
+	/// Object secondary ID to create
+	ui32 subID = 0;
+	/// Position of visitable tile of created object
+	int3 targetPos;
+	/// Which player initiated creation of this object
+	PlayerColor initiator;
+
+	ObjectInstanceID createdObjectID; //used locally, filled during applyGs
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & ID;
+		h & subID;
+		h & targetPos;
+		h & initiator;
+	}
+};
+
+struct DLL_LINKAGE SetAvailableArtifacts : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	si32 id = 0; //two variants: id < 0: set artifact pool for Artifact Merchants in towns; id >= 0: set pool for adv. map Black Market (id is the id of Black Market instance then)
+	std::vector<const CArtifact *> arts;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & id;
+		h & arts;
+	}
+};
+
+struct DLL_LINKAGE CGarrisonOperationPack : CPackForClient
+{
+};
+
+struct DLL_LINKAGE ChangeStackCount : CGarrisonOperationPack
+{
+	ObjectInstanceID army;
+	SlotID slot;
+	TQuantity count;
+	bool absoluteValue; //if not -> count will be added (or subtracted if negative)
+
+	void applyGs(CGameState * gs);
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & army;
+		h & slot;
+		h & count;
+		h & absoluteValue;
+	}
+};
+
+struct DLL_LINKAGE SetStackType : CGarrisonOperationPack
+{
+	ObjectInstanceID army;
+	SlotID slot;
+	CreatureID type;
+
+	void applyGs(CGameState * gs);
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & army;
+		h & slot;
+		h & type;
+	}
+};
+
+struct DLL_LINKAGE EraseStack : CGarrisonOperationPack
+{
+	ObjectInstanceID army;
+	SlotID slot;
+
+	void applyGs(CGameState * gs);
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & army;
+		h & slot;
+	}
+};
+
+struct DLL_LINKAGE SwapStacks : CGarrisonOperationPack
+{
+	ObjectInstanceID srcArmy;
+	ObjectInstanceID dstArmy;
+	SlotID srcSlot;
+	SlotID dstSlot;
+
+	void applyGs(CGameState * gs);
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & srcArmy;
+		h & dstArmy;
+		h & srcSlot;
+		h & dstSlot;
+	}
+};
+
+struct DLL_LINKAGE InsertNewStack : CGarrisonOperationPack
+{
+	ObjectInstanceID army;
+	SlotID slot;
+	CreatureID type;
+	TQuantity count = 0;
+
+	void applyGs(CGameState * gs);
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & army;
+		h & slot;
+		h & type;
+		h & count;
+	}
+};
+
+///moves creatures from src stack to dst slot, may be used for merging/splittint/moving stacks
+struct DLL_LINKAGE RebalanceStacks : CGarrisonOperationPack
+{
+	ObjectInstanceID srcArmy;
+	ObjectInstanceID dstArmy;
+	SlotID srcSlot;
+	SlotID dstSlot;
+
+	TQuantity count;
+
+	void applyGs(CGameState * gs);
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & srcArmy;
+		h & dstArmy;
+		h & srcSlot;
+		h & dstSlot;
+		h & count;
+	}
+};
+
+struct DLL_LINKAGE BulkRebalanceStacks : CGarrisonOperationPack
+{
+	std::vector<RebalanceStacks> moves;
+
+	void applyGs(CGameState * gs);
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler>
+	void serialize(Handler & h, const int version)
+	{
+		h & moves;
+	}
+};
+
+struct DLL_LINKAGE BulkSmartRebalanceStacks : CGarrisonOperationPack
+{
+	std::vector<RebalanceStacks> moves;
+	std::vector<ChangeStackCount> changes;
+
+	void applyGs(CGameState * gs);
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler>
+	void serialize(Handler & h, const int version)
+	{
+		h & moves;
+		h & changes;
+	}
+};
+
+struct DLL_LINKAGE CArtifactOperationPack : CPackForClient
+{
+};
+
+struct DLL_LINKAGE PutArtifact : CArtifactOperationPack
+{
+	PutArtifact() = default;
+	explicit PutArtifact(ArtifactLocation * dst, bool askAssemble = true)
+		: al(*dst), askAssemble(askAssemble)
+	{
+	}
+
+	ArtifactLocation al;
+	bool askAssemble = false;
+	ConstTransitivePtr<CArtifactInstance> art;
+
+	void applyGs(CGameState * gs);
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & al;
+		h & askAssemble;
+		h & art;
+	}
+};
+
+struct DLL_LINKAGE NewArtifact : public CArtifactOperationPack
+{
+	ConstTransitivePtr<CArtifactInstance> art;
+
+	void applyGs(CGameState * gs);
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & art;
+	}
+};
+
+struct DLL_LINKAGE EraseArtifact : CArtifactOperationPack
+{
+	ArtifactLocation al;
+
+	void applyGs(CGameState * gs);
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & al;
+	}
+};
+
+struct DLL_LINKAGE MoveArtifact : CArtifactOperationPack
+{
+	MoveArtifact() = default;
+	MoveArtifact(ArtifactLocation * src, ArtifactLocation * dst, bool askAssemble = true)
+		: src(*src), dst(*dst), askAssemble(askAssemble)
+	{
+	}
+	ArtifactLocation src, dst;
+	bool askAssemble = true;
+
+	void applyGs(CGameState * gs);
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & src;
+		h & dst;
+		h & askAssemble;
+	}
+};
+
+struct DLL_LINKAGE BulkMoveArtifacts : CArtifactOperationPack
+{
+	struct LinkedSlots
+	{
+		ArtifactPosition srcPos;
+		ArtifactPosition dstPos;
+
+		LinkedSlots() = default;
+		LinkedSlots(const ArtifactPosition & srcPos, const ArtifactPosition & dstPos)
+			: srcPos(srcPos)
+			, dstPos(dstPos)
+		{
+		}
+		template <typename Handler> void serialize(Handler & h, const int version)
+		{
+			h & srcPos;
+			h & dstPos;
+		}
+	};
+
+	TArtHolder srcArtHolder;
+	TArtHolder dstArtHolder;
+
+	BulkMoveArtifacts()
+		: swap(false)
+	{
+	}
+	BulkMoveArtifacts(TArtHolder srcArtHolder, TArtHolder dstArtHolder, bool swap)
+		: srcArtHolder(std::move(srcArtHolder))
+		, dstArtHolder(std::move(dstArtHolder))
+		, swap(swap)
+	{
+	}
+
+	void applyGs(CGameState * gs);
+
+	std::vector<LinkedSlots> artsPack0;
+	std::vector<LinkedSlots> artsPack1;
+	bool swap;
+	CArtifactSet * getSrcHolderArtSet();
+	CArtifactSet * getDstHolderArtSet();
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & artsPack0;
+		h & artsPack1;
+		h & srcArtHolder;
+		h & dstArtHolder;
+		h & swap;
+	}
+};
+
+struct DLL_LINKAGE AssembledArtifact : CArtifactOperationPack
+{
+	ArtifactLocation al; //where assembly will be put
+	CArtifact * builtArt;
+
+	void applyGs(CGameState * gs);
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & al;
+		h & builtArt;
+	}
+};
+
+struct DLL_LINKAGE DisassembledArtifact : CArtifactOperationPack
+{
+	ArtifactLocation al;
+
+	void applyGs(CGameState * gs);
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & al;
+	}
+};
+
+struct DLL_LINKAGE HeroVisit : public CPackForClient
+{
+	PlayerColor player;
+	ObjectInstanceID heroId;
+	ObjectInstanceID objId;
+
+	bool starting; //false -> ending
+
+	void applyGs(CGameState * gs);
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & player;
+		h & heroId;
+		h & objId;
+		h & starting;
+	}
+};
+
+struct DLL_LINKAGE NewTurn : public CPackForClient
+{
+	enum weekType { NORMAL, DOUBLE_GROWTH, BONUS_GROWTH, DEITYOFFIRE, PLAGUE, NO_ACTION };
+
+	void applyGs(CGameState * gs);
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	struct Hero
+	{
+		ObjectInstanceID id;
+		ui32 move, mana; //id is a general serial id
+		template <typename Handler> void serialize(Handler & h, const int version)
+		{
+			h & id;
+			h & move;
+			h & mana;
+		}
+		bool operator<(const Hero & h)const { return id < h.id; }
+	};
+
+	std::set<Hero> heroes; //updates movement and mana points
+	std::map<PlayerColor, ResourceSet> res; //player ID => resource value[res_id]
+	std::map<ObjectInstanceID, SetAvailableCreatures> cres;//creatures to be placed in towns
+	ui32 day = 0;
+	ui8 specialWeek = 0; //weekType
+	CreatureID creatureid; //for creature weeks
+
+	NewTurn() = default;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & heroes;
+		h & cres;
+		h & res;
+		h & day;
+		h & specialWeek;
+		h & creatureid;
+	}
+};
+
+struct DLL_LINKAGE InfoWindow : public CPackForClient //103  - displays simple info window
+{
+	EInfoWindowMode type = EInfoWindowMode::MODAL;
+	MetaString text;
+	std::vector<Component> components;
+	PlayerColor player;
+	ui16 soundID = 0;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & type;
+		h & text;
+		h & components;
+		h & player;
+		h & soundID;
+	}
+	InfoWindow() = default;
+};
+
+namespace ObjProperty
+{
+	enum
+	{
+		OWNER = 1, BLOCKVIS = 2, PRIMARY_STACK_COUNT = 3, VISITORS = 4, VISITED = 5, ID = 6, AVAILABLE_CREATURE = 7, SUBID = 8,
+		MONSTER_COUNT = 10, MONSTER_POWER = 11, MONSTER_EXP = 12, MONSTER_RESTORE_TYPE = 13, MONSTER_REFUSED_JOIN,
+
+		//town-specific
+		STRUCTURE_ADD_VISITING_HERO, STRUCTURE_CLEAR_VISITORS, STRUCTURE_ADD_GARRISONED_HERO,  //changing buildings state
+		BONUS_VALUE_FIRST, BONUS_VALUE_SECOND, //used in Rampart for special building that generates resources (storing resource type and quantity)
+
+		//creature-bank specific
+		BANK_DAYCOUNTER, BANK_RESET, BANK_CLEAR,
+
+		//object with reward
+		REWARD_RANDOMIZE, REWARD_SELECT, REWARD_CLEARED
+	};
+}
+
+struct DLL_LINKAGE SetObjectProperty : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+	ObjectInstanceID id;
+	ui8 what = 0; // see ObjProperty enum
+	ui32 val = 0;
+	SetObjectProperty() = default;
+	SetObjectProperty(const ObjectInstanceID & ID, ui8 What, ui32 Val)
+		: id(ID)
+		, what(What)
+		, val(Val)
+	{
+	}
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & id;
+		h & what;
+		h & val;
+	}
+};
+
+struct DLL_LINKAGE ChangeObjectVisitors : public CPackForClient
+{
+	enum VisitMode
+	{
+		VISITOR_ADD,      // mark hero as one that have visited this object
+		VISITOR_ADD_TEAM, // mark team as one that have visited this object
+		VISITOR_REMOVE,   // unmark visitor, reversed to ADD
+		VISITOR_CLEAR     // clear all visitors from this object (object reset)
+	};
+	ui32 mode = VISITOR_CLEAR; // uses VisitMode enum
+	ObjectInstanceID object;
+	ObjectInstanceID hero; // note: hero owner will be also marked as "visited" this object
+
+	void applyGs(CGameState * gs) const;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	ChangeObjectVisitors() = default;
+
+	ChangeObjectVisitors(ui32 mode, const ObjectInstanceID & object, const ObjectInstanceID & heroID = ObjectInstanceID(-1))
+		: mode(mode)
+		, object(object)
+		, hero(heroID)
+	{
+	}
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & object;
+		h & hero;
+		h & mode;
+	}
+};
+
+struct DLL_LINKAGE PrepareHeroLevelUp : public CPackForClient
+{
+	ObjectInstanceID heroId;
+
+	/// Do not serialize, used by server only
+	std::vector<SecondarySkill> skills;
+
+	void applyGs(CGameState * gs);
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & heroId;
+	}
+};
+
+struct DLL_LINKAGE HeroLevelUp : public Query
+{
+	PlayerColor player;
+	ObjectInstanceID heroId;
+
+	PrimarySkill primskill = PrimarySkill::ATTACK;
+	std::vector<SecondarySkill> skills;
+
+	void applyGs(CGameState * gs) const;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & queryID;
+		h & player;
+		h & heroId;
+		h & primskill;
+		h & skills;
+	}
+};
+
+struct DLL_LINKAGE CommanderLevelUp : public Query
+{
+	PlayerColor player;
+	ObjectInstanceID heroId;
+
+	std::vector<ui32> skills; //0-5 - secondary skills, val-100 - special skill
+
+	void applyGs(CGameState * gs) const;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & queryID;
+		h & player;
+		h & heroId;
+		h & skills;
+	}
+};
+
+//A dialog that requires making decision by player - it may contain components to choose between or has yes/no options
+//Client responds with QueryReply, where answer: 0 - cancel pressed, choice doesn't matter; 1/2/...  - first/second/... component selected and OK pressed
+//Until sending reply player won't be allowed to take any actions
+struct DLL_LINKAGE BlockingDialog : public Query
+{
+	enum { ALLOW_CANCEL = 1, SELECTION = 2 };
+	MetaString text;
+	std::vector<Component> components;
+	PlayerColor player;
+	ui8 flags = 0;
+	ui16 soundID = 0;
+
+	bool cancel() const
+	{
+		return flags & ALLOW_CANCEL;
+	}
+	bool selection() const
+	{
+		return flags & SELECTION;
+	}
+
+	BlockingDialog(bool yesno, bool Selection)
+	{
+		if(yesno) flags |= ALLOW_CANCEL;
+		if(Selection) flags |= SELECTION;
+	}
+	BlockingDialog() = default;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & queryID;
+		h & text;
+		h & components;
+		h & player;
+		h & flags;
+		h & soundID;
+	}
+};
+
+struct DLL_LINKAGE GarrisonDialog : public Query
+{
+	ObjectInstanceID objid, hid;
+	bool removableUnits = false;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & queryID;
+		h & objid;
+		h & hid;
+		h & removableUnits;
+	}
+};
+
+struct DLL_LINKAGE ExchangeDialog : public Query
+{
+	PlayerColor player;
+
+	ObjectInstanceID hero1;
+	ObjectInstanceID hero2;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & queryID;
+		h & player;
+		h & hero1;
+		h & hero2;
+	}
+};
+
+struct DLL_LINKAGE TeleportDialog : public Query
+{
+	TeleportDialog() = default;
+
+	TeleportDialog(const ObjectInstanceID & hero, const TeleportChannelID & Channel)
+		: hero(hero)
+		, channel(Channel)
+	{
+	}
+	ObjectInstanceID hero;
+	TeleportChannelID channel;
+	TTeleportExitsList exits;
+	bool impassable = false;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & queryID;
+		h & hero;
+		h & channel;
+		h & exits;
+		h & impassable;
+	}
+};
+
+struct DLL_LINKAGE MapObjectSelectDialog : public Query
+{
+	PlayerColor player;
+	Component icon;
+	MetaString title;
+	MetaString description;
+	std::vector<ObjectInstanceID> objects;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & queryID;
+		h & player;
+		h & icon;
+		h & title;
+		h & description;
+		h & objects;
+	}
+};
+
+struct DLL_LINKAGE AdvmapSpellCast : public CPackForClient
+{
+	ObjectInstanceID casterID;
+	SpellID spellID;
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & casterID;
+		h & spellID;
+	}
+
+protected:
+	void visitTyped(ICPackVisitor & visitor) override;
+};
+
+struct DLL_LINKAGE ShowWorldViewEx : public CPackForClient
+{
+	PlayerColor player;
+	bool showTerrain; // TODO: send terrain state
+
+	std::vector<ObjectPosInfo> objectPositions;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & player;
+		h & showTerrain;
+		h & objectPositions;
+	}
+
+protected:
+	void visitTyped(ICPackVisitor & visitor) override;
+};
+
+struct DLL_LINKAGE PlayerMessageClient : public CPackForClient
+{
+	PlayerMessageClient() = default;
+	PlayerMessageClient(const PlayerColor & Player, std::string Text)
+		: player(Player)
+		, text(std::move(Text))
+	{
+	}
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	PlayerColor player;
+	std::string text;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & player;
+		h & text;
+	}
+};
+
+struct DLL_LINKAGE CenterView : public CPackForClient
+{
+	PlayerColor player;
+	int3 pos;
+	ui32 focusTime = 0; //ms
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & pos;
+		h & player;
+		h & focusTime;
+	}
+};
+
+VCMI_LIB_NAMESPACE_END

+ 557 - 0
lib/networkPacks/PacksForClientBattle.h

@@ -0,0 +1,557 @@
+/*
+ * PacksForClientBattle.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 "BattleChanges.h"
+#include "../MetaString.h"
+#include "../battle/BattleAction.h"
+
+class CClient;
+
+VCMI_LIB_NAMESPACE_BEGIN
+
+class CGHeroInstance;
+class CArmedInstance;
+class IBattleState;
+class BattleInfo;
+
+struct DLL_LINKAGE BattleStart : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	BattleID battleID = BattleID::NONE;
+	BattleInfo * info = nullptr;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & info;
+		assert(battleID != BattleID::NONE);
+	}
+};
+
+struct DLL_LINKAGE BattleNextRound : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	BattleID battleID = BattleID::NONE;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		assert(battleID != BattleID::NONE);
+	}
+};
+
+struct DLL_LINKAGE BattleSetActiveStack : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	BattleID battleID = BattleID::NONE;
+	ui32 stack = 0;
+	ui8 askPlayerInterface = true;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & stack;
+		h & askPlayerInterface;
+		assert(battleID != BattleID::NONE);
+	}
+};
+
+struct DLL_LINKAGE BattleCancelled: public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	BattleID battleID = BattleID::NONE;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		assert(battleID != BattleID::NONE);
+	}
+};
+
+struct DLL_LINKAGE BattleResultAccepted : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	struct HeroBattleResults
+	{
+		HeroBattleResults()
+			: hero(nullptr), army(nullptr), exp(0) {}
+
+		CGHeroInstance * hero;
+		CArmedInstance * army;
+		TExpType exp;
+
+		template <typename Handler> void serialize(Handler & h, const int version)
+		{
+			h & hero;
+			h & army;
+			h & exp;
+		}
+	};
+
+	BattleID battleID = BattleID::NONE;
+	std::array<HeroBattleResults, 2> heroResult;
+	ui8 winnerSide;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & heroResult;
+		h & winnerSide;
+		assert(battleID != BattleID::NONE);
+	}
+};
+
+struct DLL_LINKAGE BattleResult : public Query
+{
+	void applyFirstCl(CClient * cl);
+
+	BattleID battleID = BattleID::NONE;
+	EBattleResult result = EBattleResult::NORMAL;
+	ui8 winner = 2; //0 - attacker, 1 - defender, [2 - draw (should be possible?)]
+	std::map<ui32, si32> casualties[2]; //first => casualties of attackers - map crid => number
+	TExpType exp[2] = {0, 0}; //exp for attacker and defender
+	std::set<ArtifactInstanceID> artifacts; //artifacts taken from loser to winner - currently unused
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & queryID;
+		h & result;
+		h & winner;
+		h & casualties[0];
+		h & casualties[1];
+		h & exp;
+		h & artifacts;
+		assert(battleID != BattleID::NONE);
+	}
+};
+
+struct DLL_LINKAGE BattleLogMessage : public CPackForClient
+{
+	BattleID battleID = BattleID::NONE;
+	std::vector<MetaString> lines;
+
+	void applyGs(CGameState * gs);
+	void applyBattle(IBattleState * battleState);
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & lines;
+		assert(battleID != BattleID::NONE);
+	}
+};
+
+struct DLL_LINKAGE BattleStackMoved : public CPackForClient
+{
+	BattleID battleID = BattleID::NONE;
+	ui32 stack = 0;
+	std::vector<BattleHex> tilesToMove;
+	int distance = 0;
+	bool teleporting = false;
+
+	void applyGs(CGameState * gs);
+	void applyBattle(IBattleState * battleState);
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & stack;
+		h & tilesToMove;
+		h & distance;
+		h & teleporting;
+		assert(battleID != BattleID::NONE);
+	}
+};
+
+struct DLL_LINKAGE BattleUnitsChanged : public CPackForClient
+{
+	void applyGs(CGameState * gs);
+	void applyBattle(IBattleState * battleState);
+
+	BattleID battleID = BattleID::NONE;
+	std::vector<UnitChanges> changedStacks;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & changedStacks;
+		assert(battleID != BattleID::NONE);
+	}
+};
+
+struct BattleStackAttacked
+{
+	DLL_LINKAGE void applyGs(CGameState * gs);
+	DLL_LINKAGE void applyBattle(IBattleState * battleState);
+
+	BattleID battleID = BattleID::NONE;
+	ui32 stackAttacked = 0, attackerID = 0;
+	ui32 killedAmount = 0;
+	int64_t damageAmount = 0;
+	UnitChanges newState;
+	enum EFlags { KILLED = 1, SECONDARY = 2, REBIRTH = 4, CLONE_KILLED = 8, SPELL_EFFECT = 16, FIRE_SHIELD = 32, };
+	ui32 flags = 0; //uses EFlags (above)
+	SpellID spellID = SpellID::NONE; //only if flag SPELL_EFFECT is set
+
+	bool killed() const//if target stack was killed
+	{
+		return flags & KILLED || flags & CLONE_KILLED;
+	}
+	bool cloneKilled() const
+	{
+		return flags & CLONE_KILLED;
+	}
+	bool isSecondary() const//if stack was not a primary target (receives no spell effects)
+	{
+		return flags & SECONDARY;
+	}
+	///Attacked with spell (SPELL_LIKE_ATTACK)
+	bool isSpell() const
+	{
+		return flags & SPELL_EFFECT;
+	}
+	bool willRebirth() const//resurrection, e.g. Phoenix
+	{
+		return flags & REBIRTH;
+	}
+	bool fireShield() const
+	{
+		return flags & FIRE_SHIELD;
+	}
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & stackAttacked;
+		h & attackerID;
+		h & newState;
+		h & flags;
+		h & killedAmount;
+		h & damageAmount;
+		h & spellID;
+		assert(battleID != BattleID::NONE);
+	}
+	bool operator<(const BattleStackAttacked & b) const
+	{
+		return stackAttacked < b.stackAttacked;
+	}
+};
+
+struct DLL_LINKAGE BattleAttack : public CPackForClient
+{
+	void applyGs(CGameState * gs);
+	BattleUnitsChanged attackerChanges;
+
+	BattleID battleID = BattleID::NONE;
+	std::vector<BattleStackAttacked> bsa;
+	ui32 stackAttacking = 0;
+	ui32 flags = 0; //uses Eflags (below)
+	enum EFlags { SHOT = 1, COUNTER = 2, LUCKY = 4, UNLUCKY = 8, BALLISTA_DOUBLE_DMG = 16, DEATH_BLOW = 32, SPELL_LIKE = 64, LIFE_DRAIN = 128 };
+
+	BattleHex tile;
+	SpellID spellID = SpellID::NONE; //for SPELL_LIKE
+
+	bool shot() const//distance attack - decrease number of shots
+	{
+		return flags & SHOT;
+	}
+	bool counter() const//is it counterattack?
+	{
+		return flags & COUNTER;
+	}
+	bool lucky() const
+	{
+		return flags & LUCKY;
+	}
+	bool unlucky() const
+	{
+		return flags & UNLUCKY;
+	}
+	bool ballistaDoubleDmg() const //if it's ballista attack and does double dmg
+	{
+		return flags & BALLISTA_DOUBLE_DMG;
+	}
+	bool deathBlow() const
+	{
+		return flags & DEATH_BLOW;
+	}
+	bool spellLike() const
+	{
+		return flags & SPELL_LIKE;
+	}
+	bool lifeDrain() const
+	{
+		return flags & LIFE_DRAIN;
+	}
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & bsa;
+		h & stackAttacking;
+		h & flags;
+		h & tile;
+		h & spellID;
+		h & attackerChanges;
+		assert(battleID != BattleID::NONE);
+	}
+};
+
+struct DLL_LINKAGE StartAction : public CPackForClient
+{
+	StartAction() = default;
+	explicit StartAction(BattleAction act)
+		: ba(std::move(act))
+	{
+	}
+	void applyFirstCl(CClient * cl);
+	void applyGs(CGameState * gs);
+
+	BattleID battleID = BattleID::NONE;
+	BattleAction ba;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & ba;
+		assert(battleID != BattleID::NONE);
+	}
+};
+
+struct DLL_LINKAGE EndAction : public CPackForClient
+{
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	BattleID battleID = BattleID::NONE;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+	}
+};
+
+struct DLL_LINKAGE BattleSpellCast : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	BattleID battleID = BattleID::NONE;
+	bool activeCast = true;
+	ui8 side = 0; //which hero did cast spell: 0 - attacker, 1 - defender
+	SpellID spellID; //id of spell
+	ui8 manaGained = 0; //mana channeling ability
+	BattleHex tile; //destination tile (may not be set in some global/mass spells
+	std::set<ui32> affectedCres; //ids of creatures affected by this spell, generally used if spell does not set any effect (like dispel or cure)
+	std::set<ui32> resistedCres; // creatures that resisted the spell (e.g. Dwarves)
+	std::set<ui32> reflectedCres; // creatures that reflected the spell (e.g. Magic Mirror spell)
+	si32 casterStack = -1; // -1 if not cated by creature, >=0 caster stack ID
+	bool castByHero = true; //if true - spell has been cast by hero, otherwise by a creature
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & side;
+		h & spellID;
+		h & manaGained;
+		h & tile;
+		h & affectedCres;
+		h & resistedCres;
+		h & reflectedCres;
+		h & casterStack;
+		h & castByHero;
+		h & activeCast;
+		assert(battleID != BattleID::NONE);
+	}
+};
+
+struct DLL_LINKAGE StacksInjured : public CPackForClient
+{
+	void applyGs(CGameState * gs);
+	void applyBattle(IBattleState * battleState);
+
+	BattleID battleID = BattleID::NONE;
+	std::vector<BattleStackAttacked> stacks;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & stacks;
+		assert(battleID != BattleID::NONE);
+	}
+};
+
+struct DLL_LINKAGE BattleResultsApplied : public CPackForClient
+{
+	BattleID battleID = BattleID::NONE;
+	PlayerColor player1, player2;
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & player1;
+		h & player2;
+		assert(battleID != BattleID::NONE);
+	}
+};
+
+struct DLL_LINKAGE BattleObstaclesChanged : public CPackForClient
+{
+	void applyGs(CGameState * gs);
+	void applyBattle(IBattleState * battleState);
+
+	BattleID battleID = BattleID::NONE;
+	std::vector<ObstacleChanges> changes;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & changes;
+		assert(battleID != BattleID::NONE);
+	}
+};
+
+struct DLL_LINKAGE CatapultAttack : public CPackForClient
+{
+	struct AttackInfo
+	{
+		si16 destinationTile;
+		EWallPart attackedPart;
+		ui8 damageDealt;
+
+		template <typename Handler> void serialize(Handler & h, const int version)
+		{
+			h & destinationTile;
+			h & attackedPart;
+			h & damageDealt;
+		}
+	};
+
+	CatapultAttack();
+	~CatapultAttack() override;
+
+	void applyGs(CGameState * gs);
+	void applyBattle(IBattleState * battleState);
+
+	BattleID battleID = BattleID::NONE;
+	std::vector< AttackInfo > attackedParts;
+	int attacker = -1; //if -1, then a spell caused this
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & attackedParts;
+		h & attacker;
+		assert(battleID != BattleID::NONE);
+	}
+};
+
+struct DLL_LINKAGE BattleSetStackProperty : public CPackForClient
+{
+	enum BattleStackProperty { CASTS, ENCHANTER_COUNTER, UNBIND, CLONED, HAS_CLONE };
+
+	void applyGs(CGameState * gs) const;
+
+	BattleID battleID = BattleID::NONE;
+	int stackID = 0;
+	BattleStackProperty which = CASTS;
+	int val = 0;
+	int absolute = 0;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & stackID;
+		h & which;
+		h & val;
+		h & absolute;
+		assert(battleID != BattleID::NONE);
+	}
+
+protected:
+	void visitTyped(ICPackVisitor & visitor) override;
+};
+
+///activated at the beginning of turn
+struct DLL_LINKAGE BattleTriggerEffect : public CPackForClient
+{
+	void applyGs(CGameState * gs) const; //effect
+
+	BattleID battleID = BattleID::NONE;
+	int stackID = 0;
+	int effect = 0; //use corresponding Bonus type
+	int val = 0;
+	int additionalInfo = 0;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & stackID;
+		h & effect;
+		h & val;
+		h & additionalInfo;
+		assert(battleID != BattleID::NONE);
+	}
+
+protected:
+	void visitTyped(ICPackVisitor & visitor) override;
+};
+
+struct DLL_LINKAGE BattleUpdateGateState : public CPackForClient
+{
+	void applyGs(CGameState * gs) const;
+
+	BattleID battleID = BattleID::NONE;
+	EGateState state = EGateState::NONE;
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & state;
+		assert(battleID != BattleID::NONE);
+	}
+
+protected:
+	void visitTyped(ICPackVisitor & visitor) override;
+};
+
+VCMI_LIB_NAMESPACE_END

+ 23 - 24
lib/NetPacksLobby.h → lib/networkPacks/PacksForLobby.h

@@ -1,5 +1,5 @@
 /*
- * NetPacksLobby.h, part of VCMI engine
+ * PacksForLobby.h, part of VCMI engine
  *
  * Authors: listed in file AUTHORS in main folder
  *
@@ -9,9 +9,8 @@
  */
 #pragma once
 
-#include "NetPacksBase.h"
-
 #include "StartInfo.h"
+#include "NetPacksBase.h"
 
 class CServerHandler;
 class CVCMIServer;
@@ -43,7 +42,7 @@ struct DLL_LINKAGE LobbyClientConnected : public CLobbyPackToPropagate
 	int clientId = -1;
 	int hostClientId = -1;
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler & h, const int version)
 	{
@@ -62,7 +61,7 @@ struct DLL_LINKAGE LobbyClientDisconnected : public CLobbyPackToPropagate
 	bool shutdownServer = false;
 
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -75,7 +74,7 @@ struct DLL_LINKAGE LobbyChatMessage : public CLobbyPackToPropagate
 {
 	std::string playerName, message;
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -91,7 +90,7 @@ struct DLL_LINKAGE LobbyGuiAction : public CLobbyPackToPropagate
 	} action = NONE;
 
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -103,7 +102,7 @@ struct DLL_LINKAGE LobbyLoadProgress : public CLobbyPackToPropagate
 {
 	unsigned char progress;
 	
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -115,7 +114,7 @@ struct DLL_LINKAGE LobbyEndGame : public CLobbyPackToPropagate
 {
 	bool closeConnection = false, restart = false;
 	
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 	
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -131,7 +130,7 @@ struct DLL_LINKAGE LobbyStartGame : public CLobbyPackToPropagate
 	CGameState * initializedGameState = nullptr;
 	int clientId = -1; //-1 means to all clients
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -148,7 +147,7 @@ struct DLL_LINKAGE LobbyChangeHost : public CLobbyPackToPropagate
 {
 	int newHostConnectionId = -1;
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler & h, const int version)
 	{
@@ -161,7 +160,7 @@ struct DLL_LINKAGE LobbyUpdateState : public CLobbyPackToPropagate
 	LobbyState state;
 	bool hostChanged = false; // Used on client-side only
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -176,7 +175,7 @@ struct DLL_LINKAGE LobbySetMap : public CLobbyPackToServer
 
 	LobbySetMap() : mapInfo(nullptr), mapGenOpts(nullptr) {}
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -189,7 +188,7 @@ struct DLL_LINKAGE LobbySetCampaign : public CLobbyPackToServer
 {
 	std::shared_ptr<CampaignState> ourCampaign;
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -201,7 +200,7 @@ struct DLL_LINKAGE LobbySetCampaignMap : public CLobbyPackToServer
 {
 	CampaignScenarioID mapId = CampaignScenarioID::NONE;
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -213,7 +212,7 @@ struct DLL_LINKAGE LobbySetCampaignBonus : public CLobbyPackToServer
 {
 	int bonusId = -1;
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -228,7 +227,7 @@ struct DLL_LINKAGE LobbyChangePlayerOption : public CLobbyPackToServer
 	int32_t value = 0;
 	PlayerColor color = PlayerColor::CANNOT_DETERMINE;
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -242,7 +241,7 @@ struct DLL_LINKAGE LobbySetPlayer : public CLobbyPackToServer
 {
 	PlayerColor clickedColor = PlayerColor::CANNOT_DETERMINE;
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -255,7 +254,7 @@ struct DLL_LINKAGE LobbySetPlayerName : public CLobbyPackToServer
 	PlayerColor color = PlayerColor::CANNOT_DETERMINE;
 	std::string name = "";
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -268,7 +267,7 @@ struct DLL_LINKAGE LobbySetSimturns : public CLobbyPackToServer
 {
 	SimturnsInfo simturnsInfo;
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -280,7 +279,7 @@ struct DLL_LINKAGE LobbySetTurnTime : public CLobbyPackToServer
 {
 	TurnTimerInfo turnTimerInfo;
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -292,7 +291,7 @@ struct DLL_LINKAGE LobbySetDifficulty : public CLobbyPackToServer
 {
 	ui8 difficulty = 0;
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -305,7 +304,7 @@ struct DLL_LINKAGE LobbyForceSetPlayer : public CLobbyPackToServer
 	ui8 targetConnectedPlayer = -1;
 	PlayerColor targetPlayerColor = PlayerColor::CANNOT_DETERMINE;
 
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 
 	template <typename Handler> void serialize(Handler & h, const int version)
 	{
@@ -318,7 +317,7 @@ struct DLL_LINKAGE LobbyShowMessage : public CLobbyPackToPropagate
 {
 	std::string message;
 	
-	virtual void visitTyped(ICPackVisitor & visitor) override;
+	void visitTyped(ICPackVisitor & visitor) override;
 	
 	template <typename Handler> void serialize(Handler & h, const int version)
 	{

+ 669 - 0
lib/networkPacks/PacksForServer.h

@@ -0,0 +1,669 @@
+/*
+ * PacksForServer.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 "ArtifactLocation.h"
+#include "NetPacksBase.h"
+
+#include "../int3.h"
+#include "../battle/BattleAction.h"
+
+VCMI_LIB_NAMESPACE_BEGIN
+
+struct DLL_LINKAGE GamePause : public CPackForServer
+{
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+	}
+};
+
+struct DLL_LINKAGE EndTurn : public CPackForServer
+{
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+	}
+};
+
+struct DLL_LINKAGE DismissHero : public CPackForServer
+{
+	DismissHero() = default;
+	DismissHero(const ObjectInstanceID & HID)
+		: hid(HID)
+	{
+	}
+	ObjectInstanceID hid;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & hid;
+	}
+};
+
+struct DLL_LINKAGE MoveHero : public CPackForServer
+{
+	MoveHero() = default;
+	MoveHero(const int3 & Dest, const ObjectInstanceID & HID, bool Transit)
+		: dest(Dest)
+		, hid(HID)
+		, transit(Transit)
+	{
+	}
+	int3 dest;
+	ObjectInstanceID hid;
+	bool transit = false;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & dest;
+		h & hid;
+		h & transit;
+	}
+};
+
+struct DLL_LINKAGE CastleTeleportHero : public CPackForServer
+{
+	CastleTeleportHero() = default;
+	CastleTeleportHero(const ObjectInstanceID & HID, const ObjectInstanceID & Dest, ui8 Source)
+		: dest(Dest)
+		, hid(HID)
+		, source(Source)
+	{
+	}
+	ObjectInstanceID dest;
+	ObjectInstanceID hid;
+	si8 source = 0; //who give teleporting, 1=castle gate
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & dest;
+		h & hid;
+	}
+};
+
+struct DLL_LINKAGE ArrangeStacks : public CPackForServer
+{
+	ArrangeStacks() = default;
+	ArrangeStacks(ui8 W, const SlotID & P1, const SlotID & P2, const ObjectInstanceID & ID1, const ObjectInstanceID & ID2, si32 VAL)
+		: what(W)
+		, p1(P1)
+		, p2(P2)
+		, id1(ID1)
+		, id2(ID2)
+		, val(VAL)
+	{
+	}
+
+	ui8 what = 0; //1 - swap; 2 - merge; 3 - split
+	SlotID p1, p2; //positions of first and second stack
+	ObjectInstanceID id1, id2; //ids of objects with garrison
+	si32 val = 0;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & what;
+		h & p1;
+		h & p2;
+		h & id1;
+		h & id2;
+		h & val;
+	}
+};
+
+struct DLL_LINKAGE BulkMoveArmy : public CPackForServer
+{
+	SlotID srcSlot;
+	ObjectInstanceID srcArmy;
+	ObjectInstanceID destArmy;
+
+	BulkMoveArmy() = default;
+
+	BulkMoveArmy(const ObjectInstanceID & srcArmy, const ObjectInstanceID & destArmy, const SlotID & srcSlot)
+		: srcArmy(srcArmy)
+		, destArmy(destArmy)
+		, srcSlot(srcSlot)
+	{
+	}
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler>
+	void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & srcSlot;
+		h & srcArmy;
+		h & destArmy;
+	}
+};
+
+struct DLL_LINKAGE BulkSplitStack : public CPackForServer
+{
+	SlotID src;
+	ObjectInstanceID srcOwner;
+	si32 amount = 0;
+
+	BulkSplitStack() = default;
+
+	BulkSplitStack(const ObjectInstanceID & srcOwner, const SlotID & src, si32 howMany)
+		: src(src)
+		, srcOwner(srcOwner)
+		, amount(howMany)
+	{
+	}
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler>
+	void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & src;
+		h & srcOwner;
+		h & amount;
+	}
+};
+
+struct DLL_LINKAGE BulkMergeStacks : public CPackForServer
+{
+	SlotID src;
+	ObjectInstanceID srcOwner;
+
+	BulkMergeStacks() = default;
+
+	BulkMergeStacks(const ObjectInstanceID & srcOwner, const SlotID & src)
+		: src(src)
+		, srcOwner(srcOwner)
+	{
+	}
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler>
+	void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & src;
+		h & srcOwner;
+	}
+};
+
+struct DLL_LINKAGE BulkSmartSplitStack : public CPackForServer
+{
+	SlotID src;
+	ObjectInstanceID srcOwner;
+
+	BulkSmartSplitStack() = default;
+
+	BulkSmartSplitStack(const ObjectInstanceID & srcOwner, const SlotID & src)
+		: src(src)
+		, srcOwner(srcOwner)
+	{
+	}
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler>
+	void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & src;
+		h & srcOwner;
+	}
+};
+
+struct DLL_LINKAGE DisbandCreature : public CPackForServer
+{
+	DisbandCreature() = default;
+	DisbandCreature(const SlotID & Pos, const ObjectInstanceID & ID)
+		: pos(Pos)
+		, id(ID)
+	{
+	}
+	SlotID pos; //stack pos
+	ObjectInstanceID id; //object id
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & pos;
+		h & id;
+	}
+};
+
+struct DLL_LINKAGE BuildStructure : public CPackForServer
+{
+	BuildStructure() = default;
+	BuildStructure(const ObjectInstanceID & TID, const BuildingID & BID)
+		: tid(TID)
+		, bid(BID)
+	{
+	}
+	ObjectInstanceID tid; //town id
+	BuildingID bid; //structure id
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & tid;
+		h & bid;
+	}
+};
+
+struct DLL_LINKAGE RazeStructure : public BuildStructure
+{
+	void visitTyped(ICPackVisitor & visitor) override;
+};
+
+struct DLL_LINKAGE RecruitCreatures : public CPackForServer
+{
+	RecruitCreatures() = default;
+	RecruitCreatures(const ObjectInstanceID & TID, const ObjectInstanceID & DST, const CreatureID & CRID, si32 Amount, si32 Level)
+		: tid(TID)
+		, dst(DST)
+		, crid(CRID)
+		, amount(Amount)
+		, level(Level)
+	{
+	}
+	ObjectInstanceID tid; //dwelling id, or town
+	ObjectInstanceID dst; //destination ID, e.g. hero
+	CreatureID crid;
+	ui32 amount = 0; //creature amount
+	si32 level = 0; //dwelling level to buy from, -1 if any
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & tid;
+		h & dst;
+		h & crid;
+		h & amount;
+		h & level;
+	}
+};
+
+struct DLL_LINKAGE UpgradeCreature : public CPackForServer
+{
+	UpgradeCreature() = default;
+	UpgradeCreature(const SlotID & Pos, const ObjectInstanceID & ID, const CreatureID & CRID)
+		: pos(Pos)
+		, id(ID)
+		, cid(CRID)
+	{
+	}
+	SlotID pos; //stack pos
+	ObjectInstanceID id; //object id
+	CreatureID cid; //id of type to which we want make upgrade
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & pos;
+		h & id;
+		h & cid;
+	}
+};
+
+struct DLL_LINKAGE GarrisonHeroSwap : public CPackForServer
+{
+	GarrisonHeroSwap() = default;
+	GarrisonHeroSwap(const ObjectInstanceID & TID)
+		: tid(TID)
+	{
+	}
+	ObjectInstanceID tid;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & tid;
+	}
+};
+
+struct DLL_LINKAGE ExchangeArtifacts : public CPackForServer
+{
+	ArtifactLocation src, dst;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & src;
+		h & dst;
+	}
+};
+
+struct DLL_LINKAGE BulkExchangeArtifacts : public CPackForServer
+{
+	ObjectInstanceID srcHero;
+	ObjectInstanceID dstHero;
+	bool swap = false;
+	bool equipped = true;
+	bool backpack = true;
+
+	BulkExchangeArtifacts() = default;
+	BulkExchangeArtifacts(const ObjectInstanceID & srcHero, const ObjectInstanceID & dstHero, bool swap, bool equipped, bool backpack)
+		: srcHero(srcHero)
+		, dstHero(dstHero)
+		, swap(swap)
+		, equipped(equipped)
+		, backpack(backpack)
+	{
+	}
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & srcHero;
+		h & dstHero;
+		h & swap;
+		h & equipped;
+		h & backpack;
+	}
+};
+
+struct DLL_LINKAGE AssembleArtifacts : public CPackForServer
+{
+	AssembleArtifacts() = default;
+	AssembleArtifacts(const ObjectInstanceID & _heroID, const ArtifactPosition & _artifactSlot, bool _assemble, const ArtifactID & _assembleTo)
+		: heroID(_heroID)
+		, artifactSlot(_artifactSlot)
+		, assemble(_assemble)
+		, assembleTo(_assembleTo)
+	{
+	}
+	ObjectInstanceID heroID;
+	ArtifactPosition artifactSlot;
+	bool assemble = false; // True to assemble artifact, false to disassemble.
+	ArtifactID assembleTo; // Artifact to assemble into.
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & heroID;
+		h & artifactSlot;
+		h & assemble;
+		h & assembleTo;
+	}
+};
+
+struct DLL_LINKAGE EraseArtifactByClient : public CPackForServer
+{
+	EraseArtifactByClient() = default;
+	EraseArtifactByClient(const ArtifactLocation & al)
+		: al(al)
+	{
+	}
+	ArtifactLocation al;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer&>(*this);
+		h & al;
+	}
+};
+
+struct DLL_LINKAGE BuyArtifact : public CPackForServer
+{
+	BuyArtifact() = default;
+	BuyArtifact(const ObjectInstanceID & HID, const ArtifactID & AID)
+		: hid(HID)
+		, aid(AID)
+	{
+	}
+	ObjectInstanceID hid;
+	ArtifactID aid;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & hid;
+		h & aid;
+	}
+};
+
+struct DLL_LINKAGE TradeOnMarketplace : public CPackForServer
+{
+	ObjectInstanceID marketId;
+	ObjectInstanceID heroId;
+
+	EMarketMode mode = EMarketMode::RESOURCE_RESOURCE;
+	std::vector<ui32> r1, r2; //mode 0: r1 - sold resource, r2 - bought res (exception: when sacrificing art r1 is art id [todo: make r2 preferred slot?]
+	std::vector<ui32> val; //units of sold resource
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & marketId;
+		h & heroId;
+		h & mode;
+		h & r1;
+		h & r2;
+		h & val;
+	}
+};
+
+struct DLL_LINKAGE SetFormation : public CPackForServer
+{
+	SetFormation() = default;
+	;
+	SetFormation(const ObjectInstanceID & HID, ui8 Formation)
+		: hid(HID)
+		, formation(Formation)
+	{
+	}
+	ObjectInstanceID hid;
+	ui8 formation = 0;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & hid;
+		h & formation;
+	}
+};
+
+struct DLL_LINKAGE HireHero : public CPackForServer
+{
+	HireHero() = default;
+	HireHero(HeroTypeID HID, const ObjectInstanceID & TID)
+		: hid(HID)
+		, tid(TID)
+	{
+	}
+	HeroTypeID hid; //available hero serial
+	ObjectInstanceID tid; //town (tavern) id
+	PlayerColor player;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & hid;
+		h & tid;
+		h & player;
+	}
+};
+
+struct DLL_LINKAGE BuildBoat : public CPackForServer
+{
+	ObjectInstanceID objid; //where player wants to buy a boat
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & objid;
+	}
+};
+
+struct DLL_LINKAGE QueryReply : public CPackForServer
+{
+	QueryReply() = default;
+	QueryReply(const QueryID & QID, std::optional<int32_t> Reply)
+		: qid(QID)
+		, reply(Reply)
+	{
+	}
+	QueryID qid;
+	PlayerColor player;
+	std::optional<int32_t> reply;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & qid;
+		h & player;
+		h & reply;
+	}
+};
+
+struct DLL_LINKAGE MakeAction : public CPackForServer
+{
+	MakeAction() = default;
+	MakeAction(BattleAction BA)
+		: ba(std::move(BA))
+	{
+	}
+	BattleAction ba;
+	BattleID battleID;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & ba;
+		h & battleID;
+	}
+};
+
+struct DLL_LINKAGE DigWithHero : public CPackForServer
+{
+	ObjectInstanceID id; //digging hero id
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & id;
+	}
+};
+
+struct DLL_LINKAGE CastAdvSpell : public CPackForServer
+{
+	ObjectInstanceID hid; //hero id
+	SpellID sid; //spell id
+	int3 pos; //selected tile (not always used)
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & hid;
+		h & sid;
+		h & pos;
+	}
+};
+
+/***********************************************************************************************************/
+
+struct DLL_LINKAGE SaveGame : public CPackForServer
+{
+	SaveGame() = default;
+	SaveGame(std::string Fname)
+		: fname(std::move(Fname))
+	{
+	}
+	std::string fname;
+
+	void applyGs(CGameState * gs) {};
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & fname;
+	}
+};
+
+struct DLL_LINKAGE PlayerMessage : public CPackForServer
+{
+	PlayerMessage() = default;
+	PlayerMessage(std::string Text, const ObjectInstanceID & obj)
+		: text(std::move(Text))
+		, currObj(obj)
+	{
+	}
+
+	void applyGs(CGameState * gs) {};
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	std::string text;
+	ObjectInstanceID currObj; // optional parameter that specifies current object. For cheats :)
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & static_cast<CPackForServer &>(*this);
+		h & text;
+		h & currObj;
+	}
+};
+
+VCMI_LIB_NAMESPACE_END

+ 42 - 0
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<std::pair<ui32, std::vector<Bonus>>> toAdd;
+	std::vector<std::pair<ui32, std::vector<Bonus>>> toUpdate;
+	std::vector<std::pair<ui32, std::vector<Bonus>>> toRemove;
+
+	void visitTyped(ICPackVisitor & visitor) override;
+
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & battleID;
+		h & toAdd;
+		h & toUpdate;
+		h & toRemove;
+		assert(battleID != BattleID::NONE);
+	}
+};
+
+VCMI_LIB_NAMESPACE_END

+ 40 - 0
lib/networkPacks/StackLocation.h

@@ -0,0 +1,40 @@
+/*
+ * StackLocation.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 "../ConstTransitivePtr.h"
+#include "../GameConstants.h"
+
+VCMI_LIB_NAMESPACE_BEGIN
+
+class CArmedInstance;
+class CStackInstance;
+
+struct StackLocation
+{
+	ConstTransitivePtr<CArmedInstance> army;
+	SlotID slot;
+
+	StackLocation() = default;
+	StackLocation(const CArmedInstance * Army, const SlotID & Slot)
+		: army(const_cast<CArmedInstance *>(Army))  //we are allowed here to const cast -> change will go through one of our packages... do not abuse!
+		, slot(Slot)
+	{
+	}
+
+	DLL_LINKAGE const CStackInstance * getStack();
+	template <typename Handler> void serialize(Handler & h, const int version)
+	{
+		h & army;
+		h & slot;
+	}
+};
+
+VCMI_LIB_NAMESPACE_END

+ 5 - 2
lib/registerTypes/RegisterTypes.h

@@ -9,8 +9,11 @@
  */
 #pragma once
 
-#include "../NetPacks.h"
-#include "../NetPacksLobby.h"
+#include "../networkPacks/PacksForClient.h"
+#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"

+ 0 - 1
lib/registerTypes/TypesClientPacks1.cpp

@@ -18,7 +18,6 @@
 #include "../CHeroHandler.h"
 #include "../spells/CSpellHandler.h"
 #include "../CTownHandler.h"
-#include "../NetPacks.h"
 
 #include "../serializer/BinaryDeserializer.h"
 #include "../serializer/BinarySerializer.h"

+ 0 - 1
lib/registerTypes/TypesClientPacks2.cpp

@@ -20,7 +20,6 @@
 #include "../CHeroHandler.h"
 #include "../spells/CSpellHandler.h"
 #include "../CTownHandler.h"
-#include "../NetPacks.h"
 
 #include "../serializer/BinaryDeserializer.h"
 #include "../serializer/BinarySerializer.h"

+ 0 - 1
lib/registerTypes/TypesLobbyPacks.cpp

@@ -27,7 +27,6 @@
 #include "../RiverHandler.h"
 #include "../TerrainHandler.h"
 #include "../campaign/CampaignState.h"
-#include "../NetPacks.h"
 #include "../rmg/CMapGenOptions.h"
 
 #include "../serializer/BinaryDeserializer.h"

+ 0 - 1
lib/registerTypes/TypesMapObjects1.cpp

@@ -18,7 +18,6 @@
 #include "../CHeroHandler.h"
 #include "../spells/CSpellHandler.h"
 #include "../CTownHandler.h"
-#include "../NetPacks.h"
 
 #include "../serializer/BinaryDeserializer.h"
 #include "../serializer/BinarySerializer.h"

+ 0 - 1
lib/registerTypes/TypesMapObjects2.cpp

@@ -20,7 +20,6 @@
 #include "../CHeroHandler.h"
 #include "../spells/CSpellHandler.h"
 #include "../CTownHandler.h"
-#include "../NetPacks.h"
 
 #include "../serializer/BinaryDeserializer.h"
 #include "../serializer/BinarySerializer.h"

+ 0 - 1
lib/registerTypes/TypesMapObjects3.cpp

@@ -18,7 +18,6 @@
 #include "../CHeroHandler.h"
 #include "../spells/CSpellHandler.h"
 #include "../CTownHandler.h"
-#include "../NetPacks.h"
 
 #include "../serializer/BinaryDeserializer.h"
 #include "../serializer/BinarySerializer.h"

+ 0 - 1
lib/registerTypes/TypesServerPacks.cpp

@@ -18,7 +18,6 @@
 #include "../CHeroHandler.h"
 #include "../spells/CSpellHandler.h"
 #include "../CTownHandler.h"
-#include "../NetPacks.h"
 
 #include "../serializer/BinaryDeserializer.h"
 #include "../serializer/BinarySerializer.h"

+ 1 - 1
lib/rewardable/Configuration.h

@@ -12,8 +12,8 @@
 
 #include "Limiter.h"
 #include "MetaString.h"
-#include "NetPacksBase.h"
 #include "Reward.h"
+#include "../networkPacks/EInfoWindowMode.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 4 - 1
lib/rewardable/Interface.cpp

@@ -15,11 +15,14 @@
 #include "../TerrainHandler.h"
 #include "../CPlayerState.h"
 #include "../CSoundBase.h"
-#include "../NetPacks.h"
 #include "../gameState/CGameState.h"
 #include "../spells/CSpellHandler.h"
 #include "../spells/ISpellMechanics.h"
+#include "../mapObjects/CGHeroInstance.h"
 #include "../mapObjects/MiscObjects.h"
+#include "../mapping/CMapDefines.h"
+#include "../networkPacks/StackLocation.h"
+#include "../networkPacks/PacksForClient.h"
 #include "../IGameCallback.h"
 
 VCMI_LIB_NAMESPACE_BEGIN

+ 1 - 0
lib/rewardable/Limiter.cpp

@@ -14,6 +14,7 @@
 #include "../IGameCallback.h"
 #include "../CPlayerState.h"
 #include "../mapObjects/CGHeroInstance.h"
+#include "../networkPacks/Component.h"
 #include "../serializer/JsonSerializeFormat.h"
 #include "../constants/StringConstants.h"
 #include "../CHeroHandler.h"

+ 1 - 0
lib/rewardable/Reward.h

@@ -13,6 +13,7 @@
 #include "../ResourceSet.h"
 #include "../bonuses/Bonus.h"
 #include "../CCreatureSet.h"
+#include "../networkPacks/Component.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 3 - 3
lib/spells/AdventureSpellMechanics.cpp

@@ -14,12 +14,12 @@
 
 #include "CSpellHandler.h"
 
+#include "../CGameInfoCallback.h"
+#include "../CPlayerState.h"
 #include "../CRandomGenerator.h"
 #include "../mapObjects/CGHeroInstance.h"
-#include "../NetPacks.h"
-#include "../CGameInfoCallback.h"
 #include "../mapping/CMap.h"
-#include "../CPlayerState.h"
+#include "../networkPacks/PacksForClient.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 2 - 2
lib/spells/BattleSpellMechanics.cpp

@@ -16,9 +16,9 @@
 
 #include "../battle/IBattleState.h"
 #include "../battle/CBattleInfoCallback.h"
-
+#include "../networkPacks/PacksForClientBattle.h"
+#include "../networkPacks/SetStackEffect.h"
 #include "../CStack.h"
-#include "../NetPacks.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 

+ 0 - 1
lib/spells/ISpellMechanics.cpp

@@ -36,7 +36,6 @@
 #include "effects/Timed.h"
 
 #include "CSpellHandler.h"
-#include "../NetPacks.h"
 
 #include "../CHeroHandler.h"//todo: remove
 #include "../IGameCallback.h"//todo: remove

+ 0 - 1
lib/spells/ObstacleCasterProxy.h

@@ -9,7 +9,6 @@
  */
 
 #include "ProxyCaster.h"
-#include "../lib/NetPacksBase.h"
 #include "../battle/BattleHex.h"
 #include "../battle/CObstacleInstance.h"
 

+ 1 - 1
lib/spells/effects/Catapult.cpp

@@ -14,11 +14,11 @@
 #include "Registry.h"
 #include "../ISpellMechanics.h"
 
-#include "../../NetPacks.h"
 #include "../../battle/IBattleState.h"
 #include "../../battle/CBattleInfoCallback.h"
 #include "../../battle/Unit.h"
 #include "../../mapObjects/CGTownInstance.h"
+#include "../../networkPacks/PacksForClientBattle.h"
 #include "../../serializer/JsonSerializeFormat.h"
 
 VCMI_LIB_NAMESPACE_BEGIN

+ 2 - 1
lib/spells/effects/Clone.cpp

@@ -12,10 +12,11 @@
 #include "Clone.h"
 #include "Registry.h"
 #include "../ISpellMechanics.h"
-#include "../../NetPacks.h"
 #include "../../battle/CBattleInfoCallback.h"
 #include "../../battle/IBattleState.h"
 #include "../../battle/CUnitState.h"
+#include "../../networkPacks/PacksForClientBattle.h"
+#include "../../networkPacks/SetStackEffect.h"
 #include "../../serializer/JsonSerializeFormat.h"
 
 VCMI_LIB_NAMESPACE_BEGIN

Some files were not shown because too many files changed in this diff