summaryrefslogtreecommitdiff
path: root/src/misc_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-12-04 22:50:07 +0000
committerrubidium <rubidium@openttd.org>2007-12-04 22:50:07 +0000
commit8c5c0e9367080e6d6d3cbfdb68c470084aaa3c68 (patch)
tree8be008625423f80c09a97292d66eff91ac987834 /src/misc_cmd.cpp
parent46441ac31c2e305dc1b82a4a5ff3df74ffb735e5 (diff)
downloadopenttd-8c5c0e9367080e6d6d3cbfdb68c470084aaa3c68.tar.xz
(svn r11573) -Codechange: pause games that miss GRFs by default and throw some warnings and disclaimers when you want to unpause it.
Diffstat (limited to 'src/misc_cmd.cpp')
-rw-r--r--src/misc_cmd.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp
index dd7570d72..c30d62d61 100644
--- a/src/misc_cmd.cpp
+++ b/src/misc_cmd.cpp
@@ -294,6 +294,17 @@ CommandCost CmdChangePresidentName(TileIndex tile, uint32 flags, uint32 p1, uint
return CommandCost();
}
+/**
+ * In case of an unsafe unpause, we want the
+ * user to confirm that it might crash.
+ * @param w unused
+ * @param confirmed whether the user confirms his/her action
+ */
+static void AskUnsafeUnpauseCallback(Window *w, bool confirmed)
+{
+ DoCommandP(0, confirmed ? 0 : 1, 0, NULL, CMD_PAUSE);
+}
+
/** Pause/Unpause the game (server-only).
* Increase or decrease the pause counter. If the counter is zero,
* the game is unpaused. A counter is used instead of a boolean value
@@ -307,7 +318,24 @@ CommandCost CmdPause(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
if (flags & DC_EXEC) {
_pause_game += (p1 == 1) ? 1 : -1;
- if (_pause_game == (byte)-1) _pause_game = 0;
+
+ switch (_pause_game) {
+ case (byte)-4:
+ case (byte)-1:
+ _pause_game = 0;
+ break;
+ case (byte)-3:
+ ShowQuery(
+ STR_NEWGRF_UNPAUSE_WARNING_TITLE,
+ STR_NEWGRF_UNPAUSE_WARNING,
+ NULL,
+ AskUnsafeUnpauseCallback
+ );
+ break;
+
+ default: break;
+ }
+
InvalidateWindow(WC_STATUS_BAR, 0);
InvalidateWindow(WC_MAIN_TOOLBAR, 0);
}