diff options
author | frosch <frosch@openttd.org> | 2021-04-30 17:35:32 +0200 |
---|---|---|
committer | frosch <github@elsenhans.name> | 2021-05-13 23:28:43 +0200 |
commit | 9f8d0b1bee104471aff1a5e318b2a92bc235d934 (patch) | |
tree | fc0ff5fa0ae9e6eba562b07a02f1d5cc9876d056 /src/newgrf.cpp | |
parent | a9ff296c3d608f04a14cd604a94531f5b42b2061 (diff) | |
download | openttd-9f8d0b1bee104471aff1a5e318b2a92bc235d934.tar.xz |
Fix: Resolve cargo-types of default vehicles via their cargo label.
Default vehicles now behave as if they had a cargo translation table. This fixes default vehicles carrying seemingly random cargos, if NewGRF industry sets are present.
This behavior is disabled, when a NewGRF touches any of the cargo-type or refitting properties. In that case it's up to the NewGRF to define its own cargo translation table.
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r-- | src/newgrf.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 3473cbdc2..dd03e2327 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -8768,6 +8768,12 @@ static void CalculateRefitMasks() EngineInfo *ei = &e->info; bool only_defaultcargo; ///< Set if the vehicle shall carry only the default cargo + /* If the NewGRF did not set any cargo properties, we apply default cargo translation. */ + if (_gted[engine].defaultcargo_grf == nullptr) { + /* Translate cargo_type using the original climate-specific cargo table. */ + ei->cargo_type = GetDefaultCargoID(_settings_game.game_creation.landscape, static_cast<CargoType>(ei->cargo_type)); + } + /* Did the newgrf specify any refitting? If not, use defaults. */ if (_gted[engine].refittability != GRFTempEngineData::UNSET) { CargoTypes mask = 0; @@ -8814,7 +8820,7 @@ static void CalculateRefitMasks() } /* Clear invalid cargoslots (from default vehicles or pre-NewCargo GRFs) */ - if (!HasBit(_cargo_mask, ei->cargo_type)) ei->cargo_type = CT_INVALID; + if (ei->cargo_type != CT_INVALID && !HasBit(_cargo_mask, ei->cargo_type)) ei->cargo_type = CT_INVALID; /* Ensure that the vehicle is either not refittable, or that the default cargo is one of the refittable cargoes. * Note: Vehicles refittable to no cargo are handle differently to vehicle refittable to a single cargo. The latter might have subtypes. */ |