mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-10-09 07:59:40 +00:00
Improve performance of full state hash computation, by skipping script components that are known to have no data.
Switch to much quicker (and less comprehensive) per-turn hashing in multiplayer games. This was SVN commit r9036.
This commit is contained in:
@@ -100,11 +100,15 @@ bool CComponentManager::DumpDebugState(std::ostream& stream)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CComponentManager::ComputeStateHash(std::string& outHash)
|
||||
bool CComponentManager::ComputeStateHash(std::string& outHash, bool quick)
|
||||
{
|
||||
// Hash serialization: this includes the minimal data necessary to detect
|
||||
// differences in the state, and ignores things like counts and names
|
||||
|
||||
// If 'quick' is set, this checks even fewer things, so that it will
|
||||
// be fast enough to run every turn but will typically detect any
|
||||
// out-of-syncs fairly soon
|
||||
|
||||
CHashSerializer serializer(m_ScriptInterface);
|
||||
|
||||
serializer.StringASCII("rng", SerializeRNG(m_RNG), 0, 32);
|
||||
@@ -116,6 +120,10 @@ bool CComponentManager::ComputeStateHash(std::string& outHash)
|
||||
if (cit->second.empty())
|
||||
continue;
|
||||
|
||||
// In quick mode, only check unit positions
|
||||
if (quick && !(cit->first == CID_Position))
|
||||
continue;
|
||||
|
||||
serializer.NumberI32_Unbounded("component type id", cit->first);
|
||||
|
||||
std::map<entity_id_t, IComponent*>::const_iterator eit = cit->second.begin();
|
||||
|
||||
Reference in New Issue
Block a user