mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(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.
This commit is contained in:
parent
dab9de2e61
commit
792d1bd883
@ -123,7 +123,9 @@
|
|||||||
if (!IsValidIndustry(industry_id)) return -1;
|
if (!IsValidIndustry(industry_id)) return -1;
|
||||||
|
|
||||||
Industry *ind = ::GetIndustry(industry_id);
|
Industry *ind = ::GetIndustry(industry_id);
|
||||||
return (int32)::FindStationsAroundTiles(ind->xy, ind->width, ind->height).Length();
|
StationList stations;
|
||||||
|
::FindStationsAroundTiles(ind->xy, ind->width, ind->height, &stations);
|
||||||
|
return (int32)stations.Length();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ int32 AIIndustry::GetDistanceManhattanToTile(IndustryID industry_id, TileIndex tile)
|
/* static */ int32 AIIndustry::GetDistanceManhattanToTile(IndustryID industry_id, TileIndex tile)
|
||||||
|
@ -1992,7 +1992,8 @@ static void CanCargoServiceIndustry(CargoID cargo, Industry *ind, bool *c_accept
|
|||||||
int WhoCanServiceIndustry(Industry *ind)
|
int WhoCanServiceIndustry(Industry *ind)
|
||||||
{
|
{
|
||||||
/* Find all stations within reach of the industry */
|
/* Find all stations within reach of the industry */
|
||||||
StationList stations = FindStationsAroundTiles(ind->xy, ind->width, ind->height);
|
StationList stations;
|
||||||
|
FindStationsAroundTiles(ind->xy, ind->width, ind->height, &stations);
|
||||||
|
|
||||||
if (stations.Length() == 0) return 0; // No stations found at all => nobody services
|
if (stations.Length() == 0) return 0; // No stations found at all => nobody services
|
||||||
|
|
||||||
|
@ -2940,10 +2940,8 @@ CommandCost CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2,
|
|||||||
*
|
*
|
||||||
* @return: Set of found stations
|
* @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 */
|
/* area to search = producer plus station catchment radius */
|
||||||
int max_rad = (_settings_game.station.modified_catchment ? MAX_CATCHMENT : CA_UNMODIFIED);
|
int max_rad = (_settings_game.station.modified_catchment ? MAX_CATCHMENT : CA_UNMODIFIED);
|
||||||
int w = w_prod + 2 * max_rad;
|
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
|
/* Insert the station in the set. This will fail if it has
|
||||||
* already been added.
|
* already been added.
|
||||||
*/
|
*/
|
||||||
stations.Include(st);
|
stations->Include(st);
|
||||||
|
|
||||||
END_TILE_LOOP(cur_tile, w, h, tile - TileDiffXY(max_rad, max_rad))
|
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)
|
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_rating1 = 0; // rating of st1
|
||||||
uint best_rating2 = 0; // rating of st2
|
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) {
|
for (Station **st_iter = all_stations.Begin(); st_iter != all_stations.End(); ++st_iter) {
|
||||||
Station *st = *st_iter;
|
Station *st = *st_iter;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint radius);
|
void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint radius);
|
||||||
|
|
||||||
typedef SmallVector<Station*, 1> StationList;
|
typedef SmallVector<Station*, 1> StationList;
|
||||||
StationList FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod);
|
void FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod, StationList *stations);
|
||||||
|
|
||||||
void ShowStationViewWindow(StationID station);
|
void ShowStationViewWindow(StationID station);
|
||||||
void UpdateAllStationVirtCoord();
|
void UpdateAllStationVirtCoord();
|
||||||
|
Loading…
Reference in New Issue
Block a user