Skip to content

Commit

Permalink
Merge dev to rc (#58)
Browse files Browse the repository at this point in the history
* Fix possible crash in emitClient with player array

* Update helpers

* Update helpers

* Update helpers

* Add player.setIntoVehicle

Former-commit-id: 55f9169
  • Loading branch information
LeonMrBonnie authored Sep 10, 2021
1 parent b92d51d commit 53f04e6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/bindings/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ static void EmitClient(const v8::FunctionCallbackInfo<v8::Value>& info)
for (int i = 0; i < arr->Length(); ++i)
{
Ref<IPlayer> player;
V8Entity* v8Player = V8Entity::Get(arr->Get(ctx, i).ToLocalChecked());
v8::Local<v8::Value> 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<IPlayer>());
Expand Down
14 changes: 14 additions & 0 deletions src/bindings/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,18 @@ static void IsEntityInStreamRange(const v8::FunctionCallbackInfo<v8::Value>& inf
V8_RETURN_BOOLEAN(player->IsEntityInStreamingRange(entity));
}

static void SetIntoVehicle(const v8::FunctionCallbackInfo<v8::Value>& 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<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
Expand Down Expand Up @@ -470,4 +482,6 @@ extern V8Class v8Player("Player", v8Entity, nullptr, [](v8::Local<v8::FunctionTe
V8::SetMethod(isolate, tpl, "getProp", &GetProps);
V8::SetMethod(isolate, tpl, "getDlcProp", &GetDlcProps);
V8::SetMethod(isolate, tpl, "clearProp", &ClearProps);

V8::SetMethod(isolate, tpl, "setIntoVehicle", &SetIntoVehicle);
});
2 changes: 1 addition & 1 deletion src/cpp-sdk
2 changes: 1 addition & 1 deletion src/helpers

0 comments on commit 53f04e6

Please sign in to comment.