summaryrefslogtreecommitdiff
path: root/src/town.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/town.h')
-rw-r--r--src/town.h116
1 files changed, 115 insertions, 1 deletions
diff --git a/src/town.h b/src/town.h
index ad3b60ee5..3bc81f2b6 100644
--- a/src/town.h
+++ b/src/town.h
@@ -5,9 +5,72 @@
#include "oldpool.h"
#include "player.h"
+#include "functions.h"
+#include "helpers.hpp"
enum {
- INVALID_TOWN = 0xFFFF,
+ HOUSE_NO_CLASS = 0,
+ NEW_HOUSE_OFFSET = 110,
+ HOUSE_MAX = 512,
+ INVALID_TOWN = 0xFFFF,
+ INVALID_HOUSE_ID = 0xFFFF,
+
+ /* There can only be as many classes as there are new houses, plus one for
+ * NO_CLASS, as the original houses don't have classes. */
+ HOUSE_CLASS_MAX = HOUSE_MAX - NEW_HOUSE_OFFSET + 1,
+};
+
+enum BuildingFlags {
+ TILE_NO_FLAG = 0,
+ TILE_SIZE_1x1 = 1U << 0,
+ TILE_NOT_SLOPED = 1U << 1,
+ TILE_SIZE_2x1 = 1U << 2,
+ TILE_SIZE_1x2 = 1U << 3,
+ TILE_SIZE_2x2 = 1U << 4,
+ BUILDING_IS_ANIMATED = 1U << 5,
+ BUILDING_IS_CHURCH = 1U << 6,
+ BUILDING_IS_STADIUM = 1U << 7,
+ BUILDING_HAS_1_TILE = TILE_SIZE_1x1 | TILE_SIZE_2x1 | TILE_SIZE_1x2 | TILE_SIZE_2x2,
+ BUILDING_2_TILES_X = TILE_SIZE_2x1 | TILE_SIZE_2x2,
+ BUILDING_2_TILES_Y = TILE_SIZE_1x2 | TILE_SIZE_2x2,
+ BUILDING_HAS_4_TILES = TILE_SIZE_2x2,
+};
+
+DECLARE_ENUM_AS_BIT_SET(BuildingFlags)
+
+enum HouseZones { ///< Bit Value Meaning
+ HZ_NOZNS = 0x0000, ///< 0 This is just to get rid of zeros, meaning none
+ HZ_ZON1 = 0x0001, ///< 0..4 1,2,4,8,10 which town zones the building can be built in, Zone1 been the further suburb
+ HZ_ZON2 = 0x0002,
+ HZ_ZON3 = 0x0004,
+ HZ_ZON4 = 0x0008,
+ HZ_ZON5 = 0x0010, ///< center of town
+ HZ_ZONALL = 0x001F, ///< 1F This is just to englobe all above types at once
+ HZ_SUBARTC_ABOVE = 0x0800, ///< 11 800 can appear in sub-arctic climate above the snow line
+ HZ_TEMP = 0x1000, ///< 12 1000 can appear in temperate climate
+ HZ_SUBARTC_BELOW = 0x2000, ///< 13 2000 can appear in sub-arctic climate below the snow line
+ HZ_SUBTROPIC = 0x4000, ///< 14 4000 can appear in subtropical climate
+ HZ_TOYLND = 0x8000 ///< 15 8000 can appear in toyland climate
+};
+
+DECLARE_ENUM_AS_BIT_SET(HouseZones)
+
+enum HouseExtraFlags {
+ NO_EXTRA_FLAG = 0,
+ BUILDING_IS_HISTORICAL = 1U << 0, ///< this house will only appear during town generation in random games, thus the historical
+ BUILDING_IS_PROTECTED = 1U << 1, ///< towns and AI will not remove this house, while human players will be able tp
+ SYNCHRONISED_CALLBACK_1B = 1U << 2, ///< synchronized callback 1B will be performed, on multi tile houses
+ CALLBACK_1A_RANDOM_BITS = 1U << 3, ///< callback 1A needs random bits
+};
+
+DECLARE_ENUM_AS_BIT_SET(HouseExtraFlags)
+
+typedef uint16 HouseID;
+typedef uint16 HouseClassID;
+
+struct BuildingCounts {
+ uint8 id_count[HOUSE_MAX];
+ uint8 class_count[HOUSE_CLASS_MAX];
};
struct Town {
@@ -78,8 +141,48 @@ struct Town {
// NOSAVE: UpdateTownRadius updates this given the house count.
uint16 radius[5];
+
+ // NOSAVE: The number of each type of building in the town.
+ BuildingCounts building_counts;
};
+struct HouseSpec {
+ /* Standard properties */
+ Year min_date; ///< introduction year of the house
+ Year max_date; ///< last year it can be built
+ byte population; ///< population (Zero on other tiles in multi tile house.)
+ byte removal_cost; ///< cost multiplier for removing it
+ StringID building_name; ///< building name
+ uint16 remove_rating_decrease; ///< rating decrease if removed
+ byte mail_generation; ///< mail generation multiplier (tile based, as the acceptances below)
+ byte passenger_acceptance; ///< passenger acceptance, given in 1/8th unit, max is 8, as the 3 next properies
+ byte mail_acceptance; ///< mail acceptance
+ byte goods_acceptance; ///< good acceptance
+ byte food_acceptance; ///< food (or fizzy drink) acceptance
+ BuildingFlags building_flags; ///< some flags that describe the house (size, stadium etc...)
+ HouseZones building_availability; ///< where can it be built (climates, zones)
+ bool enabled; ///< the house is still avaible (by default, true.newgrf can disable it, though)
+
+ /* NewHouses properties */
+ HouseID substitute_id; ///< which house this one is based on
+ struct SpriteGroup *spritegroup; ///< pointer to the different sprites of the house
+ HouseID override; ///< which house this one replaces
+ uint16 callback_mask; ///< House callback flags
+ byte random_colour[4]; ///< 4 "random" colours
+ byte probability; ///< Relative probability of appearing (16 is the standard value)
+ HouseExtraFlags extra_flags; ///< some more flags
+ HouseClassID class_id; ///< defines the class this house has (grf file based) @See HouseGetVariable, prop 0x44
+ byte animation_frames; ///< number of animation frames
+ byte animation_speed; ///< amount of time between each of those frames
+ byte processing_time; ///< Periodic refresh multiplier
+
+ /* grf file related properties*/
+ uint8 local_id; ///< id defined by the grf file for this house
+ const struct GRFFile *grffile; ///< grf file that introduced this house
+};
+
+VARDEF HouseSpec _house_specs[HOUSE_MAX];
+
uint32 GetWorldPopulation();
void UpdateTownVirtCoord(Town *t);
@@ -158,6 +261,12 @@ VARDEF const Town** _town_sort;
DECLARE_OLD_POOL(Town, Town, 3, 8000)
+static inline HouseSpec *GetHouseSpecs(HouseID house_id)
+{
+ assert(house_id < HOUSE_MAX);
+ return &_house_specs[house_id];
+}
+
/**
* Check if a Town really exists.
*/
@@ -229,4 +338,9 @@ VARDEF byte _town_sort_order;
VARDEF Town *_cleared_town;
VARDEF int _cleared_town_rating;
+uint OriginalTileRandomiser(uint x, uint y);
+void ResetHouses();
+
+void ClearTownHouse(Town *t, TileIndex tile);
+
#endif /* TOWN_H */