コード例 #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();
        }
    }
}
コード例 #2
0
ファイル: GameSavedFile.cpp プロジェクト: lweberk/s25client
/**
 *
 *  @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();
        }
    }
}
コード例 #3
0
ファイル: GameSavegame.cpp プロジェクト: jhkl/s25client
/**
 *
 *  @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;
}
コード例 #4
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;
}