diff options
author | rubidium42 <rubidium@openttd.org> | 2021-06-12 09:10:17 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-06-13 12:45:45 +0200 |
commit | 55a11710a6c0f7942f3947711f2050c34782c39d (patch) | |
tree | 491b3009324e623236977614e91371a0ea4abac7 /src/saveload | |
parent | a99ac62c1ab816ee48cac85fdf834f9fdc599cb1 (diff) | |
download | openttd-55a11710a6c0f7942f3947711f2050c34782c39d.tar.xz |
Codechange: convert printf DEBUG statements to fmt Debug statements
Diffstat (limited to 'src/saveload')
-rw-r--r-- | src/saveload/afterload.cpp | 6 | ||||
-rw-r--r-- | src/saveload/ai_sl.cpp | 12 | ||||
-rw-r--r-- | src/saveload/game_sl.cpp | 12 | ||||
-rw-r--r-- | src/saveload/oldloader.cpp | 8 | ||||
-rw-r--r-- | src/saveload/oldloader_sl.cpp | 40 | ||||
-rw-r--r-- | src/saveload/saveload.cpp | 30 | ||||
-rw-r--r-- | src/saveload/waypoint_sl.cpp | 4 |
7 files changed, 56 insertions, 56 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index ff2159996..40f11f507 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -568,8 +568,8 @@ bool AfterLoadGame() if (IsSavegameVersionBefore(SLV_119)) { _pause_mode = (_pause_mode == 2) ? PM_PAUSED_NORMAL : PM_UNPAUSED; } else if (_network_dedicated && (_pause_mode & PM_PAUSED_ERROR) != 0) { - DEBUG(net, 0, "The loading savegame was paused due to an error state"); - DEBUG(net, 0, " This savegame cannot be used for multiplayer"); + Debug(net, 0, "The loading savegame was paused due to an error state"); + Debug(net, 0, " This savegame cannot be used for multiplayer"); /* Restore the signals */ ResetSignalHandlers(); return false; @@ -2308,7 +2308,7 @@ bool AfterLoadGame() /* At some point, invalid depots were saved into the game (possibly those removed in the past?) * Remove them here, so they don't cause issues further down the line */ if (!IsDepotTile(d->xy)) { - DEBUG(sl, 0, "Removing invalid depot %d at %d, %d", d->index, TileX(d->xy), TileY(d->xy)); + Debug(sl, 0, "Removing invalid depot {} at {}, {}", d->index, TileX(d->xy), TileY(d->xy)); delete d; d = nullptr; continue; diff --git a/src/saveload/ai_sl.cpp b/src/saveload/ai_sl.cpp index 7eb2a5ce1..c821dfe59 100644 --- a/src/saveload/ai_sl.cpp +++ b/src/saveload/ai_sl.cpp @@ -86,15 +86,15 @@ static void Load_AIPL() config->Change(_ai_saveload_name.c_str(), -1, false, _ai_saveload_is_random); if (!config->HasScript()) { if (_ai_saveload_name.compare("%_dummy") != 0) { - DEBUG(script, 0, "The savegame has an AI by the name '%s', version %d which is no longer available.", _ai_saveload_name.c_str(), _ai_saveload_version); - DEBUG(script, 0, "A random other AI will be loaded in its place."); + Debug(script, 0, "The savegame has an AI by the name '{}', version {} which is no longer available.", _ai_saveload_name, _ai_saveload_version); + Debug(script, 0, "A random other AI will be loaded in its place."); } else { - DEBUG(script, 0, "The savegame had no AIs available at the time of saving."); - DEBUG(script, 0, "A random available AI will be loaded now."); + Debug(script, 0, "The savegame had no AIs available at the time of saving."); + Debug(script, 0, "A random available AI will be loaded now."); } } else { - DEBUG(script, 0, "The savegame has an AI by the name '%s', version %d which is no longer available.", _ai_saveload_name.c_str(), _ai_saveload_version); - DEBUG(script, 0, "The latest version of that AI has been loaded instead, but it'll not get the savegame data as it's incompatible."); + Debug(script, 0, "The savegame has an AI by the name '{}', version {} which is no longer available.", _ai_saveload_name, _ai_saveload_version); + Debug(script, 0, "The latest version of that AI has been loaded instead, but it'll not get the savegame data as it's incompatible."); } /* Make sure the AI doesn't get the saveload data, as it was not the * writer of the saveload data in the first place */ diff --git a/src/saveload/game_sl.cpp b/src/saveload/game_sl.cpp index 4034df3c9..a1093eaf4 100644 --- a/src/saveload/game_sl.cpp +++ b/src/saveload/game_sl.cpp @@ -77,15 +77,15 @@ static void Load_GSDT() config->Change(_game_saveload_name.c_str(), -1, false, _game_saveload_is_random); if (!config->HasScript()) { if (_game_saveload_name.compare("%_dummy") != 0) { - DEBUG(script, 0, "The savegame has an GameScript by the name '%s', version %d which is no longer available.", _game_saveload_name.c_str(), _game_saveload_version); - DEBUG(script, 0, "This game will continue to run without GameScript."); + Debug(script, 0, "The savegame has an GameScript by the name '{}', version {} which is no longer available.", _game_saveload_name, _game_saveload_version); + Debug(script, 0, "This game will continue to run without GameScript."); } else { - DEBUG(script, 0, "The savegame had no GameScript available at the time of saving."); - DEBUG(script, 0, "This game will continue to run without GameScript."); + Debug(script, 0, "The savegame had no GameScript available at the time of saving."); + Debug(script, 0, "This game will continue to run without GameScript."); } } else { - DEBUG(script, 0, "The savegame has an GameScript by the name '%s', version %d which is no longer available.", _game_saveload_name.c_str(), _game_saveload_version); - DEBUG(script, 0, "The latest version of that GameScript has been loaded instead, but it'll not get the savegame data as it's incompatible."); + Debug(script, 0, "The savegame has an GameScript by the name '{}', version {} which is no longer available.", _game_saveload_name, _game_saveload_version); + Debug(script, 0, "The latest version of that GameScript has been loaded instead, but it'll not get the savegame data as it's incompatible."); } /* Make sure the GameScript doesn't get the saveload data, as it was not the * writer of the saveload data in the first place */ diff --git a/src/saveload/oldloader.cpp b/src/saveload/oldloader.cpp index 74a1466da..a6f2d55ce 100644 --- a/src/saveload/oldloader.cpp +++ b/src/saveload/oldloader.cpp @@ -56,7 +56,7 @@ static byte ReadByteFromFile(LoadgameState *ls) /* We tried to read, but there is nothing in the file anymore.. */ if (count == 0) { - DEBUG(oldloader, 0, "Read past end of file, loading failed"); + Debug(oldloader, 0, "Read past end of file, loading failed"); throw std::exception(); } @@ -132,7 +132,7 @@ bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks) break; case OC_ASSERT: - DEBUG(oldloader, 4, "Assert point: 0x%X / 0x%X", ls->total_read, (uint)(size_t)chunk->ptr + _bump_assert_value); + Debug(oldloader, 4, "Assert point: 0x{:X} / 0x{:X}", ls->total_read, (uint)(size_t)chunk->ptr + _bump_assert_value); if (ls->total_read != (size_t)chunk->ptr + _bump_assert_value) throw std::exception(); default: break; } @@ -273,7 +273,7 @@ bool LoadOldSaveGame(const std::string &file) { LoadgameState ls; - DEBUG(oldloader, 3, "Trying to load a TTD(Patch) savegame"); + Debug(oldloader, 3, "Trying to load a TTD(Patch) savegame"); InitLoading(&ls); @@ -281,7 +281,7 @@ bool LoadOldSaveGame(const std::string &file) ls.file = FioFOpenFile(file, "rb", NO_DIRECTORY); if (ls.file == nullptr) { - DEBUG(oldloader, 0, "Cannot open file '%s'", file.c_str()); + Debug(oldloader, 0, "Cannot open file '{}'", file); return false; } diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp index d9926aa60..8b33c02db 100644 --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -132,7 +132,7 @@ static uint32 RemapOldTownName(uint32 townnameparts, byte old_town_name_type) return FIXNUM(townnameparts - 86, lengthof(_name_french_real), 0); case 2: // German - DEBUG(misc, 0, "German Townnames are buggy (%d)", townnameparts); + Debug(misc, 0, "German Townnames are buggy ({})", townnameparts); return townnameparts; case 4: // Latin-American @@ -532,9 +532,9 @@ static void ReadTTDPatchFlags() for (uint i = 0; i < 17; i++) _old_map3[i] = 0; for (uint i = 0x1FE00; i < 0x20000; i++) _old_map3[i] = 0; - if (_savegame_type == SGT_TTDP2) DEBUG(oldloader, 2, "Found TTDPatch game"); + if (_savegame_type == SGT_TTDP2) Debug(oldloader, 2, "Found TTDPatch game"); - DEBUG(oldloader, 3, "Vehicle-multiplier is set to %d (%d vehicles)", _old_vehicle_multiplier, _old_vehicle_multiplier * 850); + Debug(oldloader, 3, "Vehicle-multiplier is set to {} ({} vehicles)", _old_vehicle_multiplier, _old_vehicle_multiplier * 850); } static const OldChunks town_chunk[] = { @@ -1114,7 +1114,7 @@ static bool LoadOldVehicleUnion(LoadgameState *ls, int num) /* This chunk size should always be 10 bytes */ if (ls->total_read - temp != 10) { - DEBUG(oldloader, 0, "Assert failed in VehicleUnion: invalid chunk size"); + Debug(oldloader, 0, "Assert failed in VehicleUnion: invalid chunk size"); return false; } @@ -1327,7 +1327,7 @@ bool LoadOldVehicle(LoadgameState *ls, int num) /* This should be consistent, else we have a big problem... */ if (v->index != _current_vehicle_id) { - DEBUG(oldloader, 0, "Loading failed - vehicle-array is invalid"); + Debug(oldloader, 0, "Loading failed - vehicle-array is invalid"); return false; } } @@ -1512,7 +1512,7 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int num) { ReadTTDPatchFlags(); - DEBUG(oldloader, 2, "Found %d extra chunk(s)", _old_extra_chunk_nums); + Debug(oldloader, 2, "Found {} extra chunk(s)", _old_extra_chunk_nums); for (int i = 0; i != _old_extra_chunk_nums; i++) { uint16 id = ReadUint16(ls); @@ -1535,7 +1535,7 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int num) c->ident.grfid = grfid; AppendToGRFConfigList(&_grfconfig, c); - DEBUG(oldloader, 3, "TTDPatch game using GRF file with GRFID %0X", BSWAP32(c->ident.grfid)); + Debug(oldloader, 3, "TTDPatch game using GRF file with GRFID {:08X}", BSWAP32(c->ident.grfid)); } len -= 5; } @@ -1548,14 +1548,14 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int num) /* TTDPatch version and configuration */ case 0x3: _ttdp_version = ReadUint32(ls); - DEBUG(oldloader, 3, "Game saved with TTDPatch version %d.%d.%d r%d", + Debug(oldloader, 3, "Game saved with TTDPatch version {}.{}.{} r{}", GB(_ttdp_version, 24, 8), GB(_ttdp_version, 20, 4), GB(_ttdp_version, 16, 4), GB(_ttdp_version, 0, 16)); len -= 4; while (len-- != 0) ReadByte(ls); // skip the configuration break; default: - DEBUG(oldloader, 4, "Skipping unknown extra chunk %X", id); + Debug(oldloader, 4, "Skipping unknown extra chunk {}", id); while (len-- != 0) ReadByte(ls); break; } @@ -1742,7 +1742,7 @@ static const OldChunks main_chunk[] = { bool LoadTTDMain(LoadgameState *ls) { - DEBUG(oldloader, 3, "Reading main chunk..."); + Debug(oldloader, 3, "Reading main chunk..."); _read_ttdpatch_flags = false; @@ -1752,7 +1752,7 @@ bool LoadTTDMain(LoadgameState *ls) _old_vehicle_names = nullptr; try { if (!LoadChunk(ls, nullptr, main_chunk)) { - DEBUG(oldloader, 0, "Loading failed"); + Debug(oldloader, 0, "Loading failed"); free(_old_vehicle_names); return false; } @@ -1761,7 +1761,7 @@ bool LoadTTDMain(LoadgameState *ls) throw; } - DEBUG(oldloader, 3, "Done, converting game data..."); + Debug(oldloader, 3, "Done, converting game data..."); FixTTDMapArray(); FixTTDDepots(); @@ -1776,8 +1776,8 @@ bool LoadTTDMain(LoadgameState *ls) /* We have a new difficulty setting */ _settings_game.difficulty.town_council_tolerance = Clamp(_old_diff_level, 0, 2); - DEBUG(oldloader, 3, "Finished converting game data"); - DEBUG(oldloader, 1, "TTD(Patch) savegame successfully converted"); + Debug(oldloader, 3, "Finished converting game data"); + Debug(oldloader, 1, "TTD(Patch) savegame successfully converted"); free(_old_vehicle_names); @@ -1786,7 +1786,7 @@ bool LoadTTDMain(LoadgameState *ls) bool LoadTTOMain(LoadgameState *ls) { - DEBUG(oldloader, 3, "Reading main chunk..."); + Debug(oldloader, 3, "Reading main chunk..."); _read_ttdpatch_flags = false; @@ -1797,10 +1797,10 @@ bool LoadTTOMain(LoadgameState *ls) /* Load the biggest chunk */ if (!LoadChunk(ls, nullptr, main_chunk)) { - DEBUG(oldloader, 0, "Loading failed"); + Debug(oldloader, 0, "Loading failed"); return false; } - DEBUG(oldloader, 3, "Done, converting game data..."); + Debug(oldloader, 3, "Done, converting game data..."); if (_settings_game.game_creation.town_name != 0) _settings_game.game_creation.town_name++; @@ -1808,7 +1808,7 @@ bool LoadTTOMain(LoadgameState *ls) _trees_tick_ctr = 0xFF; if (!FixTTOMapArray() || !FixTTOEngines()) { - DEBUG(oldloader, 0, "Conversion failed"); + Debug(oldloader, 0, "Conversion failed"); return false; } @@ -1825,8 +1825,8 @@ bool LoadTTOMain(LoadgameState *ls) * the vehicles stay the same" */ _economy.inflation_payment = std::min(_economy.inflation_payment * 124 / 74, MAX_INFLATION); - DEBUG(oldloader, 3, "Finished converting game data"); - DEBUG(oldloader, 1, "TTO savegame successfully converted"); + Debug(oldloader, 3, "Finished converting game data"); + Debug(oldloader, 1, "TTO savegame successfully converted"); return true; } diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 805934858..f9abac3ba 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -313,7 +313,7 @@ static void SlNullPointers() for (auto &ch : ChunkHandlers()) { if (ch.ptrs_proc != nullptr) { - DEBUG(sl, 3, "Nulling pointers for %c%c%c%c", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id); + Debug(sl, 3, "Nulling pointers for {:c}{:c}{:c}{:c}", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id); ch.ptrs_proc(); } } @@ -656,7 +656,7 @@ int SlIterateArray() case CH_SPARSE_ARRAY: index = (int)SlReadSparseIndex(); break; case CH_ARRAY: index = _sl.array_index++; break; default: - DEBUG(sl, 0, "SlIterateArray error"); + Debug(sl, 0, "SlIterateArray error"); return -1; // error } @@ -949,7 +949,7 @@ static void SlString(void *ptr, size_t length, VarType conv) return; case SLE_VAR_STRB: if (len >= length) { - DEBUG(sl, 1, "String length in savegame is bigger than buffer, truncating"); + Debug(sl, 1, "String length in savegame is bigger than buffer, truncating"); SlCopyBytes(ptr, length); SlSkipBytes(len - length); len = length - 1; @@ -1718,7 +1718,7 @@ static void SlSaveChunk(const ChunkHandler &ch) if (proc == nullptr) return; SlWriteUint32(ch.id); - DEBUG(sl, 2, "Saving chunk %c%c%c%c", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id); + Debug(sl, 2, "Saving chunk {:c}{:c}{:c}{:c}", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id); _sl.block_mode = ch.type; switch (ch.type) { @@ -1771,7 +1771,7 @@ static void SlLoadChunks() const ChunkHandler *ch; for (id = SlReadUint32(); id != 0; id = SlReadUint32()) { - DEBUG(sl, 2, "Loading chunk %c%c%c%c", id >> 24, id >> 16, id >> 8, id); + Debug(sl, 2, "Loading chunk {:c}{:c}{:c}{:c}", id >> 24, id >> 16, id >> 8, id); ch = SlFindChunkHandler(id); if (ch == nullptr) SlErrorCorrupt("Unknown chunk type"); @@ -1786,7 +1786,7 @@ static void SlLoadCheckChunks() const ChunkHandler *ch; for (id = SlReadUint32(); id != 0; id = SlReadUint32()) { - DEBUG(sl, 2, "Loading chunk %c%c%c%c", id >> 24, id >> 16, id >> 8, id); + Debug(sl, 2, "Loading chunk {:c}{:c}{:c}{:c}", id >> 24, id >> 16, id >> 8, id); ch = SlFindChunkHandler(id); if (ch == nullptr) SlErrorCorrupt("Unknown chunk type"); @@ -1801,7 +1801,7 @@ static void SlFixPointers() for (auto &ch : ChunkHandlers()) { if (ch.ptrs_proc != nullptr) { - DEBUG(sl, 3, "Fixing pointers for %c%c%c%c", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id); + Debug(sl, 3, "Fixing pointers for {:c}{:c}{:c}{:c}", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id); ch.ptrs_proc(); } } @@ -1845,7 +1845,7 @@ struct FileReader : LoadFilter { { clearerr(this->file); if (fseek(this->file, this->begin, SEEK_SET)) { - DEBUG(sl, 1, "Could not reset the file reading"); + Debug(sl, 1, "Could not reset the file reading"); } } }; @@ -2470,7 +2470,7 @@ static SaveOrLoadResult SaveFileToDisk(bool threaded) * cancelled due to a client disconnecting. */ if (_sl.error_str != STR_NETWORK_ERROR_LOSTCONNECTION) { /* Skip the "colour" character */ - DEBUG(sl, 0, "%s", GetSaveLoadErrorString() + 3); + Debug(sl, 0, "{}", GetSaveLoadErrorString() + 3); asfp = SaveFileError; } @@ -2516,7 +2516,7 @@ static SaveOrLoadResult DoSave(SaveFilter *writer, bool threaded) SaveFileStart(); if (!threaded || !StartNewThread(&_save_thread, "ottd:savegame", &SaveFileToDisk, true)) { - if (threaded) DEBUG(sl, 1, "Cannot create savegame thread, reverting to single-threaded mode..."); + if (threaded) Debug(sl, 1, "Cannot create savegame thread, reverting to single-threaded mode..."); SaveOrLoadResult result = SaveFileToDisk(false); SaveFileDone(); @@ -2569,7 +2569,7 @@ static SaveOrLoadResult DoLoad(LoadFilter *reader, bool load_check) for (;;) { /* No loader found, treat as version 0 and use LZO format */ if (fmt == endof(_saveload_formats)) { - DEBUG(sl, 0, "Unknown savegame type, trying to load it as the buggy format"); + Debug(sl, 0, "Unknown savegame type, trying to load it as the buggy format"); _sl.lf->Reset(); _sl_version = SL_MIN_VERSION; _sl_minor_version = 0; @@ -2595,7 +2595,7 @@ static SaveOrLoadResult DoLoad(LoadFilter *reader, bool load_check) * Therefore it is loaded, but never saved (or, it saves a 0 in any scenario). */ _sl_minor_version = (TO_BE32(hdr[1]) >> 8) & 0xFF; - DEBUG(sl, 1, "Loading savegame version %d", _sl_version); + Debug(sl, 1, "Loading savegame version {}", _sl_version); /* Is the version higher than the current? */ if (_sl_version > SAVEGAME_VERSION) SlError(STR_GAME_SAVELOAD_ERROR_TOO_NEW_SAVEGAME); @@ -2775,7 +2775,7 @@ SaveOrLoadResult SaveOrLoad(const std::string &filename, SaveLoadOperation fop, } if (fop == SLO_SAVE) { // SAVE game - DEBUG(desync, 1, "save: %08x; %02x; %s", _date, _date_fract, filename.c_str()); + Debug(desync, 1, "save: {:08x}; {:02x}; {}", _date, _date_fract, filename); if (_network_server || !_settings_client.gui.threaded_saves) threaded = false; return DoSave(new FileWriter(fh), threaded); @@ -2783,14 +2783,14 @@ SaveOrLoadResult SaveOrLoad(const std::string &filename, SaveLoadOperation fop, /* LOAD game */ assert(fop == SLO_LOAD || fop == SLO_CHECK); - DEBUG(desync, 1, "load: %s", filename.c_str()); + Debug(desync, 1, "load: {}", filename); return DoLoad(new FileReader(fh), fop == SLO_CHECK); } catch (...) { /* This code may be executed both for old and new save games. */ ClearSaveLoadState(); /* Skip the "colour" character */ - if (fop != SLO_CHECK) DEBUG(sl, 0, "%s", GetSaveLoadErrorString() + 3); + if (fop != SLO_CHECK) Debug(sl, 0, "{}", GetSaveLoadErrorString()); /* A saver/loader exception!! reinitialize all variables to prevent crash! */ return (fop == SLO_LOAD) ? SL_REINIT : SL_ERROR; diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp index 97e2d12c9..c94a90953 100644 --- a/src/saveload/waypoint_sl.cpp +++ b/src/saveload/waypoint_sl.cpp @@ -103,10 +103,10 @@ void MoveWaypointsToBaseStations() /* Sometimes waypoint (sign) locations became disconnected from their actual location in * the map array. If this is the case, try to locate the actual location in the map array */ if (!IsTileType(t, MP_RAILWAY) || GetRailTileType(t) != 2 /* RAIL_TILE_WAYPOINT */ || _m[t].m2 != wp.index) { - DEBUG(sl, 0, "Found waypoint tile %u with invalid position", t); + Debug(sl, 0, "Found waypoint tile {} with invalid position", t); for (t = 0; t < MapSize(); t++) { if (IsTileType(t, MP_RAILWAY) && GetRailTileType(t) == 2 /* RAIL_TILE_WAYPOINT */ && _m[t].m2 == wp.index) { - DEBUG(sl, 0, "Found actual waypoint position at %u", t); + Debug(sl, 0, "Found actual waypoint position at {}", t); break; } } |