From 3d581f4f894293f45666220de78651ba6b9a7d1c Mon Sep 17 00:00:00 2001 From: peter1138 Date: Tue, 20 Feb 2007 22:09:21 +0000 Subject: (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels. --- src/newgrf_engine.cpp | 42 ++++-------------------------------------- 1 file changed, 4 insertions(+), 38 deletions(-) (limited to 'src/newgrf_engine.cpp') diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index 0a1183afb..2c3e0ac6a 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -18,44 +18,9 @@ #include "newgrf_cargo.h" #include "date.h" #include "helpers.hpp" +#include "cargotype.h" - -/* Default cargo classes */ -static const uint16 _cargo_classes[NUM_GLOBAL_CID] = { - CC_PASSENGERS, - CC_BULK, - CC_MAIL, - CC_LIQUID, - CC_PIECE_GOODS, - CC_EXPRESS, - CC_BULK, - CC_PIECE_GOODS, - CC_BULK, - CC_PIECE_GOODS, - CC_ARMOURED, - CC_PIECE_GOODS, - CC_REFRIGERATED | CC_EXPRESS, - CC_REFRIGERATED | CC_EXPRESS, - CC_BULK, - CC_LIQUID, - CC_LIQUID, - CC_BULK, - CC_PIECE_GOODS, - CC_PIECE_GOODS, - CC_EXPRESS, - CC_BULK, - CC_LIQUID, - CC_BULK, - CC_PIECE_GOODS, - CC_LIQUID, - CC_PIECE_GOODS, - CC_PIECE_GOODS, - CC_NOAVAILABLE, - CC_NOAVAILABLE, - CC_NOAVAILABLE, -}; - int _traininfo_vehicle_pitch = 0; int _traininfo_vehicle_width = 29; @@ -587,7 +552,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by if (u->cargo_cap == 0) continue; /* Map from climate to global cargo ID */ cargo = _global_cargo_id[_opt.landscape][u->cargo_type]; - cargo_classes |= _cargo_classes[cargo]; + cargo_classes |= GetCargo(cargo)->classes; common_cargos[cargo]++; user_def_data |= RailVehInfo(u->engine_type)->user_def_data; } @@ -644,8 +609,9 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by * cccc - the cargo class value of the cargo transported by the vehicle. */ CargoID cid = _global_cargo_id[_opt.landscape][v->cargo_type]; + const CargoSpec *cs = GetCargo(v->cargo_type); - return (_cargo_classes[cid] << 16) | (_cargoc.weights[v->cargo_type] << 8) | cid; + return (cs->classes << 16) | (cs->weight << 8) | cid; } case 0x48: return GetVehicleTypeInfo(v->engine_type); /* Vehicle Type Info */ -- cgit v1.2.3-54-g00ecf