diff --git a/src/command.cpp b/src/command.cpp index a052b0b3f3..55edd921fc 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -28,6 +28,7 @@ #include "string_func.h" #include "scope_info.h" #include "core/random_func.hpp" +#include "settings_func.h" #include #include "table/strings.h" @@ -596,8 +597,20 @@ static void DumpSubCommandLog(char *&buffer, const char *last, const CommandLog if (entry.p3 != 0) { buffer += seprintf(buffer, last, "p3: 0x" OTTD_PRINTFHEX64PAD ", ", entry.p3); } - buffer += seprintf(buffer, last, "cc: %3u, lc: %3u, cmd: 0x%08X (%s)\n", + buffer += seprintf(buffer, last, "cc: %3u, lc: %3u, cmd: 0x%08X (%s)", (uint) entry.current_company, (uint) entry.local_company, entry.cmd, GetCommandName(entry.cmd)); + + switch (entry.cmd & CMD_ID_MASK) { + case CMD_CHANGE_SETTING: + buffer += seprintf(buffer, last, " [%s]", GetSettingNameByIndex(entry.p1)); + break; + + case CMD_CHANGE_COMPANY_SETTING: + buffer += seprintf(buffer, last, " [%s]", GetCompanySettingNameByIndex(entry.p1)); + break; + } + + buffer += seprintf(buffer, last, "\n"); } } diff --git a/src/settings.cpp b/src/settings.cpp index ba98fd634f..db8b4c5ee7 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -2363,6 +2363,14 @@ CommandCost CmdChangeSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uin return CommandCost(); } +const char *GetSettingNameByIndex(uint32 idx) +{ + const SettingDesc *sd = GetSettingDescription(idx); + if (sd == nullptr) return nullptr; + + return sd->desc.name; +} + /** * Change one of the per-company settings. * @param tile unused @@ -2400,6 +2408,13 @@ CommandCost CmdChangeCompanySetting(TileIndex tile, DoCommandFlag flags, uint32 return CommandCost(); } +const char *GetCompanySettingNameByIndex(uint32 idx) +{ + if (idx >= lengthof(_company_settings)) return nullptr; + + return _company_settings[idx].desc.name; +} + /** * Top function to save the new value of an element of the Settings struct * @param index offset in the SettingDesc array of the Settings struct which diff --git a/src/settings_func.h b/src/settings_func.h index 987bcb6942..d547dc2de2 100644 --- a/src/settings_func.h +++ b/src/settings_func.h @@ -39,4 +39,7 @@ void SyncCompanySettings(); void SetupTimeSettings(); +const char *GetSettingNameByIndex(uint32 idx); +const char *GetCompanySettingNameByIndex(uint32 idx); + #endif /* SETTINGS_FUNC_H */