diff --git a/server/battles/BattleActionProcessor.cpp b/server/battles/BattleActionProcessor.cpp index 012a9918b..44157097e 100644 --- a/server/battles/BattleActionProcessor.cpp +++ b/server/battles/BattleActionProcessor.cpp @@ -29,17 +29,12 @@ #include "../../lib/spells/ISpellMechanics.h" #include "../../lib/spells/Problem.h" -BattleActionProcessor::BattleActionProcessor(BattleProcessor * owner) +BattleActionProcessor::BattleActionProcessor(BattleProcessor * owner, CGameHandler * newGameHandler) : owner(owner) - , gameHandler(nullptr) + , gameHandler(newGameHandler) { } -void BattleActionProcessor::setGameHandler(CGameHandler * newGameHandler) -{ - gameHandler = newGameHandler; -} - bool BattleActionProcessor::doEmptyAction(const CBattleInfoCallback & battle, const BattleAction & ba) { return true; diff --git a/server/battles/BattleActionProcessor.h b/server/battles/BattleActionProcessor.h index 6c28b5950..ec616f888 100644 --- a/server/battles/BattleActionProcessor.h +++ b/server/battles/BattleActionProcessor.h @@ -78,8 +78,7 @@ class BattleActionProcessor : boost::noncopyable bool makeBattleActionImpl(const CBattleInfoCallback & battle, const BattleAction & ba); public: - explicit BattleActionProcessor(BattleProcessor * owner); - void setGameHandler(CGameHandler * newGameHandler); + explicit BattleActionProcessor(BattleProcessor * owner, CGameHandler * newGameHandler); bool makeAutomaticBattleAction(const CBattleInfoCallback & battle, const BattleAction & ba); bool makePlayerBattleAction(const CBattleInfoCallback & battle, PlayerColor player, const BattleAction & ba); diff --git a/server/battles/BattleFlowProcessor.cpp b/server/battles/BattleFlowProcessor.cpp index 94d585803..aca32f764 100644 --- a/server/battles/BattleFlowProcessor.cpp +++ b/server/battles/BattleFlowProcessor.cpp @@ -25,17 +25,12 @@ #include "../../lib/spells/ISpellMechanics.h" #include "../../lib/spells/ObstacleCasterProxy.h" -BattleFlowProcessor::BattleFlowProcessor(BattleProcessor * owner) +BattleFlowProcessor::BattleFlowProcessor(BattleProcessor * owner, CGameHandler * newGameHandler) : owner(owner) - , gameHandler(nullptr) + , gameHandler(newGameHandler) { } -void BattleFlowProcessor::setGameHandler(CGameHandler * newGameHandler) -{ - gameHandler = newGameHandler; -} - void BattleFlowProcessor::summonGuardiansHelper(const CBattleInfoCallback & battle, std::vector & output, const BattleHex & targetPosition, ui8 side, bool targetIsTwoHex) //return hexes for summoning two hex monsters in output, target = unit to guard { int x = targetPosition.getX(); diff --git a/server/battles/BattleFlowProcessor.h b/server/battles/BattleFlowProcessor.h index 929445701..e781b0a75 100644 --- a/server/battles/BattleFlowProcessor.h +++ b/server/battles/BattleFlowProcessor.h @@ -51,8 +51,7 @@ class BattleFlowProcessor : boost::noncopyable bool makeAutomaticAction(const CBattleInfoCallback & battle, const CStack * stack, BattleAction & ba); //used when action is taken by stack without volition of player (eg. unguided catapult attack) public: - explicit BattleFlowProcessor(BattleProcessor * owner); - void setGameHandler(CGameHandler * newGameHandler); + explicit BattleFlowProcessor(BattleProcessor * owner, CGameHandler * newGameHandler); void onBattleStarted(const CBattleInfoCallback & battle); void onTacticsEnded(const CBattleInfoCallback & battle); diff --git a/server/battles/BattleProcessor.cpp b/server/battles/BattleProcessor.cpp index c2c3e4be3..14f359397 100644 --- a/server/battles/BattleProcessor.cpp +++ b/server/battles/BattleProcessor.cpp @@ -33,15 +33,9 @@ BattleProcessor::BattleProcessor(CGameHandler * gameHandler) : gameHandler(gameHandler) - , flowProcessor(std::make_unique(this)) - , actionsProcessor(std::make_unique(this)) - , resultProcessor(std::make_unique(this)) -{ - setGameHandler(gameHandler); -} - -BattleProcessor::BattleProcessor(): - BattleProcessor(nullptr) + , flowProcessor(std::make_unique(this, gameHandler)) + , actionsProcessor(std::make_unique(this, gameHandler)) + , resultProcessor(std::make_unique(this, gameHandler)) { } @@ -316,12 +310,3 @@ void BattleProcessor::battleAfterLevelUp(const BattleID & battleID, const Battle { resultProcessor->battleAfterLevelUp(battleID, result); } - -void BattleProcessor::setGameHandler(CGameHandler * newGameHandler) -{ - gameHandler = newGameHandler; - - actionsProcessor->setGameHandler(newGameHandler); - flowProcessor->setGameHandler(newGameHandler); - resultProcessor->setGameHandler(newGameHandler); -} diff --git a/server/battles/BattleProcessor.h b/server/battles/BattleProcessor.h index 952759fde..e284def89 100644 --- a/server/battles/BattleProcessor.h +++ b/server/battles/BattleProcessor.h @@ -52,11 +52,8 @@ class BattleProcessor : boost::noncopyable public: explicit BattleProcessor(CGameHandler * gameHandler); - BattleProcessor(); ~BattleProcessor(); - void setGameHandler(CGameHandler * gameHandler); - /// Starts battle with specified parameters void startBattlePrimary(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool creatureBank = false, const CGTownInstance *town = nullptr); /// Starts battle between two armies (which can also be heroes) at specified tile @@ -78,6 +75,5 @@ public: { } - }; diff --git a/server/battles/BattleResultProcessor.cpp b/server/battles/BattleResultProcessor.cpp index e4b851331..a2d161d1e 100644 --- a/server/battles/BattleResultProcessor.cpp +++ b/server/battles/BattleResultProcessor.cpp @@ -29,17 +29,12 @@ #include "../../lib/serializer/Cast.h" #include "../../lib/spells/CSpellHandler.h" -BattleResultProcessor::BattleResultProcessor(BattleProcessor * owner) +BattleResultProcessor::BattleResultProcessor(BattleProcessor * owner, CGameHandler * newGameHandler) // : owner(owner) - : gameHandler(nullptr) + : gameHandler(newGameHandler) { } -void BattleResultProcessor::setGameHandler(CGameHandler * newGameHandler) -{ - gameHandler = newGameHandler; -} - CasualtiesAfterBattle::CasualtiesAfterBattle(const CBattleInfoCallback & battle, uint8_t sideInBattle): army(battle.battleGetArmyObject(sideInBattle)) { diff --git a/server/battles/BattleResultProcessor.h b/server/battles/BattleResultProcessor.h index 5160c55e4..f82f18fba 100644 --- a/server/battles/BattleResultProcessor.h +++ b/server/battles/BattleResultProcessor.h @@ -70,8 +70,7 @@ class BattleResultProcessor : boost::noncopyable std::map> finishingBattles; public: - explicit BattleResultProcessor(BattleProcessor * owner); - void setGameHandler(CGameHandler * newGameHandler); + explicit BattleResultProcessor(BattleProcessor * owner, CGameHandler * newGameHandler); bool battleIsEnding(const CBattleInfoCallback & battle) const; diff --git a/server/processors/HeroPoolProcessor.cpp b/server/processors/HeroPoolProcessor.cpp index 053a5cd70..0c82a061b 100644 --- a/server/processors/HeroPoolProcessor.cpp +++ b/server/processors/HeroPoolProcessor.cpp @@ -25,11 +25,6 @@ #include "../../lib/gameState/TavernSlot.h" #include "../../lib/GameSettings.h" -HeroPoolProcessor::HeroPoolProcessor() - : gameHandler(nullptr) -{ -} - HeroPoolProcessor::HeroPoolProcessor(CGameHandler * gameHandler) : gameHandler(gameHandler) { diff --git a/server/processors/HeroPoolProcessor.h b/server/processors/HeroPoolProcessor.h index 941801dd0..8d0d8552d 100644 --- a/server/processors/HeroPoolProcessor.h +++ b/server/processors/HeroPoolProcessor.h @@ -28,6 +28,8 @@ class CGameHandler; class HeroPoolProcessor : boost::noncopyable { + CGameHandler * gameHandler; + /// per-player random generators std::map> playerSeed; @@ -49,9 +51,6 @@ class HeroPoolProcessor : boost::noncopyable TavernHeroSlot selectSlotForRole(const PlayerColor & player, TavernSlotRole roleID); public: - CGameHandler * gameHandler; - - HeroPoolProcessor(); HeroPoolProcessor(CGameHandler * gameHandler); void onHeroSurrendered(const PlayerColor & color, const CGHeroInstance * hero); @@ -66,7 +65,6 @@ public: template void serialize(Handler &h) { - // h & gameHandler; // FIXME: make this work instead of using deserializationFix in gameHandler h & playerSeed; h & heroSeed; } diff --git a/server/processors/PlayerMessageProcessor.cpp b/server/processors/PlayerMessageProcessor.cpp index 1184e96ff..879c36cfd 100644 --- a/server/processors/PlayerMessageProcessor.cpp +++ b/server/processors/PlayerMessageProcessor.cpp @@ -29,11 +29,6 @@ #include "../../lib/networkPacks/StackLocation.h" #include "../../lib/serializer/Connection.h" -PlayerMessageProcessor::PlayerMessageProcessor() - :gameHandler(nullptr) -{ -} - PlayerMessageProcessor::PlayerMessageProcessor(CGameHandler * gameHandler) :gameHandler(gameHandler) { diff --git a/server/processors/PlayerMessageProcessor.h b/server/processors/PlayerMessageProcessor.h index 9d4fd36dc..6dc22591b 100644 --- a/server/processors/PlayerMessageProcessor.h +++ b/server/processors/PlayerMessageProcessor.h @@ -21,6 +21,8 @@ class CGameHandler; class PlayerMessageProcessor { + CGameHandler * gameHandler; + void executeCheatCode(const std::string & cheatName, PlayerColor player, ObjectInstanceID currObj, const std::vector & arguments ); bool handleCheatCode(const std::string & cheatFullCommand, PlayerColor player, ObjectInstanceID currObj); bool handleHostCommand(PlayerColor player, const std::string & message); @@ -43,9 +45,6 @@ class PlayerMessageProcessor void cheatFly(PlayerColor player, const CGHeroInstance * hero); public: - CGameHandler * gameHandler; - - PlayerMessageProcessor(); PlayerMessageProcessor(CGameHandler * gameHandler); /// incoming NetPack handling