summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormaedhros <maedhros@openttd.org>2007-02-28 17:59:05 +0000
committermaedhros <maedhros@openttd.org>2007-02-28 17:59:05 +0000
commit469fbc912c2f8b502f683362a86f86d0aa991751 (patch)
tree69eb785ea7e1b67aa0b9366a3f703c525d13e4df
parentaadd8a4b44e0f67e5a2ccb685a56fc258c1eb9ff (diff)
downloadopenttd-469fbc912c2f8b502f683362a86f86d0aa991751.tar.xz
(svn r8946) -Feature: [NewGRF] Add support for vehicle variables 0xFE and 0xFF bit 10,
which is set when a vehicle was built during the exclusive testing phase.
-rw-r--r--src/aircraft_cmd.cpp3
-rw-r--r--src/newgrf_engine.cpp15
-rw-r--r--src/roadveh_cmd.cpp3
-rw-r--r--src/ship_cmd.cpp3
-rw-r--r--src/train_cmd.cpp3
-rw-r--r--src/vehicle.h1
6 files changed, 28 insertions, 0 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index fe5d371be..a0c3acfdc 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -390,6 +390,9 @@ int32 CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->random_bits = VehicleRandomBits();
u->random_bits = VehicleRandomBits();
+ v->vehicle_flags = 0;
+ if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SETBIT(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
+
VehiclePositionChanged(v);
VehiclePositionChanged(u);
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index dd38fbafc..e9e5dd86c 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -601,6 +601,21 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
}
case 0x7F: return GetGRFParameter(v->engine_type, parameter); /* Read GRF parameter */
+
+ case 0xFE:
+ case 0xFF: {
+ uint16 modflags = 0;
+
+ /* TODO: There are some other bits that should be implemented:
+ * bit 5: Whether the rail vehicle is powered or not (mostly useful for wagons).
+ * bit 6: This is an electrically powered rail vehicle which is running on normal rail.
+ * bit 8: (Maybe?) Toggled whenever the train reverses.
+ */
+
+ if (HASBIT(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE)) SETBIT(modflags, 10);
+
+ return variable == 0xFE ? modflags : GB(modflags, 8, 8);
+ }
}
/* General vehicle properties */
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 9fc8204cf..6e594ebb3 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -204,6 +204,9 @@ int32 CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->cur_image = 0xC15;
v->random_bits = VehicleRandomBits();
+ v->vehicle_flags = 0;
+ if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SETBIT(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
+
VehiclePositionChanged(v);
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 618fcdbb6..98d9e40c7 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -913,6 +913,9 @@ int32 CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->type = VEH_Ship;
v->random_bits = VehicleRandomBits();
+ v->vehicle_flags = 0;
+ if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SETBIT(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
+
VehiclePositionChanged(v);
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 56d09cbda..13a647abb 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -785,6 +785,9 @@ int32 CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->cur_image = 0xAC2;
v->random_bits = VehicleRandomBits();
+ v->vehicle_flags = 0;
+ if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SETBIT(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
+
v->subtype = 0;
SetFrontEngine(v);
SetTrainEngine(v);
diff --git a/src/vehicle.h b/src/vehicle.h
index d14da3a7f..7ae508e0b 100644
--- a/src/vehicle.h
+++ b/src/vehicle.h
@@ -86,6 +86,7 @@ enum VehStatus {
enum VehicleFlags {
VF_LOADING_FINISHED,
VF_CARGO_UNLOADING,
+ VF_BUILT_AS_PROTOTYPE,
};
/* Effect vehicle types */