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); 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); 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/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/server/src/bindings/Player.cpp b/server/src/bindings/Player.cpp index a1ff6eeb..32a0bf82 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(); @@ -1322,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 { @@ -1332,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 { @@ -1353,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 { @@ -1363,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 { @@ -1427,9 +1397,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");