summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-05-17 08:20:36 +0000
committerpeter1138 <peter1138@openttd.org>2006-05-17 08:20:36 +0000
commit5a65e3301ef6698f42332cc5275af58fcd47460f (patch)
tree86473fe61b5bbbf5466a59213c097725714ee861
parentafd69f53f59b5bf1e4c51b56434931e62f186180 (diff)
downloadopenttd-5a65e3301ef6698f42332cc5275af58fcd47460f.tar.xz
(svn r4896) - NewGRF: add support for vehicle property 0x25 (user defined data) used by variable 0x42.
-rw-r--r--engine.h1
-rw-r--r--newgrf.c5
-rw-r--r--newgrf_engine.c4
-rw-r--r--table/engines.h2
4 files changed, 9 insertions, 3 deletions
diff --git a/engine.h b/engine.h
index 0e3ee1a1c..64ce15934 100644
--- a/engine.h
+++ b/engine.h
@@ -30,6 +30,7 @@ typedef struct RailVehicleInfo {
// kind of visual effect to generate for a vehicle (default, steam, diesel, electric).
// Same goes for the callback result, which atm is only used to check if a wagon is powered.
byte shorten_factor; // length on main map for this type is 8 - shorten_factor
+ byte user_def_data; ///! Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles
} RailVehicleInfo;
typedef struct ShipVehicleInfo {
diff --git a/newgrf.c b/newgrf.c
index f304ba60f..b17897829 100644
--- a/newgrf.c
+++ b/newgrf.c
@@ -437,6 +437,10 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf
}
break;
+ case 0x25: /* User-defined bit mask to set when checking veh. var. 42 */
+ FOR_EACH_OBJECT rvi[i].user_def_data = grf_load_byte(&buf);
+ break;
+
case 0x27: /* Miscellaneous flags */
FOR_EACH_OBJECT ei[i].misc_flags = grf_load_byte(&buf);
break;
@@ -454,7 +458,6 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf
case 0x1C: /* Refit cost */
case 0x1F: /* Tractive effort */
case 0x20: /* Air drag */
- case 0x25: /* User-defined bit mask to set when checking veh. var. 42 */
case 0x26: /* Retire vehicle early */
/* TODO */
FOR_EACH_OBJECT grf_load_byte(&buf);
diff --git a/newgrf_engine.c b/newgrf_engine.c
index 46af6e888..c89dbd0a7 100644
--- a/newgrf_engine.c
+++ b/newgrf_engine.c
@@ -534,6 +534,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
byte cargo_classes = 0;
uint common_cargo_best = 0;
uint common_cargos[NUM_GLOBAL_CID];
+ byte user_def_data = 0;
CargoID cargo;
CargoID common_cargo_type = GC_PASSENGERS;
@@ -547,6 +548,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
cargo = _global_cargo_id[_opt.landscape][u->cargo_type];
cargo_classes |= _cargo_classes[cargo];
common_cargos[cargo]++;
+ user_def_data |= RailVehInfo(u->engine_type)->user_def_data;
}
/* Pick the most common cargo type */
@@ -557,7 +559,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
}
}
- return cargo_classes | (common_cargo_type << 8);
+ return cargo_classes | (common_cargo_type << 8) | (user_def_data << 24);
}
case 0x43: /* Player information */
diff --git a/table/engines.h b/table/engines.h
index dc33ebafa..5a38b7f73 100644
--- a/table/engines.h
+++ b/table/engines.h
@@ -324,7 +324,7 @@ const EngineInfo orig_engine_info[] = {
* @param j cargo_type
* @param k ai_rank
*/
-#define RVI(a, b, c, d, e, f, g, h, i, j, k) { a, b, c, d, e, f, g, h, h, i, j, k, 0, 0, 0, 0, 0 }
+#define RVI(a, b, c, d, e, f, g, h, i, j, k) { a, b, c, d, e, f, g, h, h, i, j, k, 0, 0, 0, 0, 0, 0 }
#define M RVI_MULTIHEAD
#define W RVI_WAGON
#define S 0