mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-07-13 18:24:16 +00:00
Compare commits
76 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d274535f83 | |||
| 9915c83363 | |||
| 9f5a30a871 | |||
| 6832fd05d6 | |||
| c6aa7776fc | |||
| b0f5976121 | |||
| 1bd47fa649 | |||
| 0e924d0d51 | |||
| 70a7a41882 | |||
| 6ee816d10d | |||
| 8695413211 | |||
| 52c5a995cc | |||
| 9d5568dc56 | |||
| c62a1b6add | |||
| 4228e18c90 | |||
| 023e968302 | |||
| a4eb10b6a4 | |||
| 0166e488d0 | |||
| 0836fd3af8 | |||
| 9791b8875c | |||
| 01e8a1644a | |||
| cebb2634a1 | |||
| 21a7ca1b64 | |||
| bd4ab2b10d | |||
| 1cdc8e8f48 | |||
| 1f72a45231 | |||
| 002223afda | |||
| ecc79b1918 | |||
| d5000aea87 | |||
| 810788a3e4 | |||
| e724a2e467 | |||
| 54ba295fce | |||
| f419550061 | |||
| 8cccbe8542 | |||
| 6787843b37 | |||
| 16d3c6f796 | |||
| 21e5101560 | |||
| 1adf19d416 | |||
| c7e228fbae | |||
| 6e04b2d93a | |||
| 57a4c47cb0 | |||
| 416e0399af | |||
| 050b574cc0 | |||
| d65f3cf75b | |||
| 329d2eb268 | |||
| 221f491019 | |||
| 89db370e12 | |||
| aa84a65546 | |||
| b28c69a515 | |||
| ac41547123 | |||
| 2fc610f6bc | |||
| ddd3883aa9 | |||
| defadf094f | |||
| 81299db946 | |||
| c3895ec1ca | |||
| c741fe5310 | |||
| e1dfb1085e | |||
| 142b6fa47a | |||
| a6cbffc774 | |||
| dc4ead532d | |||
| f28d9bc7dc | |||
| 8c73eb8aea | |||
| 43b1b050e2 | |||
| 9f87edc6e9 | |||
| c6f78c5522 | |||
| 9f01268538 | |||
| 5523a4fe4b | |||
| 7f11d0f002 | |||
| 6b31ba35fd | |||
| d2329f0723 | |||
| ef45efeb86 | |||
| edcca75637 | |||
| c1bacf1f3a | |||
| 795b651744 | |||
| be108bb8b3 | |||
| d8b8812026 |
@@ -1,7 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: Bug report
|
name: Bug report
|
||||||
about: Create a report to help us improve
|
about: Create a report to help us improve
|
||||||
title: "[Bug] Enter issue title here"
|
|
||||||
labels: bug
|
labels: bug
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: Feature request
|
name: Feature request
|
||||||
about: Suggest an idea for this project
|
about: Suggest an idea for this project
|
||||||
title: "[Feature Request]"
|
labels: feature
|
||||||
labels: enhancement
|
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
+70
-68
@@ -2,15 +2,33 @@ name: Linux
|
|||||||
|
|
||||||
on: [push]
|
on: [push]
|
||||||
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
||||||
|
VCPKG_FORCE_SYSTEM_BINARIES: 1
|
||||||
|
CMAKE_BUILD_TYPE: "Release"
|
||||||
|
DEBIAN_FRONTEND: "noninteractive"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
debian-11-build:
|
x86_64-matrix:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- distro: debian
|
||||||
|
version: 11
|
||||||
|
- distro: debian
|
||||||
|
version: 12
|
||||||
|
- distro: ubuntu
|
||||||
|
version: 22.04
|
||||||
|
- distro: ubuntu
|
||||||
|
version: 20.04
|
||||||
container:
|
container:
|
||||||
image: debian:11
|
image: ${{ matrix.distro }}:${{ matrix.version }}
|
||||||
steps:
|
steps:
|
||||||
|
- name: get-cmake
|
||||||
|
uses: lukka/get-cmake@v3.28.1
|
||||||
|
|
||||||
- name: Export GitHub Actions cache environment variables
|
- name: Export GitHub Actions cache environment variables
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
@@ -29,37 +47,59 @@ jobs:
|
|||||||
|
|
||||||
- name: Git config safe directory
|
- name: Git config safe directory
|
||||||
shell: bash
|
shell: bash
|
||||||
run: bash ./scripts/debian-11/1.5-git-safe.sh
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1.5-git-safe.sh
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: bash ./scripts/debian-11/1-install-deps.sh
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1-install-deps.sh
|
||||||
|
|
||||||
- name: Create Build Environment
|
- name: Create Build Environment
|
||||||
run: bash ./scripts/debian-11/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
||||||
|
|
||||||
- name: Build Server
|
- name: Build Server
|
||||||
run: bash ./scripts/debian-11/3-build.sh
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/3-build.sh
|
||||||
|
|
||||||
- name: Archive server artifact
|
- name: Archive server artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: BeamMP-Server-debian
|
name: BeamMP-Server.${{ matrix.distro }}.${{ matrix.version }}.x86_64
|
||||||
path: ./bin/BeamMP-Server
|
path: ./bin/BeamMP-Server
|
||||||
|
|
||||||
- name: Build Tests
|
- name: Archive server debug info artifact
|
||||||
run: bash ./scripts/debian-11/3-build-tests.sh
|
|
||||||
|
|
||||||
- name: Archive server tests artifact
|
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: BeamMP-Server-debian-tests
|
name: debuginfo.${{ matrix.distro }}.${{ matrix.version }}.x86_64
|
||||||
path: ./bin/BeamMP-Server-tests
|
path: ./bin/BeamMP-Server.debug
|
||||||
|
|
||||||
ubuntu-22-04-build:
|
- name: Build Tests
|
||||||
runs-on: ubuntu-latest
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/3-build-tests.sh
|
||||||
|
|
||||||
|
- name: Install Runtime Dependencies
|
||||||
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/4-install-runtime-deps.sh
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: ./bin/BeamMP-Server-tests
|
||||||
|
|
||||||
|
arm64-matrix:
|
||||||
|
runs-on: [Linux, ARM64]
|
||||||
|
env:
|
||||||
|
VCPKG_DEFAULT_TRIPLET: "arm64-linux"
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- distro: debian
|
||||||
|
version: 11
|
||||||
|
- distro: debian
|
||||||
|
version: 12
|
||||||
|
- distro: ubuntu
|
||||||
|
version: 22.04
|
||||||
|
- distro: ubuntu
|
||||||
|
version: 20.04
|
||||||
container:
|
container:
|
||||||
image: ubuntu:22.04
|
image: ${{ matrix.distro }}:${{ matrix.version }}
|
||||||
steps:
|
steps:
|
||||||
|
- name: get-cmake
|
||||||
|
uses: lukka/get-cmake@v3.28.1
|
||||||
|
|
||||||
- name: Export GitHub Actions cache environment variables
|
- name: Export GitHub Actions cache environment variables
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
@@ -78,73 +118,35 @@ jobs:
|
|||||||
|
|
||||||
- name: Git config safe directory
|
- name: Git config safe directory
|
||||||
shell: bash
|
shell: bash
|
||||||
run: bash ./scripts/ubuntu-22.04/1.5-git-safe.sh
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1.5-git-safe.sh
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: bash ./scripts/ubuntu-22.04/1-install-deps.sh
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1-install-deps.sh
|
||||||
|
|
||||||
- name: Setup vcpkg
|
|
||||||
uses: lukka/run-vcpkg@v11
|
|
||||||
with:
|
|
||||||
runVcpkgInstall: true
|
|
||||||
|
|
||||||
- name: Create Build Environment
|
- name: Create Build Environment
|
||||||
run: bash ./scripts/ubuntu-22.04/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
||||||
|
|
||||||
- name: Build Server
|
- name: Build Server
|
||||||
run: bash ./scripts/ubuntu-22.04/3-build.sh
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/3-build.sh
|
||||||
|
|
||||||
- name: Archive server artifact
|
- name: Archive server artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: BeamMP-Server-ubuntu
|
name: BeamMP-Server.${{ matrix.distro }}.${{ matrix.version }}.arm64
|
||||||
path: ./bin/BeamMP-Server
|
path: ./bin/BeamMP-Server
|
||||||
|
|
||||||
- name: Build Tests
|
|
||||||
run: bash ./scripts/ubuntu-22.04/3-build-tests.sh
|
|
||||||
|
|
||||||
- name: Archive server tests artifact
|
- name: Archive server debug info artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: BeamMP-Server-ubuntu-tests
|
name: debuginfo.${{ matrix.distro }}.${{ matrix.version }}.arm64
|
||||||
path: ./bin/BeamMP-Server-tests
|
path: ./bin/BeamMP-Server.debug
|
||||||
|
|
||||||
|
- name: Build Tests
|
||||||
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/3-build-tests.sh
|
||||||
|
|
||||||
run-debian-11-tests:
|
|
||||||
needs: debian-11-build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: debian:11
|
|
||||||
steps:
|
|
||||||
- uses: actions/download-artifact@master
|
|
||||||
with:
|
|
||||||
name: BeamMP-Server-debian-tests
|
|
||||||
|
|
||||||
- name: Install Runtime Dependencies
|
- name: Install Runtime Dependencies
|
||||||
run: |
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/4-install-runtime-deps.sh
|
||||||
apt-get update -y
|
|
||||||
apt-get install -y liblua5.3-0
|
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: |
|
run: ./bin/BeamMP-Server-tests
|
||||||
chmod +x ./BeamMP-Server-tests
|
|
||||||
./BeamMP-Server-tests
|
|
||||||
|
|
||||||
run-ubuntu-22-04-tests:
|
|
||||||
needs: ubuntu-22-04-build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: ubuntu:22.04
|
|
||||||
steps:
|
|
||||||
- uses: actions/download-artifact@master
|
|
||||||
with:
|
|
||||||
name: BeamMP-Server-ubuntu-tests
|
|
||||||
|
|
||||||
- name: Install Runtime Dependencies
|
|
||||||
run: |
|
|
||||||
apt-get update -y
|
|
||||||
apt-get install -y liblua5.3-0
|
|
||||||
|
|
||||||
- name: Test
|
|
||||||
run: |
|
|
||||||
chmod +x ./BeamMP-Server-tests
|
|
||||||
./BeamMP-Server-tests
|
|
||||||
@@ -7,6 +7,8 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
||||||
|
CMAKE_BUILD_TYPE: "Release"
|
||||||
|
DEBIAN_FRONTEND: "noninteractive"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
create-release:
|
create-release:
|
||||||
@@ -26,18 +28,30 @@ jobs:
|
|||||||
draft: false
|
draft: false
|
||||||
prerelease: true
|
prerelease: true
|
||||||
body: |
|
body: |
|
||||||
Files included in this release:
|
Files included in this release are:
|
||||||
- `BeamMP-Server.exe` is the windows build.
|
- `BeamMP-Server.$DISTRO.$DISTROVERSION.$ARCH` for linux builds, for example `BeamMP-Server.debian.11.x86_64` for the Debian 11 build for x86_64. All require `liblua5.3` to be installed.
|
||||||
- `BeamMP-Server-debian` is a Debian 11 build, requires `liblua5.3-0`.
|
- `BeamMP-Server.exe` for the Windows build (x86_64). You need to install the [Visual C++ Redistributables](https://aka.ms/vs/17/release/vc_redist.x64.exe) to run this.
|
||||||
- `BeamMP-Server-ubuntu` is a Ubuntu 22.04 build, requires `liblua5.3-0`.
|
|
||||||
|
|
||||||
upload-release-files-debian-11:
|
x86_64-matrix:
|
||||||
name: Build and upload Debian 11 Release Files
|
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
needs: create-release
|
needs: create-release
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- distro: debian
|
||||||
|
version: 11
|
||||||
|
- distro: debian
|
||||||
|
version: 12
|
||||||
|
- distro: ubuntu
|
||||||
|
version: 22.04
|
||||||
|
- distro: ubuntu
|
||||||
|
version: 20.04
|
||||||
container:
|
container:
|
||||||
image: debian:11
|
image: ${{ matrix.distro }}:${{ matrix.version }}
|
||||||
steps:
|
steps:
|
||||||
|
- name: get-cmake
|
||||||
|
uses: lukka/get-cmake@v3.28.1
|
||||||
|
|
||||||
- name: Export GitHub Actions cache environment variables
|
- name: Export GitHub Actions cache environment variables
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
@@ -56,21 +70,16 @@ jobs:
|
|||||||
|
|
||||||
- name: Git config safe directory
|
- name: Git config safe directory
|
||||||
shell: bash
|
shell: bash
|
||||||
run: bash ./scripts/debian-11/1.5-git-safe.sh
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1.5-git-safe.sh
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: bash ./scripts/debian-11/1-install-deps.sh
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1-install-deps.sh
|
||||||
|
|
||||||
- name: Setup vcpkg
|
|
||||||
uses: lukka/run-vcpkg@v11
|
|
||||||
with:
|
|
||||||
runVcpkgInstall: true
|
|
||||||
|
|
||||||
- name: Create Build Environment
|
- name: Create Build Environment
|
||||||
run: bash ./scripts/debian-11/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
||||||
|
|
||||||
- name: Build Server
|
- name: Build Server
|
||||||
run: bash ./scripts/debian-11/3-build.sh
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/3-build.sh
|
||||||
|
|
||||||
- name: Upload Release Asset
|
- name: Upload Release Asset
|
||||||
id: upload-release-asset
|
id: upload-release-asset
|
||||||
@@ -78,18 +87,45 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
|
asset_name: BeamMP-Server.${{ matrix.distro }}.${{ matrix.version }}.x86_64
|
||||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||||
asset_path: ./bin/BeamMP-Server
|
asset_path: ./bin/BeamMP-Server
|
||||||
asset_name: BeamMP-Server-debian
|
|
||||||
asset_content_type: application/x-elf
|
asset_content_type: application/x-elf
|
||||||
|
|
||||||
upload-release-files-ubuntu-22-04:
|
- name: Upload Debug Info
|
||||||
name: Build and upload Ubuntu 22.04 Release Files
|
id: upload-debug-info
|
||||||
runs-on: ubuntu-22.04
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
asset_name: debuginfo.${{ matrix.distro }}.${{ matrix.version }}.x86_64
|
||||||
|
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||||
|
asset_path: ./bin/BeamMP-Server.debug
|
||||||
|
asset_content_type: application/x-elf
|
||||||
|
|
||||||
|
arm64-matrix:
|
||||||
|
runs-on: [Linux, ARM64]
|
||||||
needs: create-release
|
needs: create-release
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- distro: debian
|
||||||
|
version: 11
|
||||||
|
- distro: debian
|
||||||
|
version: 12
|
||||||
|
- distro: ubuntu
|
||||||
|
version: 22.04
|
||||||
|
- distro: ubuntu
|
||||||
|
version: 20.04
|
||||||
|
env:
|
||||||
|
VCPKG_DEFAULT_TRIPLET: "arm64-linux"
|
||||||
|
VCPKG_FORCE_SYSTEM_BINARIES: 1
|
||||||
container:
|
container:
|
||||||
image: ubuntu:22.04
|
image: ${{ matrix.distro }}:${{ matrix.version }}
|
||||||
steps:
|
steps:
|
||||||
|
- name: get-cmake
|
||||||
|
uses: lukka/get-cmake@v3.28.1
|
||||||
|
|
||||||
- name: Export GitHub Actions cache environment variables
|
- name: Export GitHub Actions cache environment variables
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
@@ -108,16 +144,16 @@ jobs:
|
|||||||
|
|
||||||
- name: Git config safe directory
|
- name: Git config safe directory
|
||||||
shell: bash
|
shell: bash
|
||||||
run: bash ./scripts/ubuntu-22.04/1.5-git-safe.sh
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1.5-git-safe.sh
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: bash ./scripts/ubuntu-22.04/1-install-deps.sh
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1-install-deps.sh
|
||||||
|
|
||||||
- name: Create Build Environment
|
- name: Create Build Environment
|
||||||
run: bash ./scripts/ubuntu-22.04/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
||||||
|
|
||||||
- name: Build Server
|
- name: Build Server
|
||||||
run: bash ./scripts/ubuntu-22.04/3-build.sh
|
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/3-build.sh
|
||||||
|
|
||||||
- name: Upload Release Asset
|
- name: Upload Release Asset
|
||||||
id: upload-release-asset
|
id: upload-release-asset
|
||||||
@@ -125,9 +161,20 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
|
asset_name: BeamMP-Server.${{ matrix.distro }}.${{ matrix.version }}.arm64
|
||||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||||
asset_path: ./bin/BeamMP-Server
|
asset_path: ./bin/BeamMP-Server
|
||||||
asset_name: BeamMP-Server-ubuntu
|
asset_content_type: application/x-elf
|
||||||
|
|
||||||
|
- name: Upload Debug Info
|
||||||
|
id: upload-debug-info
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
asset_name: debuginfo.${{ matrix.distro }}.${{ matrix.version }}.arm64
|
||||||
|
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||||
|
asset_path: ./bin/BeamMP-Server.debug
|
||||||
asset_content_type: application/x-elf
|
asset_content_type: application/x-elf
|
||||||
|
|
||||||
upload-release-files-windows:
|
upload-release-files-windows:
|
||||||
@@ -163,6 +210,6 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||||
asset_path: ./bin/BeamMP-Server.exe
|
asset_path: ./bin/Release/BeamMP-Server.exe
|
||||||
asset_name: BeamMP-Server.exe
|
asset_name: BeamMP-Server.exe
|
||||||
asset_content_type: application/vnd.microsoft.portable-executable
|
asset_content_type: application/vnd.microsoft.portable-executable
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ on: [push]
|
|||||||
env:
|
env:
|
||||||
VCPKG_DEFAULT_TRIPLET: x64-windows-static
|
VCPKG_DEFAULT_TRIPLET: x64-windows-static
|
||||||
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
||||||
|
CMAKE_BUILD_TYPE: "Release"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
windows-build:
|
windows-build:
|
||||||
@@ -38,5 +39,5 @@ jobs:
|
|||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: BeamMP-Server-windows
|
name: BeamMP-Server-windows
|
||||||
path: ./bin/BeamMP-Server.exe
|
path: ./bin/Release/BeamMP-Server.exe
|
||||||
|
|
||||||
|
|||||||
+6
-3
@@ -48,6 +48,7 @@ set(PRJ_HEADERS
|
|||||||
include/TScopedTimer.h
|
include/TScopedTimer.h
|
||||||
include/TServer.h
|
include/TServer.h
|
||||||
include/VehicleData.h
|
include/VehicleData.h
|
||||||
|
include/Env.h
|
||||||
)
|
)
|
||||||
# add all source files (.cpp) to this, except the one with main()
|
# add all source files (.cpp) to this, except the one with main()
|
||||||
set(PRJ_SOURCES
|
set(PRJ_SOURCES
|
||||||
@@ -70,6 +71,7 @@ set(PRJ_SOURCES
|
|||||||
src/TScopedTimer.cpp
|
src/TScopedTimer.cpp
|
||||||
src/TServer.cpp
|
src/TServer.cpp
|
||||||
src/VehicleData.cpp
|
src/VehicleData.cpp
|
||||||
|
src/Env.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package(Lua REQUIRED)
|
find_package(Lua REQUIRED)
|
||||||
@@ -126,9 +128,10 @@ include(FindThreads)
|
|||||||
# enables compile_commands.json for clang-related tools (such as the clang LS)
|
# enables compile_commands.json for clang-related tools (such as the clang LS)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
# build debug builds by default (if not specified otherwise)
|
# build release builds by default (if not specified otherwise)
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT DEFINED CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE "Debug")
|
message(NOTICE "No build type specified, defaulting to 'Release'")
|
||||||
|
set(CMAKE_BUILD_TYPE "Release")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
|
|||||||
-156
@@ -1,156 +0,0 @@
|
|||||||
# v3.1.1
|
|
||||||
|
|
||||||
- FIXED bug which caused GetPlayerIdentifiers, GetPlayerName, etc not to work in `onPlayerDisconnect`
|
|
||||||
- FIXED some issues which could cause the server to crash when receiving malformed data
|
|
||||||
- FIXED a bug which caused a server to crash during authentication when receiving malformed data
|
|
||||||
- FIXED minor vulnerability in chat message handling
|
|
||||||
- FIXED a minor formatting bug in the `status` command
|
|
||||||
|
|
||||||
# v3.1.0
|
|
||||||
|
|
||||||
- ADDED Tab autocomplete in console, smart tab autocomplete (understands lua tables and types) in the lua console
|
|
||||||
- ADDED lua debug facilities (type `:help` when attached to lua via `lua`)
|
|
||||||
- ADDED Util.JsonEncode() and Util.JsonDecode(), which turn lua tables into json and vice-versa
|
|
||||||
- ADDED FS.ListFiles and FS.ListDirectories
|
|
||||||
- ADDED onFileChanged event, triggered when a server plugin file changes
|
|
||||||
- ADDED MP.GetPositionRaw(), which can be used to retrieve the latest position packet per player, per vehicle
|
|
||||||
- ADDED error messages to some lua functions
|
|
||||||
- ADDED HOME and END button working in console
|
|
||||||
- ADDED `MP.TriggerClientEventJson()` which takes a table as the data argument and sends it as JSON
|
|
||||||
- ADDED identifiers (beammp id, ip) to onPlayerAuth (4th argument)
|
|
||||||
- ADDED more network debug logging
|
|
||||||
- CHANGED all networking to be more stable, performant, and safe
|
|
||||||
- FIXED `ip` in MP.GetPlayerIdentifiers
|
|
||||||
- FIXED issue with client->server events which contain `:`
|
|
||||||
- FIXED a fatal exception on LuaEngine startup if Resources/Server is a symlink
|
|
||||||
- FIXED onInit not being called on hot-reload
|
|
||||||
- FIXED incorrect timing calculation of Lua EventTimer loop
|
|
||||||
- FIXED bug which caused hot-reload not to report syntax errors
|
|
||||||
- FIXED missing error messages on some event handler calls
|
|
||||||
- FIXED vehicles not deleting for all players if an edit was cancelled by Lua
|
|
||||||
- FIXED server not handling binary UDP packets properly
|
|
||||||
- REMOVED "Backend response failed to parse as valid json" message
|
|
||||||
|
|
||||||
# v3.0.2
|
|
||||||
|
|
||||||
- ADDED Periodic update message if a new server is released
|
|
||||||
- ADDED Config setting for the IP the http server listens on
|
|
||||||
- CHANGED Default MaxPlayers to 8
|
|
||||||
- CHANGED Default http server listen IP to localhost
|
|
||||||
- FIXED `MP.CreateEventTimer` filling up the queue (see <https://wiki.beammp.com/en/Scripting/new-lua-scripting#mpcreateeventtimerevent_name-string-interval_ms-number-strategy-number-since-v302>)
|
|
||||||
- FIXED `MP.TriggerClientEvent` not kicking the client if it failed
|
|
||||||
- FIXED Lua result queue handling not checking all results
|
|
||||||
- FIXED bug which caused ServerConfig.toml to generate incorrectly
|
|
||||||
|
|
||||||
# v3.0.1
|
|
||||||
|
|
||||||
- ADDED Backup URLs to UpdateCheck (will fail less often now)
|
|
||||||
- ADDED console cursor left and right movement (with arrow keys) and working HOME and END key (via github.com/lionkor/commandline)
|
|
||||||
- FIXED infinite snowmen / infinite unicycle spawning bug
|
|
||||||
- FIXED a bug where, when run with --working-directory, the Server.log would still be in the original directory
|
|
||||||
- FIXED a bug which could cause the plugin reload thread to spin at 100% if the reloaded plugin's didn't terminate
|
|
||||||
- FIXED an issue which would cause servers to crash on mod download via SIGPIPE on POSIX
|
|
||||||
- FIXED an issue which would cause servers to crash when checking if a vehicle is a unicycle
|
|
||||||
|
|
||||||
# v3.0.0
|
|
||||||
|
|
||||||
- CHANGED entire plugin Lua implementation (rewrite)
|
|
||||||
- CHANGED moved *almost all* Lua functions into MP.\*
|
|
||||||
- CHANGED console to use a custom language (type `help`, `list`, or `status`!)
|
|
||||||
- CHANGED all files of a Lua plugin to share a Lua state (no more state-per-file)
|
|
||||||
- ADDED many new Lua API functions, which can be found at <https://wiki.beammp.com/en/Scripting/functions>
|
|
||||||
- ADDED Commandline options. Run with `--help` to see all options.
|
|
||||||
- ADDED HTTP(S) Server (OpenAPI spec coming soon!)
|
|
||||||
- ADDED plugin directories to `package.path` and `package.cpath` before `onInit`
|
|
||||||
- ADDED ability to add `PluginConfig.toml` to your plugin folder to change some settings
|
|
||||||
- ADDED ability to share a lua state with other plugins via `StateId` setting in `PluginConfig.toml`
|
|
||||||
- ADDED ability to see name-to-thread-ID association in debug mode
|
|
||||||
- ADDED dumping tables with `print()` (try it with `print(MP)`)
|
|
||||||
- ADDED `MP.GetOSName()`, `MP.CreateTimer()`, `MP.GetLuaMemoryUsage()` and many more (see <https://wiki.beammp.com/en/Scripting/functions>)
|
|
||||||
- ADDED `MP.Settings` table to make usage of `MP.Set()` easier
|
|
||||||
- ADDED `FS.*` table with common filesystem operations (do `print(FS)` to see them!)
|
|
||||||
- FIXED i/o thread spin when stdout is /dev/null on linux
|
|
||||||
- FIXED removed extra whitespace infront of onChatMessage message
|
|
||||||
|
|
||||||
# v2.3.3
|
|
||||||
|
|
||||||
- CHANGED servers to be private by default
|
|
||||||
|
|
||||||
# v2.3.2
|
|
||||||
|
|
||||||
- ADDED Ctrl+C causes a graceful shutdown on windows (did already on linux)
|
|
||||||
- ADDED more meaningful shutdown messages
|
|
||||||
- ADDED even better backend connection error reporting
|
|
||||||
- ADDED `SendErrors` config in `ServerConfig.toml` to opt-out of error reporting
|
|
||||||
- ADDED hard-shutdown if Ctrl+C pressed 3 times
|
|
||||||
- FIXED issue with shells like bash being unusable after server exit
|
|
||||||
|
|
||||||
# v2.3.1
|
|
||||||
|
|
||||||
- CHANGED join/sync timeout to 20 minutes, players wont drop if loading takes >5 mins
|
|
||||||
|
|
||||||
# v2.3.0
|
|
||||||
|
|
||||||
- ADDED version check - the server will now let you know when a new release is out
|
|
||||||
- ADDED logging of various errors, crashes and exceptions to the backend
|
|
||||||
- ADDED chat messages are now logged to the server console as [CHAT]
|
|
||||||
- ADDED debug message telling you when the server heartbeats to the backend
|
|
||||||
- REMOVED various [DEBUG] messages which were confusing (such as "breaking client loop")
|
|
||||||
- FIXED various crashes and issues with handling unexpected backend responses
|
|
||||||
- FIXED minor bugs due to code correctness
|
|
||||||
|
|
||||||
# v2.2.0
|
|
||||||
|
|
||||||
- FIXED major security flaw
|
|
||||||
- FIXED minor bugs
|
|
||||||
|
|
||||||
# v2.1.4
|
|
||||||
|
|
||||||
- ADDED debug heartbeat print
|
|
||||||
- ADDED kicking every player before shutdown
|
|
||||||
- FIXED rare bug which led to violent crash
|
|
||||||
- FIXED minor bugs
|
|
||||||
|
|
||||||
# v2.1.3
|
|
||||||
|
|
||||||
- FIXED Lua events not cancelling properly on Linux
|
|
||||||
|
|
||||||
# v2.1.2
|
|
||||||
|
|
||||||
- CHANGED default map to gridmap v2
|
|
||||||
- FIXED version number display
|
|
||||||
|
|
||||||
# v2.1.1
|
|
||||||
# v2.1.0 (pre-v2.1.1)
|
|
||||||
# v2.0.4 (pre-v2.1.0)
|
|
||||||
|
|
||||||
- REMOVED boost as a runtime dependency
|
|
||||||
- FIXED Lua plugins on Linux
|
|
||||||
- FIXED console history on Windows
|
|
||||||
- CHANGED to new config format TOML
|
|
||||||
|
|
||||||
# v2.0.3
|
|
||||||
|
|
||||||
- WORKAROUND for timeout bug / ghost player bug
|
|
||||||
- FIXED 100% CPU spin when stdin is /dev/null.
|
|
||||||
|
|
||||||
# v2.0.2
|
|
||||||
|
|
||||||
- ADDED fully new commandline
|
|
||||||
- ADDED new backend
|
|
||||||
- ADDED automated build system
|
|
||||||
- ADDED lua GetPlayerIdentifiers
|
|
||||||
- ADDED lots of debug info
|
|
||||||
- ADDED better POSTing and GETing
|
|
||||||
- ADDED a license
|
|
||||||
- FIXED ghost players in player list issue
|
|
||||||
- FIXED ghost vehicle after joining issue
|
|
||||||
- FIXED missing vehicle after joining issue
|
|
||||||
- FIXED a lot of desync issues
|
|
||||||
- FIXED some memory leaks
|
|
||||||
- FIXED various crashes
|
|
||||||
- FIXED various data-races
|
|
||||||
- FIXED some linux-specific crashes
|
|
||||||
- FIXED some linux-specific issues
|
|
||||||
- FIXED bug which caused kicking to be logged as leaving
|
|
||||||
- FIXED various internal developer quality-of-life things
|
|
||||||
@@ -6,13 +6,12 @@
|
|||||||
This is the server for the multiplayer mod **[BeamMP](https://beammp.com/)** for the game [BeamNG.drive](https://www.beamng.com/).
|
This is the server for the multiplayer mod **[BeamMP](https://beammp.com/)** for the game [BeamNG.drive](https://www.beamng.com/).
|
||||||
The server is the point through which all clients communicate. You can write Lua mods for the server, there are detailed instructions on the [BeamMP Wiki](https://wiki.beammp.com).
|
The server is the point through which all clients communicate. You can write Lua mods for the server, there are detailed instructions on the [BeamMP Wiki](https://wiki.beammp.com).
|
||||||
|
|
||||||
**For Linux, you __need__ the runtime dependencies, listed below under "[prerequisites](#prerequisites)".**
|
**For Linux, you __need__ the runtime dependencies, which are listed below under [Runtime Dependencies](#runtime-dependencies)**
|
||||||
|
|
||||||
## Support + Contact
|
## Support + Contact
|
||||||
|
|
||||||
Feel free to ask any questions via the following channels:
|
Feel free to ask any questions via the following channels:
|
||||||
|
|
||||||
- **IRC**: `#beammp` on [irc.libera.chat](https://web.libera.chat/)
|
|
||||||
- **Discord**: [click for invite](https://discord.gg/beammp)
|
- **Discord**: [click for invite](https://discord.gg/beammp)
|
||||||
- **BeamMP Forum**: [BeamMP Forum Support](https://forum.beammp.com/c/support/33)
|
- **BeamMP Forum**: [BeamMP Forum Support](https://forum.beammp.com/c/support/33)
|
||||||
|
|
||||||
@@ -43,7 +42,7 @@ We only allow building unmodified (original) source code for public use. `master
|
|||||||
|
|
||||||
## Supported Operating Systems
|
## Supported Operating Systems
|
||||||
|
|
||||||
The code itself supports (latest stable) Linux and Windows. In terms of actual build support, for now we usually only distribute Windows binaries and sometimes Linux. For any other distro or OS, you just have to find the same libraries listed in the Linux Build [Prerequisites](#prerequisites) further down the page, and it should build fine. We don't currently support any big-endian architectures.
|
The code itself supports (latest stable) Linux and Windows. In terms of actual build support, for now we usually only distribute Windows binaries and Linux. For any other distro or OS, you just have to find the same libraries listed in [Runtime Dependencies](#runtime-dependencies) further down the page, and it should build fine.
|
||||||
|
|
||||||
Recommended compilers: MSVC, GCC, CLANG.
|
Recommended compilers: MSVC, GCC, CLANG.
|
||||||
|
|
||||||
@@ -51,127 +50,37 @@ You can find precompiled binaries under [Releases](https://github.com/BeamMP/Bea
|
|||||||
|
|
||||||
## Build Instructions
|
## Build Instructions
|
||||||
|
|
||||||
**__Do not compile from `master`. Always build from a release tag, i.e. `tags/v3.1.0`!__**
|
On Linux, you need some dependencies to **build** the server (on Windows, you don't):
|
||||||
|
|
||||||
Currently only Linux and Windows are supported (generally). See [Releases](https://github.com/BeamMP/BeamMP-Server/releases/) for official binary releases. On systems to which we do not provide binaries (so anything but windows), you are allowed to compile the program and use it. Other restrictions, such as not being allowed to distribute those binaries, still apply (see [copyright notice](#copyright)).
|
|
||||||
|
|
||||||
### Prerequisites
|
|
||||||
|
|
||||||
#### Windows
|
|
||||||
|
|
||||||
There are **no runtime libraries** needed for Windows.
|
|
||||||
|
|
||||||
Please use the prepackaged binaries in [Releases](https://github.com/BeamMP/BeamMP-Server/releases/).
|
|
||||||
|
|
||||||
Dependencies for **Windows** can be installed with `vcpkg`.
|
|
||||||
These are:
|
|
||||||
```
|
```
|
||||||
lua zlib rapidjson openssl websocketpp curl
|
liblua5.3-dev curl zip unzip tar cmake make git g++
|
||||||
```
|
```
|
||||||
The triplet we use for releases is `x64-windows-static`.
|
|
||||||
|
|
||||||
#### Linux
|
You can install these with your distribution's package manager. You will need sudo or need root for ONLY this step.
|
||||||
|
|
||||||
We recommend Ubuntu 22.04 or Arch Linux. Any Linux distribution will work, but you have to figure out the package names yourself (please feel free to PR in a change to this README with that info).
|
The names of each package may change depending on your platform.
|
||||||
|
|
||||||
##### Runtime Dependencies
|
If you are building for ARM (like aarch64), you need to run `export VCPKG_FORCE_SYSTEM_BINARIES=1` before the following commands.
|
||||||
|
|
||||||
|
You can build on **Windows, Linux** or other platforms by following these steps:
|
||||||
|
|
||||||
|
1. Check out the repository with git: `git clone --recursive https://github.com/BeamMP/BeamMP-Server`.
|
||||||
|
2. Go into the directory `cd BeamMP-Server`.
|
||||||
|
3. Run CMake `cmake -S . -B bin -DCMAKE_BUILD_TYPE=Release` - this can take a few minutes and may take a lot of disk space and bandwidth.
|
||||||
|
4. Build via `cmake --build bin --parallel --config Release -t BeamMP-Server`.
|
||||||
|
5. Your executable can be found in `bin/`.
|
||||||
|
|
||||||
|
When you make changes to the code, you only have to run step 4 again.
|
||||||
|
|
||||||
|
### Runtime Dependencies
|
||||||
|
|
||||||
These are needed to *run* the server.
|
These are needed to *run* the server.
|
||||||
|
|
||||||
<details>
|
Debian, Ubuntu and friends: `liblua5.3-0`
|
||||||
<summary>
|
|
||||||
Ubuntu 22.04
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
`apt-get install` the following libraries:
|
Other Linux distros: `liblua` of *some kind*.
|
||||||
```
|
|
||||||
liblua5.3-0
|
|
||||||
libssl3
|
|
||||||
curl
|
|
||||||
```
|
|
||||||
</details>
|
|
||||||
|
|
||||||
<details>
|
Windows: No libraries.
|
||||||
<summary>
|
|
||||||
Arch Linux
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
`pacman -Syu` the following libraries:
|
|
||||||
```
|
|
||||||
lua53
|
|
||||||
openssl
|
|
||||||
curl
|
|
||||||
```
|
|
||||||
</details>
|
|
||||||
|
|
||||||
##### Build Dependencies
|
|
||||||
These are needed for you to *build* the server, in addition to the [runtime dependencies](#runtime-dependencies).
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>
|
|
||||||
Ubuntu 22.04
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
`apt-get install` the following libraries and programs:
|
|
||||||
```
|
|
||||||
git
|
|
||||||
libz-dev
|
|
||||||
rapidjson-dev
|
|
||||||
liblua5.3-dev
|
|
||||||
libssl-dev
|
|
||||||
libwebsocketpp-dev
|
|
||||||
libcurl4-openssl-dev
|
|
||||||
cmake
|
|
||||||
g++-10
|
|
||||||
libboost1.74-all-dev
|
|
||||||
libssl3
|
|
||||||
curl
|
|
||||||
```
|
|
||||||
</details>
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>
|
|
||||||
Arch Linux
|
|
||||||
</summary>
|
|
||||||
|
|
||||||
`pacman -Syu` the following libraries and programs:
|
|
||||||
```
|
|
||||||
lua53
|
|
||||||
openssl
|
|
||||||
curl
|
|
||||||
git
|
|
||||||
cmake
|
|
||||||
g++
|
|
||||||
zlib
|
|
||||||
boost
|
|
||||||
websocketpp
|
|
||||||
```
|
|
||||||
</details>
|
|
||||||
|
|
||||||
#### macOS
|
|
||||||
|
|
||||||
Dependencies for **macOS** can be installed with homebrew.
|
|
||||||
```
|
|
||||||
brew install lua@5.3 rapidjson websocketpp cmake openssl@1.1
|
|
||||||
```
|
|
||||||
Some packages are included in **macOS** but you might want to install homebrew versions.
|
|
||||||
```
|
|
||||||
brew install curl zlib git make
|
|
||||||
```
|
|
||||||
|
|
||||||
### How to build
|
|
||||||
|
|
||||||
On Windows, use git-bash for these commands. On Linux, these should work in your shell.
|
|
||||||
|
|
||||||
1. Make sure you have all [prerequisites](#prerequisites) installed
|
|
||||||
2. Clone the repository in a location of your choice with `git clone https://github.com/BeamMP/BeamMP-Server` .
|
|
||||||
3. Change into the BeamMP-Server directory by running `cd BeamMP-Server`.
|
|
||||||
4. Checkout the branch or tag of the release you want to compile, for example `git checkout tags/v3.0.2` for version 3.0.2. You can find the latest version [here](https://github.com/BeamMP/BeamMP-Server/tags).
|
|
||||||
6. Run `cmake . -DCMAKE_BUILD_TYPE=Release` (with `.`). This may take some time, and will update all submodules and prepare the build.
|
|
||||||
7. Run `make -j` . This step will take some time and will use a lot of CPU and RAM. Remove the `-j` if you run out of memory. *If you change something in the source code, you only have to re-run this step.*
|
|
||||||
8. You now have a `BeamMP-Server` file in your directory, which is executable with `./BeamMP-Server` (`.\BeamMP-Server.exe` for windows). Follow the (Windows or Linux, doesnt matter) instructions on the [wiki](https://wiki.beammp.com/en/home/server-installation) for further setup after installation (which we just did), such as port-forwarding and getting a key to actually run the server.
|
|
||||||
|
|
||||||
*tip: to run the server in the background, simply (in bash, zsh, etc) run:* `nohup ./BeamMP-Server &`*.*
|
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
The BeamMP project is supported by community donations via our [Patreon](https://www.patreon.com/BeamMP). This brings perks such as Patreon-only channels on our Discord, early access to new updates, and more server keys.
|
The BeamMP project is supported by community donations via our [Patreon](https://www.patreon.com/BeamMP). This brings perks such as Patreon-only channels on our Discord, early access to new updates, and more server keys.
|
||||||
|
|||||||
Vendored
+1
-1
Submodule deps/commandline updated: 0ff46d25b1...b2a29733f9
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|||||||
+25
-6
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
@@ -43,6 +61,7 @@ public:
|
|||||||
struct TSettings {
|
struct TSettings {
|
||||||
std::string ServerName { "BeamMP Server" };
|
std::string ServerName { "BeamMP Server" };
|
||||||
std::string ServerDesc { "BeamMP Default Description" };
|
std::string ServerDesc { "BeamMP Default Description" };
|
||||||
|
std::string ServerTags { "Freeroam" };
|
||||||
std::string Resource { "Resources" };
|
std::string Resource { "Resources" };
|
||||||
std::string MapName { "/levels/gridmap_v2/info.json" };
|
std::string MapName { "/levels/gridmap_v2/info.json" };
|
||||||
std::string Key {};
|
std::string Key {};
|
||||||
@@ -75,7 +94,7 @@ public:
|
|||||||
static void RegisterShutdownHandler(const TShutdownHandler& Handler);
|
static void RegisterShutdownHandler(const TShutdownHandler& Handler);
|
||||||
// Causes all threads to finish up and exit gracefull gracefully
|
// Causes all threads to finish up and exit gracefull gracefully
|
||||||
static void GracefullyShutdown();
|
static void GracefullyShutdown();
|
||||||
static TConsole& Console() { return *mConsole; }
|
static TConsole& Console() { return mConsole; }
|
||||||
static std::string ServerVersionString();
|
static std::string ServerVersionString();
|
||||||
static const Version& ServerVersion() { return mVersion; }
|
static const Version& ServerVersion() { return mVersion; }
|
||||||
static uint8_t ClientMajorVersion() { return 2; }
|
static uint8_t ClientMajorVersion() { return 2; }
|
||||||
@@ -101,9 +120,7 @@ public:
|
|||||||
static void SleepSafeSeconds(size_t Seconds);
|
static void SleepSafeSeconds(size_t Seconds);
|
||||||
|
|
||||||
static void InitializeConsole() {
|
static void InitializeConsole() {
|
||||||
if (!mConsole) {
|
mConsole.InitializeCommandline();
|
||||||
mConsole = std::make_unique<TConsole>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class Status {
|
enum class Status {
|
||||||
@@ -129,15 +146,17 @@ private:
|
|||||||
static inline SystemStatusMap mSystemStatusMap {};
|
static inline SystemStatusMap mSystemStatusMap {};
|
||||||
static inline std::mutex mSystemStatusMapMutex {};
|
static inline std::mutex mSystemStatusMapMutex {};
|
||||||
static inline std::string mPPS;
|
static inline std::string mPPS;
|
||||||
static inline std::unique_ptr<TConsole> mConsole;
|
static inline TConsole mConsole;
|
||||||
static inline std::shared_mutex mShutdownMtx {};
|
static inline std::shared_mutex mShutdownMtx {};
|
||||||
static inline bool mShutdown { false };
|
static inline bool mShutdown { false };
|
||||||
static inline std::mutex mShutdownHandlersMutex {};
|
static inline std::mutex mShutdownHandlersMutex {};
|
||||||
static inline std::deque<TShutdownHandler> mShutdownHandlers {};
|
static inline std::deque<TShutdownHandler> mShutdownHandlers {};
|
||||||
|
|
||||||
static inline Version mVersion { 3, 1, 2 };
|
static inline Version mVersion { 3, 2, 2 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void SplitString(std::string const& str, const char delim, std::vector<std::string>& out);
|
||||||
|
|
||||||
std::string ThreadName(bool DebugModeOverride = false);
|
std::string ThreadName(bool DebugModeOverride = false);
|
||||||
void RegisterThread(const std::string& str);
|
void RegisterThread(const std::string& str);
|
||||||
#define RegisterThreadAuto() RegisterThread(__func__)
|
#define RegisterThreadAuto() RegisterThread(__func__)
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Environment.h"
|
#include "Environment.h"
|
||||||
|
|||||||
+17
-1
@@ -1,4 +1,20 @@
|
|||||||
// Copyright Anonymous275 8/11/2020
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|||||||
+17
-1
@@ -1,4 +1,20 @@
|
|||||||
// Author: lionkor
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Asserts are to be used anywhere where assumptions about state are made
|
* Asserts are to be used anywhere where assumptions about state are made
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
|
namespace Env {
|
||||||
|
|
||||||
|
enum class Key {
|
||||||
|
// provider settings
|
||||||
|
PROVIDER_UPDATE_MESSAGE,
|
||||||
|
};
|
||||||
|
|
||||||
|
std::optional<std::string> Get(Key key);
|
||||||
|
|
||||||
|
std::string_view ToString(Key key);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// one of BEAMMP_{WINDOWS,LINUX,APPLE} will be set at the end of this
|
// one of BEAMMP_{WINDOWS,LINUX,APPLE} will be set at the end of this
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Common.h>
|
#include <Common.h>
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|||||||
+15
-1
@@ -1,6 +1,20 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
//
|
//
|
||||||
// Created by anon on 4/21/21.
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
//
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "rapidjson/stringbuffer.h"
|
#include "rapidjson/stringbuffer.h"
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "TLuaEngine.h"
|
#include "TLuaEngine.h"
|
||||||
|
|||||||
+18
-1
@@ -1,4 +1,21 @@
|
|||||||
// Author: lionkor
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
void SetupSignalHandlers();
|
void SetupSignalHandlers();
|
||||||
|
|||||||
+22
-3
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
@@ -22,11 +40,12 @@ private:
|
|||||||
void CreateConfigFile();
|
void CreateConfigFile();
|
||||||
void ParseFromFile(std::string_view name);
|
void ParseFromFile(std::string_view name);
|
||||||
void PrintDebug();
|
void PrintDebug();
|
||||||
void TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, std::string& OutValue);
|
void TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, const std::string_view& Env, std::string& OutValue);
|
||||||
void TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, bool& OutValue);
|
void TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, const std::string_view& Env, bool& OutValue);
|
||||||
void TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, int& OutValue);
|
void TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, const std::string_view& Env, int& OutValue);
|
||||||
|
|
||||||
void ParseOldFormat();
|
void ParseOldFormat();
|
||||||
|
std::string TagsAsPrettyArray() const;
|
||||||
bool IsDefault();
|
bool IsDefault();
|
||||||
bool mFailed { false };
|
bool mFailed { false };
|
||||||
std::string mConfigFileName;
|
std::string mConfigFileName;
|
||||||
|
|||||||
+23
-2
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Cryptography.h"
|
#include "Cryptography.h"
|
||||||
@@ -17,12 +35,15 @@ class TConsole {
|
|||||||
public:
|
public:
|
||||||
TConsole();
|
TConsole();
|
||||||
|
|
||||||
|
// Initializes the commandline app to take over I/O
|
||||||
|
void InitializeCommandline();
|
||||||
|
|
||||||
void Write(const std::string& str);
|
void Write(const std::string& str);
|
||||||
void WriteRaw(const std::string& str);
|
void WriteRaw(const std::string& str);
|
||||||
void InitializeLuaConsole(TLuaEngine& Engine);
|
void InitializeLuaConsole(TLuaEngine& Engine);
|
||||||
void BackupOldLog();
|
void BackupOldLog();
|
||||||
void StartLoggingToFile();
|
void StartLoggingToFile();
|
||||||
Commandline& Internal() { return mCommandline; }
|
Commandline& Internal() { return *mCommandline; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RunAsCommand(const std::string& cmd, bool IgnoreNotACommand = false);
|
void RunAsCommand(const std::string& cmd, bool IgnoreNotACommand = false);
|
||||||
@@ -56,7 +77,7 @@ private:
|
|||||||
{ "say", [this](const auto&, const auto&) { Command_Say(""); } }, // shouldn't actually be called
|
{ "say", [this](const auto&, const auto&) { Command_Say(""); } }, // shouldn't actually be called
|
||||||
};
|
};
|
||||||
|
|
||||||
Commandline mCommandline;
|
std::unique_ptr<Commandline> mCommandline { nullptr };
|
||||||
std::vector<std::string> mCachedLuaHistory;
|
std::vector<std::string> mCachedLuaHistory;
|
||||||
std::vector<std::string> mCachedRegularHistory;
|
std::vector<std::string> mCachedRegularHistory;
|
||||||
TLuaEngine* mLuaEngine { nullptr };
|
TLuaEngine* mLuaEngine { nullptr };
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "TNetwork.h"
|
#include "TNetwork.h"
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "TLuaEngine.h"
|
#include "TLuaEngine.h"
|
||||||
|
|
||||||
class TLuaPlugin {
|
class TLuaPlugin {
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BoostAliases.h"
|
#include "BoostAliases.h"
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
@@ -18,4 +36,4 @@ private:
|
|||||||
std::string mFileList;
|
std::string mFileList;
|
||||||
std::string mTrimmedList;
|
std::string mTrimmedList;
|
||||||
int mModsLoaded = 0;
|
int mModsLoaded = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|||||||
+20
-2
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "IThreaded.h"
|
#include "IThreaded.h"
|
||||||
@@ -26,7 +44,7 @@ public:
|
|||||||
void ForEachClient(const std::function<bool(std::weak_ptr<TClient>)>& Fn);
|
void ForEachClient(const std::function<bool(std::weak_ptr<TClient>)>& Fn);
|
||||||
size_t ClientCount() const;
|
size_t ClientCount() const;
|
||||||
|
|
||||||
static void GlobalParser(const std::weak_ptr<TClient>& Client, std::vector<uint8_t>&& Packet, TPPSMonitor& PPSMonitor, TNetwork& Network);
|
void GlobalParser(const std::weak_ptr<TClient>& Client, std::vector<uint8_t>&& Packet, TPPSMonitor& PPSMonitor, TNetwork& Network);
|
||||||
static void HandleEvent(TClient& c, const std::string& Data);
|
static void HandleEvent(TClient& c, const std::string& Data);
|
||||||
RWMutex& GetClientMutex() const { return mClientsMutex; }
|
RWMutex& GetClientMutex() const { return mClientsMutex; }
|
||||||
|
|
||||||
@@ -43,7 +61,7 @@ private:
|
|||||||
static bool ShouldSpawn(TClient& c, const std::string& CarJson, int ID);
|
static bool ShouldSpawn(TClient& c, const std::string& CarJson, int ID);
|
||||||
static bool IsUnicycle(TClient& c, const std::string& CarJson);
|
static bool IsUnicycle(TClient& c, const std::string& CarJson);
|
||||||
static void Apply(TClient& c, int VID, const std::string& pckt);
|
static void Apply(TClient& c, int VID, const std::string& pckt);
|
||||||
static void HandlePosition(TClient& c, const std::string& Packet);
|
void HandlePosition(TClient& c, const std::string& Packet);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BufferView {
|
struct BufferView {
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|||||||
@@ -4,4 +4,4 @@ set -ex
|
|||||||
|
|
||||||
apt-get update -y
|
apt-get update -y
|
||||||
|
|
||||||
apt-get install -y liblua5.3-0 liblua5.3-dev curl zip unzip tar cmake make git g++
|
apt-get install -y liblua5.3-0 liblua5.3-dev curl zip unzip tar cmake make git g++ ninja-build
|
||||||
|
|||||||
@@ -2,4 +2,6 @@
|
|||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
cmake . -B bin $1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O3 -s -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,--build-id=none -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" -DBeamMP-Server_ENABLE_LTO=ON
|
./vcpkg/bootstrap-vcpkg.sh
|
||||||
|
|
||||||
|
cmake . -B bin $1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O3 -g -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" -DBeamMP-Server_ENABLE_LTO=ON
|
||||||
|
|||||||
@@ -3,3 +3,8 @@
|
|||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
cmake --build bin --parallel -t BeamMP-Server
|
cmake --build bin --parallel -t BeamMP-Server
|
||||||
|
|
||||||
|
objcopy --only-keep-debug bin/BeamMP-Server bin/BeamMP-Server.debug
|
||||||
|
objcopy --add-gnu-debuglink bin/BeamMP-Server bin/BeamMP-Server.debug
|
||||||
|
|
||||||
|
strip -s bin/BeamMP-Server
|
||||||
|
|||||||
Executable
+7
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
apt-get update -y
|
||||||
|
|
||||||
|
apt-get install -y liblua5.3-0 liblua5.3-dev curl zip unzip tar cmake make git g++ ninja-build
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
git config --global --add safe.directory $(pwd)
|
||||||
|
git config --global --add safe.directory $(pwd)/vcpkg
|
||||||
|
git config --global --add safe.directory $(pwd)/deps/commandline
|
||||||
Executable
+7
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
./vcpkg/bootstrap-vcpkg.sh
|
||||||
|
|
||||||
|
cmake . -B bin $1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O3 -g -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" -DBeamMP-Server_ENABLE_LTO=ON
|
||||||
Executable
+5
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
cmake --build bin --parallel -t BeamMP-Server-tests
|
||||||
Executable
+10
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
cmake --build bin --parallel -t BeamMP-Server
|
||||||
|
|
||||||
|
objcopy --only-keep-debug bin/BeamMP-Server bin/BeamMP-Server.debug
|
||||||
|
objcopy --add-gnu-debuglink bin/BeamMP-Server bin/BeamMP-Server.debug
|
||||||
|
|
||||||
|
strip -s bin/BeamMP-Server
|
||||||
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
apt-get update -y
|
||||||
|
|
||||||
|
apt-get install -y liblua5.3-0 curl
|
||||||
|
|
||||||
Executable
+7
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
apt-get update -y
|
||||||
|
|
||||||
|
apt-get install -y liblua5.3-0 liblua5.3-dev curl zip unzip tar cmake make git g++ ninja-build
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
git config --global --add safe.directory $(pwd)
|
||||||
|
git config --global --add safe.directory $(pwd)/vcpkg
|
||||||
|
git config --global --add safe.directory $(pwd)/deps/commandline
|
||||||
Executable
+7
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
./vcpkg/bootstrap-vcpkg.sh
|
||||||
|
|
||||||
|
cmake . -B bin $1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O3 -g -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" -DBeamMP-Server_ENABLE_LTO=ON
|
||||||
Executable
+5
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
cmake --build bin --parallel -t BeamMP-Server-tests
|
||||||
Executable
+10
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
cmake --build bin --parallel -t BeamMP-Server
|
||||||
|
|
||||||
|
objcopy --only-keep-debug bin/BeamMP-Server bin/BeamMP-Server.debug
|
||||||
|
objcopy --add-gnu-debuglink bin/BeamMP-Server bin/BeamMP-Server.debug
|
||||||
|
|
||||||
|
strip -s bin/BeamMP-Server
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
apt-get update -y
|
||||||
|
|
||||||
|
apt-get install -y liblua5.3-0 curl
|
||||||
|
|
||||||
@@ -4,4 +4,4 @@ set -ex
|
|||||||
|
|
||||||
apt-get update -y
|
apt-get update -y
|
||||||
|
|
||||||
apt-get install -y liblua5.3-0 liblua5.3-dev curl zip unzip tar cmake make git g++
|
apt-get install -y liblua5.3-0 liblua5.3-dev curl zip unzip tar cmake make git g++ ninja-build
|
||||||
|
|||||||
@@ -2,4 +2,6 @@
|
|||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
cmake . -B bin $1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O3 -s -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,--build-id=none -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" -DBeamMP-Server_ENABLE_LTO=ON
|
./vcpkg/bootstrap-vcpkg.sh
|
||||||
|
|
||||||
|
cmake . -B bin $1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O3 -g -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" -DBeamMP-Server_ENABLE_LTO=ON
|
||||||
|
|||||||
@@ -3,3 +3,8 @@
|
|||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
cmake --build bin --parallel -t BeamMP-Server
|
cmake --build bin --parallel -t BeamMP-Server
|
||||||
|
|
||||||
|
objcopy --only-keep-debug bin/BeamMP-Server bin/BeamMP-Server.debug
|
||||||
|
objcopy --add-gnu-debuglink bin/BeamMP-Server bin/BeamMP-Server.debug
|
||||||
|
|
||||||
|
strip -s bin/BeamMP-Server
|
||||||
|
|||||||
Regular → Executable
+2
@@ -2,4 +2,6 @@
|
|||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
|
vcpkg add port lua
|
||||||
|
|
||||||
cmake . -B bin $1 -DCMAKE_BUILD_TYPE=Release -DBeamMP-Server_ENABLE_LTO=ON -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
cmake . -B bin $1 -DCMAKE_BUILD_TYPE=Release -DBeamMP-Server_ENABLE_LTO=ON -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
||||||
|
|||||||
@@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
cmake --build bin --parallel -t BeamMP-Server
|
cmake --build bin --parallel -t BeamMP-Server --config Release
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "ArgsParser.h"
|
#include "ArgsParser.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|||||||
+21
-1
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
|
|
||||||
#include "CustomAssert.h"
|
#include "CustomAssert.h"
|
||||||
@@ -53,9 +71,9 @@ std::string TClient::GetCarPositionRaw(int Ident) {
|
|||||||
try {
|
try {
|
||||||
return mVehiclePosition.at(size_t(Ident));
|
return mVehiclePosition.at(size_t(Ident));
|
||||||
} catch (const std::out_of_range& oor) {
|
} catch (const std::out_of_range& oor) {
|
||||||
|
beammp_debugf("Failed to get vehicle position for {}: {}", Ident, oor.what());
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TClient::Disconnect(std::string_view Reason) {
|
void TClient::Disconnect(std::string_view Reason) {
|
||||||
@@ -146,6 +164,8 @@ std::optional<std::weak_ptr<TClient>> GetClient(TServer& Server, int ID) {
|
|||||||
MaybeClient = CPtr;
|
MaybeClient = CPtr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
beammp_debugf("Found an expired client while looking for id {}", ID);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|||||||
+36
-2
@@ -1,8 +1,28 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
|
#include "Env.h"
|
||||||
#include "TConsole.h"
|
#include "TConsole.h"
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <charconv>
|
#include <charconv>
|
||||||
|
#include <fmt/core.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
@@ -201,8 +221,11 @@ void Application::CheckForUpdates() {
|
|||||||
auto MyVersion = ServerVersion();
|
auto MyVersion = ServerVersion();
|
||||||
auto RemoteVersion = Version(VersionStrToInts(Response));
|
auto RemoteVersion = Version(VersionStrToInts(Response));
|
||||||
if (IsOutdated(MyVersion, RemoteVersion)) {
|
if (IsOutdated(MyVersion, RemoteVersion)) {
|
||||||
std::string RealVersionString = RemoteVersion.AsString();
|
std::string RealVersionString = std::string("v") + RemoteVersion.AsString();
|
||||||
beammp_warn(std::string(ANSI_YELLOW_BOLD) + "NEW VERSION IS OUT! Please update to the new version (v" + RealVersionString + ") of the BeamMP-Server! Download it here: https://beammp.com/! For a guide on how to update, visit: https://wiki.beammp.com/en/home/server-maintenance#updating-the-server" + std::string(ANSI_RESET));
|
const std::string DefaultUpdateMsg = "NEW VERSION IS OUT! Please update to the new version ({}) of the BeamMP-Server! Download it here: https://beammp.com/! For a guide on how to update, visit: https://wiki.beammp.com/en/home/server-maintenance#updating-the-server";
|
||||||
|
auto UpdateMsg = Env::Get(Env::Key::PROVIDER_UPDATE_MESSAGE).value_or(DefaultUpdateMsg);
|
||||||
|
UpdateMsg = fmt::vformat(std::string_view(UpdateMsg), fmt::make_format_args(RealVersionString));
|
||||||
|
beammp_warnf("{}{}{}", ANSI_YELLOW_BOLD, UpdateMsg, ANSI_RESET);
|
||||||
} else {
|
} else {
|
||||||
if (FirstTime) {
|
if (FirstTime) {
|
||||||
beammp_info("Server up-to-date!");
|
beammp_info("Server up-to-date!");
|
||||||
@@ -348,3 +371,14 @@ std::string GetPlatformAgnosticErrorString() {
|
|||||||
return "(no human-readable errors on this platform)";
|
return "(no human-readable errors on this platform)";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: add unit tests to SplitString
|
||||||
|
void SplitString(const std::string& str, const char delim, std::vector<std::string>& out) {
|
||||||
|
size_t start;
|
||||||
|
size_t end = 0;
|
||||||
|
|
||||||
|
while ((start = str.find_first_not_of(delim, end)) != std::string::npos) {
|
||||||
|
end = str.find(delim, start);
|
||||||
|
out.push_back(str.substr(start, end - start));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "Compat.h"
|
#include "Compat.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "Env.h"
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
std::optional<std::string> Env::Get(Env::Key key) {
|
||||||
|
auto StrKey = ToString(key);
|
||||||
|
auto Value = std::getenv(StrKey.data());
|
||||||
|
if (!Value || std::string_view(Value).empty()) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
return Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view Env::ToString(Env::Key key) {
|
||||||
|
switch (key) {
|
||||||
|
case Key::PROVIDER_UPDATE_MESSAGE:
|
||||||
|
return "BEAMMP_PROVIDER_UPDATE_MESSAGE";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "Http.h"
|
#include "Http.h"
|
||||||
|
|
||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "LuaAPI.h"
|
#include "LuaAPI.h"
|
||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "SignalHandling.h"
|
#include "SignalHandling.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
|
|||||||
+88
-53
@@ -1,6 +1,25 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
#include "TConfig.h"
|
#include "TConfig.h"
|
||||||
|
#include <cstdlib>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
@@ -8,16 +27,29 @@
|
|||||||
|
|
||||||
// General
|
// General
|
||||||
static constexpr std::string_view StrDebug = "Debug";
|
static constexpr std::string_view StrDebug = "Debug";
|
||||||
|
static constexpr std::string_view EnvStrDebug = "BEAMMP_DEBUG";
|
||||||
static constexpr std::string_view StrPrivate = "Private";
|
static constexpr std::string_view StrPrivate = "Private";
|
||||||
|
static constexpr std::string_view EnvStrPrivate = "BEAMMP_PRIVATE";
|
||||||
static constexpr std::string_view StrPort = "Port";
|
static constexpr std::string_view StrPort = "Port";
|
||||||
|
static constexpr std::string_view EnvStrPort = "BEAMMP_PORT";
|
||||||
static constexpr std::string_view StrMaxCars = "MaxCars";
|
static constexpr std::string_view StrMaxCars = "MaxCars";
|
||||||
|
static constexpr std::string_view EnvStrMaxCars = "BEAMMP_MAX_CARS";
|
||||||
static constexpr std::string_view StrMaxPlayers = "MaxPlayers";
|
static constexpr std::string_view StrMaxPlayers = "MaxPlayers";
|
||||||
|
static constexpr std::string_view EnvStrMaxPlayers = "BEAMMP_MAX_PLAYERS";
|
||||||
static constexpr std::string_view StrMap = "Map";
|
static constexpr std::string_view StrMap = "Map";
|
||||||
|
static constexpr std::string_view EnvStrMap = "BEAMMP_MAP";
|
||||||
static constexpr std::string_view StrName = "Name";
|
static constexpr std::string_view StrName = "Name";
|
||||||
|
static constexpr std::string_view EnvStrName = "BEAMMP_NAME";
|
||||||
static constexpr std::string_view StrDescription = "Description";
|
static constexpr std::string_view StrDescription = "Description";
|
||||||
|
static constexpr std::string_view EnvStrDescription = "BEAMMP_DESCRIPTION";
|
||||||
|
static constexpr std::string_view StrTags = "Tags";
|
||||||
|
static constexpr std::string_view EnvStrTags = "BEAMMP_TAGS";
|
||||||
static constexpr std::string_view StrResourceFolder = "ResourceFolder";
|
static constexpr std::string_view StrResourceFolder = "ResourceFolder";
|
||||||
|
static constexpr std::string_view EnvStrResourceFolder = "BEAMMP_RESOURCE_FOLDER";
|
||||||
static constexpr std::string_view StrAuthKey = "AuthKey";
|
static constexpr std::string_view StrAuthKey = "AuthKey";
|
||||||
|
static constexpr std::string_view EnvStrAuthKey = "BEAMMP_AUTH_KEY";
|
||||||
static constexpr std::string_view StrLogChat = "LogChat";
|
static constexpr std::string_view StrLogChat = "LogChat";
|
||||||
|
static constexpr std::string_view EnvStrLogChat = "BEAMMP_LOG_CHAT";
|
||||||
static constexpr std::string_view StrPassword = "Password";
|
static constexpr std::string_view StrPassword = "Password";
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
@@ -25,14 +57,6 @@ static constexpr std::string_view StrSendErrors = "SendErrors";
|
|||||||
static constexpr std::string_view StrSendErrorsMessageEnabled = "SendErrorsShowMessage";
|
static constexpr std::string_view StrSendErrorsMessageEnabled = "SendErrorsShowMessage";
|
||||||
static constexpr std::string_view StrHideUpdateMessages = "ImScaredOfUpdates";
|
static constexpr std::string_view StrHideUpdateMessages = "ImScaredOfUpdates";
|
||||||
|
|
||||||
// HTTP
|
|
||||||
static constexpr std::string_view StrHTTPServerEnabled = "HTTPServerEnabled";
|
|
||||||
static constexpr std::string_view StrHTTPServerUseSSL = "UseSSL";
|
|
||||||
static constexpr std::string_view StrSSLKeyPath = "SSLKeyPath";
|
|
||||||
static constexpr std::string_view StrSSLCertPath = "SSLCertPath";
|
|
||||||
static constexpr std::string_view StrHTTPServerPort = "HTTPServerPort";
|
|
||||||
static constexpr std::string_view StrHTTPServerIP = "HTTPServerIP";
|
|
||||||
|
|
||||||
TEST_CASE("TConfig::TConfig") {
|
TEST_CASE("TConfig::TConfig") {
|
||||||
const std::string CfgFile = "beammp_server_testconfig.toml";
|
const std::string CfgFile = "beammp_server_testconfig.toml";
|
||||||
fs::remove(CfgFile);
|
fs::remove(CfgFile);
|
||||||
@@ -56,7 +80,6 @@ TEST_CASE("TConfig::TConfig") {
|
|||||||
const auto table = toml::parse(CfgFile);
|
const auto table = toml::parse(CfgFile);
|
||||||
CHECK(table.at("General").is_table());
|
CHECK(table.at("General").is_table());
|
||||||
CHECK(table.at("Misc").is_table());
|
CHECK(table.at("Misc").is_table());
|
||||||
CHECK(table.at("HTTP").is_table());
|
|
||||||
|
|
||||||
fs::remove(CfgFile);
|
fs::remove(CfgFile);
|
||||||
}
|
}
|
||||||
@@ -102,34 +125,26 @@ void TConfig::FlushToFile() {
|
|||||||
data["General"][StrPrivate.data()] = Application::Settings.Private;
|
data["General"][StrPrivate.data()] = Application::Settings.Private;
|
||||||
data["General"][StrPort.data()] = Application::Settings.Port;
|
data["General"][StrPort.data()] = Application::Settings.Port;
|
||||||
data["General"][StrName.data()] = Application::Settings.ServerName;
|
data["General"][StrName.data()] = Application::Settings.ServerName;
|
||||||
|
SetComment(data["General"][StrTags.data()].comments(), " Add custom identifying tags to your server to make it easier to find. Format should be TagA,TagB,TagC. Note the comma seperation.");
|
||||||
|
data["General"][StrTags.data()] = Application::Settings.ServerTags;
|
||||||
data["General"][StrMaxCars.data()] = Application::Settings.MaxCars;
|
data["General"][StrMaxCars.data()] = Application::Settings.MaxCars;
|
||||||
data["General"][StrMaxPlayers.data()] = Application::Settings.MaxPlayers;
|
data["General"][StrMaxPlayers.data()] = Application::Settings.MaxPlayers;
|
||||||
data["General"][StrMap.data()] = Application::Settings.MapName;
|
data["General"][StrMap.data()] = Application::Settings.MapName;
|
||||||
data["General"][StrDescription.data()] = Application::Settings.ServerDesc;
|
data["General"][StrDescription.data()] = Application::Settings.ServerDesc;
|
||||||
data["General"][StrResourceFolder.data()] = Application::Settings.Resource;
|
data["General"][StrResourceFolder.data()] = Application::Settings.Resource;
|
||||||
data["General"][StrPassword.data()] = Application::Settings.Password;
|
// data["General"][StrPassword.data()] = Application::Settings.Password;
|
||||||
SetComment(data["General"][StrPassword.data()].comments(), " Sets a password on this server, which restricts people from joining. To join, a player must enter this exact password. Leave empty ("") to disable the password.");
|
// SetComment(data["General"][StrPassword.data()].comments(), " Sets a password on this server, which restricts people from joining. To join, a player must enter this exact password. Leave empty ("") to disable the password.");
|
||||||
// Misc
|
// Misc
|
||||||
data["Misc"][StrHideUpdateMessages.data()] = Application::Settings.HideUpdateMessages;
|
data["Misc"][StrHideUpdateMessages.data()] = Application::Settings.HideUpdateMessages;
|
||||||
SetComment(data["Misc"][StrHideUpdateMessages.data()].comments(), " Hides the periodic update message which notifies you of a new server version. You should really keep this on and always update as soon as possible. For more information visit https://wiki.beammp.com/en/home/server-maintenance#updating-the-server. An update message will always appear at startup regardless.");
|
SetComment(data["Misc"][StrHideUpdateMessages.data()].comments(), " Hides the periodic update message which notifies you of a new server version. You should really keep this on and always update as soon as possible. For more information visit https://wiki.beammp.com/en/home/server-maintenance#updating-the-server. An update message will always appear at startup regardless.");
|
||||||
data["Misc"][StrSendErrors.data()] = Application::Settings.SendErrors;
|
data["Misc"][StrSendErrors.data()] = Application::Settings.SendErrors;
|
||||||
SetComment(data["Misc"][StrSendErrors.data()].comments(), " You can turn on/off the SendErrors message you get on startup here");
|
SetComment(data["Misc"][StrSendErrors.data()].comments(), " If SendErrors is `true`, the server will send helpful info about crashes and other issues back to the BeamMP developers. This info may include your config, who is on your server at the time of the error, and similar general information. This kind of data is vital in helping us diagnose and fix issues faster. This has no impact on server performance. You can opt-out of this system by setting this to `false`");
|
||||||
data["Misc"][StrSendErrorsMessageEnabled.data()] = Application::Settings.SendErrorsMessageEnabled;
|
data["Misc"][StrSendErrorsMessageEnabled.data()] = Application::Settings.SendErrorsMessageEnabled;
|
||||||
SetComment(data["Misc"][StrSendErrorsMessageEnabled.data()].comments(), " If SendErrors is `true`, the server will send helpful info about crashes and other issues back to the BeamMP developers. This info may include your config, who is on your server at the time of the error, and similar general information. This kind of data is vital in helping us diagnose and fix issues faster. This has no impact on server performance. You can opt-out of this system by setting this to `false`");
|
SetComment(data["Misc"][StrSendErrorsMessageEnabled.data()].comments(), " You can turn on/off the SendErrors message you get on startup here");
|
||||||
// HTTP
|
|
||||||
data["HTTP"][StrSSLKeyPath.data()] = Application::Settings.SSLKeyPath;
|
|
||||||
data["HTTP"][StrSSLCertPath.data()] = Application::Settings.SSLCertPath;
|
|
||||||
data["HTTP"][StrHTTPServerPort.data()] = Application::Settings.HTTPServerPort;
|
|
||||||
SetComment(data["HTTP"][StrHTTPServerIP.data()].comments(), " Which IP to listen on. Pick 0.0.0.0 for a public-facing server with no specific IP, and 127.0.0.1 or 'localhost' for a local server.");
|
|
||||||
data["HTTP"][StrHTTPServerIP.data()] = Application::Settings.HTTPServerIP;
|
|
||||||
data["HTTP"][StrHTTPServerUseSSL.data()] = Application::Settings.HTTPServerUseSSL;
|
|
||||||
SetComment(data["HTTP"][StrHTTPServerUseSSL.data()].comments(), " Recommended to have enabled for servers which face the internet. With SSL the server will serve https and requires valid key and cert files");
|
|
||||||
data["HTTP"][StrHTTPServerEnabled.data()] = Application::Settings.HTTPServerEnabled;
|
|
||||||
SetComment(data["HTTP"][StrHTTPServerEnabled.data()].comments(), " Enables the internal HTTP server");
|
|
||||||
std::stringstream Ss;
|
std::stringstream Ss;
|
||||||
Ss << "# This is the BeamMP-Server config file.\n"
|
Ss << "# This is the BeamMP-Server config file.\n"
|
||||||
"# Help & Documentation: `https://wiki.beammp.com/en/home/server-maintenance`\n"
|
"# Help & Documentation: `https://wiki.beammp.com/en/home/server-maintenance`\n"
|
||||||
"# IMPORTANT: Fill in the AuthKey with the key you got from `https://beammp.com/k/dashboard` on the left under \"Keys\"\n"
|
"# IMPORTANT: Fill in the AuthKey with the key you got from `https://keymaster.beammp.com/` on the left under \"Keys\"\n"
|
||||||
<< data;
|
<< data;
|
||||||
auto File = std::fopen(mConfigFileName.c_str(), "w+");
|
auto File = std::fopen(mConfigFileName.c_str(), "w+");
|
||||||
if (!File) {
|
if (!File) {
|
||||||
@@ -159,19 +174,38 @@ void TConfig::CreateConfigFile() {
|
|||||||
FlushToFile();
|
FlushToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TConfig::TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, std::string& OutValue) {
|
void TConfig::TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, const std::string_view& Env, std::string& OutValue) {
|
||||||
|
if (!Env.empty()) {
|
||||||
|
if (const char* envp = std::getenv(Env.data()); envp != nullptr && std::strcmp(envp, "") != 0) {
|
||||||
|
OutValue = std::string(envp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (Table[Category.c_str()][Key.data()].is_string()) {
|
if (Table[Category.c_str()][Key.data()].is_string()) {
|
||||||
OutValue = Table[Category.c_str()][Key.data()].as_string();
|
OutValue = Table[Category.c_str()][Key.data()].as_string();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TConfig::TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, bool& OutValue) {
|
void TConfig::TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, const std::string_view& Env, bool& OutValue) {
|
||||||
|
if (!Env.empty()) {
|
||||||
|
if (const char* envp = std::getenv(Env.data()); envp != nullptr && std::strcmp(envp, "") != 0) {
|
||||||
|
auto Str = std::string(envp);
|
||||||
|
OutValue = Str == "1" || Str == "true";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (Table[Category.c_str()][Key.data()].is_boolean()) {
|
if (Table[Category.c_str()][Key.data()].is_boolean()) {
|
||||||
OutValue = Table[Category.c_str()][Key.data()].as_boolean();
|
OutValue = Table[Category.c_str()][Key.data()].as_boolean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TConfig::TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, int& OutValue) {
|
void TConfig::TryReadValue(toml::value& Table, const std::string& Category, const std::string_view& Key, const std::string_view& Env, int& OutValue) {
|
||||||
|
if (!Env.empty()) {
|
||||||
|
if (const char* envp = std::getenv(Env.data()); envp != nullptr && std::strcmp(envp, "") != 0) {
|
||||||
|
OutValue = int(std::strtol(envp, nullptr, 10));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (Table[Category.c_str()][Key.data()].is_integer()) {
|
if (Table[Category.c_str()][Key.data()].is_integer()) {
|
||||||
OutValue = int(Table[Category.c_str()][Key.data()].as_integer());
|
OutValue = int(Table[Category.c_str()][Key.data()].as_integer());
|
||||||
}
|
}
|
||||||
@@ -181,29 +215,23 @@ void TConfig::ParseFromFile(std::string_view name) {
|
|||||||
try {
|
try {
|
||||||
toml::value data = toml::parse<toml::preserve_comments>(name.data());
|
toml::value data = toml::parse<toml::preserve_comments>(name.data());
|
||||||
// GENERAL
|
// GENERAL
|
||||||
TryReadValue(data, "General", StrDebug, Application::Settings.DebugModeEnabled);
|
TryReadValue(data, "General", StrDebug, EnvStrDebug, Application::Settings.DebugModeEnabled);
|
||||||
TryReadValue(data, "General", StrPrivate, Application::Settings.Private);
|
TryReadValue(data, "General", StrPrivate, EnvStrPrivate, Application::Settings.Private);
|
||||||
TryReadValue(data, "General", StrPort, Application::Settings.Port);
|
TryReadValue(data, "General", StrPort, EnvStrPort, Application::Settings.Port);
|
||||||
TryReadValue(data, "General", StrMaxCars, Application::Settings.MaxCars);
|
TryReadValue(data, "General", StrMaxCars, EnvStrMaxCars, Application::Settings.MaxCars);
|
||||||
TryReadValue(data, "General", StrMaxPlayers, Application::Settings.MaxPlayers);
|
TryReadValue(data, "General", StrMaxPlayers, EnvStrMaxPlayers, Application::Settings.MaxPlayers);
|
||||||
TryReadValue(data, "General", StrMap, Application::Settings.MapName);
|
TryReadValue(data, "General", StrMap, EnvStrMap, Application::Settings.MapName);
|
||||||
TryReadValue(data, "General", StrName, Application::Settings.ServerName);
|
TryReadValue(data, "General", StrName, EnvStrName, Application::Settings.ServerName);
|
||||||
TryReadValue(data, "General", StrDescription, Application::Settings.ServerDesc);
|
TryReadValue(data, "General", StrDescription, EnvStrDescription, Application::Settings.ServerDesc);
|
||||||
TryReadValue(data, "General", StrResourceFolder, Application::Settings.Resource);
|
TryReadValue(data, "General", StrTags, EnvStrTags, Application::Settings.ServerTags);
|
||||||
TryReadValue(data, "General", StrAuthKey, Application::Settings.Key);
|
TryReadValue(data, "General", StrResourceFolder, EnvStrResourceFolder, Application::Settings.Resource);
|
||||||
TryReadValue(data, "General", StrLogChat, Application::Settings.LogChat);
|
TryReadValue(data, "General", StrAuthKey, EnvStrAuthKey, Application::Settings.Key);
|
||||||
TryReadValue(data, "General", StrPassword, Application::Settings.Password);
|
TryReadValue(data, "General", StrLogChat, EnvStrLogChat, Application::Settings.LogChat);
|
||||||
|
TryReadValue(data, "General", StrPassword, "", Application::Settings.Password);
|
||||||
// Misc
|
// Misc
|
||||||
TryReadValue(data, "Misc", StrSendErrors, Application::Settings.SendErrors);
|
TryReadValue(data, "Misc", StrSendErrors, "", Application::Settings.SendErrors);
|
||||||
TryReadValue(data, "Misc", StrHideUpdateMessages, Application::Settings.HideUpdateMessages);
|
TryReadValue(data, "Misc", StrHideUpdateMessages, "", Application::Settings.HideUpdateMessages);
|
||||||
TryReadValue(data, "Misc", StrSendErrorsMessageEnabled, Application::Settings.SendErrorsMessageEnabled);
|
TryReadValue(data, "Misc", StrSendErrorsMessageEnabled, "", Application::Settings.SendErrorsMessageEnabled);
|
||||||
// HTTP
|
|
||||||
TryReadValue(data, "HTTP", StrSSLKeyPath, Application::Settings.SSLKeyPath);
|
|
||||||
TryReadValue(data, "HTTP", StrSSLCertPath, Application::Settings.SSLCertPath);
|
|
||||||
TryReadValue(data, "HTTP", StrHTTPServerPort, Application::Settings.HTTPServerPort);
|
|
||||||
TryReadValue(data, "HTTP", StrHTTPServerIP, Application::Settings.HTTPServerIP);
|
|
||||||
TryReadValue(data, "HTTP", StrHTTPServerEnabled, Application::Settings.HTTPServerEnabled);
|
|
||||||
TryReadValue(data, "HTTP", StrHTTPServerUseSSL, Application::Settings.HTTPServerUseSSL);
|
|
||||||
} catch (const std::exception& err) {
|
} catch (const std::exception& err) {
|
||||||
beammp_error("Error parsing config file value: " + std::string(err.what()));
|
beammp_error("Error parsing config file value: " + std::string(err.what()));
|
||||||
mFailed = true;
|
mFailed = true;
|
||||||
@@ -236,12 +264,9 @@ void TConfig::PrintDebug() {
|
|||||||
beammp_debug(std::string(StrMap) + ": \"" + Application::Settings.MapName + "\"");
|
beammp_debug(std::string(StrMap) + ": \"" + Application::Settings.MapName + "\"");
|
||||||
beammp_debug(std::string(StrName) + ": \"" + Application::Settings.ServerName + "\"");
|
beammp_debug(std::string(StrName) + ": \"" + Application::Settings.ServerName + "\"");
|
||||||
beammp_debug(std::string(StrDescription) + ": \"" + Application::Settings.ServerDesc + "\"");
|
beammp_debug(std::string(StrDescription) + ": \"" + Application::Settings.ServerDesc + "\"");
|
||||||
|
beammp_debug(std::string(StrTags) + ": " + TagsAsPrettyArray());
|
||||||
beammp_debug(std::string(StrLogChat) + ": \"" + (Application::Settings.LogChat ? "true" : "false") + "\"");
|
beammp_debug(std::string(StrLogChat) + ": \"" + (Application::Settings.LogChat ? "true" : "false") + "\"");
|
||||||
beammp_debug(std::string(StrResourceFolder) + ": \"" + Application::Settings.Resource + "\"");
|
beammp_debug(std::string(StrResourceFolder) + ": \"" + Application::Settings.Resource + "\"");
|
||||||
beammp_debug(std::string(StrSSLKeyPath) + ": \"" + Application::Settings.SSLKeyPath + "\"");
|
|
||||||
beammp_debug(std::string(StrSSLCertPath) + ": \"" + Application::Settings.SSLCertPath + "\"");
|
|
||||||
beammp_debug(std::string(StrHTTPServerPort) + ": \"" + std::to_string(Application::Settings.HTTPServerPort) + "\"");
|
|
||||||
beammp_debug(std::string(StrHTTPServerIP) + ": \"" + Application::Settings.HTTPServerIP + "\"");
|
|
||||||
// special!
|
// special!
|
||||||
beammp_debug("Key Length: " + std::to_string(Application::Settings.Key.length()) + "");
|
beammp_debug("Key Length: " + std::to_string(Application::Settings.Key.length()) + "");
|
||||||
beammp_debug("Password Protected: " + std::string(Application::Settings.Password.empty() ? "false" : "true"));
|
beammp_debug("Password Protected: " + std::string(Application::Settings.Password.empty() ? "false" : "true"));
|
||||||
@@ -299,3 +324,13 @@ void TConfig::ParseOldFormat() {
|
|||||||
Str >> std::ws;
|
Str >> std::ws;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::string TConfig::TagsAsPrettyArray() const {
|
||||||
|
std::vector<std::string> TagsArray = {};
|
||||||
|
SplitString(Application::Settings.ServerTags, ',', TagsArray);
|
||||||
|
std::string Pretty = {};
|
||||||
|
for (size_t i = 0; i < TagsArray.size() - 1; ++i) {
|
||||||
|
Pretty += '\"' + TagsArray[i] + "\", ";
|
||||||
|
}
|
||||||
|
Pretty += '\"' + TagsArray.at(TagsArray.size() - 1) + "\"";
|
||||||
|
return Pretty;
|
||||||
|
}
|
||||||
|
|||||||
+48
-27
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "TConsole.h"
|
#include "TConsole.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Compat.h"
|
#include "Compat.h"
|
||||||
@@ -52,17 +70,6 @@ TEST_CASE("TrimString") {
|
|||||||
CHECK(TrimString("") == "");
|
CHECK(TrimString("") == "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add unit tests to SplitString
|
|
||||||
static inline void SplitString(std::string const& str, const char delim, std::vector<std::string>& out) {
|
|
||||||
size_t start;
|
|
||||||
size_t end = 0;
|
|
||||||
|
|
||||||
while ((start = str.find_first_not_of(delim, end)) != std::string::npos) {
|
|
||||||
end = str.find(delim, start);
|
|
||||||
out.push_back(str.substr(start, end - start));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string GetDate() {
|
static std::string GetDate() {
|
||||||
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
|
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
|
||||||
time_t tt = std::chrono::system_clock::to_time_t(now);
|
time_t tt = std::chrono::system_clock::to_time_t(now);
|
||||||
@@ -157,13 +164,13 @@ void TConsole::ChangeToLuaConsole(const std::string& LuaStateId) {
|
|||||||
mIsLuaConsole = true;
|
mIsLuaConsole = true;
|
||||||
if (mStateId != mDefaultStateId) {
|
if (mStateId != mDefaultStateId) {
|
||||||
Application::Console().WriteRaw("Attached to Lua state '" + mStateId + "'. For help, type `:help`. To detach, type `:exit`");
|
Application::Console().WriteRaw("Attached to Lua state '" + mStateId + "'. For help, type `:help`. To detach, type `:exit`");
|
||||||
mCommandline.set_prompt("lua @" + LuaStateId + "> ");
|
mCommandline->set_prompt("lua @" + LuaStateId + "> ");
|
||||||
} else {
|
} else {
|
||||||
Application::Console().WriteRaw("Attached to Lua. For help, type `:help`. To detach, type `:exit`");
|
Application::Console().WriteRaw("Attached to Lua. For help, type `:help`. To detach, type `:exit`");
|
||||||
mCommandline.set_prompt("lua> ");
|
mCommandline->set_prompt("lua> ");
|
||||||
}
|
}
|
||||||
mCachedRegularHistory = mCommandline.history();
|
mCachedRegularHistory = mCommandline->history();
|
||||||
mCommandline.set_history(mCachedLuaHistory);
|
mCommandline->set_history(mCachedLuaHistory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,9 +182,9 @@ void TConsole::ChangeToRegularConsole() {
|
|||||||
} else {
|
} else {
|
||||||
Application::Console().WriteRaw("Detached from Lua.");
|
Application::Console().WriteRaw("Detached from Lua.");
|
||||||
}
|
}
|
||||||
mCachedLuaHistory = mCommandline.history();
|
mCachedLuaHistory = mCommandline->history();
|
||||||
mCommandline.set_history(mCachedRegularHistory);
|
mCommandline->set_history(mCachedRegularHistory);
|
||||||
mCommandline.set_prompt("> ");
|
mCommandline->set_prompt("> ");
|
||||||
mStateId = mDefaultStateId;
|
mStateId = mDefaultStateId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -257,7 +264,7 @@ void TConsole::Command_Clear(const std::string&, const std::vector<std::string>&
|
|||||||
if (!EnsureArgsCount(args, 0, size_t(-1))) {
|
if (!EnsureArgsCount(args, 0, size_t(-1))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mCommandline.write("\x1b[;H\x1b[2J");
|
mCommandline->write("\x1b[;H\x1b[2J");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TConsole::Command_Kick(const std::string&, const std::vector<std::string>& args) {
|
void TConsole::Command_Kick(const std::string&, const std::vector<std::string>& args) {
|
||||||
@@ -589,16 +596,20 @@ Commands
|
|||||||
}
|
}
|
||||||
|
|
||||||
TConsole::TConsole() {
|
TConsole::TConsole() {
|
||||||
mCommandline.enable_history();
|
}
|
||||||
mCommandline.set_history_limit(20);
|
|
||||||
mCommandline.set_prompt("> ");
|
void TConsole::InitializeCommandline() {
|
||||||
|
mCommandline = std::make_unique<Commandline>();
|
||||||
|
mCommandline->enable_history();
|
||||||
|
mCommandline->set_history_limit(20);
|
||||||
|
mCommandline->set_prompt("> ");
|
||||||
BackupOldLog();
|
BackupOldLog();
|
||||||
mCommandline.on_command = [this](Commandline& c) {
|
mCommandline->on_command = [this](Commandline& c) {
|
||||||
try {
|
try {
|
||||||
auto TrimmedCmd = c.get_command();
|
auto TrimmedCmd = c.get_command();
|
||||||
TrimmedCmd = TrimString(TrimmedCmd);
|
TrimmedCmd = TrimString(TrimmedCmd);
|
||||||
auto [cmd, args] = ParseCommand(TrimmedCmd);
|
auto [cmd, args] = ParseCommand(TrimmedCmd);
|
||||||
mCommandline.write(mCommandline.prompt() + TrimmedCmd);
|
mCommandline->write(mCommandline->prompt() + TrimmedCmd);
|
||||||
if (mIsLuaConsole) {
|
if (mIsLuaConsole) {
|
||||||
if (!mLuaEngine) {
|
if (!mLuaEngine) {
|
||||||
beammp_info("Lua not started yet, please try again in a second");
|
beammp_info("Lua not started yet, please try again in a second");
|
||||||
@@ -633,7 +644,7 @@ TConsole::TConsole() {
|
|||||||
beammp_error("Console died with: " + std::string(e.what()) + ". This could be a fatal error and could cause the server to terminate.");
|
beammp_error("Console died with: " + std::string(e.what()) + ". This could be a fatal error and could cause the server to terminate.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
mCommandline.on_autocomplete = [this](Commandline&, std::string stub, int) {
|
mCommandline->on_autocomplete = [this](Commandline&, std::string stub, int) {
|
||||||
std::vector<std::string> suggestions;
|
std::vector<std::string> suggestions;
|
||||||
try {
|
try {
|
||||||
if (mIsLuaConsole) { // if lua
|
if (mIsLuaConsole) { // if lua
|
||||||
@@ -703,11 +714,21 @@ TConsole::TConsole() {
|
|||||||
|
|
||||||
void TConsole::Write(const std::string& str) {
|
void TConsole::Write(const std::string& str) {
|
||||||
auto ToWrite = GetDate() + str;
|
auto ToWrite = GetDate() + str;
|
||||||
mCommandline.write(ToWrite);
|
// allows writing to stdout without an initialized console
|
||||||
|
if (mCommandline) {
|
||||||
|
mCommandline->write(ToWrite);
|
||||||
|
} else {
|
||||||
|
std::cout << ToWrite << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TConsole::WriteRaw(const std::string& str) {
|
void TConsole::WriteRaw(const std::string& str) {
|
||||||
mCommandline.write(str);
|
// allows writing to stdout without an initialized console
|
||||||
|
if (mCommandline) {
|
||||||
|
mCommandline->write(str);
|
||||||
|
} else {
|
||||||
|
std::cout << str << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TConsole::InitializeLuaConsole(TLuaEngine& Engine) {
|
void TConsole::InitializeLuaConsole(TLuaEngine& Engine) {
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "THeartbeatThread.h"
|
#include "THeartbeatThread.h"
|
||||||
|
|
||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
@@ -129,6 +147,7 @@ std::string THeartbeatThread::GenerateCall() {
|
|||||||
<< "&version=" << Application::ServerVersionString()
|
<< "&version=" << Application::ServerVersionString()
|
||||||
<< "&clientversion=" << std::to_string(Application::ClientMajorVersion()) + ".0" // FIXME: Wtf.
|
<< "&clientversion=" << std::to_string(Application::ClientMajorVersion()) + ".0" // FIXME: Wtf.
|
||||||
<< "&name=" << Application::Settings.ServerName
|
<< "&name=" << Application::Settings.ServerName
|
||||||
|
<< "&tags=" << Application::Settings.ServerTags
|
||||||
<< "&modlist=" << mResourceManager.TrimmedList()
|
<< "&modlist=" << mResourceManager.TrimmedList()
|
||||||
<< "&modstotalsize=" << mResourceManager.MaxModSize()
|
<< "&modstotalsize=" << mResourceManager.MaxModSize()
|
||||||
<< "&modstotal=" << mResourceManager.ModsLoaded()
|
<< "&modstotal=" << mResourceManager.ModsLoaded()
|
||||||
|
|||||||
+19
-1
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "TLuaEngine.h"
|
#include "TLuaEngine.h"
|
||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
#include "CustomAssert.h"
|
#include "CustomAssert.h"
|
||||||
@@ -601,7 +619,7 @@ std::pair<sol::table, std::string> TLuaEngine::StateThreadData::Lua_GetPositionR
|
|||||||
return Result;
|
return Result;
|
||||||
} else {
|
} else {
|
||||||
// return std::make_tuple(sol::lua_nil, sol::make_object(StateView, "Client expired"));
|
// return std::make_tuple(sol::lua_nil, sol::make_object(StateView, "Client expired"));
|
||||||
Result.second = "Client expired";
|
Result.second = "No such player";
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "TLuaPlugin.h"
|
#include "TLuaPlugin.h"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|||||||
+20
-2
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "TNetwork.h"
|
#include "TNetwork.h"
|
||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
@@ -101,7 +119,7 @@ void TNetwork::UDPServerMain() {
|
|||||||
Client->SetUDPAddr(client);
|
Client->SetUDPAddr(client);
|
||||||
Client->SetIsConnected(true);
|
Client->SetIsConnected(true);
|
||||||
Data.erase(Data.begin(), Data.begin() + 2);
|
Data.erase(Data.begin(), Data.begin() + 2);
|
||||||
TServer::GlobalParser(ClientPtr, std::move(Data), mPPSMonitor, *this);
|
mServer.GlobalParser(ClientPtr, std::move(Data), mPPSMonitor, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -552,7 +570,7 @@ void TNetwork::TCPClient(const std::weak_ptr<TClient>& c) {
|
|||||||
Client->Disconnect("TCPRcv failed");
|
Client->Disconnect("TCPRcv failed");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
TServer::GlobalParser(c, std::move(res), mPPSMonitor, *this);
|
mServer.GlobalParser(c, std::move(res), mPPSMonitor, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QueueSync.joinable())
|
if (QueueSync.joinable())
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "TPPSMonitor.h"
|
#include "TPPSMonitor.h"
|
||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
#include "TNetwork.h"
|
#include "TNetwork.h"
|
||||||
|
|||||||
+20
-1
@@ -1,6 +1,25 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "TPluginMonitor.h"
|
#include "TPluginMonitor.h"
|
||||||
|
|
||||||
#include "TLuaEngine.h"
|
#include "TLuaEngine.h"
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
TPluginMonitor::TPluginMonitor(const fs::path& Path, std::shared_ptr<TLuaEngine> Engine)
|
TPluginMonitor::TPluginMonitor(const fs::path& Path, std::shared_ptr<TLuaEngine> Engine)
|
||||||
: mEngine(Engine)
|
: mEngine(Engine)
|
||||||
@@ -9,7 +28,7 @@ TPluginMonitor::TPluginMonitor(const fs::path& Path, std::shared_ptr<TLuaEngine>
|
|||||||
if (!fs::exists(mPath)) {
|
if (!fs::exists(mPath)) {
|
||||||
fs::create_directories(mPath);
|
fs::create_directories(mPath);
|
||||||
}
|
}
|
||||||
for (const auto& Entry : fs::recursive_directory_iterator(mPath)) {
|
for (const auto& Entry : fs::recursive_directory_iterator(mPath, fs::directory_options::follow_directory_symlink)) {
|
||||||
// TODO: trigger an event when a subfolder file changes
|
// TODO: trigger an event when a subfolder file changes
|
||||||
if (Entry.is_regular_file()) {
|
if (Entry.is_regular_file()) {
|
||||||
mFileTimes[Entry.path().string()] = fs::last_write_time(Entry.path());
|
mFileTimes[Entry.path().string()] = fs::last_write_time(Entry.path());
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "TResourceManager.h"
|
#include "TResourceManager.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "TScopedTimer.h"
|
#include "TScopedTimer.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
|
|||||||
+96
-24
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "TServer.h"
|
#include "TServer.h"
|
||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
@@ -7,6 +25,7 @@
|
|||||||
#include <TLuaPlugin.h>
|
#include <TLuaPlugin.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <any>
|
#include <any>
|
||||||
|
#include <optional>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
@@ -51,6 +70,30 @@ TEST_CASE("GetPidVid") {
|
|||||||
CHECK_EQ(pid, 10);
|
CHECK_EQ(pid, 10);
|
||||||
CHECK_EQ(vid, 12);
|
CHECK_EQ(vid, 12);
|
||||||
}
|
}
|
||||||
|
SUBCASE("Valid doubledigit 2") {
|
||||||
|
const auto MaybePidVid = GetPidVid("10-2");
|
||||||
|
CHECK(MaybePidVid);
|
||||||
|
auto [pid, vid] = MaybePidVid.value();
|
||||||
|
|
||||||
|
CHECK_EQ(pid, 10);
|
||||||
|
CHECK_EQ(vid, 2);
|
||||||
|
}
|
||||||
|
SUBCASE("Valid doubledigit 3") {
|
||||||
|
const auto MaybePidVid = GetPidVid("33-23");
|
||||||
|
CHECK(MaybePidVid);
|
||||||
|
auto [pid, vid] = MaybePidVid.value();
|
||||||
|
|
||||||
|
CHECK_EQ(pid, 33);
|
||||||
|
CHECK_EQ(vid, 23);
|
||||||
|
}
|
||||||
|
SUBCASE("Valid doubledigit 4") {
|
||||||
|
const auto MaybePidVid = GetPidVid("3-23");
|
||||||
|
CHECK(MaybePidVid);
|
||||||
|
auto [pid, vid] = MaybePidVid.value();
|
||||||
|
|
||||||
|
CHECK_EQ(pid, 3);
|
||||||
|
CHECK_EQ(vid, 23);
|
||||||
|
}
|
||||||
SUBCASE("Empty string") {
|
SUBCASE("Empty string") {
|
||||||
const auto MaybePidVid = GetPidVid("");
|
const auto MaybePidVid = GetPidVid("");
|
||||||
CHECK(!MaybePidVid);
|
CHECK(!MaybePidVid);
|
||||||
@@ -214,6 +257,7 @@ void TServer::GlobalParser(const std::weak_ptr<TClient>& Client, std::vector<uin
|
|||||||
PPSMonitor.IncrementInternalPPS();
|
PPSMonitor.IncrementInternalPPS();
|
||||||
Network.SendToAll(LockedClient.get(), Packet, false, false);
|
Network.SendToAll(LockedClient.get(), Packet, false, false);
|
||||||
HandlePosition(*LockedClient, StringPacket);
|
HandlePosition(*LockedClient, StringPacket);
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -388,7 +432,7 @@ void TServer::Apply(TClient& c, int VID, const std::string& pckt) {
|
|||||||
|
|
||||||
FoundPos = VD.find('{');
|
FoundPos = VD.find('{');
|
||||||
if (FoundPos == std::string::npos) {
|
if (FoundPos == std::string::npos) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
VD = VD.substr(FoundPos);
|
VD = VD.substr(FoundPos);
|
||||||
rapidjson::Document Veh, Pack;
|
rapidjson::Document Veh, Pack;
|
||||||
@@ -422,35 +466,63 @@ void TServer::InsertClient(const std::shared_ptr<TClient>& NewClient) {
|
|||||||
(void)mClients.insert(NewClient);
|
(void)mClients.insert(NewClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TServer::HandlePosition(TClient& c, const std::string& Packet) {
|
struct PidVidData {
|
||||||
|
int PID;
|
||||||
|
int VID;
|
||||||
|
std::string Data;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::optional<PidVidData> ParsePositionPacket(const std::string& Packet) {
|
||||||
if (Packet.size() < 3) {
|
if (Packet.size() < 3) {
|
||||||
// invalid packet
|
// invalid packet
|
||||||
return;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
// Zp:serverVehicleID:data
|
// Zp:PID-VID:DATA
|
||||||
// Zp:0:data
|
|
||||||
std::string withoutCode = Packet.substr(3);
|
std::string withoutCode = Packet.substr(3);
|
||||||
auto NameDataSep = withoutCode.find(':', 2);
|
|
||||||
if (NameDataSep == std::string::npos || NameDataSep < 2) {
|
|
||||||
// invalid packet
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// FIXME: ensure that -2 does what it should... it seems weird.
|
|
||||||
std::string ServerVehicleID = withoutCode.substr(2, NameDataSep - 2);
|
|
||||||
if (NameDataSep + 1 > withoutCode.size()) {
|
|
||||||
// invalid packet
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::string Data = withoutCode.substr(NameDataSep + 1);
|
|
||||||
|
|
||||||
// parse veh ID
|
// parse veh ID
|
||||||
auto MaybePidVid = GetPidVid(ServerVehicleID);
|
if (auto DataBeginPos = withoutCode.find('{'); DataBeginPos != std::string::npos && DataBeginPos != 0) {
|
||||||
if (MaybePidVid) {
|
// separator is :{, so position of { minus one
|
||||||
int PID = -1;
|
auto PidVidOnly = withoutCode.substr(0, DataBeginPos - 1);
|
||||||
int VID = -1;
|
auto MaybePidVid = GetPidVid(PidVidOnly);
|
||||||
// FIXME: check that the VID and PID are valid, so that we don't waste memory
|
if (MaybePidVid) {
|
||||||
std::tie(PID, VID) = MaybePidVid.value();
|
int PID = -1;
|
||||||
|
int VID = -1;
|
||||||
|
// FIXME: check that the VID and PID are valid, so that we don't waste memory
|
||||||
|
std::tie(PID, VID) = MaybePidVid.value();
|
||||||
|
|
||||||
c.SetCarPosition(VID, Data);
|
std::string Data = withoutCode.substr(DataBeginPos);
|
||||||
|
return PidVidData {
|
||||||
|
.PID = PID,
|
||||||
|
.VID = VID,
|
||||||
|
.Data = Data,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
// invalid packet
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// invalid packet
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("ParsePositionPacket") {
|
||||||
|
const auto TestData = R"({"tim":10.428000331623,"vel":[-2.4171722121385e-05,-9.7184734153252e-06,-7.6420763232237e-06],"rot":[-0.0001296154171915,0.0031575385950029,0.98994906610295,0.14138903660382],"rvel":[5.3640324636461e-05,-9.9824529946024e-05,5.1664064641372e-05],"pos":[-0.27281248907838,-0.20515357944633,0.49695488960431],"ping":0.032999999821186})";
|
||||||
|
SUBCASE("All the pids and vids") {
|
||||||
|
for (int pid = 0; pid < 100; ++pid) {
|
||||||
|
for (int vid = 0; vid < 100; ++vid) {
|
||||||
|
std::optional<PidVidData> MaybeRes = ParsePositionPacket(fmt::format("Zp:{}-{}:{}", pid, vid, TestData));
|
||||||
|
CHECK(MaybeRes.has_value());
|
||||||
|
CHECK_EQ(MaybeRes.value().PID, pid);
|
||||||
|
CHECK_EQ(MaybeRes.value().VID, vid);
|
||||||
|
CHECK_EQ(MaybeRes.value().Data, TestData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TServer::HandlePosition(TClient& c, const std::string& Packet) {
|
||||||
|
if (auto Parsed = ParsePositionPacket(Packet); Parsed.has_value()) {
|
||||||
|
c.SetCarPosition(Parsed.value().VID, Parsed.value().Data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "VehicleData.h"
|
#include "VehicleData.h"
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|||||||
+32
-15
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "ArgsParser.h"
|
#include "ArgsParser.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Http.h"
|
#include "Http.h"
|
||||||
@@ -69,7 +87,6 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
int BeamMPServerMain(MainArguments Arguments) {
|
int BeamMPServerMain(MainArguments Arguments) {
|
||||||
setlocale(LC_ALL, "C");
|
setlocale(LC_ALL, "C");
|
||||||
Application::InitializeConsole();
|
|
||||||
ArgsParser Parser;
|
ArgsParser Parser;
|
||||||
Parser.RegisterArgument({ "help" }, ArgsParser::NONE);
|
Parser.RegisterArgument({ "help" }, ArgsParser::NONE);
|
||||||
Parser.RegisterArgument({ "version" }, ArgsParser::NONE);
|
Parser.RegisterArgument({ "version" }, ArgsParser::NONE);
|
||||||
@@ -80,12 +97,10 @@ int BeamMPServerMain(MainArguments Arguments) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (Parser.FoundArgument({ "help" })) {
|
if (Parser.FoundArgument({ "help" })) {
|
||||||
Application::Console().Internal().set_prompt("");
|
|
||||||
Application::Console().WriteRaw(sCommandlineArguments);
|
Application::Console().WriteRaw(sCommandlineArguments);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (Parser.FoundArgument({ "version" })) {
|
if (Parser.FoundArgument({ "version" })) {
|
||||||
Application::Console().Internal().set_prompt("");
|
|
||||||
Application::Console().WriteRaw("BeamMP-Server v" + Application::ServerVersionString());
|
Application::Console().WriteRaw("BeamMP-Server v" + Application::ServerVersionString());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -109,11 +124,22 @@ int BeamMPServerMain(MainArguments Arguments) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TConfig Config(ConfigPath);
|
||||||
|
|
||||||
|
if (Config.Failed()) {
|
||||||
|
beammp_info("Closing in 10 seconds");
|
||||||
|
// loop to make it possible to ctrl+c instead
|
||||||
|
for (size_t i = 0; i < 20; ++i) {
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
Application::InitializeConsole();
|
||||||
|
Application::Console().StartLoggingToFile();
|
||||||
|
|
||||||
Application::SetSubsystemStatus("Main", Application::Status::Starting);
|
Application::SetSubsystemStatus("Main", Application::Status::Starting);
|
||||||
|
|
||||||
Application::Console().StartLoggingToFile();
|
|
||||||
|
|
||||||
SetupSignalHandlers();
|
SetupSignalHandlers();
|
||||||
|
|
||||||
bool Shutdown = false;
|
bool Shutdown = false;
|
||||||
@@ -128,20 +154,11 @@ int BeamMPServerMain(MainArguments Arguments) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
TServer Server(Arguments.List);
|
TServer Server(Arguments.List);
|
||||||
TConfig Config(ConfigPath);
|
|
||||||
auto LuaEngine = std::make_shared<TLuaEngine>();
|
auto LuaEngine = std::make_shared<TLuaEngine>();
|
||||||
LuaEngine->SetServer(&Server);
|
LuaEngine->SetServer(&Server);
|
||||||
Application::Console().InitializeLuaConsole(*LuaEngine);
|
Application::Console().InitializeLuaConsole(*LuaEngine);
|
||||||
|
|
||||||
if (Config.Failed()) {
|
|
||||||
beammp_info("Closing in 10 seconds");
|
|
||||||
// loop to make it possible to ctrl+c instead
|
|
||||||
for (size_t i = 0; i < 20; ++i) {
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
RegisterThread("Main");
|
RegisterThread("Main");
|
||||||
|
|
||||||
beammp_trace("Running in debug mode on a debug build");
|
beammp_trace("Running in debug mode on a debug build");
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
// BeamMP, the BeamNG.drive multiplayer mod.
|
||||||
|
// Copyright (C) 2024 BeamMP Ltd., BeamMP team and contributors.
|
||||||
|
//
|
||||||
|
// BeamMP Ltd. can be contacted by electronic mail via contact@beammp.com.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#define DOCTEST_CONFIG_IMPLEMENT
|
#define DOCTEST_CONFIG_IMPLEMENT
|
||||||
#include <doctest/doctest.h>
|
#include <doctest/doctest.h>
|
||||||
|
|
||||||
|
|||||||
+1
-1
Submodule vcpkg updated: 72010900b7...8397227251
+7
-7
@@ -2,18 +2,18 @@
|
|||||||
"name": "server",
|
"name": "server",
|
||||||
"version-string": "0.1.0",
|
"version-string": "0.1.0",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"fmt",
|
|
||||||
"doctest",
|
|
||||||
"boost-asio",
|
"boost-asio",
|
||||||
"boost-variant",
|
|
||||||
"boost-spirit",
|
"boost-spirit",
|
||||||
"boost-uuid",
|
"boost-uuid",
|
||||||
|
"boost-variant",
|
||||||
"cpp-httplib",
|
"cpp-httplib",
|
||||||
"toml11",
|
"doctest",
|
||||||
|
"fmt",
|
||||||
"libzip",
|
"libzip",
|
||||||
"rapidjson",
|
|
||||||
"nlohmann-json",
|
"nlohmann-json",
|
||||||
"openssl",
|
"openssl",
|
||||||
"sol2"
|
"rapidjson",
|
||||||
|
"sol2",
|
||||||
|
"toml11"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user