mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 18:40:29 +00:00
(svn r23480) -Fix [FS#4594]: replace OS error messages with internal error messages when that's possible
This commit is contained in:
parent
e88a982fc6
commit
0ca25fb3af
@ -32,6 +32,7 @@
|
|||||||
#include "core/random_func.hpp"
|
#include "core/random_func.hpp"
|
||||||
#include "core/backup_type.hpp"
|
#include "core/backup_type.hpp"
|
||||||
#include "progress.h"
|
#include "progress.h"
|
||||||
|
#include "error.h"
|
||||||
|
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
|
|
||||||
@ -83,6 +84,7 @@ static void CleanupGeneration()
|
|||||||
_gw.threaded = false;
|
_gw.threaded = false;
|
||||||
|
|
||||||
DeleteWindowById(WC_MODAL_PROGRESS, 0);
|
DeleteWindowById(WC_MODAL_PROGRESS, 0);
|
||||||
|
ShowFirstError();
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,6 +319,7 @@ void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_setti
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UnshowCriticalError();
|
||||||
/* Remove any open window */
|
/* Remove any open window */
|
||||||
DeleteAllNonVitalWindows();
|
DeleteAllNonVitalWindows();
|
||||||
/* Hide vital windows, because we don't allow to use them */
|
/* Hide vital windows, because we don't allow to use them */
|
||||||
|
@ -1371,6 +1371,21 @@ STR_CONFIG_SETTING_REVERSE_AT_SIGNALS :{LTBLUE}Automat
|
|||||||
|
|
||||||
STR_CONFIG_SETTING_QUERY_CAPTION :{WHITE}Change setting value
|
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
|
# Intro window
|
||||||
STR_INTRO_CAPTION :{WHITE}OpenTTD {REV}
|
STR_INTRO_CAPTION :{WHITE}OpenTTD {REV}
|
||||||
|
|
||||||
|
@ -2285,7 +2285,8 @@ static const SaveLoadFormat *GetSavegameFormat(char *s, byte *compression_level)
|
|||||||
char *end;
|
char *end;
|
||||||
long level = strtol(complevel, &end, 10);
|
long level = strtol(complevel, &end, 10);
|
||||||
if (end == complevel || level != Clamp(level, slf->min_compression, slf->max_compression)) {
|
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 {
|
} else {
|
||||||
*compression_level = level;
|
*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 */
|
/* Restore the string by adding the : back */
|
||||||
if (complevel != NULL) *complevel = ':';
|
if (complevel != NULL) *complevel = ':';
|
||||||
|
@ -61,6 +61,7 @@
|
|||||||
#include "smallmap_gui.h"
|
#include "smallmap_gui.h"
|
||||||
#include "roadveh.h"
|
#include "roadveh.h"
|
||||||
#include "fios.h"
|
#include "fios.h"
|
||||||
|
#include "strings_func.h"
|
||||||
|
|
||||||
#include "void_map.h"
|
#include "void_map.h"
|
||||||
#include "station_base.h"
|
#include "station_base.h"
|
||||||
@ -340,7 +341,10 @@ static const void *StringToVal(const SettingDescBase *desc, const char *orig_str
|
|||||||
case SDT_NUMX: {
|
case SDT_NUMX: {
|
||||||
char *end;
|
char *end;
|
||||||
size_t val = strtoul(str, &end, 0);
|
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;
|
return (void*)val;
|
||||||
}
|
}
|
||||||
case SDT_ONEOFMANY: {
|
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. */
|
* 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 && desc->proc_cnvt != NULL) r = desc->proc_cnvt(str);
|
||||||
if (r != (size_t)-1) return (void*)r; // and here goes converted value
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
case SDT_MANYOFMANY: {
|
case SDT_MANYOFMANY: {
|
||||||
size_t r = LookupManyOfMany(desc->many, str);
|
size_t r = LookupManyOfMany(desc->many, str);
|
||||||
if (r != (size_t)-1) return (void*)r;
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
case SDT_BOOLX:
|
case SDT_BOOLX:
|
||||||
if (strcmp(str, "true") == 0 || strcmp(str, "on") == 0 || strcmp(str, "1") == 0) return (void*)true;
|
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;
|
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;
|
break;
|
||||||
|
|
||||||
case SDT_STRING: return orig_str;
|
case SDT_STRING: return orig_str;
|
||||||
@ -500,7 +512,8 @@ static void IniLoadSettings(IniFile *ini, const SettingDesc *sd, const char *grp
|
|||||||
|
|
||||||
case SDT_INTLIST: {
|
case SDT_INTLIST: {
|
||||||
if (!LoadIntList((const char*)p, ptr, sld->length, GetVarMemType(sld->conv))) {
|
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) {
|
} else if (sd->desc.proc_cnvt != NULL) {
|
||||||
sd->desc.proc_cnvt((const char*)p);
|
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)) {
|
if (!StrEmpty(item->value)) {
|
||||||
c->num_params = ParseIntList(item->value, (int*)c->param, lengthof(c->param));
|
c->num_params = ParseIntList(item->value, (int*)c->param, lengthof(c->param));
|
||||||
if (c->num_params == (byte)-1) {
|
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;
|
c->num_params = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if item is valid */
|
/* Check if item is valid */
|
||||||
if (!FillGRFDetails(c, is_static) || HasBit(c->flags, GCF_INVALID)) {
|
if (!FillGRFDetails(c, is_static) || HasBit(c->flags, GCF_INVALID)) {
|
||||||
const char *msg;
|
|
||||||
|
|
||||||
if (c->status == GCS_NOT_FOUND) {
|
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)) {
|
} 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)) {
|
} 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)) {
|
} else if (HasBit(c->flags, GCF_INVALID)) {
|
||||||
msg = "incompatible to this version of OpenTTD";
|
SetDParam(1, STR_CONFIG_ERROR_INVALID_GRF_INCOMPATIBLE);
|
||||||
} else {
|
} 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;
|
delete c;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1401,7 +1414,9 @@ static GRFConfig *GRFLoadConfig(IniFile *ini, const char *grpname, bool is_stati
|
|||||||
bool duplicate = false;
|
bool duplicate = false;
|
||||||
for (const GRFConfig *gc = first; gc != NULL; gc = gc->next) {
|
for (const GRFConfig *gc = first; gc != NULL; gc = gc->next) {
|
||||||
if (gc->ident.grfid == c->ident.grfid) {
|
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;
|
duplicate = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user