Changeset - r12776:f8721a71753f
[Not reviewed]
master
0 1 0
rubidium - 15 years ago 2009-08-22 20:20:20
rubidium@openttd.org
(svn r17267) -Change [FS#3139]: mention the MD5 checksum of the original NewGRF in the "saveload failed horribly"-error message and make it more clear that the filename is of the current NewGRF
1 file changed with 24 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/saveload/afterload.cpp
Show inline comments
 
@@ -9,24 +9,25 @@
 

	
 
/** @file afterload.cpp Code updating data after game load */
 

	
 
#include "../stdafx.h"
 
#include "../void_map.h"
 
#include "../signs_base.h"
 
#include "../roadstop_base.h"
 
#include "../window_func.h"
 
#include "../fios.h"
 
#include "../train.h"
 
#include "../string_func.h"
 
#include "../gamelog.h"
 
#include "../gamelog_internal.h"
 
#include "../network/network.h"
 
#include "../gfxinit.h"
 
#include "../functions.h"
 
#include "../industry_map.h"
 
#include "../town_map.h"
 
#include "../clear_map.h"
 
#include "../vehicle_func.h"
 
#include "../newgrf_station.h"
 
#include "../yapf/yapf.hpp"
 
#include "../elrail_func.h"
 
#include "../signs_func.h"
 
#include "../aircraft.h"
 
@@ -266,58 +267,77 @@ static void SetSignalHandlers()
 

	
 
/**
 
 * Resets signal handlers back to original handlers.
 
 */
 
static void ResetSignalHandlers()
 
{
 
	signal(SIGSEGV, _prev_segfault);
 
	signal(SIGABRT, _prev_abort);
 
	signal(SIGFPE,  _prev_fpe);
 
}
 

	
 
/**
 
 * Try to find the overridden GRF identifier of the given GRF.
 
 * @param c the GRF to get the 'previous' version of.
 
 * @return the GRF identifier or \a c if none could be found.
 
 */
 
static const GRFIdentifier *GetOverriddenIdentifier(const GRFConfig *c)
 
{
 
	const LoggedAction *la = &_gamelog_action[_gamelog_actions - 1];
 
	if (la->at != GLAT_LOAD) return c;
 

	
 
	const LoggedChange *lcend = &la->change[la->changes];
 
	for (const LoggedChange *lc = la->change; lc != lcend; lc++) {
 
		if (lc->ct == GLCT_GRFCOMPAT && lc->grfcompat.grfid == c->grfid) return &lc->grfcompat;
 
	}
 

	
 
	return c;
 
}
 

	
 
/**
 
 * Signal handler used to give a user a more useful report for crashes during
 
 * the savegame loading process; especially when there's problems with the
 
 * NewGRFs that are required by the savegame.
 
 * @param signum received signal
 
 */
 
static void CDECL HandleSavegameLoadCrash(int signum)
 
{
 
	ResetSignalHandlers();
 

	
 
	char buffer[8192];
 
	char *p = buffer;
 
	p += seprintf(p, lastof(buffer),
 
			"Loading your savegame caused OpenTTD to crash.\n"
 
			"This is most likely caused by a missing NewGRF or a NewGRF that has been\n"
 
			"loaded as replacement for a missing NewGRF. OpenTTD cannot easily\n"
 
			"determine whether a replacement NewGRF is of a newer or older version.\n"
 
			"It will load a NewGRF with the same GRF ID as the missing NewGRF. This\n"
 
			"means that if the author makes incompatible NewGRFs with the same GRF ID\n"
 
			"OpenTTD cannot magically do the right thing. In most cases OpenTTD will\n"
 
			"load the savegame and not crash, but this is an exception.\n"
 
			"Please load the savegame with the appropriate NewGRFs. When loading a\n"
 
			"savegame still crashes when all NewGRFs are found you should file a\n"
 
			"bug report. The missing NewGRFs are:\n");
 

	
 
	for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
 
	for (const GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
 
		if (HasBit(c->flags, GCF_COMPATIBLE)) {
 
			const GRFIdentifier *replaced = GetOverriddenIdentifier(c);
 
			char buf[40];
 
			md5sumToString(buf, lastof(buf), c->md5sum);
 
			p += seprintf(p, lastof(buffer), "NewGRF %08X (%s) not found; checksum %s. Tried another NewGRF with same GRF ID\n", BSWAP32(c->grfid), c->filename, buf);
 
			md5sumToString(buf, lastof(buf), replaced->md5sum);
 
			p += seprintf(p, lastof(buffer), "NewGRF %08X (checksum %s) not found.\n  Loaded NewGRF \"%s\" with same GRF ID instead.\n", BSWAP32(c->grfid), buf, c->filename);
 
		}
 
		if (c->status == GCS_NOT_FOUND) {
 
			char buf[40];
 
			md5sumToString(buf, lastof(buf), c->md5sum);
 
			p += seprintf(p, lastof(buffer), "NewGRF %08X (%s) not found; checksum %s\n", BSWAP32(c->grfid), c->filename, buf);
 
			p += seprintf(p, lastof(buffer), "NewGRF %08X (%s) not found; checksum %s.\n", BSWAP32(c->grfid), c->filename, buf);
 
		}
 
	}
 

	
 
	ShowInfo(buffer);
 

	
 
	SignalHandlerPointer call = NULL;
 
	switch (signum) {
 
		case SIGSEGV: call = _prev_segfault; break;
 
		case SIGABRT: call = _prev_abort; break;
 
		case SIGFPE:  call = _prev_fpe; break;
 
		default: NOT_REACHED();
 
	}
0 comments (0 inline, 0 general)