Skip to content

Commit

Permalink
Merge branch 'rc' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Nov 19, 2024
2 parents 0597eb7 + 5cb28e9 commit def8d54
Show file tree
Hide file tree
Showing 11 changed files with 430 additions and 2 deletions.
7 changes: 7 additions & 0 deletions c-api/data/aabb.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once
#include "cpp-sdk/deps/alt-math/alt-math.h"

typedef struct {
alt::Position min;
alt::Position max;
} aabb_t;
6 changes: 6 additions & 0 deletions c-api/data/weapon_model_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct ClrWeaponModelInfo {
int32_t skillAbove50MaxAmmoMp = 0;
int32_t maxSkillMaxAmmoMp = 0;
int32_t bonusMaxAmmoMp = 0;
char* damageType = nullptr;

ClrWeaponModelInfo() = default;
ClrWeaponModelInfo(alt::WeaponModelInfo info) :
Expand Down Expand Up @@ -42,12 +43,17 @@ struct ClrWeaponModelInfo {
ammoModelName = new char[info.ammoModelName.length() + 1];
std::copy(info.ammoModelName.begin(), info.ammoModelName.end(), ammoModelName);
ammoModelName[info.ammoModelName.length()] = '\0';

damageType = new char[info.damageType.length() + 1];
std::copy(info.damageType.begin(), info.damageType.end(), damageType);
damageType[info.damageType.length()] = '\0';
}

~ClrWeaponModelInfo() {
delete[] name;
delete[] ammoType;
delete[] modelName;
delete[] ammoModelName;
delete[] damageType;
}
};
62 changes: 61 additions & 1 deletion 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 = 11629663074568386340UL;
inline uint64_t capiHash = 10075699596264467259UL;
inline uint64_t capiHashes[] = {
0,
#ifdef ALT_CLIENT_API
Expand Down Expand Up @@ -469,6 +469,36 @@ inline uint64_t capiHashes[] = {
8280976854604120523UL,
4939806300942583161UL,
12260251650657662947UL,
15230725921455826742UL,
9833874365185055719UL,
10883468373939012235UL,
15377866266281851140UL,
8232363457953011397UL,
2751756776126960023UL,
1814048572451154980UL,
13960987639501218250UL,
13352719488432116273UL,
4913927801862478282UL,
7285942813518470950UL,
1117662078157381260UL,
9560528769032004812UL,
13206342625351776081UL,
14268893542560810008UL,
3255950788253963043UL,
16182899257589323539UL,
15288926594136993761UL,
9853055316547927459UL,
12340070947493379575UL,
16837975631170049766UL,
8261388998032521861UL,
7856663484428066825UL,
15158102510225914020UL,
4739364089865431579UL,
4358271132564072471UL,
7499702612373464399UL,
12048596999299004349UL,
4102368831198906004UL,
7739810354326755506UL,
12723661681621738686UL,
12557963046901634258UL,
8482470825689546294UL,
Expand Down Expand Up @@ -2256,6 +2286,36 @@ inline void* capiPointers[] = {
(void*) HttpClient_Put,
(void*) HttpClient_SetExtraHeader,
(void*) HttpClient_Trace,
(void*) Interior_GetEntitiesExtents,
(void*) Interior_GetPortalCount,
(void*) Interior_GetPosition,
(void*) Interior_GetRoomCount,
(void*) Interior_GetRotation,
(void*) InteriorPortal_GetCornerCount,
(void*) InteriorPortal_GetCornerPosition,
(void*) InteriorPortal_GetEntityArcheType,
(void*) InteriorPortal_GetEntityCount,
(void*) InteriorPortal_GetEntityFlag,
(void*) InteriorPortal_GetEntityPosition,
(void*) InteriorPortal_GetEntityRotation,
(void*) InteriorPortal_GetFlag,
(void*) InteriorPortal_GetIndex,
(void*) InteriorPortal_GetRoomFrom,
(void*) InteriorPortal_GetRoomTo,
(void*) InteriorPortal_SetCornerPosition,
(void*) InteriorPortal_SetEntityFlag,
(void*) InteriorPortal_SetFlag,
(void*) InteriorPortal_SetRoomFrom,
(void*) InteriorPortal_SetRoomTo,
(void*) InteriorRoom_GetExtents,
(void*) InteriorRoom_GetFlag,
(void*) InteriorRoom_GetIndex,
(void*) InteriorRoom_GetName,
(void*) InteriorRoom_GetNameHash,
(void*) InteriorRoom_GetTimecycle,
(void*) InteriorRoom_SetExtents,
(void*) InteriorRoom_SetFlag,
(void*) InteriorRoom_SetTimecycle,
(void*) LocalObject_ActivatePhysics,
(void*) LocalObject_AttachToEntity,
(void*) LocalObject_AttachToEntity_ScriptId,
Expand Down
3 changes: 3 additions & 0 deletions c-api/func_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
#include "entities/local_ped.h"
#include "entities/font.h"
#include "entities/custom_texture.h"
#include "interior.h"
#include "interior_portal.h"
#include "interior_room.h"
#include <type_traits>

const function_table_t* get_func_table();
39 changes: 39 additions & 0 deletions c-api/interior.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "interior.h"

#include "utils/macros.h"

CAPI_START()

#ifdef ALT_CLIENT_API
uint16_t Interior_GetRoomCount(uint32_t interiorId)
{
auto interior = alt::ICore::Instance().GetInterior(interiorId);
return interior->GetRoomCount();
}

uint16_t Interior_GetPortalCount(uint32_t interiorId)
{
auto interior = alt::ICore::Instance().GetInterior(interiorId);
return interior->GetPortalCount();
}

alt::Position Interior_GetPosition(uint32_t interiorId)
{
auto interior = alt::ICore::Instance().GetInterior(interiorId);
return interior->GetPosition();
}

alt::Rotation Interior_GetRotation(uint32_t interiorId)
{
auto interior = alt::ICore::Instance().GetInterior(interiorId);
return interior->GetRotation();
}

void Interior_GetEntitiesExtents(uint32_t interiorId, aabb_t& extents)
{
auto interior = alt::ICore::Instance().GetInterior(interiorId);
auto ext = interior->GetEntitiesExtents();
extents.min = ext.min;
extents.max = ext.max;
}
#endif
29 changes: 29 additions & 0 deletions c-api/interior.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wempty-body"
#pragma clang diagnostic ignored "-Wswitch"
#endif

#include "cpp-sdk/SDK.h"
#include "data/aabb.h"
#include "data/types.h"
#include "data/invoker.h"
#include "utils/export.h"

#ifdef ALT_SERVER_API
#include <CSharpResourceImpl.h>
#elif ALT_CLIENT_API
#include "../client/src/runtime/CSharpResourceImpl.h"
#endif

#ifdef __clang__
#pragma clang diagnostic pop
#endif

EXPORT_CLIENT uint16_t Interior_GetRoomCount(uint32_t interiorId);
EXPORT_CLIENT uint16_t Interior_GetPortalCount(uint32_t interiorId);
EXPORT_CLIENT alt::Position Interior_GetPosition(uint32_t interiorId);
EXPORT_CLIENT alt::Rotation Interior_GetRotation(uint32_t interiorId);
EXPORT_CLIENT void Interior_GetEntitiesExtents(uint32_t interiorId, aabb_t& extents);
111 changes: 111 additions & 0 deletions c-api/interior_portal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#include "interior_portal.h"

#include "cpp-sdk/script-objects/IInteriorPortal.h"
#include "utils/macros.h"

CAPI_START()

#ifdef ALT_CLIENT_API
uint32_t InteriorPortal_GetIndex(uint32_t interiorId, uint32_t portalIndex)
{
auto portal = GetInteriorPortal(interiorId, portalIndex);
return portal->GetIndex();
}

uint16_t InteriorPortal_GetCornerCount(uint32_t interiorId, uint32_t portalIndex)
{
auto portal = GetInteriorPortal(interiorId, portalIndex);
return portal->GetCornerCount();
}

alt::Position InteriorPortal_GetCornerPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t cornerIndex)
{
auto portal = GetInteriorPortal(interiorId, portalIndex);
return portal->GetCornerPosition(cornerIndex);
}

uint32_t InteriorPortal_GetRoomFrom(uint32_t interiorId, uint32_t portalIndex)
{
auto portal = GetInteriorPortal(interiorId, portalIndex);
return portal->GetRoomFrom();
}

uint32_t InteriorPortal_GetRoomTo(uint32_t interiorId, uint32_t portalIndex)
{
auto portal = GetInteriorPortal(interiorId, portalIndex);
return portal->GetRoomTo();
}

int32_t InteriorPortal_GetFlag(uint32_t interiorId, uint32_t portalIndex)
{
auto portal = GetInteriorPortal(interiorId, portalIndex);
return portal->GetFlag();
}

uint16_t InteriorPortal_GetEntityCount(uint32_t interiorId, uint32_t portalIndex)
{
auto portal = GetInteriorPortal(interiorId, portalIndex);
return portal->GetEntityCount();
}

uint32_t InteriorPortal_GetEntityArcheType(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex)
{
auto portal = GetInteriorPortal(interiorId, portalIndex);
return portal->GetEntityArcheType(entityIndex);
}

int32_t InteriorPortal_GetEntityFlag(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex)
{
auto portal = GetInteriorPortal(interiorId, portalIndex);
return portal->GetEntityFlag(entityIndex);
}

alt::Position InteriorPortal_GetEntityPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex)
{
auto portal = GetInteriorPortal(interiorId, portalIndex);
return portal->GetEntityPosition(entityIndex);
}

alt::Rotation InteriorPortal_GetEntityRotation(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex)
{
auto portal = GetInteriorPortal(interiorId, portalIndex);
return portal->GetEntityRotation(entityIndex);
}

void InteriorPortal_SetCornerPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t cornerIndex,
position_t position)
{
auto portal = GetInteriorPortal(interiorId, portalIndex);
portal->SetCornerPosition(cornerIndex, alt::Position(position.x, position.y, position.z));
}

