From 53f04e6de8483234f2cebd19e9c97a3e741c1126 Mon Sep 17 00:00:00 2001 From: Leon B Date: Fri, 10 Sep 2021 20:58:14 +0200 Subject: [PATCH] Merge dev to rc (#58) * Fix possible crash in emitClient with player array * Update helpers * Update helpers * Update helpers * Add player.setIntoVehicle Former-commit-id: 55f9169af75abd764c85577d7205488bf8f4b375 --- src/bindings/Main.cpp | 4 +++- src/bindings/Player.cpp | 14 ++++++++++++++ src/cpp-sdk | 2 +- src/helpers | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/bindings/Main.cpp b/src/bindings/Main.cpp index e929c183..380e8495 100644 --- a/src/bindings/Main.cpp +++ b/src/bindings/Main.cpp @@ -94,7 +94,9 @@ static void EmitClient(const v8::FunctionCallbackInfo& info) for (int i = 0; i < arr->Length(); ++i) { Ref player; - V8Entity* v8Player = V8Entity::Get(arr->Get(ctx, i).ToLocalChecked()); + v8::Local ply; + V8_CHECK(arr->Get(ctx, i).ToLocal(&ply), "Invalid player in emitClient players array"); + V8Entity* v8Player = V8Entity::Get(ply); V8_CHECK(v8Player && v8Player->GetHandle()->GetType() == alt::IBaseObject::Type::PLAYER, "player inside array expected"); targets.Push(v8Player->GetHandle().As()); diff --git a/src/bindings/Player.cpp b/src/bindings/Player.cpp index 27f01895..1a074214 100644 --- a/src/bindings/Player.cpp +++ b/src/bindings/Player.cpp @@ -369,6 +369,18 @@ static void IsEntityInStreamRange(const v8::FunctionCallbackInfo& inf V8_RETURN_BOOLEAN(player->IsEntityInStreamingRange(entity)); } +static void SetIntoVehicle(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_CHECK_ARGS_LEN(2); + V8_GET_THIS_BASE_OBJECT(player, IPlayer); + + V8_ARG_TO_BASE_OBJECT(1, vehicle, alt::IVehicle, "Vehicle"); + V8_ARG_TO_UINT32(2, seat); + + player->SetIntoVehicle(vehicle, seat); +} + static void AllGetter(v8::Local name, const v8::PropertyCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); @@ -470,4 +482,6 @@ extern V8Class v8Player("Player", v8Entity, nullptr, [](v8::Local