void SavedFile::WritePlayerData(BinaryFile& file) { // Spielerdaten for(std::vector<Player>::const_iterator it = players.begin(); it != players.end(); ++it) { file.WriteUnsignedInt(it->ps); if(it->ps != PS_LOCKED) { file.WriteShortString(it->name); file.WriteUnsignedChar(it->nation); file.WriteUnsignedInt(it->color); file.WriteUnsignedChar(it->team); } } }
/** * schreibt die GlobalGameSettings in die Datei. * * @author OLiver */ void SavedFile::WriteGGS(BinaryFile& file) { Serializer ser; ggs.Serialize(&ser); file.WriteUnsignedInt(ser.GetLength()); file.WriteRawData(ser.GetData(), ser.GetLength()); }
/** * * @author OLiver */ bool Savegame::Save(BinaryFile& file) { // Versionszeug schreiben WriteVersion(file, 8, SAVE_SIGNATURE, SAVE_VERSION); // Timestamp der Aufzeichnung unser_time_t tmpTime = libendian::ConvertEndianess<false>::fromNative(save_time); file.WriteRawData(&tmpTime, 8); // Mapname file.WriteShortString(map_name); // Anzahl Spieler file.WriteUnsignedChar(GetPlayerCount()); // Größe der Spielerdaten (später ausfüllen) unsigned players_size = 0; unsigned players_pos = file.Tell(); file.WriteUnsignedInt(players_size); // Spielerdaten WritePlayerData(file); // Wieder zurückspringen und Größe des Spielerblocks eintragen unsigned new_pos = file.Tell(); file.Seek(players_pos, SEEK_SET); file.WriteUnsignedInt(new_pos - players_pos - 4); file.Seek(new_pos, SEEK_SET); // GGS WriteGGS(file); // Start-GF file.WriteUnsignedInt(start_gf); // Serialisiertes Spielzeug reinschreiben sgd.WriteToFile(file); return true; }
/** * * @author OLiver */ void SavedFile::WritePlayerData(BinaryFile& file) { // Spielerdaten for(unsigned char i = 0; i < player_count; ++i) { file.WriteUnsignedInt(players[i].ps); if(players[i].ps != PS_LOCKED) { file.WriteShortString(players[i].name); file.WriteUnsignedChar(players[i].nation); file.WriteUnsignedChar(players[i].color); file.WriteUnsignedChar(players[i].team); } } }
bool Savegame::Save(BinaryFile& file) { // Versionszeug schreiben WriteFileHeader(file); // Timestamp der Aufzeichnung unser_time_t tmpTime = libendian::ConvertEndianess<false>::fromNative(save_time); file.WriteRawData(&tmpTime, sizeof(tmpTime)); // Mapname file.WriteShortString(mapName); WritePlayerData(file); WriteGGS(file); // Start-GF file.WriteUnsignedInt(start_gf); // Serialisiertes Spielzeug reinschreiben sgd.WriteToFile(file); return true; }