From 19c0f0568a792557ac36fbfff4457dab7ff786e7 Mon Sep 17 00:00:00 2001 From: Till Schreiber Date: Thu, 16 Jan 2025 15:47:33 +0100 Subject: [PATCH 1/6] Altv 641 (#346) * ALTV-641 - add IsOnVehicle() Getter * ALTV-641 update sdk --- server/src/bindings/Player.cpp | 1 + shared/deps/cpp-sdk | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/bindings/Player.cpp b/server/src/bindings/Player.cpp index 063527a1..6f628cff 100644 --- a/server/src/bindings/Player.cpp +++ b/server/src/bindings/Player.cpp @@ -1615,6 +1615,7 @@ extern V8Class v8Player("Player", V8Helpers::SetMethod(isolate, tpl, "removeDecoration", &RemoveDecoration); V8Helpers::SetMethod(isolate, tpl, "clearDecorations", &ClearDecorations); V8Helpers::SetMethod(isolate, tpl, "getDecorations", &GetDecorations); + V8Helpers::SetAccessor(isolate, tpl, "isOnVehicle"); V8Helpers::SetAccessor(isolate, tpl, "netOwnershipDisabled"); }); diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index 3df49e42..d5453484 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit 3df49e42866c672c869feeafdd589fb4f34698a1 +Subproject commit d5453484571e1862e3d8adf4d6814891ec98612c From 5c5d679721072cefb7e7b2917662b1c6e4da5528 Mon Sep 17 00:00:00 2001 From: OlegT Date: Sat, 18 Jan 2025 01:47:34 +0300 Subject: [PATCH 2/6] ALTV-652 Add build and deploy to custom branch --- .github/workflows/build-deploy-custom.yml | 269 ++++++++++++++++++++++ 1 file changed, 269 insertions(+) create mode 100644 .github/workflows/build-deploy-custom.yml diff --git a/.github/workflows/build-deploy-custom.yml b/.github/workflows/build-deploy-custom.yml new file mode 100644 index 00000000..ab2f8a4b --- /dev/null +++ b/.github/workflows/build-deploy-custom.yml @@ -0,0 +1,269 @@ +name: Build & deploy server to custom CDN branch +on: + workflow_dispatch: + inputs: + cdn_branch: + description: 'CDN branch' + required: true + version: + description: 'Version' + required: true + +jobs: + build-windows: + name: Build windows release + runs-on: windows-2019 + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Extract version + id: version + shell: bash + run: | + TAG=${GITHUB_REF/refs\/tags\//} + echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT + echo "BRANCH=${{ github.event.inputs.cdn_branch }}" >> $GITHUB_OUTPUT + + - name: Build + shell: cmd + run: | + cd server + build.bat 0 %VERSION% + env: + VERSION: ${{ steps.version.outputs.VERSION }} + + - name: Copy files + shell: cmd + run: | + cd server + mkdir upload\modules\js-module + mkdir debug + copy dist\js-module.dll upload\modules\js-module + copy dist\libnode.dll upload\modules\js-module + copy dist\js-module.pdb debug + + - uses: actions/upload-artifact@v3 + with: + name: js-module-windows + path: ./server/upload/ + + - uses: actions/upload-artifact@v3 + with: + name: js-module-windows-debug + path: ./server/debug + + build-linux: + name: Build linux release + runs-on: ubuntu-20.04 + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Extract version + id: version + shell: bash + run: | + TAG=${GITHUB_REF/refs\/tags\//} + echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT + echo "BRANCH=${{ github.event.inputs.cdn_branch }}" >> $GITHUB_OUTPUT + cd shared/deps/cpp-sdk + echo "SDK_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: Build + run: | + cd server + ./build.sh %VERSION% + env: + VERSION: ${{ steps.version.outputs.VERSION }} + + - name: Copy files + run: | + cd server + mkdir -p upload/modules/js-module + cp ./dist/libjs-module.so ./upload/modules/js-module + cp ./dist/libnode.so ./upload/modules/js-module + echo ${{ steps.version.outputs.SDK_COMMIT }} >> ./upload/sdk.version + + - uses: actions/upload-artifact@v3 + with: + name: js-module-linux + path: ./server/upload/ + + deploy-cdn: + name: Deploy release to alt:V CDN + runs-on: ubuntu-20.04 + needs: [build-linux, build-windows] + steps: + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 16.x + + - name: Cache node_modules + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ${{ runner.os }} + + - name: Download windows artifacts + uses: actions/download-artifact@v3 + with: + name: js-module-windows + path: dist-windows + + - name: Download linux artifacts + uses: actions/download-artifact@v3 + with: + name: js-module-linux + path: dist-linux + + - name: Extract version + id: version + shell: bash + run: | + TAG=${GITHUB_REF/refs\/tags\//} + echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT + echo "BRANCH=${{ github.event.inputs.cdn_branch }}" >> $GITHUB_OUTPUT + echo "SDK_VERSION=$(cat dist-linux/sdk.version)" >> $GITHUB_OUTPUT + rm dist-linux/sdk.version + + - name: Install upload tool + run: npm i @altmp/upload-tool@latest fast-xml-parser@4.3.6 + + - name: Deploy windows artifacts to cdn + run: npx alt-upload dist-windows js-module/$BRANCH/x64_win32 $VERSION $SDK_VERSION + env: + AWS_KEY_ID: ${{ secrets.AWS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_BUCKET: ${{ secrets.AWS_BUCKET }} + AWS_ENDPOINT: ${{ secrets.AWS_ENDPOINT }} + CF_CACHE_PURGE_TOKEN: ${{ secrets.CF_CACHE_PURGE_TOKEN }} + CF_CACHE_ZONE_ID: ${{ secrets.CF_CACHE_ZONE_ID }} + CF_CACHE_PURGE_URL: ${{ secrets.CF_CACHE_PURGE_URL }} + BRANCH: ${{ steps.version.outputs.BRANCH }} + VERSION: ${{ steps.version.outputs.VERSION }} + SDK_VERSION: ${{ steps.version.outputs.SDK_VERSION }} + + - name: Deploy linux artifacts to cdn + run: npx alt-upload dist-linux js-module/$BRANCH/x64_linux $VERSION $SDK_VERSION + env: + AWS_KEY_ID: ${{ secrets.AWS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_BUCKET: ${{ secrets.AWS_BUCKET }} + AWS_ENDPOINT: ${{ secrets.AWS_ENDPOINT }} + CF_CACHE_PURGE_TOKEN: ${{ secrets.CF_CACHE_PURGE_TOKEN }} + CF_CACHE_ZONE_ID: ${{ secrets.CF_CACHE_ZONE_ID }} + CF_CACHE_PURGE_URL: ${{ secrets.CF_CACHE_PURGE_URL }} + BRANCH: ${{ steps.version.outputs.BRANCH }} + VERSION: ${{ steps.version.outputs.VERSION }} + SDK_VERSION: ${{ steps.version.outputs.SDK_VERSION }} + + build-docker: + name: Trigger Docker image build + runs-on: ubuntu-latest + needs: [deploy-cdn] + steps: + - name: Get Token + id: get_workflow_token + uses: peter-murray/workflow-application-token-action@v2 + with: + application_id: ${{ secrets.CI_APP_ID }} + application_private_key: ${{ secrets.CI_APP_PRIVATE_KEY }} + permissions: "actions:write" + organization: altmp + + - name: Trigger Docker build + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: build.yml + ref: main + repo: altmp/altv-docker + token: ${{ steps.get_workflow_token.outputs.token }} + + create-release: + name: Create GitHub Release + runs-on: ubuntu-20.04 + needs: [build-linux, build-windows] + steps: + - name: Download windows artifacts + uses: actions/download-artifact@v3 + with: + name: js-module-windows + path: dist-windows + + - name: Download windows debug artifacts + uses: actions/download-artifact@v3 + with: + name: js-module-windows-debug + path: dist-windows + + - name: Download linux artifacts + uses: actions/download-artifact@v3 + with: + name: js-module-linux + path: dist-linux + + - name: Extract version + id: version + shell: bash + run: | + TAG=${GITHUB_REF/refs\/tags\//} + echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT + echo "BRANCH=${{ github.event.inputs.cdn_branch }}" >> $GITHUB_OUTPUT + echo "SDK_COMMIT=$(cat dist-linux/sdk.version)" >> $GITHUB_OUTPUT + rm dist-linux/sdk.version + + - name: Zip artifacts + run: | + zip -r -j js-module-windows dist-windows + zip -r -j js-module-linux dist-linux + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ steps.version.outputs.VERSION }} + body: | + SDK version: [${{ steps.version.outputs.SDK_COMMIT }}](https://github.com/altmp/cpp-sdk/commit/${{ steps.version.outputs.SDK_COMMIT }}) + + - name: Upload windows artifacts + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./js-module-windows.zip + asset_name: js-module-windows.zip + asset_content_type: application/zip + + - name: Upload linux artifacts + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./js-module-linux.zip + asset_name: js-module-linux.zip + asset_content_type: application/zip + + delete-artifacts: + name: Delete artifacts + runs-on: ubuntu-20.04 + needs: [ create-release, deploy-cdn ] + if: ${{ always() }} + steps: + - name: Delete artifacts + uses: geekyeggo/delete-artifact@v2 + with: + name: | + js-module-linux + js-module-windows + js-module-windows-debug From 95bae6d02e9f5c92dc44dd0641b2c9e54003e89e Mon Sep 17 00:00:00 2001 From: Till Schreiber Date: Sun, 19 Jan 2025 11:37:14 +0100 Subject: [PATCH 3/6] ALTV-627 - make Wheel-Api for server --- server/src/bindings/Vehicle.cpp | 127 ++++++++++++++++++++++++++++++++ shared/deps/cpp-sdk | 2 +- 2 files changed, 128 insertions(+), 1 deletion(-) diff --git a/server/src/bindings/Vehicle.cpp b/server/src/bindings/Vehicle.cpp index 71c9e1b0..13f1ee9a 100644 --- a/server/src/bindings/Vehicle.cpp +++ b/server/src/bindings/Vehicle.cpp @@ -307,6 +307,120 @@ static void SetBadge(const v8::FunctionCallbackInfo& info) _this->SetBadge(textureDictionary, texture, positions); } +static void GetWheelCamber(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle); + V8_CHECK_ARGS_LEN(1); + V8_ARG_TO_INT(1, wheel); + V8_RETURN_NUMBER(vehicle->GetWheelCamber(wheel)); +} + +static void SetWheelCamber(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle); + V8_CHECK_ARGS_LEN(2); + V8_ARG_TO_INT(1, wheel); + V8_ARG_TO_NUMBER(2, value); + vehicle->SetWheelCamber(wheel, value); +} + +static void GetWheelTrackWidth(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle); + V8_CHECK_ARGS_LEN(1); + V8_ARG_TO_INT(1, wheel); + V8_RETURN_NUMBER(vehicle->GetWheelTrackWidth(wheel)); +} + +static void SetWheelTrackWidth(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle); + V8_CHECK_ARGS_LEN(2); + V8_ARG_TO_INT(1, wheel); + V8_ARG_TO_NUMBER(2, value); + vehicle->SetWheelTrackWidth(wheel, value); +} + +static void GetWheelHeight(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle); + V8_CHECK_ARGS_LEN(1); + V8_ARG_TO_INT(1, wheel); + V8_RETURN_NUMBER(vehicle->GetWheelHeight(wheel)); +} + +static void SetWheelHeight(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle); + V8_CHECK_ARGS_LEN(2); + V8_ARG_TO_INT(1, wheel); + V8_ARG_TO_NUMBER(2, value); + vehicle->SetWheelHeight(wheel, value); +} + +static void GetWheelTyreRadius(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle); + V8_CHECK_ARGS_LEN(1); + V8_ARG_TO_INT(1, wheel); + V8_RETURN_NUMBER(vehicle->GetWheelTyreRadius(wheel)); +} + +static void SetWheelTyreRadius(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle); + V8_CHECK_ARGS_LEN(2); + V8_ARG_TO_INT(1, wheel); + V8_ARG_TO_NUMBER(2, value); + vehicle->SetWheelTyreRadius(wheel, value); +} + +static void GetWheelRimRadius(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle); + V8_CHECK_ARGS_LEN(1); + V8_ARG_TO_INT(1, wheel); + V8_RETURN_NUMBER(vehicle->GetWheelRimRadius(wheel)); +} + +static void SetWheelRimRadius(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle); + V8_CHECK_ARGS_LEN(2); + V8_ARG_TO_INT(1, wheel); + V8_ARG_TO_NUMBER(2, value); + vehicle->SetWheelRimRadius(wheel, value); +} + +static void GetWheelTyreWidth(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle); + V8_CHECK_ARGS_LEN(1); + V8_ARG_TO_INT(1, wheel); + V8_RETURN_NUMBER(vehicle->GetWheelTyreWidth(wheel)); +} + +static void SetWheelTyreWidth(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(vehicle, alt::IVehicle); + V8_CHECK_ARGS_LEN(2); + V8_ARG_TO_INT(1, wheel); + V8_ARG_TO_NUMBER(2, value); + vehicle->SetWheelTyreWidth(wheel, value); +} + extern V8Class v8Entity; extern V8Class v8Vehicle("Vehicle", v8Entity, @@ -495,4 +609,17 @@ extern V8Class v8Vehicle("Vehicle", V8Helpers::SetAccessor(isolate, tpl, "hybridExtraActive"); V8Helpers::SetAccessor(isolate, tpl, "hybridExtraState"); V8Helpers::SetMethod(isolate, tpl, "setBadge", &SetBadge); + + V8Helpers::SetMethod(isolate, tpl, "getWheelCamber", GetWheelCamber); + V8Helpers::SetMethod(isolate, tpl, "setWheelCamber", SetWheelCamber); + V8Helpers::SetMethod(isolate, tpl, "getWheelTrackWidth", GetWheelTrackWidth); + V8Helpers::SetMethod(isolate, tpl, "setWheelTrackWidth", SetWheelTrackWidth); + V8Helpers::SetMethod(isolate, tpl, "getWheelHeight", GetWheelHeight); + V8Helpers::SetMethod(isolate, tpl, "setWheelHeight", SetWheelHeight); + V8Helpers::SetMethod(isolate, tpl, "getWheelTyreRadius", GetWheelTyreRadius); + V8Helpers::SetMethod(isolate, tpl, "setWheelTyreRadius", SetWheelTyreRadius); + V8Helpers::SetMethod(isolate, tpl, "getWheelRimRadius", GetWheelRimRadius); + V8Helpers::SetMethod(isolate, tpl, "setWheelRimRadius", SetWheelRimRadius); + V8Helpers::SetMethod(isolate, tpl, "getWheelTyreWidth", GetWheelTyreWidth); + V8Helpers::SetMethod(isolate, tpl, "setWheelTyreWidth", SetWheelTyreWidth); }); diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index d5453484..c4c3ba07 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit d5453484571e1862e3d8adf4d6814891ec98612c +Subproject commit c4c3ba074efe7fa83e68e8aab1056a8aa615d42c From 8f91c19c4a2494ec91740f3e73b671fbc606c7d7 Mon Sep 17 00:00:00 2001 From: OlegT Date: Mon, 20 Jan 2025 12:10:29 +0300 Subject: [PATCH 4/6] ALTV-627 Update cpp-sdk refs --- shared/deps/cpp-sdk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index c4c3ba07..000b5d5b 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit c4c3ba074efe7fa83e68e8aab1056a8aa615d42c +Subproject commit 000b5d5b9868d3491274e65884071d56877d1b93 From 29e02ce6ef767aecc752839cefddd4f53a822e14 Mon Sep 17 00:00:00 2001 From: vadzz Date: Thu, 30 Jan 2025 12:59:05 +0300 Subject: [PATCH 5/6] ALTV-603 | bump sdk --- shared/deps/cpp-sdk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index 000b5d5b..81e85576 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit 000b5d5b9868d3491274e65884071d56877d1b93 +Subproject commit 81e855762a701dd47fedb5c9a48d7799a11b1863 From 4532386678b1c961f2ec3500cd9737b2ca6dafcd Mon Sep 17 00:00:00 2001 From: OlegTrofimov Date: Thu, 30 Jan 2025 22:26:50 +0300 Subject: [PATCH 6/6] ALTV-603 Update refs cpp-sdk (#350) Update actions/download-artifact to 4 Update actions/upload-artifact to 4 --- .github/workflows/build-deploy.yml | 16 ++++++++-------- shared/deps/cpp-sdk | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 7f100b8a..53b29431 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -44,12 +44,12 @@ jobs: copy dist\libnode.dll upload\modules\js-module copy dist\js-module.pdb debug - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: js-module-windows path: ./server/upload/ - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: js-module-windows-debug path: ./server/debug @@ -88,7 +88,7 @@ jobs: cp ./dist/libnode.so ./upload/modules/js-module echo ${{ steps.version.outputs.SDK_COMMIT }} >> ./upload/sdk.version - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: js-module-linux path: ./server/upload/ @@ -110,13 +110,13 @@ jobs: key: ${{ runner.os }} - name: Download windows artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: js-module-windows path: dist-windows - name: Download linux artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: js-module-linux path: dist-linux @@ -190,19 +190,19 @@ jobs: needs: [build-linux, build-windows] steps: - name: Download windows artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: js-module-windows path: dist-windows - name: Download windows debug artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: js-module-windows-debug path: dist-windows - name: Download linux artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: js-module-linux path: dist-linux diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index 81e85576..2004269e 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit 81e855762a701dd47fedb5c9a48d7799a11b1863 +Subproject commit 2004269e5121ff82ba949d1774a6975c4aa56d8a