From ff6682b42137ec4fc2782686e83bb1b2cd8976ac Mon Sep 17 00:00:00 2001 From: Till Schreiber Date: Thu, 9 Jan 2025 12:35:51 +0100 Subject: [PATCH] ALTV-626 make playerDimensionChange shared (#344) --- server/src/events/Player.cpp | 13 ------------- shared/events/Player.cpp | 14 +++++++++++++- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/server/src/events/Player.cpp b/server/src/events/Player.cpp index 3384e83f..63deb5e4 100644 --- a/server/src/events/Player.cpp +++ b/server/src/events/Player.cpp @@ -16,7 +16,6 @@ #include "cpp-sdk/events/CPlayerWeaponChangeEvent.h" #include "cpp-sdk/events/CLocalMetaDataChangeEvent.h" #include "cpp-sdk/events/CPlayerRequestControlEvent.h" -#include "cpp-sdk/events/CPlayerDimensionChangeEvent.h" using alt::CEvent; using EventType = CEvent::Type; @@ -185,18 +184,6 @@ V8_LOCAL_EVENT_HANDLER requestControl(EventType::PLAYER_REQUEST_CONTROL, args.push_back(resource->GetBaseObjectOrNull(ev->GetTarget())); }); -V8_LOCAL_EVENT_HANDLER playerDimensionChange(EventType::PLAYER_DIMENSION_CHANGE, - "playerDimensionChange", - [](V8ResourceImpl* resource, const alt::CEvent* e, std::vector>& args) - { - auto ev = static_cast(e); - v8::Isolate* isolate = resource->GetIsolate(); - - args.push_back(resource->GetBaseObjectOrNull(ev->GetTarget())); - args.push_back(V8Helpers::JSValue(ev->GetOldDimension())); - args.push_back(V8Helpers::JSValue(ev->GetNewDimension())); - }); - V8_LOCAL_EVENT_HANDLER playerSpawn(EventType::PLAYER_SPAWN, "playerSpawn", [](V8ResourceImpl* resource, const alt::CEvent* e, std::vector>& args) diff --git a/shared/events/Player.cpp b/shared/events/Player.cpp index 58766919..4ea54a04 100644 --- a/shared/events/Player.cpp +++ b/shared/events/Player.cpp @@ -3,6 +3,7 @@ #include "cpp-sdk/events/CPlayerChangeAnimationEvent.h" #include "cpp-sdk/events/CPlayerChangeInteriorEvent.h" +#include "cpp-sdk/events/CPlayerDimensionChangeEvent.h" using EventType = alt::CEvent::Type; @@ -20,7 +21,6 @@ V8_LOCAL_EVENT_HANDLER animationChange(EventType::PLAYER_CHANGE_ANIMATION_EVENT, args.emplace_back(V8Helpers::JSValue(ev->GetNewAnimationName())); }); - V8_LOCAL_EVENT_HANDLER playerInteriorChange(EventType::PLAYER_CHANGE_INTERIOR_EVENT, "playerInteriorChange", [](V8ResourceImpl* resource, const alt::CEvent* e, std::vector>& args) @@ -32,3 +32,15 @@ V8_LOCAL_EVENT_HANDLER playerInteriorChange(EventType::PLAYER_CHANGE_INTERIOR_EV args.emplace_back(V8Helpers::JSValue(ev->GetOldInteriorLocation())); args.emplace_back(V8Helpers::JSValue(ev->GetNewInteriorLocation())); }); + +V8_LOCAL_EVENT_HANDLER playerDimensionChange(EventType::PLAYER_DIMENSION_CHANGE, + "playerDimensionChange", + [](V8ResourceImpl* resource, const alt::CEvent* e, std::vector>& args) + { + auto ev = static_cast(e); + v8::Isolate* isolate = resource->GetIsolate(); + + args.push_back(resource->GetBaseObjectOrNull(ev->GetTarget())); + args.push_back(V8Helpers::JSValue(ev->GetOldDimension())); + args.push_back(V8Helpers::JSValue(ev->GetNewDimension())); + });