Esempio n. 1
0
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();
}
Esempio n. 2
0
void SerializedGameData::MakeSnapshot(GameWorld& gw)
{
    Prepare(false);

    // Anzahl Objekte reinschreiben
    expectedObjectsCount = GameObject::GetObjCount();
    PushUnsignedInt(expectedObjectsCount);

    // Objektmanager serialisieren
    gw.Serialize(*this);
    // EventManager serialisieren
    gw.GetEvMgr().Serialize(*this);
    // Spieler serialisieren
    for(unsigned i = 0; i < gw.GetPlayerCount(); ++i)
        gw.GetPlayer(i).Serialize(*this);

    // If this check fails, we missed some objects or some objects were destroyed without decreasing the obj count
    RTTR_Assert(writtenObjIds.size() == objectsCount);
    RTTR_Assert(expectedObjectsCount == objectsCount + 1); // "Nothing" nodeObj does not get serialized

    writtenObjIds.clear();
}