mirror of https://github.com/OpenTTD/OpenTTD
(svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
parent
614dd12f21
commit
39f92d1f21
|
@ -1416,6 +1416,19 @@ DEF_CONSOLE_CMD(ConPatch)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEF_CONSOLE_CMD(ConListPatches)
|
||||||
|
{
|
||||||
|
if (argc == 0) {
|
||||||
|
IConsoleHelp("List patch options. Usage: 'list_patches'");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc != 1) return false;
|
||||||
|
|
||||||
|
IConsoleListPatches();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
DEF_CONSOLE_CMD(ConListDumpVariables)
|
DEF_CONSOLE_CMD(ConListDumpVariables)
|
||||||
{
|
{
|
||||||
const IConsoleVar *var;
|
const IConsoleVar *var;
|
||||||
|
@ -1497,6 +1510,7 @@ void IConsoleStdLibRegister()
|
||||||
IConsoleCmdRegister("pwd", ConPrintWorkingDirectory);
|
IConsoleCmdRegister("pwd", ConPrintWorkingDirectory);
|
||||||
IConsoleCmdRegister("clear", ConClearBuffer);
|
IConsoleCmdRegister("clear", ConClearBuffer);
|
||||||
IConsoleCmdRegister("patch", ConPatch);
|
IConsoleCmdRegister("patch", ConPatch);
|
||||||
|
IConsoleCmdRegister("list_patches", ConListPatches);
|
||||||
|
|
||||||
IConsoleAliasRegister("dir", "ls");
|
IConsoleAliasRegister("dir", "ls");
|
||||||
IConsoleAliasRegister("del", "rm %+");
|
IConsoleAliasRegister("del", "rm %+");
|
||||||
|
|
|
@ -1829,6 +1829,25 @@ void IConsoleGetPatchSetting(const char *name)
|
||||||
name, value, (sd->desc.flags & SGF_0ISDISABLED) ? "(0) " : "", sd->desc.min, sd->desc.max);
|
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
|
/** Save and load handler for patches/settings
|
||||||
* @param osd SettingDesc struct containing all information
|
* @param osd SettingDesc struct containing all information
|
||||||
* @param object can be either NULL in which case we load global variables or
|
* @param object can be either NULL in which case we load global variables or
|
||||||
|
|
|
@ -86,6 +86,7 @@ extern Patches _patches_newgame;
|
||||||
|
|
||||||
bool IConsoleSetPatchSetting(const char *name, int32 value);
|
bool IConsoleSetPatchSetting(const char *name, int32 value);
|
||||||
void IConsoleGetPatchSetting(const char *name);
|
void IConsoleGetPatchSetting(const char *name);
|
||||||
|
void IConsoleListPatches();
|
||||||
const SettingDesc *GetPatchFromName(const char *name, uint *i);
|
const SettingDesc *GetPatchFromName(const char *name, uint *i);
|
||||||
bool SetPatchValue(uint index, const Patches *object, int32 value);
|
bool SetPatchValue(uint index, const Patches *object, int32 value);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue