Skip to content

Commit 4e894ca

Browse files
Fix col shape entity pointer type
1 parent f34c8fb commit 4e894ca

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

runtime/include/CSharpResource.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ typedef void (* OnCreateColShapeDelegate_t)(alt::IColShape* colShape);
9797
typedef void (* OnRemoveColShapeDelegate_t)(alt::IColShape* colShape);
9898
typedef void (* OnConsoleCommandDelegate_t)(const char* name, alt::Array<alt::StringView>* args);
9999
typedef void (* MetaChangeDelegate_t)(void* entity, alt::IBaseObject::Type type, alt::StringView key, alt::MValue* value);
100-
typedef void (* ColShapeDelegate_t)(alt::IColShape* colShape, alt::IEntity* entity, alt::IBaseObject::Type baseObjectType, bool state);
100+
typedef void (* ColShapeDelegate_t)(alt::IColShape* colShape, void* entity, alt::IBaseObject::Type baseObjectType, bool state);
101101

102102
class CSharpResource : public alt::IResource {
103103
bool OnEvent(const alt::CEvent* ev) override;

runtime/src/CSharpResource.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -358,19 +358,12 @@ bool CSharpResource::OnEvent(const alt::CEvent* ev) {
358358
case alt::CEvent::Type::COLSHAPE_EVENT: {
359359
auto entity = ((alt::CColShapeEvent*) (ev))->GetEntity();
360360
if (entity != nullptr) {
361-
switch (entity->GetType()) {
362-
case alt::IBaseObject::Type::PLAYER:
363-
ColShapeDelegate(((alt::CColShapeEvent*) (ev))->GetTarget(),
364-
dynamic_cast<alt::IPlayer*>(entity),
365-
entity->GetType(),
366-
((alt::CColShapeEvent*) (ev))->GetState());
367-
break;
368-
case alt::IBaseObject::Type::VEHICLE:
369-
ColShapeDelegate(((alt::CColShapeEvent*) (ev))->GetTarget(),
370-
dynamic_cast<alt::IVehicle*>(entity),
371-
entity->GetType(),
372-
((alt::CColShapeEvent*) (ev))->GetState());
373-
break;
361+
auto entityPointer = GetEntityPointer(entity);
362+
if (entityPointer != nullptr) {
363+
ColShapeDelegate(((alt::CColShapeEvent*) (ev))->GetTarget(),
364+
entityPointer,
365+
entity->GetType(),
366+
((alt::CColShapeEvent*) (ev))->GetState());
374367
}
375368
}
376369
break;

0 commit comments

Comments
 (0)