mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-12 09:09:09 +00:00
Feature: [NewGRF] Maximum curve speed modifier for rail vehicles (#9346)
This commit is contained in:
@@ -1177,16 +1177,23 @@ uint16 GetVehicleCallbackParent(CallbackID callback, uint32 param1, uint32 param
|
||||
|
||||
|
||||
/* Callback 36 handlers */
|
||||
uint GetVehicleProperty(const Vehicle *v, PropertyID property, uint orig_value)
|
||||
int GetVehicleProperty(const Vehicle *v, PropertyID property, int orig_value, bool is_signed)
|
||||
{
|
||||
return GetEngineProperty(v->engine_type, property, orig_value, v);
|
||||
return GetEngineProperty(v->engine_type, property, orig_value, v, is_signed);
|
||||
}
|
||||
|
||||
|
||||
uint GetEngineProperty(EngineID engine, PropertyID property, uint orig_value, const Vehicle *v)
|
||||
int GetEngineProperty(EngineID engine, PropertyID property, int orig_value, const Vehicle *v, bool is_signed)
|
||||
{
|
||||
uint16 callback = GetVehicleCallback(CBID_VEHICLE_MODIFY_PROPERTY, property, 0, engine, v);
|
||||
if (callback != CALLBACK_FAILED) return callback;
|
||||
if (callback != CALLBACK_FAILED) {
|
||||
if (is_signed) {
|
||||
/* Sign extend 15 bit integer */
|
||||
return static_cast<int16>(callback << 1) >> 1;
|
||||
} else {
|
||||
return callback;
|
||||
}
|
||||
}
|
||||
|
||||
return orig_value;
|
||||
}
|
||||
|
Reference in New Issue
Block a user