mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-23 04:04:09 +01:00
Codechange: Store the rail type of rail engines as a RailTypes bitmask.
This commit is contained in:
@@ -565,7 +565,7 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec
|
||||
RailType rt = GetTileRailType(v->tile);
|
||||
const RailTypeInfo *rti = GetRailTypeInfo(rt);
|
||||
return (rti->flags.Test(RailTypeFlag::Catenary) ? 0x200 : 0) |
|
||||
(HasPowerOnRail(Train::From(v)->railtype, rt) ? 0x100 : 0) |
|
||||
(HasPowerOnRail(Train::From(v)->railtypes, rt) ? 0x100 : 0) |
|
||||
GetReverseRailTypeTranslation(rt, object->ro.grffile);
|
||||
}
|
||||
|
||||
@@ -732,7 +732,7 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec
|
||||
const Train *u = is_powered_wagon ? t->First() : t; // for powered wagons the engine defines the type of engine (i.e. railtype)
|
||||
RailType railtype = GetRailType(v->tile);
|
||||
bool powered = t->IsEngine() || is_powered_wagon;
|
||||
bool has_power = HasPowerOnRail(u->railtype, railtype);
|
||||
bool has_power = HasPowerOnRail(u->railtypes, railtype);
|
||||
|
||||
if (powered && has_power) SetBit(modflags, 5);
|
||||
if (powered && !has_power) SetBit(modflags, 6);
|
||||
@@ -915,7 +915,7 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec
|
||||
Train *t = Train::From(v);
|
||||
switch (variable - 0x80) {
|
||||
case 0x62: return t->track;
|
||||
case 0x66: return t->railtype;
|
||||
case 0x66: return t->railtypes.GetNthSetBit(0).value_or(RailType::INVALID_RAILTYPE);
|
||||
case 0x73: return 0x80 + VEHICLE_LENGTH - t->gcache.cached_veh_length;
|
||||
case 0x74: return t->gcache.cached_power;
|
||||
case 0x75: return GB(t->gcache.cached_power, 8, 24);
|
||||
|
||||
Reference in New Issue
Block a user