From f15f80d895b1ea976564bb1ec76dba457e3b721b Mon Sep 17 00:00:00 2001 From: LeonMrBonnie Date: Tue, 26 Jan 2021 08:03:33 +0100 Subject: [PATCH 1/4] Add dlc setter and getter for clothes Former-commit-id: b275bcbf9223b82f94394ec43f18fbf24da1d28b --- src/bindings/Player.cpp | 42 ++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/bindings/Player.cpp b/src/bindings/Player.cpp index 0910ed7b..4622d7d3 100644 --- a/src/bindings/Player.cpp +++ b/src/bindings/Player.cpp @@ -194,37 +194,61 @@ static void HwidExHashGetter(v8::Local name, const v8::PropertyCallb static void SetClothes(const v8::FunctionCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT(); - V8_CHECK_ARGS_LEN2(3, 4); + V8_CHECK_ARGS_LEN_MIN_MAX(3, 5); V8_GET_THIS_BASE_OBJECT(player, IPlayer); V8_ARG_TO_INTEGER(1, component); V8_ARG_TO_INTEGER(2, drawable); V8_ARG_TO_INTEGER(3, texture); - if(info.Length() == 4) + if(info.Length() == 3) + { + player->SetClothes(component, drawable, texture, 2); + } + else if(info.Length() == 4) { V8_ARG_TO_INTEGER(4, palette); player->SetClothes(component, drawable, texture, palette); } - else + else if(info.Length() == 5) { - player->SetClothes(component, drawable, texture, 2); + V8_ARG_TO_INTEGER(4, palette); + V8_ARG_TO_INTEGER(5, dlc); + player->SetDlcClothes(component, drawable, texture, palette, dlc); } } static void GetClothes(const v8::FunctionCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT(); - V8_CHECK_ARGS_LEN(1); + V8_CHECK_ARGS_LEN2(1, 2); V8_GET_THIS_BASE_OBJECT(player, IPlayer); V8_ARG_TO_INTEGER(1, component); - auto cloth = player->GetClothes(component); + bool dlcCloth = false; + if(info.Length() == 2) + { + V8_ARG_TO_BOOLEAN(2, dlc); + dlcCloth = dlc; + } + V8_NEW_OBJECT(clothes); - V8_OBJECT_SET_INTEGER(clothes, "drawable", cloth.drawableId); - V8_OBJECT_SET_INTEGER(clothes, "texture", cloth.textureId); - V8_OBJECT_SET_INTEGER(clothes, "palette", cloth.paletteId); + if(!dlcCloth) + { + auto cloth = player->GetClothes(component); + V8_OBJECT_SET_INTEGER(clothes, "drawable", cloth.drawableId); + V8_OBJECT_SET_INTEGER(clothes, "texture", cloth.textureId); + V8_OBJECT_SET_INTEGER(clothes, "palette", cloth.paletteId); + } + else + { + auto cloth = player->GetDlcClothes(component); + V8_OBJECT_SET_INTEGER(clothes, "drawable", cloth.drawableId); + V8_OBJECT_SET_INTEGER(clothes, "texture", cloth.textureId); + V8_OBJECT_SET_INTEGER(clothes, "palette", cloth.paletteId); + V8_OBJECT_SET_INTEGER(clothes, "dlc", cloth.dlc); + } V8_RETURN(clothes); } From f677b91207aff570d2340dd55bb6b451d7d8d315 Mon Sep 17 00:00:00 2001 From: LeonMrBonnie Date: Tue, 26 Jan 2021 08:22:48 +0100 Subject: [PATCH 2/4] Add player props and dlc props Former-commit-id: bac3801a02c0370286f8624a7843f3607f94d3a1 --- src/bindings/Player.cpp | 57 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/bindings/Player.cpp b/src/bindings/Player.cpp index 4622d7d3..c4197cc9 100644 --- a/src/bindings/Player.cpp +++ b/src/bindings/Player.cpp @@ -253,6 +253,60 @@ static void GetClothes(const v8::FunctionCallbackInfo& info) V8_RETURN(clothes); } +static void SetProps(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_CHECK_ARGS_LEN_MIN_MAX(3, 4); + V8_GET_THIS_BASE_OBJECT(player, IPlayer); + + V8_ARG_TO_INTEGER(1, component); + V8_ARG_TO_INTEGER(2, drawable); + V8_ARG_TO_INTEGER(3, texture); + + if(info.Length() == 3) + { + player->SetProps(component, drawable, texture); + } + else if(info.Length() == 4) + { + V8_ARG_TO_INTEGER(4, dlc); + player->SetDlcProps(component, drawable, texture, dlc); + } +} + +static void GetProps(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_CHECK_ARGS_LEN2(1, 2); + V8_GET_THIS_BASE_OBJECT(player, IPlayer); + + V8_ARG_TO_INTEGER(1, component); + + bool dlcProp = false; + if(info.Length() == 2) + { + V8_ARG_TO_BOOLEAN(2, dlc); + dlcProp = dlc; + } + + V8_NEW_OBJECT(clothes); + if(!dlcProp) + { + auto prop = player->GetProps(component); + V8_OBJECT_SET_INTEGER(clothes, "drawable", prop.drawableId); + V8_OBJECT_SET_INTEGER(clothes, "texture", prop.textureId); + } + else + { + auto prop = player->GetDlcProps(component); + V8_OBJECT_SET_INTEGER(clothes, "drawable", prop.drawableId); + V8_OBJECT_SET_INTEGER(clothes, "texture", prop.textureId); + V8_OBJECT_SET_INTEGER(clothes, "dlc", prop.dlc); + } + + V8_RETURN(clothes); +} + static void IsEntityInStreamRange(const v8::FunctionCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT(); @@ -347,4 +401,7 @@ extern V8Class v8Player("Player", v8Entity, nullptr, [](v8::Local Date: Tue, 26 Jan 2021 09:59:14 +0100 Subject: [PATCH 3/4] Fix var name Former-commit-id: d7db24689713319a4848a75d23ea619eed3ac4fb --- src/bindings/Player.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/bindings/Player.cpp b/src/bindings/Player.cpp index c4197cc9..4813bd13 100644 --- a/src/bindings/Player.cpp +++ b/src/bindings/Player.cpp @@ -289,22 +289,22 @@ static void GetProps(const v8::FunctionCallbackInfo& info) dlcProp = dlc; } - V8_NEW_OBJECT(clothes); + V8_NEW_OBJECT(prop); if(!dlcProp) { - auto prop = player->GetProps(component); - V8_OBJECT_SET_INTEGER(clothes, "drawable", prop.drawableId); - V8_OBJECT_SET_INTEGER(clothes, "texture", prop.textureId); + auto props = player->GetProps(component); + V8_OBJECT_SET_INTEGER(prop, "drawable", props.drawableId); + V8_OBJECT_SET_INTEGER(prop, "texture", props.textureId); } else { - auto prop = player->GetDlcProps(component); - V8_OBJECT_SET_INTEGER(clothes, "drawable", prop.drawableId); - V8_OBJECT_SET_INTEGER(clothes, "texture", prop.textureId); - V8_OBJECT_SET_INTEGER(clothes, "dlc", prop.dlc); + auto props = player->GetDlcProps(component); + V8_OBJECT_SET_INTEGER(prop, "drawable", props.drawableId); + V8_OBJECT_SET_INTEGER(prop, "texture", props.textureId); + V8_OBJECT_SET_INTEGER(prop, "dlc", props.dlc); } - V8_RETURN(clothes); + V8_RETURN(prop); } static void IsEntityInStreamRange(const v8::FunctionCallbackInfo& info) From 5dc8b2bbdb03af26eae62c04a4623cbdc332a35f Mon Sep 17 00:00:00 2001 From: LeonMrBonnie Date: Tue, 26 Jan 2021 10:03:21 +0100 Subject: [PATCH 4/4] Rename setProps to setProp und getProps to getProp Former-commit-id: 8d306cf5baec646b73ddaa43516846b542e351ca --- src/bindings/Player.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bindings/Player.cpp b/src/bindings/Player.cpp index 4813bd13..21d08c69 100644 --- a/src/bindings/Player.cpp +++ b/src/bindings/Player.cpp @@ -402,6 +402,6 @@ extern V8Class v8Player("Player", v8Entity, nullptr, [](v8::Local