diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9257a061dd..def59df365 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -165,6 +165,7 @@ add_files( engine_func.h engine_gui.cpp engine_gui.h + engine_override.h engine_type.h error.h error_gui.cpp diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 6287607115..58a168dd53 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -40,6 +40,7 @@ #include "newgrf_profiling.h" #include "console_func.h" #include "engine_base.h" +#include "engine_override.h" #include "road.h" #include "rail.h" #include "game/game.hpp" diff --git a/src/engine.cpp b/src/engine.cpp index a0df90cea5..b331ddb7f8 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -25,6 +25,7 @@ #include "engine_gui.h" #include "engine_func.h" #include "engine_base.h" +#include "engine_override.h" #include "company_base.h" #include "vehicle_func.h" #include "articulated_vehicles.h" diff --git a/src/engine_base.h b/src/engine_base.h index 039c39b5fd..8474918a17 100644 --- a/src/engine_base.h +++ b/src/engine_base.h @@ -215,28 +215,6 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> { } }; -struct EngineIDMapping { - uint32_t grfid; ///< The GRF ID of the file the entity belongs to - uint16_t internal_id; ///< The internal ID within the GRF file - VehicleType type; ///< The engine type - uint8_t 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 : std::vector { - static const uint NUM_DEFAULT_ENGINES; ///< Number of default entries - - void ResetToDefaultMapping(); - EngineID GetID(VehicleType type, uint16_t grf_local_id, uint32_t grfid); - - static bool ResetToCurrentNewGRFConfig(); -}; - -extern EngineOverrideManager _engine_mngr; - inline const EngineInfo *EngInfo(EngineID e) { return &Engine::Get(e)->info; diff --git a/src/engine_override.h b/src/engine_override.h new file mode 100644 index 0000000000..8e6822a796 --- /dev/null +++ b/src/engine_override.h @@ -0,0 +1,40 @@ +/* + * 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 . + */ + +/** @file engine_override.h Engine override functionality. */ + +#ifndef ENGINE_OVERRIDE_H +#define ENGINE_OVERRIDE_H + +#include "engine_type.h" +#include "vehicle_type.h" + +#include + +struct EngineIDMapping { + uint32_t grfid; ///< The GRF ID of the file the entity belongs to + uint16_t internal_id; ///< The internal ID within the GRF file + VehicleType type; ///< The engine type + uint8_t 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 : std::vector { + static const uint NUM_DEFAULT_ENGINES; ///< Number of default entries + + void ResetToDefaultMapping(); + EngineID GetID(VehicleType type, uint16_t grf_local_id, uint32_t grfid); + + static bool ResetToCurrentNewGRFConfig(); +}; + +extern EngineOverrideManager _engine_mngr; + +#endif /* ENGINE_BASE_H */ diff --git a/src/newgrf.cpp b/src/newgrf.cpp index b522f15053..dffab5a9c9 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -18,6 +18,7 @@ #include "fileio_func.h" #include "engine_func.h" #include "engine_base.h" +#include "engine_override.h" #include "bridge.h" #include "town.h" #include "newgrf_engine.h" diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index e01a781e22..b0c997a729 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -29,6 +29,7 @@ #include "newgrf_extension.h" #include "newgrf_analysis.h" #include "newgrf_dump.h" +#include "engine_override.h" #include "safeguards.h" diff --git a/src/openttd.cpp b/src/openttd.cpp index 6cfb3aaf25..166409e10a 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -53,6 +53,7 @@ #include "station_base.h" #include "crashlog.h" #include "engine_func.h" +#include "engine_override.h" #include "core/random_func.hpp" #include "rail_gui.h" #include "road_gui.h" diff --git a/src/saveload/engine_sl.cpp b/src/saveload/engine_sl.cpp index e5ab5e7239..cde7bd5575 100644 --- a/src/saveload/engine_sl.cpp +++ b/src/saveload/engine_sl.cpp @@ -13,6 +13,7 @@ #include "compat/engine_sl_compat.h" #include "../engine_base.h" +#include "../engine_override.h" #include "../string_func.h" #include diff --git a/src/settings.cpp b/src/settings.cpp index 3c0c52cfdd..5b9667446b 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -79,6 +79,7 @@ #include "statusbar_gui.h" #include "graph_gui.h" #include "string_func_extra.h" +#include "engine_override.h" #include "void_map.h" #include "station_base.h" diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 7e17f60a12..4e8e7d09c5 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -30,6 +30,7 @@ #include "object.h" #include "hotkeys.h" #include "engine_base.h" +#include "engine_override.h" #include "terraform_gui.h" #include "cheat_func.h" #include "town_gui.h"