Skip to content

Commit

Permalink
Merge pull request #348 from altmp/ALTV-627
Browse files Browse the repository at this point in the history
ALTV-627 - make Wheel-Api for server
  • Loading branch information
OlegTrofimov authored Jan 22, 2025
2 parents 5c5d679 + 8f91c19 commit 8de4968
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 1 deletion.
127 changes: 127 additions & 0 deletions server/src/bindings/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,120 @@ static void SetBadge(const v8::FunctionCallbackInfo<v8::Value>& info)
_this->SetBadge(textureDictionary, texture, positions);
}

static void GetWheelCamber(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT();
V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle);
V8_CHECK_ARGS_LEN(1);
V8_ARG_TO_INT(1, wheel);
V8_RETURN_NUMBER(vehicle->GetWheelCamber(wheel));
}

static void SetWheelCamber(const v8::FunctionCallbackInfo<v8::Value>& 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_NUMBER(2, value);
vehicle->SetWheelCamber(wheel, value);
}

static void GetWheelTrackWidth(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT();
V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle);
V8_CHECK_ARGS_LEN(1);
V8_ARG_TO_INT(1, wheel);
V8_RETURN_NUMBER(vehicle->GetWheelTrackWidth(wheel));
}

static void SetWheelTrackWidth(const v8::FunctionCallbackInfo<v8::Value>& 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_NUMBER(2, value);
vehicle->SetWheelTrackWidth(wheel, value);
}

static void GetWheelHeight(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT();
V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle);
V8_CHECK_ARGS_LEN(1);
V8_ARG_TO_INT(1, wheel);
V8_RETURN_NUMBER(vehicle->GetWheelHeight(wheel));
}

static void SetWheelHeight(const v8::FunctionCallbackInfo<v8::Value>& 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_NUMBER(2, value);
vehicle->SetWheelHeight(wheel, value);
}

static void GetWheelTyreRadius(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT();
V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle);
V8_CHECK_ARGS_LEN(1);
V8_ARG_TO_INT(1, wheel);
V8_RETURN_NUMBER(vehicle->GetWheelTyreRadius(wheel));
}

static void SetWheelTyreRadius(const v8::FunctionCallbackInfo<v8::Value>& 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_NUMBER(2, value);
vehicle->SetWheelTyreRadius(wheel, value);
}

static void GetWheelRimRadius(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT();
V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle);
V8_CHECK_ARGS_LEN(1);
V8_ARG_TO_INT(1, wheel);
V8_RETURN_NUMBER(vehicle->GetWheelRimRadius(wheel));
}

static void SetWheelRimRadius(const v8::FunctionCallbackInfo<v8::Value>& 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_NUMBER(2, value);
vehicle->SetWheelRimRadius(wheel, value);
}

static void GetWheelTyreWidth(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT();
V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle);
V8_CHECK_ARGS_LEN(1);
V8_ARG_TO_INT(1, wheel);
V8_RETURN_NUMBER(vehicle->GetWheelTyreWidth(wheel));
}

static void SetWheelTyreWidth(const v8::FunctionCallbackInfo<v8::Value>& 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_NUMBER(2, value);
vehicle->SetWheelTyreWidth(wheel, value);
}

extern V8Class v8Entity;
extern V8Class v8Vehicle("Vehicle",
v8Entity,
Expand Down Expand Up @@ -495,4 +609,17 @@ extern V8Class v8Vehicle("Vehicle",
V8Helpers::SetAccessor<IVehicle, bool, &IVehicle::GetHybridExtraActive, &IVehicle::SetHybridExtraActive>(isolate, tpl, "hybridExtraActive");
V8Helpers::SetAccessor<IVehicle, uint8_t, &IVehicle::GetHybridExtraState, &IVehicle::SetHybridExtraState>(isolate, tpl, "hybridExtraState");
V8Helpers::SetMethod(isolate, tpl, "setBadge", &SetBadge);

V8Helpers::SetMethod(isolate, tpl, "getWheelCamber", GetWheelCamber);
V8Helpers::SetMethod(isolate, tpl, "setWheelCamber", SetWheelCamber);
V8Helpers::SetMethod(isolate, tpl, "getWheelTrackWidth", GetWheelTrackWidth);
V8Helpers::SetMethod(isolate, tpl, "setWheelTrackWidth", SetWheelTrackWidth);
V8Helpers::SetMethod(isolate, tpl, "getWheelHeight", GetWheelHeight);
V8Helpers::SetMethod(isolate, tpl, "setWheelHeight", SetWheelHeight);
V8Helpers::SetMethod(isolate, tpl, "getWheelTyreRadius", GetWheelTyreRadius);
V8Helpers::SetMethod(isolate, tpl, "setWheelTyreRadius", SetWheelTyreRadius);
V8Helpers::SetMethod(isolate, tpl, "getWheelRimRadius", GetWheelRimRadius);
V8Helpers::SetMethod(isolate, tpl, "setWheelRimRadius", SetWheelRimRadius);
V8Helpers::SetMethod(isolate, tpl, "getWheelTyreWidth", GetWheelTyreWidth);
V8Helpers::SetMethod(isolate, tpl, "setWheelTyreWidth", SetWheelTyreWidth);
});
2 changes: 1 addition & 1 deletion shared/deps/cpp-sdk
Submodule cpp-sdk updated 1 files
+14 −13 objects/IVehicle.h

0 comments on commit 8de4968

Please sign in to comment.