From e205b3f81cc81044dde3a1c50dd0c9e45d695355 Mon Sep 17 00:00:00 2001 From: doxoh Date: Fri, 20 Oct 2023 17:14:31 +0200 Subject: [PATCH] fix GetEntitiesIn* --- c-api/core.cpp | 20 ++++++++++++++------ c-api/core.h | 6 +++--- c-api/func_table.cpp | 12 ++++++------ 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/c-api/core.cpp b/c-api/core.cpp index 537a695..2921020 100644 --- a/c-api/core.cpp +++ b/c-api/core.cpp @@ -770,19 +770,21 @@ uint64_t Core_GetClosestEntitiesCount(alt::ICore* core, vector3_t position, int3 return core->GetClosestEntities(pos, range, dimension, limit, allowedTypes).size(); } -void Core_GetEntitiesInDimension(alt::ICore* core, int32_t dimension, uint64_t allowedTypes, alt::IBaseObject* entities[], uint8_t types[], uint64_t size) { +void Core_GetEntitiesInDimension(alt::ICore* core, int32_t dimension, uint64_t allowedTypes, void**& entities, uint8_t types[], uint64_t size) { auto entitiesArray = core->GetEntitiesInDimension(dimension, allowedTypes); if (entitiesArray.size() < size) { size = entitiesArray.size(); } + auto entityArr = new void*[size]; for (uint64_t i = 0; i < size; i++) { - entities[i] = entitiesArray[i]; + entityArr[i] = Util_GetBaseObjectPointer(entitiesArray[i]); types[i] = (uint8_t) entitiesArray[i]->GetType(); } + entities = entityArr; } -void Core_GetEntitiesInRange(alt::ICore* core, vector3_t position, int32_t range, int32_t dimension, uint64_t allowedTypes, alt::IBaseObject* entities[], uint8_t types[], uint64_t size) { +void Core_GetEntitiesInRange(alt::ICore* core, vector3_t position, int32_t range, int32_t dimension, uint64_t allowedTypes, void**& entities, uint8_t types[], uint64_t size) { alt::Position pos; pos.x = position.x; pos.y = position.y; @@ -792,13 +794,16 @@ void Core_GetEntitiesInRange(alt::ICore* core, vector3_t position, int32_t range if (entitiesArray.size() < size) { size = entitiesArray.size(); } + + auto entityArr = new void*[size]; for (uint64_t i = 0; i < size; i++) { - entities[i] = entitiesArray[i]; + entityArr[i] = Util_GetBaseObjectPointer(entitiesArray[i]); types[i] = (uint8_t) entitiesArray[i]->GetType(); } + entities = entityArr; } -void Core_GetClosestEntities(alt::ICore* core, vector3_t position, int32_t range, int32_t dimension, int32_t limit, uint64_t allowedTypes, alt::IBaseObject* entities[], uint8_t types[], uint64_t size) { +void Core_GetClosestEntities(alt::ICore* core, vector3_t position, int32_t range, int32_t dimension, int32_t limit, uint64_t allowedTypes, void**& entities, uint8_t types[], uint64_t size) { alt::Position pos; pos.x = position.x; pos.y = position.y; @@ -808,10 +813,13 @@ void Core_GetClosestEntities(alt::ICore* core, vector3_t position, int32_t range if (entitiesArray.size() < size) { size = entitiesArray.size(); } + + auto entityArr = new void*[size]; for (uint64_t i = 0; i < size; i++) { - entities[i] = entitiesArray[i]; + entityArr[i] = Util_GetBaseObjectPointer(entitiesArray[i]); types[i] = (uint8_t) entitiesArray[i]->GetType(); } + entities = entityArr; } alt::IMarker* Core_CreateMarker(alt::ICore* core, alt::IPlayer* target, uint8_t type, position_t position, rgba_t color, diff --git a/c-api/core.h b/c-api/core.h index bd52af0..5d8c462 100644 --- a/c-api/core.h +++ b/c-api/core.h @@ -133,9 +133,9 @@ EXPORT_SERVER void Core_SetWorldProfiler(alt::ICore* core, uint8_t state); EXPORT_SERVER uint64_t Core_GetEntitiesInDimensionCount(alt::ICore* core, int32_t dimension, uint64_t allowedTypes); EXPORT_SERVER uint64_t Core_GetEntitiesInRangeCount(alt::ICore* core, vector3_t position, int32_t range, int32_t dimension, uint64_t allowedTypes); EXPORT_SERVER uint64_t Core_GetClosestEntitiesCount(alt::ICore* core, vector3_t position, int32_t range, int32_t dimension, int32_t limit, uint64_t allowedTypes); -EXPORT_SERVER void Core_GetEntitiesInDimension(alt::ICore* core, int32_t dimension, uint64_t allowedTypes, alt::IBaseObject* entities[], uint8_t types[], uint64_t size); -EXPORT_SERVER void Core_GetEntitiesInRange(alt::ICore* core, vector3_t position, int32_t range, int32_t dimension, uint64_t allowedTypes, alt::IBaseObject* entities[], uint8_t types[], uint64_t size); -EXPORT_SERVER void Core_GetClosestEntities(alt::ICore* core, vector3_t position, int32_t range, int32_t dimension, int32_t limit, uint64_t allowedTypes, alt::IBaseObject* entities[], uint8_t types[], uint64_t size); +EXPORT_SERVER void Core_GetEntitiesInDimension(alt::ICore* core, int32_t dimension, uint64_t allowedTypes, void**& entities, uint8_t types[], uint64_t size); +EXPORT_SERVER void Core_GetEntitiesInRange(alt::ICore* core, vector3_t position, int32_t range, int32_t dimension, uint64_t allowedTypes, void**& entities, uint8_t types[], uint64_t size); +EXPORT_SERVER void Core_GetClosestEntities(alt::ICore* core, vector3_t position, int32_t range, int32_t dimension, int32_t limit, uint64_t allowedTypes, void**& entities, uint8_t types[], uint64_t size); #ifdef ALT_CLIENT_API EXPORT_CLIENT uint8_t Core_Client_FileExists(alt::ICore* core, alt::IResource* resource, const char* path); diff --git a/c-api/func_table.cpp b/c-api/func_table.cpp index a190f7d..2e83df6 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 = 14520310097856707558UL; +inline uint64_t capiHash = 3167287157903801399UL; inline uint64_t capiHashes[] = { 0, #ifdef ALT_CLIENT_API @@ -1252,7 +1252,7 @@ inline uint64_t capiHashes[] = { 3918260719528326415UL, 2302278843105157392UL, 8318093389193375258UL, - 17687301249122992283UL, + 15007201997776333277UL, 18440829979133890169UL, 7918377113203812466UL, 6954962557541059864UL, @@ -1330,13 +1330,13 @@ inline uint64_t capiHashes[] = { 16312284234900575747UL, 14452794280175707515UL, 10333270135403224879UL, - 4559218685940666205UL, + 12057843286905322939UL, 419502286495548608UL, 12193205314801108926UL, 13972691773502904173UL, - 4124119004202747553UL, + 11709139263193592519UL, 12784287737200780200UL, - 12414549446254212526UL, + 4074854033126410216UL, 6795936790869684439UL, 5931751806478777368UL, 3581368898059030296UL, @@ -1549,7 +1549,7 @@ inline uint64_t capiHashes[] = { 1312826368700331414UL, 3655237348473428026UL, 8554773347420139463UL, - 6476166832678215577UL, + 1447949168829725163UL, 8002690258276396481UL, 4097244648501164820UL, 10761034670704244318UL,