Skip to content

Commit

Permalink
Use format_target for crashlog and related areas
Browse files Browse the repository at this point in the history
Scope info format, version info, gamelog, setting value format, etc
  • Loading branch information
JGRennison committed Sep 29, 2024
1 parent 7e748a3 commit be02805
Show file tree
Hide file tree
Showing 35 changed files with 803 additions and 901 deletions.
2 changes: 1 addition & 1 deletion src/ai/ai_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
for (const Company *c : Company::Iterate()) {
if (c->is_ai) {
SCOPE_INFO_FMT([&], "AI::GameLoop: %i: %s (v%d)\n", (int)c->index, c->ai_info->GetName().c_str(), c->ai_info->GetVersion());
SCOPE_INFO_FMT([&], "AI::GameLoop: {}: {} (v{})\n", (int)c->index, c->ai_info->GetName(), c->ai_info->GetVersion());
PerformanceMeasurer framerate((PerformanceElement)(PFE_AI0 + c->index));
cur_company.Change(c->index);
c->ai_instance->GameLoop();
Expand Down
2 changes: 1 addition & 1 deletion src/cachecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log, CheckC
if (desync_level == 1 && _state_ticks.base() % 500 != 0) return;
}

SCOPE_INFO_FMT([flags], "CheckCaches: %X", flags);
SCOPE_INFO_FMT([flags], "CheckCaches: {:X}", flags);

std::vector<std::string> saved_messages;
std::function<void(const char *)> log_orig;
Expand Down
4 changes: 2 additions & 2 deletions src/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ struct cmd_text_info_dumper {
*/
CommandCost DoCommandEx(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, DoCommandFlag flags, uint32_t cmd, const char *text, const CommandAuxiliaryBase *aux_data)
{
SCOPE_INFO_FMT([=], "DoCommand: tile: %X (%d x %d), p1: 0x%X, p2: 0x%X, p3: " OTTD_PRINTFHEX64 ", flags: 0x%X, company: %s, cmd: 0x%X (%s)%s",
SCOPE_INFO_FMT([=], "DoCommand: tile: {:X} ({} x {}), p1: 0x{:X}, p2: 0x{:X}, p3: 0x{:X}, flags: 0x{:X}, company: {}, cmd: 0x{:X} ({}){}",
tile, TileX(tile), TileY(tile), p1, p2, p3, flags, scope_dumper().CompanyInfo(_current_company), cmd, GetCommandName(cmd), cmd_text_info_dumper().CommandTextInfo(text, aux_data));

CommandCost res;
Expand Down Expand Up @@ -971,7 +971,7 @@ static void AppendCommandLogEntry(const CommandCost &res, TileIndex tile, uint32
*/
bool DoCommandPEx(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd, CommandCallback *callback, const char *text, const CommandAuxiliaryBase *aux_data, bool my_cmd)
{
SCOPE_INFO_FMT([=], "DoCommandP: tile: %X (%d x %d), p1: 0x%X, p2: 0x%X, p3: 0x" OTTD_PRINTFHEX64 ", company: %s, cmd: 0x%X (%s), my_cmd: %d%s",
SCOPE_INFO_FMT([=], "DoCommandP: tile: {:X} ({} x {}), p1: 0x{:X}, p2: 0x{:X}, p3: 0x{:X}, company: {}, cmd: 0x{:X} ({}), my_cmd: {}{}",
tile, TileX(tile), TileY(tile), p1, p2, p3, scope_dumper().CompanyInfo(_current_company), cmd, GetCommandName(cmd), my_cmd, cmd_text_info_dumper().CommandTextInfo(text, aux_data));

/* Cost estimation is generally only done when the
Expand Down
4 changes: 2 additions & 2 deletions src/console_cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3495,8 +3495,8 @@ DEF_CONSOLE_CMD(ConDumpVersion)
return true;
}

char buffer[65536];
CrashLog::VersionInfoLog(buffer, lastof(buffer));
format_buffer buffer;
CrashLog::VersionInfoLog(buffer);
PrintLineByLine(buffer);
return true;
}
Expand Down
Loading

0 comments on commit be02805

Please sign in to comment.