diff options
author | Darkvater <darkvater@openttd.org> | 2005-05-11 00:00:27 +0000 |
---|---|---|
committer | Darkvater <darkvater@openttd.org> | 2005-05-11 00:00:27 +0000 |
commit | 5e6923e9369a5a531d9b64da45fcfcc91f7687de (patch) | |
tree | 52f7adfab821276fb325d32c2907e8ab6461f2a5 /engine.h | |
parent | fe223eccf40cd7cf1d81053c5565e9cdbffe414c (diff) | |
download | openttd-5e6923e9369a5a531d9b64da45fcfcc91f7687de.tar.xz |
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
- CodeChange: To correctly accept engine-prototypes, the best-player checking has been moved to its own function, I hope it functions the same as before.
- CodeChange: Added symbolic types of PlayerID, OrderID and EngineID. For engines also added GetEngine() and IsEngineIndex(), similar to the other such functions.
- CodeChange: To correctly build industries, some tables have been moved to build_industry.h. The only way to find out currently if an industry is valid in a climate is by looping all industries and checking if it matches. Also to comply with the patch setting build_rawmaterial_industries, it is assumed that these industries do not accept any cargo of any type. This can and probably should changed in the future to some flag in their struct. Also use _opt_ptr instead of _opt.
- CodeChange: implemented the HQ checking code inspired by MarkR2 in "[ 1190944 ] Many commands not checked for security". Unfortunately it is impossible to prevent only deleting a HQ by a modified client atm.
- CodeChange: For insert order and modify order their parameters are implicitely truncated to 8 bits, instead of the 16 bits said in the comments.
Diffstat (limited to 'engine.h')
-rw-r--r-- | engine.h | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -66,10 +66,10 @@ typedef struct Engine { uint16 duration_phase_1, duration_phase_2, duration_phase_3; byte lifelength; byte flags; - byte preview_player; + PlayerID preview_player; byte preview_wait; byte railtype; - byte player_avail; + PlayerID player_avail; byte type; // type, ie VEH_Road, VEH_Train, etc. Same as in vehicle.h } Engine; @@ -128,7 +128,7 @@ void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw); void DrawShipEngineInfo(int engine, int x, int y, int maxw); void DrawAircraftEngineInfo(int engine, int x, int y, int maxw); -void AcceptEnginePreview(Engine *e, int player); +void AcceptEnginePreview(Engine *e, PlayerID player); void LoadCustomEngineNames(void); void DeleteCustomEngineNames(void); @@ -150,9 +150,21 @@ enum { ROAD_ENGINES_INDEX = NUM_TRAIN_ENGINES, }; VARDEF Engine _engines[TOTAL_NUM_ENGINES]; -#define DEREF_ENGINE(i) (&_engines[i]) +#define FOR_ALL_ENGINES(e) for (e = _engines; e != endof(_engines); e++) +#define DEREF_ENGINE(i) (GetEngine(i)) +static inline Engine* GetEngine(uint i) +{ + assert(i < lengthof(_engines)); + return &_engines[i]; +} + VARDEF StringID _engine_name_strings[TOTAL_NUM_ENGINES]; +static inline bool IsEngineIndex(uint index) +{ + return index < TOTAL_NUM_ENGINES; +} + /* Access Vehicle Data */ //#include "table/engines.h" extern EngineInfo _engine_info[TOTAL_NUM_ENGINES]; |