Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into rc
Browse files Browse the repository at this point in the history
  • Loading branch information
emcifuntik committed Oct 4, 2023
2 parents e86d6c3 + 31414e8 commit 4d80312
Show file tree
Hide file tree
Showing 18 changed files with 255 additions and 142 deletions.
23 changes: 22 additions & 1 deletion c-api/cache/CachedBaseObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace cache
{
};

CachedBaseObject(IBaseObject* base) : _type(base->GetType())
CachedBaseObject(IBaseObject* base) : _type(base->GetType()), _id(base->GetID())
{
auto keys = base->GetMetaDataKeys();
for (const auto& key : keys)
Expand Down Expand Up @@ -67,6 +67,27 @@ namespace cache
{
return false;
}

bool HasSyncedMetaData(const std::string & key) const override
{
return false;
}

alt::MValueConst GetSyncedMetaData(const std::string & key) const override
{
return alt::ICore::Instance().CreateMValueNil();
}

uint32_t _id;
uint32_t GetID() const override
{
return _id;
}

std::vector<std::string> GetSyncedMetaDataKeys() const override
{
return {};
}

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

Expand Down
22 changes: 12 additions & 10 deletions c-api/cache/CachedEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace cache
class CachedEntity : public virtual CachedWorldObject, public virtual CachedBaseObject, public virtual alt::IEntity
{
public:
CachedEntity(IEntity* base) : CachedBaseObject(base), CachedWorldObject(base), _id(base->GetID()),
CachedEntity(IEntity* base) : CachedBaseObject(base), CachedWorldObject(base),
_networkOwner(base->GetNetworkOwner()),
_model(base->GetModel()),
_rotation(base->GetRotation()),
Expand All @@ -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 All @@ -40,14 +41,7 @@ namespace cache
_streamSyncedMetaData[key] = base->GetStreamSyncedMetaData(key);
}
}

uint32_t _id;

uint32_t GetID() const override
{
return _id;
}


uint16_t GetSyncID() const override { return static_cast<uint16_t>(_id)/*only temp*/; }

alt::IPlayer* _networkOwner;
Expand Down Expand Up @@ -211,7 +205,15 @@ 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 {}

void SetStreamingDistance(uint32_t streamingDistance) override {}
#endif


Expand Down
2 changes: 1 addition & 1 deletion c-api/cache/CachedPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -607,4 +607,4 @@ namespace cache
#endif

};
} // namespace alt
} // namespace alt
32 changes: 24 additions & 8 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 Expand Up @@ -1006,6 +1006,16 @@ void Core_TriggerClientRPCAnswer(alt::ICore* core, alt::IPlayer* target, uint16_
if(answer == nullptr) return;
core->TriggerClientRPCAnswer(target, answerID, answer->get()->Clone(), error);
}

uint16_t Core_TriggerClientRPCEvent(alt::ICore* core, alt::IPlayer* target, const char* ev, alt::MValueConst* args[],
int size)
{
alt::MValueArgs mValues = alt::MValueArgs(size);
for (int i = 0; i < size; i++) {
ToMValueArg(mValues, core, args[i], i);
}
return core->TriggerClientRPCEvent(target, ev, mValues);
}
#endif

#ifdef ALT_CLIENT_API
Expand Down Expand Up @@ -1617,8 +1627,8 @@ alt::IWebSocketClient* Core_CreateWebsocketClient(alt::ICore* core, alt::IResour
return webSocketClient;
}

alt::IAudio* Core_CreateAudio(alt::ICore* core, const char* source, float volume, uint8_t isRadio, const char* basePath, alt::IResource* resource, uint32_t &id) {
auto audio = core->CreateAudio(source, volume, isRadio, basePath, resource);
alt::IAudio* Core_CreateAudio(alt::ICore* core, const char* source, float volume, uint8_t isRadio, uint8_t clearCache, const char* basePath, alt::IResource* resource, uint32_t &id) {
auto audio = core->CreateAudio(source, volume, isRadio, clearCache, basePath, resource);
if (audio != nullptr) {
id = audio->GetID();
}
Expand Down Expand Up @@ -2005,6 +2015,12 @@ void Core_GetAllWeaponData(alt::ICore* core, uint32_t weaponHashes[], uint64_t s
}
}

void Core_TriggerServerRPCAnswer(alt::ICore* core, uint16_t answerID, alt::MValueConst* answer, const char* error)
{
if(answer == nullptr) return;
core->TriggerServerRPCAnswer(answerID, answer->get()->Clone(), error);
}

uint16_t Core_TriggerServerRPCEvent(alt::ICore* core, const char* ev, alt::MValueConst* args[], int size)
{
alt::MValueArgs mValues = alt::MValueArgs(size);
Expand Down
Loading

0 comments on commit 4d80312

Please sign in to comment.