Move EngineOverrideManager to separate header
This commit is contained in:
@@ -165,6 +165,7 @@ add_files(
|
|||||||
engine_func.h
|
engine_func.h
|
||||||
engine_gui.cpp
|
engine_gui.cpp
|
||||||
engine_gui.h
|
engine_gui.h
|
||||||
|
engine_override.h
|
||||||
engine_type.h
|
engine_type.h
|
||||||
error.h
|
error.h
|
||||||
error_gui.cpp
|
error_gui.cpp
|
||||||
|
@@ -40,6 +40,7 @@
|
|||||||
#include "newgrf_profiling.h"
|
#include "newgrf_profiling.h"
|
||||||
#include "console_func.h"
|
#include "console_func.h"
|
||||||
#include "engine_base.h"
|
#include "engine_base.h"
|
||||||
|
#include "engine_override.h"
|
||||||
#include "road.h"
|
#include "road.h"
|
||||||
#include "rail.h"
|
#include "rail.h"
|
||||||
#include "game/game.hpp"
|
#include "game/game.hpp"
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
#include "engine_gui.h"
|
#include "engine_gui.h"
|
||||||
#include "engine_func.h"
|
#include "engine_func.h"
|
||||||
#include "engine_base.h"
|
#include "engine_base.h"
|
||||||
|
#include "engine_override.h"
|
||||||
#include "company_base.h"
|
#include "company_base.h"
|
||||||
#include "vehicle_func.h"
|
#include "vehicle_func.h"
|
||||||
#include "articulated_vehicles.h"
|
#include "articulated_vehicles.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<EngineIDMapping> {
|
|
||||||
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)
|
inline const EngineInfo *EngInfo(EngineID e)
|
||||||
{
|
{
|
||||||
return &Engine::Get(e)->info;
|
return &Engine::Get(e)->info;
|
||||||
|
40
src/engine_override.h
Normal file
40
src/engine_override.h
Normal file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file engine_override.h Engine override functionality. */
|
||||||
|
|
||||||
|
#ifndef ENGINE_OVERRIDE_H
|
||||||
|
#define ENGINE_OVERRIDE_H
|
||||||
|
|
||||||
|
#include "engine_type.h"
|
||||||
|
#include "vehicle_type.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
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<EngineIDMapping> {
|
||||||
|
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 */
|
@@ -18,6 +18,7 @@
|
|||||||
#include "fileio_func.h"
|
#include "fileio_func.h"
|
||||||
#include "engine_func.h"
|
#include "engine_func.h"
|
||||||
#include "engine_base.h"
|
#include "engine_base.h"
|
||||||
|
#include "engine_override.h"
|
||||||
#include "bridge.h"
|
#include "bridge.h"
|
||||||
#include "town.h"
|
#include "town.h"
|
||||||
#include "newgrf_engine.h"
|
#include "newgrf_engine.h"
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include "newgrf_extension.h"
|
#include "newgrf_extension.h"
|
||||||
#include "newgrf_analysis.h"
|
#include "newgrf_analysis.h"
|
||||||
#include "newgrf_dump.h"
|
#include "newgrf_dump.h"
|
||||||
|
#include "engine_override.h"
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
|
@@ -53,6 +53,7 @@
|
|||||||
#include "station_base.h"
|
#include "station_base.h"
|
||||||
#include "crashlog.h"
|
#include "crashlog.h"
|
||||||
#include "engine_func.h"
|
#include "engine_func.h"
|
||||||
|
#include "engine_override.h"
|
||||||
#include "core/random_func.hpp"
|
#include "core/random_func.hpp"
|
||||||
#include "rail_gui.h"
|
#include "rail_gui.h"
|
||||||
#include "road_gui.h"
|
#include "road_gui.h"
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include "compat/engine_sl_compat.h"
|
#include "compat/engine_sl_compat.h"
|
||||||
|
|
||||||
#include "../engine_base.h"
|
#include "../engine_base.h"
|
||||||
|
#include "../engine_override.h"
|
||||||
#include "../string_func.h"
|
#include "../string_func.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@@ -79,6 +79,7 @@
|
|||||||
#include "statusbar_gui.h"
|
#include "statusbar_gui.h"
|
||||||
#include "graph_gui.h"
|
#include "graph_gui.h"
|
||||||
#include "string_func_extra.h"
|
#include "string_func_extra.h"
|
||||||
|
#include "engine_override.h"
|
||||||
|
|
||||||
#include "void_map.h"
|
#include "void_map.h"
|
||||||
#include "station_base.h"
|
#include "station_base.h"
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include "object.h"
|
#include "object.h"
|
||||||
#include "hotkeys.h"
|
#include "hotkeys.h"
|
||||||
#include "engine_base.h"
|
#include "engine_base.h"
|
||||||
|
#include "engine_override.h"
|
||||||
#include "terraform_gui.h"
|
#include "terraform_gui.h"
|
||||||
#include "cheat_func.h"
|
#include "cheat_func.h"
|
||||||
#include "town_gui.h"
|
#include "town_gui.h"
|
||||||
|
Reference in New Issue
Block a user