summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2007-01-26 00:25:39 +0000
committerDarkvater <Darkvater@openttd.org>2007-01-26 00:25:39 +0000
commit783902838e4d3b45e595536d9d95bc02c686f6e9 (patch)
tree1d69c10e1a1d7db35968224f9cf455de4ea1217c /src
parent4dd7a61a5054dfb87cd4a5d5ba18554ca7c7079a (diff)
downloadopenttd-783902838e4d3b45e595536d9d95bc02c686f6e9.tar.xz
(svn r8409) -Regression (r8049): When the latest news was deleted, the news queue wrapped back to the oldest item, showing all news again.
-Regression [FS#573] (r8049): ShowLastNewsMessage could show an out-of-bounds news item because it did not checked if a previous item actually existed the first time it is called (forced news is INVALID_NEWS).
Diffstat (limited to 'src')
-rw-r--r--src/news_gui.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 0119429ca..7a2432f57 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -559,7 +559,7 @@ void ShowLastNewsMessage(void)
/* Not forced any news yet, show the current one, unless a news window is
* open (which can only be the current one), then show the previous item */
const Window *w = FindWindowById(WC_NEWS_WINDOW, 0);
- ShowNewsMessage((w == NULL) ? _current_news : decreaseIndex(_current_news));
+ ShowNewsMessage((w == NULL || (_current_news == _oldest_news)) ? _current_news : decreaseIndex(_current_news));
} else if (_forced_news == _oldest_news) {
/* We have reached the oldest news, start anew with the latest */
ShowNewsMessage(_latest_news);
@@ -918,9 +918,11 @@ void DeleteVehicleNews(VehicleID vid, StringID news)
for (NewsID i = n;; i = decreaseIndex(i)) {
_news_items[i] = _news_items[decreaseIndex(i)];
- if (i == _current_news) _current_news = increaseIndex(_current_news);
- if (i == _forced_news) _forced_news = increaseIndex(_forced_news);
- if (i == visible_news) WP(w, news_d).ni = &_news_items[increaseIndex(visible_news)];
+ if (i != _latest_news) {
+ if (i == _current_news) _current_news = increaseIndex(_current_news);
+ if (i == _forced_news) _forced_news = increaseIndex(_forced_news);
+ if (i == visible_news) WP(w, news_d).ni = &_news_items[increaseIndex(visible_news)];
+ }
if (i == _oldest_news) break;
}