From 8bb66e74b0918d89d465e4ca15f3be63e77126a8 Mon Sep 17 00:00:00 2001 From: xshady <54737754+xxshady@users.noreply.github.com> Date: Sat, 16 Nov 2024 22:31:04 +0300 Subject: [PATCH 1/3] Interior API additions (#332) * chore(client): remove unneeded check it's checked after `if` anyway * feat(client): add Interior id getter * fix(client): InteriorPortal constructor * fix(client): typo * fix(client): id getter --- client/src/bindings/Interior.cpp | 8 ++++++++ client/src/bindings/InteriorPortal.cpp | 10 +++++----- client/src/bindings/InteriorRoom.cpp | 1 - 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/client/src/bindings/Interior.cpp b/client/src/bindings/Interior.cpp index 08c1f8b1..051b9fc4 100644 --- a/client/src/bindings/Interior.cpp +++ b/client/src/bindings/Interior.cpp @@ -138,6 +138,13 @@ static void GetPortalByIndex(const v8::FunctionCallbackInfo& info) V8_RETURN(v8InteriorPortal.New(isolate->GetEnteredOrMicrotaskContext(), args)); } +static void IdGetter(v8::Local, const v8::PropertyCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_INTERNAL_FIELD_UINT32(1, interiorId); + V8_RETURN_UINT(interiorId); +} + extern V8Class v8Interior("Interior", Constructor, [](v8::Local tpl) @@ -155,6 +162,7 @@ extern V8Class v8Interior("Interior", V8Helpers::SetAccessor(isolate, tpl, "pos", &PositionGetter); V8Helpers::SetAccessor(isolate, tpl, "rot", &RotationGetter); V8Helpers::SetAccessor(isolate, tpl, "entitiesExtents", &EntitiesExtentsGetter); + V8Helpers::SetAccessor(isolate, tpl, "id", &IdGetter); V8Helpers::SetStaticMethod(isolate, tpl, "getForInteriorID", &GetForInteriorID); }); diff --git a/client/src/bindings/InteriorPortal.cpp b/client/src/bindings/InteriorPortal.cpp index 0bb929b5..58c62cbb 100644 --- a/client/src/bindings/InteriorPortal.cpp +++ b/client/src/bindings/InteriorPortal.cpp @@ -5,14 +5,14 @@ static void Constructor(const v8::FunctionCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT(); - V8_CHECK_CONSTRUCTOR() + V8_CHECK_CONSTRUCTOR(); - V8_CHECK_ARGS_LEN(3) - V8_ARG_TO_UINT(1, interiorId) - V8_ARG_TO_UINT(2, portalIndex) + V8_CHECK_ARGS_LEN(2); + V8_ARG_TO_UINT(1, interiorId); + V8_ARG_TO_UINT(2, portalIndex); std::shared_ptr interior = alt::ICore::Instance().GetInterior(interiorId); - V8_CHECK(interior, "interior doesn't exist") + V8_CHECK(interior, "interior doesn't exist"); std::shared_ptr portal = interior->GetPortalByIndex(portalIndex); V8_CHECK(portal, "interior portal doesn't exist"); diff --git a/client/src/bindings/InteriorRoom.cpp b/client/src/bindings/InteriorRoom.cpp index ef19a595..c5bd1644 100644 --- a/client/src/bindings/InteriorRoom.cpp +++ b/client/src/bindings/InteriorRoom.cpp @@ -19,7 +19,6 @@ static void Constructor(const v8::FunctionCallbackInfo& info) if(isIndex) { room = interior->GetRoomByIndex(value); - V8_CHECK(room, "interior room doesn't exist"); } else { From 48c4f7181dd19160f37ec9aa1eb7fb77697d7029 Mon Sep 17 00:00:00 2001 From: xshady <54737754+xxshady@users.noreply.github.com> Date: Sun, 17 Nov 2024 13:39:33 +0300 Subject: [PATCH 2/3] feat(client): add InteriorPortal entityCount (#333) --- client/src/bindings/InteriorPortal.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/src/bindings/InteriorPortal.cpp b/client/src/bindings/InteriorPortal.cpp index 58c62cbb..a461f209 100644 --- a/client/src/bindings/InteriorPortal.cpp +++ b/client/src/bindings/InteriorPortal.cpp @@ -141,6 +141,13 @@ static void GetCornerPos(const v8::FunctionCallbackInfo& info) } +static void EntityCountGetter(v8::Local, const v8::PropertyCallbackInfo& info) +{ + GET_THIS_INTERIOR_PORTAL(portal); + + V8_RETURN_UINT(portal->GetEntityCount()); +} + static void SetCornerPos(const v8::FunctionCallbackInfo& info) { GET_THIS_INTERIOR_PORTAL(portal); @@ -165,6 +172,7 @@ extern V8Class v8InteriorPortal("InteriorPortal", V8Helpers::SetAccessor(isolate, tpl, "roomFrom", &RoomFromGetter, &RoomFromSetter); V8Helpers::SetAccessor(isolate, tpl, "roomTo", &RoomToGetter, &RoomToSetter); V8Helpers::SetAccessor(isolate, tpl, "flag", &FlagGetter, &FlagSetter); + V8Helpers::SetAccessor(isolate, tpl, "entityCount", &EntityCountGetter); V8Helpers::SetMethod(isolate, tpl, "getCornerPos", &GetCornerPos); V8Helpers::SetMethod(isolate, tpl, "getEntityArchetype", &GetEntityArchetype); From bac7246dc6543170ceab5ef38126b3af7155e63c Mon Sep 17 00:00:00 2001 From: Till Schreiber Date: Tue, 19 Nov 2024 12:37:24 +0100 Subject: [PATCH 3/3] ALTV-520 - update 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 e2966f42..f18e52bb 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit e2966f42c4509f6a6836c18b9766c26ef23a87af +Subproject commit f18e52bbb7fd9cc57efa66f6c40449b41cdc13a0