src/engine.h
author rubidium
Sun, 13 Jan 2008 13:36:01 +0000
changeset 8268 5027ad5e70a0
parent 8264 b1e85998c7d3
child 8449 64c872ab3ed3
permissions -rw-r--r--
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
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
6125
a6fff965707c (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents: 5955
diff changeset
     3
/** @file engine.h */
a6fff965707c (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents: 5955
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#ifndef ENGINE_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     6
#define ENGINE_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
8103
cf92483a0abf (svn r11664) -Codechange: use more specific ("rail_type.h" instead of "rail.h" that includes way more than only "rail_type.h") includes at some places.
rubidium
parents: 7496
diff changeset
     8
#include "rail_type.h"
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8103
diff changeset
     9
#include "cargo_type.h"
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8103
diff changeset
    10
#include "vehicle_type.h"
8123
ce31d2843a95 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8119
diff changeset
    11
#include "gfx_type.h"
8140
0d0d8c94f84b (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8139
diff changeset
    12
#include "date_type.h"
8157
1505def01945 (svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents: 8140
diff changeset
    13
#include "sound_type.h"
8254
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8237
diff changeset
    14
#include "player_type.h"
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8259
diff changeset
    15
#include "strings_type.h"
405
415546028e8d (svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents: 389
diff changeset
    16
5868
94430141c189 (svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents: 5855
diff changeset
    17
enum RailVehicleTypes {
6125
a6fff965707c (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents: 5955
diff changeset
    18
	RAILVEH_SINGLEHEAD,  ///< indicates a "standalone" locomotive
a6fff965707c (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents: 5955
diff changeset
    19
	RAILVEH_MULTIHEAD,   ///< indicates a combination of two locomotives
a6fff965707c (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents: 5955
diff changeset
    20
	RAILVEH_WAGON,       ///< simple wagon, not motorized
5868
94430141c189 (svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents: 5855
diff changeset
    21
};
94430141c189 (svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents: 5855
diff changeset
    22
6581
3641873f4f3f (svn r9795) -Codechange: enumify the EngineClass.
rubidium
parents: 6505
diff changeset
    23
enum EngineClass {
3641873f4f3f (svn r9795) -Codechange: enumify the EngineClass.
rubidium
parents: 6505
diff changeset
    24
	EC_STEAM,
3641873f4f3f (svn r9795) -Codechange: enumify the EngineClass.
rubidium
parents: 6505
diff changeset
    25
	EC_DIESEL,
3641873f4f3f (svn r9795) -Codechange: enumify the EngineClass.
rubidium
parents: 6505
diff changeset
    26
	EC_ELECTRIC,
6585
46035c6baa8d (svn r9799) -Codechange: separate engine class and engine running cost class (mart3p).
rubidium
parents: 6581
diff changeset
    27
	EC_MONORAIL,
46035c6baa8d (svn r9799) -Codechange: separate engine class and engine running cost class (mart3p).
rubidium
parents: 6581
diff changeset
    28
	EC_MAGLEV,
6581
3641873f4f3f (svn r9795) -Codechange: enumify the EngineClass.
rubidium
parents: 6505
diff changeset
    29
};
3641873f4f3f (svn r9795) -Codechange: enumify the EngineClass.
rubidium
parents: 6505
diff changeset
    30
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    31
struct RailVehicleInfo {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
	byte image_index;
5868
94430141c189 (svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents: 5855
diff changeset
    33
	RailVehicleTypes railveh_type;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
	byte base_cost;
5823
7aa8c2312103 (svn r8385) -Fix
tron
parents: 5770
diff changeset
    35
	RailTypeByte railtype;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
	uint16 max_speed;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
	uint16 power;
2542
812fc4357594 (svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents: 2530
diff changeset
    38
	uint16 weight;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
	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
    40
	byte running_cost_class;
6581
3641873f4f3f (svn r9795) -Codechange: enumify the EngineClass.
rubidium
parents: 6505
diff changeset
    41
	EngineClass engclass;           ///< Class of engine for this vehicle
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
	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
    43
	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
    44
	byte ai_rank;
1908
2fa391fed79a (svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents: 1895
diff changeset
    45
	uint16 pow_wag_power;
2fa391fed79a (svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents: 1895
diff changeset
    46
	byte pow_wag_weight;
2fa391fed79a (svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents: 1895
diff changeset
    47
	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
    48
	                    //       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
    49
	                    //       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
    50
	                    //       Same goes for the callback result, which atm is only used to check if a wagon is powered.
6125
a6fff965707c (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents: 5955
diff changeset
    51
	byte shorten_factor;   ///< length on main map for this type is 8 - shorten_factor
7318
632cd0497770 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 6943
diff changeset
    52
	byte tractive_effort;  ///< Tractive effort coefficient
6125
a6fff965707c (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents: 5955
diff changeset
    53
	byte user_def_data;    ///< Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    54
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    56
struct ShipVehicleInfo {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
	byte image_index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
	byte base_cost;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
	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
    60
	CargoID cargo_type;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
	uint16 capacity;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
	byte running_cost;
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
    63
	SoundFxByte sfx;
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
    64
	bool refittable;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    65
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
5855
6f273e99a57a (svn r8429) -Codechange: Add a name for AircraftVehicleInfo subtype helicopter and remove some magic numbers related to the subtype.
Darkvater
parents: 5854
diff changeset
    67
/* AircraftVehicleInfo subtypes, bitmask type.
6f273e99a57a (svn r8429) -Codechange: Add a name for AircraftVehicleInfo subtype helicopter and remove some magic numbers related to the subtype.
Darkvater
parents: 5854
diff changeset
    68
 * If bit 0 is 0 then it is a helicopter, otherwise it is a plane
6f273e99a57a (svn r8429) -Codechange: Add a name for AircraftVehicleInfo subtype helicopter and remove some magic numbers related to the subtype.
Darkvater
parents: 5854
diff changeset
    69
 * in which case bit 1 tells us whether it's a big(fast) plane or not */
4023
5d84c056a2b1 (svn r5262) Add symbolic names for the aircraft subtypes. not perfect, but better than raw numbers
tron
parents: 3997
diff changeset
    70
enum {
5855
6f273e99a57a (svn r8429) -Codechange: Add a name for AircraftVehicleInfo subtype helicopter and remove some magic numbers related to the subtype.
Darkvater
parents: 5854
diff changeset
    71
	AIR_HELI = 0,
6125
a6fff965707c (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents: 5955
diff changeset
    72
	AIR_CTOL = 1, ///< Conventional Take Off and Landing, i.e. planes
4023
5d84c056a2b1 (svn r5262) Add symbolic names for the aircraft subtypes. not perfect, but better than raw numbers
tron
parents: 3997
diff changeset
    73
	AIR_FAST = 2
5d84c056a2b1 (svn r5262) Add symbolic names for the aircraft subtypes. not perfect, but better than raw numbers
tron
parents: 3997
diff changeset
    74
};
5d84c056a2b1 (svn r5262) Add symbolic names for the aircraft subtypes. not perfect, but better than raw numbers
tron
parents: 3997
diff changeset
    75
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    76
struct AircraftVehicleInfo {
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
    77
	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
    78
	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
    79
	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
    80
	byte subtype;
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
    81
	SoundFxByte sfx;
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
    82
	byte acceleration;
6193
6f20de9e4f1b (svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar
parents: 6174
diff changeset
    83
	uint16 max_speed;
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
    84
	byte mail_capacity;
922
10035216cbaf (svn r1410) Replaced all occurences of 'passanger' by 'passenger' in the code
celestar
parents: 842
diff changeset
    85
	uint16 passenger_capacity;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    86
};
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
    87
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    88
struct RoadVehicleInfo {
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
    89
	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
    90
	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
    91
	byte running_cost;
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
    92
	SoundFxByte sfx;
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
    93
	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
    94
	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
    95
	CargoID cargo_type;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    96
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
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
    98
/** Information about a vehicle
4549
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4434
diff changeset
    99
 *  @see table/engines.h
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4434
diff changeset
   100
 */
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   101
struct EngineInfo {
4289
8981ce44336d (svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents: 4077
diff changeset
   102
	Date base_intro;
4326
2e2c9d21ed96 (svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents: 4289
diff changeset
   103
	Year lifelength;
2e2c9d21ed96 (svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents: 4289
diff changeset
   104
	Year base_life;
6488
b6c42e91bb35 (svn r9669) -Documentation: some more doxygen fixes
belugas
parents: 6481
diff changeset
   105
	byte unk2;         ///< flag for carriage(bit 7) and decay speed(bits0..6)
5211
fb4dc0ca975d (svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents: 5187
diff changeset
   106
	byte load_amount;
5763
a6029daa547f (svn r8314) -Fix
tron
parents: 5668
diff changeset
   107
	byte climates;
2611
36aa372eeb34 (svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents: 2602
diff changeset
   108
	uint32 refit_mask;
3997
8a997effbcec (svn r5201) - NewGRF: add loading of default refit costs. This information is not yet used
peter1138
parents: 3956
diff changeset
   109
	byte refit_cost;
3095
19084629d27a (svn r3684) - NewGRF: Support loading of miscellaneous flags (not used yet)
peter1138
parents: 3022
diff changeset
   110
	byte misc_flags;
3956
92362ba224b7 (svn r5105) - NewGRF: Move callbackmask from *VehicleInfo to EngineInfo. This simplifies code that works with more than one vehicle type.
peter1138
parents: 3866
diff changeset
   111
	byte callbackmask;
6606
cc9f292f7223 (svn r9825) -Codechange: [NewGRF] Add support for early vehicle retirement.
peter1138
parents: 6599
diff changeset
   112
	byte retire_early; ///< Number of years early to retire vehicle
8258
9fa31acb07bc (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8254
diff changeset
   113
	StringID string_id; ///< Default name of engine
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   114
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   116
struct Engine {
8258
9fa31acb07bc (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8254
diff changeset
   117
	char *name;         ///< Custom name of engine
4289
8981ce44336d (svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents: 4077
diff changeset
   118
	Date intro_date;
8981ce44336d (svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents: 4077
diff changeset
   119
	Date age;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
	uint16 reliability;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
	uint16 reliability_spd_dec;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
	uint16 reliability_start, reliability_max, reliability_final;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
	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
   124
	byte lifelength;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
	byte flags;
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
   126
	PlayerByte preview_player;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
	byte preview_wait;
2331
84638ba57139 (svn r2857) -Fix: PlayerID is not a valid type for a player-bit-field. Partly reverted r2290
truelight
parents: 2186
diff changeset
   128
	byte player_avail;
8139
4e91c448c409 (svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium
parents: 8123
diff changeset
   129
	VehicleType type; ///< type, ie VEH_ROAD, VEH_TRAIN, etc.
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   130
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
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
   132
/**
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
   133
 * 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
   134
 */
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
   135
enum {
6685
00490513d7b1 (svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents: 6643
diff changeset
   136
	EF_RAIL_TILTS = 0, ///< Rail vehicle tilts in curves
00490513d7b1 (svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents: 6643
diff changeset
   137
	EF_ROAD_TRAM  = 0, ///< Road vehicle is a tram/light rail vehicle
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
   138
	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
   139
	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
   140
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
6174
0c743995213f (svn r8944) -Codechange: Move the enum describing the bitmask of Engine.flags to engine.h and give the enum values better names.
maedhros
parents: 6125
diff changeset
   142
/**
0c743995213f (svn r8944) -Codechange: Move the enum describing the bitmask of Engine.flags to engine.h and give the enum values better names.
maedhros
parents: 6125
diff changeset
   143
 * Engine.flags is a bitmask, with the following values.
0c743995213f (svn r8944) -Codechange: Move the enum describing the bitmask of Engine.flags to engine.h and give the enum values better names.
maedhros
parents: 6125
diff changeset
   144
 */
0c743995213f (svn r8944) -Codechange: Move the enum describing the bitmask of Engine.flags to engine.h and give the enum values better names.
maedhros
parents: 6125
diff changeset
   145
enum {
0c743995213f (svn r8944) -Codechange: Move the enum describing the bitmask of Engine.flags to engine.h and give the enum values better names.
maedhros
parents: 6125
diff changeset
   146
	ENGINE_AVAILABLE         = 1, ///< This vehicle is available to everyone.
0c743995213f (svn r8944) -Codechange: Move the enum describing the bitmask of Engine.flags to engine.h and give the enum values better names.
maedhros
parents: 6125
diff changeset
   147
	ENGINE_EXCLUSIVE_PREVIEW = 2, ///< This vehicle is in the exclusive preview stage, either being used or being offered to a player.
0c743995213f (svn r8944) -Codechange: Move the enum describing the bitmask of Engine.flags to engine.h and give the enum values better names.
maedhros
parents: 6125
diff changeset
   148
	ENGINE_OFFER_WINDOW_OPEN = 4, ///< The exclusive offer window is currently open for a player.
0c743995213f (svn r8944) -Codechange: Move the enum describing the bitmask of Engine.flags to engine.h and give the enum values better names.
maedhros
parents: 6125
diff changeset
   149
};
0c743995213f (svn r8944) -Codechange: Move the enum describing the bitmask of Engine.flags to engine.h and give the enum values better names.
maedhros
parents: 6125
diff changeset
   150
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
enum {
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
   152
	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
   153
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
   155
static const EngineID INVALID_ENGINE = 0xFFFF;
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
   156
2848
8f57563f8ddf (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
   157
8221
59791d0e0c04 (svn r11784) -Codechange: set up initial engine data in one place
peter1138
parents: 8212
diff changeset
   158
void SetupEngines();
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6193
diff changeset
   159
void StartupEngines();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   162
void DrawTrainEngine(int x, int y, EngineID engine, SpriteID pal);
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   163
void DrawRoadVehEngine(int x, int y, EngineID engine, SpriteID pal);
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   164
void DrawShipEngine(int x, int y, EngineID engine, SpriteID pal);
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   165
void DrawAircraftEngine(int x, int y, EngineID engine, SpriteID pal);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6193
diff changeset
   167
void LoadCustomEngineNames();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6193
diff changeset
   168
void DeleteCustomEngineNames();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
5215
b8fb685df4c5 (svn r7330) -Fix (r7304): Data invalidation doesn't always happen as the local
peter1138
parents: 5211
diff changeset
   170
bool IsEngineBuildable(EngineID engine, byte type, PlayerID player);
6505
8b4c20ddacd3 (svn r9688) -Codechange: Created a function to get default cargo type for a cargo type
bjarni
parents: 6488
diff changeset
   171
CargoID GetEngineCargoType(EngineID engine);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
enum {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
	NUM_NORMAL_RAIL_ENGINES = 54,
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   175
	NUM_MONORAIL_ENGINES    = 30,
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   176
	NUM_MAGLEV_ENGINES      = 32,
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   177
	NUM_TRAIN_ENGINES       = NUM_NORMAL_RAIL_ENGINES + NUM_MONORAIL_ENGINES + NUM_MAGLEV_ENGINES,
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   178
	NUM_ROAD_ENGINES        = 88,
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   179
	NUM_SHIP_ENGINES        = 11,
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   180
	NUM_AIRCRAFT_ENGINES    = 41,
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   181
	TOTAL_NUM_ENGINES       = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES + NUM_AIRCRAFT_ENGINES,
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   182
	AIRCRAFT_ENGINES_INDEX  = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES,
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   183
	SHIP_ENGINES_INDEX      = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES,
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   184
	ROAD_ENGINES_INDEX      = NUM_TRAIN_ENGINES,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
};
5944
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   186
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   187
static inline EngineID GetFirstEngineOfType(byte type)
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   188
{
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   189
	const EngineID start[] = {0, ROAD_ENGINES_INDEX, SHIP_ENGINES_INDEX, AIRCRAFT_ENGINES_INDEX};
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   190
5955
fe61588d5188 (svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents: 5944
diff changeset
   191
	return start[type];
5944
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   192
}
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   193
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   194
static inline EngineID GetLastEngineOfType(byte type)
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   195
{
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   196
	const EngineID end[] = {
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   197
		NUM_TRAIN_ENGINES,
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   198
		ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES,
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   199
		SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES,
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   200
		AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES};
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   201
5955
fe61588d5188 (svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents: 5944
diff changeset
   202
	return end[type];
5944
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   203
}
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   204
8268
5027ad5e70a0 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents: 8264
diff changeset
   205
extern 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
   206
#define FOR_ALL_ENGINES(e) for (e = _engines; e != endof(_engines); e++)
5944
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   207
#define FOR_ALL_ENGINEIDS_OF_TYPE(e, type) for (e = GetFirstEngineOfType(type); e != GetLastEngineOfType(type); e++)
6d059cc8662b (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 5868
diff changeset
   208
1926
530480d14685 (svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents: 1922
diff changeset
   209
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
   210
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
   211
{
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4023
diff changeset
   212
	assert(i < lengthof(_engines));
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4023
diff changeset
   213
	return &_engines[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
   214
}
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
   215
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
   216
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
   217
{
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
   218
	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
   219
}
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
   220
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
   221
/* Access Vehicle Data */
8226
9c72921cf666 (svn r11789) -Codechange: coding style for global variable names
peter1138
parents: 8221
diff changeset
   222
extern const EngineInfo _orig_engine_info[TOTAL_NUM_ENGINES];
9c72921cf666 (svn r11789) -Codechange: coding style for global variable names
peter1138
parents: 8221
diff changeset
   223
extern const RailVehicleInfo _orig_rail_vehicle_info[NUM_TRAIN_ENGINES];
9c72921cf666 (svn r11789) -Codechange: coding style for global variable names
peter1138
parents: 8221
diff changeset
   224
extern const ShipVehicleInfo _orig_ship_vehicle_info[NUM_SHIP_ENGINES];
9c72921cf666 (svn r11789) -Codechange: coding style for global variable names
peter1138
parents: 8221
diff changeset
   225
extern const AircraftVehicleInfo _orig_aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES];
9c72921cf666 (svn r11789) -Codechange: coding style for global variable names
peter1138
parents: 8221
diff changeset
   226
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
   227
2763
a4d065e3261b (svn r3308) BAD
tron
parents: 2611
diff changeset
   228
extern EngineInfo _engine_info[TOTAL_NUM_ENGINES];
a4d065e3261b (svn r3308) BAD
tron
parents: 2611
diff changeset
   229
extern RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES];
a4d065e3261b (svn r3308) BAD
tron
parents: 2611
diff changeset
   230
extern ShipVehicleInfo _ship_vehicle_info[NUM_SHIP_ENGINES];
a4d065e3261b (svn r3308) BAD
tron
parents: 2611
diff changeset
   231
extern AircraftVehicleInfo _aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES];
a4d065e3261b (svn r3308) BAD
tron
parents: 2611
diff changeset
   232
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
   233
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
   234
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
   235
{
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
   236
	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
   237
	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
   238
}
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
   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 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
   241
{
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   242
	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
   243
	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
   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 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
   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 >= 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
   249
	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
   250
}
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   251
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
   252
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
   253
{
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
   254
	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
   255
	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
   256
}
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 445
diff changeset
   257
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
   258
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
   259
{
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
   260
	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
   261
	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
   262
}
405
415546028e8d (svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents: 389
diff changeset
   263
5187
12dc9dfa6af6 (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5037
diff changeset
   264
/* Engine list manipulators - current implementation is only C wrapper of CBlobT<EngineID> class (helpers.cpp) */
12dc9dfa6af6 (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5037
diff changeset
   265
void EngList_Create(EngineList *el);            ///< Creates engine list
12dc9dfa6af6 (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5037
diff changeset
   266
void EngList_Destroy(EngineList *el);           ///< Deallocate and destroy engine list
12dc9dfa6af6 (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5037
diff changeset
   267
uint EngList_Count(const EngineList *el);       ///< Returns number of items in the engine list
12dc9dfa6af6 (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5037
diff changeset
   268
void EngList_Add(EngineList *el, EngineID eid); ///< Append one item at the end of engine list
12dc9dfa6af6 (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5037
diff changeset
   269
EngineID* EngList_Items(EngineList *el);        ///< Returns engine list items as C array
12dc9dfa6af6 (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5037
diff changeset
   270
void EngList_RemoveAll(EngineList *el);         ///< Removes all items from engine list
12dc9dfa6af6 (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5037
diff changeset
   271
typedef int CDECL EngList_SortTypeFunction(const void*, const void*); ///< argument type for EngList_Sort()
12dc9dfa6af6 (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5037
diff changeset
   272
void EngList_Sort(EngineList *el, EngList_SortTypeFunction compare); ///< qsort of the engine list
12dc9dfa6af6 (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5037
diff changeset
   273
void EngList_SortPartial(EngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items); ///< qsort of specified portion of the engine list
12dc9dfa6af6 (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5037
diff changeset
   274
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
   275
#endif /* ENGINE_H */