(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 *.
This commit is contained in:
15
town.h
15
town.h
@@ -91,10 +91,19 @@ enum {
|
||||
|
||||
bool CheckforTownRating(uint tile, uint32 flags, Town *t, byte type);
|
||||
|
||||
#define DEREF_TOWN(i) (&_towns[i])
|
||||
#define FOR_ALL_TOWNS(c) for(c=_towns; c != endof(_towns); c++)
|
||||
|
||||
VARDEF Town _towns[70];
|
||||
VARDEF uint _towns_size;
|
||||
|
||||
VARDEF uint16 *_town_sort;
|
||||
|
||||
static inline Town *GetTown(uint index)
|
||||
{
|
||||
assert(index < _towns_size);
|
||||
return &_towns[index];
|
||||
}
|
||||
|
||||
#define FOR_ALL_TOWNS(t) for(t = _towns; t != &_towns[_towns_size]; t++)
|
||||
|
||||
VARDEF int _total_towns; // For the AI: the amount of towns active
|
||||
|
||||
VARDEF bool _town_sort_dirty;
|
||||
|
||||
Reference in New Issue
Block a user