summaryrefslogtreecommitdiff
path: root/newgrf_engine.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-06-22 21:31:09 +0000
committerpeter1138 <peter1138@openttd.org>2006-06-22 21:31:09 +0000
commitea5f3af9b823bd2985ad2532acb58de5fa2ed6a2 (patch)
tree4e1a2e2ba526c7020908f3fe9af81b6475b5a544 /newgrf_engine.c
parent158e0e43f2330c0e02e3c5808f7616e321c18d56 (diff)
downloadopenttd-ea5f3af9b823bd2985ad2532acb58de5fa2ed6a2.tar.xz
(svn r5338) - NewGRF: add support for vehicle variable 48, vehicle type info (more mart3p)
Diffstat (limited to 'newgrf_engine.c')
-rw-r--r--newgrf_engine.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/newgrf_engine.c b/newgrf_engine.c
index 5d02d1f62..93d7bddaf 100644
--- a/newgrf_engine.c
+++ b/newgrf_engine.c
@@ -502,6 +502,21 @@ static void VehicleSetTriggers(const ResolverObject *object, int triggers)
}
+static uint32 GetVehicleTypeInfo(EngineID engine_type)
+{
+ /* Bit 0 Vehicle type is available on the market
+ * Bit 1 Vehicle type is in the testing phase
+ * Bit 2 Exclusive testing offer for a human player active */
+ const Engine *e = GetEngine(engine_type);
+ uint32 var = 0;
+
+ if (e->player_avail == 0xFF) SETBIT(var, 0);
+ if (e->age < e->duration_phase_1) SETBIT(var, 1);
+ if (e->player_avail > 0 && e->player_avail != 0xFF) SETBIT(var, 2);
+ return var;
+}
+
+
static uint32 GetGRFParameter(EngineID engine_type, byte parameter)
{
const GRFFile *file = GetEngineGRF(engine_type);
@@ -520,6 +535,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
switch (variable) {
case 0x43: return _current_player; /* Owner information */
case 0x46: return 0; /* Motion counter */
+ case 0x48: return GetVehicleTypeInfo(object->u.vehicle.self_type); /* Vehicle Type Info */
case 0xC4: return _cur_year; /* Build year */
case 0xDA: return INVALID_VEHICLE; /* Next vehicle */
case 0x7F: return GetGRFParameter(object->u.vehicle.self_type, parameter); /* Read GRF parameter */
@@ -626,6 +642,8 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
return (_cargo_classes[cid] << 16) | (_cargoc.weights[v->cargo_type] << 8) | cid;
}
+ case 0x48: return GetVehicleTypeInfo(v->engine_type); /* Vehicle Type Info */
+
/* Variables which use the parameter */
case 0x60: /* Count consist's engine ID occurance */
if (v->type != VEH_Train) return v->engine_type == parameter;