Codechange: Use C++ features for train wagon overrides. (#9141)

This removes the need for C-style array management and allows use of iterators to perform wagon override lookups.
This commit is contained in:
2021-04-30 12:03:07 +01:00
committed by GitHub
parent 665a3928e2
commit 3dbd6475fe
4 changed files with 13 additions and 55 deletions

View File

@@ -15,6 +15,12 @@
#include "core/pool_type.hpp"
#include "newgrf_commons.h"
struct WagonOverride {
std::vector<EngineID> engines;
CargoID cargo;
const SpriteGroup *group;
};
typedef Pool<Engine, EngineID, 64, 64000> EnginePool;
extern EnginePool _engine_pool;
@@ -56,13 +62,11 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
* evaluating callbacks.
*/
GRFFilePropsBase<NUM_CARGO + 2> grf_prop;
uint16 overrides_count;
struct WagonOverride *overrides;
std::vector<WagonOverride> overrides;
uint16 list_position;
Engine();
Engine() {}
Engine(VehicleType type, EngineID base);
~Engine();
bool IsEnabled() const;
/**