summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2006-08-15 07:37:01 +0000
committerDarkvater <Darkvater@openttd.org>2006-08-15 07:37:01 +0000
commit397a0a32beeb7259a77b7d2f8d6e9a5a96a1fe66 (patch)
tree1467a28e1969e71421d080e091d5a09d204f07ce
parent5cf43b9f3c26ae5e44215cfa8142ed9e440dd3a0 (diff)
downloadopenttd-397a0a32beeb7259a77b7d2f8d6e9a5a96a1fe66.tar.xz
(svn r5908) - Codechange (r5903): Move the retrieval of the new value of a patch to console_cmds.c, so there is no need for that function in settings.c
-rw-r--r--console_cmds.c3
-rw-r--r--settings.c14
-rw-r--r--settings.h2
3 files changed, 7 insertions, 12 deletions
diff --git a/console_cmds.c b/console_cmds.c
index f65854562..9ceca60cc 100644
--- a/console_cmds.c
+++ b/console_cmds.c
@@ -1342,7 +1342,8 @@ DEF_CONSOLE_CMD(ConPatch)
if (argc == 2) {
IConsoleGetPatchSetting(argv[1]);
} else {
- IConsoleSetPatchSetting(argv[1], argv[2]);
+ int32 val;
+ if (GetArgumentInteger(&val, argv[2])) IConsoleSetPatchSetting(argv[1], val);
}
return true;
diff --git a/settings.c b/settings.c
index 3d1c5ae69..ae710f663 100644
--- a/settings.c
+++ b/settings.c
@@ -1597,13 +1597,9 @@ const SettingDesc *GetPatchFromName(const char *name, uint *i)
}
/* Those 2 functions need to be here, else we have to make some stuff non-static
- * and besides, it is also better to keep stuff like this at the same place
- * XXX - Perhaps back to console[_cmds].c? They are console functions after all */
-extern bool GetArgumentInteger(uint32 *value, const char *arg);
-
-void IConsoleSetPatchSetting(const char *name, const char *value)
+ * and besides, it is also better to keep stuff like this at the same place */
+void IConsoleSetPatchSetting(const char *name, int32 value)
{
- int32 val;
uint index;
const SettingDesc *sd = GetPatchFromName(name, &index);
const Patches *patches_ptr;
@@ -1614,13 +1610,11 @@ void IConsoleSetPatchSetting(const char *name, const char *value)
return;
}
- if (!GetArgumentInteger(&val, value)) return;
-
patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
ptr = ini_get_variable(&sd->save, patches_ptr);
- SetPatchValue(index, patches_ptr, val);
- if (sd->desc.proc != NULL) sd->desc.proc(val);
+ SetPatchValue(index, patches_ptr, value);
+ if (sd->desc.proc != NULL) sd->desc.proc(value);
}
void IConsoleGetPatchSetting(const char *name)
diff --git a/settings.h b/settings.h
index f837ee835..904abca77 100644
--- a/settings.h
+++ b/settings.h
@@ -77,7 +77,7 @@ static inline void *ini_get_variable(const SaveLoad *sld, const void *object)
/** The patch values that are used for new games and/or modified in config file */
extern Patches _patches_newgame;
-void IConsoleSetPatchSetting(const char *name, const char *value);
+void IConsoleSetPatchSetting(const char *name, int32 value);
void IConsoleGetPatchSetting(const char *name);
const SettingDesc *GetPatchFromName(const char *name, uint *i);
void SetPatchValue(uint index, const Patches *object, int32 value);