Skip to content

Commit

Permalink
ALTV-364 add static property
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Feb 7, 2025
1 parent 59f5ca8 commit 75d3d5d
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 24 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup .NET Core
shell: pwsh
run: |
.\download_dotnet.ps1 ${{ runner.temp }} linux
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: nethost-linux
path: ${{ runner.temp }}/libnethost.tar
fetch-nethost-windows:
runs-on: windows-2022
steps:
- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup .NET Core
shell: pwsh
run: |
.\download_dotnet.ps1 ${{ runner.temp }} win
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: nethost-windows
path: ${{ runner.temp }}\libnethost.tar
Expand All @@ -58,10 +58,10 @@ jobs:
nethost: nethost-windows,
}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: ${{ matrix.config.nethost }}
path: ./nethost
Expand Down Expand Up @@ -105,18 +105,18 @@ jobs:
filename=$(echo "${{ matrix.config.name }}")
tar -cvf ./$filename.tar modules/$filename/modules
echo "art_name=$filename" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: csharp-module-${{ matrix.config.name }}
path: ./${{ steps.create_archive.outputs.art_name }}.tar
build-client:
runs-on: windows-latest
needs: [fetch-nethost-linux, fetch-nethost-windows]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: nethost-windows
path: ./nethost
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
run: |
tar -cvf ./$filename.tar client/windows/client
echo "art_name=$filename" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: client-windows
path: ./${{ steps.create_archive.outputs.art_name }}.tar
Expand Down
12 changes: 12 additions & 0 deletions c-api/cache/CachedEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace cache
_rotation(base->GetRotation()),
_visible(base->GetVisible()),
_frozen(base->IsFrozen()),
_staticEntity(base->IsStaticEntity()),
#ifdef ALT_SERVER_API
_streamed(base->GetStreamed()),
_collision(base->HasCollision()),
Expand Down Expand Up @@ -136,6 +137,17 @@ namespace cache
void SetFrozen(bool state) override
{
}

bool _staticEntity;

bool IsStaticEntity() const override
{
return _staticEntity;
}

void SetStaticEntity(bool state) override
{
}

