summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2008-03-03 20:56:30 +0000
committerglx <glx@openttd.org>2008-03-03 20:56:30 +0000
commitb64f637c720add4799c38c62b82c2858cdae9e0a (patch)
treedb93eac119a52cc01a0e4e720f4e99b3b98e4cc2
parentcf0e6d4cb48b733b1f6ca8819c05638218899f76 (diff)
downloadopenttd-b64f637c720add4799c38c62b82c2858cdae9e0a.tar.xz
(svn r12331) -Feature: [NewGRF] vehicle variable FE bit 8
-rw-r--r--src/newgrf_engine.cpp5
-rw-r--r--src/train_cmd.cpp5
-rw-r--r--src/vehicle.cpp2
-rw-r--r--src/vehicle_base.h5
4 files changed, 12 insertions, 5 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 648f46919..ef31b976c 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -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);
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index f38e39524..f513fbc01 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -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);
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index e91f243a5..9eefcb72c 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -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:
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index 3b5464a9d..8bcaa2b47 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -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 {