Exemplo n.º 1
0
void SavedFile::ReadPlayerData(BinaryFile& file)
{
    for(std::vector<Player>::iterator it = players.begin(); it != players.end(); ++it)
    {
        it->ps = file.ReadUnsignedInt();

        if(it->ps != PS_LOCKED)
        {
            it->name = file.ReadShortString();
            it->nation = Nation(file.ReadUnsignedChar());
            it->color = file.ReadUnsignedInt();
            it->team = file.ReadUnsignedChar();
        }
    }
}
Exemplo n.º 2
0
/**
 *
 *  @author OLiver
 */
bool Savegame::Load(BinaryFile& file, const bool load_players, const bool load_sgd)
{
    // Signatur und Version einlesen
    if(!ValidateFile(file, 8, SAVE_SIGNATURE, SAVE_VERSION))
    {
        LOG.lprintf("Savegame::Load: ERROR: File is not a valid RTTR savegame!\n");
        return false;
    }

    // Zeitstempel
    file.ReadRawData(&save_time, 8);

    // Map-Name
    file.ReadShortString(map_name);

    // Anzahl Spieler
    player_count = file.ReadUnsignedChar();

    // Spielerzeug
    if(load_players)
    {
        // Größe des Spielerblocks überspringen
        file.Seek(4, SEEK_CUR);

        ReadPlayerData(file);
    }
    else
    {
        // Überspringen
        players = 0;
        unsigned player_size = file.ReadUnsignedInt();
        file.Seek(player_size, SEEK_CUR);
    }

    // GGS
    ReadGGS(file);

    // Start-GF
    start_gf = file.ReadUnsignedInt();

    if(load_sgd)
    {
        // Serialisiertes Spielzeug lesen
        sgd.ReadFromFile(file);
    }

    return true;
}
Exemplo n.º 3
0
/**
 *
 *  @author OLiver
 */
bool Savegame::Load(BinaryFile& file, const bool load_players, const bool load_sgd)
{
    // Signatur und Version einlesen
    if(!ValidateFile(file, sizeof(SAVE_SIGNATURE), SAVE_SIGNATURE, SAVE_VERSION))
        return false;

    // Zeitstempel
    file.ReadRawData(&save_time, 8);
    save_time = libendian::ConvertEndianess<false>::toNative(save_time);

    // Map-Name
    map_name = file.ReadShortString();

    // Anzahl Spieler
    SetPlayerCount(file.ReadUnsignedChar());

    // Spielerzeug
    if(load_players)
    {
        // Größe des Spielerblocks überspringen
        file.Seek(4, SEEK_CUR);

        ReadPlayerData(file);
    }
    else
    {
        // Überspringen
        unsigned player_size = file.ReadUnsignedInt();
        file.Seek(player_size, SEEK_CUR);
    }

    // GGS
    ReadGGS(file);

    // Start-GF
    start_gf = file.ReadUnsignedInt();

    if(load_sgd)
    {
        // Serialisiertes Spielzeug lesen
        sgd.ReadFromFile(file);
    }

    return true;
}
Exemplo n.º 4
0
/**
 *  liest die GlobalGameSettings aus der Datei.
 *
 *  @author OLiver
 */
void SavedFile::ReadGGS(BinaryFile& file)
{
    unsigned length = file.ReadUnsignedInt();
    boost::interprocess::unique_ptr<unsigned char, Deleter<unsigned char[]> > buffer(new unsigned char[length]);

    file.ReadRawData(buffer.get(), length);
    Serializer ser(buffer.get(), length);

    ggs.Deserialize(ser);
}
Exemplo n.º 5
0
/**
 *  liest die GlobalGameSettings aus der Datei.
 *
 *  @author OLiver
 */
void SavedFile::ReadGGS(BinaryFile& file)
{
    unsigned length = file.ReadUnsignedInt();
    unsigned char* buffer = new unsigned char[length];

    file.ReadRawData(buffer, length);
    Serializer ser(buffer, length);

    ggs.Deserialize(&ser);

    delete[] buffer;
}
Exemplo n.º 6
0
/**
 *
 *  @author OLiver
 */
void SavedFile::ReadPlayerData(BinaryFile& file)
{
    // ggf. wieder löschen
    delete[] players;

    players = new SavedFile::Player[player_count];
    for(unsigned char i = 0; i < player_count; ++i)
    {
        players[i].ps = file.ReadUnsignedInt();

        if(players[i].ps != PS_LOCKED)
        {
            file.ReadShortString(players[i].name);
            players[i].nation = Nation(file.ReadUnsignedChar());
            players[i].color = file.ReadUnsignedChar();
            players[i].team = file.ReadUnsignedChar();
        }
    }
}
Exemplo n.º 7
0
bool Savegame::Load(BinaryFile& file, const bool load_players, const bool load_sgd)
{
    // Signatur und Version einlesen
    if(!ReadFileHeader(file))
        return false;

    // Zeitstempel
    file.ReadRawData(&save_time, sizeof(save_time));
    save_time = libendian::ConvertEndianess<false>::toNative(save_time);

    // Map-Name
    mapName = file.ReadShortString();

    ReadPlayerData(file);
    ReadGGS(file);

    // Start-GF
    start_gf = file.ReadUnsignedInt();

    if(load_sgd)
        sgd.ReadFromFile(file); // Serialisiertes Spielzeug lesen

    return true;
}