From 616b35681cd5fde6d7602c82c0617eb911fcc218 Mon Sep 17 00:00:00 2001 From: xLuxy <67131061+xLuxy@users.noreply.github.com> Date: Sun, 3 Sep 2023 23:43:39 +0200 Subject: [PATCH 1/5] shared: Add missing VirtualEntity.getByID and VirtualEntity.getByRemoteID static methods --- shared/bindings/VirtualEntity.cpp | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/shared/bindings/VirtualEntity.cpp b/shared/bindings/VirtualEntity.cpp index 349c18a1..ca163cf4 100644 --- a/shared/bindings/VirtualEntity.cpp +++ b/shared/bindings/VirtualEntity.cpp @@ -35,6 +35,42 @@ static void Constructor(const v8::FunctionCallbackInfo& info) V8_BIND_BASE_OBJECT(virtualEntity, "Failed to create virtual entity"); } +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::VIRTUAL_ENTITY, id); + + if(entity) + { + V8_RETURN_BASE_OBJECT(entity); + return; + } + + V8_RETURN_NULL(); +} + +static void StaticGetByRemoteId(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT_RESOURCE(); + V8_CHECK_ARGS_LEN(1); + + V8_ARG_TO_INT32(1, id); + + alt::IBaseObject* entity = alt::ICore::Instance().GetBaseObjectByRemoteID(alt::IBaseObject::Type::VIRTUAL_ENTITY, id); + + if(entity) + { + V8_RETURN_BASE_OBJECT(entity); + return; + } + + V8_RETURN_NULL(); +} + static void AllGetter(v8::Local name, const v8::PropertyCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT_RESOURCE(); @@ -197,6 +233,9 @@ extern V8Class v8VirtualEntity("VirtualEntity", { v8::Isolate* isolate = v8::Isolate::GetCurrent(); + V8Helpers::SetStaticMethod(isolate, tpl, "getByID", StaticGetByID); + V8Helpers::SetStaticMethod(isolate, tpl, "getByRemoteID", StaticGetByRemoteId); + V8Helpers::SetStaticAccessor(isolate, tpl, "all", AllGetter); V8Helpers::SetAccessor(isolate, tpl, "group"); From c8a03ee8c69b7caf2c9394c62c15a25f35841728 Mon Sep 17 00:00:00 2001 From: xLuxy <67131061+xLuxy@users.noreply.github.com> Date: Mon, 4 Sep 2023 00:01:16 +0200 Subject: [PATCH 2/5] Add VirtualEntityGroup.getByID static methods --- shared/bindings/VirtualEntityGroup.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/shared/bindings/VirtualEntityGroup.cpp b/shared/bindings/VirtualEntityGroup.cpp index 3151abbc..76eb3fab 100644 --- a/shared/bindings/VirtualEntityGroup.cpp +++ b/shared/bindings/VirtualEntityGroup.cpp @@ -17,6 +17,24 @@ static void Constructor(const v8::FunctionCallbackInfo& info) V8_BIND_BASE_OBJECT(virtualEntityGroup, "Failed to create virtual entity group"); } +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::VIRTUAL_ENTITY_GROUP, id); + + if(entity) + { + V8_RETURN_BASE_OBJECT(entity); + return; + } + + V8_RETURN_NULL(); +} + static void AllGetter(v8::Local name, const v8::PropertyCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT_RESOURCE(); @@ -97,6 +115,8 @@ extern V8Class v8VirtualEntityGroup("VirtualEntityGroup", { v8::Isolate* isolate = v8::Isolate::GetCurrent(); + V8Helpers::SetStaticMethod(isolate, tpl, "getByID", StaticGetByID); + V8Helpers::SetStaticAccessor(isolate, tpl, "all", AllGetter); V8Helpers::SetMethod(isolate, tpl, "hasMeta", HasMeta); From f3d4815c03f94e4617f62bd9bf25abf95c35d593 Mon Sep 17 00:00:00 2001 From: xLuxy <67131061+xLuxy@users.noreply.github.com> Date: Mon, 4 Sep 2023 00:02:38 +0200 Subject: [PATCH 3/5] server: Fix build --- shared/bindings/VirtualEntity.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shared/bindings/VirtualEntity.cpp b/shared/bindings/VirtualEntity.cpp index ca163cf4..13bddc20 100644 --- a/shared/bindings/VirtualEntity.cpp +++ b/shared/bindings/VirtualEntity.cpp @@ -53,6 +53,8 @@ static void StaticGetByID(const v8::FunctionCallbackInfo& info) V8_RETURN_NULL(); } +#ifdef ALT_CLIENT_API + static void StaticGetByRemoteId(const v8::FunctionCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT_RESOURCE(); @@ -71,6 +73,8 @@ static void StaticGetByRemoteId(const v8::FunctionCallbackInfo& info) V8_RETURN_NULL(); } +#endif + static void AllGetter(v8::Local name, const v8::PropertyCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT_RESOURCE(); @@ -234,7 +238,9 @@ extern V8Class v8VirtualEntity("VirtualEntity", v8::Isolate* isolate = v8::Isolate::GetCurrent(); V8Helpers::SetStaticMethod(isolate, tpl, "getByID", StaticGetByID); +#ifdef ALT_CLIENT_API V8Helpers::SetStaticMethod(isolate, tpl, "getByRemoteID", StaticGetByRemoteId); +#endif V8Helpers::SetStaticAccessor(isolate, tpl, "all", AllGetter); From c4a8960af2d7bfdfd186c4ffcd02a47a9451b9ff Mon Sep 17 00:00:00 2001 From: xLuxy <67131061+xLuxy@users.noreply.github.com> Date: Mon, 4 Sep 2023 00:25:46 +0200 Subject: [PATCH 4/5] client: add VirtualEntityGroup.getByRemoteID static method --- shared/bindings/VirtualEntityGroup.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/shared/bindings/VirtualEntityGroup.cpp b/shared/bindings/VirtualEntityGroup.cpp index 76eb3fab..2e1c4552 100644 --- a/shared/bindings/VirtualEntityGroup.cpp +++ b/shared/bindings/VirtualEntityGroup.cpp @@ -35,6 +35,28 @@ static void StaticGetByID(const v8::FunctionCallbackInfo& info) V8_RETURN_NULL(); } +#ifdef ALT_CLIENT_API + +static void StaticGetByRemoteId(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT_RESOURCE(); + V8_CHECK_ARGS_LEN(1); + + V8_ARG_TO_INT32(1, id); + + alt::IBaseObject* entity = alt::ICore::Instance().GetBaseObjectByRemoteID(alt::IBaseObject::Type::VIRTUAL_ENTITY_GROUP, id); + + if(entity) + { + V8_RETURN_BASE_OBJECT(entity); + return; + } + + V8_RETURN_NULL(); +} + +#endif + static void AllGetter(v8::Local name, const v8::PropertyCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT_RESOURCE(); @@ -116,7 +138,9 @@ extern V8Class v8VirtualEntityGroup("VirtualEntityGroup", v8::Isolate* isolate = v8::Isolate::GetCurrent(); V8Helpers::SetStaticMethod(isolate, tpl, "getByID", StaticGetByID); - +#ifdef ALT_CLIENT_API + V8Helpers::SetStaticMethod(isolate, tpl, "getByRemoteID", StaticGetByRemoteId); +#endif V8Helpers::SetStaticAccessor(isolate, tpl, "all", AllGetter); V8Helpers::SetMethod(isolate, tpl, "hasMeta", HasMeta); From 51d8e23d196e5a265d2e7b1ba7370b863ab640f3 Mon Sep 17 00:00:00 2001 From: xLuxy <67131061+xLuxy@users.noreply.github.com> Date: Mon, 4 Sep 2023 13:01:51 +0200 Subject: [PATCH 5/5] client: comment out VirtualEntityGroup.getByRemoteID --- shared/bindings/VirtualEntityGroup.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shared/bindings/VirtualEntityGroup.cpp b/shared/bindings/VirtualEntityGroup.cpp index 2e1c4552..29a2ae24 100644 --- a/shared/bindings/VirtualEntityGroup.cpp +++ b/shared/bindings/VirtualEntityGroup.cpp @@ -37,6 +37,7 @@ static void StaticGetByID(const v8::FunctionCallbackInfo& info) #ifdef ALT_CLIENT_API +/* NOTE (xLuxy): Client's are not aware of remote groups (yet?) static void StaticGetByRemoteId(const v8::FunctionCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT_RESOURCE(); @@ -53,7 +54,7 @@ static void StaticGetByRemoteId(const v8::FunctionCallbackInfo& info) } V8_RETURN_NULL(); -} +}*/ #endif @@ -139,7 +140,7 @@ extern V8Class v8VirtualEntityGroup("VirtualEntityGroup", V8Helpers::SetStaticMethod(isolate, tpl, "getByID", StaticGetByID); #ifdef ALT_CLIENT_API - V8Helpers::SetStaticMethod(isolate, tpl, "getByRemoteID", StaticGetByRemoteId); + // V8Helpers::SetStaticMethod(isolate, tpl, "getByRemoteID", StaticGetByRemoteId); #endif V8Helpers::SetStaticAccessor(isolate, tpl, "all", AllGetter);