changeset 17741:39e8414a5448 draft

(svn r22522) -Fix (r22489): (size_t)(uint32)(-1) != (size_t)-1
author frosch <frosch@openttd.org>
date Sun, 29 May 2011 18:35:31 +0000
parents aa54f6076a93
children f8b6cde27fd2
files src/settings.cpp src/settings_internal.h src/table/settings.h.preamble
diffstat 3 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -97,10 +97,10 @@
  * @param onelen force calculation of the *one parameter
  * @return the integer index of the full-list, or -1 if not found
  */
-static int LookupOneOfMany(const char *many, const char *one, size_t onelen = 0)
+static size_t LookupOneOfMany(const char *many, const char *one, size_t onelen = 0)
 {
 	const char *s;
-	int idx;
+	size_t idx;
 
 	if (onelen == 0) onelen = strlen(one);
 
@@ -113,7 +113,7 @@
 		s = many;
 		while (*s != '|' && *s != 0) s++;
 		if ((size_t)(s - many) == onelen && !memcmp(one, many, onelen)) return idx;
-		if (*s == 0) return -1;
+		if (*s == 0) return (size_t)-1;
 		many = s + 1;
 		idx++;
 	}
@@ -126,11 +126,11 @@
  * of seperated by a whitespace,tab or | character
  * @return the 'fully' set integer, or -1 if a set is not found
  */
-static uint32 LookupManyOfMany(const char *many, const char *str)
+static size_t LookupManyOfMany(const char *many, const char *str)
 {
 	const char *s;
-	int r;
-	uint32 res = 0;
+	size_t r;
+	size_t res = 0;
 
 	for (;;) {
 		/* skip "whitespace" */
@@ -141,7 +141,7 @@
 		while (*s != 0 && *s != ' ' && *s != '\t' && *s != '|') s++;
 
 		r = LookupOneOfMany(many, str, s - str);
-		if (r == -1) return (uint32)-1;
+		if (r == (size_t)-1) return r;
 
 		SetBit(res, r); // value found, set it
 		if (*s == 0) break;
@@ -1059,7 +1059,7 @@
  * @param value that was read from config file
  * @return the "hopefully" converted value
  */
-static int32 ConvertLandscape(const char *value)
+static size_t ConvertLandscape(const char *value)
 {
 	/* try with the old values */
 	return LookupOneOfMany("normal|hilly|desert|candy", value);
--- a/src/settings_internal.h
+++ b/src/settings_internal.h
@@ -56,7 +56,7 @@
 
 
 typedef bool OnChange(int32 var);           ///< callback prototype on data modification
-typedef int32 OnConvert(const char *value); ///< callback prototype for convertion error
+typedef size_t OnConvert(const char *value); ///< callback prototype for convertion error
 
 /** Properties of config file settings. */
 struct SettingDescBase {
--- a/src/table/settings.h.preamble
+++ b/src/table/settings.h.preamble
@@ -10,7 +10,7 @@
 /** @file table/settings.h Settings to save in the savegame and config file. */
 
 /* Callback function used in _settings[] as well as _company_settings[] */
-static int32 ConvertLandscape(const char *value);
+static size_t ConvertLandscape(const char *value);
 
 
 /****************************