diff options
author | rubidium <rubidium@openttd.org> | 2009-12-02 16:20:44 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-12-02 16:20:44 +0000 |
commit | 81062163a25497e9d83fd354b53234d1796f675d (patch) | |
tree | 207947eb4a906654b373c62ba6b6fca2fbe96727 /src/station_cmd.cpp | |
parent | 1c65150d6d30e460d1615c907e9c403d45a518ed (diff) | |
download | openttd-81062163a25497e9d83fd354b53234d1796f675d.tar.xz |
(svn r18377) -Codechange: add 'cache' of the tile area of truck and bus stops.
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r-- | src/station_cmd.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 45a534733..347c57dec 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -397,12 +397,12 @@ void Station::GetTileArea(TileArea *ta, StationType type) const return; case STATION_TRUCK: - ta->tile = this->truck_stops != NULL ? this->truck_stops->xy : INVALID_TILE; - break; + *ta = this->truck_station; + return; case STATION_BUS: - ta->tile = this->bus_stops != NULL ? this->bus_stops->xy : INVALID_TILE; - break; + *ta = this->bus_station; + return; case STATION_DOCK: case STATION_OILRIG: @@ -1212,7 +1212,7 @@ restart: } } } else { - ta.tile = INVALID_TILE; + ta.Clear(); } st->train_station = ta; @@ -1427,9 +1427,7 @@ CommandCost RemoveRailStation(T *st, DoCommandFlag flags) if (flags & DC_EXEC) { st->rect.AfterRemoveRect(st, st->train_station.tile, st->train_station.w, st->train_station.h); - st->train_station.tile = INVALID_TILE; - st->train_station.w = 0; - st->train_station.h = 0; + st->train_station.Clear(); st->facilities &= ~FACIL_TRAIN; @@ -1626,6 +1624,12 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin RoadStop **currstop = FindRoadStopSpot(type, st); *currstop = road_stop; + if (type) { + st->truck_station.Add(tile); + } else { + st->bus_station.Add(tile); + } + /* initialize an empty station */ st->AddFacility((type) ? FACIL_TRUCK_STOP : FACIL_BUS_STOP, tile); @@ -1735,6 +1739,15 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags) st->UpdateVirtCoord(); st->RecomputeIndustriesNear(); DeleteStationIfEmpty(st); + + /* Update the tile area of the truck/bus stop */ + if (is_truck) { + st->truck_station.Clear(); + for (const RoadStop *rs = st->truck_stops; rs != NULL; rs = rs->next) st->truck_station.Add(rs->xy); + } else { + st->bus_station.Clear(); + for (const RoadStop *rs = st->bus_stops; rs != NULL; rs = rs->next) st->bus_station.Add(rs->xy); + } } return CommandCost(EXPENSES_CONSTRUCTION, _price[is_truck ? PR_CLEAR_STATION_TRUCK : PR_CLEAR_STATION_BUS]); |