diff options
author | rubidium <rubidium@openttd.org> | 2011-12-10 16:05:26 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2011-12-10 16:05:26 +0000 |
commit | 0ca25fb3af8fbf00607df120149b27aa7a763edb (patch) | |
tree | 432cac5f9d7caac4f6256b2c4266bfcfd42a68b9 | |
parent | e88a982fc6b12fbecbba59868fc8530449ff0ca7 (diff) | |
download | openttd-0ca25fb3af8fbf00607df120149b27aa7a763edb.tar.xz |
(svn r23480) -Fix [FS#4594]: replace OS error messages with internal error messages when that's possible
-rw-r--r-- | src/genworld.cpp | 3 | ||||
-rw-r--r-- | src/lang/english.txt | 15 | ||||
-rw-r--r-- | src/saveload/saveload.cpp | 7 | ||||
-rw-r--r-- | src/settings.cpp | 45 |
4 files changed, 53 insertions, 17 deletions
diff --git a/src/genworld.cpp b/src/genworld.cpp index 9302bbb03..beb9059b2 100644 --- a/src/genworld.cpp +++ b/src/genworld.cpp @@ -32,6 +32,7 @@ #include "core/random_func.hpp" #include "core/backup_type.hpp" #include "progress.h" +#include "error.h" #include "table/sprites.h" @@ -83,6 +84,7 @@ static void CleanupGeneration() _gw.threaded = false; DeleteWindowById(WC_MODAL_PROGRESS, 0); + ShowFirstError(); MarkWholeScreenDirty(); } @@ -317,6 +319,7 @@ void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_setti return; } + UnshowCriticalError(); /* Remove any open window */ DeleteAllNonVitalWindows(); /* Hide vital windows, because we don't allow to use them */ diff --git a/src/lang/english.txt b/src/lang/english.txt index 0df1bba12..d3fb8e8d9 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1371,6 +1371,21 @@ STR_CONFIG_SETTING_REVERSE_AT_SIGNALS :{LTBLUE}Automat STR_CONFIG_SETTING_QUERY_CAPTION :{WHITE}Change setting value +# Config errors +STR_CONFIG_ERROR :{WHITE}Error with the configuration file... +STR_CONFIG_ERROR_ARRAY :{WHITE}... error in array '{RAW_STRING}' +STR_CONFIG_ERROR_INVALID_VALUE :{WHITE}... invalid value '{RAW_STRING}' for '{RAW_STRING}' +STR_CONFIG_ERROR_TRAILING_CHARACTERS :{WHITE}... trailing characters at end of setting '{RAW_STRING}' +STR_CONFIG_ERROR_DUPLICATE_GRFID :{WHITE}... ignoring NewGRF '{RAW_STRING}': duplicate GRF ID with '{RAW_STRING}' +STR_CONFIG_ERROR_INVALID_GRF :{WHITE}... ignoring invalid NewGRF '{RAW_STRING}': {STRING} +STR_CONFIG_ERROR_INVALID_GRF_NOT_FOUND :not found +STR_CONFIG_ERROR_INVALID_GRF_UNSAFE :unsafe for static use +STR_CONFIG_ERROR_INVALID_GRF_SYSTEM :system NewGRF +STR_CONFIG_ERROR_INVALID_GRF_INCOMPATIBLE :incompatible to this version of OpenTTD +STR_CONFIG_ERROR_INVALID_GRF_UNKNOWN :unknown +STR_CONFIG_ERROR_INVALID_SAVEGAME_COMPRESSION_LEVEL :{WHITE}... compression level '{RAW_STRING}' is not valid +STR_CONFIG_ERROR_INVALID_SAVEGAME_COMPRESSION_ALGORITHM :{WHITE}... savegame format '{RAW_STRING}' is not available. Reverting to '{RAW_STRING}' + # Intro window STR_INTRO_CAPTION :{WHITE}OpenTTD {REV} diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 5efc187a8..afcd9332a 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -2285,7 +2285,8 @@ static const SaveLoadFormat *GetSavegameFormat(char *s, byte *compression_level) char *end; long level = strtol(complevel, &end, 10); if (end == complevel || level != Clamp(level, slf->min_compression, slf->max_compression)) { - ShowInfoF("Compression level '%s' is not valid.", complevel); + SetDParamStr(0, complevel); + ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_SAVEGAME_COMPRESSION_LEVEL, WL_CRITICAL); } else { *compression_level = level; } @@ -2294,7 +2295,9 @@ static const SaveLoadFormat *GetSavegameFormat(char *s, byte *compression_level) } } - ShowInfoF("Savegame format '%s' is not available. Reverting to '%s'.", s, def->name); + SetDParamStr(0, s); + SetDParamStr(1, def->name); + ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_SAVEGAME_COMPRESSION_ALGORITHM, WL_CRITICAL); /* Restore the string by adding the : back */ if (complevel != NULL) *complevel = ':'; diff --git a/src/settings.cpp b/src/settings.cpp index e9d4a17de..a4ee25997 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -61,6 +61,7 @@ #include "smallmap_gui.h" #include "roadveh.h" #include "fios.h" +#include "strings_func.h" #include "void_map.h" #include "station_base.h" @@ -340,7 +341,10 @@ static const void *StringToVal(const SettingDescBase *desc, const char *orig_str case SDT_NUMX: { char *end; size_t val = strtoul(str, &end, 0); - if (*end != '\0') ShowInfoF("ini: trailing characters at end of setting '%s'", desc->name); + if (*end != '\0') { + SetDParamStr(0, desc->name); + ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_TRAILING_CHARACTERS, WL_CRITICAL); + } return (void*)val; } case SDT_ONEOFMANY: { @@ -349,19 +353,27 @@ static const void *StringToVal(const SettingDescBase *desc, const char *orig_str * look if we have defined a converter from old value to new value. */ if (r == (size_t)-1 && desc->proc_cnvt != NULL) r = desc->proc_cnvt(str); if (r != (size_t)-1) return (void*)r; // and here goes converted value - ShowInfoF("ini: invalid value '%s' for '%s'", str, desc->name); // sorry, we failed + + SetDParamStr(0, str); + SetDParamStr(1, desc->name); + ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_VALUE, WL_CRITICAL); return 0; } case SDT_MANYOFMANY: { size_t r = LookupManyOfMany(desc->many, str); if (r != (size_t)-1) return (void*)r; - ShowInfoF("ini: invalid value '%s' for '%s'", str, desc->name); + SetDParamStr(0, str); + SetDParamStr(1, desc->name); + ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_VALUE, WL_CRITICAL); return NULL; } case SDT_BOOLX: if (strcmp(str, "true") == 0 || strcmp(str, "on") == 0 || strcmp(str, "1") == 0) return (void*)true; if (strcmp(str, "false") == 0 || strcmp(str, "off") == 0 || strcmp(str, "0") == 0) return (void*)false; - ShowInfoF("ini: invalid setting value '%s' for '%s'", str, desc->name); + + SetDParamStr(0, str); + SetDParamStr(1, desc->name); + ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_VALUE, WL_CRITICAL); break; case SDT_STRING: return orig_str; @@ -500,7 +512,8 @@ static void IniLoadSettings(IniFile *ini, const SettingDesc *sd, const char *grp case SDT_INTLIST: { if (!LoadIntList((const char*)p, ptr, sld->length, GetVarMemType(sld->conv))) { - ShowInfoF("ini: error in array '%s'", sdb->name); + SetDParamStr(0, sdb->name); + ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_ARRAY, WL_CRITICAL); } else if (sd->desc.proc_cnvt != NULL) { sd->desc.proc_cnvt((const char*)p); } @@ -1371,28 +1384,28 @@ static GRFConfig *GRFLoadConfig(IniFile *ini, const char *grpname, bool is_stati if (!StrEmpty(item->value)) { c->num_params = ParseIntList(item->value, (int*)c->param, lengthof(c->param)); if (c->num_params == (byte)-1) { - ShowInfoF("ini: error in array '%s'", item->name); + SetDParamStr(0, item->name); + ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_ARRAY, WL_CRITICAL); c->num_params = 0; } } /* Check if item is valid */ if (!FillGRFDetails(c, is_static) || HasBit(c->flags, GCF_INVALID)) { - const char *msg; - if (c->status == GCS_NOT_FOUND) { - msg = "not found"; + SetDParam(1, STR_CONFIG_ERROR_INVALID_GRF_NOT_FOUND); } else if (HasBit(c->flags, GCF_UNSAFE)) { - msg = "unsafe for static use"; + SetDParam(1, STR_CONFIG_ERROR_INVALID_GRF_UNSAFE); } else if (HasBit(c->flags, GCF_SYSTEM)) { - msg = "system NewGRF"; + SetDParam(1, STR_CONFIG_ERROR_INVALID_GRF_SYSTEM); } else if (HasBit(c->flags, GCF_INVALID)) { - msg = "incompatible to this version of OpenTTD"; + SetDParam(1, STR_CONFIG_ERROR_INVALID_GRF_INCOMPATIBLE); } else { - msg = "unknown"; + SetDParam(1, STR_CONFIG_ERROR_INVALID_GRF_UNKNOWN); } - ShowInfoF("ini: ignoring invalid NewGRF '%s': %s", item->name, msg); + SetDParamStr(0, item->name); + ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_GRF, WL_CRITICAL); delete c; continue; } @@ -1401,7 +1414,9 @@ static GRFConfig *GRFLoadConfig(IniFile *ini, const char *grpname, bool is_stati bool duplicate = false; for (const GRFConfig *gc = first; gc != NULL; gc = gc->next) { if (gc->ident.grfid == c->ident.grfid) { - ShowInfoF("ini: ignoring NewGRF '%s': duplicate GRF ID with '%s'", item->name, gc->filename); + SetDParamStr(0, item->name); + SetDParamStr(1, gc->filename); + ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_DUPLICATE_GRFID, WL_CRITICAL); duplicate = true; break; } |