From 01100053ff5308e0a07b1faa449255527cc12c31 Mon Sep 17 00:00:00 2001 From: frosch Date: Sat, 26 May 2012 14:16:07 +0000 Subject: [PATCH] (svn r24285) -Codechange: Add a more explcit NewsFlag to indicate that the first string parameter is a vehicle ID. --- src/news_func.h | 2 +- src/news_gui.cpp | 10 +--------- src/news_type.h | 2 ++ 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/news_func.h b/src/news_func.h index b825c686fa..f218db3634 100644 --- a/src/news_func.h +++ b/src/news_func.h @@ -41,7 +41,7 @@ static inline void AddVehicleNewsItem(StringID string, NewsType type, VehicleID */ static inline void AddVehicleAdviceNewsItem(StringID string, VehicleID vehicle) { - AddNewsItem(string, NT_ADVICE, NF_INCOLOUR | NF_SMALL, NR_VEHICLE, vehicle); + AddNewsItem(string, NT_ADVICE, NF_INCOLOUR | NF_SMALL | NF_VEHICLE_PARAM0, NR_VEHICLE, vehicle); } static inline void AddTileNewsItem(StringID string, NewsType type, TileIndex tile, void *free_data = NULL) diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 023cd20825..7efa2b212b 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -846,15 +846,7 @@ void ChangeVehicleNews(VehicleID from_index, VehicleID to_index) for (NewsItem *ni = _oldest_news; ni != NULL; ni = ni->next) { if (ni->reftype1 == NR_VEHICLE && ni->ref1 == from_index) ni->ref1 = to_index; if (ni->reftype2 == NR_VEHICLE && ni->ref2 == from_index) ni->ref2 = to_index; - - /* Oh noes :( - * Autoreplace is breaking the whole news-reference concept here, as we want to keep the news, - * but do not know which DParams to change. - * - * Currently only NT_ADVICE news have vehicle IDs in their DParams. - * And all NT_ADVICE news have the ID in param 0. - */ - if (ni->type == NT_ADVICE && ni->params[0] == from_index) ni->params[0] = to_index; + if (ni->flags & NF_VEHICLE_PARAM0 && ni->params[0] == from_index) ni->params[0] = to_index; } } diff --git a/src/news_type.h b/src/news_type.h index 6029890758..40b6e2c941 100644 --- a/src/news_type.h +++ b/src/news_type.h @@ -81,10 +81,12 @@ enum NewsFlag { NFB_SHADE = 2, ///< News item uses shaded colours. NFB_WINDOW_LAYOUT = 3, ///< First bit for window layout. NFB_WINDOW_LAYOUT_COUNT = 3, ///< Number of bits for window layout. + NFB_VEHICLE_PARAM0 = 6, ///< String param 0 contains a vehicle ID. (special autoreplace behaviour) NF_INCOLOUR = 1 << NFB_INCOLOUR, ///< Bit value for coloured news. NF_NO_TRANSPARENT = 1 << NFB_NO_TRANSPARENT, ///< Bit value for disabling transparency. NF_SHADE = 1 << NFB_SHADE, ///< Bit value for enabling shading. + NF_VEHICLE_PARAM0 = 1 << NFB_VEHICLE_PARAM0, ///< Bit value for specifying that string param 0 contains a vehicle ID. (special autoreplace behaviour) NF_THIN = 0 << NFB_WINDOW_LAYOUT, ///< Thin news item. (Newspaper with headline and viewport) NF_SMALL = 1 << NFB_WINDOW_LAYOUT, ///< Small news item. (Information window with text and viewport)