tron@2186: /* $Id$ */ tron@2186: truelight@0: #ifndef TOWN_H truelight@0: #define TOWN_H truelight@0: truelight@1260: #include "pool.h" truelight@0: #include "player.h" truelight@0: truelight@0: struct Town { truelight@0: TileIndex xy; truelight@0: truelight@0: // Current population of people and amount of houses. truelight@0: uint16 num_houses; truelight@0: uint32 population; truelight@193: truelight@0: // Town name truelight@0: uint16 townnametype; truelight@0: uint32 townnameparts; truelight@193: truelight@193: // NOSAVE: Location of name sign, UpdateTownVirtCoord updates this. truelight@0: ViewportSign sign; truelight@193: truelight@0: // Makes sure we don't build certain house types twice. truelight@0: byte flags12; truelight@0: truelight@0: // Which players have a statue? truelight@0: byte statues; truelight@0: truelight@0: // Sort index in listings truelight@0: byte sort_index_obsolete; truelight@0: truelight@0: // Player ratings as well as a mask that determines which players have a rating. truelight@0: byte have_ratings; truelight@0: uint8 unwanted[MAX_PLAYERS]; // how many months companies aren't wanted by towns (bribe) tron@2498: PlayerID exclusivity; // which player has exslusivity dominik@121: uint8 exclusive_counter; // months till the exclusivity expires truelight@0: int16 ratings[MAX_PLAYERS]; truelight@193: truelight@0: // Maximum amount of passengers and mail that can be transported. celestar@1377: uint32 max_pass; celestar@1377: uint32 max_mail; celestar@1377: uint32 new_max_pass; celestar@1377: uint32 new_max_mail; celestar@1377: uint32 act_pass; celestar@1377: uint32 act_mail; celestar@1377: uint32 new_act_pass; celestar@1377: uint32 new_act_mail; truelight@0: truelight@0: // Amount of passengers that were transported. truelight@0: byte pct_pass_transported; truelight@0: byte pct_mail_transported; truelight@0: truelight@0: // Amount of food and paper that was transported. Actually a bit mask would be enough. truelight@0: uint16 act_food; darkvater@4: uint16 act_water; truelight@0: uint16 new_act_food; darkvater@4: uint16 new_act_water; truelight@193: truelight@0: // Time until we rebuild a house. truelight@0: byte time_until_rebuild; truelight@0: truelight@0: // When to grow town next time. truelight@0: byte grow_counter; truelight@193: byte growth_rate; truelight@0: truelight@0: // Fund buildings program in action? truelight@0: byte fund_buildings_months; truelight@193: truelight@0: // Fund road reconstruction in action? truelight@0: byte road_build_months; truelight@0: truelight@0: // Index in town array truelight@820: uint16 index; truelight@0: truelight@0: // NOSAVE: UpdateTownRadius updates this given the house count. truelight@0: uint16 radius[5]; truelight@0: }; truelight@0: tron@1093: uint32 GetWorldPopulation(void); truelight@0: truelight@835: void UpdateTownVirtCoord(Town *t); tron@1093: void InitializeTown(void); truelight@0: void ShowTownViewWindow(uint town); truelight@0: void DeleteTown(Town *t); truelight@0: void ExpandTown(Town *t); celestar@1362: Town *CreateRandomTown(uint attempts); truelight@0: truelight@0: enum { truelight@0: ROAD_REMOVE = 0, truelight@0: UNMOVEABLE_REMOVE = 1, truelight@0: TUNNELBRIDGE_REMOVE = 1, truelight@0: INDUSTRY_REMOVE = 2 truelight@0: }; truelight@0: celestar@1005: enum { celestar@1005: // These refer to the maximums, so Appalling is -1000 to -400 celestar@1005: // MAXIMUM RATINGS BOUNDARIES celestar@1005: RATING_MINIMUM = -1000, celestar@1005: RATING_APPALLING = -400, celestar@1005: RATING_VERYPOOR = -200, celestar@1005: RATING_POOR = 0, celestar@1005: RATING_MEDIOCRE = 200, celestar@1005: RATING_GOOD = 400, celestar@1005: RATING_VERYGOOD = 600, celestar@1005: RATING_EXCELLENT = 800, celestar@1005: RATING_OUTSTANDING= 1000, // OUTSTANDING celestar@1005: celestar@1005: RATING_MAXIMUM = RATING_OUTSTANDING, celestar@1005: celestar@1005: // RATINGS AFFECTING NUMBERS celestar@1005: RATING_TREE_DOWN_STEP = -35, celestar@1005: RATING_TREE_MINIMUM = RATING_MINIMUM, celestar@1005: RATING_TREE_UP_STEP = 7, celestar@1005: RATING_TREE_MAXIMUM = 220, celestar@1005: celestar@1005: RATING_TUNNEL_BRIDGE_DOWN_STEP = -250, celestar@1005: RATING_TUNNEL_BRIDGE_MINIMUM = 0, celestar@1005: celestar@1005: RATING_INDUSTRY_DOWN_STEP = -1500, celestar@1005: RATING_INDUSTRY_MINIMUM = RATING_MINIMUM, celestar@1005: celestar@1005: RATING_ROAD_DOWN_STEP = -50, celestar@1005: RATING_ROAD_MINIMUM = -100, celestar@1005: RATING_HOUSE_MINIMUM = RATING_MINIMUM, celestar@1005: celestar@1005: RATING_BRIBE_UP_STEP = 200, celestar@1005: RATING_BRIBE_MAXIMUM = 800, tron@1019: RATING_BRIBE_DOWN_TO = -50 // XXX SHOULD BE SOMETHING LOWER? celestar@1005: }; celestar@1005: tron@1977: bool CheckforTownRating(TileIndex tile, uint32 flags, Town *t, byte type); truelight@0: truelight@919: VARDEF uint16 *_town_sort; truelight@919: truelight@1260: extern MemoryPool _town_pool; truelight@1260: truelight@1260: /** matthijs@1330: * Check if a Town really exists. matthijs@1330: */ Darkvater@2436: static inline bool IsValidTown(const Town* town) matthijs@1330: { matthijs@1330: return town->xy != 0; /* XXX: Replace by INVALID_TILE someday */ matthijs@1330: } matthijs@1330: matthijs@1330: /** truelight@1260: * Get the pointer to the town with index 'index' truelight@1260: */ truelight@919: static inline Town *GetTown(uint index) truelight@919: { truelight@1260: return (Town*)GetItemFromPool(&_town_pool, index); truelight@919: } truelight@919: truelight@1260: /** truelight@1260: * Get the current size of the TownPool truelight@1260: */ truelight@1260: static inline uint16 GetTownPoolSize(void) truelight@1260: { truelight@1260: return _town_pool.total_items; truelight@1260: } truelight@919: Darkvater@1784: static inline bool IsTownIndex(uint index) Darkvater@1784: { Darkvater@1784: return index < GetTownPoolSize(); Darkvater@1784: } Darkvater@1784: truelight@1260: #define FOR_ALL_TOWNS_FROM(t, start) for (t = GetTown(start); t != NULL; t = (t->index + 1 < GetTownPoolSize()) ? GetTown(t->index + 1) : NULL) truelight@1260: #define FOR_ALL_TOWNS(t) FOR_ALL_TOWNS_FROM(t, 0) truelight@1260: truelight@1260: VARDEF uint _total_towns; // For the AI: the amount of towns active truelight@0: truelight@0: VARDEF bool _town_sort_dirty; truelight@0: VARDEF byte _town_sort_order; truelight@0: truelight@0: VARDEF Town *_cleared_town; truelight@0: VARDEF int _cleared_town_rating; truelight@0: truelight@0: #endif /* TOWN_H */