void InteriorPortal_SetRoomFrom(uint32_t interiorId, uint32_t portalIndex, uint32_t roomFrom)
{
auto portal = GetInteriorPortal(interiorId, portalIndex);
portal->SetRoomFrom(roomFrom);
}

void InteriorPortal_SetRoomTo(uint32_t interiorId, uint32_t portalIndex, uint32_t roomTo)
{
auto portal = GetInteriorPortal(interiorId, portalIndex);
portal->SetRoomTo(roomTo);
}

void InteriorPortal_SetFlag(uint32_t interiorId, uint32_t portalIndex, int32_t flag)
{
auto portal = GetInteriorPortal(interiorId, portalIndex);
portal->SetFlag(flag);
}

void InteriorPortal_SetEntityFlag(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex, int32_t flag)
{
auto portal = GetInteriorPortal(interiorId, portalIndex);
portal->SetEntityFlag(entityIndex, flag);
}

std::shared_ptr<alt::IInteriorPortal> GetInteriorPortal(uint32_t interiorId, uint32_t portalIndex)
{
auto interior = alt::ICore::Instance().GetInterior(interiorId);
return interior->GetPortalByIndex(portalIndex);
}
#endif
47 changes: 47 additions & 0 deletions c-api/interior_portal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once

#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wempty-body"
#pragma clang diagnostic ignored "-Wswitch"
#endif

