mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r12331) -Feature: [NewGRF] vehicle variable FE bit 8
This commit is contained in:
parent
cf0e6d4cb4
commit
b64f637c72
|
@ -627,16 +627,15 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
|
|||
uint16 modflags = 0;
|
||||
|
||||
if (v->type == VEH_TRAIN) {
|
||||
/* @todo: There are some other bits that should be implemented:
|
||||
* bit 8: (Maybe?) Toggled whenever the train reverses.
|
||||
*/
|
||||
const Vehicle *u = IsTrainWagon(v) && HasBit(v->vehicle_flags, VRF_POWEREDWAGON) ? v->First() : v;
|
||||
RailType railtype = GetRailType(v->tile);
|
||||
bool powered = IsTrainEngine(v) || (IsTrainWagon(v) && HasBit(v->vehicle_flags, VRF_POWEREDWAGON));
|
||||
bool has_power = powered && HasPowerOnRail(u->u.rail.railtype, railtype);
|
||||
bool is_electric = powered && u->u.rail.railtype == RAILTYPE_ELECTRIC;
|
||||
|
||||
if (has_power) SetBit(modflags, 5);
|
||||
if (is_electric && !has_power) SetBit(modflags, 6);
|
||||
if (HasBit(v->u.rail.flags, VRF_TOGGLE_REVERSE)) SetBit(modflags, 8);
|
||||
}
|
||||
if (HasBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE)) SetBit(modflags, 10);
|
||||
|
||||
|
|
|
@ -1787,7 +1787,10 @@ static void ReverseTrainDirection(Vehicle *v)
|
|||
}
|
||||
|
||||
/* update all images */
|
||||
for (Vehicle *u = v; u != NULL; u = u->Next()) { u->cur_image = u->GetImage(u->direction); }
|
||||
for (Vehicle *u = v; u != NULL; u = u->Next()) {
|
||||
ToggleBit(u->u.rail.flags, VRF_TOGGLE_REVERSE);
|
||||
u->cur_image = u->GetImage(u->direction);
|
||||
}
|
||||
|
||||
ClrBit(v->u.rail.flags, VRF_REVERSING);
|
||||
|
||||
|
|
|
@ -2199,6 +2199,8 @@ void VehicleEnterDepot(Vehicle *v)
|
|||
if (!IsFrontEngine(v)) v = v->First();
|
||||
UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner);
|
||||
v->load_unload_time_rem = 0;
|
||||
/* Reset reversed flag */
|
||||
for (Vehicle *u = v; u != NULL; u = u->Next()) ClrBit(u->u.rail.flags, VRF_TOGGLE_REVERSE);
|
||||
break;
|
||||
|
||||
case VEH_ROAD:
|
||||
|
|
|
@ -118,7 +118,7 @@ struct VehicleRail {
|
|||
const struct SpriteGroup *cached_override;
|
||||
};
|
||||
|
||||
enum {
|
||||
enum VehicleRailFlags {
|
||||
VRF_REVERSING = 0,
|
||||
|
||||
/* used to calculate if train is going up or down */
|
||||
|
@ -136,6 +136,9 @@ enum {
|
|||
|
||||
/* used to mark that electric train engine is allowed to run on normal rail */
|
||||
VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL = 6,
|
||||
|
||||
/* used for vehicle var 0xFE bit 8 (toggled each time the train is reversed) */
|
||||
VRF_TOGGLE_REVERSE = 7,
|
||||
};
|
||||
|
||||
struct VehicleAir {
|
||||
|
|
Loading…
Reference in New Issue