summaryrefslogtreecommitdiff
path: root/src/station_cmd.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2009-01-13 20:43:53 +0000
committerpeter1138 <peter1138@openttd.org>2009-01-13 20:43:53 +0000
commit4585d9785da5d93e9b7d99daa02f4e6aa6dd21c3 (patch)
tree4f3979be8f4424ca7b44a2e80ec1de5621a609c9 /src/station_cmd.cpp
parentf70b4c5ae448e8775883007af1baa32084957f73 (diff)
downloadopenttd-4585d9785da5d93e9b7d99daa02f4e6aa6dd21c3.tar.xz
(svn r15073) -Fix (r15067) [FS#2532]: Default copy constructors don't necessarily do what you want. Instead of creating one, we now pass a pointer around as that avoids additional allocations.
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r--src/station_cmd.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 9c3529390..8085af255 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2940,10 +2940,8 @@ CommandCost CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2,
*
* @return: Set of found stations
*/
-StationList FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod)
+void FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod, StationList *stations)
{
- StationList stations;
-
/* area to search = producer plus station catchment radius */
int max_rad = (_settings_game.station.modified_catchment ? MAX_CATCHMENT : CA_UNMODIFIED);
int w = w_prod + 2 * max_rad;
@@ -2989,11 +2987,9 @@ StationList FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod)
/* Insert the station in the set. This will fail if it has
* already been added.
*/
- stations.Include(st);
+ stations->Include(st);
END_TILE_LOOP(cur_tile, w, h, tile - TileDiffXY(max_rad, max_rad))
-
- return stations;
}
uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount)
@@ -3003,7 +2999,8 @@ uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount)
uint best_rating1 = 0; // rating of st1
uint best_rating2 = 0; // rating of st2
- StationList all_stations = FindStationsAroundTiles(tile, w, h);
+ StationList all_stations;
+ FindStationsAroundTiles(tile, w, h, &all_stations);
for (Station **st_iter = all_stations.Begin(); st_iter != all_stations.End(); ++st_iter) {
Station *st = *st_iter;