mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Added serialization of turn timer handler
This commit is contained in:
parent
090a1c7764
commit
5010344df0
@ -39,6 +39,7 @@ enum class ESerializationVersion : int32_t
|
||||
JSON_FLAGS, // 836 json uses new format for flags
|
||||
MANA_LIMIT, // 837 change MANA_PER_KNOWLEGDE to percentage
|
||||
BONUS_META_STRING, // 838 bonuses use MetaString instead of std::string for descriptions
|
||||
TURN_TIMERS_STATE, // 839 current state of turn timers is serialized
|
||||
|
||||
CURRENT = BONUS_META_STRING
|
||||
CURRENT = TURN_TIMERS_STATE
|
||||
};
|
||||
|
@ -230,6 +230,9 @@ public:
|
||||
h & *playerMessages;
|
||||
h & *turnOrder;
|
||||
|
||||
if (h.version >= Handler::Version::TURN_TIMERS_STATE)
|
||||
h & *turnTimerHandler;
|
||||
|
||||
#if SCRIPTING_ENABLED
|
||||
JsonNode scriptsState;
|
||||
if(h.saving)
|
||||
|
@ -25,7 +25,7 @@ class CGameHandler;
|
||||
class TurnTimerHandler
|
||||
{
|
||||
CGameHandler & gameHandler;
|
||||
const int turnTimePropagateFrequency = 1000;
|
||||
static constexpr int turnTimePropagateFrequency = 1000;
|
||||
std::map<PlayerColor, TurnTimerInfo> timers;
|
||||
std::map<PlayerColor, int> lastUpdate;
|
||||
std::map<PlayerColor, bool> endTurnAllowed;
|
||||
@ -48,4 +48,11 @@ public:
|
||||
void update(int waitTime);
|
||||
void setTimerEnabled(PlayerColor player, bool enabled);
|
||||
void setEndTurnAllowed(PlayerColor player, bool enabled);
|
||||
|
||||
template<typename Handler>
|
||||
void serialize(Handler & h)
|
||||
{
|
||||
h & timers;
|
||||
h & endTurnAllowed;
|
||||
}
|
||||
};
|
||||
|
@ -249,10 +249,12 @@ void TurnOrderProcessor::doStartPlayerTurn(PlayerColor which)
|
||||
assert(gameHandler->getPlayerState(which));
|
||||
assert(gameHandler->getPlayerState(which)->status == EPlayerStatus::INGAME);
|
||||
|
||||
//Note: on game load, "actingPlayer" might already contain list of players
|
||||
// Only if player is actually starting his turn (and not loading from save)
|
||||
if (!actingPlayers.count(which))
|
||||
gameHandler->onPlayerTurnStarted(which);
|
||||
|
||||
actingPlayers.insert(which);
|
||||
awaitingPlayers.erase(which);
|
||||
gameHandler->onPlayerTurnStarted(which);
|
||||
|
||||
auto turnQuery = std::make_shared<TimerPauseQuery>(gameHandler, which);
|
||||
gameHandler->queries->addQuery(turnQuery);
|
||||
|
Loading…
Reference in New Issue
Block a user