From 7981ac40d0a7329aa31f5d52af0247661da64a00 Mon Sep 17 00:00:00 2001 From: Vektor Date: Tue, 26 Dec 2023 14:47:15 +0100 Subject: [PATCH 01/14] chore: bump sdk --- shared/deps/cpp-sdk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index 298e02d3..a474e345 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit 298e02d3cce8dd67ca19709a57bc9c77ced4c7c6 +Subproject commit a474e3453f1e774bd8194a226b51a9d68d1242da From a0e62a9fe1a75b53a6a27fd5f098aef2c5e13e1c Mon Sep 17 00:00:00 2001 From: xLuxy <67131061+xLuxy@users.noreply.github.com> Date: Thu, 28 Dec 2023 14:47:56 +0100 Subject: [PATCH 02/14] chore: Update cpp-sdk --- shared/deps/cpp-sdk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index a474e345..e45d0588 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit a474e3453f1e774bd8194a226b51a9d68d1242da +Subproject commit e45d05882e7af0ea8cf2865ddd148914cb187af1 From 49540fc09d3df3a01d6259b894bed694c7231f88 Mon Sep 17 00:00:00 2001 From: xLuxy <67131061+xLuxy@users.noreply.github.com> Date: Thu, 28 Dec 2023 15:24:29 +0100 Subject: [PATCH 03/14] feat(client): Add new voice methods --- client/src/bindings/ClientBindingsMain.cpp | 112 ++++++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-) diff --git a/client/src/bindings/ClientBindingsMain.cpp b/client/src/bindings/ClientBindingsMain.cpp index f3037b0e..4294e8ac 100644 --- a/client/src/bindings/ClientBindingsMain.cpp +++ b/client/src/bindings/ClientBindingsMain.cpp @@ -1226,7 +1226,7 @@ static void GetPoolEntities(const v8::FunctionCallbackInfo& info) V8_GET_ISOLATE_CONTEXT(); V8_CHECK_ARGS_LEN(1); V8_ARG_TO_STRING(1, pool); - + auto entities = alt::ICore::Instance().GetPoolEntities(pool); v8::Local arr = v8::Array::New(isolate, entities.size()); @@ -1236,6 +1236,102 @@ static void GetPoolEntities(const v8::FunctionCallbackInfo& info) V8_RETURN(arr); } +static void GetVoicePlayers(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + + auto players = alt::ICore::Instance().GetVoicePlayers(); + v8::Local arr = v8::Array::New(isolate, players.size()); + + for (uint32_t i = 0; i < players.size(); ++i) + arr->Set(ctx, i, v8::Integer::NewFromUnsigned(isolate, players[i])); + + V8_RETURN(arr); +} + +static void RemoveVoicePlayer(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_CHECK_ARGS_LEN(1); + + V8_ARG_TO_INT(1, playerId); + + alt::ICore::Instance().RemoveVoicePlayer(playerId); +} + +static void GetVoiceSpatialVolume(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_CHECK_ARGS_LEN(1); + + V8_ARG_TO_INT(1, playerId); + + V8_RETURN_NUMBER(alt::ICore::Instance().GetVoiceSpatialVolume(playerId)); +} + +static void SetVoiceSpatialVolume(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_CHECK_ARGS_LEN(2); + + V8_ARG_TO_INT(1, playerId); + V8_ARG_TO_NUMBER(2, value); + + alt::ICore::Instance().SetVoiceSpatialVolume(playerId, value); +} + +static void GetVoiceNonSpatialVolume(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_CHECK_ARGS_LEN(1); + + V8_ARG_TO_INT(1, playerId); + + V8_RETURN_NUMBER(alt::ICore::Instance().GetVoiceNonSpatialVolume(playerId)); +} + +static void SetVoiceNonSpatialVolume(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_CHECK_ARGS_LEN(2); + + V8_ARG_TO_INT(1, playerId); + V8_ARG_TO_NUMBER(2, value); + + alt::ICore::Instance().SetVoiceNonSpatialVolume(playerId, value); +} + +static void AddVoiceFilter(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT_RESOURCE(); + V8_CHECK_ARGS_LEN(2); + + V8_ARG_TO_INT(1, playerId); + V8_ARG_TO_BASE_OBJECT(2, filter, alt::IAudioFilter); + + alt::ICore::Instance().AddVoiceFilter(playerId, filter); +} + +static void RemoveVoiceFilter(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT_RESOURCE(); + V8_CHECK_ARGS_LEN(1); + + V8_ARG_TO_INT(1, playerId); + + alt::ICore::Instance().RemoveVoiceFilter(playerId); +} + +static void GetVoiceFilter(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT_RESOURCE(); + V8_CHECK_ARGS_LEN(1); + + V8_ARG_TO_INT(1, playerId); + + V8_RETURN_BASE_OBJECT(alt::ICore::Instance().GetVoiceFilter(playerId)); +} + extern V8Module sharedModule; extern V8Class v8Player, v8Player, v8Vehicle, v8WebView, v8HandlingData, v8LocalStorage, v8MemoryBuffer, v8MapZoomData, v8Discord, v8Voice, v8WebSocketClient, v8Checkpoint, v8HttpClient, v8Audio, v8LocalPlayer, v8Profiler, v8Worker, v8RmlDocument, v8RmlElement, v8WeaponData, v8FocusData, v8LocalObject, v8TextEncoder, v8TextDecoder, v8Object, v8VirtualEntityGroup, @@ -1427,4 +1523,18 @@ extern V8Module altModule("alt", V8Helpers::RegisterFunc(exports, "getPoolSize", &GetPoolSize); V8Helpers::RegisterFunc(exports, "getPoolCount", &GetPoolCount); V8Helpers::RegisterFunc(exports, "getPoolEntities", &GetPoolEntities); + + V8Helpers::RegisterFunc(exports, "getVoicePlayers", &GetVoicePlayers); + V8Helpers::RegisterFunc(exports, "removeVoicePlayer", &RemoveVoicePlayer); + + // Voice related functions + V8Helpers::RegisterFunc(exports, "getVoiceSpatialVolume", &GetVoiceSpatialVolume); + V8Helpers::RegisterFunc(exports, "setVoiceSpatialVolume", &SetVoiceSpatialVolume); + + V8Helpers::RegisterFunc(exports, "getVoiceNonSpatialVolume", &GetVoiceNonSpatialVolume); + V8Helpers::RegisterFunc(exports, "setVoiceNonSpatialVolume", &SetVoiceNonSpatialVolume); + + V8Helpers::RegisterFunc(exports, "addVoiceFilter", &AddVoiceFilter); + V8Helpers::RegisterFunc(exports, "removeVoiceFilter", &RemoveVoiceFilter); + V8Helpers::RegisterFunc(exports, "getVoiceFilter", &GetVoiceFilter); }); From 33355ee691758769d7d115a5bb9e2bad567a9497 Mon Sep 17 00:00:00 2001 From: xLuxy <67131061+xLuxy@users.noreply.github.com> Date: Thu, 28 Dec 2023 15:30:57 +0100 Subject: [PATCH 04/14] chore(client): Move comment --- client/src/bindings/ClientBindingsMain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/bindings/ClientBindingsMain.cpp b/client/src/bindings/ClientBindingsMain.cpp index 4294e8ac..d3a8f475 100644 --- a/client/src/bindings/ClientBindingsMain.cpp +++ b/client/src/bindings/ClientBindingsMain.cpp @@ -1524,10 +1524,10 @@ extern V8Module altModule("alt", V8Helpers::RegisterFunc(exports, "getPoolCount", &GetPoolCount); V8Helpers::RegisterFunc(exports, "getPoolEntities", &GetPoolEntities); + // Voice related functions V8Helpers::RegisterFunc(exports, "getVoicePlayers", &GetVoicePlayers); V8Helpers::RegisterFunc(exports, "removeVoicePlayer", &RemoveVoicePlayer); - // Voice related functions V8Helpers::RegisterFunc(exports, "getVoiceSpatialVolume", &GetVoiceSpatialVolume); V8Helpers::RegisterFunc(exports, "setVoiceSpatialVolume", &SetVoiceSpatialVolume); From 979748b4db33737c9cdd794d237501e48422a529 Mon Sep 17 00:00:00 2001 From: lackos888 <29657187+lackos888@users.noreply.github.com> Date: Thu, 28 Dec 2023 15:33:58 +0100 Subject: [PATCH 05/14] =?UTF-8?q?fix=20object=20missing=20getByID=20getter?= =?UTF-8?q?=20+=20fix=20object=20and=20ped=20removeEntity=20e=E2=80=A6=20(?= =?UTF-8?q?#309)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/bindings/Object.cpp | 20 ++++++++++++++++++++ shared/V8ResourceImpl.cpp | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/server/src/bindings/Object.cpp b/server/src/bindings/Object.cpp index 858d487d..8019606b 100644 --- a/server/src/bindings/Object.cpp +++ b/server/src/bindings/Object.cpp @@ -66,6 +66,25 @@ static void CountGetter(v8::Local name, const v8::PropertyCallbackIn V8_RETURN_UINT(alt::ICore::Instance().GetBaseObjects(alt::IBaseObject::Type::OBJECT).size()); } +static void StaticGetByID(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT_RESOURCE(); + V8_CHECK_ARGS_LEN(1); + + V8_ARG_TO_INT(1, id); + + alt::IBaseObject* entity = alt::ICore::Instance().GetBaseObjectByID(alt::IBaseObject::Type::OBJECT, id); + + if(entity) + { + V8_RETURN_BASE_OBJECT(entity); + } + else + { + V8_RETURN_NULL(); + } +} + // clang-format off extern V8Class v8Entity; extern V8Class v8Object("Object", v8Entity, Constructor, [](v8::Local tpl) @@ -74,6 +93,7 @@ extern V8Class v8Object("Object", v8Entity, Constructor, [](v8::Local(isolate, tpl, "activatePhysics"); V8Helpers::SetMethod(isolate, tpl, "placeOnGroundProperly"); diff --git a/shared/V8ResourceImpl.cpp b/shared/V8ResourceImpl.cpp index a47d58ee..00cf7b82 100644 --- a/shared/V8ResourceImpl.cpp +++ b/shared/V8ResourceImpl.cpp @@ -277,7 +277,7 @@ void V8ResourceImpl::OnRemoveBaseObject(alt::IBaseObject* handle) if(!ent) return; auto entityType = handle->GetType(); - if(entityType == alt::IBaseObject::Type::PLAYER || entityType == alt::IBaseObject::Type::LOCAL_PLAYER || entityType == alt::IBaseObject::Type::VEHICLE) + if(entityType == alt::IBaseObject::Type::PLAYER || entityType == alt::IBaseObject::Type::LOCAL_PLAYER || entityType == alt::IBaseObject::Type::VEHICLE || entityType == alt::IBaseObject::Type::PED || entityType == alt::IBaseObject::Type::OBJECT) { std::vector handlers = GetLocalHandlers("removeEntity"); std::vector> args{ ent->GetJSVal(isolate) }; From 933f76ccaa47e50655f935ed3bc22787806331cc Mon Sep 17 00:00:00 2001 From: Vadim Zubkov Date: Thu, 28 Dec 2023 18:14:13 +0300 Subject: [PATCH 06/14] fix(client): missing arg --- client/src/bindings/ClientBindingsMain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/bindings/ClientBindingsMain.cpp b/client/src/bindings/ClientBindingsMain.cpp index d3a8f475..2a07e41b 100644 --- a/client/src/bindings/ClientBindingsMain.cpp +++ b/client/src/bindings/ClientBindingsMain.cpp @@ -1307,7 +1307,7 @@ static void AddVoiceFilter(const v8::FunctionCallbackInfo& info) V8_CHECK_ARGS_LEN(2); V8_ARG_TO_INT(1, playerId); - V8_ARG_TO_BASE_OBJECT(2, filter, alt::IAudioFilter); + V8_ARG_TO_BASE_OBJECT(2, filter, alt::IAudioFilter, "AudioFilter"); alt::ICore::Instance().AddVoiceFilter(playerId, filter); } From 7b6f1922c96a137b5d4cc5821120567b8ce520bc Mon Sep 17 00:00:00 2001 From: Vadim Zubkov Date: Thu, 28 Dec 2023 20:00:32 +0300 Subject: [PATCH 07/14] feat(server): minor version in events --- server/src/bindings/ConnectionInfo.cpp | 20 +++++++++++++++++++- server/src/events/Player.cpp | 3 ++- shared/deps/cpp-sdk | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/server/src/bindings/ConnectionInfo.cpp b/server/src/bindings/ConnectionInfo.cpp index 81938659..4e178cee 100644 --- a/server/src/bindings/ConnectionInfo.cpp +++ b/server/src/bindings/ConnectionInfo.cpp @@ -55,10 +55,26 @@ static void BranchGetter(v8::Local, const v8::PropertyCallbackInfo, const v8::PropertyCallbackInfo& info) +{ + V8_DEPRECATE("ConnectionInfo build", "versionMajor & versionMinor"); + + V8_GET_ISOLATE_CONTEXT_RESOURCE(); + V8_GET_THIS_BASE_OBJECT(con, alt::IConnectionInfo); + V8_RETURN_UINT(con->GetVersionMajor()); +} + +static void VersionMajorGetter(v8::Local, const v8::PropertyCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT_RESOURCE(); + V8_GET_THIS_BASE_OBJECT(con, alt::IConnectionInfo); + V8_RETURN_UINT(con->GetVersionMajor()); +} + +static void VersionMinorGetter(v8::Local, const v8::PropertyCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT_RESOURCE(); V8_GET_THIS_BASE_OBJECT(con, alt::IConnectionInfo); - V8_RETURN_UINT(con->GetBuild()); + V8_RETURN_UINT(con->GetVersionMinor()); } static void CdnUrlGetter(v8::Local, const v8::PropertyCallbackInfo& info) @@ -216,6 +232,8 @@ extern V8Class v8ConnectionInfo("ConnectionInfo", V8Helpers::SetAccessor(isolate, tpl, "isDebug", &IsDebugGetter); V8Helpers::SetAccessor(isolate, tpl, "branch", &BranchGetter); V8Helpers::SetAccessor(isolate, tpl, "build", &BuildGetter); + V8Helpers::SetAccessor(isolate, tpl, "versionMajor", &VersionMajorGetter); + V8Helpers::SetAccessor(isolate, tpl, "versionMinor", &VersionMinorGetter); V8Helpers::SetAccessor(isolate, tpl, "cdnUrl", &CdnUrlGetter); V8Helpers::SetAccessor(isolate, tpl, "passwordHash", &PasswordHashGetter); V8Helpers::SetAccessor(isolate, tpl, "ip", &IpGetter); diff --git a/server/src/events/Player.cpp b/server/src/events/Player.cpp index e1af453f..50086dbf 100644 --- a/server/src/events/Player.cpp +++ b/server/src/events/Player.cpp @@ -44,7 +44,8 @@ V8Helpers::LocalEventHandler playerConnectDenied(EventType::PLAYER_CONNECT_DENIE args.push_back(V8Helpers::JSValue(ev->GetPasswordHash())); args.push_back(V8Helpers::JSValue(ev->IsDebug())); args.push_back(V8Helpers::JSValue(ev->GetBranch())); - args.push_back(V8Helpers::JSValue(ev->GetMajorVersion())); + args.push_back(V8Helpers::JSValue(ev->GetVersionMajor())); + // TODO: no idea where to put version minor to not break backward compatibility, not sure it's needed at all args.push_back(V8Helpers::JSValue(ev->GetCdnUrl())); args.push_back(V8Helpers::JSValue(ev->GetDiscordId())); }); diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index e45d0588..36517cfa 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit e45d05882e7af0ea8cf2865ddd148914cb187af1 +Subproject commit 36517cfae5a9662c56981844dcd052b6f299294d From 5805a9128dddcd6f094e788cf5829602b1a75f4a Mon Sep 17 00:00:00 2001 From: Vadim Zubkov Date: Thu, 28 Dec 2023 20:12:15 +0300 Subject: [PATCH 08/14] chore(ci): update tag wildcards --- .github/workflows/build-deploy.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index b0bd1769..771a7faf 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -4,9 +4,9 @@ on: branches-ignore: - '**' tags: - - 'dev/*.*-dev*' - - 'rc/*.*-rc*' - - 'release/*.*' + - 'dev/*.*.*-dev.*' + - 'rc/*.*.*-rc.*' + - 'release/*.*.*' jobs: build-windows: From f02660a910fe9969a12e2c6cadf20da4f67386ee Mon Sep 17 00:00:00 2001 From: xLuxy <67131061+xLuxy@users.noreply.github.com> Date: Fri, 29 Dec 2023 06:29:57 +0100 Subject: [PATCH 09/14] feat(server): Add Vehicle.setBadge --- server/src/bindings/Vehicle.cpp | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/server/src/bindings/Vehicle.cpp b/server/src/bindings/Vehicle.cpp index 8c747eb6..71c9e1b0 100644 --- a/server/src/bindings/Vehicle.cpp +++ b/server/src/bindings/Vehicle.cpp @@ -252,6 +252,61 @@ static void GetPassengers(v8::Local, const v8::PropertyCallbackInfo< V8_RETURN(obj); } +static void SetBadge(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_CHECK_ARGS_LEN_MIN_MAX(3, 6); + V8_GET_THIS_BASE_OBJECT(_this, IVehicle); + + uint32_t textureDictionary; + if (info[0]->IsString()) + { + V8_ARG_TO_STRING(1, textureDictionaryName); + textureDictionary = alt::ICore::Instance().Hash(textureDictionaryName); + } + else + { + V8_ARG_TO_UINT(1, _textureDictionary); + textureDictionary = _textureDictionary; + } + + uint32_t texture; + if (info[1]->IsString()) + { + V8_ARG_TO_STRING(2, textureName); + texture = alt::ICore::Instance().Hash(textureName); + } + else + { + V8_ARG_TO_UINT(2, _texture); + texture = _texture; + } + + alt::VehicleBadgePosition positions[4]; + for (int i = 0; i < 4; i++) + { + if (!info[i + 2]->IsObject()) break; + + V8_ARG_TO_OBJECT(i + 3, dict); + + if (dict.IsEmpty()) break; + + V8_TO_BOOLEAN(V8Helpers::Get(ctx, dict, "active"), active); + V8_TO_NUMBER(V8Helpers::Get(ctx, dict, "size"), size); + V8_TO_INT32(V8Helpers::Get(ctx, dict, "boneIndex"), boneIndex); + V8_TO_INT32(V8Helpers::Get(ctx, dict, "alpha"), alpha); + + V8_TO_VECTOR3(V8Helpers::Get(ctx, dict, "offset"), offset); + V8_TO_VECTOR3(V8Helpers::Get(ctx, dict, "direction"), direction); + V8_TO_VECTOR3(V8Helpers::Get(ctx, dict, "side"), side); + + positions[i] = alt::VehicleBadgePosition((uint8_t)alpha, (float)size, (int16_t)boneIndex, offset, direction, side); + positions[i].active = active; + } + + _this->SetBadge(textureDictionary, texture, positions); +} + extern V8Class v8Entity; extern V8Class v8Vehicle("Vehicle", v8Entity, @@ -439,4 +494,5 @@ extern V8Class v8Vehicle("Vehicle", V8Helpers::SetMethod(isolate, tpl, "setWeaponCapacity", &SetWeaponCapacity); V8Helpers::SetAccessor(isolate, tpl, "hybridExtraActive"); V8Helpers::SetAccessor(isolate, tpl, "hybridExtraState"); + V8Helpers::SetMethod(isolate, tpl, "setBadge", &SetBadge); }); From c73c1a780669dc576631be9bb595844bc8537421 Mon Sep 17 00:00:00 2001 From: Vadim Zubkov Date: Sat, 30 Dec 2023 00:57:13 +0300 Subject: [PATCH 10/14] fix(shared): SourceLocation::ToString --- shared/V8Helpers.cpp | 11 ++++++----- shared/V8Helpers.h | 2 +- shared/V8ResourceImpl.h | 2 +- shared/helpers/Macros.h | 2 +- shared/helpers/Serialization.cpp | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/shared/V8Helpers.cpp b/shared/V8Helpers.cpp index 52a2e655..a4014d16 100644 --- a/shared/V8Helpers.cpp +++ b/shared/V8Helpers.cpp @@ -189,17 +189,18 @@ V8Helpers::SourceLocation::SourceLocation(std::string&& _fileName, int _line, v8 context.Reset(ctx->GetIsolate(), ctx); } -std::string V8Helpers::SourceLocation::ToString() +std::string V8Helpers::SourceLocation::ToString(v8::Isolate* isolate) { - auto isolate = v8::Isolate::GetCurrent(); - std::stringstream stream; stream << "["; + // Check if not inside a worker - if(!(*static_cast(isolate->GetData(v8::Isolate::GetNumberOfDataSlots() - 1)))) + bool* isWorker = static_cast(isolate->GetData(v8::Isolate::GetNumberOfDataSlots() - 1)); + if (!isWorker || !(*isWorker)) { - stream << V8ResourceImpl::Get(context.Get(v8::Isolate::GetCurrent()))->GetResource()->GetName() << ":"; + stream << V8ResourceImpl::Get(context.Get(isolate))->GetResource()->GetName() << ":"; } + stream << fileName << ":" << line << "]"; return stream.str(); } diff --git a/shared/V8Helpers.h b/shared/V8Helpers.h index eb1498c5..4c835c62 100644 --- a/shared/V8Helpers.h +++ b/shared/V8Helpers.h @@ -59,7 +59,7 @@ namespace V8Helpers return line; } - std::string ToString(); + std::string ToString(v8::Isolate* isolate); static SourceLocation GetCurrent(v8::Isolate* isolate, V8ResourceImpl* resource = nullptr); diff --git a/shared/V8ResourceImpl.h b/shared/V8ResourceImpl.h index 400d8ace..61657a7b 100644 --- a/shared/V8ResourceImpl.h +++ b/shared/V8ResourceImpl.h @@ -86,7 +86,7 @@ class V8ResourceImpl : public alt::IResource::Impl if(!anyHandlerRemoved) { - Log::Warning << location.ToString() << " alt.off was called for event \"" << ev << "\" with function reference that was not subscribed" << Log::Endl; + Log::Warning << location.ToString(isolate) << " alt.off was called for event \"" << ev << "\" with function reference that was not subscribed" << Log::Endl; return; } diff --git a/shared/helpers/Macros.h b/shared/helpers/Macros.h index b5517b92..f21cac6f 100644 --- a/shared/helpers/Macros.h +++ b/shared/helpers/Macros.h @@ -377,6 +377,6 @@ { \ V8_GET_ISOLATE(); \ V8_GET_RESOURCE(); \ - Log::Warning << V8Helpers::SourceLocation::GetCurrent(isolate, resource).ToString() << " " << oldName << " is deprecated and will be removed in future versions. Consider using " \ + Log::Warning << V8Helpers::SourceLocation::GetCurrent(isolate, resource).ToString(isolate) << " " << oldName << " is deprecated and will be removed in future versions. Consider using " \ << newName << " instead" << Log::Endl; \ } diff --git a/shared/helpers/Serialization.cpp b/shared/helpers/Serialization.cpp index eee5289e..dabce201 100644 --- a/shared/helpers/Serialization.cpp +++ b/shared/helpers/Serialization.cpp @@ -56,7 +56,7 @@ alt::MValue V8Helpers::V8ToMValue(v8::Local val, bool allowFunction) { if(!allowFunction) { - Log::Error << V8Helpers::SourceLocation::GetCurrent(isolate).ToString() << " " + Log::Error << V8Helpers::SourceLocation::GetCurrent(isolate).ToString(isolate) << " " << "Cannot convert function to MValue" << Log::Endl; return core.CreateMValueNone(); } From 2bf91fd74748806246363b4b72c2cf6c9e8ea8ea Mon Sep 17 00:00:00 2001 From: xLuxy <67131061+xLuxy@users.noreply.github.com> Date: Sat, 30 Dec 2023 11:02:29 +0100 Subject: [PATCH 11/14] fix(client): Fix client build --- client/src/bindings/V8Natives.cpp | 4 ++-- client/src/workers/CWorker.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/src/bindings/V8Natives.cpp b/client/src/bindings/V8Natives.cpp index eb539bac..a2d7b888 100644 --- a/client/src/bindings/V8Natives.cpp +++ b/client/src/bindings/V8Natives.cpp @@ -92,7 +92,7 @@ inline void ShowNativeArgParseErrorMsg(V8ResourceImpl* resource, v8::LocalGetName() << ")"; - Log::Error << source.ToString() << " " << errorMsg.str() << Log::Endl; + Log::Error << source.ToString(isolate) << " " << errorMsg.str() << Log::Endl; Log::Error << "Check the documentation for the needed arguments of this native." << Log::Endl; resource->DispatchErrorEvent(errorMsg.str(), source.GetFileName(), source.GetLineNumber(), V8Helpers::GetStackTrace(errorMsg.str())); @@ -109,7 +109,7 @@ inline void ShowNativeArgMismatchErrorMsg(V8ResourceImpl* resource, alt::INative std::stringstream errorMsg; errorMsg << "Native argument size mismatch. Expected: " << expected << ", Received: " << received << " (" << native->GetName() << ")"; - Log::Error << source.ToString() << " " << errorMsg.str() << Log::Endl; + Log::Error << source.ToString(isolate) << " " << errorMsg.str() << Log::Endl; Log::Error << "Check the documentation for the needed arguments of this native." << Log::Endl; resource->DispatchErrorEvent(errorMsg.str(), source.GetFileName(), source.GetLineNumber(), V8Helpers::GetStackTrace(errorMsg.str())); diff --git a/client/src/workers/CWorker.cpp b/client/src/workers/CWorker.cpp index f5abb6d7..2c76b9db 100644 --- a/client/src/workers/CWorker.cpp +++ b/client/src/workers/CWorker.cpp @@ -135,14 +135,14 @@ void CWorker::SetupIsolate() case v8::kPromiseRejectAfterResolved: { std::ostringstream stream; - stream << location.ToString() << " Promise rejected after being resolved (" << *v8::String::Utf8Value(isolate, value->ToString(ctx).ToLocalChecked()) << ")"; + stream << location.ToString(isolate) << " Promise rejected after being resolved (" << *v8::String::Utf8Value(isolate, value->ToString(ctx).ToLocalChecked()) << ")"; worker->EmitError(stream.str()); break; } case v8::kPromiseResolveAfterResolved: { std::ostringstream stream; - stream << location.ToString() << " Promise resolved after being resolved (" << *v8::String::Utf8Value(isolate, value->ToString(ctx).ToLocalChecked()) << ")"; + stream << location.ToString(isolate) << " Promise resolved after being resolved (" << *v8::String::Utf8Value(isolate, value->ToString(ctx).ToLocalChecked()) << ")"; worker->EmitError(stream.str()); break; } From c2a6b4025bbb9b9850bcfac1e92a7ae0d2f2bc32 Mon Sep 17 00:00:00 2001 From: Vektor Date: Tue, 2 Jan 2024 19:08:36 +0100 Subject: [PATCH 12/14] chore: Update cpp-sdk --- shared/deps/cpp-sdk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index 36517cfa..d6d7c8a7 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit 36517cfae5a9662c56981844dcd052b6f299294d +Subproject commit d6d7c8a78d3298690e6ef3138853e6d864d90732 From da0042ac75b9122fa883f93980a8d5114bc50ac6 Mon Sep 17 00:00:00 2001 From: xLuxy <67131061+xLuxy@users.noreply.github.com> Date: Tue, 2 Jan 2024 20:45:44 +0100 Subject: [PATCH 13/14] feat(client): Add `alt.updateClipContext` --- client/src/bindings/ClientBindingsMain.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/client/src/bindings/ClientBindingsMain.cpp b/client/src/bindings/ClientBindingsMain.cpp index 2a07e41b..163ce2c7 100644 --- a/client/src/bindings/ClientBindingsMain.cpp +++ b/client/src/bindings/ClientBindingsMain.cpp @@ -1332,6 +1332,23 @@ static void GetVoiceFilter(const v8::FunctionCallbackInfo& info) V8_RETURN_BASE_OBJECT(alt::ICore::Instance().GetVoiceFilter(playerId)); } +static void UpdateClipContext(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_CHECK_ARGS_LEN(1); + V8_CHECK(!info[0]->IsNullOrUndefined() && info[0]->IsObject(), "Argument 1 must be an object"); + + auto dict = V8Helpers::CppValue>(info[0].As()); + std::unordered_map context; + + if(dict.has_value()) + { + for(auto& [key, value] : dict.value()) V8Helpers::SafeToString(value, isolate, ctx, context[key]); + } + + alt::ICore::Instance().UpdateClipContext(context); +} + extern V8Module sharedModule; extern V8Class v8Player, v8Player, v8Vehicle, v8WebView, v8HandlingData, v8LocalStorage, v8MemoryBuffer, v8MapZoomData, v8Discord, v8Voice, v8WebSocketClient, v8Checkpoint, v8HttpClient, v8Audio, v8LocalPlayer, v8Profiler, v8Worker, v8RmlDocument, v8RmlElement, v8WeaponData, v8FocusData, v8LocalObject, v8TextEncoder, v8TextDecoder, v8Object, v8VirtualEntityGroup, @@ -1537,4 +1554,5 @@ extern V8Module altModule("alt", V8Helpers::RegisterFunc(exports, "addVoiceFilter", &AddVoiceFilter); V8Helpers::RegisterFunc(exports, "removeVoiceFilter", &RemoveVoiceFilter); V8Helpers::RegisterFunc(exports, "getVoiceFilter", &GetVoiceFilter); + V8Helpers::RegisterFunc(exports, "updateClipContext", &UpdateClipContext); }); From 4dcc6dee8a162882a421ac749081a5a824b4ef3a Mon Sep 17 00:00:00 2001 From: Till Schreiber Date: Wed, 3 Jan 2024 00:27:02 +0100 Subject: [PATCH 14/14] feat(shared): add count to decoration (#311) --- server/src/bindings/Player.cpp | 1 + shared/deps/cpp-sdk | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/bindings/Player.cpp b/server/src/bindings/Player.cpp index 9148daff..653105c0 100644 --- a/server/src/bindings/Player.cpp +++ b/server/src/bindings/Player.cpp @@ -1420,6 +1420,7 @@ static void GetDecorations(const v8::FunctionCallbackInfo& info) V8_NEW_OBJECT(decorationsObj); V8_OBJECT_SET_UINT(decorationsObj, "collection", decoration.collection); V8_OBJECT_SET_UINT(decorationsObj, "overlay", decoration.overlay); + V8_OBJECT_SET_INT(decorationsObj, "count", decoration.count); decorationsArr->Set(ctx, i, decorationsObj); } diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index d6d7c8a7..2fe9645d 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit d6d7c8a78d3298690e6ef3138853e6d864d90732 +Subproject commit 2fe9645da8d1cf8db2867cc76f189ff3c57faf89