NewGRF: Elide unmasked vehicle callbacks where possible

This includes:
* CBID_VEHICLE_32DAY_CALLBACK
* CBID_VEHICLE_REFIT_COST
* CBID_VEHICLE_MODIFY_PROPERTY
  This is on a per-property basis

The main benefit of this is to avoid callbacks not handled by the
vehicle's current sprite group from using the full graphics chain as
the "default" branch in the callback switch.
In the case where the graphics chain is long/expensive, a lot of work
had to be done before a callback failure result was eventually returned.
This commit is contained in:
Jonathan G Rennison
2021-05-18 19:07:44 +01:00
parent 7274432987
commit a15e26f369
12 changed files with 285 additions and 3 deletions

View File

@@ -272,7 +272,7 @@ static int GetRefitCostFactor(const Vehicle *v, EngineID engine_type, CargoID ne
const Engine *e = Engine::Get(engine_type);
/* Is this vehicle a NewGRF vehicle? */
if (e->GetGRF() != nullptr) {
if (e->GetGRF() != nullptr && (e->callbacks_used & SGCU_VEHICLE_REFIT_COST) != 0) {
const CargoSpec *cs = CargoSpec::Get(new_cid);
uint32 param1 = (cs->classes << 16) | (new_subtype << 8) | e->GetGRF()->cargo_map[new_cid];