mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
TurnTimerHandler is now a unique_ptr
This commit is contained in:
parent
a99d5e6fa1
commit
090a1c7764
@ -514,7 +514,7 @@ CGameHandler::CGameHandler(CVCMIServer * lobby)
|
||||
, complainNoCreatures("No creatures to split")
|
||||
, complainNotEnoughCreatures("Cannot split that stack, not enough creatures!")
|
||||
, complainInvalidSlot("Invalid slot accessed!")
|
||||
, turnTimerHandler(*this)
|
||||
, turnTimerHandler(std::make_unique<TurnTimerHandler>(*this))
|
||||
{
|
||||
QID = 1;
|
||||
applier = std::make_shared<CApplier<CBaseForGHApply>>();
|
||||
@ -616,7 +616,7 @@ void CGameHandler::setPortalDwelling(const CGTownInstance * town, bool forced=fa
|
||||
void CGameHandler::onPlayerTurnStarted(PlayerColor which)
|
||||
{
|
||||
events::PlayerGotTurn::defaultExecute(serverEventBus.get(), which);
|
||||
turnTimerHandler.onPlayerGetTurn(which);
|
||||
turnTimerHandler->onPlayerGetTurn(which);
|
||||
}
|
||||
|
||||
void CGameHandler::onPlayerTurnEnded(PlayerColor which)
|
||||
@ -1009,7 +1009,7 @@ void CGameHandler::start(bool resume)
|
||||
onNewTurn();
|
||||
events::TurnStarted::defaultExecute(serverEventBus.get());
|
||||
for(auto & player : gs->players)
|
||||
turnTimerHandler.onGameplayStart(player.first);
|
||||
turnTimerHandler->onGameplayStart(player.first);
|
||||
}
|
||||
else
|
||||
events::GameResumed::defaultExecute(serverEventBus.get());
|
||||
@ -1019,7 +1019,7 @@ void CGameHandler::start(bool resume)
|
||||
|
||||
void CGameHandler::tick(int millisecondsPassed)
|
||||
{
|
||||
turnTimerHandler.update(millisecondsPassed);
|
||||
turnTimerHandler->update(millisecondsPassed);
|
||||
}
|
||||
|
||||
void CGameHandler::giveSpells(const CGTownInstance *t, const CGHeroInstance *h)
|
||||
@ -1307,7 +1307,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
|
||||
if(h->boat && !h->boat->onboardAssaultAllowed)
|
||||
lookForGuards = IGNORE_GUARDS;
|
||||
|
||||
turnTimerHandler.setEndTurnAllowed(h->getOwner(), !movingOntoWater && !movingOntoObstacle);
|
||||
turnTimerHandler->setEndTurnAllowed(h->getOwner(), !movingOntoWater && !movingOntoObstacle);
|
||||
doMove(TryMoveHero::SUCCESS, lookForGuards, visitDest, LEAVING_TILE);
|
||||
return true;
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
std::unique_ptr<BattleProcessor> battles;
|
||||
std::unique_ptr<QueriesProcessor> queries;
|
||||
std::unique_ptr<TurnOrderProcessor> turnOrder;
|
||||
std::unique_ptr<TurnTimerHandler> turnTimerHandler;
|
||||
|
||||
//use enums as parameters, because doMove(sth, true, false, true) is not readable
|
||||
enum EGuardLook {CHECK_FOR_GUARDS, IGNORE_GUARDS};
|
||||
@ -76,8 +77,6 @@ public:
|
||||
ui32 QID;
|
||||
|
||||
SpellCastEnvironment * spellEnv;
|
||||
|
||||
TurnTimerHandler turnTimerHandler;
|
||||
|
||||
const Services * services() const override;
|
||||
const BattleCb * battle(const BattleID & battleID) const override;
|
||||
|
@ -126,7 +126,7 @@ void BattleFlowProcessor::onBattleStarted(const CBattleInfoCallback & battle)
|
||||
{
|
||||
tryPlaceMoats(battle);
|
||||
|
||||
gameHandler->turnTimerHandler.onBattleStart(battle.getBattle()->getBattleID());
|
||||
gameHandler->turnTimerHandler->onBattleStart(battle.getBattle()->getBattleID());
|
||||
|
||||
if (battle.battleGetTacticDist() == 0)
|
||||
onTacticsEnded(battle);
|
||||
@ -319,7 +319,7 @@ void BattleFlowProcessor::activateNextStack(const CBattleInfoCallback & battle)
|
||||
if(!removeGhosts.changedStacks.empty())
|
||||
gameHandler->sendAndApply(&removeGhosts);
|
||||
|
||||
gameHandler->turnTimerHandler.onBattleNextStack(battle.getBattle()->getBattleID(), *next);
|
||||
gameHandler->turnTimerHandler->onBattleNextStack(battle.getBattle()->getBattleID(), *next);
|
||||
|
||||
if (!tryMakeAutomaticAction(battle, next))
|
||||
{
|
||||
|
@ -292,7 +292,7 @@ void BattleResultProcessor::endBattle(const CBattleInfoCallback & battle)
|
||||
otherBattleQuery->result = battleQuery->result;
|
||||
}
|
||||
|
||||
gameHandler->turnTimerHandler.onBattleEnd(battle.getBattle()->getBattleID());
|
||||
gameHandler->turnTimerHandler->onBattleEnd(battle.getBattle()->getBattleID());
|
||||
gameHandler->sendAndApply(battleResult);
|
||||
|
||||
if (battleResult->queryID == QueryID::NONE)
|
||||
|
@ -30,12 +30,12 @@ bool TimerPauseQuery::blocksPack(const CPack *pack) const
|
||||
|
||||
void TimerPauseQuery::onAdding(PlayerColor color)
|
||||
{
|
||||
gh->turnTimerHandler.setTimerEnabled(color, false);
|
||||
gh->turnTimerHandler->setTimerEnabled(color, false);
|
||||
}
|
||||
|
||||
void TimerPauseQuery::onRemoval(PlayerColor color)
|
||||
{
|
||||
gh->turnTimerHandler.setTimerEnabled(color, true);
|
||||
gh->turnTimerHandler->setTimerEnabled(color, true);
|
||||
}
|
||||
|
||||
bool TimerPauseQuery::endsByPlayerAnswer() const
|
||||
|
Loading…
Reference in New Issue
Block a user