MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ModifyStationRatingAround

Function ModifyStationRatingAround

src/station_cmd.cpp:4388–4399  ·  view source on GitHub ↗

* Forcibly modify station ratings near a given tile. * Used when a crash hurts a company's station ratings nearby, or when local authority actions affect nearby ratings. * @param tile The center of the ratings change area. * @param owner The station owner whose stations are affected. * @param amount The amount to change the rating. * @param radius The radius to search for stations, from the o

Source from the content-addressed store, hash-verified

4386 * @param radius The radius to search for stations, from the origin tile.
4387 */
4388void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint radius)
4389{
4390 ForAllStationsRadius(tile, radius, [&](Station *st) {
4391 if (st->owner == owner && DistanceManhattan(tile, st->xy) <= radius) {
4392 for (GoodsEntry &ge : st->goods) {
4393 if (ge.status.Any()) {
4394 ge.rating = ClampTo<uint8_t>(ge.rating + amount);
4395 }
4396 }
4397 }
4398 });
4399}
4400
4401static uint UpdateStationWaiting(Station *st, CargoType cargo, uint amount, Source source)
4402{

Callers 7

CheckTrainCollisionFunction · 0.85
RoadVehCrashFunction · 0.85
CrashAirplaneFunction · 0.85
TownActionAdvertiseSmallFunction · 0.85
TownActionAdvertiseLargeFunction · 0.85
TownActionBuyRightsFunction · 0.85

Calls 3

ForAllStationsRadiusFunction · 0.85
DistanceManhattanFunction · 0.85
AnyMethod · 0.80

Tested by

no test coverage detected