Skip to content

Commit

Permalink
fix GetEntitiesIn*
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Oct 20, 2023
1 parent 59834d3 commit e205b3f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
20 changes: 14 additions & 6 deletions c-api/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions c-api/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions c-api/func_table.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -1252,7 +1252,7 @@ inline uint64_t capiHashes[] = {
3918260719528326415UL,
2302278843105157392UL,
8318093389193375258UL,
17687301249122992283UL,
15007201997776333277UL,
18440829979133890169UL,
7918377113203812466UL,
6954962557541059864UL,
Expand Down Expand Up @@ -1330,13 +1330,13 @@ inline uint64_t capiHashes[] = {
16312284234900575747UL,
14452794280175707515UL,
10333270135403224879UL,
4559218685940666205UL,
12057843286905322939UL,
419502286495548608UL,
12193205314801108926UL,
13972691773502904173UL,
4124119004202747553UL,
11709139263193592519UL,
12784287737200780200UL,
12414549446254212526UL,
4074854033126410216UL,
6795936790869684439UL,
5931751806478777368UL,
3581368898059030296UL,
Expand Down Expand Up @@ -1549,7 +1549,7 @@ inline uint64_t capiHashes[] = {
1312826368700331414UL,
3655237348473428026UL,
8554773347420139463UL,
6476166832678215577UL,
1447949168829725163UL,
8002690258276396481UL,
4097244648501164820UL,
10761034670704244318UL,
Expand Down

0 comments on commit e205b3f

Please sign in to comment.