From 86ea6eb507f5abe32c0311581c8f5bf142620ea9 Mon Sep 17 00:00:00 2001 From: xLuxy <67131061+xLuxy@users.noreply.github.com> Date: Sun, 1 Oct 2023 07:47:10 +0200 Subject: [PATCH] shared: Add streaming stuff --- server/src/classes/Entity.cpp | 1 + server/src/factories/ObjectFactory.cpp | 4 +++- server/src/factories/PedFactory.cpp | 4 +++- server/src/factories/VehicleFactory.cpp | 4 +++- types/server/index.d.ts | 4 ++++ 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/server/src/classes/Entity.cpp b/server/src/classes/Entity.cpp index 1dc2141cd..8fc5204d8 100644 --- a/server/src/classes/Entity.cpp +++ b/server/src/classes/Entity.cpp @@ -174,6 +174,7 @@ extern js::Class entityClass("Entity", &sharedEntityClass, nullptr, [](js::Class tpl.Property<&alt::IEntity::GetVisible, &alt::IEntity::SetVisible>("visible"); tpl.Property<&alt::IEntity::GetStreamed, &alt::IEntity::SetStreamed>("streamed"); tpl.Property<&alt::IEntity::HasCollision, &alt::IEntity::SetCollision>("collision"); + tpl.Property<&alt::IEntity::GetStreamingDistance, &alt::IEntity::SetStreamingDistance>("streamingDistance"); tpl.Property<&alt::IEntity::GetTimestamp>("timestamp"); tpl.DynamicProperty("syncedMeta", nullptr, SyncedMetaSetter, SyncedMetaDeleter, nullptr); diff --git a/server/src/factories/ObjectFactory.cpp b/server/src/factories/ObjectFactory.cpp index d2c5e3ff9..04139d35d 100644 --- a/server/src/factories/ObjectFactory.cpp +++ b/server/src/factories/ObjectFactory.cpp @@ -11,5 +11,7 @@ static js::FactoryHandler objectFactory(alt::IBaseObject::Type::OBJECT, [](js::O uint8_t alpha = args.Get("alpha", 255); uint8_t textureVariation = args.Get("textureVariation", 0); uint16_t lodDistance = args.Get("lodDistance", 100); - return alt::ICore::Instance().CreateObject(model, pos, rot, alpha, textureVariation, lodDistance); + uint32_t streamingDistance = args.Get("streamingDistance", 0); + + return alt::ICore::Instance().CreateObject(model, pos, rot, alpha, textureVariation, lodDistance, streamingDistance); }); diff --git a/server/src/factories/PedFactory.cpp b/server/src/factories/PedFactory.cpp index 308114bd0..51d03bbee 100644 --- a/server/src/factories/PedFactory.cpp +++ b/server/src/factories/PedFactory.cpp @@ -7,5 +7,7 @@ static js::FactoryHandler pedFactory(alt::IBaseObject::Type::PED, [](js::Object& alt::Vector3f pos; if(!args.Get("pos", pos)) return nullptr; float heading = args.Get("heading"); - return alt::ICore::Instance().CreatePed(model, pos, { 0, 0, heading }); + uint32_t streamingDistance = args.Get("streamingDistance", 0); + + return alt::ICore::Instance().CreatePed(model, pos, { 0, 0, heading }, streamingDistance); }); diff --git a/server/src/factories/VehicleFactory.cpp b/server/src/factories/VehicleFactory.cpp index acfc06e18..9c743e155 100644 --- a/server/src/factories/VehicleFactory.cpp +++ b/server/src/factories/VehicleFactory.cpp @@ -7,5 +7,7 @@ static js::FactoryHandler vehicleFactory(alt::IBaseObject::Type::VEHICLE, [](js: alt::Vector3f pos; if(!args.Get("pos", pos)) return nullptr; alt::Vector3f rot = args.Get("rot"); - return alt::ICore::Instance().CreateVehicle(model, pos, rot); + uint32_t streamingDistance = args.Get("streamingDistance", 0); + + return alt::ICore::Instance().CreateVehicle(model, pos, rot, streamingDistance); }); diff --git a/types/server/index.d.ts b/types/server/index.d.ts index 6b3432ec4..6a841d58f 100644 --- a/types/server/index.d.ts +++ b/types/server/index.d.ts @@ -237,6 +237,7 @@ declare module "@altv/server" { streamed: boolean; frozen: boolean; collision: boolean; + streamingDistance: number; readonly timestamp: number; readonly meta: EntityMeta; @@ -271,6 +272,7 @@ declare module "@altv/server" { alpha?: number; // default: 255 textureVariation?: number; // default: 0 lodDistance?: number; // default: 100 + streamingDistance?: number; // default: 0 } export abstract class Object extends Entity { @@ -297,6 +299,7 @@ declare module "@altv/server" { model: number | string; pos: altShared.IVector3; heading: number; + streamingDistance?: number; // default: 0 } export abstract class Ped extends Entity { @@ -495,6 +498,7 @@ declare module "@altv/server" { model: number | string; pos: altShared.IVector3; rot?: altShared.IVector3; // default: { x: 0, y: 0, z: 0 } + streamingDistance?: number; // default: 0 } export abstract class Vehicle extends Entity {