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