diff options
author | frosch <frosch@openttd.org> | 2009-03-08 16:51:08 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-03-08 16:51:08 +0000 |
commit | 987e72f4f2d89da1575b0c55eccdaff0d1ad4f99 (patch) | |
tree | d0b5e144e2002e62ecfeb6cffe5e5bf0090a2aea /src/engine_base.h | |
parent | 4a5c4f6089b344c4e385a1f1e4d26545f46f4984 (diff) | |
download | openttd-987e72f4f2d89da1575b0c55eccdaff0d1ad4f99.tar.xz |
(svn r15645) -Fix (r12924)[FS#2612]: Add an EngineOverrideManager to give the term 'compatible newgrf' again some sense and to not crash because of trivial changes.
Diffstat (limited to 'src/engine_base.h')
-rw-r--r-- | src/engine_base.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/engine_base.h b/src/engine_base.h index 34852dc59..a008539b6 100644 --- a/src/engine_base.h +++ b/src/engine_base.h @@ -8,6 +8,7 @@ #include "engine_type.h" #include "economy_type.h" #include "oldpool.h" +#include "core/smallvec_type.hpp" DECLARE_OLD_POOL(Engine, Engine, 6, 10000) @@ -60,6 +61,26 @@ struct Engine : PoolItem<Engine, EngineID, &_Engine_pool> { uint GetDisplayMaxTractiveEffort() const; }; +struct EngineIDMapping { + uint32 grfid; ///< The GRF ID of the file the entity belongs to + uint16 internal_id; ///< The internal ID within the GRF file + VehicleTypeByte type; ///< The engine type + uint8 substitute_id; ///< The (original) entity ID to use if this GRF is not available (currently not used) +}; + +/** + * Stores the mapping of EngineID to the internal id of newgrfs. + * Note: This is not part of Engine, as the data in the EngineOverrideManager and the engine pool get resetted in different cases. + */ +struct EngineOverrideManager : SmallVector<EngineIDMapping, 256> { + static const uint NUM_DEFAULT_ENGINES; ///< Number of default entries + + void ResetToDefaultMapping(); + EngineID GetID(VehicleType type, uint16 grf_local_id, uint32 grfid); +}; + +extern EngineOverrideManager _engine_mngr; + static inline bool IsEngineIndex(uint index) { return index < GetEnginePoolSize(); |