Skip to content

Commit

Permalink
ALTV-625 - make playerInteriorChange shared (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh authored Jan 9, 2025
1 parent d512099 commit 22a3e36
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
13 changes: 0 additions & 13 deletions server/src/events/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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/CPlayerChangeInteriorEvent.h"
#include "cpp-sdk/events/CPlayerDimensionChangeEvent.h"

using alt::CEvent;
Expand Down Expand Up @@ -186,18 +185,6 @@ V8_LOCAL_EVENT_HANDLER requestControl(EventType::PLAYER_REQUEST_CONTROL,
args.push_back(resource->GetBaseObjectOrNull(ev->GetTarget()));
});

V8_LOCAL_EVENT_HANDLER playerInteriorChange(EventType::PLAYER_CHANGE_INTERIOR_EVENT,
"playerInteriorChange",
[](V8ResourceImpl* resource, const alt::CEvent* e, std::vector<v8::Local<v8::Value>>& args)
{
auto ev = static_cast<const alt::CPlayerChangeInteriorEvent*>(e);
v8::Isolate* isolate = resource->GetIsolate();

args.push_back(resource->GetBaseObjectOrNull(ev->GetTarget()));
args.push_back(V8Helpers::JSValue(ev->GetOldInteriorLocation()));
args.push_back(V8Helpers::JSValue(ev->GetNewInteriorLocation()));
});

V8_LOCAL_EVENT_HANDLER playerDimensionChange(EventType::PLAYER_DIMENSION_CHANGE,
"playerDimensionChange",
[](V8ResourceImpl* resource, const alt::CEvent* e, std::vector<v8::Local<v8::Value>>& args)
Expand Down
36 changes: 26 additions & 10 deletions shared/events/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,33 @@
#include "../V8Helpers.h"

#include "cpp-sdk/events/CPlayerChangeAnimationEvent.h"
#include "cpp-sdk/events/CPlayerChangeInteriorEvent.h"

using EventType = alt::CEvent::Type;

V8_LOCAL_EVENT_HANDLER
animationChange(EventType::PLAYER_CHANGE_ANIMATION_EVENT, "playerAnimationChange", [](V8ResourceImpl* resource, const alt::CEvent* e, std::vector<v8::Local<v8::Value>>& args) {
auto ev = static_cast<const alt::CPlayerChangeAnimationEvent*>(e);
v8::Isolate* isolate = resource->GetIsolate();
V8_LOCAL_EVENT_HANDLER animationChange(EventType::PLAYER_CHANGE_ANIMATION_EVENT,
"playerAnimationChange",
[](V8ResourceImpl* resource, const alt::CEvent* e, std::vector<v8::Local<v8::Value>>& args)
{
auto ev = static_cast<const alt::CPlayerChangeAnimationEvent*>(e);
v8::Isolate* isolate = resource->GetIsolate();

args.push_back(resource->GetBaseObjectOrNull(ev->GetTarget()));
args.push_back(V8Helpers::JSValue(ev->GetOldAnimationDict()));
args.push_back(V8Helpers::JSValue(ev->GetNewAnimationDict()));
args.push_back(V8Helpers::JSValue(ev->GetOldAnimationName()));
args.push_back(V8Helpers::JSValue(ev->GetNewAnimationName()));
});
args.emplace_back(resource->GetBaseObjectOrNull(ev->GetTarget()));
args.emplace_back(V8Helpers::JSValue(ev->GetOldAnimationDict()));
args.emplace_back(V8Helpers::JSValue(ev->GetNewAnimationDict()));
args.emplace_back(V8Helpers::JSValue(ev->GetOldAnimationName()));
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<v8::Local<v8::Value>>& args)
{
auto ev = static_cast<const alt::CPlayerChangeInteriorEvent*>(e);
v8::Isolate* isolate = resource->GetIsolate();

args.emplace_back(resource->GetBaseObjectOrNull(ev->GetTarget()));
args.emplace_back(V8Helpers::JSValue(ev->GetOldInteriorLocation()));
args.emplace_back(V8Helpers::JSValue(ev->GetNewInteriorLocation()));
});

0 comments on commit 22a3e36

Please sign in to comment.