(svn r21987) -Fix: Make news items, engine previews and AI preview events deal with no longer existing Engine items after resetting the pool.

This commit is contained in:
frosch
2011-02-05 20:41:13 +00:00
parent faa2a26ae1
commit ef3ec0f8c8
6 changed files with 41 additions and 0 deletions

View File

@@ -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;