diff options
author | truelight <truelight@openttd.org> | 2005-01-06 22:31:58 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2005-01-06 22:31:58 +0000 |
commit | b450603437d1eae96e109058ab1c59b86be8a216 (patch) | |
tree | 254702245ba43d006f4823111d0c2c592fb701ca /vehicle.h | |
parent | 3845670c7847f468387c8513889dfb1db4e303d4 (diff) | |
download | openttd-b450603437d1eae96e109058ab1c59b86be8a216.tar.xz |
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
(in prepare of dynamic arrays):
- DEREF_XXX is changed into GetXXX
- All direct call are directed via GetXXX
- struct Industry has now an index-field
- ENUM'd some stuff
- Replaced home built loops with FOR_ALL_XXX
- Added _stations_size, _vehicles_size, ... which gives the length of the
array (which will be dynamic in the near future)
- Changed lengtof(XXX) to _XXX_size (e.g. _stations_size)
- Removed all endof(XXX) (because mostly it was part of a FOR_ALL_XXX)
- Made the sort-functions of all 4 dynamic
- Made all 4 Initialize functions more of the same
- Some minor tab-fixing and stuff
(tnx to Tron for proof-reading my 100kb patch ;))
Note for all: please do NOT directly call _stations, _vehicles, _towns and
_industries, but use the right wrapper to access them. Thank you.
Ps: please also do not use 'v++', where v is of type Vehicle *.
Diffstat (limited to 'vehicle.h')
-rw-r--r-- | vehicle.h | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -408,9 +408,6 @@ byte GetDirectionTowards(Vehicle *v, int x, int y); #define BEGIN_ENUM_WAGONS(v) do { #define END_ENUM_WAGONS(v) } while ( (v=v->next) != NULL); -#define DEREF_VEHICLE(i) (&_vehicles[i]) -#define FOR_ALL_VEHICLES(v) for(v=_vehicles; v != endof(_vehicles); v++) - /* vehicle.c */ enum { NUM_NORMAL_VEHICLES = 2048, @@ -419,6 +416,18 @@ enum { }; VARDEF Vehicle _vehicles[NUM_VEHICLES]; +VARDEF uint _vehicles_size; + +VARDEF SortStruct *_vehicle_sort; + +static inline Vehicle *GetVehicle(uint index) +{ + assert(index < _vehicles_size); + return &_vehicles[index]; +} + +#define FOR_ALL_VEHICLES(v) for(v = _vehicles; v != &_vehicles[_vehicles_size]; v++) +#define FOR_ALL_VEHICLES_FROM(v, from) for(v = GetVehicle(from); v != &_vehicles[_vehicles_size]; v++) VARDEF Order _order_array[5000]; VARDEF Order *_ptr_to_next_order; |