void SerializedGameData::ReadFromFile(BinaryFile& file) { Serializer::ReadFromFile(file); total_objects_count = PopUnsignedInt(); objects_count = 0; objects_read = new GameObject*[total_objects_count]; GameObject::SetObjCount(total_objects_count); }
void SerializedGameData::ReadSnapshot(GameWorld& gw, EventManager& evMgr) { Prepare(true); em = &evMgr; expectedObjectsReadCount = PopUnsignedInt(); GameObject::SetObjCount(expectedObjectsReadCount); gw.Deserialize(*this); evMgr.Deserialize(*this); for (unsigned i = 0; i < GAMECLIENT.GetPlayerCount(); ++i) GAMECLIENT.GetPlayer(i).Deserialize(*this); em = NULL; readObjects.clear(); }
void SerializedGameData::ReadSnapshot(GameWorld& gw) { Prepare(true); em = &gw.GetEvMgr(); expectedObjectsCount = PopUnsignedInt(); GameObject::SetObjCount(0); gw.Deserialize(*this); em->Deserialize(*this); for (unsigned i = 0; i < gw.GetPlayerCount(); ++i) gw.GetPlayer(i).Deserialize(*this); // If this check fails, we did not serialize all objects or there was an async RTTR_Assert(expectedObjectsCount == GameObject::GetObjCount()); RTTR_Assert(expectedObjectsCount == objectsCount + 1); // "Nothing" nodeObj does not get serialized em = NULL; readObjects.clear(); }
GameObject* SerializedGameData::PopObject_(GO_Type got) { // Obj-ID holen unsigned obj_id = PopUnsignedInt(); // Obj-ID = 0 ? Dann Null-Pointer zurueckgeben if(!obj_id) return 0; GameObject* go; // Schon vorhanden? if( (go = GetGameObject(obj_id))) // dann das nehmen return go; // Objekt nich bekannt? Dann in den heiligen Schriften lesen if(got == GOT_UNKNOWN) got = GO_Type(PopUnsignedShort()); // und erzeugen go = Create_GameObject(got, obj_id); // Sicherheitscode auslesen unsigned short safety_code = PopUnsignedShort(); if(safety_code != 0xFFFF) { LOG.lprintf("SerializedGameData::PopObject_: ERROR: After loading Object(obj_id = %u, got = %u); Code is wrong!\n", obj_id, got); assert(false); return 0; } return go; }