Codechange: Unify random trigger enums and turn them into enum classes. (#14066)

This commit is contained in:
frosch
2025-04-21 20:03:34 +02:00
committed by GitHub
parent f399b8eb29
commit 61a0a520f6
28 changed files with 185 additions and 148 deletions

View File

@@ -1167,7 +1167,7 @@ static void TriggerIndustryProduction(Industry *i)
}
}
TriggerIndustryRandomisation(i, INDUSTRY_TRIGGER_RECEIVED_CARGO);
TriggerIndustryRandomisation(i, IndustryRandomTrigger::CargoReceived);
TriggerIndustryAnimation(i, IAT_INDUSTRY_RECEIVED_CARGO);
}
@@ -1779,7 +1779,7 @@ static void LoadUnloadVehicle(Vehicle *front)
/* If there's goods waiting at the station, and the vehicle
* has capacity for it, load it on the vehicle. */
if ((v->cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0 || (ge->HasData() && ge->GetData().cargo.AvailableCount() > 0)) && MayLoadUnderExclusiveRights(st, v)) {
if (v->cargo.StoredCount() == 0) TriggerVehicleRandomisation(v, VEHICLE_TRIGGER_NEW_CARGO);
if (v->cargo.StoredCount() == 0) TriggerVehicleRandomisation(v, VehicleRandomTrigger::NewCargo);
if (_settings_game.order.gradual_loading) cap_left = std::min(cap_left, GetLoadAmount(v));
uint loaded = ge->GetOrCreateData().cargo.Load(cap_left, &v->cargo, next_station, v->GetCargoTile());
@@ -1811,10 +1811,10 @@ static void LoadUnloadVehicle(Vehicle *front)
st->last_vehicle_type = v->type;
if (ge->GetData().cargo.TotalCount() == 0) {
TriggerStationRandomisation(st, st->xy, SRT_CARGO_TAKEN, v->cargo_type);
TriggerStationRandomisation(st, st->xy, StationRandomTrigger::CargoTaken, v->cargo_type);
TriggerStationAnimation(st, st->xy, SAT_CARGO_TAKEN, v->cargo_type);
TriggerAirportAnimation(st, AAT_STATION_CARGO_TAKEN, v->cargo_type);
TriggerRoadStopRandomisation(st, st->xy, RSRT_CARGO_TAKEN, v->cargo_type);
TriggerRoadStopRandomisation(st, st->xy, StationRandomTrigger::CargoTaken, v->cargo_type);
TriggerRoadStopAnimation(st, st->xy, SAT_CARGO_TAKEN, v->cargo_type);
}
@@ -1834,10 +1834,10 @@ static void LoadUnloadVehicle(Vehicle *front)
if (anything_loaded || anything_unloaded) {
if (front->type == VEH_TRAIN) {
TriggerStationRandomisation(st, front->tile, SRT_TRAIN_LOADS);
TriggerStationRandomisation(st, front->tile, StationRandomTrigger::VehicleLoads);
TriggerStationAnimation(st, front->tile, SAT_TRAIN_LOADS);
} else if (front->type == VEH_ROAD) {
TriggerRoadStopRandomisation(st, front->tile, RSRT_VEH_LOADS);
TriggerRoadStopRandomisation(st, front->tile, StationRandomTrigger::VehicleLoads);
TriggerRoadStopAnimation(st, front->tile, SAT_TRAIN_LOADS);
}
}
@@ -1910,7 +1910,7 @@ static void LoadUnloadVehicle(Vehicle *front)
/* Make sure the vehicle is marked dirty, since we need to update the NewGRF
* properties such as weight, power and TE whenever the trigger runs. */
dirty_vehicle = true;
TriggerVehicleRandomisation(front, VEHICLE_TRIGGER_EMPTY);
TriggerVehicleRandomisation(front, VehicleRandomTrigger::Empty);
}
if (dirty_vehicle) {