Skip to content

Commit

Permalink
Interior API additions (#332)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
xxshady authored Nov 16, 2024
1 parent 6492b15 commit 8bb66e7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 8 additions & 0 deletions client/src/bindings/Interior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ static void GetPortalByIndex(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_RETURN(v8InteriorPortal.New(isolate->GetEnteredOrMicrotaskContext(), args));
}

static void IdGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT();
V8_GET_THIS_INTERNAL_FIELD_UINT32(1, interiorId);
V8_RETURN_UINT(interiorId);
}

extern V8Class v8Interior("Interior",
Constructor,
[](v8::Local<v8::FunctionTemplate> tpl)
Expand All @@ -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);
});
10 changes: 5 additions & 5 deletions client/src/bindings/InteriorPortal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
static void Constructor(const v8::FunctionCallbackInfo<v8::Value>& 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<alt::IInterior> interior = alt::ICore::Instance().GetInterior(interiorId);
V8_CHECK(interior, "interior doesn't exist")
V8_CHECK(interior, "interior doesn't exist");

std::shared_ptr<alt::IInteriorPortal> portal = interior->GetPortalByIndex(portalIndex);
V8_CHECK(portal, "interior portal doesn't exist");
Expand Down
1 change: 0 additions & 1 deletion client/src/bindings/InteriorRoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ static void Constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
if(isIndex)
{
room = interior->GetRoomByIndex(value);
V8_CHECK(room, "interior room doesn't exist");
}
else
{
Expand Down

0 comments on commit 8bb66e7

Please sign in to comment.