Changeset - r14269:cb886fbeaf44
[Not reviewed]
master
0 5 0
rubidium - 14 years ago 2010-01-16 19:08:33
rubidium@openttd.org
(svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
5 files changed with 43 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/os/macosx/crashlog_osx.cpp
Show inline comments
 
@@ -10,12 +10,13 @@
 
/** @file crashlog_osx.cpp OS X crash log handler */
 

	
 
#include "../../stdafx.h"
 
#include "../../crashlog.h"
 
#include "../../string_func.h"
 
#include "../../gamelog.h"
 
#include "../../saveload/saveload.h"
 
#include "macos.h"
 

	
 
#include <errno.h>
 
#include <signal.h>
 
#include <mach-o/arch.h>
 
#include <dlfcn.h>
 
@@ -227,12 +228,19 @@ void CDECL HandleCrash(int signum)
 
		ShowMacDialog("A serious fault condition occured in the game. The game will shut down.",
 
				"As you loaded an emergency savegame no crash information will be generated.\n",
 
				"Quit");
 
		abort();
 
	}
 

	
 
	if (SaveloadCrashWithMissingNewGRFs()) {
 
		ShowMacDialog("A serious fault condition occured in the game. The game will shut down.",
 
				"As you loaded an savegame for which you do not have the required NewGRFs no crash information will be generated.\n",
 
				"Quit");
 
		abort();
 
	}
 

	
 
	CrashLogOSX log(signum);
 
	log.MakeCrashLog();
 
	log.DisplayCrashDialog();
 

	
 
	CrashLog::AfterCrashLogCleanup();
 
	abort();
src/os/unix/crashlog_unix.cpp
Show inline comments
 
@@ -10,12 +10,13 @@
 
/** @file crashlog_unix.cpp Unix crash log handler */
 

	
 
#include "../../stdafx.h"
 
#include "../../crashlog.h"
 
#include "../../string_func.h"
 
#include "../../gamelog.h"
 
#include "../../saveload/saveload.h"
 

	
 
#include <errno.h>
 
#include <signal.h>
 
#include <sys/utsname.h>
 

	
 
#if defined(__GLIBC__)
 
@@ -153,12 +154,19 @@ static void CDECL HandleCrash(int signum
 
	if (GamelogTestEmergency()) {
 
		printf("A serious fault condition occured in the game. The game will shut down.\n");
 
		printf("As you loaded an emergency savegame no crash information will be generated.\n");
 
		abort();
 
	}
 

	
 
	if (SaveloadCrashWithMissingNewGRFs()) {
 
		printf("A serious fault condition occured in the game. The game will shut down.\n");
 
		printf("As you loaded an savegame for which you do not have the required NewGRFs\n");
 
		printf("no crash information will be generated.\n");
 
		abort();
 
	}
 

	
 
	CrashLogUnix log(signum);
 
	log.MakeCrashLog();
 

	
 
	CrashLog::AfterCrashLogCleanup();
 
	abort();
 
}
src/os/windows/crashlog_win.cpp
Show inline comments
 
@@ -15,12 +15,13 @@
 
#include "../../core/alloc_func.hpp"
 
#include "../../core/math_func.hpp"
 
#include "../../string_func.h"
 
#include "../../fileio_func.h"
 
#include "../../strings_func.h"
 
#include "../../gamelog.h"
 
#include "../../saveload/saveload.h"
 

	
 
#include <windows.h>
 
#include <signal.h>
 

	
 
/**
 
 * Windows implementation for the crash logger.
 
@@ -375,12 +376,21 @@ static LONG WINAPI ExceptionHandler(EXCE
 
			_T("A serious fault condition occured in the game. The game will shut down.\n")
 
			_T("As you loaded an emergency savegame no crash information will be generated.\n");
 
		MessageBox(NULL, _emergency_crash, _T("Fatal Application Failure"), MB_ICONERROR);
 
		ExitProcess(3);
 
	}
 

	
 
	if (SaveloadCrashWithMissingNewGRFs()) {
 
		static const TCHAR _saveload_crash[] =
 
			_T("A serious fault condition occured in the game. The game will shut down.\n")
 
			_T("As you loaded an savegame for which you do not have the required NewGRFs\n")
 
			_T("no crash information will be generated.\n");
 
		MessageBox(NULL, _saveload_crash, _T("Fatal Application Failure"), MB_ICONERROR);
 
		ExitProcess(3);
 
	}
 

	
 
	CrashLogWindows *log = new CrashLogWindows(ep);
 
	CrashLogWindows::current = log;
 
	log->FillCrashLog(log->crashlog, lastof(log->crashlog));
 
	log->WriteCrashLog(log->crashlog, log->crashlog_filename, lastof(log->crashlog_filename));
 
	log->WriteCrashDump(log->crashdump_filename, lastof(log->crashdump_filename));
 
	log->WriteScreenshot(log->screenshot_filename, lastof(log->screenshot_filename));
src/saveload/afterload.cpp
Show inline comments
 
@@ -308,12 +308,25 @@ static const GRFIdentifier *GetOverridde
 
		if (lc->ct == GLCT_GRFCOMPAT && lc->grfcompat.grfid == c->grfid) return &lc->grfcompat;
 
	}
 

	
 
	return c;
 
}
 

	
 
/** Was the saveload crash because of missing NewGRFs? */
 
static bool _saveload_crash_with_missing_newgrfs = false;
 

	
 
/**
 
 * Did loading the savegame cause a crash? If so,
 
 * were NewGRFs missing?
 
 * @return when the saveload crashed due to missing NewGRFs.
 
 */
 
bool SaveloadCrashWithMissingNewGRFs()
 
{
 
	return _saveload_crash_with_missing_newgrfs;
 
}
 

	
 
/**
 
 * 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
 
 */
 
@@ -339,17 +352,19 @@ static void CDECL HandleSavegameLoadCras
 
	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), 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);
 
			_saveload_crash_with_missing_newgrfs = true;
 
		}
 
		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);
 
			_saveload_crash_with_missing_newgrfs = true;
 
		}
 
	}
 

	
 
	ShowInfo(buffer);
 

	
 
	SignalHandlerPointer call = NULL;
src/saveload/saveload.h
Show inline comments
 
@@ -321,9 +321,11 @@ void SlWriteByte(byte b);
 

	
 
void SlGlobList(const SaveLoadGlobVarList *sldg);
 
void SlArray(void *array, size_t length, VarType conv);
 
void SlObject(void *object, const SaveLoad *sld);
 
bool SlObjectMember(void *object, const SaveLoad *sld);
 

	
 
bool SaveloadCrashWithMissingNewGRFs();
 

	
 
extern char _savegame_format[8];
 

	
 
#endif /* SAVELOAD_H */
0 comments (0 inline, 0 general)