Skip to content

Commit

Permalink
Fix col shape entity pointer type
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianTerhorst committed Aug 1, 2019
1 parent f34c8fb commit 4e894ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion runtime/include/CSharpResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ typedef void (* OnCreateColShapeDelegate_t)(alt::IColShape* colShape);
typedef void (* OnRemoveColShapeDelegate_t)(alt::IColShape* colShape);
typedef void (* OnConsoleCommandDelegate_t)(const char* name, alt::Array<alt::StringView>* args);
typedef void (* MetaChangeDelegate_t)(void* entity, alt::IBaseObject::Type type, alt::StringView key, alt::MValue* value);
typedef void (* ColShapeDelegate_t)(alt::IColShape* colShape, alt::IEntity* entity, alt::IBaseObject::Type baseObjectType, bool state);
typedef void (* ColShapeDelegate_t)(alt::IColShape* colShape, void* entity, alt::IBaseObject::Type baseObjectType, bool state);

class CSharpResource : public alt::IResource {
bool OnEvent(const alt::CEvent* ev) override;
Expand Down
19 changes: 6 additions & 13 deletions runtime/src/CSharpResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,19 +358,12 @@ bool CSharpResource::OnEvent(const alt::CEvent* ev) {
case alt::CEvent::Type::COLSHAPE_EVENT: {
auto entity = ((alt::CColShapeEvent*) (ev))->GetEntity();
if (entity != nullptr) {
switch (entity->GetType()) {
case alt::IBaseObject::Type::PLAYER:
ColShapeDelegate(((alt::CColShapeEvent*) (ev))->GetTarget(),
dynamic_cast<alt::IPlayer*>(entity),
entity->GetType(),
((alt::CColShapeEvent*) (ev))->GetState());
break;
case alt::IBaseObject::Type::VEHICLE:
ColShapeDelegate(((alt::CColShapeEvent*) (ev))->GetTarget(),
dynamic_cast<alt::IVehicle*>(entity),
entity->GetType(),
((alt::CColShapeEvent*) (ev))->GetState());
break;
auto entityPointer = GetEntityPointer(entity);
if (entityPointer != nullptr) {
ColShapeDelegate(((alt::CColShapeEvent*) (ev))->GetTarget(),
entityPointer,
entity->GetType(),
((alt::CColShapeEvent*) (ev))->GetState());
}
}
break;
Expand Down

0 comments on commit 4e894ca

Please sign in to comment.