mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r15893) -Add: watermark crash.sav and don't generate crash information if a loaded crash.sav causes a crash
This commit is contained in:
parent
8293be426c
commit
75c99d8b9b
|
@ -135,6 +135,7 @@ static const char *la_text[] = {
|
|||
"cheat was used",
|
||||
"settings changed",
|
||||
"GRF bug triggered",
|
||||
"emergency savegame",
|
||||
};
|
||||
|
||||
assert_compile(lengthof(la_text) == GLAT_END);
|
||||
|
@ -249,6 +250,9 @@ void GamelogPrint(GamelogPrintProc *proc)
|
|||
PrintGrfFilename(buf, lc->grfbug.grfid);
|
||||
break;
|
||||
}
|
||||
|
||||
case GLCT_EMERGENCY:
|
||||
break;
|
||||
}
|
||||
|
||||
proc(buf);
|
||||
|
@ -317,6 +321,31 @@ static LoggedChange *GamelogChange(GamelogChangeType ct)
|
|||
}
|
||||
|
||||
|
||||
/** Logs a emergency savegame
|
||||
*/
|
||||
void GamelogEmergency()
|
||||
{
|
||||
assert(_gamelog_action_type == GLAT_EMERGENCY);
|
||||
GamelogChange(GLCT_EMERGENCY);
|
||||
}
|
||||
|
||||
/** Finds out if current game is a loaded emergency savegame.
|
||||
*/
|
||||
bool GamelogTestEmergency()
|
||||
{
|
||||
const LoggedChange *emergency = NULL;
|
||||
|
||||
const LoggedAction *laend = &_gamelog_action[_gamelog_actions];
|
||||
for (const LoggedAction *la = _gamelog_action; la != laend; la++) {
|
||||
const LoggedChange *lcend = &la->change[la->changes];
|
||||
for (const LoggedChange *lc = la->change; lc != lcend; lc++) {
|
||||
if (lc->ct == GLCT_EMERGENCY) emergency = lc;
|
||||
}
|
||||
}
|
||||
|
||||
return (emergency != NULL);
|
||||
}
|
||||
|
||||
/** Logs a change in game revision
|
||||
* @param revision new revision string
|
||||
*/
|
||||
|
|
|
@ -14,6 +14,7 @@ enum GamelogActionType {
|
|||
GLAT_CHEAT, ///< Cheat was used
|
||||
GLAT_SETTING, ///< Setting changed
|
||||
GLAT_GRFBUG, ///< GRF bug was triggered
|
||||
GLAT_EMERGENCY, ///< Emergency savegame
|
||||
GLAT_END, ///< So we know how many GLATs are there
|
||||
GLAT_NONE = 0xFF, ///< No logging active; in savegames, end of list
|
||||
};
|
||||
|
@ -29,6 +30,9 @@ void GamelogPrint(GamelogPrintProc *proc); // needed for WIN32 / WINCE crash.log
|
|||
void GamelogPrintDebug(int level);
|
||||
void GamelogPrintConsole();
|
||||
|
||||
void GamelogEmergency();
|
||||
bool GamelogTestEmergency();
|
||||
|
||||
void GamelogRevision();
|
||||
void GamelogMode();
|
||||
void GamelogOldver();
|
||||
|
|
|
@ -19,6 +19,7 @@ enum GamelogChangeType {
|
|||
GLCT_GRFPARAM, ///< GRF parameter changed
|
||||
GLCT_GRFMOVE, ///< GRF order changed
|
||||
GLCT_GRFBUG, ///< GRF bug triggered
|
||||
GLCT_EMERGENCY, ///< Emergency savegame
|
||||
GLCT_END, ///< So we know how many GLCTs are there
|
||||
GLCT_NONE = 0xFF, ///< In savegames, end of list
|
||||
};
|
||||
|
|
|
@ -76,6 +76,10 @@ static const SaveLoad _glog_grfbug_desc[] = {
|
|||
SLE_END()
|
||||
};
|
||||
|
||||
static const SaveLoad _glog_emergency_desc[] = {
|
||||
SLE_END()
|
||||
};
|
||||
|
||||
static const SaveLoad *_glog_desc[] = {
|
||||
_glog_mode_desc,
|
||||
_glog_revision_desc,
|
||||
|
@ -87,6 +91,7 @@ static const SaveLoad *_glog_desc[] = {
|
|||
_glog_grfparam_desc,
|
||||
_glog_grfmove_desc,
|
||||
_glog_grfbug_desc,
|
||||
_glog_emergency_desc,
|
||||
};
|
||||
|
||||
assert_compile(lengthof(_glog_desc) == GLCT_END);
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include "saveload_internal.h"
|
||||
|
||||
extern const uint16 SAVEGAME_VERSION = 115;
|
||||
extern const uint16 SAVEGAME_VERSION = 116;
|
||||
|
||||
SavegameType _savegame_type; ///< type of savegame we are loading
|
||||
|
||||
|
|
|
@ -234,8 +234,15 @@ static const TCHAR _save_succeeded[] =
|
|||
_T("Be aware that critical parts of the internal game state may have become ")
|
||||
_T("corrupted. The saved game is not guaranteed to work.");
|
||||
|
||||
static const TCHAR _emergency_crash[] =
|
||||
_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");
|
||||
|
||||
static bool EmergencySave()
|
||||
{
|
||||
GamelogStartAction(GLAT_EMERGENCY);
|
||||
GamelogEmergency();
|
||||
GamelogStopAction();
|
||||
SaveOrLoad("crash.sav", SL_SAVE, BASE_DIR);
|
||||
return true;
|
||||
}
|
||||
|
@ -471,6 +478,10 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
|
|||
static bool had_exception = false;
|
||||
|
||||
if (had_exception) ExitProcess(0);
|
||||
if (GamelogTestEmergency()) {
|
||||
MessageBox(NULL, _emergency_crash, _T("Fatal Application Failure"), MB_ICONERROR);
|
||||
ExitProcess(0);
|
||||
}
|
||||
had_exception = true;
|
||||
|
||||
_ident = GetTickCount(); // something pretty unique
|
||||
|
|
Loading…
Reference in New Issue