Translations update
[openttd/fttd.git] / src / house.h
blobbb167f16736cfb287d82e6fbf1770da3dcd00f3f
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file house.h definition of HouseSpec and accessors */
12 #ifndef HOUSE_H
13 #define HOUSE_H
15 #include "cargo_type.h"
16 #include "date_type.h"
17 #include "house_type.h"
18 #include "newgrf_animation_type.h"
19 #include "newgrf_commons.h"
20 #include "map/house.h"
22 static const HouseID NUM_HOUSES_PER_GRF = 255; ///< Number of supported houses per NewGRF; limited to 255 to allow extending Action3 with an extended byte later on.
24 static const uint HOUSE_NO_CLASS = 0;
25 static const HouseID NEW_HOUSE_OFFSET = 110; ///< Offset for new houses.
26 static const HouseID NUM_HOUSES = 512; ///< Total number of houses.
27 static const HouseID INVALID_HOUSE_ID = 0xFFFF;
29 /**
30 * There can only be as many classes as there are new houses, plus one for
31 * NO_CLASS, as the original houses don't have classes.
33 static const uint HOUSE_CLASS_MAX = NUM_HOUSES - NEW_HOUSE_OFFSET + 1;
35 enum BuildingFlags {
36 TILE_NO_FLAG = 0,
37 TILE_SIZE_1x1 = 1U << 0,
38 TILE_NOT_SLOPED = 1U << 1,
39 TILE_SIZE_2x1 = 1U << 2,
40 TILE_SIZE_1x2 = 1U << 3,
41 TILE_SIZE_2x2 = 1U << 4,
42 BUILDING_IS_ANIMATED = 1U << 5,
43 BUILDING_IS_CHURCH = 1U << 6,
44 BUILDING_IS_STADIUM = 1U << 7,
45 BUILDING_HAS_1_TILE = TILE_SIZE_1x1 | TILE_SIZE_2x1 | TILE_SIZE_1x2 | TILE_SIZE_2x2,
46 BUILDING_HAS_2_TILES = TILE_SIZE_2x1 | TILE_SIZE_1x2 | TILE_SIZE_2x2,
47 BUILDING_2_TILES_X = TILE_SIZE_2x1 | TILE_SIZE_2x2,
48 BUILDING_2_TILES_Y = TILE_SIZE_1x2 | TILE_SIZE_2x2,
49 BUILDING_HAS_4_TILES = TILE_SIZE_2x2,
51 DECLARE_ENUM_AS_BIT_SET(BuildingFlags)
53 enum HouseZonesBits {
54 HZB_BEGIN = 0,
55 HZB_TOWN_EDGE = 0,
56 HZB_TOWN_OUTSKIRT,
57 HZB_TOWN_OUTER_SUBURB,
58 HZB_TOWN_INNER_SUBURB,
59 HZB_TOWN_CENTRE,
60 HZB_END,
62 assert_compile(HZB_END == 5);
64 DECLARE_POSTFIX_INCREMENT(HouseZonesBits)
66 enum HouseZones { ///< Bit Value Meaning
67 HZ_NOZNS = 0x0000, ///< 0 This is just to get rid of zeros, meaning none
68 HZ_ZON1 = 1U << HZB_TOWN_EDGE, ///< 0..4 1,2,4,8,10 which town zones the building can be built in, Zone1 been the further suburb
69 HZ_ZON2 = 1U << HZB_TOWN_OUTSKIRT,
70 HZ_ZON3 = 1U << HZB_TOWN_OUTER_SUBURB,
71 HZ_ZON4 = 1U << HZB_TOWN_INNER_SUBURB,
72 HZ_ZON5 = 1U << HZB_TOWN_CENTRE, ///< center of town
73 HZ_ZONALL = 0x001F, ///< 1F This is just to englobe all above types at once
74 HZ_SUBARTC_ABOVE = 0x0800, ///< 11 800 can appear in sub-arctic climate above the snow line
75 HZ_TEMP = 0x1000, ///< 12 1000 can appear in temperate climate
76 HZ_SUBARTC_BELOW = 0x2000, ///< 13 2000 can appear in sub-arctic climate below the snow line
77 HZ_SUBTROPIC = 0x4000, ///< 14 4000 can appear in subtropical climate
78 HZ_TOYLND = 0x8000, ///< 15 8000 can appear in toyland climate
79 HZ_CLIMALL = 0xF800, ///< Bitmask of all climate bits
81 DECLARE_ENUM_AS_BIT_SET(HouseZones)
83 enum HouseExtraFlags {
84 NO_EXTRA_FLAG = 0,
85 BUILDING_IS_HISTORICAL = 1U << 0, ///< this house will only appear during town generation in random games, thus the historical
86 BUILDING_IS_PROTECTED = 1U << 1, ///< towns and AI will not remove this house, while human players will be able to
87 SYNCHRONISED_CALLBACK_1B = 1U << 2, ///< synchronized callback 1B will be performed, on multi tile houses
88 CALLBACK_1A_RANDOM_BITS = 1U << 3, ///< callback 1A needs random bits
91 DECLARE_ENUM_AS_BIT_SET(HouseExtraFlags)
93 struct HouseSpec {
94 /* Standard properties */
95 Year min_year; ///< introduction year of the house
96 Year max_year; ///< last year it can be built
97 byte population; ///< population (Zero on other tiles in multi tile house.)
98 byte removal_cost; ///< cost multiplier for removing it
99 StringID building_name; ///< building name
100 uint16 remove_rating_decrease; ///< rating decrease if removed
101 byte mail_generation; ///< mail generation multiplier (tile based, as the acceptances below)
102 byte cargo_acceptance[3]; ///< acceptance level for the cargo slots
103 CargoID accepts_cargo[3]; ///< 3 input cargo slots
104 BuildingFlags building_flags; ///< some flags that describe the house (size, stadium etc...)
105 HouseZones building_availability; ///< where can it be built (climates, zones)
106 bool enabled; ///< the house is available to build (true by default, but can be disabled by newgrf)
108 /* NewHouses properties */
109 GRFFileProps grf_prop; ///< Properties related the the grf file
110 uint16 callback_mask; ///< Bitmask of house callbacks that have to be called
111 byte random_colour[4]; ///< 4 "random" colours
112 byte probability; ///< Relative probability of appearing (16 is the standard value)
113 HouseExtraFlags extra_flags; ///< some more flags
114 HouseClassID class_id; ///< defines the class this house has (not grf file based)
115 AnimationInfo animation; ///< information about the animation.
116 byte processing_time; ///< Periodic refresh multiplier
117 byte minimum_life; ///< The minimum number of years this house will survive before the town rebuilds it
118 uint32 watched_cargoes; ///< Cargo types watched for acceptance.
120 Money GetRemovalCost() const;
122 static inline HouseSpec *Get(size_t house_id)
124 assert(house_id < NUM_HOUSES);
125 extern HouseSpec _house_specs[];
126 return &_house_specs[house_id];
131 * Do HouseID translation for NewGRFs.
132 * @param hid the HouseID to get the override for.
133 * @return the HouseID to actually work with.
135 static inline HouseID GetTranslatedHouseID(HouseID hid)
137 const HouseSpec *hs = HouseSpec::Get(hid);
138 return hs->grf_prop.override == INVALID_HOUSE_ID ? hid : hs->grf_prop.override;
142 * Get the type of this house, which is an index into the house spec array
143 * @param t the tile
144 * @pre IsHouseTile(t)
145 * @return house type
147 static inline HouseID GetHouseType(TileIndex t)
149 return GetTranslatedHouseID(GetCleanHouseType(t));
152 void DrawHouseImage (HouseID house_id, BlitArea *dpi, int left, int top, int right, int bottom);
154 #endif /* HOUSE_H */