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 Sep 27, 2023
2 parents e72fc31 + f8160ee commit e86d6c3
Show file tree
Hide file tree
Showing 15 changed files with 363 additions and 76 deletions.
79 changes: 42 additions & 37 deletions c-api/cache/CachedPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,40 @@ namespace cache
public:

CachedPlayer(IPlayer* base) : CachedBaseObject(base), CachedWorldObject(base), CachedEntity(base),
_name(base->GetName()),
_health(base->GetHealth()),
_maxHealth(base->GetMaxHealth()),
_currentWeapon(base->GetCurrentWeapon()),
_dead(base->IsDead()),
_jumping(base->IsJumping()),
_inRagdoll(base->IsInRagdoll()),
_aiming(base->IsAiming()),
_shooting(base->IsShooting()),
_reloading(base->IsReloading()),
_enteringVehicle(base->IsEnteringVehicle()),
_leavingVehicle(base->IsLeavingVehicle()),
_onLadder(base->IsOnLadder()),
_inMelee(base->IsInMelee()),
_inCover(base->IsInCover()),
_armour(base->GetArmour()),
_maxArmour(base->GetMaxArmour()),
_moveSpeed(base->GetMoveSpeed()),
_aimPos(base->GetAimPos()),
_headRotation(base->GetHeadRotation()),
_inVehicle(base->IsInVehicle()),
_vehicle(base->GetVehicle()),
_seat(base->GetSeat()),
_entityAimingAt(base->GetEntityAimingAt()),
_entityAimOffset(base->GetEntityAimOffset()),
_flashlightActive(base->IsFlashlightActive()),
_currentAnimationDict(base->GetCurrentAnimationDict()),
_currentAnimationName(base->GetCurrentAnimationName()),
_spawned(base->IsSpawned()),
_forwardSpeed(base->GetForwardSpeed()),
_strafeSpeed(base->GetStrafeSpeed()),
_parachuting(base->IsParachuting()),
_name(base->GetName()),
_health(base->GetHealth()),
_maxHealth(base->GetMaxHealth()),
_currentWeaponTintIndex(base->GetCurrentWeaponTintIndex()),
_currentWeapon(base->GetCurrentWeapon()),
_dead(base->IsDead()),
_jumping(base->IsJumping()),
_inRagdoll(base->IsInRagdoll()),
_aiming(base->IsAiming()),
_shooting(base->IsShooting()),
_reloading(base->IsReloading()),
_enteringVehicle(base->IsEnteringVehicle()),
_leavingVehicle(base->IsLeavingVehicle()),
_onLadder(base->IsOnLadder()),
_inMelee(base->IsInMelee()),
_inCover(base->IsInCover()),
_armour(base->GetArmour()),
_maxArmour(base->GetMaxArmour()),
_moveSpeed(base->GetMoveSpeed()),
_aimPos(base->GetAimPos()),
_headRotation(base->GetHeadRotation()),
_inVehicle(base->IsInVehicle()),
_vehicle(base->GetVehicle()),
_seat(base->GetSeat()),
_entityAimingAt(base->GetEntityAimingAt()),
_entityAimOffset(base->GetEntityAimOffset()),
_flashlightActive(base->IsFlashlightActive()),
_currentAnimationDict(base->GetCurrentAnimationDict()),
_currentAnimationName(base->GetCurrentAnimationName()),
_spawned(base->IsSpawned()),
_forwardSpeed(base->GetForwardSpeed()),
_strafeSpeed(base->GetStrafeSpeed()),
_parachuting(base->IsParachuting()),
#ifdef ALT_SERVER_API
_currentWeaponTintIndex(base->GetCurrentWeaponTintIndex()),
_superJumpEnabled(base->IsSuperJumpEnabled()),
_crouching(base->IsCrouching()),
_stealthy(base->IsStealthy()),
Expand Down Expand Up @@ -75,10 +75,10 @@ namespace cache
_faceFeatures(20, 0.0f),
_socialClubName(base->GetSocialClubName())
#elif ALT_CLIENT_API
_talking(base->IsTalking()),
_micLevel(base->GetMicLevel()),
_spatialVolume(base->GetSpatialVolume()),
_nonSpatialVolume(base->GetNonSpatialVolume())
_talking(base->IsTalking()),
_micLevel(base->GetMicLevel()),
_spatialVolume(base->GetSpatialVolume()),
_nonSpatialVolume(base->GetNonSpatialVolume())
#endif
{
#ifdef ALT_SERVER_API
Expand Down Expand Up @@ -599,6 +599,11 @@ namespace cache
void RemoveFilter() override {}
alt::IAudioFilter* GetFilter() const override { return nullptr; }

std::string _taskData;
std::string GetTaskData() const override {
return _taskData;
}

#endif

};
Expand Down
23 changes: 19 additions & 4 deletions c-api/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ alt::IColShape* Core_CreateColShapePolygon(alt::ICore* core, float minZ, float m
return colShape;
}

