Explorar o código

Merge pull request #5705 from IvanSavenko/callback_split

Reorganize callback-related code
Ivan Savenko hai 5 meses
pai
achega
9a30ce27af
Modificáronse 100 ficheiros con 143 adicións e 388 borrados
  1. 0 1
      AI/BattleAI/AttackPossibility.h
  2. 4 5
      AI/BattleAI/BattleAI.cpp
  3. 1 2
      AI/BattleAI/BattleAI.h
  4. 2 0
      AI/BattleAI/BattleEvaluator.cpp
  5. 2 1
      AI/BattleAI/BattleEvaluator.h
  6. 0 1
      AI/BattleAI/BattleExchangeVariant.h
  7. 0 1
      AI/BattleAI/main.cpp
  8. 2 0
      AI/EmptyAI/CEmptyAI.cpp
  9. 1 2
      AI/EmptyAI/CEmptyAI.h
  10. 1 1
      AI/Nullkiller/AIGateway.cpp
  11. 1 2
      AI/Nullkiller/AIGateway.h
  12. 1 1
      AI/Nullkiller/AIUtility.h
  13. 0 1
      AI/Nullkiller/Analyzers/ArmyManager.cpp
  14. 0 1
      AI/Nullkiller/Engine/AIMemory.cpp
  15. 0 1
      AI/Nullkiller/Engine/PriorityEvaluator.cpp
  16. 0 1
      AI/Nullkiller/Goals/CompleteQuest.h
  17. 1 1
      AI/Nullkiller/Pathfinding/AINodeStorage.cpp
  18. 0 1
      AI/Nullkiller/Pathfinding/AIPathfinder.cpp
  19. 0 1
      AI/Nullkiller/Pathfinding/Actors.cpp
  20. 0 1
      AI/Nullkiller/Pathfinding/GraphPaths.cpp
  21. 0 1
      AI/Nullkiller/Pathfinding/ObjectGraph.cpp
  22. 0 1
      AI/Nullkiller/Pathfinding/ObjectGraphCalculator.cpp
  23. 0 1
      AI/Nullkiller/Pathfinding/Rules/AILayerTransitionRule.h
  24. 0 1
      AI/Nullkiller/Pathfinding/Rules/AIMovementAfterDestinationRule.h
  25. 0 1
      AI/Nullkiller/Pathfinding/Rules/AIMovementToDestinationRule.h
  26. 0 1
      AI/Nullkiller/Pathfinding/Rules/AIPreviousNodeRule.h
  27. 0 1
      AI/Nullkiller/StdInc.h
  28. 2 6
      AI/StupidAI/StupidAI.cpp
  29. 1 2
      AI/StupidAI/StupidAI.h
  30. 0 1
      AI/StupidAI/main.cpp
  31. 1 2
      AI/VCAI/AIUtility.h
  32. 0 1
      AI/VCAI/ArmyManager.cpp
  33. 0 1
      AI/VCAI/BuildingManager.cpp
  34. 0 1
      AI/VCAI/Goals/AbstractGoal.h
  35. 1 1
      AI/VCAI/Pathfinding/AINodeStorage.cpp
  36. 0 2
      AI/VCAI/Pathfinding/AINodeStorage.h
  37. 0 1
      AI/VCAI/Pathfinding/AIPathfinder.cpp
  38. 0 1
      AI/VCAI/Pathfinding/PathfindingManager.cpp
  39. 0 1
      AI/VCAI/Pathfinding/Rules/AILayerTransitionRule.h
  40. 0 1
      AI/VCAI/Pathfinding/Rules/AIMovementAfterDestinationRule.h
  41. 0 1
      AI/VCAI/Pathfinding/Rules/AIMovementToDestinationRule.h
  42. 0 1
      AI/VCAI/Pathfinding/Rules/AIPreviousNodeRule.h
  43. 0 1
      AI/VCAI/ResourceManager.cpp
  44. 1 1
      AI/VCAI/VCAI.cpp
  45. 1 3
      AI/VCAI/VCAI.h
  46. 0 219
      CCallback.h
  47. 1 1
      client/ArtifactsUIController.cpp
  48. 0 1
      client/CMakeLists.txt
  49. 23 8
      client/CPlayerInterface.cpp
  50. 4 1
      client/CPlayerInterface.h
  51. 29 15
      client/Client.cpp
  52. 13 7
      client/Client.h
  53. 4 2
      client/ClientCommandManager.cpp
  54. 1 2
      client/GameChatHandler.cpp
  55. 1 2
      client/HeroMovementController.cpp
  56. 1 1
      client/NetPacksClient.cpp
  57. 1 1
      client/PlayerLocalState.cpp
  58. 1 1
      client/adventureMap/AdventureMapInterface.cpp
  59. 1 1
      client/adventureMap/AdventureMapShortcuts.cpp
  60. 1 1
      client/adventureMap/AdventureOptions.cpp
  61. 0 1
      client/adventureMap/CInGameConsole.cpp
  62. 1 1
      client/adventureMap/CInfoBar.cpp
  63. 1 2
      client/adventureMap/CList.cpp
  64. 1 1
      client/adventureMap/CMinimap.cpp
  65. 1 1
      client/adventureMap/CResDataBar.cpp
  66. 1 1
      client/adventureMap/MapAudioPlayer.cpp
  67. 2 1
      client/adventureMap/TurnTimerWidget.cpp
  68. 2 1
      client/battle/BattleActionsController.cpp
  69. 1 1
      client/battle/BattleAnimationClasses.cpp
  70. 1 3
      client/battle/BattleEffectsController.cpp
  71. 1 1
      client/battle/BattleFieldController.cpp
  72. 2 1
      client/battle/BattleInterface.cpp
  73. 2 1
      client/battle/BattleInterfaceClasses.cpp
  74. 1 1
      client/battle/BattleObstacleController.cpp
  75. 1 1
      client/battle/BattleSiegeController.cpp
  76. 1 2
      client/battle/BattleStacksController.cpp
  77. 5 7
      client/battle/BattleWindow.cpp
  78. 1 1
      client/lobby/CCampaignInfoScreen.cpp
  79. 0 2
      client/lobby/CLobbyScreen.cpp
  80. 1 1
      client/lobby/CSavingScreen.cpp
  81. 1 2
      client/lobby/CScenarioInfoScreen.cpp
  82. 0 2
      client/lobby/CSelectionBase.cpp
  83. 0 2
      client/lobby/SelectionTab.cpp
  84. 0 2
      client/mainmenu/CMainMenu.cpp
  85. 0 2
      client/mapView/MapRenderer.cpp
  86. 1 1
      client/mapView/MapRendererContext.cpp
  87. 1 1
      client/mapView/MapRendererContextState.cpp
  88. 1 2
      client/mapView/MapView.cpp
  89. 1 1
      client/mapView/MapViewController.cpp
  90. 2 1
      client/mapView/mapHandler.cpp
  91. 0 2
      client/widgets/CArtifactsOfHeroAltar.cpp
  92. 1 2
      client/widgets/CArtifactsOfHeroBackpack.cpp
  93. 1 1
      client/widgets/CArtifactsOfHeroBase.cpp
  94. 0 1
      client/widgets/CArtifactsOfHeroKingdom.cpp
  95. 1 2
      client/widgets/CArtifactsOfHeroMain.cpp
  96. 1 2
      client/widgets/CComponentHolder.cpp
  97. 1 2
      client/widgets/CExchangeController.cpp
  98. 0 2
      client/widgets/CExchangeController.h
  99. 1 2
      client/widgets/CGarrisonInt.cpp
  100. 0 2
      client/widgets/Images.cpp

+ 0 - 1
AI/BattleAI/AttackPossibility.h

@@ -9,7 +9,6 @@
  */
 #pragma once
 #include "../../lib/battle/CUnitState.h"
-#include "../../CCallback.h"
 #include "StackWithBonuses.h"
 
 #define BATTLE_TRACE_LEVEL 0

+ 4 - 5
AI/BattleAI/BattleAI.cpp

@@ -17,6 +17,9 @@
 #include "tbb/parallel_for.h"
 #include "../../lib/CStopWatch.h"
 #include "../../lib/CThreadHelper.h"
+#include "../../lib/battle/CPlayerBattleCallback.h"
+#include "../../lib/callback/CBattleCallback.h"
+#include "../../lib/callback/IGameInfoCallback.h"
 #include "../../lib/mapObjects/CGTownInstance.h"
 #include "../../lib/spells/CSpellHandler.h"
 #include "../../lib/spells/ISpellMechanics.h"
@@ -34,8 +37,7 @@
 
 CBattleAI::CBattleAI()
 	: side(BattleSide::NONE),
-	wasWaitingForRealize(false),
-	wasUnlockingGs(false)
+	wasWaitingForRealize(false)
 {
 }
 
@@ -45,7 +47,6 @@ CBattleAI::~CBattleAI()
 	{
 		//Restore previous state of CB - it may be shared with the main AI (like VCAI)
 		cb->waitTillRealize = wasWaitingForRealize;
-		cb->unlockGsWhenWaiting = wasUnlockingGs;
 	}
 }
 
