mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-17 21:25:40 +00:00
(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.
This commit is contained in:
parent
37abff2c47
commit
00558b779d
@ -912,17 +912,15 @@ void DeleteVehicleNews(VehicleID vid, StringID news)
|
|||||||
w = FindWindowById(WC_NEWS_WINDOW, 0);
|
w = FindWindowById(WC_NEWS_WINDOW, 0);
|
||||||
visible_news = (w != NULL) ? (NewsID)(WP(w, news_d).ni - _news_items) : INVALID_NEWS;
|
visible_news = (w != NULL) ? (NewsID)(WP(w, news_d).ni - _news_items) : INVALID_NEWS;
|
||||||
|
|
||||||
i = n;
|
for (i = n;; i = decreaseIndex(i)) {
|
||||||
do {
|
|
||||||
_news_items[i] = _news_items[decreaseIndex(i)];
|
_news_items[i] = _news_items[decreaseIndex(i)];
|
||||||
|
|
||||||
if (i == _current_news) _current_news = increaseIndex(_current_news);
|
if (i == _current_news) _current_news = increaseIndex(_current_news);
|
||||||
if (i == _forced_news) _forced_news = increaseIndex(_forced_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 == visible_news) WP(w, news_d).ni = &_news_items[increaseIndex(visible_news)];
|
||||||
|
|
||||||
i = decreaseIndex(i);
|
if (i == _oldest_news) break;
|
||||||
} while (i != _oldest_news);
|
}
|
||||||
|
|
||||||
_oldest_news = increaseIndex(_oldest_news);
|
_oldest_news = increaseIndex(_oldest_news);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user