Merge branch 'template_train_replacement' into template_train_replacement-sx

This commit is contained in:
Jonathan G Rennison 2016-06-21 18:56:40 +01:00
commit 84e467328f

View File

@ -623,6 +623,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
case 0x4A: {
if (v->type != VEH_TRAIN) return 0;
if (Train::From(v)->IsVirtual()) return 0x1FF;
RailType rt = GetTileRailType(v->tile);
return (HasPowerOnRail(Train::From(v)->railtype, rt) ? 0x100 : 0) | GetReverseRailTypeTranslation(rt, object->ro.grffile);
}
@ -716,9 +717,14 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
const Train *t = Train::From(v);
bool is_powered_wagon = HasBit(t->flags, VRF_POWEREDWAGON);
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;
if (u->IsVirtual()) {
has_power = true;
} else {
RailType railtype = GetRailType(v->tile);
has_power = HasPowerOnRail(u->railtype, railtype);
}
if (powered && has_power) SetBit(modflags, 5);
if (powered && !has_power) SetBit(modflags, 6);