summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/error.h1
-rw-r--r--src/error_gui.cpp48
-rw-r--r--src/fios_gui.cpp2
-rw-r--r--src/genworld_gui.cpp2
-rw-r--r--src/intro_gui.cpp5
-rw-r--r--src/network/network_client.cpp1
6 files changed, 53 insertions, 6 deletions
diff --git a/src/error.h b/src/error.h
index 75efb75b8..366bcd3ad 100644
--- a/src/error.h
+++ b/src/error.h
@@ -23,5 +23,6 @@ enum WarningLevel {
};
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x = 0, int y = 0, uint textref_stack_size = 0, const uint32 *textref_stack = NULL);
+void ClearErrorMessages();
#endif /* ERROR_H */
diff --git a/src/error_gui.cpp b/src/error_gui.cpp
index d02ebc15c..ee2d5325a 100644
--- a/src/error_gui.cpp
+++ b/src/error_gui.cpp
@@ -25,6 +25,7 @@
#include "window_gui.h"
#include "table/strings.h"
+#include <list>
/** Widgets of the error message windows */
enum ErrorMessageWidgets {
@@ -82,6 +83,7 @@ protected:
Point position; ///< Position of the error message window.
CompanyID face; ///< Company belonging to the face being shown. #INVALID_COMPANY if no face present.
+public:
/**
* Copy the given data into our instace.
* @param data The data to copy.
@@ -91,7 +93,6 @@ protected:
*this = data;
}
-public:
/**
* Display an error message in a window.
* @param summary_msg General error message showed in first line. Must be valid.
@@ -122,6 +123,11 @@ public:
}
};
+/** Define a queue with errors. */
+typedef std::list<ErrorMessageData> ErrorList;
+/** The actual queue with errors. */
+ErrorList _errors;
+
/** Window class for displaying an error message window. */
struct ErrmsgWindow : public Window, ErrorMessageData {
private:
@@ -255,6 +261,11 @@ public:
~ErrmsgWindow()
{
SetRedErrorSquare(INVALID_TILE);
+
+ if (!_errors.empty()) {
+ new ErrmsgWindow(_errors.front());
+ _errors.pop_front();
+ }
}
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
@@ -263,9 +274,26 @@ public:
delete this;
return ES_HANDLED;
}
+
+ /**
+ * Check whether the currently shown error message was critical or not.
+ * @return True iff the message was critical.
+ */
+ bool IsCritical()
+ {
+ return this->duration == 0;
+ }
};
/**
+ * Clear all errors from the queue.
+ */
+void ClearErrorMessages()
+{
+ _errors.clear();
+}
+
+/**
* Display an error message in a window.
* @param summary_msg General error message showed in first line. Must be valid.
* @param detailed_msg Detailed error message showed in second line. Can be INVALID_STRING_ID.
@@ -304,7 +332,19 @@ void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel
if (_settings_client.gui.errmsg_duration == 0 && !no_timeout) return;
- DeleteWindowById(WC_ERRMSG, 0);
- ErrorMessageData data(summary_msg, detailed_msg, no_timeout ? _settings_client.gui.errmsg_duration : 0, x, y, textref_stack_size, textref_stack);
- new ErrmsgWindow(data);
+ ErrorMessageData data(summary_msg, detailed_msg, no_timeout ? 0 : _settings_client.gui.errmsg_duration, x, y, textref_stack_size, textref_stack);
+
+ ErrmsgWindow *w = (ErrmsgWindow*)FindWindowById(WC_ERRMSG, 0);
+ if (w != NULL && w->IsCritical()) {
+ /* A critical error is currently shown. */
+ if (wl == WL_CRITICAL) {
+ /* Push another critical error in the queue of errors,
+ * but do not put other errors in the queue. */
+ _errors.push_back(data);
+ }
+ } else {
+ /* Nothing or a non-critical error was shown. */
+ delete w;
+ new ErrmsgWindow(data);
+ }
}
diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp
index 4a56d2ce6..edafb0977 100644
--- a/src/fios_gui.cpp
+++ b/src/fios_gui.cpp
@@ -546,7 +546,7 @@ public:
strecpy(_file_to_saveload.name, name, lastof(_file_to_saveload.name));
strecpy(_file_to_saveload.title, this->selected->title, lastof(_file_to_saveload.title));
-
+ ClearErrorMessages();
delete this;
}
break;
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index 5cf604091..455d1ae6f 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -29,6 +29,7 @@
#include "core/geometry_func.hpp"
#include "core/random_func.hpp"
#include "progress.h"
+#include "error.h"
#include "table/strings.h"
#include "table/sprites.h"
@@ -305,6 +306,7 @@ static const NWidgetPart _nested_heightmap_load_widgets[] = {
static void StartGeneratingLandscape(GenenerateLandscapeWindowMode mode)
{
DeleteAllNonVitalWindows();
+ ClearErrorMessages();
/* Copy all XXX_newgame to XXX when coming from outside the editor */
MakeNewgameSettingsLive();
diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp
index 388587fb2..e619c5269 100644
--- a/src/intro_gui.cpp
+++ b/src/intro_gui.cpp
@@ -333,7 +333,10 @@ void AskExitGame()
static void AskExitToGameMenuCallback(Window *w, bool confirmed)
{
- if (confirmed) _switch_mode = SM_MENU;
+ if (confirmed) {
+ _switch_mode = SM_MENU;
+ ClearErrorMessages();
+ }
}
void AskExitToGameMenu()
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index cc6c79e8e..c98253648 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -841,6 +841,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(Packet
lf->Reset();
/* The map is done downloading, load it */
+ ClearErrorMessages();
bool load_success = SafeLoad(NULL, SL_LOAD, GM_NORMAL, NO_DIRECTORY, lf);
/* Long savegame loads shouldn't affect the lag calculation! */