diff --git a/c-api/data/aabb.h b/c-api/data/aabb.h new file mode 100644 index 0000000..76cb6b5 --- /dev/null +++ b/c-api/data/aabb.h @@ -0,0 +1,7 @@ +#pragma once +#include "cpp-sdk/deps/alt-math/alt-math.h" + +typedef struct { + alt::Position min; + alt::Position max; +} aabb_t; \ No newline at end of file diff --git a/c-api/func_table.cpp b/c-api/func_table.cpp index 4d77544..24ba0c5 100644 --- a/c-api/func_table.cpp +++ b/c-api/func_table.cpp @@ -1,6 +1,6 @@ #include "func_table.h" -inline uint64_t capiHash = 11629663074568386340UL; +inline uint64_t capiHash = 10075699596264467259UL; inline uint64_t capiHashes[] = { 0, #ifdef ALT_CLIENT_API @@ -469,6 +469,36 @@ inline uint64_t capiHashes[] = { 8280976854604120523UL, 4939806300942583161UL, 12260251650657662947UL, + 15230725921455826742UL, + 9833874365185055719UL, + 10883468373939012235UL, + 15377866266281851140UL, + 8232363457953011397UL, + 2751756776126960023UL, + 1814048572451154980UL, + 13960987639501218250UL, + 13352719488432116273UL, + 4913927801862478282UL, + 7285942813518470950UL, + 1117662078157381260UL, + 9560528769032004812UL, + 13206342625351776081UL, + 14268893542560810008UL, + 3255950788253963043UL, + 16182899257589323539UL, + 15288926594136993761UL, + 9853055316547927459UL, + 12340070947493379575UL, + 16837975631170049766UL, + 8261388998032521861UL, + 7856663484428066825UL, + 15158102510225914020UL, + 4739364089865431579UL, + 4358271132564072471UL, + 7499702612373464399UL, + 12048596999299004349UL, + 4102368831198906004UL, + 7739810354326755506UL, 12723661681621738686UL, 12557963046901634258UL, 8482470825689546294UL, @@ -2256,6 +2286,36 @@ inline void* capiPointers[] = { (void*) HttpClient_Put, (void*) HttpClient_SetExtraHeader, (void*) HttpClient_Trace, + (void*) Interior_GetEntitiesExtents, + (void*) Interior_GetPortalCount, + (void*) Interior_GetPosition, + (void*) Interior_GetRoomCount, + (void*) Interior_GetRotation, + (void*) InteriorPortal_GetCornerCount, + (void*) InteriorPortal_GetCornerPosition, + (void*) InteriorPortal_GetEntityArcheType, + (void*) InteriorPortal_GetEntityCount, + (void*) InteriorPortal_GetEntityFlag, + (void*) InteriorPortal_GetEntityPosition, + (void*) InteriorPortal_GetEntityRotation, + (void*) InteriorPortal_GetFlag, + (void*) InteriorPortal_GetIndex, + (void*) InteriorPortal_GetRoomFrom, + (void*) InteriorPortal_GetRoomTo, + (void*) InteriorPortal_SetCornerPosition, + (void*) InteriorPortal_SetEntityFlag, + (void*) InteriorPortal_SetFlag, + (void*) InteriorPortal_SetRoomFrom, + (void*) InteriorPortal_SetRoomTo, + (void*) InteriorRoom_GetExtents, + (void*) InteriorRoom_GetFlag, + (void*) InteriorRoom_GetIndex, + (void*) InteriorRoom_GetName, + (void*) InteriorRoom_GetNameHash, + (void*) InteriorRoom_GetTimecycle, + (void*) InteriorRoom_SetExtents, + (void*) InteriorRoom_SetFlag, + (void*) InteriorRoom_SetTimecycle, (void*) LocalObject_ActivatePhysics, (void*) LocalObject_AttachToEntity, (void*) LocalObject_AttachToEntity_ScriptId, diff --git a/c-api/func_table.h b/c-api/func_table.h index f732f85..cb2d24a 100644 --- a/c-api/func_table.h +++ b/c-api/func_table.h @@ -53,6 +53,9 @@ #include "entities/local_ped.h" #include "entities/font.h" #include "entities/custom_texture.h" +#include "interior.h" +#include "interior_portal.h" +#include "interior_room.h" #include const function_table_t* get_func_table(); \ No newline at end of file diff --git a/c-api/interior.cpp b/c-api/interior.cpp new file mode 100644 index 0000000..c21cc5b --- /dev/null +++ b/c-api/interior.cpp @@ -0,0 +1,39 @@ +#include "interior.h" + +#include "utils/macros.h" + +CAPI_START() + +#ifdef ALT_CLIENT_API +uint16_t Interior_GetRoomCount(uint32_t interiorId) +{ + auto interior = alt::ICore::Instance().GetInterior(interiorId); + return interior->GetRoomCount(); +} + +uint16_t Interior_GetPortalCount(uint32_t interiorId) +{ + auto interior = alt::ICore::Instance().GetInterior(interiorId); + return interior->GetPortalCount(); +} + +alt::Position Interior_GetPosition(uint32_t interiorId) +{ + auto interior = alt::ICore::Instance().GetInterior(interiorId); + return interior->GetPosition(); +} + +alt::Rotation Interior_GetRotation(uint32_t interiorId) +{ + auto interior = alt::ICore::Instance().GetInterior(interiorId); + return interior->GetRotation(); +} + +void Interior_GetEntitiesExtents(uint32_t interiorId, aabb_t& extents) +{ + auto interior = alt::ICore::Instance().GetInterior(interiorId); + auto ext = interior->GetEntitiesExtents(); + extents.min = ext.min; + extents.max = ext.max; +} +#endif \ No newline at end of file diff --git a/c-api/interior.h b/c-api/interior.h new file mode 100644 index 0000000..e8ce4d9 --- /dev/null +++ b/c-api/interior.h @@ -0,0 +1,29 @@ +#pragma once + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wempty-body" +#pragma clang diagnostic ignored "-Wswitch" +#endif + +#include "cpp-sdk/SDK.h" +#include "data/aabb.h" +#include "data/types.h" +#include "data/invoker.h" +#include "utils/export.h" + +#ifdef ALT_SERVER_API +#include +#elif ALT_CLIENT_API +#include "../client/src/runtime/CSharpResourceImpl.h" +#endif + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +EXPORT_CLIENT uint16_t Interior_GetRoomCount(uint32_t interiorId); +EXPORT_CLIENT uint16_t Interior_GetPortalCount(uint32_t interiorId); +EXPORT_CLIENT alt::Position Interior_GetPosition(uint32_t interiorId); +EXPORT_CLIENT alt::Rotation Interior_GetRotation(uint32_t interiorId); +EXPORT_CLIENT void Interior_GetEntitiesExtents(uint32_t interiorId, aabb_t& extents); \ No newline at end of file diff --git a/c-api/interior_portal.cpp b/c-api/interior_portal.cpp new file mode 100644 index 0000000..e864844 --- /dev/null +++ b/c-api/interior_portal.cpp @@ -0,0 +1,111 @@ +#include "interior_portal.h" + +#include "cpp-sdk/script-objects/IInteriorPortal.h" +#include "utils/macros.h" + +CAPI_START() + +#ifdef ALT_CLIENT_API +uint32_t InteriorPortal_GetIndex(uint32_t interiorId, uint32_t portalIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetIndex(); +} + +uint16_t InteriorPortal_GetCornerCount(uint32_t interiorId, uint32_t portalIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetCornerCount(); +} + +alt::Position InteriorPortal_GetCornerPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t cornerIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetCornerPosition(cornerIndex); +} + +uint32_t InteriorPortal_GetRoomFrom(uint32_t interiorId, uint32_t portalIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetRoomFrom(); +} + +uint32_t InteriorPortal_GetRoomTo(uint32_t interiorId, uint32_t portalIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetRoomTo(); +} + +int32_t InteriorPortal_GetFlag(uint32_t interiorId, uint32_t portalIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetFlag(); +} + +uint16_t InteriorPortal_GetEntityCount(uint32_t interiorId, uint32_t portalIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetEntityCount(); +} + +uint32_t InteriorPortal_GetEntityArcheType(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetEntityArcheType(entityIndex); +} + +int32_t InteriorPortal_GetEntityFlag(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetEntityFlag(entityIndex); +} + +alt::Position InteriorPortal_GetEntityPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetEntityPosition(entityIndex); +} + +alt::Rotation InteriorPortal_GetEntityRotation(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetEntityRotation(entityIndex); +} + +void InteriorPortal_SetCornerPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t cornerIndex, + position_t position) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + portal->SetCornerPosition(cornerIndex, alt::Position(position.x, position.y, position.z)); +} + +void InteriorPortal_SetRoomFrom(uint32_t interiorId, uint32_t portalIndex, uint32_t roomFrom) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + portal->SetRoomFrom(roomFrom); +} + +void InteriorPortal_SetRoomTo(uint32_t interiorId, uint32_t portalIndex, uint32_t roomTo) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + portal->SetRoomTo(roomTo); +} + +void InteriorPortal_SetFlag(uint32_t interiorId, uint32_t portalIndex, int32_t flag) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + portal->SetFlag(flag); +} + +void InteriorPortal_SetEntityFlag(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex, int32_t flag) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + portal->SetEntityFlag(entityIndex, flag); +} + +std::shared_ptr GetInteriorPortal(uint32_t interiorId, uint32_t portalIndex) +{ + auto interior = alt::ICore::Instance().GetInterior(interiorId); + return interior->GetPortalByIndex(portalIndex); +} +#endif \ No newline at end of file diff --git a/c-api/interior_portal.h b/c-api/interior_portal.h new file mode 100644 index 0000000..4e67497 --- /dev/null +++ b/c-api/interior_portal.h @@ -0,0 +1,47 @@ +#pragma once + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wempty-body" +#pragma clang diagnostic ignored "-Wswitch" +#endif + +#include "cpp-sdk/SDK.h" +#include "data/aabb.h" +#include "data/types.h" +#include "data/invoker.h" +#include "utils/export.h" + +#ifdef ALT_SERVER_API +#include +#elif ALT_CLIENT_API +#include "../client/src/runtime/CSharpResourceImpl.h" +#endif + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +EXPORT_CLIENT uint32_t InteriorPortal_GetIndex(uint32_t interiorId, uint32_t portalIndex); +EXPORT_CLIENT uint16_t InteriorPortal_GetCornerCount(uint32_t interiorId, uint32_t portalIndex); +EXPORT_CLIENT alt::Position InteriorPortal_GetCornerPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t cornerIndex); +EXPORT_CLIENT uint32_t InteriorPortal_GetRoomFrom(uint32_t interiorId, uint32_t portalIndex); +EXPORT_CLIENT uint32_t InteriorPortal_GetRoomTo(uint32_t interiorId, uint32_t portalIndex); +EXPORT_CLIENT int32_t InteriorPortal_GetFlag(uint32_t interiorId, uint32_t portalIndex); + +EXPORT_CLIENT uint16_t InteriorPortal_GetEntityCount(uint32_t interiorId, uint32_t portalIndex); +EXPORT_CLIENT uint32_t InteriorPortal_GetEntityArcheType(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex); +EXPORT_CLIENT int32_t InteriorPortal_GetEntityFlag(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex); +EXPORT_CLIENT alt::Position InteriorPortal_GetEntityPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex); +EXPORT_CLIENT alt::Rotation InteriorPortal_GetEntityRotation(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex); + + +EXPORT_CLIENT void InteriorPortal_SetCornerPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t cornerIndex, position_t position); +EXPORT_CLIENT void InteriorPortal_SetRoomFrom(uint32_t interiorId, uint32_t portalIndex, uint32_t roomFrom); +EXPORT_CLIENT void InteriorPortal_SetRoomTo(uint32_t interiorId, uint32_t portalIndex, uint32_t roomTo); +EXPORT_CLIENT void InteriorPortal_SetFlag(uint32_t interiorId, uint32_t portalIndex, int32_t flag); +EXPORT_CLIENT void InteriorPortal_SetEntityFlag(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex, int32_t flag); + +#ifdef ALT_CLIENT_API +std::shared_ptr GetInteriorPortal(uint32_t interiorId, uint32_t portalIndex); +#endif \ No newline at end of file diff --git a/c-api/interior_room.cpp b/c-api/interior_room.cpp new file mode 100644 index 0000000..45ba257 --- /dev/null +++ b/c-api/interior_room.cpp @@ -0,0 +1,86 @@ +#include "interior_room.h" + +#include "cpp-sdk/script-objects/IInteriorRoom.h" +#include "utils/macros.h" +#include "utils/strings.h" + +CAPI_START() + +#ifdef ALT_CLIENT_API +uint32_t InteriorRoom_GetIndex(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex) +{ + auto room = GetInteriorRoom(interiorId, roomValue, isIndex); + return room->GetIndex(); +} + +const char* InteriorRoom_GetName(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, int32_t& size) +{ + auto room = GetInteriorRoom(interiorId, roomValue, isIndex); + return AllocateString(room->GetName(), size); +} + +uint32_t InteriorRoom_GetNameHash(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex) +{ + auto room = GetInteriorRoom(interiorId, roomValue, isIndex); + return room->GetNameHash(); +} + +int32_t InteriorRoom_GetFlag(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex) +{ + auto room = GetInteriorRoom(interiorId, roomValue, isIndex); + return room->GetFlag(); +} + +uint32_t InteriorRoom_GetTimecycle(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex) +{ + auto room = GetInteriorRoom(interiorId, roomValue, isIndex); + return room->GetTimecycle(); +} + +void InteriorRoom_GetExtents(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, + aabb_t& extents) +{ + auto room = GetInteriorRoom(interiorId, roomValue, isIndex); + auto ext = room->GetExtents(); + extents.min = ext.min; + extents.max = ext.max; +} + +void InteriorRoom_SetFlag(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, int32_t flag) +{ + auto room = GetInteriorRoom(interiorId, roomValue, isIndex); + room->SetFlag(flag); +} + +void InteriorRoom_SetTimecycle(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, uint32_t timecycle) +{ + auto room = GetInteriorRoom(interiorId, roomValue, isIndex); + room->SetTimecycle(timecycle); +} + +void InteriorRoom_SetExtents(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, position_t min, + position_t max) +{ + auto room = GetInteriorRoom(interiorId, roomValue, isIndex); + alt::AABB extentInfo; + extentInfo.min = alt::Position(min.x, min.y, min.z); + extentInfo.max = alt::Position(max.x, max.y, max.z); + room->SetExtents(extentInfo); +} + +std::shared_ptr GetInteriorRoom(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex) +{ + auto interior = alt::ICore::Instance().GetInterior(interiorId); + std::shared_ptr room; + if (isIndex == 1) + { + room = interior->GetRoomByIndex(roomValue); + } + else + { + room = interior->GetRoomByHash(roomValue); + } + + return room; +} +#endif \ No newline at end of file diff --git a/c-api/interior_room.h b/c-api/interior_room.h new file mode 100644 index 0000000..dbc7a5a --- /dev/null +++ b/c-api/interior_room.h @@ -0,0 +1,40 @@ +#pragma once + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wempty-body" +#pragma clang diagnostic ignored "-Wswitch" +#endif + +#include "cpp-sdk/SDK.h" +#include "data/aabb.h" +#include "data/types.h" +#include "data/invoker.h" +#include "utils/export.h" + +#ifdef ALT_SERVER_API +#include +#elif ALT_CLIENT_API +#include "../client/src/runtime/CSharpResourceImpl.h" +#endif + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +EXPORT_CLIENT uint32_t InteriorRoom_GetIndex(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex); +EXPORT_CLIENT const char* InteriorRoom_GetName(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, int32_t& size); +EXPORT_CLIENT uint32_t InteriorRoom_GetNameHash(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex); +EXPORT_CLIENT int32_t InteriorRoom_GetFlag(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex); +EXPORT_CLIENT uint32_t InteriorRoom_GetTimecycle(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex); + +EXPORT_CLIENT void InteriorRoom_GetExtents(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, aabb_t& extents); + +EXPORT_CLIENT void InteriorRoom_SetFlag(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, int32_t flag); +EXPORT_CLIENT void InteriorRoom_SetTimecycle(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, uint32_t timecycle); +EXPORT_CLIENT void InteriorRoom_SetExtents(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, position_t min, position_t max); + + +#ifdef ALT_CLIENT_API +std::shared_ptr GetInteriorRoom(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex); +#endif \ No newline at end of file diff --git a/cpp-sdk b/cpp-sdk index b782525..1c7ace8 160000 --- a/cpp-sdk +++ b/cpp-sdk @@ -1 +1 @@ -Subproject commit b7825258fafcb6d9aa3906b41e27cfe2d8bf93af +Subproject commit 1c7ace86d575b156f098ba5f0ca01128536502c5