Skip to content

Commit

Permalink
streaming distance per entity
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Sep 30, 2023
1 parent 9bb0c18 commit 3e2149e
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 16 deletions.
10 changes: 9 additions & 1 deletion c-api/cache/CachedEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ namespace cache
#ifdef ALT_SERVER_API
_streamed(base->GetStreamed()),
_collision(base->HasCollision()),
_timestamp(base->GetTimestamp())
_timestamp(base->GetTimestamp()),
_streamingDistance(base->GetStreamingDistance())
#elif ALT_CLIENT_API
_scriptId(base->GetScriptID()),
_remoteId(base->GetRemoteID()),
Expand Down Expand Up @@ -211,6 +212,13 @@ namespace cache
return _timestamp;
}

uint32_t _streamingDistance;

uint32_t GetStreamingDistance() const override
{
return _streamingDistance;
}

void SetMultipleStreamSyncedMetaData(const std::unordered_map<std::string, alt::MValue>& values) override {}
#endif

Expand Down
12 changes: 6 additions & 6 deletions c-api/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ void Core_TriggerClientEventUnreliableForAll(alt::ICore* core, const char* ev, a
core->TriggerClientEventUnreliableForAll(ev, mValues);
}

alt::IVehicle* Core_CreateVehicle(alt::ICore* core, uint32_t model, position_t pos, rotation_t rot, uint32_t &id) {
alt::IVehicle* Core_CreateVehicle(alt::ICore* core, uint32_t model, position_t pos, rotation_t rot, uint32_t streamingDistance, uint32_t &id) {
alt::Position position;
position.x = pos.x;
position.y = pos.y;
Expand All @@ -558,14 +558,14 @@ alt::IVehicle* Core_CreateVehicle(alt::ICore* core, uint32_t model, position_t p
rotation.roll = rot.roll;
rotation.pitch = rot.pitch;
rotation.yaw = rot.yaw;
auto vehicle = core->CreateVehicle(model, position, rotation);
auto vehicle = core->CreateVehicle(model, position, rotation, streamingDistance);
if (vehicle != nullptr) {
id = vehicle->GetID();
}
return vehicle;
}

alt::IPed* Core_CreatePed(alt::ICore* core, uint32_t model, position_t pos, rotation_t rot, uint32_t &id)
alt::IPed* Core_CreatePed(alt::ICore* core, uint32_t model, position_t pos, rotation_t rot, uint32_t streamingDistance, uint32_t &id)
{
alt::Position position;
position.x = pos.x;
Expand All @@ -577,7 +577,7 @@ alt::IPed* Core_CreatePed(alt::ICore* core, uint32_t model, position_t pos, rota
rotation.pitch = rot.pitch;
rotation.yaw = rot.yaw;

auto ped = core->CreatePed(model, position, rotation);
auto ped = core->CreatePed(model, position, rotation, streamingDistance);
if (ped != nullptr) {
id = ped->GetID();
}
Expand Down Expand Up @@ -822,7 +822,7 @@ alt::IMarker* Core_CreateMarker(alt::ICore* core, alt::IPlayer* target, uint8_t
}

alt::IObject* Core_CreateObject(alt::ICore* core, uint32_t model, position_t position, rotation_t rotation,
uint8_t alpha, uint8_t textureVariation, uint16_t lodDistance, uint32_t& id)
uint8_t alpha, uint8_t textureVariation, uint16_t lodDistance, uint32_t streamingDistance, uint32_t& id)
{
alt::Position pos;
pos.x = position.x;
Expand All @@ -834,7 +834,7 @@ alt::IObject* Core_CreateObject(alt::ICore* core, uint32_t model, position_t pos
rot.pitch = rotation.pitch;
rot.yaw = rotation.yaw;

auto networkObject = core->CreateObject(model, pos, rot, alpha, textureVariation, lodDistance);
auto networkObject = core->CreateObject(model, pos, rot, alpha, textureVariation, lodDistance, streamingDistance);
if (networkObject != nullptr) {
id = networkObject->GetID();
}
Expand Down
6 changes: 3 additions & 3 deletions c-api/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ EXPORT_SERVER void Core_TriggerClientEventUnreliable(alt::ICore* core, alt::IPla
EXPORT_SERVER void Core_TriggerClientEventUnreliableForSome(alt::ICore* core, alt::IPlayer* targets[], int targetsSize, const char* ev, alt::MValueConst* args[], int argsSize);
EXPORT_SERVER void Core_TriggerClientEventUnreliableForAll(alt::ICore* core, const char* ev, alt::MValueConst* args[], int size);

EXPORT_SERVER alt::IVehicle* Core_CreateVehicle(alt::ICore* core, uint32_t model, position_t pos, rotation_t rot, uint32_t &id);
EXPORT_SERVER alt::IPed* Core_CreatePed(alt::ICore* core, uint32_t model, position_t pos, rotation_t rot, uint32_t &id);
EXPORT_SERVER alt::IVehicle* Core_CreateVehicle(alt::ICore* core, uint32_t model, position_t pos, rotation_t rot, uint32_t streamingDistance, uint32_t &id);
EXPORT_SERVER alt::IPed* Core_CreatePed(alt::ICore* core, uint32_t model, position_t pos, rotation_t rot, uint32_t streamingDistance, uint32_t &id);
#ifdef ALT_SERVER_API
EXPORT_SERVER alt::ICheckpoint* Core_CreateCheckpoint(alt::ICore* core, uint8_t type, position_t pos, float radius, float height, rgba_t color, uint32_t streamingDistance, uint32_t &id);
#endif
Expand Down Expand Up @@ -347,7 +347,7 @@ EXPORT_CLIENT alt::IFont* Core_RegisterFont(alt::ICore* core, alt::IResource* re

EXPORT_CLIENT uint8_t Core_IsFullScreen(alt::ICore* core);

EXPORT_SERVER alt::IObject* Core_CreateObject(alt::ICore* core, uint32_t model, position_t position, rotation_t rotation, uint8_t alpha, uint8_t textureVariation, uint16_t lodDistance, uint32_t& id);
EXPORT_SERVER alt::IObject* Core_CreateObject(alt::ICore* core, uint32_t model, position_t position, rotation_t rotation, uint8_t alpha, uint8_t textureVariation, uint16_t lodDistance, uint32_t streamingDistance, uint32_t& id);

EXPORT_SERVER alt::Metric* Core_RegisterMetric(alt::ICore* core, const char* metricName, uint8_t type, const char* keys[], const char* values[], uint64_t size);
EXPORT_SERVER void Core_UnregisterMetric(alt::ICore* core, alt::Metric* metric);
Expand Down
5 changes: 5 additions & 0 deletions c-api/entities/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ void Entity_SetMultipleStreamSyncedMetaData(alt::IEntity* entity, const char* ke

entity->SetMultipleStreamSyncedMetaData(data);
}

uint32_t Entity_GetStreamingDistance(alt::IEntity* entity)
{
return entity->GetStreamingDistance();
}
#endif

#ifdef ALT_CLIENT_API
Expand Down
4 changes: 3 additions & 1 deletion c-api/entities/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ EXPORT_SERVER void Entity_Detach(alt::IEntity* entity);

EXPORT_SERVER void Entity_SetMultipleStreamSyncedMetaData(alt::IEntity* entity, const char* keys[], alt::MValueConst* values[], uint64_t size);

EXPORT_SERVER uint32_t Entity_GetTimestamp(alt::IEntity* entity);
EXPORT_SERVER uint32_t Entity_GetTimestamp(alt::IEntity* entity);

EXPORT_SERVER uint32_t Entity_GetStreamingDistance(alt::IEntity* entity);
8 changes: 4 additions & 4 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 = 3798753127100614877UL;
inline uint64_t capiHash = 16969270403256639162UL;
inline uint64_t capiHashes[] = {
0,
#ifdef ALT_CLIENT_API
Expand Down Expand Up @@ -1315,9 +1315,9 @@ inline uint64_t capiHashes[] = {
6946126881626778655UL,
3410920088129362997UL,
9200413248217250533UL,
6986805276481094958UL,
3289494476065537885UL,
2859438702466150327UL,
6778852446992337891UL,
16295351054968805916UL,
494948204560226296UL,
16510685691058823138UL,
7933678493039322900UL,
11272860948152964480UL,
Expand Down
2 changes: 1 addition & 1 deletion cpp-sdk
Submodule cpp-sdk updated 2 files
+30 −3 ICore.h
+2 −0 objects/IEntity.h

0 comments on commit 3e2149e

Please sign in to comment.