VarAction2: Detect and replace scaled reads of train/RV/ship current speed

This commit is contained in:
Jonathan G Rennison
2022-05-26 21:31:20 +01:00
parent 730b84e262
commit 2360b3e93e
4 changed files with 27 additions and 3 deletions

View File

@@ -25,6 +25,7 @@
#include "newgrf_cache_check.h"
#include "ship.h"
#include "scope_info.h"
#include "newgrf_extension.h"
#include "safeguards.h"
@@ -477,6 +478,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
case 0x80 + 0x34:
case 0x80 + 0x35:
case A2VRI_VEHICLE_CURRENT_SPEED_SCALED:
if (v->type == VEH_AIRCRAFT) {
_sprite_group_resolve_check_veh_check = false;
} else {
@@ -878,6 +880,9 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
return variable == 0xFE ? modflags : GB(modflags, 8, 8);
}
case A2VRI_VEHICLE_CURRENT_SPEED_SCALED:
return (v->cur_speed * parameter) >> 16;
}
/*