@@ -66,9 +67,7 @@ void CBattleAI::initBattleInterface(std::shared_ptr<Environment> ENV, std::share
 	cb = CB;
 	playerID = *CB->getPlayerID();
 	wasWaitingForRealize = CB->waitTillRealize;
-	wasUnlockingGs = CB->unlockGsWhenWaiting;
 	CB->waitTillRealize = false;
-	CB->unlockGsWhenWaiting = false;
 	movesSkippedByDefense = 0;
 
 	logHexNumbers();

+ 1 - 2
AI/BattleAI/BattleAI.h

@@ -8,8 +8,8 @@
  *
  */
 #pragma once
-#include "../../lib/AI_Base.h"
 #include "../../lib/battle/ReachabilityInfo.h"
+#include "../../lib/callback/CGameInterface.h"
 #include "PossibleSpellcast.h"
 #include "PotentialTargets.h"
 
@@ -60,7 +60,6 @@ class CBattleAI : public CBattleGameInterface
 
 	//Previous setting of cb
 	bool wasWaitingForRealize;
-	bool wasUnlockingGs;
 	int movesSkippedByDefense;
 
 public:

+ 2 - 0
AI/BattleAI/BattleEvaluator.cpp

@@ -16,6 +16,8 @@
 #include "tbb/parallel_for.h"
 #include "../../lib/CStopWatch.h"
 #include "../../lib/CThreadHelper.h"
+#include "../../lib/battle/CPlayerBattleCallback.h"
+#include "../../lib/callback/CBattleCallback.h"
 #include "../../lib/mapObjects/CGTownInstance.h"
 #include "../../lib/entities/building/TownFortifications.h"
 #include "../../lib/spells/CSpellHandler.h"

+ 2 - 1
AI/BattleAI/BattleEvaluator.h

@@ -8,7 +8,6 @@
  *
  */
 #pragma once
-#include "../../lib/AI_Base.h"
 #include "../../lib/battle/ReachabilityInfo.h"
 #include "PossibleSpellcast.h"
 #include "PotentialTargets.h"
@@ -17,6 +16,8 @@
 VCMI_LIB_NAMESPACE_BEGIN
 
 class CSpell;
+class CBattleCallback;
+class BattleAction;
 
 VCMI_LIB_NAMESPACE_END
 

+ 0 - 1
AI/BattleAI/BattleExchangeVariant.h

@@ -9,7 +9,6 @@
  */
 #pragma once
 
-#include "../../lib/AI_Base.h"
 #include "../../lib/battle/ReachabilityInfo.h"
 #include "PotentialTargets.h"
 #include "StackWithBonuses.h"

+ 0 - 1
AI/BattleAI/main.cpp

@@ -8,7 +8,6 @@
  *
  */
 #include "StdInc.h"
-#include "../../lib/AI_Base.h"
 #include "BattleAI.h"
 
 #ifdef __GNUC__

+ 2 - 0
AI/EmptyAI/CEmptyAI.cpp

@@ -13,6 +13,8 @@
 #include "../../lib/CRandomGenerator.h"
 #include "../../lib/CStack.h"
 #include "../../lib/battle/BattleAction.h"
+#include "../../lib/battle/CPlayerBattleCallback.h"
+#include "../../lib/callback/CCallback.h"
 
 void CEmptyAI::initGameInterface(std::shared_ptr<Environment> ENV, std::shared_ptr<CCallback> CB)
 {

+ 1 - 2
AI/EmptyAI/CEmptyAI.h

@@ -9,8 +9,7 @@
  */
 #pragma once
 
-#include "../../lib/AI_Base.h"
-#include "../../CCallback.h"
+#include "../../lib/callback/CGlobalAI.h"
 
 struct HeroMoveDetails;
 

+ 1 - 1
AI/Nullkiller/AIGateway.cpp

@@ -12,6 +12,7 @@
 #include "../../lib/AsyncRunner.h"
 #include "../../lib/UnlockGuard.h"
 #include "../../lib/StartInfo.h"
+#include "../../lib/battle/CPlayerBattleCallback.h"
 #include "../../lib/entities/artifact/ArtifactUtils.h"
 #include "../../lib/entities/artifact/CArtifact.h"
 #include "../../lib/entities/building/CBuilding.h"
@@ -576,7 +577,6 @@ void AIGateway::initGameInterface(std::shared_ptr<Environment> env, std::shared_
 	NET_EVENT_HANDLER;
 	playerID = *myCb->getPlayerID();
 	myCb->waitTillRealize = true;
-	myCb->unlockGsWhenWaiting = true;
 
 	nullkiller->init(CB, this);
 	

+ 1 - 2
AI/Nullkiller/AIGateway.h

@@ -11,12 +11,11 @@
 
 #include "AIUtility.h"
 #include "Goals/AbstractGoal.h"
-#include "../../lib/AI_Base.h"
-#include "../../CCallback.h"
 #include "../../lib/CThreadHelper.h"
 #include "../../lib/GameConstants.h"
 #include "../../lib/GameLibrary.h"
 #include "../../lib/CCreatureHandler.h"
+#include "../../lib/callback/CAdventureAI.h"
 #include "../../lib/mapObjects/MiscObjects.h"
 #include "../../lib/spells/CSpellHandler.h"
 #include "Pathfinding/AIPathfinder.h"

+ 1 - 1
AI/Nullkiller/AIUtility.h

@@ -44,7 +44,7 @@
 #include "../../lib/spells/CSpellHandler.h"
 #include "../../lib/CStopWatch.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
-#include "../../CCallback.h"
+#include "../../lib/callback/CCallback.h"
 
 #include <chrono>
 

+ 0 - 1
AI/Nullkiller/Analyzers/ArmyManager.cpp

@@ -11,7 +11,6 @@
 #include "StdInc.h"
 #include "ArmyManager.h"
 #include "../Engine/Nullkiller.h"
-#include "../../../CCallback.h"
 #include "../../../lib/mapObjects/MapObjects.h"
 #include "../../../lib/mapping/CMapDefines.h"
 #include "../../../lib/IGameSettings.h"

+ 0 - 1
AI/Nullkiller/Engine/AIMemory.cpp

@@ -9,7 +9,6 @@
 */
 #include "../StdInc.h"
 #include "AIMemory.h"
-#include "../../../CCallback.h"
 
 namespace NKAI
 {

+ 0 - 1
AI/Nullkiller/Engine/PriorityEvaluator.cpp

@@ -20,7 +20,6 @@
 #include "../../../lib/CCreatureHandler.h"
 #include "../../../lib/GameLibrary.h"
 #include "../../../lib/StartInfo.h"
-#include "../../../CCallback.h"
 #include "../../../lib/filesystem/Filesystem.h"
 #include "../Goals/ExecuteHeroChain.h"
 #include "../Goals/BuildThis.h"

+ 0 - 1
AI/Nullkiller/Goals/CompleteQuest.h

@@ -10,7 +10,6 @@
 #pragma once
 
 #include "../AIUtility.h"
-#include "../../../CCallback.h"
 #include "../Goals/CGoal.h"
 #include "../../../lib/gameState/QuestInfo.h"
 

+ 1 - 1
AI/Nullkiller/Pathfinding/AINodeStorage.cpp

@@ -14,7 +14,7 @@
 #include "../Goals/Goals.h"
 #include "../AIGateway.h"
 #include "../Engine/Nullkiller.h"
-#include "../../../CCallback.h"
+#include "../../../lib/callback/IGameCallback.h"
 #include "../../../lib/mapping/CMap.h"
 #include "../../../lib/mapObjects/MapObjects.h"
 #include "../../../lib/pathfinder/CPathfinder.h"

+ 0 - 1
AI/Nullkiller/Pathfinding/AIPathfinder.cpp

@@ -10,7 +10,6 @@
 #include "StdInc.h"
 #include "AIPathfinder.h"
 #include "AIPathfinderConfig.h"
-#include "../../../CCallback.h"
 #include "../../../lib/mapping/CMap.h"
 #include "../Engine/Nullkiller.h"
 

+ 0 - 1
AI/Nullkiller/Pathfinding/Actors.cpp

@@ -11,7 +11,6 @@
 #include "Actors.h"
 #include "../AIGateway.h"
 #include "../Engine/Nullkiller.h"
-#include "../../../CCallback.h"
 #include "../../../lib/mapObjects/MapObjects.h"
 #include "../../../lib/mapping/CMapDefines.h"
 #include "../../../lib/pathfinder/TurnInfo.h"

+ 0 - 1
AI/Nullkiller/Pathfinding/GraphPaths.cpp

@@ -11,7 +11,6 @@
 #include "GraphPaths.h"
 #include "AIPathfinderConfig.h"
 #include "../../../lib/CRandomGenerator.h"
-#include "../../../CCallback.h"
 #include "../../../lib/mapObjects/CQuest.h"
 #include "../../../lib/mapping/CMap.h"
 #include "../Engine/Nullkiller.h"

+ 0 - 1
AI/Nullkiller/Pathfinding/ObjectGraph.cpp

@@ -12,7 +12,6 @@
 #include "ObjectGraphCalculator.h"
 #include "AIPathfinderConfig.h"
 #include "../../../lib/CRandomGenerator.h"
-#include "../../../CCallback.h"
 #include "../../../lib/mapping/CMap.h"
 #include "../Engine/Nullkiller.h"
 #include "../../../lib/logging/VisualLogger.h"

+ 0 - 1
AI/Nullkiller/Pathfinding/ObjectGraphCalculator.cpp

@@ -11,7 +11,6 @@
 #include "ObjectGraphCalculator.h"
 #include "AIPathfinderConfig.h"
 #include "../../../lib/CRandomGenerator.h"
-#include "../../../CCallback.h"
 #include "../../../lib/mapping/CMap.h"
 #include "../Engine/Nullkiller.h"
 #include "../../../lib/logging/VisualLogger.h"

+ 0 - 1
AI/Nullkiller/Pathfinding/Rules/AILayerTransitionRule.h

@@ -14,7 +14,6 @@
 #include "../../AIGateway.h"
 #include "../Actions/BoatActions.h"
 #include "../Actions/AdventureSpellCastMovementActions.h"
-#include "../../../../CCallback.h"
 #include "../../../../lib/mapObjects/MapObjects.h"
 #include "../../../../lib/pathfinder/PathfindingRules.h"
 

+ 0 - 1
AI/Nullkiller/Pathfinding/Rules/AIMovementAfterDestinationRule.h

@@ -12,7 +12,6 @@
 
 #include "../AINodeStorage.h"
 #include "../../AIGateway.h"
-#include "../../../../CCallback.h"
 #include "../../../../lib/mapObjects/MapObjects.h"
 #include "../../../../lib/pathfinder/PathfindingRules.h"
 

+ 0 - 1
AI/Nullkiller/Pathfinding/Rules/AIMovementToDestinationRule.h

@@ -12,7 +12,6 @@
 
 #include "../AINodeStorage.h"
 #include "../../AIGateway.h"
-#include "../../../../CCallback.h"
 #include "../../../../lib/mapObjects/MapObjects.h"
 #include "../../../../lib/pathfinder/PathfindingRules.h"
 

+ 0 - 1
AI/Nullkiller/Pathfinding/Rules/AIPreviousNodeRule.h

@@ -12,7 +12,6 @@
 
 #include "../AINodeStorage.h"
 #include "../../AIGateway.h"
-#include "../../../../CCallback.h"
 #include "../../../../lib/mapObjects/MapObjects.h"
 #include "../../../../lib/pathfinder/PathfindingRules.h"
 

+ 0 - 1
AI/Nullkiller/StdInc.h

@@ -10,4 +10,3 @@
 #pragma  once
 #include "../../Global.h"
 VCMI_LIB_USING_NAMESPACE
-#include "../../CCallback.h"

+ 2 - 6
AI/StupidAI/StupidAI.cpp

@@ -8,19 +8,18 @@
  *
  */
 #include "StdInc.h"
-#include "../../lib/AI_Base.h"
 #include "StupidAI.h"
 #include "../../lib/CStack.h"
-#include "../../CCallback.h"
 #include "../../lib/CCreatureHandler.h"
 #include "../../lib/battle/BattleAction.h"
 #include "../../lib/battle/BattleInfo.h"
+#include "../../lib/battle/CPlayerBattleCallback.h"
+#include "../../lib/callback/CBattleCallback.h"
 #include "../../lib/CRandomGenerator.h"
 
 CStupidAI::CStupidAI()
 	: side(BattleSide::NONE)
 	, wasWaitingForRealize(false)
-	, wasUnlockingGs(false)
 {
 	print("created");
 }
@@ -32,7 +31,6 @@ CStupidAI::~CStupidAI()
 	{
 		//Restore previous state of CB - it may be shared with the main AI (like VCAI)
 		cb->waitTillRealize = wasWaitingForRealize;
-		cb->unlockGsWhenWaiting = wasUnlockingGs;
 	}
 }
 
@@ -43,9 +41,7 @@ void CStupidAI::initBattleInterface(std::shared_ptr<Environment> ENV, std::share
 	cb = CB;
 
 	wasWaitingForRealize = CB->waitTillRealize;
-	wasUnlockingGs = CB->unlockGsWhenWaiting;
 	CB->waitTillRealize = false;
-	CB->unlockGsWhenWaiting = false;
 }
 
 void CStupidAI::initBattleInterface(std::shared_ptr<Environment> ENV, std::shared_ptr<CBattleCallback> CB, AutocombatPreferences autocombatPreferences)

+ 1 - 2
AI/StupidAI/StupidAI.h

@@ -11,7 +11,7 @@
 
 #include "../../lib/battle/BattleHex.h"
 #include "../../lib/battle/ReachabilityInfo.h"
-#include "../../lib/CGameInterface.h"
+#include "../../lib/callback/CBattleGameInterface.h"
 
 class EnemyInfo;
 
@@ -22,7 +22,6 @@ class CStupidAI : public CBattleGameInterface
 	std::shared_ptr<Environment> env;
 
 	bool wasWaitingForRealize;
-	bool wasUnlockingGs;
 
 	void print(const std::string &text) const;
 public:

+ 0 - 1
AI/StupidAI/main.cpp

@@ -9,7 +9,6 @@
  */
 #include "StdInc.h"
 
-#include "../../lib/AI_Base.h"
 #include "StupidAI.h"
 
 #ifdef __GNUC__

+ 1 - 2
AI/VCAI/AIUtility.h

@@ -14,10 +14,9 @@
 #include "../../lib/spells/CSpellHandler.h"
 #include "../../lib/CStopWatch.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
-#include "../../CCallback.h"
+#include "../../lib/callback/CCallback.h"
 
 class VCAI;
-class CCallback;
 struct creInfo;
 
 using crint3 = const int3 &;

+ 0 - 1
AI/VCAI/ArmyManager.cpp

@@ -11,7 +11,6 @@
 #include "StdInc.h"
 #include "ArmyManager.h"
 
-#include "../../CCallback.h"
 #include "../../lib/mapObjects/MapObjects.h"
 
 void ArmyManager::init(CPlayerSpecificInfoCallback * CB)

+ 0 - 1
AI/VCAI/BuildingManager.cpp

@@ -11,7 +11,6 @@
 #include "StdInc.h"
 #include "BuildingManager.h"
 
-#include "../../CCallback.h"
 #include "../../lib/mapObjects/MapObjects.h"
 #include "../../lib/entities/building/CBuilding.h"
 

+ 0 - 1
AI/VCAI/Goals/AbstractGoal.h

@@ -16,7 +16,6 @@
 struct HeroPtr;
 class VCAI;
 class FuzzyHelper;
-class CCallback;
 
 namespace Goals
 {

+ 1 - 1
AI/VCAI/Pathfinding/AINodeStorage.cpp

@@ -11,7 +11,7 @@
 #include "AINodeStorage.h"
 #include "Actions/TownPortalAction.h"
 #include "../Goals/Goals.h"
-#include "../../../CCallback.h"
+#include "../../../lib/callback/IGameCallback.h"
 #include "../../../lib/mapping/CMap.h"
 #include "../../../lib/mapObjects/MapObjects.h"
 #include "../../../lib/pathfinder/CPathfinder.h"

+ 0 - 2
AI/VCAI/Pathfinding/AINodeStorage.h

@@ -18,8 +18,6 @@
 #include "../Goals/AbstractGoal.h"
 #include "Actions/ISpecialAction.h"
 
-class CCallback;
-
 struct AIPathNode : public CGPathNode
 {
 	uint32_t chainMask;

+ 0 - 1
AI/VCAI/Pathfinding/AIPathfinder.cpp

@@ -10,7 +10,6 @@
 #include "StdInc.h"
 #include "AIPathfinder.h"
 #include "AIPathfinderConfig.h"
-#include "../../../CCallback.h"
 #include "../../../lib/mapping/CMapDefines.h"
 
 #include <tbb/task_group.h>

+ 0 - 1
AI/VCAI/Pathfinding/PathfindingManager.cpp

@@ -13,7 +13,6 @@
 #include "AIPathfinderConfig.h"
 #include "../Goals/Goals.h"
 #include "../Goals/CompleteQuest.h"
-#include "../../../lib/CGameInfoCallback.h"
 #include "../../../lib/gameState/QuestInfo.h"
 #include "../../../lib/mapping/CMapDefines.h"
 #include "../../../lib/mapObjects/CQuest.h"

+ 0 - 1
AI/VCAI/Pathfinding/Rules/AILayerTransitionRule.h

@@ -13,7 +13,6 @@
 #include "../AINodeStorage.h"
 #include "../../VCAI.h"
 #include "../Actions/BoatActions.h"
-#include "../../../../CCallback.h"
 #include "../../../../lib/mapObjects/MapObjects.h"
 #include "../../../../lib/pathfinder/PathfindingRules.h"
 

+ 0 - 1
AI/VCAI/Pathfinding/Rules/AIMovementAfterDestinationRule.h

@@ -12,7 +12,6 @@
 
 #include "../AINodeStorage.h"
 #include "../../VCAI.h"
-#include "../../../../CCallback.h"
 #include "../../../../lib/mapObjects/MapObjects.h"
 #include "../../../../lib/pathfinder/PathfindingRules.h"
 

+ 0 - 1
AI/VCAI/Pathfinding/Rules/AIMovementToDestinationRule.h

@@ -12,7 +12,6 @@
 
 #include "../AINodeStorage.h"
 #include "../../VCAI.h"
-#include "../../../../CCallback.h"
 #include "../../../../lib/mapObjects/MapObjects.h"
 #include "../../../../lib/pathfinder/PathfindingRules.h"
 

+ 0 - 1
AI/VCAI/Pathfinding/Rules/AIPreviousNodeRule.h

@@ -12,7 +12,6 @@
 
 #include "../AINodeStorage.h"
 #include "../../VCAI.h"
-#include "../../../../CCallback.h"
 #include "../../../../lib/mapObjects/MapObjects.h"
 #include "../../../../lib/pathfinder/PathfindingRules.h"
 

+ 0 - 1
AI/VCAI/ResourceManager.cpp

@@ -11,7 +11,6 @@
 #include "ResourceManager.h"
 #include "Goals/Goals.h"
 
-#include "../../CCallback.h"
 #include "../../lib/mapObjects/MapObjects.h"
 
 ResourceObjective::ResourceObjective(const TResources & Res, Goals::TSubgoal Goal)

+ 1 - 1
AI/VCAI/VCAI.cpp

@@ -19,6 +19,7 @@
 #include "../../lib/CThreadHelper.h"
 #include "../../lib/UnlockGuard.h"
 #include "../../lib/StartInfo.h"
+#include "../../lib/battle/CPlayerBattleCallback.h"
 #include "../../lib/mapObjects/MapObjects.h"
 #include "../../lib/mapObjects/ObjectTemplate.h"
 #include "../../lib/CConfigHandler.h"
@@ -627,7 +628,6 @@ void VCAI::initGameInterface(std::shared_ptr<Environment> ENV, std::shared_ptr<C
 	NET_EVENT_HANDLER; //sets ah->rm->cb
 	playerID = *myCb->getPlayerID();
 	myCb->waitTillRealize = true;
-	myCb->unlockGsWhenWaiting = true;
 	pathfinderCache = std::make_unique<PathfinderCache>(myCb.get(), PathfinderOptions(*myCb));
 
 	if(!fh)

+ 1 - 3
AI/VCAI/VCAI.h

@@ -11,14 +11,12 @@
 
 #include "AIUtility.h"
 #include "Goals/AbstractGoal.h"
-#include "../../lib/AI_Base.h"
-#include "../../CCallback.h"
 
 #include "../../lib/ConditionalWait.h"
-
 #include "../../lib/GameConstants.h"
 #include "../../lib/GameLibrary.h"
 #include "../../lib/CCreatureHandler.h"
+#include "../../lib/callback/CAdventureAI.h"
 #include "../../lib/mapObjects/MiscObjects.h"
 #include "../../lib/spells/CSpellHandler.h"
 #include "Pathfinding/AIPathfinder.h"

+ 0 - 219
CCallback.h

@@ -1,219 +0,0 @@
-/*
- * CCallback.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 "lib/CGameInfoCallback.h"
-#include "lib/battle/CPlayerBattleCallback.h"
-#include "lib/int3.h" // for int3
-#include "lib/networkPacks/TradeItem.h"
-
-VCMI_LIB_NAMESPACE_BEGIN
-
-class CGHeroInstance;
-class CGameState;
-struct CPath;
-class CGObjectInstance;
-class CArmedInstance;
-class BattleAction;
-class CGTownInstance;
-class IShipyard;
-struct CGPathNode;
-struct CGPath;
-struct CPathsInfo;
-class PathfinderConfig;
-struct CPack;
-struct CPackForServer;
-class IBattleEventsReceiver;
-class IGameEventsReceiver;
-struct ArtifactLocation;
-class BattleStateInfoForRetreat;
-
-VCMI_LIB_NAMESPACE_END
-
-// in static AI build this file gets included into libvcmi
-#ifdef STATIC_AI
-VCMI_LIB_USING_NAMESPACE
-#endif
-
-class CClient;
-struct lua_State;
-
-class IBattleCallback
-{
-public:
-	virtual ~IBattleCallback() = default;
-
-	bool waitTillRealize = false; //if true, request functions will return after they are realized by server
-	bool unlockGsWhenWaiting = false;//if true after sending each request, gs mutex will be unlocked so the changes can be applied; NOTICE caller must have gs mx locked prior to any call to actiob callback!
-	//battle
-	virtual void battleMakeSpellAction(const BattleID & battleID, const BattleAction & action) = 0;
-	virtual void battleMakeUnitAction(const BattleID & battleID, const BattleAction & action) = 0;
-	virtual void battleMakeTacticAction(const BattleID & battleID, const BattleAction & action) = 0;
-	virtual std::optional<BattleAction> makeSurrenderRetreatDecision(const BattleID & battleID, const BattleStateInfoForRetreat & battleState) = 0;
-
-	virtual std::shared_ptr<CPlayerBattleCallback> getBattle(const BattleID & battleID) = 0;
-	virtual std::optional<PlayerColor> getPlayerID() const = 0;
-};
-
-class IGameActionCallback
-{
-public:
-	//hero
-	virtual void moveHero(const CGHeroInstance *h, const std::vector<int3> & path, bool transit) =0; //moves hero alongside provided path
-	virtual void moveHero(const CGHeroInstance *h, const int3 & destination, bool transit) =0; //moves hero alongside provided path
-	virtual bool dismissHero(const CGHeroInstance * hero)=0; //dismisses given hero; true - successfully, false - not successfully
-	virtual void dig(const CGObjectInstance *hero)=0;
-	virtual void castSpell(const CGHeroInstance *hero, SpellID spellID, const int3 &pos = int3(-1, -1, -1))=0; //cast adventure map spell
-
-	//town
-	virtual void recruitHero(const CGObjectInstance *townOrTavern, const CGHeroInstance *hero, const HeroTypeID & nextHero=HeroTypeID::NONE)=0;
-	virtual bool buildBuilding(const CGTownInstance *town, BuildingID buildingID)=0;
-	virtual bool visitTownBuilding(const CGTownInstance *town, BuildingID buildingID)=0;
-	virtual void recruitCreatures(const CGDwelling *obj, const CArmedInstance * dst, CreatureID ID, ui32 amount, si32 level=-1)=0;
-	virtual bool upgradeCreature(const CArmedInstance *obj, SlotID stackPos, CreatureID newID=CreatureID::NONE)=0; //if newID==-1 then best possible upgrade will be made
-	virtual void spellResearch(const CGTownInstance *town, SpellID spellAtSlot, bool accepted)=0;
-	virtual void swapGarrisonHero(const CGTownInstance *town)=0;
-
-	virtual void trade(const ObjectInstanceID marketId, EMarketMode mode, TradeItemSell id1, TradeItemBuy id2, ui32 val1, const CGHeroInstance * hero)=0; //mode==0: sell val1 units of id1 resource for id2 resiurce
-	virtual void trade(const ObjectInstanceID marketId, EMarketMode mode, const std::vector<TradeItemSell> & id1, const std::vector<TradeItemBuy> & id2, const std::vector<ui32> & val1, const CGHeroInstance * hero)=0;
-
-	virtual int selectionMade(int selection, QueryID queryID) =0;
-	virtual int sendQueryReply(std::optional<int32_t> reply, QueryID queryID) =0;
-	virtual int swapCreatures(const CArmedInstance *s1, const CArmedInstance *s2, SlotID p1, SlotID p2)=0;//swaps creatures between two possibly different garrisons // TODO: AI-unsafe code - fix it!
-	virtual int mergeStacks(const CArmedInstance *s1, const CArmedInstance *s2, SlotID p1, SlotID p2)=0;//joins first stack to the second (creatures must be same type)
-	virtual int mergeOrSwapStacks(const CArmedInstance *s1, const CArmedInstance *s2, SlotID p1, SlotID p2) =0; //first goes to the second
-	virtual int splitStack(const CArmedInstance *s1, const CArmedInstance *s2, SlotID p1, SlotID p2, int val)=0;//split creatures from the first stack
-	//virtual bool swapArtifacts(const CGHeroInstance * hero1, ui16 pos1, const CGHeroInstance * hero2, ui16 pos2)=0; //swaps artifacts between two given heroes
-	virtual bool swapArtifacts(const ArtifactLocation &l1, const ArtifactLocation &l2)=0;
-	virtual void scrollBackpackArtifacts(ObjectInstanceID hero, bool left) = 0;
-	virtual void sortBackpackArtifactsBySlot(const ObjectInstanceID hero) = 0;
-	virtual void sortBackpackArtifactsByCost(const ObjectInstanceID hero) = 0;
-	virtual void sortBackpackArtifactsByClass(const ObjectInstanceID hero) = 0;
-	virtual void manageHeroCostume(ObjectInstanceID hero, size_t costumeIndex, bool saveCostume) = 0;
-	virtual void assembleArtifacts(const ObjectInstanceID & heroID, ArtifactPosition artifactSlot, bool assemble, ArtifactID assembleTo)=0;
-	virtual void eraseArtifactByClient(const ArtifactLocation & al)=0;
-	virtual bool dismissCreature(const CArmedInstance *obj, SlotID stackPos)=0;
-	virtual void saveLocalState(const JsonNode & data)=0;
-	virtual void endTurn()=0;
-	virtual void buyArtifact(const CGHeroInstance *hero, ArtifactID aid)=0; //used to buy artifacts in towns (including spell book in the guild and war machines in blacksmith)
-	virtual void setFormation(const CGHeroInstance * hero, EArmyFormation mode)=0;
-
-	virtual void save(const std::string &fname) = 0;
-	virtual void sendMessage(const std::string &mess, const CGObjectInstance * currentObject = nullptr) = 0;
-	virtual void gamePause(bool pause) = 0;
-	virtual void buildBoat(const IShipyard *obj) = 0;
-
-	// To implement high-level army management bulk actions
-	virtual int bulkMoveArmy(ObjectInstanceID srcArmy, ObjectInstanceID destArmy, SlotID srcSlot) = 0;
-	virtual int bulkSplitStack(ObjectInstanceID armyId, SlotID srcSlot, int howMany = 1) = 0;
-	virtual int bulkSplitAndRebalanceStack(ObjectInstanceID armyId, SlotID srcSlot) = 0;
-	virtual int bulkMergeStacks(ObjectInstanceID armyId, SlotID srcSlot) = 0;
-	
-	
-	// Moves all artifacts from one hero to another
-	virtual void bulkMoveArtifacts(ObjectInstanceID srcHero, ObjectInstanceID dstHero, bool swap, bool equipped, bool backpack) = 0;
-};
-
-class CBattleCallback : public IBattleCallback
-{
-	std::map<BattleID, std::shared_ptr<CPlayerBattleCallback>> activeBattles;
-
-	std::optional<PlayerColor> player;
-
-protected:
-	int sendRequest(const CPackForServer & request); //returns requestID (that'll be matched to requestID in PackageApplied)
-	CClient *cl;
-
-public:
-	CBattleCallback(std::optional<PlayerColor> player, CClient * C);
-	void battleMakeSpellAction(const BattleID & battleID, const BattleAction & action) override;//for casting spells by hero - DO NOT use it for moving active stack
-	void battleMakeUnitAction(const BattleID & battleID, const BattleAction & action) override;
-	void battleMakeTacticAction(const BattleID & battleID, const BattleAction & action) override; // performs tactic phase actions
-	std::optional<BattleAction> makeSurrenderRetreatDecision(const BattleID & battleID, const BattleStateInfoForRetreat & battleState) override;
-
-	std::shared_ptr<CPlayerBattleCallback> getBattle(const BattleID & battleID) override;
-	std::optional<PlayerColor> getPlayerID() const override;
-
-	void onBattleStarted(const IBattleInfo * info);
-	void onBattleEnded(const BattleID & battleID);
-
-	friend class CCallback;
-	friend class CClient;
-};
-
-class CCallback : public CPlayerSpecificInfoCallback, public CBattleCallback, public IGameActionCallback
-{
-	std::shared_ptr<CGameState> gamestate;
-
-	CGameState & gameState() final { return *gamestate; }
-	const CGameState & gameState() const final { return *gamestate; }
-
-public:
-	CCallback(std::shared_ptr<CGameState> gamestate, std::optional<PlayerColor> Player, CClient * C);
-	virtual ~CCallback();
-
-	//client-specific functionalities (pathfinding)
-	virtual bool canMoveBetween(const int3 &a, const int3 &b);
-	virtual int3 getGuardingCreaturePosition(int3 tile);
-
-	std::optional<PlayerColor> getPlayerID() const override;
-
-	//Set of metrhods that allows adding more interfaces for this player that'll receive game event call-ins.
-	void registerBattleInterface(std::shared_ptr<IBattleEventsReceiver> battleEvents);
-	void unregisterBattleInterface(std::shared_ptr<IBattleEventsReceiver> battleEvents);
-
-//commands
-	void moveHero(const CGHeroInstance *h, const std::vector<int3> & path, bool transit) override;
-	void moveHero(const CGHeroInstance *h, const int3 & destination, bool transit) override;
-	bool teleportHero(const CGHeroInstance *who, const CGTownInstance *where);
-	int selectionMade(int selection, QueryID queryID) override;
-	int sendQueryReply(std::optional<int32_t> reply, QueryID queryID) override;
-	int swapCreatures(const CArmedInstance *s1, const CArmedInstance *s2, SlotID p1, SlotID p2) override;
-	int mergeOrSwapStacks(const CArmedInstance *s1, const CArmedInstance *s2, SlotID p1, SlotID p2) override; //first goes to the second
-	int mergeStacks(const CArmedInstance *s1, const CArmedInstance *s2, SlotID p1, SlotID p2) override; //first goes to the second
-	int splitStack(const CArmedInstance *s1, const CArmedInstance *s2, SlotID p1, SlotID p2, int val) override;
-	int bulkMoveArmy(ObjectInstanceID srcArmy, ObjectInstanceID destArmy, SlotID srcSlot) override;
-	int bulkSplitStack(ObjectInstanceID armyId, SlotID srcSlot, int howMany = 1) override;
-	int bulkSplitAndRebalanceStack(ObjectInstanceID armyId, SlotID srcSlot) override;
-	int bulkMergeStacks(ObjectInstanceID armyId, SlotID srcSlot) override;
-	bool dismissHero(const CGHeroInstance * hero) override;
-	bool swapArtifacts(const ArtifactLocation &l1, const ArtifactLocation &l2) override;
-	void assembleArtifacts(const ObjectInstanceID & heroID, ArtifactPosition artifactSlot, bool assemble, ArtifactID assembleTo) override;
-	void bulkMoveArtifacts(ObjectInstanceID srcHero, ObjectInstanceID dstHero, bool swap, bool equipped = true, bool backpack = true) override;
-	void scrollBackpackArtifacts(ObjectInstanceID hero, bool left) override;
-	void sortBackpackArtifactsBySlot(const ObjectInstanceID hero) override;
-	void sortBackpackArtifactsByCost(const ObjectInstanceID hero) override;
-	void sortBackpackArtifactsByClass(const ObjectInstanceID hero) override;
-	void manageHeroCostume(ObjectInstanceID hero, size_t costumeIdx, bool saveCostume) override;
-	void eraseArtifactByClient(const ArtifactLocation & al) override;
-	bool buildBuilding(const CGTownInstance *town, BuildingID buildingID) override;
-	bool visitTownBuilding(const CGTownInstance *town, BuildingID buildingID) override;
-	void recruitCreatures(const CGDwelling * obj, const CArmedInstance * dst, CreatureID ID, ui32 amount, si32 level=-1) override;
-	bool dismissCreature(const CArmedInstance *obj, SlotID stackPos) override;
-	bool upgradeCreature(const CArmedInstance *obj, SlotID stackPos, CreatureID newID=CreatureID::NONE) override;
-	void saveLocalState(const JsonNode & data) override;
-	void endTurn() override;
-	void spellResearch(const CGTownInstance *town, SpellID spellAtSlot, bool accepted) override;
-	void swapGarrisonHero(const CGTownInstance *town) override;
-	void buyArtifact(const CGHeroInstance *hero, ArtifactID aid) override;
-	void trade(const ObjectInstanceID marketId, EMarketMode mode, TradeItemSell id1, TradeItemBuy id2, ui32 val1, const CGHeroInstance * hero = nullptr) override;
-	void trade(const ObjectInstanceID marketId, EMarketMode mode, const std::vector<TradeItemSell> & id1, const std::vector<TradeItemBuy> & id2, const std::vector<ui32> & val1, const CGHeroInstance * hero = nullptr) override;
-	void setFormation(const CGHeroInstance * hero, EArmyFormation mode) override;
-	void recruitHero(const CGObjectInstance *townOrTavern, const CGHeroInstance *hero, const HeroTypeID & nextHero=HeroTypeID::NONE) override;
-	void save(const std::string &fname) override;
-	void sendMessage(const std::string &mess, const CGObjectInstance * currentObject = nullptr) override;
-	void gamePause(bool pause) override;
-	void buildBoat(const IShipyard *obj) override;
-	void dig(const CGObjectInstance *hero) override;
-	void castSpell(const CGHeroInstance *hero, SpellID spellID, const int3 &pos = int3(-1, -1, -1)) override;
-
-//friends
-	friend class CClient;
-};

+ 1 - 1
client/ArtifactsUIController.cpp

@@ -18,8 +18,8 @@
 #include "widgets/CComponent.h"
 #include "windows/CWindowWithArtifacts.h"
 
-#include "../CCallback.h"
 #include "../lib/GameLibrary.h"
+#include "../lib/callback/CCallback.h"
 #include "../lib/entities/artifact/ArtifactUtils.h"
 #include "../lib/entities/artifact/CArtifact.h"
 #include "../lib/mapObjects/CGHeroInstance.h"

+ 0 - 1
client/CMakeLists.txt

@@ -1,6 +1,5 @@
 set(vcmiclientcommon_SRCS
 	StdInc.cpp
-	../CCallback.cpp
 
 	adventureMap/AdventureMapInterface.cpp
 	adventureMap/AdventureMapShortcuts.cpp

+ 23 - 8
client/CPlayerInterface.cpp

@@ -12,6 +12,7 @@
 
 #include <vcmi/Artifact.h>
 
+#include "Client.h"
 #include "CServerHandler.h"
 #include "HeroMovementController.h"
 #include "PlayerLocalState.h"
@@ -64,8 +65,7 @@
 #include "windows/InfoWindows.h"
 #include "windows/settings/SettingsMainWindow.h"
 
-#include "../CCallback.h"
-
+#include "../lib/callback/CDynLibHandler.h"
 #include "../lib/CConfigHandler.h"
 #include "../lib/texts/CGeneralTextHandler.h"
 #include "../lib/CPlayerState.h"
@@ -80,10 +80,14 @@
 #include "../lib/UnlockGuard.h"
 #include "../lib/VCMIDirs.h"
 
+#include "../lib/battle/CPlayerBattleCallback.h"
+
 #include "../lib/bonuses/Limiters.h"
 #include "../lib/bonuses/Propagators.h"
 #include "../lib/bonuses/Updaters.h"
 
+#include "../lib/callback/CCallback.h"
+
 #include "../lib/gameState/CGameState.h"
 
 #include "../lib/mapObjects/CGMarket.h"
@@ -665,7 +669,7 @@ void CPlayerInterface::battleStart(const BattleID & battleID, const CCreatureSet
 		autofightingAI->initBattleInterface(env, cb, autocombatPreferences);
 		autofightingAI->battleStart(battleID, army1, army2, tile, hero1, hero2, side, false);
 		isAutoFightOn = true;
-		cb->registerBattleInterface(autofightingAI);
+		registerBattleInterface(autofightingAI);
 	}
 
 	waitForAllDialogs();
@@ -802,9 +806,7 @@ void CPlayerInterface::activeStack(const BattleID & battleID, const CStack * sta
 			autofightingAI->activeStack(battleID, stack);
 			return;
 		}
-
-		cb->unregisterBattleInterface(autofightingAI);
-		autofightingAI.reset();
+		unregisterBattleInterface(autofightingAI);
 	}
 
 	assert(battleInt);
@@ -823,8 +825,7 @@ void CPlayerInterface::battleEnd(const BattleID & battleID, const BattleResult *
 	if(isAutoFightOn || autofightingAI)
 	{
 		isAutoFightOn = false;
-		cb->unregisterBattleInterface(autofightingAI);
-		autofightingAI.reset();
+		unregisterBattleInterface(autofightingAI);
 
 		if(!battleInt)
 		{
@@ -1828,3 +1829,17 @@ std::optional<BattleAction> CPlayerInterface::makeSurrenderRetreatDecision(const
 {
 	return std::nullopt;
 }
+
+void CPlayerInterface::registerBattleInterface(std::shared_ptr<CBattleGameInterface> battleEvents)
+{
+	autofightingAI = battleEvents;
+	GAME->server().client->registerBattleInterface(battleEvents, playerID);
+}
+
+void CPlayerInterface::unregisterBattleInterface(std::shared_ptr<CBattleGameInterface> battleEvents)
+{
+	assert(battleEvents == autofightingAI);
+	GAME->server().client->unregisterBattleInterface(autofightingAI, playerID);
+	autofightingAI.reset();
+}
+

+ 4 - 1
client/CPlayerInterface.h

@@ -11,8 +11,8 @@
 
 #include "ArtifactsUIController.h"
 
+#include "../lib/callback/CGameInterface.h"
 #include "../lib/FunctionList.h"
-#include "../lib/CGameInterface.h"
 #include "gui/CIntObject.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
@@ -206,6 +206,9 @@ public: // public interface for use by client via GAME->interface() access
 	///returns true if all events are processed internally
 	bool capturedAllEvents();
 
+	void registerBattleInterface(std::shared_ptr<CBattleGameInterface> battleEvents);
+	void unregisterBattleInterface(std::shared_ptr<CBattleGameInterface> battleEvents);
+
 	CPlayerInterface(PlayerColor Player);
 	~CPlayerInterface();
 

+ 29 - 15
client/Client.cpp

@@ -22,14 +22,18 @@
 #include "gui/WindowHandler.h"
 #include "mapView/mapHandler.h"
 
-#include "../CCallback.h"
 #include "../lib/CConfigHandler.h"
+#include "../lib/battle/BattleInfo.h"
+#include "../lib/battle/CPlayerBattleCallback.h"
+#include "../lib/callback/CCallback.h"
+#include "../lib/callback/CDynLibHandler.h"
+#include "../lib/callback/CGlobalAI.h"
+#include "../lib/callback/IGameInfoCallback.h"
 #include "../lib/gameState/CGameState.h"
 #include "../lib/CPlayerState.h"
 #include "../lib/CThreadHelper.h"
 #include "../lib/VCMIDirs.h"
 #include "../lib/UnlockGuard.h"
-#include "../lib/battle/BattleInfo.h"
 #include "../lib/serializer/Connection.h"
 #include "../lib/mapping/CMapService.h"
 #include "../lib/mapObjects/CArmedInstance.h"
@@ -145,18 +149,6 @@ void CClient::loadGame(std::shared_ptr<CGameState> initializedGameState)
 	initPlayerInterfaces();
 }
 
-void CClient::save(const std::string & fname)
-{
-	if(!gameState().currentBattles.empty())
-	{
-		logNetwork->error("Game cannot be saved during battle!");
-		return;
-	}
-
-	SaveGame save_game(fname);
-	sendRequest(save_game, PlayerColor::NEUTRAL);
-}
-
 void CClient::endNetwork()
 {
 	GAME->map().endNetwork();
@@ -358,7 +350,12 @@ void CClient::handlePack(CPackForClient & pack)
 	logNetwork->trace("\tMade second apply on cl: %s", typeid(pack).name());
 }
 
-int CClient::sendRequest(const CPackForServer & request, PlayerColor player)
+std::optional<BattleAction> CClient::makeSurrenderRetreatDecision(PlayerColor player, const BattleID & battleID, const BattleStateInfoForRetreat & battleState)
+{
+	return playerint[player]->makeSurrenderRetreatDecision(battleID, battleState);
+}
+
+int CClient::sendRequest(const CPackForServer & request, PlayerColor player, bool waitTillRealize)
 {
 	static ui32 requestCounter = 1;
 
@@ -372,6 +369,13 @@ int CClient::sendRequest(const CPackForServer & request, PlayerColor player)
 	if(vstd::contains(playerint, player))
 		playerint[player]->requestSent(&request, requestID);
 
+	if(waitTillRealize)
+	{
+		logGlobal->trace("We'll wait till request %d is answered.\n", requestID);
+		auto gsUnlocker = vstd::makeUnlockSharedGuard(CGameState::mutex);
+		waitingRequest.waitWhileContains(requestID);
+	}
+
 	return requestID;
 }
 
@@ -546,3 +550,13 @@ extern "C" JNIEXPORT jboolean JNICALL Java_eu_vcmi_vcmi_NativeMethods_tryToSaveT
 	return true;
 }
 #endif
+
+void CClient::registerBattleInterface(std::shared_ptr<IBattleEventsReceiver> battleEvents, PlayerColor color)
+{
+	additionalBattleInts[color].push_back(battleEvents);
+}
+
+void CClient::unregisterBattleInterface(std::shared_ptr<IBattleEventsReceiver> battleEvents, PlayerColor color)
+{
+	additionalBattleInts[color] -= battleEvents;
+}

+ 13 - 7
client/Client.h

@@ -12,8 +12,10 @@
 #include <memory>
 #include <vcmi/Environment.h>
 
-#include "../lib/IGameCallback.h"
+#include "../lib/callback/IClient.h"
+#include "../lib/callback/IGameCallback.h"
 #include "../lib/ConditionalWait.h"
+#include "../lib/ResourceSet.h"
 
 
 VCMI_LIB_NAMESPACE_BEGIN
@@ -25,6 +27,8 @@ class CGameInterface;
 class BattleAction;
 class BattleInfo;
 struct BankConfig;
+class CCallback;
+class CBattleCallback;
 
 #if SCRIPTING_ENABLED
 namespace scripting
@@ -40,8 +44,6 @@ namespace events
 
 VCMI_LIB_NAMESPACE_END
 
-class CBattleCallback;
-class CCallback;
 class CClient;
 class CBaseForCLApply;
 
@@ -119,7 +121,7 @@ public:
 };
 
 /// Class which handles client - server logic
-class CClient : public IGameCallback, public Environment
+class CClient : public IGameCallback, public Environment, public IClient
 {
 	std::shared_ptr<CGameState> gamestate;
 public:
@@ -145,7 +147,6 @@ public:
 	void newGame(std::shared_ptr<CGameState> gameState);
 	void loadGame(std::shared_ptr<CGameState> gameState);
 
-	void save(const std::string & fname);
 	void endNetwork();
 	void finishGameplay();
 	void endGame();
@@ -158,10 +159,15 @@ public:
 	void installNewPlayerInterface(std::shared_ptr<CGameInterface> gameInterface, PlayerColor color, bool battlecb = false);
 	void installNewBattleInterface(std::shared_ptr<CBattleGameInterface> battleInterface, PlayerColor color, bool needCallback = true);
 
+	//Set of metrhods that allows adding more interfaces for this player that'll receive game event call-ins.
+	void registerBattleInterface(std::shared_ptr<IBattleEventsReceiver> battleEvents, PlayerColor color);
+	void unregisterBattleInterface(std::shared_ptr<IBattleEventsReceiver> battleEvents, PlayerColor color);
+
 	ThreadSafeVector<int> waitingRequest;
 
 	void handlePack(CPackForClient & pack); //applies the given pack and deletes it
-	int sendRequest(const CPackForServer & request, PlayerColor player); //returns ID given to that request
+	int sendRequest(const CPackForServer & request, PlayerColor player, bool waitTillRealize) override; //returns ID given to that request
+	std::optional<BattleAction> makeSurrenderRetreatDecision(PlayerColor player, const BattleID & battleID, const BattleStateInfoForRetreat & battleState) override;
 
 	void battleStarted(const BattleID & battle);
 	void battleFinished(const BattleID & battleID);
@@ -184,7 +190,7 @@ public:
 	void showTeleportDialog(TeleportDialog * iw) override {};
 	void showObjectWindow(const CGObjectInstance * object, EOpenWindowMode window, const CGHeroInstance * visitor, bool addQuery) override {};
 	void giveResource(PlayerColor player, GameResID which, int val) override {};
-	void giveResources(PlayerColor player, TResources resources) override {};
+	void giveResources(PlayerColor player, ResourceSet resources) override {};
 
 	void giveCreatures(const CArmedInstance * objid, const CGHeroInstance * h, const CCreatureSet & creatures, bool remove) override {};
 	void takeCreatures(ObjectInstanceID objid, const std::vector<CStackBasicDescriptor> & creatures, bool forceRemoval) override {};

+ 4 - 2
client/ClientCommandManager.cpp

@@ -20,6 +20,9 @@
 #include "gui/WindowHandler.h"
 #include "render/IRenderHandler.h"
 #include "ClientNetPackVisitors.h"
+#include "../lib/callback/CCallback.h"
+#include "../lib/callback/CGlobalAI.h"
+#include "../lib/callback/CDynLibHandler.h"
 #include "../lib/CConfigHandler.h"
 #include "../lib/gameState/CGameState.h"
 #include "../lib/CPlayerState.h"
@@ -30,7 +33,6 @@
 #include "windows/CCastleInterface.h"
 #include "../lib/mapObjects/CGHeroInstance.h"
 #include "render/CAnimation.h"
-#include "../CCallback.h"
 #include "../lib/texts/CGeneralTextHandler.h"
 #include "../lib/filesystem/Filesystem.h"
 #include "../lib/modding/CModHandler.h"
@@ -59,7 +61,7 @@ void ClientCommandManager::handleSaveCommand(std::istringstream & singleWordBuff
 
 	std::string saveFilename;
 	singleWordBuffer >> saveFilename;
-	GAME->server().client->save(saveFilename);
+	GAME->interface()->cb->save(saveFilename);
 	printCommandMessage("Game saved as: " + saveFilename);
 }
 

+ 1 - 2
client/GameChatHandler.cpp

@@ -19,8 +19,7 @@
 
 #include "adventureMap/CInGameConsole.h"
 
-#include "../CCallback.h"
-
+#include "../lib/callback/CCallback.h"
 #include "../lib/networkPacks/PacksForLobby.h"
 #include "../lib/mapObjects/CArmedInstance.h"
 #include "../lib/CConfigHandler.h"

+ 1 - 2
client/HeroMovementController.cpp

@@ -20,11 +20,10 @@
 #include "mapView/mapHandler.h"
 #include "media/ISoundPlayer.h"
 
-#include "../CCallback.h"
-
 #include "../lib/ConditionalWait.h"
 #include "../lib/CConfigHandler.h"
 #include "../lib/CRandomGenerator.h"
+#include "../lib/callback/CCallback.h"
 #include "../lib/pathfinder/CGPathNode.h"
 #include "../lib/mapObjects/CGHeroInstance.h"
 #include "../lib/networkPacks/PacksForClient.h"

+ 1 - 1
client/NetPacksClient.cpp

@@ -28,7 +28,7 @@
 #include "CServerHandler.h"
 #include "UIHelper.h"
 
-#include "../CCallback.h"
+#include "../lib/callback/CCallback.h"
 #include "../lib/filesystem/Filesystem.h"
 #include "../lib/filesystem/FileInfo.h"
 #include "../lib/serializer/Connection.h"

+ 1 - 1
client/PlayerLocalState.cpp

@@ -10,7 +10,7 @@
 #include "StdInc.h"
 #include "PlayerLocalState.h"
 
-#include "../CCallback.h"
+#include "../lib/callback/CCallback.h"
 #include "../lib/json/JsonNode.h"
 #include "../lib/mapObjects/CGHeroInstance.h"
 #include "../lib/mapObjects/CGTownInstance.h"

+ 1 - 1
client/adventureMap/AdventureMapInterface.cpp

@@ -37,9 +37,9 @@
 #include "../PlayerLocalState.h"
 #include "../CPlayerInterface.h"
 
-#include "../../CCallback.h"
 #include "../../lib/IGameSettings.h"
 #include "../../lib/StartInfo.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/texts/CGeneralTextHandler.h"
 #include "../../lib/spells/CSpellHandler.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"

+ 1 - 1
client/adventureMap/AdventureMapShortcuts.cpp

@@ -30,9 +30,9 @@
 #include "AdventureOptions.h"
 #include "AdventureState.h"
 
-#include "../../CCallback.h"
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/CPlayerState.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/texts/CGeneralTextHandler.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/mapObjects/CGTownInstance.h"

+ 1 - 1
client/adventureMap/AdventureOptions.cpp

@@ -21,9 +21,9 @@
 #include "../gui/Shortcut.h"
 #include "../widgets/Buttons.h"
 
-#include "../../CCallback.h"
 #include "../../lib/GameLibrary.h"
 #include "../../lib/StartInfo.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/texts/CGeneralTextHandler.h"
 
 AdventureOptions::AdventureOptions()

+ 0 - 1
client/adventureMap/CInGameConsole.cpp

@@ -27,7 +27,6 @@
 #include "../adventureMap/AdventureMapInterface.h"
 #include "../windows/CMessage.h"
 
-#include "../../CCallback.h"
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/CThreadHelper.h"
 #include "../../lib/mapObjects/CArmedInstance.h"

+ 1 - 1
client/adventureMap/CInfoBar.cpp

@@ -27,9 +27,9 @@
 #include "../media/ISoundPlayer.h"
 #include "../render/IScreenHandler.h"
 
-#include "../../CCallback.h"
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/GameLibrary.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/texts/CGeneralTextHandler.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/mapObjects/CGTownInstance.h"

+ 1 - 2
client/adventureMap/CList.cpp

@@ -28,14 +28,13 @@
 #include "../render/Canvas.h"
 #include "../render/Colors.h"
 
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/texts/CGeneralTextHandler.h"
 #include "../../lib/IGameSettings.h"
 #include "../../lib/GameLibrary.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/mapObjects/CGTownInstance.h"
 
-#include "../../CCallback.h"
-
 CList::CListItem::CListItem(CList * Parent)
 	: CIntObject(LCLICK | SHOW_POPUP | HOVER),
 	parent(Parent),

+ 1 - 1
client/adventureMap/CMinimap.cpp

@@ -24,7 +24,7 @@
 #include "../render/Graphics.h"
 #include "../windows/InfoWindows.h"
 
-#include "../../CCallback.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/texts/CGeneralTextHandler.h"
 #include "../../lib/TerrainHandler.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"

+ 1 - 1
client/adventureMap/CResDataBar.cpp

@@ -19,8 +19,8 @@
 #include "../gui/TextAlignment.h"
 #include "../widgets/Images.h"
 
-#include "../../CCallback.h"
 #include "../../lib/CConfigHandler.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/texts/CGeneralTextHandler.h"
 #include "../../lib/ResourceSet.h"
 #include "../../lib/GameLibrary.h"

+ 1 - 1
client/adventureMap/MapAudioPlayer.cpp

@@ -10,7 +10,6 @@
 #include "StdInc.h"
 #include "MapAudioPlayer.h"
 
-#include "../CCallback.h"
 #include "../CPlayerInterface.h"
 #include "../GameEngine.h"
 #include "../GameInstance.h"
@@ -20,6 +19,7 @@
 
 #include "../../lib/CRandomGenerator.h"
 #include "../../lib/TerrainHandler.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/mapObjects/CArmedInstance.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/mapping/CMap.h"

+ 2 - 1
client/adventureMap/TurnTimerWidget.cpp

@@ -21,10 +21,11 @@
 #include "../widgets/GraphicalPrimitiveCanvas.h"
 #include "../widgets/TextControls.h"
 
-#include "../../CCallback.h"
 #include "../../lib/CPlayerState.h"
 #include "../../lib/CStack.h"
 #include "../../lib/StartInfo.h"
+#include "../../lib/battle/CPlayerBattleCallback.h"
+#include "../../lib/callback/CCallback.h"
 
 TurnTimerWidget::TurnTimerWidget(const Point & position)
 	: TurnTimerWidget(position, PlayerColor::NEUTRAL)

+ 2 - 1
client/battle/BattleActionsController.cpp

@@ -26,13 +26,14 @@
 #include "../windows/CCreatureWindow.h"
 #include "../windows/InfoWindows.h"
 
-#include "../../CCallback.h"
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/GameLibrary.h"
 #include "../../lib/texts/CGeneralTextHandler.h"
 #include "../../lib/CRandomGenerator.h"
 #include "../../lib/CStack.h"
 #include "../../lib/battle/BattleAction.h"
+#include "../../lib/battle/CPlayerBattleCallback.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/spells/CSpellHandler.h"
 #include "../../lib/spells/ISpellMechanics.h"
 #include "../../lib/spells/Problem.h"

+ 1 - 1
client/battle/BattleAnimationClasses.cpp

@@ -26,7 +26,7 @@
 #include "../render/CAnimation.h"
 #include "../render/IRenderHandler.h"
 
-#include "../../CCallback.h"
+#include "../../lib/battle/CPlayerBattleCallback.h"
 #include "../../lib/CStack.h"
 
 BattleAnimation::BattleAnimation(BattleInterface & owner)

+ 1 - 3
client/battle/BattleEffectsController.cpp

@@ -25,12 +25,10 @@
 #include "../render/CAnimation.h"
 #include "../render/Graphics.h"
 
-#include "../../CCallback.h"
-
 #include "../../lib/CStack.h"
 #include "../../lib/GameLibrary.h"
-#include "../../lib/IGameEventsReceiver.h"
 #include "../../lib/battle/BattleAction.h"
+#include "../../lib/battle/CPlayerBattleCallback.h"
 #include "../../lib/filesystem/ResourcePath.h"
 #include "../../lib/networkPacks/PacksForClientBattle.h"
 #include "../../lib/texts/CGeneralTextHandler.h"

+ 1 - 1
client/battle/BattleFieldController.cpp

@@ -32,10 +32,10 @@
 #include "../adventureMap/CInGameConsole.h"
 #include "../client/render/CAnimation.h"
 
-#include "../../CCallback.h"
 #include "../../lib/BattleFieldHandler.h"
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/CStack.h"
+#include "../../lib/battle/CPlayerBattleCallback.h"
 #include "../../lib/spells/ISpellMechanics.h"
 
 namespace HexMasks

+ 2 - 1
client/battle/BattleInterface.cpp

@@ -34,7 +34,6 @@
 #include "../render/Canvas.h"
 #include "../adventureMap/AdventureMapInterface.h"
 
-#include "../../CCallback.h"
 
 #include "../../lib/BattleFieldHandler.h"
 #include "../../lib/CConfigHandler.h"
@@ -43,6 +42,8 @@
 #include "../../lib/GameLibrary.h"
 #include "../../lib/TerrainHandler.h"
 #include "../../lib/UnlockGuard.h"
+#include "../../lib/battle/CPlayerBattleCallback.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/gameState/InfoAboutArmy.h"
 #include "../../lib/mapObjects/CGTownInstance.h"
 #include "../../lib/networkPacks/PacksForClientBattle.h"

+ 2 - 1
client/battle/BattleInterfaceClasses.cpp

@@ -46,10 +46,11 @@
 #include "../adventureMap/CInGameConsole.h"
 #include "../eventsSDL/InputHandler.h"
 
-#include "../../CCallback.h"
 #include "../../lib/CStack.h"
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/CCreatureHandler.h"
+#include "../../lib/battle/CPlayerBattleCallback.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/entities/hero/CHeroClass.h"
 #include "../../lib/entities/hero/CHero.h"
 #include "../../lib/GameLibrary.h"

+ 1 - 1
client/battle/BattleObstacleController.cpp

@@ -24,9 +24,9 @@
 #include "../render/Canvas.h"
 #include "../render/IRenderHandler.h"
 
-#include "../../CCallback.h"
 #include "../../lib/battle/CObstacleInstance.h"
 #include "../../lib/ObstacleHandler.h"
+#include "../../lib/battle/CPlayerBattleCallback.h"
 #include "../../lib/serializer/JsonDeserializer.h"
 
 BattleObstacleController::BattleObstacleController(BattleInterface & owner):

+ 1 - 1
client/battle/BattleSiegeController.cpp

@@ -24,8 +24,8 @@
 #include "../render/IImage.h"
 #include "../render/IRenderHandler.h"
 
-#include "../../CCallback.h"
 #include "../../lib/CStack.h"
+#include "../../lib/battle/CPlayerBattleCallback.h"
 #include "../../lib/entities/building/TownFortifications.h"
 #include "../../lib/mapObjects/CGTownInstance.h"
 #include "../../lib/networkPacks/PacksForClientBattle.h"

+ 1 - 2
client/battle/BattleStacksController.cpp

@@ -32,14 +32,13 @@
 #include "../render/Graphics.h"
 #include "../render/IFont.h"
 
-#include "../../CCallback.h"
-
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/CRandomGenerator.h"
 #include "../../lib/CStack.h"
 #include "../../lib/GameLibrary.h"
 #include "../../lib/battle/BattleAction.h"
 #include "../../lib/battle/BattleHex.h"
+#include "../../lib/battle/CPlayerBattleCallback.h"
 #include "../../lib/spells/ISpellMechanics.h"
 #include "../../lib/texts/TextOperations.h"
 

+ 5 - 7
client/battle/BattleWindow.cpp

@@ -34,14 +34,15 @@
 #include "../adventureMap/TurnTimerWidget.h"
 #include "../windows/settings/SettingsMainWindow.h"
 
-#include "../../CCallback.h"
-
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/CPlayerState.h"
 #include "../../lib/CStack.h"
 #include "../../lib/GameLibrary.h"
 #include "../../lib/StartInfo.h"
 #include "../../lib/battle/BattleInfo.h"
+#include "../../lib/battle/CPlayerBattleCallback.h"
+#include "../../lib/callback/CCallback.h"
+#include "../../lib/callback/CDynLibHandler.h"
 #include "../../lib/entities/artifact/CArtHandler.h"
 #include "../../lib/filesystem/ResourcePath.h"
 #include "../../lib/gameState/InfoAboutArmy.h"
@@ -706,8 +707,7 @@ void BattleWindow::bAutofightf()
 
 		ai->initBattleInterface(owner.curInt->env, owner.curInt->cb, autocombatPreferences);
 		ai->battleStart(owner.getBattleID(), owner.army1, owner.army2, int3(0,0,0), owner.attackingHeroInstance, owner.defendingHeroInstance, owner.getBattle()->battleGetMySide(), false);
-		owner.curInt->autofightingAI = ai;
-		owner.curInt->cb->registerBattleInterface(ai);
+		owner.curInt->registerBattleInterface(ai);
 
 		owner.requestAutofightingAIToTakeAction();
 	}
@@ -909,9 +909,7 @@ void BattleWindow::endWithAutocombat()
 			ai->battleStart(owner.getBattleID(), owner.army1, owner.army2, int3(0,0,0), owner.attackingHeroInstance, owner.defendingHeroInstance, owner.getBattle()->battleGetMySide(), false);
 
 			owner.curInt->isAutoFightOn = true;
-			owner.curInt->cb->registerBattleInterface(ai);
-			owner.curInt->autofightingAI = ai;
-
+			owner.curInt->registerBattleInterface(ai);
 			owner.requestAutofightingAIToTakeAction();
 
 			close();

+ 1 - 1
client/lobby/CCampaignInfoScreen.cpp

@@ -11,7 +11,7 @@
 
 #include "CCampaignInfoScreen.h"
 
-#include "../../CCallback.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/texts/CGeneralTextHandler.h"
 #include "../../lib/StartInfo.h"
 #include "../../lib/mapping/CMapInfo.h"

+ 0 - 2
client/lobby/CLobbyScreen.cpp

@@ -27,8 +27,6 @@
 #include "../render/Colors.h"
 #include "../globalLobby/GlobalLobbyClient.h"
 
-#include "../../CCallback.h"
-
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/texts/CGeneralTextHandler.h"
 #include "../../lib/campaign/CampaignHandler.h"

+ 1 - 1
client/lobby/CSavingScreen.cpp

@@ -19,8 +19,8 @@
 #include "../widgets/Buttons.h"
 #include "../widgets/CTextInput.h"
 
-#include "../../CCallback.h"
 #include "../../lib/CConfigHandler.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/texts/CGeneralTextHandler.h"
 #include "../../lib/StartInfo.h"
 #include "../../lib/filesystem/Filesystem.h"

+ 1 - 2
client/lobby/CScenarioInfoScreen.cpp

@@ -18,8 +18,7 @@
 #include "../gui/Shortcut.h"
 #include "../widgets/Buttons.h"
 
-#include "../../CCallback.h"
-
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/texts/CGeneralTextHandler.h"
 #include "../../lib/StartInfo.h"
 #include "../../lib/mapping/CMapInfo.h"

+ 0 - 2
client/lobby/CSelectionBase.cpp

@@ -16,8 +16,6 @@
 #include "RandomMapTab.h"
 #include "SelectionTab.h"
 
-#include "../../CCallback.h"
-
 #include "../CPlayerInterface.h"
 #include "../CServerHandler.h"
 #include "../GameEngine.h"

+ 0 - 2
client/lobby/SelectionTab.cpp

@@ -33,8 +33,6 @@
 #include "../render/IImage.h"
 #include "../render/IRenderHandler.h"
 
-#include "../../CCallback.h"
-
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/IGameSettings.h"
 #include "../../lib/filesystem/Filesystem.h"

+ 0 - 2
client/mainmenu/CMainMenu.cpp

@@ -45,8 +45,6 @@
 #include "../Client.h"
 #include "../CMT.h"
 
-#include "../../CCallback.h"
-
 #include "../../lib/texts/CGeneralTextHandler.h"
 #include "../../lib/campaign/CampaignHandler.h"
 #include "../../lib/filesystem/Filesystem.h"

+ 0 - 2
client/mapView/MapRenderer.cpp

@@ -22,8 +22,6 @@
 #include "../render/Colors.h"
 #include "../render/Graphics.h"
 
-#include "../../CCallback.h"
-
 #include "../../lib/RiverHandler.h"
 #include "../../lib/RoadHandler.h"
 #include "../../lib/TerrainHandler.h"

+ 1 - 1
client/mapView/MapRendererContext.cpp

@@ -14,12 +14,12 @@
 #include "MapRendererContextState.h"
 #include "mapHandler.h"
 
-#include "../../CCallback.h"
 #include "../CPlayerInterface.h"
 #include "../PlayerLocalState.h"
 #include "../GameInstance.h"
 
 #include "../../lib/Point.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/mapObjects/MiscObjects.h"
 #include "../../lib/spells/CSpellHandler.h"

+ 1 - 1
client/mapView/MapRendererContextState.cpp

@@ -14,11 +14,11 @@
 #include "IMapRendererContext.h"
 #include "mapHandler.h"
 
-#include "../../CCallback.h"
 #include "../CPlayerInterface.h"
 #include "../GameInstance.h"
 #include "../adventureMap/AdventureMapInterface.h"
 
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/mapping/CMap.h"
 

+ 1 - 2
client/mapView/MapView.cpp

@@ -26,8 +26,7 @@
 #include "../render/IImage.h"
 #include "../eventsSDL/InputHandler.h"
 
-#include "../../CCallback.h"
-
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
 

+ 1 - 1
client/mapView/MapViewController.cpp

@@ -16,7 +16,6 @@
 #include "MapViewCache.h"
 #include "MapViewModel.h"
 
-#include "../CCallback.h"
 #include "../CPlayerInterface.h"
 #include "../adventureMap/AdventureMapInterface.h"
 #include "../GameEngine.h"
@@ -27,6 +26,7 @@
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/StartInfo.h"
 #include "../../lib/UnlockGuard.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/mapObjects/MiscObjects.h"
 #include "../../lib/pathfinder/CGPathNode.h"

+ 2 - 1
client/mapView/mapHandler.cpp

@@ -12,13 +12,14 @@
 #include "IMapRendererObserver.h"
 #include "mapHandler.h"
 
-#include "../CCallback.h"
 #include "../CPlayerInterface.h"
 #include "../GameEngine.h"
 #include "../GameInstance.h"
 
 #include "../../lib/texts/CGeneralTextHandler.h"
 #include "../../lib/TerrainHandler.h"
+#include "../../lib/callback/CCallback.h"
+#include "../../lib/callback/IGameInfoCallback.h"
 #include "../../lib/mapObjectConstructors/CObjectClassesHandler.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/mapObjects/ObjectTemplate.h"

+ 0 - 2
client/widgets/CArtifactsOfHeroAltar.cpp

@@ -13,8 +13,6 @@
 #include "Buttons.h"
 #include "../CPlayerInterface.h"
 
-#include "../../CCallback.h"
-
 #include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/networkPacks/ArtifactLocation.h"
 

+ 1 - 2
client/widgets/CArtifactsOfHeroBackpack.cpp

@@ -20,11 +20,10 @@
 #include "../CPlayerInterface.h"
 #include "../../lib/entities/artifact/ArtifactUtils.h"
 #include "../../lib/entities/artifact/CArtifact.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/networkPacks/ArtifactLocation.h"
 
-#include "../../CCallback.h"
-
 CArtifactsOfHeroBackpack::CArtifactsOfHeroBackpack(size_t slotsColumnsMax, size_t slotsRowsMax)
 	: slotsColumnsMax(slotsColumnsMax)
 	, slotsRowsMax(slotsRowsMax)

+ 1 - 1
client/widgets/CArtifactsOfHeroBase.cpp

@@ -18,7 +18,7 @@
 
 #include "../CPlayerInterface.h"
 
-#include "../../CCallback.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/entities/artifact/ArtifactUtils.h"
 #include "../../lib/entities/artifact/CArtifact.h"
 #include "../../lib/entities/artifact/CArtifactFittingSet.h"

+ 0 - 1
client/widgets/CArtifactsOfHeroKingdom.cpp

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

+ 1 - 2
client/widgets/CArtifactsOfHeroMain.cpp

@@ -14,9 +14,8 @@
 #include "../GameInstance.h"
 
 #include "../CPlayerInterface.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
-
-#include "../../CCallback.h"
 #include "../../lib/networkPacks/ArtifactLocation.h"
 
 CArtifactsOfHeroMain::CArtifactsOfHeroMain(const Point & position)

+ 1 - 2
client/widgets/CComponentHolder.cpp

@@ -22,11 +22,10 @@
 #include "../render/IRenderHandler.h"
 #include "../CPlayerInterface.h"
 
-#include "../../CCallback.h"
-
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/CSkillHandler.h"
 #include "../../lib/GameLibrary.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/entities/artifact/ArtifactUtils.h"
 #include "../../lib/entities/artifact/CArtifact.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"

+ 1 - 2
client/widgets/CExchangeController.cpp

@@ -15,8 +15,7 @@
 
 #include "../widgets/CGarrisonInt.h"
 
-#include "../../CCallback.h"
-
+#include "../lib/callback/CCallback.h"
 #include "../lib/mapObjects/CGHeroInstance.h"
 
 CExchangeController::CExchangeController(ObjectInstanceID hero1, ObjectInstanceID hero2)

+ 0 - 2
client/widgets/CExchangeController.h

@@ -11,8 +11,6 @@
  
 #include "../lib/mapObjects/CGHeroInstance.h"
  
-class CCallback;
-
 class CExchangeController
 {
 public:

+ 1 - 2
client/widgets/CGarrisonInt.cpp

@@ -23,13 +23,12 @@
 #include "../windows/GUIClasses.h"
 #include "../CPlayerInterface.h"
 
-#include "../../CCallback.h"
-
 #include "../../lib/texts/CGeneralTextHandler.h"
 #include "../../lib/texts/TextOperations.h"
 #include "../../lib/CCreatureHandler.h"
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/GameLibrary.h"
+#include "../../lib/callback/CCallback.h"
 #include "../../lib/entities/artifact/ArtifactUtils.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/networkPacks/ArtifactLocation.h"

+ 0 - 2
client/widgets/Images.cpp

@@ -25,8 +25,6 @@
 
 #include "../CPlayerInterface.h"
 
-#include "../../CCallback.h"
-
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/texts/CGeneralTextHandler.h" //for Unicode related stuff
 #include "../../lib/CRandomGenerator.h"

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio