Files
@ r15196:77940844856f
Branch filter:
Location: cpp/openttd-patchpack/source/src/newgrf_commons.h - annotation
r15196:77940844856f
5.0 KiB
text/x-c
(svn r19835) -Codechange: Extract grfident equality check to its own method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | r6629:10368ea45a15 r6629:10368ea45a15 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r14201:353d41c4bde7 r10355:1d372454f71c r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r7325:df3b64d742c5 r6629:10368ea45a15 r6629:10368ea45a15 r7873:778564304bdd r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r7632:40eddc1d4853 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r7873:778564304bdd r6835:9051f7024392 r6629:10368ea45a15 r14833:2e2caf9b1a19 r8511:74e4574fb8bc r6629:10368ea45a15 r7325:df3b64d742c5 r7325:df3b64d742c5 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r7325:df3b64d742c5 r6629:10368ea45a15 r6835:9051f7024392 r7325:df3b64d742c5 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6629:10368ea45a15 r6835:9051f7024392 r7325:df3b64d742c5 r7325:df3b64d742c5 r7325:df3b64d742c5 r7325:df3b64d742c5 r6835:9051f7024392 r7325:df3b64d742c5 r8511:74e4574fb8bc r7667:3c17bebdab13 r6835:9051f7024392 r6835:9051f7024392 r7000:2cb5bda647b1 r7000:2cb5bda647b1 r7325:df3b64d742c5 r7632:40eddc1d4853 r7632:40eddc1d4853 r7325:df3b64d742c5 r7325:df3b64d742c5 r7325:df3b64d742c5 r7325:df3b64d742c5 r7325:df3b64d742c5 r7000:2cb5bda647b1 r7000:2cb5bda647b1 r14851:b3915c863ff3 r14851:b3915c863ff3 r14851:b3915c863ff3 r14851:b3915c863ff3 r14851:b3915c863ff3 r14851:b3915c863ff3 r14851:b3915c863ff3 r14851:b3915c863ff3 r14851:b3915c863ff3 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r6629:10368ea45a15 r6835:9051f7024392 r7000:2cb5bda647b1 r14851:b3915c863ff3 r14606:2cf1bcd611f7 r6629:10368ea45a15 r6801:3c6b56e07296 r6827:5f08bab6696e r8458:f7e90b7c0926 r6801:3c6b56e07296 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r14606:2cf1bcd611f7 r6629:10368ea45a15 | /* $Id$ */
/*
* This file is part of OpenTTD.
* 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.
* 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.
* 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/>.
*/
/** @file newgrf_commons.h This file simplyfies and embeds a common mechanism of
* loading/saving and mapping of grf entities.
*/
#ifndef NEWGRF_COMMONS_H
#define NEWGRF_COMMONS_H
#include "tile_cmd.h"
/**
* Maps an entity id stored on the map to a GRF file.
* Entities are objects used ingame (houses, industries, industry tiles) for
* which we need to correlate the ids from the grf files with the ones in the
* the savegames themselves.
* An array of EntityIDMapping structs is saved with the savegame so
* that those GRFs can be loaded in a different order, or removed safely. The
* index in the array is the entity's ID stored on the map.
*
* The substitute ID is the ID of an original entity that should be used instead
* if the GRF containing the new entity is not available.
*/
struct EntityIDMapping {
uint32 grfid; ///< The GRF ID of the file the entity belongs to
uint8 entity_id; ///< The entity ID within the GRF file
uint8 substitute_id; ///< The (original) entity ID to use if this GRF is not available
};
class OverrideManagerBase {
protected:
uint16 *entity_overrides;
uint32 *grfid_overrides;
uint16 max_offset; ///< what is the length of the original entity's array of specs
uint16 max_new_entities; ///< what is the amount of entities, old and new summed
uint16 invalid_ID; ///< ID used to dected invalid entities;
virtual bool CheckValidNewID(uint16 testid) { return true; }
public:
EntityIDMapping *mapping_ID; ///< mapping of ids from grf files. Public out of convenience
OverrideManagerBase(uint16 offset, uint16 maximum, uint16 invalid);
virtual ~OverrideManagerBase();
void ResetOverride();
void ResetMapping();
void Add(uint8 local_id, uint32 grfid, uint entity_type);
virtual uint16 AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id);
uint16 GetSubstituteID(uint16 entity_id);
virtual uint16 GetID(uint8 grf_local_id, uint32 grfid);
inline uint16 GetMaxMapping() { return max_new_entities; }
inline uint16 GetMaxOffset() { return max_offset; }
};
struct HouseSpec;
class HouseOverrideManager : public OverrideManagerBase {
public:
HouseOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) :
OverrideManagerBase(offset, maximum, invalid) {}
void SetEntitySpec(const HouseSpec *hs);
};
struct IndustrySpec;
class IndustryOverrideManager : public OverrideManagerBase {
public:
IndustryOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) :
OverrideManagerBase(offset, maximum, invalid) {}
virtual uint16 AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id);
virtual uint16 GetID(uint8 grf_local_id, uint32 grfid);
void SetEntitySpec(IndustrySpec *inds);
};
struct IndustryTileSpec;
class IndustryTileOverrideManager : public OverrideManagerBase {
protected:
virtual bool CheckValidNewID(uint16 testid) { return testid != 0xFF; }
public:
IndustryTileOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) :
OverrideManagerBase(offset, maximum, invalid) {}
void SetEntitySpec(const IndustryTileSpec *indts);
};
struct AirportSpec;
class AirportOverrideManager : public OverrideManagerBase {
public:
AirportOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) :
OverrideManagerBase(offset, maximum, invalid) {}
void SetEntitySpec(AirportSpec *inds);
};
struct AirportTileSpec;
class AirportTileOverrideManager : public OverrideManagerBase {
protected:
virtual bool CheckValidNewID(uint16 testid) { return testid != 0xFF; }
public:
AirportTileOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) :
OverrideManagerBase(offset, maximum, invalid) {}
void SetEntitySpec(const AirportTileSpec *ats);
};
extern HouseOverrideManager _house_mngr;
extern IndustryOverrideManager _industry_mngr;
extern IndustryTileOverrideManager _industile_mngr;
extern AirportOverrideManager _airport_mngr;
extern AirportTileOverrideManager _airporttile_mngr;
uint32 GetTerrainType(TileIndex tile);
TileIndex GetNearbyTile(byte parameter, TileIndex tile);
uint32 GetNearbyTileInformation(TileIndex tile);
/** Data related to the handling of grf files. */
struct GRFFileProps {
uint16 subst_id;
uint16 local_id; ///< id defined by the grf file for this entity
struct SpriteGroup *spritegroup; ///< pointer to the different sprites of the entity
const struct GRFFile *grffile; ///< grf file that introduced this entity
uint16 override; ///< id of the entity been replaced by
};
#endif /* NEWGRF_COMMONS_H */
|