summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2008-08-11 17:15:31 +0000
committerglx <glx@openttd.org>2008-08-11 17:15:31 +0000
commit9fa2cbd93e90f6e9ba4e37280f7fda16b188e130 (patch)
tree249233fcb38e652246c309bad228d181cdaa28cd
parent2a935c9025bdc48c4caccba7011182cba54b7de4 (diff)
downloadopenttd-9fa2cbd93e90f6e9ba4e37280f7fda16b188e130.tar.xz
(svn r14041) -Feature(tte): make it possible to filter list_patches output like it's done for other list_* console commands
-rw-r--r--src/console_cmds.cpp6
-rw-r--r--src/settings.cpp5
-rw-r--r--src/settings_func.h2
3 files changed, 8 insertions, 5 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index c73c76468..2286f865f 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -1267,13 +1267,13 @@ DEF_CONSOLE_CMD(ConPatch)
DEF_CONSOLE_CMD(ConListPatches)
{
if (argc == 0) {
- IConsoleHelp("List patch options. Usage: 'list_patches'");
+ IConsoleHelp("List patch options. Usage: 'list_patches [<pre-filter>]'");
return true;
}
- if (argc != 1) return false;
+ if (argc > 2) return false;
- IConsoleListPatches();
+ IConsoleListPatches((argc == 2) ? argv[1] : NULL);
return true;
}
diff --git a/src/settings.cpp b/src/settings.cpp
index c648843bf..8f82d7eae 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -2385,11 +2385,14 @@ void IConsoleGetPatchSetting(const char *name)
}
}
-void IConsoleListPatches()
+void IConsoleListPatches(const char *prefilter)
{
IConsolePrintF(CC_WARNING, "All patches with their current value:");
for (const SettingDesc *sd = _patch_settings; sd->save.cmd != SL_END; sd++) {
+ if (prefilter != NULL) {
+ if (strncmp(sd->desc.name, prefilter, min(strlen(sd->desc.name), strlen(prefilter))) != 0) continue;
+ }
char value[80];
const void *ptr = GetVariableAddress((_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game, &sd->save);
diff --git a/src/settings_func.h b/src/settings_func.h
index 725cc3bd1..2dcb705c0 100644
--- a/src/settings_func.h
+++ b/src/settings_func.h
@@ -10,7 +10,7 @@
void IConsoleSetPatchSetting(const char *name, const char *value);
void IConsoleSetPatchSetting(const char *name, int32 value);
void IConsoleGetPatchSetting(const char *name);
-void IConsoleListPatches();
+void IConsoleListPatches(const char *prefilter);
void LoadFromConfig();
void SaveToConfig();