diff options
author | smatz <smatz@openttd.org> | 2008-09-13 10:19:51 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2008-09-13 10:19:51 +0000 |
commit | 66be028ad4bb32758115ad10e542104b80d79eed (patch) | |
tree | 13719aee50b7d6e902e7f4499a4cd1c9311ea099 /src | |
parent | fc62d736f700ca344531a96ca02324695af8d761 (diff) | |
download | openttd-66be028ad4bb32758115ad10e542104b80d79eed.tar.xz |
(svn r14307) -Fix: when deleting a station, remove news items regarding it
Diffstat (limited to 'src')
-rw-r--r-- | src/aircraft_cmd.cpp | 3 | ||||
-rw-r--r-- | src/news_func.h | 4 | ||||
-rw-r--r-- | src/news_gui.cpp | 23 | ||||
-rw-r--r-- | src/roadveh_cmd.cpp | 5 | ||||
-rw-r--r-- | src/ship_cmd.cpp | 3 | ||||
-rw-r--r-- | src/station.cpp | 4 | ||||
-rw-r--r-- | src/station_cmd.cpp | 2 | ||||
-rw-r--r-- | src/train_cmd.cpp | 2 |
8 files changed, 40 insertions, 6 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 7a6d45c19..c09dd852b 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -1402,7 +1402,8 @@ static void AircraftEntersTerminal(Vehicle *v) STR_A033_CITIZENS_CELEBRATE_FIRST, (v->owner == _local_player) ? NS_ARRIVAL_PLAYER : NS_ARRIVAL_OTHER, v->index, - 0); + st->index + ); } v->BeginLoading(); diff --git a/src/news_func.h b/src/news_func.h index 8ec0e0116..40391fdba 100644 --- a/src/news_func.h +++ b/src/news_func.h @@ -7,6 +7,7 @@ #include "news_type.h" #include "vehicle_type.h" +#include "station_type.h" void AddNewsItem(StringID string, NewsSubtype subtype, uint data_a, uint data_b, void *free_data = NULL); void NewsLoop(); @@ -24,4 +25,7 @@ extern NewsTypeData _news_type_data[NT_END]; */ void DeleteVehicleNews(VehicleID, StringID news); +/** Delete news associated with given station */ +void DeleteStationNews(StationID); + #endif /* NEWS_FUNC_H */ diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 8cd973a1c..fb4f1e3f9 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -579,6 +579,29 @@ void DeleteVehicleNews(VehicleID vid, StringID news) } } +/** Remove news regarding given station so there are no 'unknown station now accepts Mail' + * or 'First train arrived at unknown station' news items. + * @param sid station to remove news about + */ +void DeleteStationNews(StationID sid) +{ + NewsItem *ni = _oldest_news; + + while (ni != NULL) { + NewsItem *next = ni->next; + switch (ni->subtype) { + case NS_ARRIVAL_PLAYER: + case NS_ARRIVAL_OTHER: + case NS_ACCEPTANCE: + if (ni->data_b == sid) DeleteNewsItem(ni); + break; + default: + break; + } + ni = next; + } +} + void RemoveOldNewsItems() { NewsItem *next; diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index bccac5a19..315499eb9 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -807,7 +807,8 @@ static void RoadVehArrivesAt(const Vehicle* v, Station* st) v->u.road.roadtype == ROADTYPE_ROAD ? STR_902F_CITIZENS_CELEBRATE_FIRST : STR_CITIZENS_CELEBRATE_FIRST_PASSENGER_TRAM, (v->owner == _local_player) ? NS_ARRIVAL_PLAYER : NS_ARRIVAL_OTHER, v->index, - 0); + st->index + ); } } else { /* Check if station was ever visited before */ @@ -818,7 +819,7 @@ static void RoadVehArrivesAt(const Vehicle* v, Station* st) v->u.road.roadtype == ROADTYPE_ROAD ? STR_9030_CITIZENS_CELEBRATE_FIRST : STR_CITIZENS_CELEBRATE_FIRST_CARGO_TRAM, (v->owner == _local_player) ? NS_ARRIVAL_PLAYER : NS_ARRIVAL_OTHER, v->index, - 0 + st->index ); } } diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 8d28a406c..cd7fe29a1 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -351,7 +351,8 @@ static void ShipArrivesAt(const Vehicle* v, Station* st) STR_9833_CITIZENS_CELEBRATE_FIRST, (v->owner == _local_player) ? NS_ARRIVAL_PLAYER : NS_ARRIVAL_OTHER, v->index, - 0); + st->index + ); } } diff --git a/src/station.cpp b/src/station.cpp index 4a7ac92f0..b74ef3783 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -31,6 +31,7 @@ #include "settings_type.h" #include "command_func.h" #include "order_func.h" +#include "news_func.h" #include "table/sprites.h" #include "table/strings.h" @@ -84,6 +85,9 @@ Station::~Station() /* Subsidies need removal as well */ DeleteSubsidyWithStation(index); + /* Remove all news items */ + DeleteStationNews(this->index); + xy = 0; for (CargoID c = 0; c < NUM_CARGO; c++) { diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 0a1eedb5c..563b2339b 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -411,7 +411,7 @@ static void ShowRejectOrAcceptNews(const Station *st, uint num_items, CargoID *c } SetDParam(0, st->index); - AddNewsItem(msg, NS_ACCEPTANCE, st->xy, 0); + AddNewsItem(msg, NS_ACCEPTANCE, st->xy, st->index); } /** diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index f03e1a06b..c87e08276 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -3251,7 +3251,7 @@ static void TrainEnterStation(Vehicle *v, StationID station) STR_8801_CITIZENS_CELEBRATE_FIRST, v->owner == _local_player ? NS_ARRIVAL_PLAYER : NS_ARRIVAL_OTHER, v->index, - 0 + st->index ); } |