diff --git a/source/simulation2/system/ComponentManagerSerialization.cpp b/source/simulation2/system/ComponentManagerSerialization.cpp index 8ab921c304..d8beb38523 100644 --- a/source/simulation2/system/ComponentManagerSerialization.cpp +++ b/source/simulation2/system/ComponentManagerSerialization.cpp @@ -97,6 +97,7 @@ bool CComponentManager::DumpDebugState(std::ostream& stream, bool includeDebugIn bool CComponentManager::ComputeStateHash(std::string& outHash, bool quick) const { + PROFILE2("ComputeStateHash"); // Hash serialization: this includes the minimal data necessary to detect // differences in the state, and ignores things like counts and names @@ -117,27 +118,17 @@ bool CComponentManager::ComputeStateHash(std::string& outHash, bool quick) const continue; // Only emit component types if they have a component that will be serialized - bool needsSerialization = false; - for (std::map::const_iterator eit = cit->second.begin(); eit != cit->second.end(); ++eit) - { - // Don't serialize local entities - if (ENTITY_IS_LOCAL(eit->first)) - continue; - - needsSerialization = true; - break; - } - - if (!needsSerialization) - continue; - - serializer.NumberI32_Unbounded("component type id", cit->first); - + bool hasEmittedComponent = false; for (std::map::const_iterator eit = cit->second.begin(); eit != cit->second.end(); ++eit) { // Don't serialize local entities if (ENTITY_IS_LOCAL(eit->first)) continue; + if (!hasEmittedComponent) + { + serializer.NumberI32_Unbounded("component type id", cit->first); + hasEmittedComponent = true; + } serializer.NumberU32_Unbounded("entity id", eit->first); eit->second->Serialize(serializer);