diff options
author | peter1138 <peter1138@openttd.org> | 2007-04-05 12:59:57 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2007-04-05 12:59:57 +0000 |
commit | 39f92d1f21386dd2f87e26785bbdb348c9775eef (patch) | |
tree | da4e2e636b2508358d93c4b1b736dc5221eabe25 /src/settings.cpp | |
parent | 614dd12f21adbd656dfacc12b3fcf94bbabf045e (diff) | |
download | openttd-39f92d1f21386dd2f87e26785bbdb348c9775eef.tar.xz |
(svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
Diffstat (limited to 'src/settings.cpp')
-rw-r--r-- | src/settings.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/settings.cpp b/src/settings.cpp index c9b1cdef9..2a758ab22 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1829,6 +1829,25 @@ void IConsoleGetPatchSetting(const char *name) name, value, (sd->desc.flags & SGF_0ISDISABLED) ? "(0) " : "", sd->desc.min, sd->desc.max); } +void IConsoleListPatches() +{ + IConsolePrintF(_icolour_warn, "All patches with their current value:"); + + for (const SettingDesc *sd = _patch_settings; sd->save.cmd != SL_END; sd++) { + char value[80]; + const void *ptr = GetVariableAddress((_game_mode == GM_MENU) ? &_patches_newgame : &_patches, &sd->save); + + if (sd->desc.cmd == SDT_BOOLX) { + snprintf(value, lengthof(value), (*(bool*)ptr == 1) ? "on" : "off"); + } else { + snprintf(value, lengthof(value), "%d", (uint32)ReadValue(ptr, sd->save.conv)); + } + IConsolePrintF(_icolour_def, "%s = %s", sd->desc.name, value); + } + + IConsolePrintF(_icolour_warn, "Use 'patch' command to change a value"); +} + /** Save and load handler for patches/settings * @param osd SettingDesc struct containing all information * @param object can be either NULL in which case we load global variables or |