diff options
author | rubidium <rubidium@openttd.org> | 2008-07-18 16:26:51 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-07-18 16:26:51 +0000 |
commit | 891bec7e23a0a077df93b8fd1fe156ef059df8b4 (patch) | |
tree | 71817bf7af4429f1e29b23c2bb0148ca8b0bea3c /src/news_gui.cpp | |
parent | e48d86fad0a384335fa4c49a4f15032bee54b16e (diff) | |
download | openttd-891bec7e23a0a077df93b8fd1fe156ef059df8b4.tar.xz |
(svn r13730) -Fix: make a copy of the names for news messages about the deletion of companies as the removal of a company could lead to wrong names in the news messages.
Diffstat (limited to 'src/news_gui.cpp')
-rw-r--r-- | src/news_gui.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 68caa9fae..06df253b2 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -49,19 +49,19 @@ void DrawNewsNewVehicleAvail(Window *w, const NewsItem *ni); static void DrawNewsBankrupcy(Window *w, const NewsItem *ni) { - Player *p = GetPlayer((PlayerID)(ni->data_b)); - DrawPlayerFace(p->face, p->player_color, 2, 23); - GfxFillRect(3, 23, 3 + 91, 23 + 118, PALETTE_TO_STRUCT_GREY, FILLRECT_RECOLOR); + const CompanyNewsInformation *cni = (const CompanyNewsInformation*)ni->free_data; - SetDParam(0, p->index); + DrawPlayerFace(cni->face, cni->colour, 2, 23); + GfxFillRect(3, 23, 3 + 91, 23 + 118, PALETTE_TO_STRUCT_GREY, FILLRECT_RECOLOR); - DrawStringMultiCenter(49, 148, STR_7058_PRESIDENT, 94); + SetDParamStr(0, cni->president_name); + DrawStringMultiCenter(49, 148, STR_JUST_RAW_STRING, 94); switch (ni->subtype) { case NS_COMPANY_TROUBLE: DrawStringCentered(w->width >> 1, 1, STR_7056_TRANSPORT_COMPANY_IN_TROUBLE, TC_FROMSTRING); - SetDParam(0, p->index); + SetDParam(0, ni->params[2]); DrawStringMultiCenter( ((w->width - 101) >> 1) + 98, @@ -73,7 +73,7 @@ static void DrawNewsBankrupcy(Window *w, const NewsItem *ni) case NS_COMPANY_MERGER: DrawStringCentered(w->width >> 1, 1, STR_7059_TRANSPORT_COMPANY_MERGER, TC_FROMSTRING); SetDParam(0, ni->params[2]); - SetDParam(1, p->index); + SetDParam(1, ni->params[3]); SetDParam(2, ni->params[4]); DrawStringMultiCenter( ((w->width - 101) >> 1) + 98, @@ -84,7 +84,7 @@ static void DrawNewsBankrupcy(Window *w, const NewsItem *ni) case NS_COMPANY_BANKRUPT: DrawStringCentered(w->width >> 1, 1, STR_705C_BANKRUPT, TC_FROMSTRING); - SetDParam(0, p->index); + SetDParam(0, ni->params[2]); DrawStringMultiCenter( ((w->width - 101) >> 1) + 98, 90, @@ -94,7 +94,7 @@ static void DrawNewsBankrupcy(Window *w, const NewsItem *ni) case NS_COMPANY_NEW: DrawStringCentered(w->width >> 1, 1, STR_705E_NEW_TRANSPORT_COMPANY_LAUNCHED, TC_FROMSTRING); - SetDParam(0, p->index); + SetDParam(0, ni->params[2]); SetDParam(1, ni->params[3]); DrawStringMultiCenter( ((w->width - 101) >> 1) + 98, @@ -485,7 +485,7 @@ static void MoveToNextItem() * * @see NewsSubype */ -void AddNewsItem(StringID string, NewsSubtype subtype, uint data_a, uint data_b) +void AddNewsItem(StringID string, NewsSubtype subtype, uint data_a, uint data_b, void *free_data) { if (_game_mode == GM_MENU) return; @@ -501,6 +501,7 @@ void AddNewsItem(StringID string, NewsSubtype subtype, uint data_a, uint data_b) ni->data_a = data_a; ni->data_b = data_b; + ni->free_data = free_data; ni->date = _date; CopyOutDParam(ni->params, 0, lengthof(ni->params)); @@ -549,6 +550,8 @@ static void DeleteNewsItem(NewsItem *ni) _latest_news = ni->prev; } + free(ni->free_data); + if (_current_news == ni) _current_news = ni->prev; _total_news--; delete ni; |