Changeset - r6103:436b6b65ad3d
[Not reviewed]
master
0 9 0
maedhros - 18 years ago 2007-02-21 23:18:08
maedhros@openttd.org
(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.
9 files changed with 25 insertions and 4 deletions:
0 comments (0 inline, 0 general)
bin/data/openttd.grf
Show inline comments
 
binary diff not shown
src/gfxinit.cpp
Show inline comments
 
@@ -324,24 +324,25 @@ static const SpriteID _openttd_grf_index
 
	541, 544, // { | } ~ large
 
	SPR_HOUSE_ICON, SPR_HOUSE_ICON,
 
	585, 585, // § large
 
	587, 587, // © large
 
	592, 592, // ® large
 
	594, 597, // ° ± ² ³ large
 
	633, 633, // × large
 
	665, 665, // ÷ large
 
	SPR_SELL_TRAIN, SPR_SHARED_ORDERS_ICON,
 
	377, 377, // · small
 
	153, 153, // · medium
 
	601, 601, // · large
 
	SPR_WARNING_SIGN, SPR_WARNING_SIGN,
 
	END
 
};
 

	
 

	
 
static void LoadSpriteTables(void)
 
{
 
	const FileList* files = _use_dos_palette ? &files_dos : &files_win;
 
	uint load_index;
 
	uint i;
 

	
 
	LoadGrfIndexed(files->basic[0].filename, trg1idx, 0);
 
	DupSprite(  2, 130); // non-breaking space medium
src/lang/english.txt
Show inline comments
 
@@ -2887,24 +2887,25 @@ STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP   
 
STR_PERFORMANCE_DETAIL_DELIVERED_TIP                            :{BLACK}Units of cargo delivered in the last four quarters
 
STR_PERFORMANCE_DETAIL_CARGO_TIP                                :{BLACK}Number of types of cargo delivered in the last quarter
 
STR_PERFORMANCE_DETAIL_MONEY_TIP                                :{BLACK}Amount of money this company has in the bank
 
STR_PERFORMANCE_DETAIL_LOAN_TIP                                 :{BLACK}The amount of money this company has taken on loan
 
STR_PERFORMANCE_DETAIL_TOTAL_TIP                                :{BLACK}Total points out of possible points
 

	
 
STR_NEWGRF_SETTINGS_BUTTON                                      :{BLACK}NewGRF Settings
 
STR_NEWGRF_SETTINGS_CAPTION                                     :{WHITE}NewGRF settings
 
STR_NEWGRF_APPLY_CHANGES                                        :{BLACK}Apply changes
 
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}
 
STR_NEWGRF_CONFIRMATION_TEXT                                    :{YELLOW}You are about to make changes to a running game; this can crash OpenTTD.{}Are you absolutely sure about this?
 

	
 
STR_NEWGRF_ADD                                                  :{BLACK}Add
 
STR_NEWGRF_ADD_TIP                                              :{BLACK}Add a NewGRF file to the list
 
STR_NEWGRF_REMOVE                                               :{BLACK}Remove
 
STR_NEWGRF_REMOVE_TIP                                           :{BLACK}Remove the selected NewGRF file from the list
 
STR_NEWGRF_MOVEUP                                               :{BLACK}Move Up
 
STR_NEWGRF_MOVEUP_TIP                                           :{BLACK}Move the selected NewGRF file up the list
 
STR_NEWGRF_MOVEDOWN                                             :{BLACK}Move Down
src/newgrf.cpp
Show inline comments
 
