(svn r17147) -Fix [FS#3048]: Keep vehicle news and viewports following vehicles, when autoreplacing/renewing them.

This commit is contained in:
frosch
2009-08-10 20:06:39 +00:00
parent 238b0e43bb
commit 52f9b8ffbd
6 changed files with 63 additions and 6 deletions

View File

@@ -673,6 +673,29 @@ void RemoveOldNewsItems()
}
}
/**
* Report a change in vehicle IDs (due to autoreplace) to affected vehicle news.
* @note Viewports of currently displayed news is changed via #ChangeVehicleViewports
* @param from_index the old vehicle ID
* @param to_index the new vehicle ID
*/
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 NS_ADVICE news have vehicle IDs in their DParams.
* And all NS_ADVICE news have the ID in param 0.
*/
if (ni->subtype == NS_ADVICE && ni->params[0] == from_index) ni->params[0] = to_index;
}
}
void NewsLoop()
{
/* no news item yet */