changeset 19384:c159fb3ccce6 draft

(svn r24285) -Codechange: Add a more explcit NewsFlag to indicate that the first string parameter is a vehicle ID.
author frosch <frosch@openttd.org>
date Sat, 26 May 2012 14:16:07 +0000
parents 0c6420024e22
children fd3f780062bf
files src/news_func.h src/news_gui.cpp src/news_type.h
diffstat 3 files changed, 4 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/news_func.h
+++ b/src/news_func.h
@@ -41,7 +41,7 @@
  */
 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)
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -846,15 +846,7 @@
 	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;
 	}
 }
 
--- a/src/news_type.h
+++ b/src/news_type.h
@@ -81,10 +81,12 @@
 	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)