@@ -2703,25 +2703,32 @@ static void GRFError(byte *buf, int len)
 
	}
 

	
 
	if (message_id >= lengthof(msgstr) && message_id != 0xFF) {
 
		grfmsg(7, "GRFError: Invalid message id.");
 
		return;
 
	}
 

	
 
	if (len <= 1) {
 
		grfmsg(7, "GRFError: No message data supplied.");
 
		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 */
 
static void GRFComment(byte *buf, int len)
 
{
 
	/* <0C> [<ignored...>]
 
	 *
 
	 * V ignored       Anything following the 0C is ignored */
 

	
 
	static char comment[256];
 
	if (len == 1) return;
 

	
src/newgrf_config.cpp
Show inline comments
 
@@ -82,24 +82,25 @@ bool FillGRFDetails(GRFConfig *config, b
 

	
 
	return CalcGRFMD5Sum(config);
 
}
 

	
 

	
 
void ClearGRFConfig(GRFConfig **config)
 
{
 
	/* GCF_COPY as in NOT strdupped/alloced the filename, name and info */
 
	if (!HASBIT((*config)->flags, GCF_COPY)) {
 
		free((*config)->filename);
 
		free((*config)->name);
 
		free((*config)->info);
 
		free((*config)->error);
 
	}
 
	free(*config);
 
	*config = NULL;
 
}
 

	
 

	
 
/* Clear a GRF Config list */
 
void ClearGRFConfigList(GRFConfig **config)
 
{
 
	GRFConfig *c, *next;
 
	for (c = *config; c != NULL; c = next) {
 
		next = c->next;
 
@@ -114,24 +115,25 @@ void ClearGRFConfigList(GRFConfig **conf
 
 * @param src pointer to source list values
 
 * @return pointer to the last value added to the destination list */
 
GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src)
 
{
 
	/* Clear destination as it will be overwritten */
 
	ClearGRFConfigList(dst);
 
	for (; src != NULL; src = src->next) {
 
		GRFConfig *c = CallocT<GRFConfig>(1);
 
		*c = *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;
 
	}
 

	
 
	return dst;
 
}
 

	
 
/**
 
 * Removes duplicates from lists of GRFConfigs. These duplicates
 
 * are introduced when the _grfconfig_static GRFs are appended
 
 * to the _grfconfig on a newgame or savegame. As the parameters
 
@@ -243,24 +245,25 @@ compatible_grf:
 
			DEBUG(grf, 1, "Loading GRF %08X from %s", BSWAP32(f->grfid), f->filename);
 
			/* The filename could be the filename as in the savegame. As we need
 
			 * to load the GRF here, we need the correct filename, so overwrite that
 
			 * in any case and set the name and info when it is not set already.
 
			 * When the GCF_COPY flag is set, it is certain that the filename is
 
			 * already a local one, so there is no need to replace it. */
 
			if (!HASBIT(c->flags, GCF_COPY)) {
 
				free(c->filename);
 
				c->filename = strdup(f->filename);
 
				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;
 
			}
 
		}
 
	}
 

	
 
	return res;
 
}
 

	
 

	
 
extern bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb);
 

	
 
/* Scan a path for NewGRFs */
 
static uint ScanPath(const char *path)
src/newgrf_config.h
Show inline comments
 
@@ -15,24 +15,25 @@ typedef enum {
 
	GCF_COPY,      ///< The data is copied from a grf in _all_grfs
 
} GCF_Flags;
 

	
 
typedef struct GRFIdentifier {
 
	uint32 grfid;
 
	uint8 md5sum[16];
 
} GRF;
 

	
 
typedef struct GRFConfig : public GRFIdentifier {
 
	char *filename;
 
	char *name;
 
	char *info;
 
	char *error;
 

	
 
	uint8 flags;
 
	uint32 param[0x80];
 
	uint8 num_params;
 

	
 
	struct GRFConfig *next;
 
} GRFConfig;
 

	
 
/* First item in list of all scanned NewGRFs */
 
extern GRFConfig *_all_grfs;
 

	
 
/* First item in list of current GRF set up */
src/newgrf_gui.cpp
Show inline comments
 
@@ -34,24 +34,29 @@ static int parse_intlist(const char *p, 
 
		if (*p != ',' && *p != ' ') return -1;
 
		p++;
 
	}
 

	
 
	return n;
 
}
 

	
 

	
 
static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint w, bool show_params)
 
{
 
	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);
 
		y += DrawStringMultiLine(x, y, STR_NEWGRF_FILENAME, w);
 
	}
 

	
 
	/* Prepare and draw GRF ID */
 
	snprintf(buff, lengthof(buff), "%08X", BSWAP32(c->grfid));
 
	SetDParamStr(0, buff);
 
	y += DrawStringMultiLine(x, y, STR_NEWGRF_GRF_ID, w);
 

	
 
	/* Prepare and draw MD5 sum */
 
@@ -319,25 +324,26 @@ static void NewGRFWndProc(Window *w, Win
 
						pal = PALETTE_TO_RED;
 
					} else if (HASBIT(c->flags, GCF_STATIC)) {
 
						pal = PALETTE_TO_GREY;
 
					} else if (HASBIT(c->flags, GCF_COMPATIBLE)) {
 
						pal = PALETTE_TO_ORANGE;
 
					} else if (HASBIT(c->flags, GCF_ACTIVATED)) {
 
						pal = PALETTE_TO_GREEN;
 
					} else {
 
						pal = PALETTE_TO_BLUE;
 
					}
 

	
 
					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;
 
				}
 
			}
 

	
 
			if (WP(w, newgrf_d).sel != NULL) {
 
				/* Draw NewGRF file info */
 
				const Widget *wi = &w->widget[SNGRFS_NEWGRF_INFO];
 
				ShowNewGRFInfo(WP(w, newgrf_d).sel, wi->left + 2, wi->top + 2, wi->right - wi->left - 2, WP(w, newgrf_d).show_params);
 
			}
 

	
 
			break;
 
		}
src/table/files.h
Show inline comments
 
