summaryrefslogtreecommitdiff
path: root/news_gui.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-04 11:01:35 +0000
committertron <tron@openttd.org>2006-03-04 11:01:35 +0000
commit332b54d5a6156c192e044163d7f38d87e2801814 (patch)
tree2eef654bc6b8956ee2e2ff73c1a3f6e72b920031 /news_gui.c
parentf383a038f0ac86706bcd976ec7a6e5e2de11b720 (diff)
downloadopenttd-332b54d5a6156c192e044163d7f38d87e2801814.tar.xz
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
This is used to delete - all news about a vehicle, when it gets deleted - "vehicle has stopped in depot" news, when it gets started - "vehicle has invalid orders" news, when the orders get changed
Diffstat (limited to 'news_gui.c')
-rw-r--r--news_gui.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/news_gui.c b/news_gui.c
index 5d484436c..1354983ec 100644
--- a/news_gui.c
+++ b/news_gui.c
@@ -865,3 +865,37 @@ void ShowMessageOptions(void)
DeleteWindowById(WC_GAME_OPTIONS, 0);
AllocateWindowDesc(&_message_options_desc);
}
+
+
+void DeleteVehicleNews(VehicleID vid, StringID news)
+{
+ byte n;
+
+ for (n = _oldest_news; _latest_news != INVALID_NEWS && n != _latest_news + 1; n = (n + 1) % MAX_NEWS) {
+ const NewsItem* ni = &_news_items[n];
+
+ if (ni->flags & NF_VEHICLE &&
+ ni->data_a == vid &&
+ (news == INVALID_STRING_ID || ni->string_id == news)) {
+ Window* w;
+ byte i;
+
+ if (_forced_news == n) MoveToNexItem();
+ if (_current_news == n) MoveToNexItem();
+
+ // If this is the last news item, invalidate _latest_news
+ if (_latest_news == _oldest_news) _latest_news = INVALID_NEWS;
+
+ for (i = n; i != _oldest_news; i = (i + MAX_NEWS - 1) % MAX_NEWS) {
+ _news_items[i] = _news_items[(i + MAX_NEWS - 1) % MAX_NEWS];
+ }
+ _oldest_news = (_oldest_news + 1) % MAX_NEWS;
+ _total_news--;
+
+ w = FindWindowById(WC_MESSAGE_HISTORY, 0);
+ if (w == NULL) return;
+ SetWindowDirty(w);
+ w->vscroll.count = _total_news;
+ }
+ }
+}