136 |
136 |
137 DEBUG(eco, 5, "Modifying EAL for town at 0x%x by %f to %f", xy, (double)activity_change, (double)this->GetActivity()); |
137 DEBUG(eco, 5, "Modifying EAL for town at 0x%x by %f to %f", xy, (double)activity_change, (double)this->GetActivity()); |
138 } |
138 } |
139 }; |
139 }; |
140 |
140 |
141 uint32 GetWorldPopulation(void); |
141 uint32 GetWorldPopulation(); |
142 |
142 |
143 void UpdateTownVirtCoord(Town *t); |
143 void UpdateTownVirtCoord(Town *t); |
144 void InitializeTown(void); |
144 void InitializeTown(); |
145 void ShowTownViewWindow(TownID town); |
145 void ShowTownViewWindow(TownID town); |
146 void ExpandTown(Town *t); |
146 void ExpandTown(Town *t); |
147 Town *CreateRandomTown(uint attempts, uint size_mode); |
147 Town *CreateRandomTown(uint attempts, uint size_mode); |
148 |
148 |
149 enum { |
149 enum { |
229 return index < GetTownPoolSize() && IsValidTown(GetTown(index)); |
229 return index < GetTownPoolSize() && IsValidTown(GetTown(index)); |
230 } |
230 } |
231 |
231 |
232 VARDEF uint _total_towns; |
232 VARDEF uint _total_towns; |
233 |
233 |
234 static inline TownID GetMaxTownIndex(void) |
234 static inline TownID GetMaxTownIndex() |
235 { |
235 { |
236 /* TODO - This isn't the real content of the function, but |
236 /* TODO - This isn't the real content of the function, but |
237 * with the new pool-system this will be replaced with one that |
237 * with the new pool-system this will be replaced with one that |
238 * _really_ returns the highest index. Now it just returns |
238 * _really_ returns the highest index. Now it just returns |
239 * the next safe value we are sure about everything is below. |
239 * the next safe value we are sure about everything is below. |
240 */ |
240 */ |
241 return GetTownPoolSize() - 1; |
241 return GetTownPoolSize() - 1; |
242 } |
242 } |
243 |
243 |
244 static inline uint GetNumTowns(void) |
244 static inline uint GetNumTowns() |
245 { |
245 { |
246 return _total_towns; |
246 return _total_towns; |
247 } |
247 } |
248 |
248 |
249 /** |
249 /** |
250 * Return a random valid town. |
250 * Return a random valid town. |
251 */ |
251 */ |
252 static inline Town *GetRandomTown(void) |
252 static inline Town *GetRandomTown() |
253 { |
253 { |
254 int num = RandomRange(GetNumTowns()); |
254 int num = RandomRange(GetNumTowns()); |
255 TownID index = INVALID_TOWN; |
255 TownID index = INVALID_TOWN; |
256 |
256 |
257 while (num >= 0) { |
257 while (num >= 0) { |