From f24c4d2c9e805c6a985c1087634de60349077c5f Mon Sep 17 00:00:00 2001 From: Artem Dzhemesiuk Date: Thu, 5 Oct 2023 14:52:15 +0200 Subject: [PATCH 1/5] Fixed Audio constructor argument count --- client/src/bindings/Audio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/bindings/Audio.cpp b/client/src/bindings/Audio.cpp index 2383439c..e7df7cd0 100644 --- a/client/src/bindings/Audio.cpp +++ b/client/src/bindings/Audio.cpp @@ -12,7 +12,7 @@ static void Constructor(const v8::FunctionCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT_RESOURCE(); V8_CHECK_CONSTRUCTOR(); - V8_CHECK_ARGS_LEN_MIN_MAX(1, 3); + V8_CHECK_ARGS_LEN_MIN_MAX(1, 4); V8_ARG_TO_STRING(1, source); V8_ARG_TO_NUMBER_OPT(2, volume, 1.f); From 21883942459325150c9b1f23245a61a4ecf89e1b Mon Sep 17 00:00:00 2001 From: Blue Date: Sat, 7 Oct 2023 17:59:45 +0200 Subject: [PATCH 2/5] server: cloudid changes --- server/src/bindings/ConnectionInfo.cpp | 33 +++-------------------- server/src/bindings/Player.cpp | 36 +------------------------- shared/deps/cpp-sdk | 2 +- 3 files changed, 5 insertions(+), 66 deletions(-) diff --git a/server/src/bindings/ConnectionInfo.cpp b/server/src/bindings/ConnectionInfo.cpp index 140d155d..6df705c0 100644 --- a/server/src/bindings/ConnectionInfo.cpp +++ b/server/src/bindings/ConnectionInfo.cpp @@ -175,38 +175,11 @@ static void SetText(v8::Local, v8::Local val, const v8::P con->SetText(text); } -static void RequestCloudID(const v8::FunctionCallbackInfo& info) +static void GetCloudIDGetter(v8::Local, const v8::PropertyCallbackInfo& info) { - static std::list> promises; - V8_GET_ISOLATE_CONTEXT_RESOURCE(); V8_GET_THIS_BASE_OBJECT(con, alt::IConnectionInfo); - - auto& persistent = promises.emplace_back(v8::Global(isolate, v8::Promise::Resolver::New(ctx).ToLocalChecked())); - - con->RequestCloudID( - [&persistent, resource](bool ok, const std::string& result) - { - resource->RunOnNextTick( - [=, &persistent]() - { - if(!resource->GetResource()->IsStarted()) - { - promises.remove(persistent); - return; - } - - auto isolate = resource->GetIsolate(); - auto context = resource->GetContext(); - - if(ok) persistent.Get(isolate)->Resolve(context, V8Helpers::JSValue(result)); - else - persistent.Get(isolate)->Reject(context, v8::Exception::Error(V8Helpers::JSValue(result))); - promises.remove(persistent); - }); - }); - - V8_RETURN(persistent.Get(isolate)->GetPromise()); + V8_RETURN_STRING(con->GetCloudID()); } extern V8Class v8BaseObject; @@ -224,7 +197,6 @@ extern V8Class v8ConnectionInfo("ConnectionInfo", V8Helpers::SetMethod(isolate, tpl, "accept", &Accept); V8Helpers::SetMethod(isolate, tpl, "decline", &Decline); - V8Helpers::SetMethod(isolate, tpl, "requestCloudID", &RequestCloudID); V8Helpers::SetAccessor(isolate, tpl, "isAccepted", &IsAcceptedGetter); V8Helpers::SetAccessor(isolate, tpl, "name", &NameGetter); @@ -241,5 +213,6 @@ extern V8Class v8ConnectionInfo("ConnectionInfo", V8Helpers::SetAccessor(isolate, tpl, "discordUserID", &DiscordUserIDGetter); V8Helpers::SetAccessor(isolate, tpl, "socialClubName", &SocialClubNameGetter); V8Helpers::SetAccessor(isolate, tpl, "id", &ConnectionIDGetter); + V8Helpers::SetAccessor(isolate, tpl, "cloudID", &GetCloudIDGetter); V8Helpers::SetAccessor(isolate, tpl, "text", &GetText, &SetText); }); diff --git a/server/src/bindings/Player.cpp b/server/src/bindings/Player.cpp index a1ff6eeb..717f2b84 100644 --- a/server/src/bindings/Player.cpp +++ b/server/src/bindings/Player.cpp @@ -866,40 +866,6 @@ static void GetLocalMetaDataKeys(const v8::FunctionCallbackInfo& info V8_RETURN(arr); } -static void RequestCloudID(const v8::FunctionCallbackInfo& info) -{ - static std::list> promises; - - V8_GET_ISOLATE_CONTEXT_RESOURCE(); - V8_GET_THIS_BASE_OBJECT(player, alt::IPlayer); - - auto& persistent = promises.emplace_back(v8::Global(isolate, v8::Promise::Resolver::New(ctx).ToLocalChecked())); - - player->RequestCloudID( - [&persistent, resource](bool ok, const std::string& result) - { - resource->RunOnNextTick( - [=, &persistent]() - { - if(!resource->GetResource()->IsStarted()) - { - promises.remove(persistent); - return; - } - - auto isolate = resource->GetIsolate(); - auto context = resource->GetContext(); - - if(ok) persistent.Get(isolate)->Resolve(context, V8Helpers::JSValue(result)); - else - persistent.Get(isolate)->Reject(context, v8::Exception::Error(V8Helpers::JSValue(result))); - promises.remove(persistent); - }); - }); - - V8_RETURN(persistent.Get(isolate)->GetPromise()); -} - static void DiscordIDGetter(v8::Local name, const v8::PropertyCallbackInfo& info) { V8_GET_ISOLATE(); @@ -1427,9 +1393,9 @@ extern V8Class v8Player("Player", V8Helpers::SetMethod(isolate, tpl, "getLocalMeta", &GetLocalMeta); V8Helpers::SetMethod(isolate, tpl, "deleteLocalMeta", &DeleteLocalMeta); V8Helpers::SetMethod(isolate, tpl, "getLocalMetaKeys", &GetLocalMetaDataKeys); - V8Helpers::SetMethod(isolate, tpl, "requestCloudID", &RequestCloudID); V8Helpers::SetAccessor(isolate, tpl, "ping"); + V8Helpers::SetAccessor(isolate, tpl, "cloudID"); V8Helpers::SetAccessor(isolate, tpl, "ip"); V8Helpers::SetAccessor(isolate, tpl, "name"); V8Helpers::SetAccessor(isolate, tpl, "vehicle"); diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index caa4d57c..7413c471 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit caa4d57c6fc8fab24c7ed12338b69401b9c7e8b3 +Subproject commit 7413c4717ce1ee8b7a65486d2c78329cd47c5e6c From c0b9d46c294c1c8cde178d905f1e2a6d03514f3f Mon Sep 17 00:00:00 2001 From: Blue Date: Sun, 8 Oct 2023 12:26:50 +0200 Subject: [PATCH 3/5] server: add GetLoadedVehicleModels --- server/src/bindings/Main.cpp | 11 +++++++++++ shared/deps/cpp-sdk | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/server/src/bindings/Main.cpp b/server/src/bindings/Main.cpp index b13e4cc5..cb5ba148 100644 --- a/server/src/bindings/Main.cpp +++ b/server/src/bindings/Main.cpp @@ -811,6 +811,16 @@ static void SetMigrationDistance(const v8::FunctionCallbackInfo& info alt::ICore::Instance().SetMigrationDistance(tickrate); } +static void GetLoadedVehicleModels(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + + std::vector list = alt::ICore::Instance().GetLoadedVehicleModels(); + v8::Local modelArray = V8Helpers::JSValue(list); + + V8_RETURN(modelArray); +} + extern V8Class v8Player, v8Vehicle, v8Blip, v8AreaBlip, v8RadiusBlip, v8PointBlip, v8Checkpoint, v8VoiceChannel, v8Colshape, v8ColshapeCylinder, v8ColshapeSphere, v8ColshapeCircle, v8ColshapeCuboid, v8ColshapeRectangle, v8ColshapePolygon, v8Ped, v8Object, v8VirtualEntity, v8VirtualEntityGroup, v8Marker, v8ConnectionInfo; @@ -852,6 +862,7 @@ extern V8Module V8Helpers::RegisterFunc(exports, "stopServer", &StopServer); V8Helpers::RegisterFunc(exports, "getVehicleModelInfoByHash", &GetVehicleModelByHash); + V8Helpers::RegisterFunc(exports, "getLoadedVehicleModels", &GetLoadedVehicleModels); V8Helpers::RegisterFunc(exports, "getPedModelInfoByHash", &GetPedModelByHash); V8Helpers::RegisterFunc(exports, "getWeaponModelInfoByHash", &GetWeaponModelByHash); V8Helpers::RegisterFunc(exports, "getAmmoHashForWeaponHash", &GetAmmoHashForWeaponHash); diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index 7413c471..bbbfc04d 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit 7413c4717ce1ee8b7a65486d2c78329cd47c5e6c +Subproject commit bbbfc04d2cdf828a616a17d7bfc49e75d6e849d3 From 30b81b1769c03630dcceec1ee1b4b8c4e3a2ad53 Mon Sep 17 00:00:00 2001 From: Artem Dzhemesiuk Date: Mon, 9 Oct 2023 18:00:39 +0200 Subject: [PATCH 4/5] server: fix decoration methods --- server/src/bindings/Player.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/src/bindings/Player.cpp b/server/src/bindings/Player.cpp index 717f2b84..32a0bf82 100644 --- a/server/src/bindings/Player.cpp +++ b/server/src/bindings/Player.cpp @@ -1288,7 +1288,8 @@ static void AddDecoration(const v8::FunctionCallbackInfo& info) uint32_t overlayHash; if(info[0]->IsNumber()) { - V8_ARG_TO_UINT(1, collectionHash); + V8_ARG_TO_UINT(1, collection); + collectionHash = collection; } else { @@ -1298,7 +1299,8 @@ static void AddDecoration(const v8::FunctionCallbackInfo& info) if(info[1]->IsNumber()) { - V8_ARG_TO_UINT(2, overlayHash); + V8_ARG_TO_UINT(2, overlay); + overlayHash = overlay; } else { @@ -1319,7 +1321,8 @@ static void RemoveDecoration(const v8::FunctionCallbackInfo& info) uint32_t overlayHash; if(info[0]->IsNumber()) { - V8_ARG_TO_UINT(1, collectionHash); + V8_ARG_TO_UINT(1, collection); + collectionHash = collection; } else { @@ -1329,7 +1332,8 @@ static void RemoveDecoration(const v8::FunctionCallbackInfo& info) if(info[1]->IsNumber()) { - V8_ARG_TO_UINT(2, overlayHash); + V8_ARG_TO_UINT(2, overlay); + overlayHash = overlay; } else { From d75b21815d317d4460e8a18ffd2be318783a84cb Mon Sep 17 00:00:00 2001 From: xLuxy <67131061+xLuxy@users.noreply.github.com> Date: Fri, 13 Oct 2023 21:24:49 +0200 Subject: [PATCH 5/5] server: Fix Checkpoint streamingDistance ctor argument --- server/src/bindings/Checkpoint.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/bindings/Checkpoint.cpp b/server/src/bindings/Checkpoint.cpp index 237353f3..dbe41e14 100644 --- a/server/src/bindings/Checkpoint.cpp +++ b/server/src/bindings/Checkpoint.cpp @@ -24,13 +24,13 @@ static void Constructor(const v8::FunctionCallbackInfo& info) V8_ARG_TO_NUMBER(3, radiusVal); V8_ARG_TO_NUMBER(4, heightVal); V8_ARG_TO_RGBA(5, colorVal); - V8_ARG_TO_UINT(6, streamingDistance) + V8_ARG_TO_UINT(6, _streamingDistance) pos = posVal; color = colorVal; radius = radiusVal; height = heightVal; - streamingDistance = streamingDistance; + streamingDistance = _streamingDistance; } else { @@ -43,13 +43,13 @@ static void Constructor(const v8::FunctionCallbackInfo& info) V8_ARG_TO_INT(8, g); V8_ARG_TO_INT(9, b); V8_ARG_TO_INT(10, a); - V8_ARG_TO_UINT(11, streamingDistance) + V8_ARG_TO_UINT(11, _streamingDistance) pos = { x, y, z }; color = { (uint8_t)r, (uint8_t)g, (uint8_t)b, (uint8_t)a }; radius = radiusVal; height = heightVal; - streamingDistance = streamingDistance; + streamingDistance = _streamingDistance; } ICheckpoint* cp = ICore::Instance().CreateCheckpoint(type, pos, radius, height, color, streamingDistance);