# house.h

Go to the documentation of this file.

    00001 /* $Id: house.h 20871 2010-10-02 14:41:25Z 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 "strings_type.h"
    00016 #include "cargo_type.h"
    00017 #include "economy_type.h"
    00018 #include "date_type.h"
    00019 #include "house_type.h"
    00020
    00023 static const byte TOWN_HOUSE_COMPLETED = 3;
    00024
    00025 enum {
    00026   HOUSE_NO_CLASS   = 0,
    00027   NEW_HOUSE_OFFSET = 110,
    00028   HOUSE_MAX        = 512,
    00029   INVALID_HOUSE_ID = 0xFFFF,
    00030
    00031   /* There can only be as many classes as there are new houses, plus one for
    00032    * NO_CLASS, as the original houses don't have classes. */
    00033   HOUSE_CLASS_MAX  = HOUSE_MAX - NEW_HOUSE_OFFSET + 1,
    00034 };
    00035
    00036 enum BuildingFlags {
    00037   TILE_NO_FLAG         =       0,
    00038   TILE_SIZE_1x1        = 1U << 0,
    00039   TILE_NOT_SLOPED      = 1U << 1,
    00040   TILE_SIZE_2x1        = 1U << 2,
    00041   TILE_SIZE_1x2        = 1U << 3,
    00042   TILE_SIZE_2x2        = 1U << 4,
    00043   BUILDING_IS_ANIMATED = 1U << 5,
    00044   BUILDING_IS_CHURCH   = 1U << 6,
    00045   BUILDING_IS_STADIUM  = 1U << 7,
    00046   BUILDING_HAS_1_TILE  = TILE_SIZE_1x1 | TILE_SIZE_2x1 | TILE_SIZE_1x2 | TILE_SIZE_2x2,
    00047   BUILDING_HAS_2_TILES = TILE_SIZE_2x1 | TILE_SIZE_1x2 | TILE_SIZE_2x2,
    00048   BUILDING_2_TILES_X   = TILE_SIZE_2x1 | TILE_SIZE_2x2,
    00049   BUILDING_2_TILES_Y   = TILE_SIZE_1x2 | TILE_SIZE_2x2,
    00050   BUILDING_HAS_4_TILES = TILE_SIZE_2x2,
    00051 };
    00052 DECLARE_ENUM_AS_BIT_SET(BuildingFlags)
    00053
    00054 enum HouseZonesBits {
    00055   HZB_BEGIN     = 0,
    00056   HZB_TOWN_EDGE = 0,
    00057   HZB_TOWN_OUTSKIRT,
    00058   HZB_TOWN_OUTER_SUBURB,
    00059   HZB_TOWN_INNER_SUBURB,
    00060   HZB_TOWN_CENTRE,
    00061   HZB_END,
    00062 };
    00063 assert_compile(HZB_END == 5);
    00064
    00065 DECLARE_POSTFIX_INCREMENT(HouseZonesBits)
    00066
    00067 enum HouseZones {
    00068   HZ_NOZNS             = 0x0000,
    00069   HZ_ZON1              = 1U << HZB_TOWN_EDGE,
    00070   HZ_ZON2              = 1U << HZB_TOWN_OUTSKIRT,
    00071   HZ_ZON3              = 1U << HZB_TOWN_OUTER_SUBURB,
    00072   HZ_ZON4              = 1U << HZB_TOWN_INNER_SUBURB,
    00073   HZ_ZON5              = 1U << HZB_TOWN_CENTRE,
    00074   HZ_ZONALL            = 0x001F,
    00075   HZ_SUBARTC_ABOVE     = 0x0800,
    00076   HZ_TEMP              = 0x1000,
    00077   HZ_SUBARTC_BELOW     = 0x2000,
    00078   HZ_SUBTROPIC         = 0x4000,
    00079   HZ_TOYLND            = 0x8000,
    00080   HZ_CLIMALL           = 0xF800,
    00081 };
    00082 DECLARE_ENUM_AS_BIT_SET(HouseZones)
    00083
    00084 enum HouseExtraFlags {
    00085   NO_EXTRA_FLAG            =       0,
    00086   BUILDING_IS_HISTORICAL   = 1U << 0,
    00087   BUILDING_IS_PROTECTED    = 1U << 1,
    00088   SYNCHRONISED_CALLBACK_1B = 1U << 2,
    00089   CALLBACK_1A_RANDOM_BITS  = 1U << 3,
    00090 };
    00091
    00092 DECLARE_ENUM_AS_BIT_SET(HouseExtraFlags)
    00093
    00094 struct HouseSpec {
    00095   /* Standard properties */
    00096   Year min_year;
    00097   Year max_year;
    00098   byte population;
    00099   byte removal_cost;
    00100   StringID building_name;
    00101   uint16 remove_rating_decrease;
    00102   byte mail_generation;
    00103   byte cargo_acceptance[3];
    00104   CargoID accepts_cargo[3];
    00105   BuildingFlags building_flags;
    00106   HouseZones building_availability;
    00107   bool enabled;
    00108
    00109   /* NewHouses properties */
    00110   HouseID substitute_id;
    00111   struct SpriteGroup *spritegroup;
    00112   HouseID override;
    00113   uint16 callback_mask;
    00114   byte random_colour[4];
    00115   byte probability;
    00116   HouseExtraFlags extra_flags;
    00117   HouseClassID class_id;
    00118   byte animation_frames;
    00119   byte animation_speed;
    00120   byte processing_time;
    00121   byte minimum_life;
    00122
    00123   /* grf file related properties*/
    00124   uint8 local_id;
    00125   const struct GRFFile *grffile;
    00126
    00131   Money GetRemovalCost() const;
    00132
    00133   static FORCEINLINE HouseSpec *Get(size_t house_id)
    00134   {
    00135     assert(house_id < HOUSE_MAX);
    00136     extern HouseSpec _house_specs[];
    00137     return &_house_specs[house_id];
    00138   }
    00139 };
    00140
    00146 static inline HouseID GetTranslatedHouseID(HouseID hid)
    00147 {
    00148   const HouseSpec *hs = HouseSpec::Get(hid);
    00149   return hs->override == INVALID_HOUSE_ID ? hid : hs->override;
    00150 }
    00151
    00152 #endif /* HOUSE_H */