Skip to content

Commit 55e23aa

Browse files
committedAug 4, 2024·
feat(client): implement new sdk methods
ALTV-278
1 parent 6a728f8 commit 55e23aa

File tree

4 files changed

+116
-6
lines changed

4 files changed

+116
-6
lines changed
 

‎.clang-format

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ IndentWidth: 4
44
---
55
Language: Cpp
66
ColumnLimit: 190
7-
AccessModifierOffset: 0
87
AlignAfterOpenBracket: true
98
#AlignConsecutiveAssignments: true
109
AlignConsecutiveBitFields: true
@@ -28,7 +27,6 @@ AlwaysBreakTemplateDeclarations: Yes
2827
BinPackArguments: false
2928
BinPackParameters: false
3029
#BitFieldColonSpacing: Both
31-
BraceWrapping: Custom
3230
BraceWrapping:
3331
AfterCaseLabel: true
3432
AfterClass: true

‎client/src/bindings/Handling.cpp

+25-2
Original file line numberDiff line numberDiff line change
@@ -221,22 +221,44 @@ static void DriveBiasFrontSetter(v8::Local<v8::String>, v8::Local<v8::Value> val
221221
vehicle->GetHandling()->SetDriveBiasFront(fvalue);
222222
}
223223

224+
static void DriveBiasRearGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
225+
{
226+
V8_GET_ISOLATE_CONTEXT();
227+
V8_GET_THIS_INTERNAL_FIELD_ENTITY(1, vehicle, alt::IVehicle);
228+
229+
V8_RETURN_NUMBER(vehicle->GetHandling()->GetDriveBiasRear());
230+
}
231+
232+
static void DriveBiasRearSetter(v8::Local<v8::String>, v8::Local<v8::Value> val, const v8::PropertyCallbackInfo<void>& info)
233+
{
234+
V8_GET_ISOLATE_CONTEXT();
235+
V8_GET_THIS_INTERNAL_FIELD_ENTITY(1, vehicle, alt::IVehicle);
236+
237+
V8_TO_NUMBER(val, fvalue);
238+
vehicle->ReplaceHandling();
239+
vehicle->GetHandling()->SetDriveBiasRear(fvalue);
240+
}
241+
224242
static void AccelerationGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
225243
{
244+
V8_DEPRECATE("HandlingData.acceleration", "HandlingData.driveBiasRear");
245+
226246
V8_GET_ISOLATE_CONTEXT();
227247
V8_GET_THIS_INTERNAL_FIELD_ENTITY(1, vehicle, alt::IVehicle);
228248

229-
V8_RETURN_NUMBER(vehicle->GetHandling()->GetAcceleration());
249+
V8_RETURN_NUMBER(vehicle->GetHandling()->GetDriveBiasRear());
230250
}
231251

232252
static void AccelerationSetter(v8::Local<v8::String>, v8::Local<v8::Value> val, const v8::PropertyCallbackInfo<void>& info)
233253
{
254+
V8_DEPRECATE("HandlingData.acceleration", "HandlingData.driveBiasRear");
255+
234256
V8_GET_ISOLATE_CONTEXT();
235257
V8_GET_THIS_INTERNAL_FIELD_ENTITY(1, vehicle, alt::IVehicle);
236258

237259
V8_TO_NUMBER(val, fvalue);
238260
vehicle->ReplaceHandling();
239-
vehicle->GetHandling()->SetAcceleration(fvalue);
261+
vehicle->GetHandling()->SetDriveBiasRear(fvalue);
240262
}
241263

