Codechange: Use EnumBitSet for GRFBug enum.

This commit is contained in:
Peter Nelson
2025-01-31 18:17:13 +00:00
committed by Peter Nelson
parent 292f4baf46
commit 877fa54f66
9 changed files with 26 additions and 25 deletions

View File

@@ -314,7 +314,7 @@ uint Vehicle::Crash(bool)
* @param bug_type Flag to check and set in grfconfig
* @param critical Shall the "OpenTTD might crash"-message be shown when the player tries to unpause?
*/
void ShowNewGrfVehicleError(EngineID engine, StringID part1, StringID part2, GRFBugs bug_type, bool critical)
void ShowNewGrfVehicleError(EngineID engine, StringID part1, StringID part2, GRFBug bug_type, bool critical)
{
const Engine *e = Engine::Get(engine);
GRFConfig *grfconfig = GetGRFConfig(e->GetGRFID());
@@ -322,8 +322,8 @@ void ShowNewGrfVehicleError(EngineID engine, StringID part1, StringID part2, GRF
/* Missing GRF. Nothing useful can be done in this situation. */
if (grfconfig == nullptr) return;
if (!HasBit(grfconfig->grf_bugs, bug_type)) {
SetBit(grfconfig->grf_bugs, bug_type);
if (!grfconfig->grf_bugs.Test(bug_type)) {
grfconfig->grf_bugs.Set(bug_type);
SetDParamStr(0, grfconfig->GetName());
SetDParam(1, engine);
ShowErrorMessage(part1, part2, WL_CRITICAL);
@@ -349,8 +349,8 @@ void VehicleLengthChanged(const Vehicle *u)
const Engine *engine = u->GetEngine();
uint32_t grfid = engine->grf_prop.grfid;
GRFConfig *grfconfig = GetGRFConfig(grfid);
if (_gamelog.GRFBugReverse(grfid, engine->grf_prop.local_id) || !HasBit(grfconfig->grf_bugs, GBUG_VEH_LENGTH)) {
ShowNewGrfVehicleError(u->engine_type, STR_NEWGRF_BROKEN, STR_NEWGRF_BROKEN_VEHICLE_LENGTH, GBUG_VEH_LENGTH, true);
if (_gamelog.GRFBugReverse(grfid, engine->grf_prop.local_id) || !grfconfig->grf_bugs.Test(GRFBug::VehLength)) {
ShowNewGrfVehicleError(u->engine_type, STR_NEWGRF_BROKEN, STR_NEWGRF_BROKEN_VEHICLE_LENGTH, GRFBug::VehLength, true);
}
}
@@ -2717,7 +2717,7 @@ void Vehicle::UpdateVisualEffect(bool allow_power_change)
if (!allow_power_change && powered_before != HasBit(this->vcache.cached_vis_effect, VE_DISABLE_WAGON_POWER)) {
ToggleBit(this->vcache.cached_vis_effect, VE_DISABLE_WAGON_POWER);
ShowNewGrfVehicleError(this->engine_type, STR_NEWGRF_BROKEN, STR_NEWGRF_BROKEN_POWERED_WAGON, GBUG_VEH_POWERED_WAGON, false);
ShowNewGrfVehicleError(this->engine_type, STR_NEWGRF_BROKEN, STR_NEWGRF_BROKEN_POWERED_WAGON, GRFBug::VehPoweredWagon, false);
}
}