Move EngineOverrideManager to separate header

This commit is contained in:
Jonathan G Rennison
2024-05-31 19:15:42 +01:00
parent b42d12deb2
commit 556722399a
11 changed files with 49 additions and 22 deletions

View File

@@ -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

View File

@@ -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"

View File

@@ -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"

View File

@@ -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)
{
return &Engine::Get(e)->info;

40
src/engine_override.h Normal file
View 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 */

View File

@@ -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"

View File

@@ -29,6 +29,7 @@
#include "newgrf_extension.h"
#include "newgrf_analysis.h"
#include "newgrf_dump.h"
#include "engine_override.h"
#include "safeguards.h"

View File

@@ -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"

View File

@@ -13,6 +13,7 @@
#include "compat/engine_sl_compat.h"
#include "../engine_base.h"
#include "../engine_override.h"
#include "../string_func.h"
#include <vector>

View File

@@ -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"

View File

@@ -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"