diff --git a/src/economy_func.h b/src/economy_func.h index eb9a04f487..5ed17bc2a1 100644 --- a/src/economy_func.h +++ b/src/economy_func.h @@ -31,7 +31,7 @@ int UpdateCompanyRatingAndValue(Company *c, bool update); void StartupIndustryDailyChanges(bool init_counter); Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16_t transit_periods, CargoID cargo_type); -uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations, Owner exclusivity = INVALID_OWNER); +uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList &all_stations, Owner exclusivity = INVALID_OWNER); void PrepareUnload(Vehicle *front_v); void LoadUnloadStation(Station *st); diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 70ac5f6c52..0c8d02fda5 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -535,7 +535,7 @@ static bool TransportIndustryGoods(TileIndex tile) p.history[THIS_MONTH].production += cw; - uint am = MoveGoodsToStation(p.cargo, cw, SourceType::Industry, i->index, &i->stations_near, i->exclusive_consumer); + uint am = MoveGoodsToStation(p.cargo, cw, SourceType::Industry, i->index, i->stations_near, i->exclusive_consumer); p.history[THIS_MONTH].transported += am; moved_cargo |= (am != 0); diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp index ca4e771dd1..ee166c84ff 100644 --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -455,11 +455,10 @@ static uint32_t GetDistanceFromNearbyHouse(uint8_t parameter, TileIndex tile, Ho TileIndex testtile = Map::WrapToMap(this->tile + TileDiffXY(x_offs, y_offs)); StationFinder stations(TileArea(testtile, 1, 1)); - const StationList *sl = stations.GetStations(); /* Collect acceptance stats. */ uint32_t res = 0; - for (Station *st : *sl) { + for (Station *st : stations.GetStations()) { if (HasBit(st->goods[cid].status, GoodsEntry::GES_EVER_ACCEPTED)) SetBit(res, 0); if (HasBit(st->goods[cid].status, GoodsEntry::GES_LAST_MONTH)) SetBit(res, 1); if (HasBit(st->goods[cid].status, GoodsEntry::GES_CURRENT_MONTH)) SetBit(res, 2); diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 82d13ac694..7dac954c89 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -4344,10 +4344,10 @@ CommandCost CmdRenameStation(DoCommandFlag flags, StationID station_id, const st return CommandCost(); } -static void AddNearbyStationsByCatchment(TileIndex tile, StationList *stations, StationList &nearby) +static void AddNearbyStationsByCatchment(TileIndex tile, StationList &stations, StationList &nearby) { for (Station *st : nearby) { - if (st->TileIsInCatchment(tile)) stations->insert(st); + if (st->TileIsInCatchment(tile)) stations.insert(st); } } @@ -4355,13 +4355,13 @@ static void AddNearbyStationsByCatchment(TileIndex tile, StationList *stations, * Run a tile loop to find stations around a tile, on demand. Cache the result for further requests * @return pointer to a StationList containing all stations found */ -const StationList *StationFinder::GetStations() +const StationList &StationFinder::GetStations() { if (this->tile != INVALID_TILE) { if (IsTileType(this->tile, MP_HOUSE)) { /* Town nearby stations need to be filtered per tile. */ assert(this->w == 1 && this->h == 1); - AddNearbyStationsByCatchment(this->tile, &this->stations, Town::GetByTile(this->tile)->stations_near); + AddNearbyStationsByCatchment(this->tile, this->stations, Town::GetByTile(this->tile)->stations_near); } else { ForAllStationsAroundTiles(*this, [this](Station *st, TileIndex) { this->stations.insert(st); @@ -4370,7 +4370,7 @@ const StationList *StationFinder::GetStations() } this->tile = INVALID_TILE; } - return &this->stations; + return this->stations; } @@ -4395,17 +4395,17 @@ static bool CanMoveGoodsToStation(const Station *st, CargoID type) return true; } -uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations, Owner exclusivity) +uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList &all_stations, Owner exclusivity) { /* Return if nothing to do. Also the rounding below fails for 0. */ - if (all_stations->empty()) return 0; + if (all_stations.empty()) return 0; if (amount == 0) return 0; Station *first_station = nullptr; typedef std::pair StationInfo; std::vector used_stations; - for (Station *st : *all_stations) { + for (Station *st : all_stations) { if (exclusivity != INVALID_OWNER && exclusivity != st->owner) continue; if (!CanMoveGoodsToStation(st, type)) continue; diff --git a/src/station_type.h b/src/station_type.h index 2d29e76946..bec8bcbae6 100644 --- a/src/station_type.h +++ b/src/station_type.h @@ -105,7 +105,7 @@ public: * @param area the area to search from */ StationFinder(const TileArea &area) : TileArea(area) {} - const StationList *GetStations(); + const StationList &GetStations(); }; #endif /* STATION_TYPE_H */