summaryrefslogtreecommitdiff
path: root/src/news_gui.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2007-01-05 11:41:11 +0000
committerDarkvater <darkvater@openttd.org>2007-01-05 11:41:11 +0000
commit2d3e7aef5165d0991e3bcecb745757e13f9b6c9c (patch)
tree57835683cf2036f7639d2dbdba7623cc66e0b60e /src/news_gui.c
parenteb42782d6ae847f937303b2905dea620813de256 (diff)
downloadopenttd-2d3e7aef5165d0991e3bcecb745757e13f9b6c9c.tar.xz
(svn r7861) -Fix (r7823): Crash when oldest news was deleted. First check the index for oldest news
and THEN decrease index, not the other way around.
Diffstat (limited to 'src/news_gui.c')
-rw-r--r--src/news_gui.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/news_gui.c b/src/news_gui.c
index 77098744d..677a87765 100644
--- a/src/news_gui.c
+++ b/src/news_gui.c
@@ -912,17 +912,15 @@ void DeleteVehicleNews(VehicleID vid, StringID news)
w = FindWindowById(WC_NEWS_WINDOW, 0);
visible_news = (w != NULL) ? (NewsID)(WP(w, news_d).ni - _news_items) : INVALID_NEWS;
- i = n;
- do {
+ for (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)];
- i = decreaseIndex(i);
- } while (i != _oldest_news);
-
+ if (i == _oldest_news) break;
+ }
_oldest_news = increaseIndex(_oldest_news);
}