#include "cpp-sdk/SDK.h"
#include "data/aabb.h"
#include "data/types.h"
#include "data/invoker.h"
#include "utils/export.h"

#ifdef ALT_SERVER_API
#include <CSharpResourceImpl.h>
#elif ALT_CLIENT_API
#include "../client/src/runtime/CSharpResourceImpl.h"
#endif

#ifdef __clang__
#pragma clang diagnostic pop
#endif

EXPORT_CLIENT uint32_t InteriorPortal_GetIndex(uint32_t interiorId, uint32_t portalIndex);
EXPORT_CLIENT uint16_t InteriorPortal_GetCornerCount(uint32_t interiorId, uint32_t portalIndex);
EXPORT_CLIENT alt::Position InteriorPortal_GetCornerPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t cornerIndex);
EXPORT_CLIENT uint32_t InteriorPortal_GetRoomFrom(uint32_t interiorId, uint32_t portalIndex);
EXPORT_CLIENT uint32_t InteriorPortal_GetRoomTo(uint32_t interiorId, uint32_t portalIndex);
EXPORT_CLIENT int32_t InteriorPortal_GetFlag(uint32_t interiorId, uint32_t portalIndex);

EXPORT_CLIENT uint16_t InteriorPortal_GetEntityCount(uint32_t interiorId, uint32_t portalIndex);
EXPORT_CLIENT uint32_t InteriorPortal_GetEntityArcheType(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex);
EXPORT_CLIENT int32_t InteriorPortal_GetEntityFlag(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex);
EXPORT_CLIENT alt::Position InteriorPortal_GetEntityPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex);
EXPORT_CLIENT alt::Rotation InteriorPortal_GetEntityRotation(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex);


EXPORT_CLIENT void InteriorPortal_SetCornerPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t cornerIndex, position_t position);
EXPORT_CLIENT void InteriorPortal_SetRoomFrom(uint32_t interiorId, uint32_t portalIndex, uint32_t roomFrom);
EXPORT_CLIENT void InteriorPortal_SetRoomTo(uint32_t interiorId, uint32_t portalIndex, uint32_t roomTo);
EXPORT_CLIENT void InteriorPortal_SetFlag(uint32_t interiorId, uint32_t portalIndex, int32_t flag);
EXPORT_CLIENT void InteriorPortal_SetEntityFlag(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex, int32_t flag);

#ifdef ALT_CLIENT_API
std::shared_ptr<alt::IInteriorPortal> GetInteriorPortal(uint32_t interiorId, uint32_t portalIndex);
#endif
Loading

0 comments on commit def8d54

Please sign in to comment.