engine.h
author peter1138
Fri, 31 Mar 2006 12:59:43 +0000
changeset 3393 c40975f04842
parent 3344 fc86351d4641
child 3750 ffe5ba5de494
permissions -rw-r--r--
(svn r4201) - Codechange: Do for _engine_info[] what we do for _*_vehicle_info[]; create and use a function to retrieve data, and ensure constness.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2129
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2129
diff changeset
     2
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
#ifndef ENGINE_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     4
#define ENGINE_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
2129
5a1fe83c2b4d (svn r2639) -Add: Added the vehicle names in table/engines.h so that you know what line represents what vehicle (I hope I didn't mess that up). Added some comments while I'm at it and include the table/ directory in the Doxygen generation
celestar
parents: 1998
diff changeset
     6
/** @file engine.h
5a1fe83c2b4d (svn r2639) -Add: Added the vehicle names in table/engines.h so that you know what line represents what vehicle (I hope I didn't mess that up). Added some comments while I'm at it and include the table/ directory in the Doxygen generation
celestar
parents: 1998
diff changeset
     7
  */
5a1fe83c2b4d (svn r2639) -Add: Added the vehicle names in table/engines.h so that you know what line represents what vehicle (I hope I didn't mess that up). Added some comments while I'm at it and include the table/ directory in the Doxygen generation
celestar
parents: 1998
diff changeset
     8
405
415546028e8d (svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents: 389
diff changeset
     9
#include "sprite.h"
2848
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
    10
#include "pool.h"
405
415546028e8d (svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents: 389
diff changeset
    11
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
typedef struct RailVehicleInfo {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
	byte image_index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
	byte flags; /* 1=multihead engine, 2=wagon */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
	byte base_cost;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
	uint16 max_speed;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
	uint16 power;
2542
812fc4357594 (svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents: 2530
diff changeset
    18
	uint16 weight;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
	byte running_cost_base;
2840
9038b4ab8c9a (svn r3388) - NewGRF: Allow train running cost class to differ from engine class. Also fix typo in r3384.
peter1138
parents: 2817
diff changeset
    20
	byte running_cost_class;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
	byte engclass; // 0: steam, 1: diesel, 2: electric
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
	byte capacity;
3344
fc86351d4641 (svn r4128) - CodeChange: Add proper semantics for CargoID for such variables instead of using the general byte-type.
Darkvater
parents: 3113
diff changeset
    23
	CargoID cargo_type;
3022
d4b90d0b5b24 (svn r3602) - Move _railveh_score data to _rail_vehicle_info->ai_rank and remove global variable to return data as we can now access this directly.
peter1138
parents: 3006
diff changeset
    24
	byte ai_rank;
1895
0d499b71a782 (svn r2401) - Fix: [newgrf] Finish up callback mechanism, implement 'refit capacity' callback slightly more correct.
hackykid
parents: 1883
diff changeset
    25
	byte callbackmask; // see CallbackMask enum
1908
2fa391fed79a (svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents: 1895
diff changeset
    26
	uint16 pow_wag_power;
2fa391fed79a (svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents: 1895
diff changeset
    27
	byte pow_wag_weight;
2fa391fed79a (svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents: 1895
diff changeset
    28
	byte visual_effect; // NOTE: this is not 100% implemented yet, at the moment it is only used as a 'fallback' value
2fa391fed79a (svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents: 1895
diff changeset
    29
	                    //       for when the 'powered wagon' callback fails. But it should really also determine what
2fa391fed79a (svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents: 1895
diff changeset
    30
	                    //       kind of visual effect to generate for a vehicle (default, steam, diesel, electric).
2fa391fed79a (svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents: 1895
diff changeset
    31
	                    //       Same goes for the callback result, which atm is only used to check if a wagon is powered.
1922
bda6f85eefaa (svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents: 1909
diff changeset
    32
	byte shorten_factor;	// length on main map for this type is 8 - shorten_factor
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
} RailVehicleInfo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
typedef struct ShipVehicleInfo {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
	byte image_index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
	byte base_cost;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
	uint16 max_speed;
3344
fc86351d4641 (svn r4128) - CodeChange: Add proper semantics for CargoID for such variables instead of using the general byte-type.
Darkvater
parents: 3113
diff changeset
    39
	CargoID cargo_type;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
	uint16 capacity;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
	byte running_cost;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
	byte sfx;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
	byte refittable;
3006
6da38dbee2a7 (svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents: 2962
diff changeset
    44
	byte callbackmask;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
} ShipVehicleInfo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
376
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    47
typedef struct AircraftVehicleInfo {
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    48
	byte image_index;
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    49
	byte base_cost;
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    50
	byte running_cost;
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    51
	byte subtype;
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    52
	byte sfx;
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    53
	byte acceleration;
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    54
	byte max_speed;
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    55
	byte mail_capacity;
922
10035216cbaf (svn r1410) Replaced all occurences of 'passanger' by 'passenger' in the code
celestar
parents: 842
diff changeset
    56
	uint16 passenger_capacity;
3006
6da38dbee2a7 (svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents: 2962
diff changeset
    57
	byte callbackmask;
376
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    58
} AircraftVehicleInfo;
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    59
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    60
typedef struct RoadVehicleInfo {
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    61
	byte image_index;
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    62
	byte base_cost;
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    63
	byte running_cost;
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    64
	byte sfx;
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    65
	byte max_speed;
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    66
	byte capacity;
3344
fc86351d4641 (svn r4128) - CodeChange: Add proper semantics for CargoID for such variables instead of using the general byte-type.
Darkvater
parents: 3113
diff changeset
    67
	CargoID cargo_type;
3006
6da38dbee2a7 (svn r3586) - NewGRF: Load callback masks for all vehicle types.
peter1138
parents: 2962
diff changeset
    68
	byte callbackmask;
376
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
    69
} RoadVehicleInfo;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
2129
5a1fe83c2b4d (svn r2639) -Add: Added the vehicle names in table/engines.h so that you know what line represents what vehicle (I hope I didn't mess that up). Added some comments while I'm at it and include the table/ directory in the Doxygen generation
celestar
parents: 1998
diff changeset
    71
/** Information about a vehicle
5a1fe83c2b4d (svn r2639) -Add: Added the vehicle names in table/engines.h so that you know what line represents what vehicle (I hope I didn't mess that up). Added some comments while I'm at it and include the table/ directory in the Doxygen generation
celestar
parents: 1998
diff changeset
    72
  * @see table/engines.h
5a1fe83c2b4d (svn r2639) -Add: Added the vehicle names in table/engines.h so that you know what line represents what vehicle (I hope I didn't mess that up). Added some comments while I'm at it and include the table/ directory in the Doxygen generation
celestar
parents: 1998
diff changeset
    73
  */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
typedef struct EngineInfo {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
	uint16 base_intro;
2129
5a1fe83c2b4d (svn r2639) -Add: Added the vehicle names in table/engines.h so that you know what line represents what vehicle (I hope I didn't mess that up). Added some comments while I'm at it and include the table/ directory in the Doxygen generation
celestar
parents: 1998
diff changeset
    76
	byte unk2;              ///< Carriages have the highest bit set in this one
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
	byte lifelength;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
	byte base_life;
2530
df14798edc40 (svn r3059) Use bitfields to encode railtype and climates of engines instead of manual shifting/anding
tron
parents: 2491
diff changeset
    79
	byte railtype:4;
df14798edc40 (svn r3059) Use bitfields to encode railtype and climates of engines instead of manual shifting/anding
tron
parents: 2491
diff changeset
    80
	byte climates:4;
2611
36aa372eeb34 (svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents: 2602
diff changeset
    81
	uint32 refit_mask;
3095
19084629d27a (svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents: 3022
diff changeset
    82
	byte misc_flags;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
} EngineInfo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
typedef struct Engine {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
	uint16 intro_date;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
	uint16 age;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
	uint16 reliability;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
	uint16 reliability_spd_dec;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
	uint16 reliability_start, reliability_max, reliability_final;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
	uint16 duration_phase_1, duration_phase_2, duration_phase_3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
	byte lifelength;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
	byte flags;
2331
84638ba57139 (svn r2857) -Fix: PlayerID is not a valid type for a player-bit-field. Partly reverted r2290
truelight
parents: 2186
diff changeset
    94
	byte preview_player;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
	byte preview_wait;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
	byte railtype;
2331
84638ba57139 (svn r2857) -Fix: PlayerID is not a valid type for a player-bit-field. Partly reverted r2290
truelight
parents: 2186
diff changeset
    97
	byte player_avail;
819
c425b7e22f6a (svn r1290) Added type to typedef struct Engine and filled in the same data as in type in vehicle
bjarni
parents: 539
diff changeset
    98
	byte type;				// type, ie VEH_Road, VEH_Train, etc. Same as in vehicle.h
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
} Engine;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
3113
d79500c648da (svn r3717) - [2cc] Add 2cc colour maps and use for newgrf engines requiring them. Currently the second colour is fixed to be the player's colour.
peter1138
parents: 3095
diff changeset
   101
/**
d79500c648da (svn r3717) - [2cc] Add 2cc colour maps and use for newgrf engines requiring them. Currently the second colour is fixed to be the player's colour.
peter1138
parents: 3095
diff changeset
   102
 * EngineInfo.misc_flags is a bitmask, with the following values
d79500c648da (svn r3717) - [2cc] Add 2cc colour maps and use for newgrf engines requiring them. Currently the second colour is fixed to be the player's colour.
peter1138
parents: 3095
diff changeset
   103
 */
d79500c648da (svn r3717) - [2cc] Add 2cc colour maps and use for newgrf engines requiring them. Currently the second colour is fixed to be the player's colour.
peter1138
parents: 3095
diff changeset
   104
enum {
d79500c648da (svn r3717) - [2cc] Add 2cc colour maps and use for newgrf engines requiring them. Currently the second colour is fixed to be the player's colour.
peter1138
parents: 3095
diff changeset
   105
	EF_RAIL_TILTS = 0, ///< Rail vehicle tilts in curves (unsupported)
d79500c648da (svn r3717) - [2cc] Add 2cc colour maps and use for newgrf engines requiring them. Currently the second colour is fixed to be the player's colour.
peter1138
parents: 3095
diff changeset
   106
	EF_ROAD_TRAM  = 0, ///< Road vehicle is a tram/light rail vehicle (unsup)
d79500c648da (svn r3717) - [2cc] Add 2cc colour maps and use for newgrf engines requiring them. Currently the second colour is fixed to be the player's colour.
peter1138
parents: 3095
diff changeset
   107
	EF_USES_2CC   = 1, ///< Vehicle uses two company colours
d79500c648da (svn r3717) - [2cc] Add 2cc colour maps and use for newgrf engines requiring them. Currently the second colour is fixed to be the player's colour.
peter1138
parents: 3095
diff changeset
   108
	EF_RAIL_IS_MU = 2, ///< Rail vehicle is a multiple-unit (DMU/EMU)
d79500c648da (svn r3717) - [2cc] Add 2cc colour maps and use for newgrf engines requiring them. Currently the second colour is fixed to be the player's colour.
peter1138
parents: 3095
diff changeset
   109
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
enum {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
	RVI_MULTIHEAD = 1,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
	RVI_WAGON = 2,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
1802
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   116
enum {
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   117
	NUM_VEHICLE_TYPES = 6
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   118
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
2848
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   120
enum {
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   121
	INVALID_ENGINE = 0xFFFF,
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   122
};
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   123
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 922
diff changeset
   124
void AddTypeToEngines(void);
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 922
diff changeset
   125
void StartupEngines(void);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
1802
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   127
enum GlobalCargo {
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   128
	GC_PASSENGERS   =   0,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   129
	GC_COAL         =   1,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   130
	GC_MAIL         =   2,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   131
	GC_OIL          =   3,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   132
	GC_LIVESTOCK    =   4,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   133
	GC_GOODS        =   5,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   134
	GC_GRAIN        =   6, // GC_WHEAT / GC_MAIZE
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   135
	GC_WOOD         =   7,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   136
	GC_IRON_ORE     =   8,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   137
	GC_STEEL        =   9,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   138
	GC_VALUABLES    =  10, // GC_GOLD / GC_DIAMONDS
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   139
	GC_PAPER        =  11,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   140
	GC_FOOD         =  12,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   141
	GC_FRUIT        =  13,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   142
	GC_COPPER_ORE   =  14,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   143
	GC_WATER        =  15,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   144
	GC_RUBBER       =  16,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   145
	GC_SUGAR        =  17,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   146
	GC_TOYS         =  18,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   147
	GC_BATTERIES    =  19,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   148
	GC_CANDY        =  20,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   149
	GC_TOFFEE       =  21,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   150
	GC_COLA         =  22,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   151
	GC_COTTON_CANDY =  23,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   152
	GC_BUBBLES      =  24,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   153
	GC_PLASTIC      =  25,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   154
	GC_FIZZY_DRINKS =  26,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   155
	GC_PAPER_TEMP   =  27,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   156
	GC_UNDEFINED    =  28, // undefined; unused slot in arctic climate
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   157
	GC_DEFAULT      =  29,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   158
	GC_PURCHASE     =  30,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   159
	GC_INVALID      = 255,
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   160
	NUM_GLOBAL_CID  =  31
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   161
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
1802
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   163
VARDEF const uint32 _default_refitmasks[NUM_VEHICLE_TYPES];
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   164
VARDEF const CargoID _global_cargo_id[NUM_LANDSCAPE][NUM_CARGO];
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   165
VARDEF const uint32 _landscape_global_cargo_mask[NUM_LANDSCAPE];
da61740cc1e7 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1786
diff changeset
   166
VARDEF const CargoID _local_cargo_id_ctype[NUM_GLOBAL_CID];
2611
36aa372eeb34 (svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents: 2602
diff changeset
   167
VARDEF const uint32 cargo_classes[16];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
2477
225b2916fe2a (svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents: 2464
diff changeset
   169
void DrawTrainEngine(int x, int y, EngineID engine, uint32 image_ormod);
225b2916fe2a (svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents: 2464
diff changeset
   170
void DrawRoadVehEngine(int x, int y, EngineID engine, uint32 image_ormod);
225b2916fe2a (svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents: 2464
diff changeset
   171
void DrawShipEngine(int x, int y, EngineID engine, uint32 image_ormod);
225b2916fe2a (svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents: 2464
diff changeset
   172
void DrawAircraftEngine(int x, int y, EngineID engine, uint32 image_ormod);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 922
diff changeset
   174
void LoadCustomEngineNames(void);
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 922
diff changeset
   175
void DeleteCustomEngineNames(void);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
1197
433b4a05fa3e (svn r1701) Style police ^^
tron
parents: 1196
diff changeset
   177
bool IsEngineBuildable(uint engine, byte type);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
enum {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
	NUM_NORMAL_RAIL_ENGINES = 54,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
	NUM_MONORAIL_ENGINES = 30,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
	NUM_MAGLEV_ENGINES = 32,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
	NUM_TRAIN_ENGINES = NUM_NORMAL_RAIL_ENGINES + NUM_MONORAIL_ENGINES + NUM_MAGLEV_ENGINES,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
	NUM_ROAD_ENGINES = 88,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
	NUM_SHIP_ENGINES = 11,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
	NUM_AIRCRAFT_ENGINES = 41,
376
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
   187
	TOTAL_NUM_ENGINES = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES + NUM_AIRCRAFT_ENGINES,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
	AIRCRAFT_ENGINES_INDEX = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
	SHIP_ENGINES_INDEX = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
	ROAD_ENGINES_INDEX = NUM_TRAIN_ENGINES,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
VARDEF Engine _engines[TOTAL_NUM_ENGINES];
1786
7cfd46c3fcc4 (svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents: 1477
diff changeset
   193
#define FOR_ALL_ENGINES(e) for (e = _engines; e != endof(_engines); e++)
1926
530480d14685 (svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents: 1922
diff changeset
   194
2477
225b2916fe2a (svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents: 2464
diff changeset
   195
static inline Engine* GetEngine(EngineID i)
1786
7cfd46c3fcc4 (svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents: 1477
diff changeset
   196
{
7cfd46c3fcc4 (svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents: 1477
diff changeset
   197
  assert(i < lengthof(_engines));
7cfd46c3fcc4 (svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents: 1477
diff changeset
   198
  return &_engines[i];
7cfd46c3fcc4 (svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents: 1477
diff changeset
   199
}
7cfd46c3fcc4 (svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents: 1477
diff changeset
   200
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
VARDEF StringID _engine_name_strings[TOTAL_NUM_ENGINES];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
1786
7cfd46c3fcc4 (svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents: 1477
diff changeset
   203
static inline bool IsEngineIndex(uint index)
7cfd46c3fcc4 (svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents: 1477
diff changeset
   204
{
7cfd46c3fcc4 (svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents: 1477
diff changeset
   205
	return index < TOTAL_NUM_ENGINES;
7cfd46c3fcc4 (svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents: 1477
diff changeset
   206
}
7cfd46c3fcc4 (svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents: 1477
diff changeset
   207
376
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
   208
/* Access Vehicle Data */
6ffd7911bf39 (svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents: 374
diff changeset
   209
//#include "table/engines.h"
2463
db029c987bc7 (svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents: 2436
diff changeset
   210
extern const EngineInfo orig_engine_info[TOTAL_NUM_ENGINES];
db029c987bc7 (svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents: 2436
diff changeset
   211
extern const RailVehicleInfo orig_rail_vehicle_info[NUM_TRAIN_ENGINES];
db029c987bc7 (svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents: 2436
diff changeset
   212
extern const ShipVehicleInfo orig_ship_vehicle_info[NUM_SHIP_ENGINES];
db029c987bc7 (svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents: 2436
diff changeset
   213
extern const AircraftVehicleInfo orig_aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES];
db029c987bc7 (svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents: 2436
diff changeset
   214
extern const RoadVehicleInfo orig_road_vehicle_info[NUM_ROAD_ENGINES];
538
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   215
2763
a4d065e3261b (svn r3308) BAD
tron
parents: 2611
diff changeset
   216
extern EngineInfo _engine_info[TOTAL_NUM_ENGINES];
a4d065e3261b (svn r3308) BAD
tron
parents: 2611
diff changeset
   217
extern RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES];
a4d065e3261b (svn r3308) BAD
tron
parents: 2611
diff changeset
   218
extern ShipVehicleInfo _ship_vehicle_info[NUM_SHIP_ENGINES];
a4d065e3261b (svn r3308) BAD
tron
parents: 2611
diff changeset
   219
extern AircraftVehicleInfo _aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES];
a4d065e3261b (svn r3308) BAD
tron
parents: 2611
diff changeset
   220
extern RoadVehicleInfo _road_vehicle_info[NUM_ROAD_ENGINES];
2463
db029c987bc7 (svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents: 2436
diff changeset
   221
3393
c40975f04842 (svn r4201) - Codechange: Do for _engine_info[] what we do for _*_vehicle_info[]; create and use a function to retrieve data, and ensure constness.
peter1138
parents: 3344
diff changeset
   222
static inline const EngineInfo *EngInfo(EngineID e)
c40975f04842 (svn r4201) - Codechange: Do for _engine_info[] what we do for _*_vehicle_info[]; create and use a function to retrieve data, and ensure constness.
peter1138
parents: 3344
diff changeset
   223
{
c40975f04842 (svn r4201) - Codechange: Do for _engine_info[] what we do for _*_vehicle_info[]; create and use a function to retrieve data, and ensure constness.
peter1138
parents: 3344
diff changeset
   224
	assert(e < lengthof(_engine_info));
c40975f04842 (svn r4201) - Codechange: Do for _engine_info[] what we do for _*_vehicle_info[]; create and use a function to retrieve data, and ensure constness.
peter1138
parents: 3344
diff changeset
   225
	return &_engine_info[e];
c40975f04842 (svn r4201) - Codechange: Do for _engine_info[] what we do for _*_vehicle_info[]; create and use a function to retrieve data, and ensure constness.
peter1138
parents: 3344
diff changeset
   226
}
c40975f04842 (svn r4201) - Codechange: Do for _engine_info[] what we do for _*_vehicle_info[]; create and use a function to retrieve data, and ensure constness.
peter1138
parents: 3344
diff changeset
   227
2477
225b2916fe2a (svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents: 2464
diff changeset
   228
static inline const RailVehicleInfo* RailVehInfo(EngineID e)
538
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   229
{
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   230
	assert(e < lengthof(_rail_vehicle_info));
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   231
	return &_rail_vehicle_info[e];
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   232
}
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   233
2477
225b2916fe2a (svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents: 2464
diff changeset
   234
static inline const ShipVehicleInfo* ShipVehInfo(EngineID e)
538
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   235
{
2477
225b2916fe2a (svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents: 2464
diff changeset
   236
	assert(e >= SHIP_ENGINES_INDEX && e < SHIP_ENGINES_INDEX + lengthof(_ship_vehicle_info));
538
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   237
	return &_ship_vehicle_info[e - SHIP_ENGINES_INDEX];
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   238
}
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   239
2477
225b2916fe2a (svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents: 2464
diff changeset
   240
static inline const AircraftVehicleInfo* AircraftVehInfo(EngineID e)
538
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   241
{
2477
225b2916fe2a (svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents: 2464
diff changeset
   242
	assert(e >= AIRCRAFT_ENGINES_INDEX && e < AIRCRAFT_ENGINES_INDEX + lengthof(_aircraft_vehicle_info));
538
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   243
	return &_aircraft_vehicle_info[e - AIRCRAFT_ENGINES_INDEX];
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   244
}
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   245
2477
225b2916fe2a (svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents: 2464
diff changeset
   246
static inline const RoadVehicleInfo* RoadVehInfo(EngineID e)
538
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   247
{
2477
225b2916fe2a (svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents: 2464
diff changeset
   248
	assert(e >= ROAD_ENGINES_INDEX && e < ROAD_ENGINES_INDEX + lengthof(_road_vehicle_info));
538
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   249
	return &_road_vehicle_info[e - ROAD_ENGINES_INDEX];
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   250
}
405
415546028e8d (svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents: 389
diff changeset
   251
2848
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   252
/************************************************************************
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   253
 * Engine Replacement stuff
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   254
 ************************************************************************/
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   255
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   256
/**
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   257
 * Struct to store engine replacements. DO NOT USE outside of engine.c. Is
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   258
 * placed here so the only exception to this rule, the saveload code, can use
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   259
 * it.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   260
 */
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   261
struct EngineRenew {
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   262
	uint16 index;
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   263
	EngineID from;
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   264
	EngineID to;
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   265
	struct EngineRenew *next;
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   266
};
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   267
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   268
typedef struct EngineRenew EngineRenew;
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   269
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   270
/**
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   271
 * Memory pool for engine renew elements. DO NOT USE outside of engine.c. Is
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   272
 * placed here so the only exception to this rule, the saveload code, can use
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   273
 * it.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   274
 */
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   275
extern MemoryPool _engine_renew_pool;
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   276
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   277
/**
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   278
 * DO NOT USE outside of engine.c. Is
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   279
 * placed here so the only exception to this rule, the saveload code, can use
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   280
 * it.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   281
 */
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   282
static inline EngineRenew *GetEngineRenew(uint16 index)
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   283
{
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   284
	return (EngineRenew*)GetItemFromPool(&_engine_renew_pool, index);
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   285
}
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   286
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   287
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   288
/**
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   289
 * A list to group EngineRenew directives together (such as per-player).
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   290
 */
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   291
typedef EngineRenew* EngineRenewList;
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   292
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   293
/**
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   294
 * Remove all engine replacement settings for the player.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   295
 * @param  er The renewlist for a given player.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   296
 * @return The new renewlist for the player.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   297
 */
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   298
void RemoveAllEngineReplacement(EngineRenewList* erl);
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   299
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   300
/**
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   301
 * Retrieve the engine replacement in a given renewlist for an original engine type.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   302
 * @param  erl The renewlist to search in.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   303
 * @param  engine Engine type to be replaced.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   304
 * @return The engine type to replace with, or INVALID_ENGINE if no
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   305
 * replacement is in the list.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   306
 */
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   307
EngineID EngineReplacement(EngineRenewList erl, EngineID engine);
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   308
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   309
/**
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   310
 * Add an engine replacement to the given renewlist.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   311
 * @param erl The renewlist to add to.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   312
 * @param old_engine The original engine type.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   313
 * @param new_engine The replacement engine type.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   314
 * @param flags The calling command flags.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   315
 * @return 0 on success, CMD_ERROR on failure.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   316
 */
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   317
int32 AddEngineReplacement(EngineRenewList* erl, EngineID old_engine, EngineID new_engine, uint32 flags);
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   318
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   319
/**
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   320
 * Remove an engine replacement from a given renewlist.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   321
 * @param erl The renewlist from which to remove the replacement
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   322
 * @param engine The original engine type.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   323
 * @param flags The calling command flags.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   324
 * @return 0 on success, CMD_ERROR on failure.
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   325
 */
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   326
int32 RemoveEngineReplacement(EngineRenewList* erl, EngineID engine, uint32 flags);
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   327
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2331
diff changeset
   328
#endif /* ENGINE_H */