src/newgrf_engine.cpp
changeset 6091 c8827d9ae04a
parent 6032 fe6a454ac1ba
child 6113 a10ede03ac58
equal deleted inserted replaced
6090:dd413a1ccb6b 6091:c8827d9ae04a
    16 #include "newgrf_station.h"
    16 #include "newgrf_station.h"
    17 #include "newgrf_spritegroup.h"
    17 #include "newgrf_spritegroup.h"
    18 #include "newgrf_cargo.h"
    18 #include "newgrf_cargo.h"
    19 #include "date.h"
    19 #include "date.h"
    20 #include "helpers.hpp"
    20 #include "helpers.hpp"
    21 
    21 #include "cargotype.h"
    22 
    22 
    23 
       
    24 /* Default cargo classes */
       
    25 static const uint16 _cargo_classes[NUM_GLOBAL_CID] = {
       
    26 	CC_PASSENGERS,
       
    27 	CC_BULK,
       
    28 	CC_MAIL,
       
    29 	CC_LIQUID,
       
    30 	CC_PIECE_GOODS,
       
    31 	CC_EXPRESS,
       
    32 	CC_BULK,
       
    33 	CC_PIECE_GOODS,
       
    34 	CC_BULK,
       
    35 	CC_PIECE_GOODS,
       
    36 	CC_ARMOURED,
       
    37 	CC_PIECE_GOODS,
       
    38 	CC_REFRIGERATED | CC_EXPRESS,
       
    39 	CC_REFRIGERATED | CC_EXPRESS,
       
    40 	CC_BULK,
       
    41 	CC_LIQUID,
       
    42 	CC_LIQUID,
       
    43 	CC_BULK,
       
    44 	CC_PIECE_GOODS,
       
    45 	CC_PIECE_GOODS,
       
    46 	CC_EXPRESS,
       
    47 	CC_BULK,
       
    48 	CC_LIQUID,
       
    49 	CC_BULK,
       
    50 	CC_PIECE_GOODS,
       
    51 	CC_LIQUID,
       
    52 	CC_PIECE_GOODS,
       
    53 	CC_PIECE_GOODS,
       
    54 	CC_NOAVAILABLE,
       
    55 	CC_NOAVAILABLE,
       
    56 	CC_NOAVAILABLE,
       
    57 };
       
    58 
    23 
    59 int _traininfo_vehicle_pitch = 0;
    24 int _traininfo_vehicle_pitch = 0;
    60 int _traininfo_vehicle_width = 29;
    25 int _traininfo_vehicle_width = 29;
    61 
    26 
    62 typedef struct WagonOverride {
    27 typedef struct WagonOverride {
   585 			for (u = v; u != NULL; u = u->next) {
   550 			for (u = v; u != NULL; u = u->next) {
   586 				/* Skip empty engines */
   551 				/* Skip empty engines */
   587 				if (u->cargo_cap == 0) continue;
   552 				if (u->cargo_cap == 0) continue;
   588 				/* Map from climate to global cargo ID */
   553 				/* Map from climate to global cargo ID */
   589 				cargo = _global_cargo_id[_opt.landscape][u->cargo_type];
   554 				cargo = _global_cargo_id[_opt.landscape][u->cargo_type];
   590 				cargo_classes |= _cargo_classes[cargo];
   555 				cargo_classes |= GetCargo(cargo)->classes;
   591 				common_cargos[cargo]++;
   556 				common_cargos[cargo]++;
   592 				user_def_data |= RailVehInfo(u->engine_type)->user_def_data;
   557 				user_def_data |= RailVehInfo(u->engine_type)->user_def_data;
   593 			}
   558 			}
   594 
   559 
   595 			/* Pick the most common cargo type */
   560 			/* Pick the most common cargo type */
   642 			 *     translated if a translation table has been installed.
   607 			 *     translated if a translation table has been installed.
   643 			 * ww - cargo unit weight in 1/16 tons, same as cargo prop. 0F.
   608 			 * ww - cargo unit weight in 1/16 tons, same as cargo prop. 0F.
   644 			 * cccc - the cargo class value of the cargo transported by the vehicle.
   609 			 * cccc - the cargo class value of the cargo transported by the vehicle.
   645 			 */
   610 			 */
   646 			CargoID cid = _global_cargo_id[_opt.landscape][v->cargo_type];
   611 			CargoID cid = _global_cargo_id[_opt.landscape][v->cargo_type];
   647 
   612 			const CargoSpec *cs = GetCargo(v->cargo_type);
   648 			return (_cargo_classes[cid] << 16) | (_cargoc.weights[v->cargo_type] << 8) | cid;
   613 
       
   614 			return (cs->classes << 16) | (cs->weight << 8) | cid;
   649 		}
   615 		}
   650 
   616 
   651 		case 0x48: return GetVehicleTypeInfo(v->engine_type); /* Vehicle Type Info */
   617 		case 0x48: return GetVehicleTypeInfo(v->engine_type); /* Vehicle Type Info */
   652 
   618 
   653 		/* Variables which use the parameter */
   619 		/* Variables which use the parameter */