@@ -50,16 +50,16 @@ static FileList files_win = {
 
};
 

	
 
static MD5File sample_cat_win = { "SAMPLE.CAT", {0x92, 0x12, 0xe8, 0x1e, 0x72, 0xba, 0xdd, 0x4b, 0xbe, 0x1e, 0xae, 0xae, 0x66, 0x45, 0x8e, 0x10} };
 
static MD5File sample_cat_dos = { "SAMPLE.CAT", {0x42, 0x2e, 0xa3, 0xdd, 0x07, 0x4d, 0x28, 0x59, 0xbb, 0x51, 0x63, 0x9a, 0x6e, 0x0e, 0x85, 0xda} };
 

	
 
static MD5File files_openttd[] = {
 
	{ "nsignalsw.grf", { 0x65, 0xb9, 0xd7, 0x30, 0x56, 0x06, 0xcc, 0x9e, 0x27, 0x57, 0xc8, 0xe4, 0x9b, 0xb3, 0x66, 0x81 } },
 
	{ "2ccmap.grf",    { 0x20, 0x03, 0x32, 0x1a, 0x43, 0x6c, 0xc1, 0x05, 0x80, 0xbd, 0x43, 0xeb, 0xe1, 0xfd, 0x0c, 0x62 } },
 
	{ "airports.grf",  { 0xfd, 0xa4, 0x38, 0xd6, 0x9c, 0x81, 0x74, 0xfe, 0xa0, 0x98, 0xa2, 0x14, 0x4b, 0x15, 0xb8, 0x4b } },
 
	{ "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 } },
 
};
src/table/sprites.h
Show inline comments
 
@@ -39,25 +39,25 @@
 
enum Sprites {
 
	SPR_SELECT_TILE  = 752,
 
	SPR_DOT          = 774, // corner marker for lower/raise land
 
	SPR_DOT_SMALL    = 4078,
 
	SPR_WHITE_POINT  = 4079,
 

	
 
	/* ASCII */
 
	SPR_ASCII_SPACE       = 2,
 
	SPR_ASCII_SPACE_SMALL = 226,
 
	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,
 
	SPR_AUTORAIL_BASE = SPR_SLOPES_BASE + 78,
 
	SPR_ELRAIL_BASE   = SPR_AUTORAIL_BASE + 55,
 
	SPR_2CCMAP_BASE   = SPR_ELRAIL_BASE + 53,
 
	SPR_OPENTTD_BASE  = SPR_2CCMAP_BASE + 256,
 

	
 
	SPR_BLOT = SPR_OPENTTD_BASE + 29, // colored circle (mainly used as vehicle profit marker and for sever compatibility)
 

	
 
	SPR_PIN_UP        = SPR_OPENTTD_BASE + 55,   // pin icon
 
	SPR_PIN_DOWN      = SPR_OPENTTD_BASE + 56,
 
@@ -86,24 +86,26 @@ enum Sprites {
 
	SPR_SELL_ALL_TRAIN    = SPR_OPENTTD_BASE + 100,
 
	SPR_SELL_ALL_ROADVEH  = SPR_OPENTTD_BASE + 101,
 
	SPR_SELL_ALL_SHIP     = SPR_OPENTTD_BASE + 102,
 
	SPR_SELL_ALL_AIRCRAFT = SPR_OPENTTD_BASE + 103,
 
	SPR_REPLACE_TRAIN     = SPR_OPENTTD_BASE + 104,
 
	SPR_REPLACE_ROADVEH   = SPR_OPENTTD_BASE + 105,
 
	SPR_REPLACE_SHIP      = SPR_OPENTTD_BASE + 106,
 
	SPR_REPLACE_AIRCRAFT  = SPR_OPENTTD_BASE + 107,
 
	SPR_SELL_CHAIN_TRAIN  = SPR_OPENTTD_BASE + 108,
 

	
 
	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)
 
	SPR_FLAGS_BASE = SPR_OPENTTD_BASE + 83, // start of the flags block (in same order as enum NetworkLanguage)
 

	
 
	SPR_AIRPORTX_BASE = SPR_OPENTTD_BASE + OPENTTD_SPRITES_COUNT, // The sprites used for other airport angles
 
	SPR_NEWAIRPORT_TARMAC = SPR_AIRPORTX_BASE,
 
	SPR_NSRUNWAY1 = SPR_AIRPORTX_BASE + 1,
 
	SPR_NSRUNWAY2 = SPR_AIRPORTX_BASE + 2,
 
	SPR_NSRUNWAY3 = SPR_AIRPORTX_BASE + 3,
 
	SPR_NSRUNWAY4 = SPR_AIRPORTX_BASE + 4,
 
	SPR_NSRUNWAY_END = SPR_AIRPORTX_BASE + 5,
0 comments (0 inline, 0 general)