Skip to content

Commit

Permalink
merge rc into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Oct 20, 2023
2 parents 602ac81 + d91cedf commit f6ad842
Show file tree
Hide file tree
Showing 136 changed files with 11,056 additions and 4,586 deletions.
168 changes: 168 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
name: Build client and server

on:
push:

jobs:
fetch-nethost-linux:
runs-on: ubuntu-22.04
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Setup .NET Core
shell: pwsh
run: |
.\download_dotnet.ps1 ${{ runner.temp }} linux
- name: Upload artifacts
uses: actions/upload-artifact@v3
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
- name: Setup .NET Core
shell: pwsh
run: |
.\download_dotnet.ps1 ${{ runner.temp }} win
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: nethost-windows
path: ${{ runner.temp }}\libnethost.tar
build-server:
runs-on: ${{ matrix.config.os }}
needs: [fetch-nethost-linux, fetch-nethost-windows]
strategy:
matrix:
config:
- {
name: linux,
os: ubuntu-20.04,
cc: gcc-9,
cxx: g++-9,
args: -DCMAKE_BUILD_TYPE=RelWithDebInfo,
nethost: nethost-linux,
}
- {
name: windows,
os: windows-latest,
cc: cl,
cxx: cl,
args: -DCMAKE_BUILD_TYPE=RelWithDebInfo -A x64 -T host=x64,
nethost: nethost-windows,
}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/download-artifact@v3
with:
name: ${{ matrix.config.nethost }}
path: ./nethost
- working-directory: ./nethost
shell: bash
run: |
tar xvf libnethost.tar
ls -l
pwd
- working-directory: ./server
shell: cmake -P {0}
run: |
set(ENV{CC} ${{ matrix.config.cc }})
set(ENV{CXX} ${{ matrix.config.cxx }})
file(MAKE_DIRECTORY build)
execute_process(
COMMAND cmake .. ${{ matrix.config.args }}
RESULT_VARIABLE result
WORKING_DIRECTORY build
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
- working-directory: ./server
shell: bash
run: cmake --build build --config RelWithDebInfo
- if: ${{ runner.os == 'Linux' }}
shell: bash
run: |
mkdir -p modules/linux/modules/
cp ./server/build/src/libcsharp-module.so ./modules/linux/modules
- if: ${{ runner.os == 'Windows' }}
shell: bash
run: |
mkdir -p modules/windows/modules/
cp ./server/build/src/RelWithDebInfo/csharp-module.dll ./modules/windows/modules
cp ./server/build/src/RelWithDebInfo/csharp-module.pdb ./modules/windows/modules
- id: create_archive
shell: bash
run: |
filename=$(echo "${{ matrix.config.name }}")
tar -cvf ./$filename.tar modules/$filename/modules
echo "art_name=$filename" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v3
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
with:
submodules: recursive
- uses: actions/download-artifact@v3
with:
name: nethost-windows
path: ./nethost
- working-directory: ./nethost
shell: bash
run: |
tar xvf libnethost.tar
ls -l
pwd
- working-directory: ./client
shell: cmake -P {0}
run: |
set(ENV{CC} cl)
set(ENV{CXX} cl)
file(MAKE_DIRECTORY build )
execute_process(
COMMAND cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -A x64 -T host=x64 -DDYNAMIC_BUILD=1
RESULT_VARIABLE result
WORKING_DIRECTORY build
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
- working-directory: ./client
shell: bash
run: cmake --build build --config RelWithDebInfo
- shell: bash
run: |
mkdir -p client/windows/client/
cp ./client/build/RelWithDebInfo/altv-client-csharp.dll ./client/windows/client
- id: create_archive
shell: bash
run: |
tar -cvf ./$filename.tar client/windows/client
echo "art_name=$filename" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v3
with:
name: client-windows
path: ./${{ steps.create_archive.outputs.art_name }}.tar
cleanup:
runs-on: ubuntu-latest
needs: [build-server, build-client]
if: ${{ always() }}
steps:
- uses: geekyeggo/delete-artifact@v2
with:
name: |
nethost-linux
nethost-windows
csharp-module-linux
csharp-module-windows
client-windows
111 changes: 91 additions & 20 deletions c-api/altv.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "altv.h"

#include "data/types.h"
#include "utils/macros.h"
#include "version/version.h"
#if defined ALTV_CSHARP_SHARED || defined ALT_SERVER_API
#include "cpp-sdk/version/version.h"
Expand All @@ -19,28 +20,12 @@
#pragma clang diagnostic pop
#endif

using alt::Array;
CAPI_START()

void FreeUIntArray(alt::Array<uint32_t>* array) {
array->~Array<uint32_t>();
void FreeUIntArray(std::vector<uint32_t>* array) {
array->clear();
}

/*void FreeStringViewArray(alt::Array<std::stringView>* array) {
array->~Array<std::stringView>();
}*/

/*void FreeStringArray(alt::Array<std::string>* array) {
array->~Array<std::string>();
}*/

/*void FreeMValueArray(alt::Array<alt::MValue>* array) {
array->~Array<alt::MValue>();
}*/

/*void FreePlayerPointerArray(alt::Array<alt::IPlayer*>* array) {
array->~Array<alt::IPlayer*>();
}*/

void FreeCharArray(char charArray[]) {
delete[] charArray;
}
Expand All @@ -53,6 +38,11 @@ void FreeUInt8Array(uint8_t uInt8Array[]) {
delete[] uInt8Array;
}

void FreeVector2Array(vector2_t* vector2Array)
{
delete[] vector2Array;
}

void FreeVoidPointerArray(void* voidPointerArray[]) {
delete[] voidPointerArray;
}
Expand All @@ -75,10 +65,79 @@ void FreeResourceArray(alt::IResource** resourceArray) {
delete[] resourceArray;
}

void FreeObjectArray(alt::IObject** objectArray) {
void FreePlayerArray(alt::IPlayer** playerArray) {
delete[] playerArray;
}

void FreeBlipArray(alt::IBlip** blipArray)
{
delete[] blipArray;
}

void FreeVehicleArray(alt::IVehicle** vehicleArray)
{
delete[] vehicleArray;
}

void FreePedArray(alt::IPed** pedArray)
{
delete[] pedArray;
}

void FreeNetworkObjectArray(alt::IObject** networkObjectArray)
{
delete[] networkObjectArray;
}

void FreeColShapeArray(alt::IColShape** colShapeArray)
{
delete[] colShapeArray;
}

void FreeMarkerArray(alt::IMarker** markerArray)
{
delete[] markerArray;
}

void FreeTextLabelArray(alt::ITextLabel** textLabelArray)
{
delete[] textLabelArray;
}

void FreeCheckpointArray(alt::ICheckpoint** checkPointArray)
{
delete[] checkPointArray;
}

void FreeVirtualEntityArray(alt::IVirtualEntity** virtualEntityArray)
{
delete[] virtualEntityArray;
}

void FreeVirtualEntityGroupArray(alt::IVirtualEntityGroup** virtualEntityGroupArray)
{
delete[] virtualEntityGroupArray;
}

void FreeConnectionInfoArray(alt::IConnectionInfo** connectionInfoArray)
{
delete[] connectionInfoArray;
}

void FreeLocalObjectArray(alt::ILocalObject** objectArray) {
delete[] objectArray;
}

void FreeAudioArray(alt::IAudio** audioArray)
{
delete[] audioArray;
}

void FreeAudioOutputArray(alt::IAudioOutput** audioOutputArray)
{
delete[] audioOutputArray;
}

void FreeMValueConstArray(alt::MValueConst** mValueConstArray) {
delete[] mValueConstArray;
}
Expand Down Expand Up @@ -112,6 +171,16 @@ void FreeRmlElementArray(alt::IRmlElement** rmlElementArray) {
delete[] rmlElementArray;
}

void FreeLocalVehicleArray(alt::ILocalVehicle** localVehicleArray)
{
delete[] localVehicleArray;
}

void FreeLocalPedArray(alt::ILocalPed** localPedArray)
{
delete[] localPedArray;
}

void* Win_GetTaskDialog() {
char *pValue;
size_t len;
Expand All @@ -131,3 +200,5 @@ void* Win_GetTaskDialog() {
}

#endif

CAPI_END()
21 changes: 19 additions & 2 deletions c-api/altv.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,35 @@
#include "cpp-sdk/SDK.h"
#include "data/types.h"

EXPORT_SHARED void FreeUIntArray(alt::Array<uint32_t> *array);
EXPORT_SHARED void FreeUIntArray(std::vector<uint32_t> *array);
//EXPORT void FreePlayerPointerArray(alt::Array<alt::IPlayer*> *array);
//EXPORT void FreeStringViewArray(alt::Array<std::stringView> *array);
//EXPORT void FreeStringArray(alt::Array<std::string>* array);
/*EXPORT void FreeMValueArray(alt::Array<alt::MValue> *array);*/
EXPORT_SHARED void FreeCharArray(char charArray[]);
EXPORT_SHARED void FreeUInt32Array(/** nint */ uint32_t* uInt32Array);
EXPORT_SHARED void FreeUInt8Array(/** nint */ uint8_t* uInt8Array);
EXPORT_SHARED void FreeVector2Array(/** nint */ vector2_t* vector2Array);
EXPORT_SHARED void FreeVoidPointerArray(/** nint */void** voidPointerArray);
EXPORT_SHARED void FreeWeaponTArray(/** nint */ weapon_t* weaponArray, uint32_t size);
EXPORT_SHARED void FreeString(const char* string);
EXPORT_SHARED void FreeStringArray(const char** stringArray, uint32_t size);
EXPORT_SHARED void FreeResourceArray(alt::IResource** resourceArray);
EXPORT_SHARED void FreeObjectArray(alt::IObject** objectArray);
EXPORT_SHARED void FreePlayerArray(alt::IPlayer** playerArray);
EXPORT_SHARED void FreeBlipArray(alt::IBlip** blipArray);
EXPORT_SHARED void FreeVehicleArray(alt::IVehicle** vehicleArray);
EXPORT_SHARED void FreePedArray(alt::IPed** pedArray);
EXPORT_SHARED void FreeNetworkObjectArray(alt::IObject** networkObjectArray);
EXPORT_SHARED void FreeColShapeArray(alt::IColShape** colShapeArray);
EXPORT_SHARED void FreeMarkerArray(alt::IMarker** markerArray);
EXPORT_SHARED void FreeTextLabelArray(alt::ITextLabel** textLabelArray);
EXPORT_SHARED void FreeCheckpointArray(alt::ICheckpoint** checkpointArray);
EXPORT_SHARED void FreeVirtualEntityArray(alt::IVirtualEntity** virtualEntityArray);
EXPORT_SHARED void FreeVirtualEntityGroupArray(alt::IVirtualEntityGroup** virtualEntityGroupArray);
EXPORT_SHARED void FreeConnectionInfoArray(alt::IConnectionInfo** connectionInfoArray);
EXPORT_SHARED void FreeLocalObjectArray(alt::ILocalObject** objectArray);
EXPORT_SHARED void FreeAudioArray(alt::IAudio** audioArray);
EXPORT_SHARED void FreeAudioOutputArray(alt::IAudioOutput** audioOutputArray);
EXPORT_SHARED void FreeMValueConstArray(alt::MValueConst** mvalueConstArray);
EXPORT_SHARED const char* GetVersionStatic(int32_t &size);
EXPORT_SHARED const char* GetBranchStatic(int32_t &size);
Expand All @@ -27,4 +42,6 @@ EXPORT_SHARED const char* GetCApiVersion(int32_t &size);
EXPORT_SHARED const char* GetSDKVersion(int32_t &size);

EXPORT_CLIENT void FreeRmlElementArray(alt::IRmlElement** rmlElementArray);
EXPORT_CLIENT void FreeLocalVehicleArray(alt::ILocalVehicle** localVehicleArray);
EXPORT_CLIENT void FreeLocalPedArray(alt::ILocalPed** localPedArray);
EXPORT_CLIENT void* Win_GetTaskDialog();
Loading

0 comments on commit f6ad842

Please sign in to comment.