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