Changeset - r19370:36325f02eb9c
[Not reviewed]
master
0 3 0
frosch - 12 years ago 2012-05-26 14:16:07
frosch@openttd.org
(svn r24285) -Codechange: Add a more explcit NewsFlag to indicate that the first string parameter is a vehicle ID.
3 files changed with 4 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/news_func.h
Show inline comments
 
@@ -41,7 +41,7 @@ static inline void AddVehicleNewsItem(St
 
 */
 
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)
src/news_gui.cpp
Show inline comments
 
@@ -846,15 +846,7 @@ void ChangeVehicleNews(VehicleID from_in
 
	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;
 
	}
 
}
 

	
src/news_type.h
Show inline comments
 
@@ -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)
0 comments (0 inline, 0 general)