# newgrf_house.h

Go to the documentation of this file.

    00001 /* $Id: newgrf_house.h 26085 2013-11-24 14:41:19Z frosch $ */
    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 NEWGRF_HOUSE_H
    00013 #define NEWGRF_HOUSE_H
    00014
    00015 #include "newgrf_callbacks.h"
    00016 #include "tile_cmd.h"
    00017 #include "house_type.h"
    00018 #include "newgrf_spritegroup.h"
    00019 #include "newgrf_town.h"
    00020
    00022 struct HouseScopeResolver : public ScopeResolver {
    00023   HouseID house_id;
    00024   TileIndex tile;
    00025   Town *town;
    00026   bool not_yet_constructed;
    00027   uint16 initial_random_bits;
    00028   uint32 watched_cargo_triggers;
    00029
    00030   HouseScopeResolver(ResolverObject &ro, HouseID house_id, TileIndex tile, Town *town,
    00031       bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers);
    00032
    00033   /* virtual */ uint32 GetRandomBits() const;
    00034   /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
    00035   /* virtual */ uint32 GetTriggers() const;
    00036   /* virtual */ void SetTriggers(int triggers) const;
    00037 };
    00038
    00040 struct HouseResolverObject : public ResolverObject {
    00041   HouseScopeResolver house_scope;
    00042   TownScopeResolver  town_scope;
    00043
    00044   HouseResolverObject(HouseID house_id, TileIndex tile, Town *town,
    00045       CallbackID callback = CBID_NO_CALLBACK, uint32 param1 = 0, uint32 param2 = 0,
    00046       bool not_yet_constructed = false, uint8 initial_random_bits = 0, uint32 watched_cargo_triggers = 0);
    00047
    00048   /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
    00049   {
    00050     switch (scope) {
    00051       case VSG_SCOPE_SELF:   return &this->house_scope;
    00052       case VSG_SCOPE_PARENT: return &this->town_scope;
    00053       default: return ResolverObject::GetScope(scope, relative);
    00054     }
    00055   }
    00056 };
    00057
    00071 struct HouseClassMapping {
    00072   uint32 grfid;
    00073   uint8  class_id;
    00074 };
    00075
    00076 HouseClassID AllocateHouseClassID(byte grf_class_id, uint32 grfid);
    00077
    00078 void InitializeBuildingCounts();
    00079 void IncreaseBuildingCount(Town *t, HouseID house_id);
    00080 void DecreaseBuildingCount(Town *t, HouseID house_id);
    00081
    00082 void DrawNewHouseTile(TileInfo *ti, HouseID house_id);
    00083 void AnimateNewHouseTile(TileIndex tile);
    00084 void AnimateNewHouseConstruction(TileIndex tile);
    00085
    00086 uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile,
    00087     bool not_yet_constructed = false, uint8 initial_random_bits = 0, uint32 watched_cargo_triggers = 0);
    00088 void WatchedCargoCallback(TileIndex tile, uint32 trigger_cargoes);
    00089
    00090 bool CanDeleteHouse(TileIndex tile);
    00091
    00092 bool NewHouseTileLoop(TileIndex tile);
    00093
    00094 enum HouseTrigger {
    00095   /* The tile of the house has been triggered during the tileloop. */
    00096   HOUSE_TRIGGER_TILE_LOOP     = 0x01,
    00097   /*
    00098    * The top tile of a (multitile) building has been triggered during and all
    00099    * the tileloop other tiles of the same building get the same random value.
    00100    */
    00101   HOUSE_TRIGGER_TILE_LOOP_TOP = 0x02,
    00102 };
    00103 void TriggerHouse(TileIndex t, HouseTrigger trigger);
    00104
    00105 #endif /* NEWGRF_HOUSE_H */