summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gamelog.cpp29
-rw-r--r--src/gamelog.h4
-rw-r--r--src/gamelog_internal.h1
-rw-r--r--src/saveload/gamelog_sl.cpp5
-rw-r--r--src/saveload/saveload.cpp2
-rw-r--r--src/win32.cpp11
6 files changed, 51 insertions, 1 deletions
diff --git a/src/gamelog.cpp b/src/gamelog.cpp
index 5fefb4a60..e47a19f0a 100644
--- a/src/gamelog.cpp
+++ b/src/gamelog.cpp
@@ -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
*/
diff --git a/src/gamelog.h b/src/gamelog.h
index 75a5f7f64..419ec9d92 100644
--- a/src/gamelog.h
+++ b/src/gamelog.h
@@ -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();
diff --git a/src/gamelog_internal.h b/src/gamelog_internal.h
index fb5fb4e68..1300429e4 100644
--- a/src/gamelog_internal.h
+++ b/src/gamelog_internal.h
@@ -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
};
diff --git a/src/saveload/gamelog_sl.cpp b/src/saveload/gamelog_sl.cpp
index 67f05d55e..e913e2dd1 100644
--- a/src/saveload/gamelog_sl.cpp
+++ b/src/saveload/gamelog_sl.cpp
@@ -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);
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index c9480f884..13c437746 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -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
diff --git a/src/win32.cpp b/src/win32.cpp
index 2b0857901..066ea628b 100644
--- a/src/win32.cpp
+++ b/src/win32.cpp
@@ -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