summaryrefslogtreecommitdiff
path: root/src/news_gui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/news_gui.cpp')
-rw-r--r--src/news_gui.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index cf7b3e91b..a958e6392 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -28,6 +28,7 @@
#include "statusbar_gui.h"
#include "company_manager_face.h"
#include "company_func.h"
+#include "engine_base.h"
#include "engine_gui.h"
#include "core/geometry_func.hpp"
@@ -809,6 +810,23 @@ void DeleteIndustryNews(IndustryID iid)
}
}
+/**
+ * Remove engine announcements for invalid engines.
+ */
+void DeleteInvalidEngineNews()
+{
+ NewsItem *ni = _oldest_news;
+
+ while (ni != NULL) {
+ NewsItem *next = ni->next;
+ if ((ni->reftype1 == NR_ENGINE && (!Engine::IsValidID(ni->ref1) || !Engine::Get(ni->ref1)->IsEnabled())) ||
+ (ni->reftype2 == NR_ENGINE && (!Engine::IsValidID(ni->ref2) || !Engine::Get(ni->ref2)->IsEnabled()))) {
+ DeleteNewsItem(ni);
+ }
+ ni = next;
+ }
+}
+
static void RemoveOldNewsItems()
{
NewsItem *next;