# house.h

Go to the documentation of this file.

    00001 /* $Id: house.h 23735 2012-01-03 20:26:05Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * 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.
    00006  * 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.
    00007  * 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/>.
    00008  */
    00009
    00012 #ifndef HOUSE_H
    00013 #define HOUSE_H
    00014
    00015 #include "cargo_type.h"
    00016 #include "date_type.h"
    00017 #include "house_type.h"
    00018 #include "newgrf_animation_type.h"
    00019 #include "newgrf_commons.h"
    00020
    00025 static const byte TOWN_HOUSE_COMPLETED = 3;
    00026
    00027 static const uint HOUSE_NO_CLASS      = 0;
    00028 static const HouseID NEW_HOUSE_OFFSET = 110;
    00029 static const HouseID HOUSE_MAX        = 512;
    00030 static const HouseID INVALID_HOUSE_ID = 0xFFFF;
    00031
    00036 static const uint HOUSE_CLASS_MAX  = HOUSE_MAX - NEW_HOUSE_OFFSET + 1;
    00037
    00038 enum BuildingFlags {
    00039   TILE_NO_FLAG         =       0,
    00040   TILE_SIZE_1x1        = 1U << 0,
    00041   TILE_NOT_SLOPED      = 1U << 1,
    00042   TILE_SIZE_2x1        = 1U << 2,
    00043   TILE_SIZE_1x2        = 1U << 3,
    00044   TILE_SIZE_2x2        = 1U << 4,
    00045   BUILDING_IS_ANIMATED = 1U << 5,
    00046   BUILDING_IS_CHURCH   = 1U << 6,
    00047   BUILDING_IS_STADIUM  = 1U << 7,
    00048   BUILDING_HAS_1_TILE  = TILE_SIZE_1x1 | TILE_SIZE_2x1 | TILE_SIZE_1x2 | TILE_SIZE_2x2,
    00049   BUILDING_HAS_2_TILES = TILE_SIZE_2x1 | TILE_SIZE_1x2 | TILE_SIZE_2x2,
    00050   BUILDING_2_TILES_X   = TILE_SIZE_2x1 | TILE_SIZE_2x2,
    00051   BUILDING_2_TILES_Y   = TILE_SIZE_1x2 | TILE_SIZE_2x2,
    00052   BUILDING_HAS_4_TILES = TILE_SIZE_2x2,
    00053 };
    00054 DECLARE_ENUM_AS_BIT_SET(BuildingFlags)
    00055
    00056 enum HouseZonesBits {
    00057   HZB_BEGIN     = 0,
    00058   HZB_TOWN_EDGE = 0,
    00059   HZB_TOWN_OUTSKIRT,
    00060   HZB_TOWN_OUTER_SUBURB,
    00061   HZB_TOWN_INNER_SUBURB,
    00062   HZB_TOWN_CENTRE,
    00063   HZB_END,
    00064 };
    00065 assert_compile(HZB_END == 5);
    00066
    00067 DECLARE_POSTFIX_INCREMENT(HouseZonesBits)
    00068
    00069 enum HouseZones {
    00070   HZ_NOZNS             = 0x0000,
    00071   HZ_ZON1              = 1U << HZB_TOWN_EDGE,
    00072   HZ_ZON2              = 1U << HZB_TOWN_OUTSKIRT,
    00073   HZ_ZON3              = 1U << HZB_TOWN_OUTER_SUBURB,
    00074   HZ_ZON4              = 1U << HZB_TOWN_INNER_SUBURB,
    00075   HZ_ZON5              = 1U << HZB_TOWN_CENTRE,
    00076   HZ_ZONALL            = 0x001F,
    00077   HZ_SUBARTC_ABOVE     = 0x0800,
    00078   HZ_TEMP              = 0x1000,
    00079   HZ_SUBARTC_BELOW     = 0x2000,
    00080   HZ_SUBTROPIC         = 0x4000,
    00081   HZ_TOYLND            = 0x8000,
    00082   HZ_CLIMALL           = 0xF800,
    00083 };
    00084 DECLARE_ENUM_AS_BIT_SET(HouseZones)
    00085
    00086 enum HouseExtraFlags {
    00087   NO_EXTRA_FLAG            =       0,
    00088   BUILDING_IS_HISTORICAL   = 1U << 0,
    00089   BUILDING_IS_PROTECTED    = 1U << 1,
    00090   SYNCHRONISED_CALLBACK_1B = 1U << 2,
    00091   CALLBACK_1A_RANDOM_BITS  = 1U << 3,
    00092 };
    00093
    00094 DECLARE_ENUM_AS_BIT_SET(HouseExtraFlags)
    00095
    00096 struct HouseSpec {
    00097   /* Standard properties */
    00098   Year min_year;
    00099   Year max_year;
    00100   byte population;
    00101   byte removal_cost;
    00102   StringID building_name;
    00103   uint16 remove_rating_decrease;
    00104   byte mail_generation;
    00105   byte cargo_acceptance[3];
    00106   CargoID accepts_cargo[3];
    00107   BuildingFlags building_flags;
    00108   HouseZones building_availability;
    00109   bool enabled;
    00110
    00111   /* NewHouses properties */
    00112   GRFFileProps grf_prop;
    00113   uint16 callback_mask;
    00114   byte random_colour[4];
    00115   byte probability;
    00116   HouseExtraFlags extra_flags;
    00117   HouseClassID class_id;
    00118   AnimationInfo animation;
    00119   byte processing_time;
    00120   byte minimum_life;
    00121   uint32 watched_cargoes;
    00122
    00123   Money GetRemovalCost() const;
    00124
    00125   static inline HouseSpec *Get(size_t house_id)
    00126   {
    00127     assert(house_id < HOUSE_MAX);
    00128     extern HouseSpec _house_specs[];
    00129     return &_house_specs[house_id];
    00130   }
    00131 };
    00132
    00138 static inline HouseID GetTranslatedHouseID(HouseID hid)
    00139 {
    00140   const HouseSpec *hs = HouseSpec::Get(hid);
    00141   return hs->grf_prop.override == INVALID_HOUSE_ID ? hid : hs->grf_prop.override;
    00142 }
    00143
    00144 #endif /* HOUSE_H */