mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-17 21:25:40 +00:00
(svn r7368) -Fix: [FS#332] Vehicle Deletion Crash [News Window Related?] (r3757).
This commit is contained in:
parent
941e6248cf
commit
8df7ca8f4a
14
news_gui.c
14
news_gui.c
@ -253,6 +253,7 @@ void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b)
|
|||||||
{
|
{
|
||||||
NewsItem *ni;
|
NewsItem *ni;
|
||||||
Window *w;
|
Window *w;
|
||||||
|
byte l_news;
|
||||||
|
|
||||||
if (_game_mode == GM_MENU) return;
|
if (_game_mode == GM_MENU) return;
|
||||||
|
|
||||||
@ -264,10 +265,11 @@ void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b)
|
|||||||
if (_total_news < MAX_NEWS) _total_news++;
|
if (_total_news < MAX_NEWS) _total_news++;
|
||||||
|
|
||||||
// make sure our pointer isn't overflowing
|
// make sure our pointer isn't overflowing
|
||||||
|
l_news = _latest_news;
|
||||||
_latest_news = increaseIndex(_latest_news);
|
_latest_news = increaseIndex(_latest_news);
|
||||||
|
|
||||||
// overwrite oldest news entry
|
/* If the fifo-buffer is full, overwrite the oldest entry */
|
||||||
if (_oldest_news == _latest_news && _news_items[_oldest_news].string_id != 0)
|
if (l_news != INVALID_NEWS && _latest_news == _oldest_news)
|
||||||
_oldest_news = increaseIndex(_oldest_news); // but make sure we're not overflowing here
|
_oldest_news = increaseIndex(_oldest_news); // but make sure we're not overflowing here
|
||||||
|
|
||||||
// add news to _latest_news
|
// add news to _latest_news
|
||||||
@ -889,10 +891,12 @@ void DeleteVehicleNews(VehicleID vid, StringID news)
|
|||||||
// If this is the last news item, invalidate _latest_news
|
// If this is the last news item, invalidate _latest_news
|
||||||
if (_latest_news == _oldest_news) _latest_news = INVALID_NEWS;
|
if (_latest_news == _oldest_news) _latest_news = INVALID_NEWS;
|
||||||
|
|
||||||
for (i = n; i != _oldest_news; i = (i + MAX_NEWS - 1) % MAX_NEWS) {
|
if (n != _oldest_news) {
|
||||||
_news_items[i] = _news_items[(i + MAX_NEWS - 1) % MAX_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 = increaseIndex(_oldest_news);
|
||||||
}
|
}
|
||||||
_oldest_news = (_oldest_news + 1) % MAX_NEWS;
|
|
||||||
_total_news--;
|
_total_news--;
|
||||||
|
|
||||||
w = FindWindowById(WC_MESSAGE_HISTORY, 0);
|
w = FindWindowById(WC_MESSAGE_HISTORY, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user