int32_t Core_GetNetTime(alt::ICore* core) {
return core->GetNetTime();
}

#ifdef ALT_SERVER_API
uint8_t Core_SubscribeCommand(alt::ICore* core, const char* cmd, alt::CommandCallback cb) {
return core->SubscribeCommand(cmd, cb);
Expand Down Expand Up @@ -685,10 +689,6 @@ void Core_DestroyColShape(alt::ICore* core, alt::IColShape* baseObject) {
return core->DestroyBaseObject(baseObject);
}

int32_t Core_GetNetTime(alt::ICore* core) {
return core->GetNetTime();
}

const char* Core_GetRootDirectory(alt::ICore* core, int32_t& size) {
return AllocateString(core->GetRootDirectory(), size);
}
Expand Down Expand Up @@ -1000,6 +1000,12 @@ void Core_SetMigrationDistance(alt::ICore* core, uint32_t limit)
{
core->SetMigrationDistance(limit);
}

void Core_TriggerClientRPCAnswer(alt::ICore* core, alt::IPlayer* target, uint16_t answerID, alt::MValueConst* answer, const char* error)
{
if(answer == nullptr) return;
core->TriggerClientRPCAnswer(target, answerID, answer->get()->Clone(), error);
}
#endif

#ifdef ALT_CLIENT_API
Expand Down Expand Up @@ -1998,6 +2004,15 @@ void Core_GetAllWeaponData(alt::ICore* core, uint32_t weaponHashes[], uint64_t s
weaponHashes[i] = weaponData[i]->GetNameHash();
}
}

uint16_t Core_TriggerServerRPCEvent(alt::ICore* core, 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->TriggerServerRPCEvent(ev, mValues);
}
#endif

