maedhros@6332: /* $Id$ */ maedhros@6332: maedhros@6332: /** @file newgrf_house.h */ maedhros@6332: maedhros@6332: #ifndef NEWGRF_HOUSE_H maedhros@6332: #define NEWGRF_HOUSE_H maedhros@6332: maedhros@6332: #include "town.h" maedhros@6332: maedhros@6332: /** maedhros@6332: * Maps a house id stored on the map to a GRF file. maedhros@6332: * House IDs are stored on the map, so there needs to be a way to tie them to maedhros@6332: * GRF files. An array of HouseIDMapping structs is saved with the savegame so maedhros@6332: * that house GRFs can be loaded in a different order, or removed safely. The maedhros@6332: * index in the array is the house ID stored on the map. maedhros@6332: * maedhros@6332: * The substitute ID is the ID of an original house that should be used instead maedhros@6332: * if the GRF containing the new house is not available. maedhros@6332: */ maedhros@6332: struct HouseIDMapping { maedhros@6332: uint32 grfid; ///< The GRF ID of the file this house belongs to maedhros@6332: uint8 house_id; ///< The house ID within the GRF file maedhros@6332: uint8 substitute_id; ///< The (original) house ID to use if this GRF is not available maedhros@6332: }; maedhros@6332: maedhros@6332: /** maedhros@6332: * Makes class IDs unique to each GRF file. maedhros@6332: * Houses can be assigned class IDs which are only comparable within the GRF maedhros@6332: * file they were defined in. This mapping ensures that if two houses have the maedhros@6332: * same class as defined by the GRF file, the classes are different within the maedhros@6332: * game. An array of HouseClassMapping structs is created, and the array index maedhros@6332: * of the struct that matches both the GRF ID and the class ID is the class ID maedhros@6332: * used in the game. maedhros@6332: * maedhros@6332: * Although similar to the HouseIDMapping struct above, this serves a different maedhros@6332: * purpose. Since the class ID is not saved anywhere, this mapping does not maedhros@6332: * need to be persistent; it just needs to keep class ids unique. maedhros@6332: */ maedhros@6332: struct HouseClassMapping { maedhros@6332: uint32 grfid; ////< The GRF ID of the file this class belongs to maedhros@6332: uint8 class_id; ////< The class id within the grf file maedhros@6332: }; maedhros@6332: maedhros@6332: extern HouseIDMapping _house_id_mapping[HOUSE_MAX]; ///< Declared in newgrf_house.cpp maedhros@6332: maedhros@6332: void AddHouseOverride(uint8 local_id, uint house_type); maedhros@6332: void ResetHouseOverrides(); maedhros@6332: maedhros@6332: void SetHouseSpec(const HouseSpec *hs); maedhros@6332: maedhros@6332: void CheckHouseIDs(); maedhros@6332: void ResetHouseIDMapping(); maedhros@6332: maedhros@6332: HouseClassID AllocateHouseClassID(byte grf_class_id, uint32 grfid); maedhros@6332: maedhros@6332: void InitializeBuildingCounts(); maedhros@6332: void IncreaseBuildingCount(Town *t, HouseID house_id); maedhros@6332: void DecreaseBuildingCount(Town *t, HouseID house_id); maedhros@6332: void AfterLoadCountBuildings(); maedhros@6332: maedhros@6332: void DrawNewHouseTile(TileInfo *ti, HouseID house_id); maedhros@6332: void AnimateNewHouseTile(TileIndex tile); maedhros@6332: void ChangeHouseAnimationFrame(TileIndex tile, uint16 callback_result); maedhros@6332: maedhros@6332: uint16 GetHouseCallback(uint16 callback, uint32 param1, HouseID house_id, Town *town, TileIndex tile); maedhros@6332: maedhros@6332: bool CanDeleteHouse(TileIndex tile); maedhros@6332: maedhros@6332: bool NewHouseTileLoop(TileIndex tile); maedhros@6332: maedhros@6332: #endif /* NEWGRF_HOUSE_H */