town.h
changeset 1260 632f63689178
parent 1220 8b951444b021
child 1330 5d76a0522a11
equal deleted inserted replaced
1259:8d8515e3da29 1260:632f63689178
     1 #ifndef TOWN_H
     1 #ifndef TOWN_H
     2 #define TOWN_H
     2 #define TOWN_H
     3 
     3 
       
     4 #include "pool.h"
     4 #include "player.h"
     5 #include "player.h"
     5 
     6 
     6 struct Town {
     7 struct Town {
     7 	TileIndex xy;
     8 	TileIndex xy;
     8 
     9 
   126 	RATING_BRIBE_DOWN_TO = -50 					// XXX SHOULD BE SOMETHING LOWER?
   127 	RATING_BRIBE_DOWN_TO = -50 					// XXX SHOULD BE SOMETHING LOWER?
   127 };
   128 };
   128 
   129 
   129 bool CheckforTownRating(uint tile, uint32 flags, Town *t, byte type);
   130 bool CheckforTownRating(uint tile, uint32 flags, Town *t, byte type);
   130 
   131 
   131 VARDEF Town _towns[250];
       
   132 VARDEF uint _towns_size;
       
   133 
       
   134 VARDEF uint16 *_town_sort;
   132 VARDEF uint16 *_town_sort;
   135 
   133 
       
   134 extern MemoryPool _town_pool;
       
   135 
       
   136 /**
       
   137  * Get the pointer to the town with index 'index'
       
   138  */
   136 static inline Town *GetTown(uint index)
   139 static inline Town *GetTown(uint index)
   137 {
   140 {
   138 	assert(index < _towns_size);
   141 	return (Town*)GetItemFromPool(&_town_pool, index);
   139 	return &_towns[index];
       
   140 }
   142 }
   141 
   143 
   142 #define FOR_ALL_TOWNS(t) for(t = _towns; t != &_towns[_towns_size]; t++)
   144 /**
       
   145  * Get the current size of the TownPool
       
   146  */
       
   147 static inline uint16 GetTownPoolSize(void)
       
   148 {
       
   149 	return _town_pool.total_items;
       
   150 }
   143 
   151 
   144 VARDEF int _total_towns; // For the AI: the amount of towns active
   152 #define FOR_ALL_TOWNS_FROM(t, start) for (t = GetTown(start); t != NULL; t = (t->index + 1 < GetTownPoolSize()) ? GetTown(t->index + 1) : NULL)
       
   153 #define FOR_ALL_TOWNS(t) FOR_ALL_TOWNS_FROM(t, 0)
       
   154 
       
   155 VARDEF uint _total_towns; // For the AI: the amount of towns active
   145 
   156 
   146 VARDEF bool _town_sort_dirty;
   157 VARDEF bool _town_sort_dirty;
   147 VARDEF byte _town_sort_order;
   158 VARDEF byte _town_sort_order;
   148 
   159 
   149 VARDEF Town *_cleared_town;
   160 VARDEF Town *_cleared_town;