Make sure that OnStateLoaded is called for all objects

fixes #7482
This commit is contained in:
Gunnar Beutner 2014-10-29 11:14:04 +01:00
parent f72f7d87c7
commit 8251a60044
2 changed files with 17 additions and 1 deletions

View File

@ -315,6 +315,7 @@ void DynamicObject::RestoreObject(const String& message, int attributeTypes)
Dictionary::Ptr update = persistentObject->Get("update");
Deserialize(object, update, false, attributeTypes);
object->OnStateLoaded();
object->SetStateLoaded(true);
}
void DynamicObject::RestoreObjects(const String& filename, int attributeTypes)
@ -341,8 +342,21 @@ void DynamicObject::RestoreObjects(const String& filename, int attributeTypes)
upq.Join();
unsigned long no_state = 0;
BOOST_FOREACH(const DynamicType::Ptr& type, DynamicType::GetTypes()) {
BOOST_FOREACH(const DynamicObject::Ptr& object, type->GetObjects()) {
if (!object->GetStateLoaded()) {
object->OnStateLoaded();
object->SetStateLoaded(true);
no_state++;
}
}
}
Log(LogInformation, "DynamicObject")
<< "Restored " << restored << " objects";
<< "Restored " << restored << " objects. Loaded " << no_state << " new objects without state.";
}
void DynamicObject::StopObjects(void)

View File

@ -62,6 +62,8 @@ abstract class DynamicObject
[protected] Dictionary::Ptr extensions;
[state] Value override_vars;
[protected] bool state_loaded;
};
}