#ifdef ALT_SERVER_API
void SetNetworkOwner(alt::IPlayer* player, bool disableMigration) override
Expand Down
12 changes: 6 additions & 6 deletions c-api/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,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 streamingDistance, uint32_t &id) {
alt::IVehicle* Core_CreateVehicle(alt::ICore* core, uint32_t model, position_t pos, rotation_t rot, uint32_t streamingDistance, uint8_t isStatic, uint32_t &id) {
alt::Position position;
position.x = pos.x;
position.y = pos.y;
Expand All @@ -577,14 +577,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, streamingDistance);
auto vehicle = core->CreateVehicle(model, position, rotation, streamingDistance, isStatic);
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 streamingDistance, uint32_t &id)
alt::IPed* Core_CreatePed(alt::ICore* core, uint32_t model, position_t pos, rotation_t rot, uint32_t streamingDistance, uint8_t isStatic, uint32_t &id)
{
alt::Position position;
position.x = pos.x;
Expand All @@ -596,7 +596,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, streamingDistance);
auto ped = core->CreatePed(model, position, rotation, streamingDistance, isStatic);
if (ped != nullptr) {
id = ped->GetID();
}
Expand Down Expand Up @@ -859,7 +859,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 streamingDistance, uint32_t& id)
uint8_t alpha, uint8_t textureVariation, uint16_t lodDistance, uint32_t streamingDistance, uint8_t isStatic, uint32_t& id)
{
alt::Position pos;
pos.x = position.x;
Expand All @@ -871,7 +871,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, streamingDistance);
auto networkObject = core->CreateObject(model, pos, rot, alpha, textureVariation, lodDistance, streamingDistance, isStatic);
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 @@ -92,8 +92,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 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);
EXPORT_SERVER alt::IVehicle* Core_CreateVehicle(alt::ICore* core, uint32_t model, position_t pos, rotation_t rot, uint32_t streamingDistance, uint8_t isStatic, uint32_t &id);
EXPORT_SERVER alt::IPed* Core_CreatePed(alt::ICore* core, uint32_t model, position_t pos, rotation_t rot, uint32_t streamingDistance, uint8_t isStatic, 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 @@ -353,7 +353,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 streamingDistance, 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, uint8_t isStatic, 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
10 changes: 10 additions & 0 deletions c-api/entities/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ void Entity_SetFrozen(alt::IEntity* entity, uint8_t state) {
entity->SetFrozen(state);
}

uint8_t Entity_IsStaticEntity(alt::IEntity* entity)
{
return entity->IsStaticEntity();
}

#ifdef ALT_SERVER_API
void Entity_SetNetOwner(alt::IEntity* entity, alt::IPlayer* networkOwnerPlayer, uint8_t disableMigration) {
entity->SetNetworkOwner(networkOwnerPlayer, disableMigration);
Expand Down Expand Up @@ -150,6 +155,11 @@ void Entity_SetStreamingDistance(alt::IEntity* entity, uint32_t streamingDistanc
{
entity->SetStreamingDistance(streamingDistance);
}

void Entity_SetStaticEntity(alt::IEntity* entity, uint8_t state)
{
entity->SetStaticEntity(state);
}
#endif

#ifdef ALT_CLIENT_API
Expand Down
3 changes: 3 additions & 0 deletions c-api/entities/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ EXPORT_SERVER uint32_t Entity_GetTimestamp(alt::IEntity* entity);

EXPORT_SERVER uint32_t Entity_GetStreamingDistance(alt::IEntity* entity);
EXPORT_SERVER void Entity_SetStreamingDistance(alt::IEntity* entity, uint32_t streamingDistance);

EXPORT_SHARED uint8_t Entity_IsStaticEntity(alt::IEntity* entity);
EXPORT_SERVER void Entity_SetStaticEntity(alt::IEntity* entity, uint8_t state);
12 changes: 8 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 = 1842878650442980314UL;
inline uint64_t capiHash = 3321255477537537411UL;
inline uint64_t capiHashes[] = {
0,
#ifdef ALT_CLIENT_API
Expand Down Expand Up @@ -1132,6 +1132,7 @@ inline uint64_t capiHashes[] = {
15286200049861980882UL,
2664435930066837893UL,
7430146286071665147UL,
14301521857243827244UL,
2663061204279682928UL,
7991844148745066430UL,
11148172387419141388UL,
Expand Down Expand Up @@ -1388,9 +1389,9 @@ inline uint64_t capiHashes[] = {
6946126881626778655UL,
3410920088129362997UL,
9200413248217250533UL,
6778852446992337891UL,
16295351054968805916UL,
494948204560226296UL,
18049638355733736363UL,
5701654053984961760UL,
12711263914629824012UL,
16510685691058823138UL,
7933678493039322900UL,
11272860948152964480UL,
Expand Down Expand Up @@ -1472,6 +1473,7 @@ inline uint64_t capiHashes[] = {
10673322505892191972UL,
5985306302153035853UL,
6937824812303569788UL,
14961071524798922101UL,
6004628797499736605UL,
13173445283048314724UL,
12798418058428333585UL,
Expand Down Expand Up @@ -2954,6 +2956,7 @@ inline void* capiPointers[] = {
(void*) Entity_GetWorldObject,
(void*) Entity_HasStreamSyncedMetaData,
(void*) Entity_IsFrozen,
(void*) Entity_IsStaticEntity,
(void*) Entity_SetFrozen,
(void*) Entity_SetRotation,
(void*) Event_Cancel,
Expand Down Expand Up @@ -3294,6 +3297,7 @@ inline void* capiPointers[] = {
(void*) Entity_SetCollision,
(void*) Entity_SetMultipleStreamSyncedMetaData,
(void*) Entity_SetNetOwner,
(void*) Entity_SetStaticEntity,
(void*) Entity_SetStreamed,
(void*) Entity_SetStreamingDistance,
(void*) Entity_SetStreamSyncedMetaData,
Expand Down
2 changes: 1 addition & 1 deletion cpp-sdk

0 comments on commit 75d3d5d

Please sign in to comment.