diff options
author | alberth <alberth@openttd.org> | 2010-04-07 20:09:53 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2010-04-07 20:09:53 +0000 |
commit | 1e48b2332e0540588f00a2ce227666fea840bb76 (patch) | |
tree | 570b929b4805af135e2d90f1a35796bf9c66ebbb | |
parent | f1da8d7281b25d1f9da952eed8d2f4660a43a815 (diff) | |
download | openttd-1e48b2332e0540588f00a2ce227666fea840bb76.tar.xz |
(svn r19576) -Codechange: Unduplicating parse_intlist().
-rw-r--r-- | src/newgrf_gui.cpp | 24 | ||||
-rw-r--r-- | src/settings.cpp | 2 | ||||
-rw-r--r-- | src/settings_func.h | 2 |
3 files changed, 3 insertions, 25 deletions
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 4838623cf..af6af1a35 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -49,30 +49,6 @@ void ShowNewGRFError() } } -/** Parse an integerlist string and set each found value - * @param p the string to be parsed. Each element in the list is seperated by a - * comma or a space character - * @param items pointer to the integerlist-array that will be filled with values - * @param maxitems the maximum number of elements the integerlist-array has - * @return returns the number of items found, or -1 on an error */ -static int parse_intlist(const char *p, int *items, int maxitems) -{ - int n = 0, v; - char *end; - - for (;;) { - while (*p == ' ' || *p == ',') p++; - if (*p == '\0') break; - v = strtol(p, &end, 0); - if (p == end || n == maxitems) return -1; - p = end; - items[n++] = v; - } - - return n; -} - - static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint right, uint bottom, bool show_params) { char buff[256]; diff --git a/src/settings.cpp b/src/settings.cpp index fc7df844a..6fec1cb55 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -156,7 +156,7 @@ static uint32 lookup_manyofmany(const char *many, const char *str) * @param items pointer to the integerlist-array that will be filled with values * @param maxitems the maximum number of elements the integerlist-array has * @return returns the number of items found, or -1 on an error */ -static int parse_intlist(const char *p, int *items, int maxitems) +int parse_intlist(const char *p, int *items, int maxitems) { int n = 0, v; char *end; diff --git a/src/settings_func.h b/src/settings_func.h index 65fca20f8..d42a6cc9e 100644 --- a/src/settings_func.h +++ b/src/settings_func.h @@ -20,6 +20,8 @@ void IConsoleSetSetting(const char *name, int32 value); void IConsoleGetSetting(const char *name, bool force_newgame = false); void IConsoleListSettings(const char *prefilter); +int parse_intlist(const char *p, int *items, int maxitems); + void LoadFromConfig(); void SaveToConfig(); void CheckConfig(); |