Changeset - r14958:63c25b2c8228
[Not reviewed]
master
0 3 0
alberth - 14 years ago 2010-04-07 20:09:53
alberth@openttd.org
(svn r19576) -Codechange: Unduplicating parse_intlist().
3 files changed with 3 insertions and 25 deletions:
0 comments (0 inline, 0 general)
src/newgrf_gui.cpp
Show inline comments
 
@@ -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];
src/settings.cpp
Show inline comments
 
@@ -156,7 +156,7 @@ static uint32 lookup_manyofmany(const ch
 
 * @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;
src/settings_func.h
Show inline comments
 
@@ -20,6 +20,8 @@ void IConsoleSetSetting(const char *name
 
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();
0 comments (0 inline, 0 general)