Codechange: Add base() method to StrongType to allow access to the base type without casting. (#11445)

This removes the ability to explicitly cast to the base type, but the requirement
to use .base() means the conversion is still explicit.
This commit is contained in:
Peter Nelson
2023-11-06 20:29:35 +00:00
committed by GitHub
parent 737775f834
commit ab535c0a86
73 changed files with 174 additions and 173 deletions

View File

@@ -358,7 +358,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
return true;
} else {
/* Target a vehicle */
RoadVehicle *u = RoadVehicle::Get(static_cast<uint32_t>(v->dest_tile));
RoadVehicle *u = RoadVehicle::Get(v->dest_tile.base());
assert(u != nullptr && u->type == VEH_ROAD && u->IsFrontEngine());
uint dist = Delta(v->x_pos, u->x_pos) + Delta(v->y_pos, u->y_pos);
@@ -437,7 +437,7 @@ static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16_t image_override, b
if (v->state == 2) {
if (GB(v->tick_counter, 0, 2) == 0) {
Industry *i = Industry::Get(static_cast<uint32_t>(v->dest_tile)); // Industry destructor calls ReleaseDisastersTargetingIndustry, so this is valid
Industry *i = Industry::Get(v->dest_tile.base()); // Industry destructor calls ReleaseDisastersTargetingIndustry, so this is valid
int x = TileX(i->location.tile) * TILE_SIZE;
int y = TileY(i->location.tile) * TILE_SIZE;
uint32_t r = Random();
@@ -455,7 +455,7 @@ static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16_t image_override, b
v->state = 2;
v->age = 0;
Industry *i = Industry::Get(static_cast<uint32_t>(v->dest_tile)); // Industry destructor calls ReleaseDisastersTargetingIndustry, so this is valid
Industry *i = Industry::Get(v->dest_tile.base()); // Industry destructor calls ReleaseDisastersTargetingIndustry, so this is valid
DestructIndustry(i);
SetDParam(0, i->town->index);