diff --git a/.clang-format b/.clang-format index 7cbf8ef7..8dd3281c 100644 --- a/.clang-format +++ b/.clang-format @@ -4,7 +4,6 @@ IndentWidth: 4 --- Language: Cpp ColumnLimit: 190 -AccessModifierOffset: 0 AlignAfterOpenBracket: true #AlignConsecutiveAssignments: true AlignConsecutiveBitFields: true @@ -28,7 +27,6 @@ AlwaysBreakTemplateDeclarations: Yes BinPackArguments: false BinPackParameters: false #BitFieldColonSpacing: Both -BraceWrapping: Custom BraceWrapping: AfterCaseLabel: true AfterClass: true diff --git a/client/src/bindings/Handling.cpp b/client/src/bindings/Handling.cpp index ce119d60..d572511d 100644 --- a/client/src/bindings/Handling.cpp +++ b/client/src/bindings/Handling.cpp @@ -221,22 +221,44 @@ static void DriveBiasFrontSetter(v8::Local, v8::Local val vehicle->GetHandling()->SetDriveBiasFront(fvalue); } +static void DriveBiasRearGetter(v8::Local, const v8::PropertyCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_INTERNAL_FIELD_ENTITY(1, vehicle, alt::IVehicle); + + V8_RETURN_NUMBER(vehicle->GetHandling()->GetDriveBiasRear()); +} + +static void DriveBiasRearSetter(v8::Local, v8::Local val, const v8::PropertyCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_INTERNAL_FIELD_ENTITY(1, vehicle, alt::IVehicle); + + V8_TO_NUMBER(val, fvalue); + vehicle->ReplaceHandling(); + vehicle->GetHandling()->SetDriveBiasRear(fvalue); +} + static void AccelerationGetter(v8::Local, const v8::PropertyCallbackInfo& info) { + V8_DEPRECATE("HandlingData.acceleration", "HandlingData.driveBiasRear"); + V8_GET_ISOLATE_CONTEXT(); V8_GET_THIS_INTERNAL_FIELD_ENTITY(1, vehicle, alt::IVehicle); - V8_RETURN_NUMBER(vehicle->GetHandling()->GetAcceleration()); + V8_RETURN_NUMBER(vehicle->GetHandling()->GetDriveBiasRear()); } static void AccelerationSetter(v8::Local, v8::Local val, const v8::PropertyCallbackInfo& info) { + V8_DEPRECATE("HandlingData.acceleration", "HandlingData.driveBiasRear"); + V8_GET_ISOLATE_CONTEXT(); V8_GET_THIS_INTERNAL_FIELD_ENTITY(1, vehicle, alt::IVehicle); V8_TO_NUMBER(val, fvalue); vehicle->ReplaceHandling(); - vehicle->GetHandling()->SetAcceleration(fvalue); + vehicle->GetHandling()->SetDriveBiasRear(fvalue); } static void InitialDriveGearsGetter(v8::Local, const v8::PropertyCallbackInfo& info) @@ -1230,6 +1252,7 @@ extern V8Class v8Handling("Handling", Constructor, [](v8::Local, v8::Local val handling->SetDriveBiasFront(fvalue); } +static void DriveBiasRearGetter(v8::Local, const v8::PropertyCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + + V8_GET_THIS_INTERNAL_FIELD_INTEGER(1, modelHash); + + auto handling = alt::ICore::Instance().GetHandlingData(modelHash); + V8_CHECK(handling, "handling data for vehicle not found"); + + V8_RETURN_NUMBER(handling->GetDriveBiasRear()); +} + +static void DriveBiasRearSetter(v8::Local, v8::Local val, const v8::PropertyCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + + V8_GET_THIS_INTERNAL_FIELD_INTEGER(1, modelHash); + + auto handling = alt::ICore::Instance().GetHandlingData(modelHash); + V8_CHECK(handling, "handling data for vehicle not found"); + + V8_TO_NUMBER(val, fvalue); + + handling->SetDriveBiasRear(fvalue); +} + static void AccelerationGetter(v8::Local, const v8::PropertyCallbackInfo& info) { + V8_DEPRECATE("HandlingData.acceleration", "HandlingData.driveBiasRear"); + V8_GET_ISOLATE_CONTEXT(); V8_GET_THIS_INTERNAL_FIELD_INTEGER(1, modelHash); @@ -329,11 +357,13 @@ static void AccelerationGetter(v8::Local, const v8::PropertyCallback auto handling = alt::ICore::Instance().GetHandlingData(modelHash); V8_CHECK(handling, "handling data for vehicle not found"); - V8_RETURN_NUMBER(handling->GetAcceleration()); + V8_RETURN_NUMBER(handling->GetDriveBiasRear()); } static void AccelerationSetter(v8::Local, v8::Local val, const v8::PropertyCallbackInfo& info) { + V8_DEPRECATE("HandlingData.acceleration", "HandlingData.driveBiasRear"); + V8_GET_ISOLATE_CONTEXT(); V8_GET_THIS_INTERNAL_FIELD_INTEGER(1, modelHash); @@ -343,7 +373,7 @@ static void AccelerationSetter(v8::Local, v8::Local val, V8_TO_NUMBER(val, fvalue); - handling->SetAcceleration(fvalue); + handling->SetDriveBiasRear(fvalue); } static void InitialDriveGearsGetter(v8::Local, const v8::PropertyCallbackInfo& info) @@ -1759,6 +1789,7 @@ extern V8Class v8HandlingData("HandlingData", Constructor, [](v8::Local& info) vehicle->SetWheelTyreWidth(wheel, value); } +static void GetWheelDynamicFlag(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle); + V8_CHECK_ARGS_LEN(2); + V8_ARG_TO_INT(1, wheel); + V8_ARG_TO_UINT(2, flag); + V8_RETURN_BOOLEAN(vehicle->GetWheelDynamicFlag(wheel, flag)); +} + +static void SetWheelDynamicFlag(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle); + V8_CHECK_ARGS_LEN(3); + V8_ARG_TO_INT(1, wheel); + V8_ARG_TO_UINT(2, flag); + V8_ARG_TO_BOOLEAN(3, value); + vehicle->SetWheelDynamicFlag(wheel, flag, value); +} + +static void GetWheelConfigFlag(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle); + V8_CHECK_ARGS_LEN(2); + V8_ARG_TO_INT(1, wheel); + V8_ARG_TO_UINT(2, flag); + V8_RETURN_BOOLEAN(vehicle->GetWheelConfigFlag(wheel, flag)); +} + +static void SetWheelConfigFlag(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle); + V8_CHECK_ARGS_LEN(3); + V8_ARG_TO_INT(1, wheel); + V8_ARG_TO_UINT(2, flag); + V8_ARG_TO_BOOLEAN(3, value); + vehicle->SetWheelConfigFlag(wheel, flag, value); +} + static void GetWheelSurfaceMaterial(const v8::FunctionCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT(); @@ -267,6 +309,15 @@ static void GetWheelSurfaceMaterial(const v8::FunctionCallbackInfo& i V8_RETURN_UINT(vehicle->GetWheelSurfaceMaterial(wheel)); } +static void SetupTransmission(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle); + V8_CHECK_ARGS_LEN(0); + + vehicle->SetupTransmission(); +} + static void StaticGetByRemoteId(const v8::FunctionCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT_RESOURCE(); @@ -331,6 +382,11 @@ extern V8Class v8Vehicle("Vehicle", V8Helpers::SetMethod(isolate, tpl, "getWheelTyreWidth", GetWheelTyreWidth); V8Helpers::SetMethod(isolate, tpl, "setWheelTyreWidth", SetWheelTyreWidth); + V8Helpers::SetMethod(isolate, tpl, "getWheelDynamicFlag", GetWheelDynamicFlag); + V8Helpers::SetMethod(isolate, tpl, "setWheelDynamicFlag", SetWheelDynamicFlag); + V8Helpers::SetMethod(isolate, tpl, "getWheelConfigFlag", GetWheelConfigFlag); + V8Helpers::SetMethod(isolate, tpl, "setWheelConfigFlag", SetWheelConfigFlag); + V8Helpers::SetAccessor(isolate, tpl, "engineTemperature"); V8Helpers::SetAccessor(isolate, tpl, "fuelLevel"); V8Helpers::SetAccessor(isolate, tpl, "oilLevel"); @@ -348,6 +404,8 @@ extern V8Class v8Vehicle("Vehicle", V8Helpers::SetAccessor(isolate, tpl, "steeringAngle"); V8Helpers::SetAccessor(isolate, tpl, "suspensionHeight"); + V8Helpers::SetMethod(isolate, tpl, "setupTransmission", SetupTransmission); + /*GETTERS BELOW ARE UNIMPLEMENTED V8Helpers::SetAccessor(isolate, tpl, "isDestroyed", &IsDestroyedGetter); V8Helpers::SetAccessor(isolate, tpl, "driver", &DriverGetter); diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index defcd54b..b1ced940 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit defcd54bae97199ef3f82a47a06c0b69f47eb912 +Subproject commit b1ced94027a7b3c0c2167b12e45da80b49c8527b