forked from mirror/OpenTTD
(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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user