CAPI_END()
7 changes: 5 additions & 2 deletions c-api/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ EXPORT_SERVER void Core_DestroyVehicle(alt::ICore* server, alt::IVehicle* baseOb
EXPORT_SERVER void Core_DestroyCheckpoint(alt::ICore* server, alt::ICheckpoint* baseObject);
EXPORT_SERVER void Core_DestroyVoiceChannel(alt::ICore* server, alt::IVoiceChannel* baseObject);
EXPORT_SERVER void Core_DestroyColShape(alt::ICore* server, alt::IColShape* baseObject);
EXPORT_SERVER int32_t Core_GetNetTime(alt::ICore* server);
EXPORT_SHARED int32_t Core_GetNetTime(alt::ICore* server);
EXPORT_SERVER const char* Core_GetRootDirectory(alt::ICore* server, int32_t& size);
EXPORT_SERVER void Core_StartResource(alt::ICore* server, const char* text);
EXPORT_SERVER void Core_StopResource(alt::ICore* server, const char* text);
Expand Down Expand Up @@ -396,4 +396,7 @@ EXPORT_SERVER uint32_t Core_GetColShapeTickRate(alt::ICore* core);
EXPORT_SERVER void Core_SetColShapeTickRate(alt::ICore* core, uint32_t limit);

EXPORT_SERVER uint32_t Core_GetMigrationDistance(alt::ICore* core);
EXPORT_SERVER void Core_SetMigrationDistance(alt::ICore* core, uint32_t limit);
EXPORT_SERVER void Core_SetMigrationDistance(alt::ICore* core, uint32_t limit);

EXPORT_SERVER void Core_TriggerClientRPCAnswer(alt::ICore* server, alt::IPlayer* target, uint16_t answerID, alt::MValueConst* answer, const char* error);
EXPORT_CLIENT uint16_t Core_TriggerServerRPCEvent(alt::ICore* server, const char* ev, alt::MValueConst* args[], int size);
43 changes: 24 additions & 19 deletions c-api/data/vehicle_model_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#include "cpp-sdk/ICore.h"
#include "bone_info.h"

struct ClrVehicleModelInfo {
struct ClrVehicleModelInfo
{
char* title = nullptr;
alt::VehicleModelInfo::Type modelType;
uint8_t wheelsCount;
Expand All @@ -24,26 +25,28 @@ struct ClrVehicleModelInfo {
uint32_t boneSize;

uint8_t canAttachCars;
uint32_t handlingNameHash;

ClrVehicleModelInfo() = default;

ClrVehicleModelInfo(alt::VehicleModelInfo info) :
modelType(info.modelType),
wheelsCount(info.wheelsCount),
hasArmoredWindows(info.hasArmoredWindows),
primaryColor(info.primaryColor),
secondaryColor(info.secondaryColor),
pearlColor(info.pearlColor),
wheelsColor(info.wheelsColor),
interiorColor(info.interiorColor),
dashboardColor(info.dashboardColor),
extras(info.extras),
defaultExtras(info.defaultExtras),
hasAutoAttachTrailer(info.hasAutoAttachTrailer),
canAttachCars(info.canAttachCars){

modelType(info.modelType),
wheelsCount(info.wheelsCount),
hasArmoredWindows(info.hasArmoredWindows),
primaryColor(info.primaryColor),
secondaryColor(info.secondaryColor),
pearlColor(info.pearlColor),
wheelsColor(info.wheelsColor),
interiorColor(info.interiorColor),
dashboardColor(info.dashboardColor),
extras(info.extras),
defaultExtras(info.defaultExtras),
hasAutoAttachTrailer(info.hasAutoAttachTrailer),
canAttachCars(info.canAttachCars),
handlingNameHash(info.handlingNameHash)
{
size_t modkitsSize = std::size(info.modkits);
for(size_t i = 0; i < modkitsSize; i++)
for (size_t i = 0; i < modkitsSize; i++)
{
modkits[i] = info.modkits[i] != 0xFFFF;
}
Expand All @@ -54,12 +57,14 @@ struct ClrVehicleModelInfo {
const auto vehModelBones = info.bones;
boneSize = vehModelBones.size();
bones = new ClrBoneInfo[boneSize];
for (uint32_t i = 0; i < boneSize; i++) {
for (uint32_t i = 0; i < boneSize; i++)
{
bones[i] = ClrBoneInfo(vehModelBones[i]);
}
}

~ClrVehicleModelInfo() {
~ClrVehicleModelInfo()
{
delete[] title;
}
};
};
5 changes: 5 additions & 0 deletions c-api/entities/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,11 @@ alt::IAudioFilter* Player_GetFilter(alt::IPlayer* player)
return player->GetFilter();
}

const char* Player_GetTaskData(alt::IPlayer* player, int32_t& size)
{
return AllocateString(player->GetTaskData(), size);
}

#endif

CAPI_END()
4 changes: 3 additions & 1 deletion c-api/entities/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,6 @@ EXPORT_CLIENT void Player_AddFilter(alt::IPlayer* player, alt::IAudioFilter* fil
EXPORT_CLIENT void Player_RemoveFilter(alt::IPlayer* player);
EXPORT_CLIENT alt::IAudioFilter* Player_GetFilter(alt::IPlayer* player);

EXPORT_SHARED uint8_t Player_IsParachuting(alt::IPlayer* player);
EXPORT_SHARED uint8_t Player_IsParachuting(alt::IPlayer* player);

EXPORT_CLIENT const char* Player_GetTaskData(alt::IPlayer* player, int32_t& size);
24 changes: 23 additions & 1 deletion c-api/event.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
#include "event.h"

#include "mvalue.h"
#include "utils/macros.h"

CAPI_START()

#ifdef ALT_SERVER_API

void Event_WeaponDamageEvent_SetDamageValue(alt::CEvent* event, uint32_t damageValue) {
((alt::CWeaponDamageEvent*) event)->SetDamageValue(damageValue);
dynamic_cast<alt::CWeaponDamageEvent*>(event)->SetDamageValue(damageValue);
}

uint8_t Event_ClientScriptRPCEvent_WillAnswer(alt::CEvent* event)
{
auto rpcEvent = dynamic_cast<alt::CClientScriptRPCEvent*>(event);
return rpcEvent->WillAnswer();
}

uint8_t Event_ClientScriptRPCEvent_Answer(alt::CEvent* event, alt::MValueConst* answer)
{
if (answer == nullptr) return false;
auto rpcEvent = dynamic_cast<alt::CClientScriptRPCEvent*>(event);
return rpcEvent->Answer(answer->get()->Clone());
}

uint8_t Event_ClientScriptRPCEvent_AnswerWithError(alt::CEvent* event, const char* error)
{
auto rpcEvent = dynamic_cast<alt::CClientScriptRPCEvent*>(event);
return rpcEvent->AnswerWithError(error);
}
#endif

Expand Down Expand Up @@ -90,6 +110,8 @@ SetDelegate(PlayerBulletHit);
SetDelegate(VoiceConnection);
SetDelegate(AudioEvent);

SetDelegate(ServerScriptRPCAnswer)

#endif

CAPI_END()
4 changes: 4 additions & 0 deletions c-api/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

EXPORT_SHARED void Event_Cancel(alt::CCancellableEvent* event);
EXPORT_SERVER void Event_WeaponDamageEvent_SetDamageValue(alt::CEvent* event, uint32_t damageValue);
EXPORT_SERVER uint8_t Event_ClientScriptRPCEvent_WillAnswer(alt::CEvent* event);
EXPORT_SERVER uint8_t Event_ClientScriptRPCEvent_Answer(alt::CEvent* event, alt::MValueConst* answer);
EXPORT_SERVER uint8_t Event_ClientScriptRPCEvent_AnswerWithError(alt::CEvent* event, const char* error);
EXPORT_SHARED uint8_t Event_WasCancelled(alt::CCancellableEvent* event);

#ifdef ALT_CLIENT_API
Expand Down Expand Up @@ -92,4 +95,5 @@ EXPORT_CLIENT void Event_SetPlayerStartLeaveVehicleDelegate(CSharpResourceImpl*

EXPORT_CLIENT void Event_SetPlayerBulletHitDelegate(CSharpResourceImpl* resource, /** ClientEvents.PlayerBulletHitModuleDelegate */ PlayerBulletHitDelegate_t delegate);
EXPORT_CLIENT void Event_SetVoiceConnectionDelegate(CSharpResourceImpl* resource, /** ClientEvents.VoiceConnectionModuleDelegate */ VoiceConnectionDelegate_t delegate);
EXPORT_CLIENT void Event_SetServerScriptRPCAnswerDelegate(CSharpResourceImpl* resource, /** ClientEvents.ServerScriptRPCAnswerModuleDelegate */ ServerScriptRPCAnswerDelegate_t delegate);
#endif
Loading

0 comments on commit e86d6c3

Please sign in to comment.