summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormaedhros <maedhros@openttd.org>2007-02-21 23:18:08 +0000
committermaedhros <maedhros@openttd.org>2007-02-21 23:18:08 +0000
commitf2d63dcecf5975b1817858e044e9044f21a4cc41 (patch)
treed603c0685ec921601a4cde5803bfbc4c046c69a3 /src
parentfd4a0dafc2b59930fd313a281f2851d8e4c75aba (diff)
downloadopenttd-f2d63dcecf5975b1817858e044e9044f21a4cc41.tar.xz
(svn r8838) -Feature: Show newgrf error messages loaded in Action B in the newgrf gui
window. GRFs with an error have a warning symbol shown before the name.
Diffstat (limited to 'src')
-rw-r--r--src/gfxinit.cpp1
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/newgrf.cpp9
-rw-r--r--src/newgrf_config.cpp3
-rw-r--r--src/newgrf_config.h1
-rw-r--r--src/newgrf_gui.cpp8
-rw-r--r--src/table/files.h2
-rw-r--r--src/table/sprites.h4
8 files changed, 25 insertions, 4 deletions
diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp
index 8efb62e4f..fbf7f4b89 100644
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -333,6 +333,7 @@ static const SpriteID _openttd_grf_indexes[] = {
377, 377, // · small
153, 153, // · medium
601, 601, // · large
+ SPR_WARNING_SIGN, SPR_WARNING_SIGN,
END
};
diff --git a/src/lang/english.txt b/src/lang/english.txt
index bfe43f177..ba05d0bfd 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -2896,6 +2896,7 @@ STR_NEWGRF_APPLY_CHANGES :{BLACK}Apply ch
STR_NEWGRF_SET_PARAMETERS :{BLACK}Set parameters
STR_NEWGRF_TIP :{BLACK}A list of all the Newgrf sets that you have installed. Click a set to change the settings
STR_NEWGRF_NO_FILES_INSTALLED :{BLACK}There are currently no newgrf files installed! Please refer to the manual for instructions on installing new graphics
+STR_NEWGRF_ERROR_MSG :{RED}{STRING}
STR_NEWGRF_FILENAME :{BLACK}Filename: {SILVER}{STRING}
STR_NEWGRF_GRF_ID :{BLACK}GRF ID: {SILVER}{STRING}
STR_NEWGRF_MD5SUM :{BLACK}MD5sum: {SILVER}{STRING}
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 1c0aed0e9..9ddc095eb 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -2712,7 +2712,14 @@ static void GRFError(byte *buf, int len)
return;
}
- grfmsg(0, msgstr[(message_id == 0xFF) ? lengthof(msgstr) - 1 : message_id], sevstr[severity], grf_load_string(&buf, len));
+ char message[512];
+ snprintf(message, lengthof(message), msgstr[(message_id == 0xFF) ? lengthof(msgstr) - 1 : message_id], sevstr[severity], grf_load_string(&buf, len));
+
+ if (_cur_grfconfig->error == NULL) {
+ _cur_grfconfig->error = strdup(message);
+ }
+
+ grfmsg(0, message);
}
/* Action 0x0C */
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index fce274a87..d6b910e05 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -91,6 +91,7 @@ void ClearGRFConfig(GRFConfig **config)
free((*config)->filename);
free((*config)->name);
free((*config)->info);
+ free((*config)->error);
}
free(*config);
*config = NULL;
@@ -123,6 +124,7 @@ GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src)
if (src->filename != NULL) c->filename = strdup(src->filename);
if (src->name != NULL) c->name = strdup(src->name);
if (src->info != NULL) c->info = strdup(src->info);
+ if (src->error != NULL) c->error = strdup(src->error);
*dst = c;
dst = &c->next;
@@ -252,6 +254,7 @@ compatible_grf:
memcpy(c->md5sum, f->md5sum, sizeof(c->md5sum));
if (c->name == NULL) c->name = strdup(f->name);
if (c->info == NULL) c->info = strdup(f->info);
+ c->error = NULL;
}
}
}
diff --git a/src/newgrf_config.h b/src/newgrf_config.h
index 97104d934..e2f326215 100644
--- a/src/newgrf_config.h
+++ b/src/newgrf_config.h
@@ -24,6 +24,7 @@ typedef struct GRFConfig : public GRFIdentifier {
char *filename;
char *name;
char *info;
+ char *error;
uint8 flags;
uint32 param[0x80];
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index 0de82b529..c418786b2 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -43,6 +43,11 @@ static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint w, bool show
{
char buff[256];
+ if (c->error != NULL) {
+ SetDParamStr(0, c->error);
+ y += DrawStringMultiLine(x, y, STR_NEWGRF_ERROR_MSG, w);
+ }
+
/* Draw filename or not if it is not known (GRF sent over internet) */
if (c->filename != NULL) {
SetDParamStr(0, c->filename);
@@ -328,7 +333,8 @@ static void NewGRFWndProc(Window *w, WindowEvent *e)
}
DrawSprite(SPR_SQUARE, pal, 5, y + 2);
- DoDrawString(text, 25, y + 3, WP(w, newgrf_d).sel == c ? 0xC : 0x10);
+ if (c->error != NULL) DrawSprite(SPR_WARNING_SIGN, 0, 20, y + 2);
+ DoDrawString(text, c->error != NULL ? 35 : 25, y + 3, WP(w, newgrf_d).sel == c ? 0xC : 0x10);
y += 14;
}
}
diff --git a/src/table/files.h b/src/table/files.h
index d843d8a9e..fca534a35 100644
--- a/src/table/files.h
+++ b/src/table/files.h
@@ -59,7 +59,7 @@ static MD5File files_openttd[] = {
{ "autorail.grf", { 0xed, 0x44, 0x7f, 0xbb, 0x19, 0x44, 0x48, 0x4c, 0x07, 0x8a, 0xb1, 0xc1, 0x5c, 0x12, 0x3a, 0x60 } },
{ "canalsw.grf", { 0x13, 0x9c, 0x98, 0xcf, 0xb8, 0x7c, 0xd7, 0x1f, 0xca, 0x34, 0xa5, 0x6b, 0x65, 0x31, 0xec, 0x0f } },
{ "elrailsw.grf", { 0x4f, 0xf9, 0xac, 0x79, 0x50, 0x28, 0x9b, 0xe2, 0x15, 0x30, 0xa8, 0x1e, 0xd5, 0xfd, 0xe1, 0xda } },
- { "openttd.grf", { 0x59, 0x22, 0x19, 0xe0, 0x6e, 0xe7, 0xb6, 0xa3, 0x55, 0x53, 0xcc, 0x9e, 0xbc, 0xaf, 0xcc, 0x83 } },
+ { "openttd.grf", { 0x10, 0xc1, 0x68, 0x56, 0x9e, 0x1e, 0x0e, 0x85, 0x9d, 0xf8, 0x53, 0x27, 0x48, 0x7e, 0x17, 0x58 } },
{ "trkfoundw.grf", { 0x12, 0x33, 0x3f, 0xa3, 0xd1, 0x86, 0x8b, 0x04, 0x53, 0x18, 0x9c, 0xee, 0xf9, 0x2d, 0xf5, 0x95 } },
{ "roadstops.grf", { 0x8c, 0xd9, 0x45, 0x21, 0x28, 0x82, 0x96, 0x45, 0x33, 0x22, 0x7a, 0xb9, 0x0d, 0xf3, 0x67, 0x4a } },
};
diff --git a/src/table/sprites.h b/src/table/sprites.h
index 157272c8d..014d03130 100644
--- a/src/table/sprites.h
+++ b/src/table/sprites.h
@@ -48,7 +48,7 @@ enum Sprites {
SPR_ASCII_SPACE_BIG = 450,
/* Extra graphic spritenumbers */
- OPENTTD_SPRITES_COUNT = 116, // number of gfx-sprites in openttd.grf
+ OPENTTD_SPRITES_COUNT = 117, // number of gfx-sprites in openttd.grf
SPR_SIGNALS_BASE = 4896,
SPR_CANALS_BASE = SPR_SIGNALS_BASE + 486,
SPR_SLOPES_BASE = SPR_CANALS_BASE + 70,
@@ -95,6 +95,8 @@ enum Sprites {
SPR_SHARED_ORDERS_ICON = SPR_OPENTTD_BASE + 115,
+ SPR_WARNING_SIGN = SPR_OPENTTD_BASE + 116, // warning sign (shown if there are any newgrf errors)
+
/* Network GUI sprites */
SPR_SQUARE = SPR_OPENTTD_BASE + 20, // colored square (used for newgrf compatibility)
SPR_LOCK = SPR_OPENTTD_BASE + 19, // lock icon (for password protected servers)