1
0
forked from 0ad/0ad

Check only that the destruction queue contains no non-local entity when serializing the game state.

Local entities being in the destruction queue when serialising is not an
issue since those should not affect the simulation anyways. This stops
the game from crashing in some rare situations.

Fixes #4616

Differential Revision: https://code.wildfiregames.com/D1738
This was SVN commit r22865.
This commit is contained in:
wraitii 2019-09-07 14:41:53 +00:00
parent 524422c7d8
commit 43bbd7d671

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2017 Wildfire Games. /* Copyright (C) 2019 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@ -181,9 +181,10 @@ bool CComponentManager::SerializeState(std::ostream& stream) const
{ {
CStdSerializer serializer(m_ScriptInterface, stream); CStdSerializer serializer(m_ScriptInterface, stream);
// We don't serialize the destruction queue, since we'd have to be careful to skip local entities etc // We don't serialize the destruction queue, since we'd have to be careful to skip local entities etc.
// and it's (hopefully) easier to just expect callers to flush the queue before serializing // This means we cannot have non-local entities in the destruction queue at this point.
ENSURE(m_DestructionQueue.empty()); ENSURE(m_DestructionQueue.empty() || std::find_if(m_DestructionQueue.begin(), m_DestructionQueue.end(),
[](entity_id_t ent) { return !ENTITY_IS_LOCAL(ent); }) == m_DestructionQueue.end());
serializer.StringASCII("rng", SerializeRNG(m_RNG), 0, 32); serializer.StringASCII("rng", SerializeRNG(m_RNG), 0, 32);
serializer.NumberU32_Unbounded("next entity id", m_NextEntityId); serializer.NumberU32_Unbounded("next entity id", m_NextEntityId);