242264
static void InitialDriveGearsGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
@@ -1230,6 +1252,7 @@ extern V8Class v8Handling("Handling", Constructor, [](v8::Local<v8::FunctionTemp
12301252
V8Helpers::SetAccessor(isolate, tpl, "percentSubmerged", &PercentSubmergedGetter, &PercentSubmergedSetter);
12311253
V8Helpers::SetAccessor(isolate, tpl, "percentSubmergedRatio", &PercentSubmergedRatioGetter, &PercentSubmergedRatioSetter);
12321254
V8Helpers::SetAccessor(isolate, tpl, "driveBiasFront", &DriveBiasFrontGetter, &DriveBiasFrontSetter);
1255+
V8Helpers::SetAccessor(isolate, tpl, "driveBiasRear", &DriveBiasRearGetter, &DriveBiasRearSetter);
12331256
V8Helpers::SetAccessor(isolate, tpl, "acceleration", &AccelerationGetter, &AccelerationSetter);
12341257
V8Helpers::SetAccessor(isolate, tpl, "initialDriveGears", &InitialDriveGearsGetter, &InitialDriveGearsSetter);
12351258
V8Helpers::SetAccessor(isolate, tpl, "driveInertia", &DriveInertiaGetter, &DriveInertiaSetter);

‎client/src/bindings/HandlingData.cpp

+33-2
Original file line numberDiff line numberDiff line change
@@ -320,20 +320,50 @@ static void DriveBiasFrontSetter(v8::Local<v8::String>, v8::Local<v8::Value> val
320320
handling->SetDriveBiasFront(fvalue);
321321
}
322322

323+
static void DriveBiasRearGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
324+
{
325+
V8_GET_ISOLATE_CONTEXT();
326+
327+
V8_GET_THIS_INTERNAL_FIELD_INTEGER(1, modelHash);
328+
329+
auto handling = alt::ICore::Instance().GetHandlingData(modelHash);
330+
V8_CHECK(handling, "handling data for vehicle not found");
331+
332+
V8_RETURN_NUMBER(handling->GetDriveBiasRear());
333+
}
334+
335+
static void DriveBiasRearSetter(v8::Local<v8::String>, v8::Local<v8::Value> val, const v8::PropertyCallbackInfo<void>& info)
336+
{
337+
V8_GET_ISOLATE_CONTEXT();
338+
339+
V8_GET_THIS_INTERNAL_FIELD_INTEGER(1, modelHash);
340+
341+
auto handling = alt::ICore::Instance().GetHandlingData(modelHash);
342+
V8_CHECK(handling, "handling data for vehicle not found");
343+
344+
V8_TO_NUMBER(val, fvalue);
345+
346+
handling->SetDriveBiasRear(fvalue);
347+
}
348+
323349
static void AccelerationGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
324350
{
351+
V8_DEPRECATE("HandlingData.acceleration", "HandlingData.driveBiasRear");
352+
325353
V8_GET_ISOLATE_CONTEXT();
326354

327355
V8_GET_THIS_INTERNAL_FIELD_INTEGER(1, modelHash);
328356

329357
auto handling = alt::ICore::Instance().GetHandlingData(modelHash);
330358
V8_CHECK(handling, "handling data for vehicle not found");
331359

332-
V8_RETURN_NUMBER(handling->GetAcceleration());
360+
V8_RETURN_NUMBER(handling->GetDriveBiasRear());
333361
}
334362

335363
static void AccelerationSetter(v8::Local<v8::String>, v8::Local<v8::Value> val, const v8::PropertyCallbackInfo<void>& info)
336364
{
365+
V8_DEPRECATE("HandlingData.acceleration", "HandlingData.driveBiasRear");
366+
337367
V8_GET_ISOLATE_CONTEXT();
338368

339369
V8_GET_THIS_INTERNAL_FIELD_INTEGER(1, modelHash);
@@ -343,7 +373,7 @@ static void AccelerationSetter(v8::Local<v8::String>, v8::Local<v8::Value> val,
343373

344374
V8_TO_NUMBER(val, fvalue);
345375

346-
handling->SetAcceleration(fvalue);
376+
handling->SetDriveBiasRear(fvalue);
347377
}
348378

349379
static void InitialDriveGearsGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
@@ -1759,6 +1789,7 @@ extern V8Class v8HandlingData("HandlingData", Constructor, [](v8::Local<v8::Func
17591789
V8Helpers::SetAccessor(isolate, tpl, "percentSubmerged", &PercentSubmergedGetter, &PercentSubmergedSetter);
17601790
V8Helpers::SetAccessor(isolate, tpl, "percentSubmergedRatio", &PercentSubmergedRatioGetter, &PercentSubmergedRatioSetter);
17611791
V8Helpers::SetAccessor(isolate, tpl, "driveBiasFront", &DriveBiasFrontGetter, &DriveBiasFrontSetter);
1792+
V8Helpers::SetAccessor(isolate, tpl, "driveBiasRear", &DriveBiasRearGetter, &DriveBiasRearSetter);
17621793
V8Helpers::SetAccessor(isolate, tpl, "acceleration", &AccelerationGetter, &AccelerationSetter);
17631794
V8Helpers::SetAccessor(isolate, tpl, "initialDriveGears", &InitialDriveGearsGetter, &InitialDriveGearsSetter);
17641795
V8Helpers::SetAccessor(isolate, tpl, "driveInertia", &DriveInertiaGetter, &DriveInertiaSetter);

‎client/src/bindings/Vehicle.cpp

+58
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,48 @@ static void SetWheelTyreWidth(const v8::FunctionCallbackInfo<v8::Value>& info)
258258
vehicle->SetWheelTyreWidth(wheel, value);
259259
}
260260

261+
static void GetWheelDynamicFlag(const v8::FunctionCallbackInfo<v8::Value>& info)
262+
{
263+
V8_GET_ISOLATE_CONTEXT();
264+
V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle);
265+
V8_CHECK_ARGS_LEN(2);
266+
V8_ARG_TO_INT(1, wheel);
267+
V8_ARG_TO_UINT(2, flag);
268+
V8_RETURN_BOOLEAN(vehicle->GetWheelDynamicFlag(wheel, flag));
269+
}
270+
271+
static void SetWheelDynamicFlag(const v8::FunctionCallbackInfo<v8::Value>& info)
272+
{
273+
V8_GET_ISOLATE_CONTEXT();
274+
V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle);
275+
V8_CHECK_ARGS_LEN(3);
276+
V8_ARG_TO_INT(1, wheel);
277+
V8_ARG_TO_UINT(2, flag);
278+
V8_ARG_TO_BOOLEAN(3, value);
279+
vehicle->SetWheelDynamicFlag(wheel, flag, value);
280+
}
281+
282+
static void GetWheelConfigFlag(const v8::FunctionCallbackInfo<v8::Value>& info)
283+
{
284+
V8_GET_ISOLATE_CONTEXT();
285+
V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle);
286+
V8_CHECK_ARGS_LEN(2);
287+
V8_ARG_TO_INT(1, wheel);
288+
V8_ARG_TO_UINT(2, flag);
289+
V8_RETURN_BOOLEAN(vehicle->GetWheelConfigFlag(wheel, flag));
290+
}
291+
292+
static void SetWheelConfigFlag(const v8::FunctionCallbackInfo<v8::Value>& info)
293+
{
294+
V8_GET_ISOLATE_CONTEXT();
295+
V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle);
296+
V8_CHECK_ARGS_LEN(3);
297+
V8_ARG_TO_INT(1, wheel);
298+
V8_ARG_TO_UINT(2, flag);
299+
V8_ARG_TO_BOOLEAN(3, value);
300+
vehicle->SetWheelConfigFlag(wheel, flag, value);
301+
}
302+
261303
static void GetWheelSurfaceMaterial(const v8::FunctionCallbackInfo<v8::Value>& info)
262304
{
263305
V8_GET_ISOLATE_CONTEXT();
@@ -267,6 +309,15 @@ static void GetWheelSurfaceMaterial(const v8::FunctionCallbackInfo<v8::Value>& i
267309
V8_RETURN_UINT(vehicle->GetWheelSurfaceMaterial(wheel));
268310
}
269311

312+
static void SetupTransmission(const v8::FunctionCallbackInfo<v8::Value>& info)
313+
{
314+
V8_GET_ISOLATE_CONTEXT();
315+
V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle);
316+
V8_CHECK_ARGS_LEN(0);
317+
318+
vehicle->SetupTransmission();
319+
}
320+
270321
static void StaticGetByRemoteId(const v8::FunctionCallbackInfo<v8::Value>& info)
271322
{
272323
V8_GET_ISOLATE_CONTEXT_RESOURCE();
@@ -331,6 +382,11 @@ extern V8Class v8Vehicle("Vehicle",
331382
V8Helpers::SetMethod(isolate, tpl, "getWheelTyreWidth", GetWheelTyreWidth);
332383
V8Helpers::SetMethod(isolate, tpl, "setWheelTyreWidth", SetWheelTyreWidth);
333384

385+
V8Helpers::SetMethod(isolate, tpl, "getWheelDynamicFlag", GetWheelDynamicFlag);
386+
V8Helpers::SetMethod(isolate, tpl, "setWheelDynamicFlag", SetWheelDynamicFlag);
387+
V8Helpers::SetMethod(isolate, tpl, "getWheelConfigFlag", GetWheelConfigFlag);
388+
V8Helpers::SetMethod(isolate, tpl, "setWheelConfigFlag", SetWheelConfigFlag);
389+
334390
V8Helpers::SetAccessor<IVehicle, float, &IVehicle::GetEngineTemperature, &IVehicle::SetEngineTemperature>(isolate, tpl, "engineTemperature");
335391
V8Helpers::SetAccessor<IVehicle, float, &IVehicle::GetFuelLevel, &IVehicle::SetFuelLevel>(isolate, tpl, "fuelLevel");
336392
V8Helpers::SetAccessor<IVehicle, float, &IVehicle::GetOilLevel, &IVehicle::SetOilLevel>(isolate, tpl, "oilLevel");
@@ -348,6 +404,8 @@ extern V8Class v8Vehicle("Vehicle",
348404
V8Helpers::SetAccessor<IVehicle, float, &IVehicle::GetSteeringAngle, &IVehicle::SetSteeringAngle>(isolate, tpl, "steeringAngle");
349405
V8Helpers::SetAccessor<IVehicle, float, &IVehicle::GetSuspensionHeight, &IVehicle::SetSuspensionHeight>(isolate, tpl, "suspensionHeight");
350406

407+
V8Helpers::SetMethod(isolate, tpl, "setupTransmission", SetupTransmission);
408+
351409
/*GETTERS BELOW ARE UNIMPLEMENTED
352410
V8Helpers::SetAccessor(isolate, tpl, "isDestroyed", &IsDestroyedGetter);
353411
V8Helpers::SetAccessor(isolate, tpl, "driver", &DriverGetter);

0 commit comments

Comments
 (0)
Please sign in to comment.