summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-05-29 18:35:31 +0000
committerfrosch <frosch@openttd.org>2011-05-29 18:35:31 +0000
commit615e435677a31a6ed7a78f21ad42af724bf20fca (patch)
tree27829a81d1431adc113a866693a28e20374c12a4
parent36526d6b0520e7cc27c0416a72186eeee7b01bdf (diff)
downloadopenttd-615e435677a31a6ed7a78f21ad42af724bf20fca.tar.xz
(svn r22522) -Fix (r22489): (size_t)(uint32)(-1) != (size_t)-1
-rw-r--r--src/settings.cpp16
-rw-r--r--src/settings_internal.h2
-rw-r--r--src/table/settings.h.preamble2
3 files changed, 10 insertions, 10 deletions
diff --git a/src/settings.cpp b/src/settings.cpp
index 24e51a69e..d11ee4344 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -97,10 +97,10 @@ static const char * const _list_group_names[] = {
* @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 @@ static int LookupOneOfMany(const char *many, const char *one, size_t onelen = 0)
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 @@ static int LookupOneOfMany(const char *many, const char *one, size_t onelen = 0)
* 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 @@ static uint32 LookupManyOfMany(const char *many, const char *str)
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 @@ static bool CheckRoadSide(int p1)
* @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);
diff --git a/src/settings_internal.h b/src/settings_internal.h
index f4444a9b4..5ada21eaa 100644
--- a/src/settings_internal.h
+++ b/src/settings_internal.h
@@ -56,7 +56,7 @@ typedef SimpleTinyEnumT<SettingGuiFlagLong, uint16> SettingGuiFlag;
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 {
diff --git a/src/table/settings.h.preamble b/src/table/settings.h.preamble
index ba1593e15..c69f114c3 100644
--- 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);
/****************************