예제 #1
0
void SerializedGameData::PushObject_(const GameObject* go, const bool known)
{
    RTTR_Assert(!isReading);

    // Gibts das Objekt gar nich?
    if (!go)
    {
        // Null draufschreiben
        PushUnsignedInt(0);
        return;
    }

    const unsigned objId = go->GetObjId();

    RTTR_Assert(objId < GameObject::GetObjIDCounter());
    if(objId >= GameObject::GetObjIDCounter())
    {
        LOG.write("%s\n") % _("An error occured while saving which was suppressed!");
        PushUnsignedInt(0);
        return;
    }

    PushUnsignedInt(objId);

    // If the object was already serialized skip the data
    if(IsObjectSerialized(objId))
    {
        if (debugMode)
            LOG.writeToFile("Saved known objId %u\n") % objId;
        return;
    }

    if (debugMode)
        LOG.writeToFile("Saving objId %u, obj#=%u\n") % objId % objectsCount;

    // Objekt merken
    writtenObjIds.insert(objId);

    objectsCount++;
    RTTR_Assert(objectsCount < GameObject::GetObjCount());

    // Objekt nich bekannt? Dann Type-ID noch mit drauf
    if(!known)
        PushUnsignedShort(go->GetGOT());

    // Objekt serialisieren
    if (debugMode)
        LOG.writeToFile("Start serializing %u\n") % objId;
    go->Serialize(*this);

    // Sicherheitscode reinschreiben
    PushUnsignedShort(GetSafetyCode(*go));
}
예제 #2
0
void SerializedGameData::PushObject(const GameObject* go, const bool known)
{
    assert(!isReading);
    if(go)
    {
        //assert(go->GetObjId() < GameObject::GetObjIDCounter());
        if(go->GetObjId() >= GameObject::GetObjIDCounter())
        {
            LOG.lprintf("%s\n", _("An error occured while saving which was suppressed!"));
            go = NULL;
        }
    }

    // Gibts das Objekt gar nich?
    if(!go)
    {
        // Null draufschreiben
        PushUnsignedInt(0);
        return;
    }

    PushUnsignedInt(go->GetObjId());

    // If the object was already serialized skip the data
    if(IsObjectSerialized(go->GetObjId()))
        return;

    // Objekt nich bekannt? Dann Type-ID noch mit drauf
    if(!known)
        PushUnsignedShort(go->GetGOT());

    // Objekt merken
    writtenObjIds.insert(go->GetObjId());

    objectsCount++;
    assert(objectsCount <= GameObject::GetObjCount());

    // Objekt serialisieren
    go->Serialize(*this);

    // Sicherheitscode reinschreiben
    PushUnsignedShort(0xFFFF);
}