mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-02-16 18:50:44 +00:00
Compare commits
120 Commits
v3.1.0
...
259-server
| 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 | ||
|
|
872c2d410d | ||
|
|
f98704e0f3 | ||
|
|
dea203c108 | ||
|
|
e245c9e9e2 | ||
|
|
11fe5ad200 | ||
|
|
667da22b0e | ||
|
|
a6eb2f7bfe | ||
|
|
103d2dc030 | ||
|
|
7f206fd0d4 | ||
|
|
22805af716 | ||
|
|
2c29a195f9 | ||
|
|
222d2492ff | ||
|
|
879b9772f5 | ||
|
|
c51cf090ef | ||
|
|
d677d8d58d | ||
|
|
4b30918659 | ||
|
|
688e46f524 | ||
|
|
9f59c27b1f | ||
|
|
6a11bcd20b | ||
|
|
b7b578bf3e | ||
|
|
6c145a6dbf | ||
|
|
67d792e0e0 | ||
|
|
eaeef0c7d0 | ||
|
|
47e64a7343 | ||
|
|
7f5b3919f4 | ||
|
|
896e777e23 | ||
|
|
aa58c1e211 | ||
|
|
49a9226dca | ||
|
|
b10d5d0f4e | ||
|
|
5581fd1692 | ||
|
|
d36bb7962c | ||
|
|
4e8bd993d5 | ||
|
|
abff9bfbdb | ||
|
|
b024533f90 | ||
|
|
f9251ff92c | ||
|
|
99f41c28cb | ||
|
|
bbd27c9cba | ||
|
|
4682922467 | ||
|
|
83fb387dfe | ||
|
|
2b61f11a86 | ||
|
|
a8b1a205f7 | ||
|
|
dd9376447a | ||
|
|
aa185afabf | ||
|
|
e8caeb9126 |
1
.github/ISSUE_TEMPLATE/bug_report.md
vendored
1
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,7 +1,6 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: "[Bug] Enter issue title here"
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
|
||||
3
.github/ISSUE_TEMPLATE/feature_request.md
vendored
3
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,8 +1,7 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: "[Feature Request]"
|
||||
labels: enhancement
|
||||
labels: feature
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
78
.github/workflows/cmake-linux.yml
vendored
78
.github/workflows/cmake-linux.yml
vendored
@@ -1,78 +0,0 @@
|
||||
name: CMake Linux Build
|
||||
|
||||
on: [push]
|
||||
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
linux-build:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: "recursive"
|
||||
|
||||
- name: Install Dependencies
|
||||
env:
|
||||
beammp_sentry_url: ${{ secrets.BEAMMP_SECRET_SENTRY_URL }}
|
||||
run: |
|
||||
echo ${#beammp_sentry_url}
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libz-dev rapidjson-dev liblua5.3 libssl-dev libwebsocketpp-dev libcurl4-openssl-dev cmake g++-10 libboost1.74-all-dev
|
||||
|
||||
- name: Create Build Environment
|
||||
run: cmake -E make_directory ${{github.workspace}}/build-linux
|
||||
|
||||
- name: Configure CMake
|
||||
shell: bash
|
||||
working-directory: ${{github.workspace}}/build-linux
|
||||
env:
|
||||
beammp_sentry_url: ${{ secrets.BEAMMP_SECRET_SENTRY_URL }}
|
||||
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_COMPILER=g++-10 -DBEAMMP_SECRET_SENTRY_URL="$beammp_sentry_url"
|
||||
|
||||
- name: Build Server
|
||||
working-directory: ${{github.workspace}}/build-linux
|
||||
shell: bash
|
||||
run: cmake --build . --config $BUILD_TYPE -t BeamMP-Server --parallel
|
||||
|
||||
- name: Build Tests
|
||||
working-directory: ${{github.workspace}}/build-linux
|
||||
shell: bash
|
||||
run: cmake --build . --config $BUILD_TYPE -t BeamMP-Server-tests --parallel
|
||||
|
||||
- name: Archive server artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: BeamMP-Server-linux
|
||||
path: ${{github.workspace}}/build-linux/BeamMP-Server
|
||||
|
||||
- name: Archive test artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: BeamMP-Server-linux-tests
|
||||
path: ${{github.workspace}}/build-linux/BeamMP-Server-tests
|
||||
|
||||
run-tests:
|
||||
needs: linux-build
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/download-artifact@master
|
||||
with:
|
||||
name: BeamMP-Server-linux-tests
|
||||
path: ${{github.workspace}}
|
||||
|
||||
- name: Install Runtime Dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y liblua5.3-0 libssl3 curl
|
||||
|
||||
- name: Test
|
||||
working-directory: ${{github.workspace}}
|
||||
shell: bash
|
||||
run: |
|
||||
chmod +x ./BeamMP-Server-tests
|
||||
./BeamMP-Server-tests
|
||||
58
.github/workflows/cmake-windows.yml
vendored
58
.github/workflows/cmake-windows.yml
vendored
@@ -1,58 +0,0 @@
|
||||
name: CMake Windows Build
|
||||
|
||||
on: [push]
|
||||
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
windows-build:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
|
||||
- name: Restore artifacts, or run vcpkg, build and cache artifacts
|
||||
uses: lukka/run-vcpkg@v7
|
||||
id: runvcpkg
|
||||
with:
|
||||
vcpkgArguments: 'lua zlib rapidjson openssl websocketpp curl'
|
||||
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
|
||||
vcpkgGitCommitId: "06b5f4a769d848d1a20fa0acd556019728b56273"
|
||||
vcpkgTriplet: 'x64-windows-static'
|
||||
|
||||
- name: Create Build Environment
|
||||
run: cmake -E make_directory ${{github.workspace}}/build-windows
|
||||
|
||||
- name: Configure CMake
|
||||
shell: bash
|
||||
working-directory: ${{github.workspace}}/build-windows
|
||||
env:
|
||||
beammp_sentry_url: ${{ secrets.BEAMMP_SECRET_SENTRY_URL }}
|
||||
run: cmake $GITHUB_WORKSPACE -DSENTRY_BACKEND=breakpad -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE='${{ runner.workspace }}/b/vcpkg/scripts/buildsystems/vcpkg.cmake' -DVCPKG_TARGET_TRIPLET=x64-windows-static -DBEAMMP_SECRET_SENTRY_URL="$beammp_sentry_url"
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{github.workspace}}/build-windows
|
||||
shell: bash
|
||||
run: cmake --build . --config $BUILD_TYPE
|
||||
|
||||
- name: Archive artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: BeamMP-Server.exe
|
||||
path: ${{github.workspace}}/build-windows/Release/BeamMP-Server.exe
|
||||
|
||||
- name: Build debug
|
||||
working-directory: ${{github.workspace}}/build-windows
|
||||
shell: bash
|
||||
run: |
|
||||
cmake --build . --config Debug
|
||||
|
||||
- name: Archive debug artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: BeamMP-Server-debug.exe
|
||||
path: ${{github.workspace}}/build-windows/Debug/BeamMP-Server.exe
|
||||
|
||||
152
.github/workflows/linux.yml
vendored
Normal file
152
.github/workflows/linux.yml
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
name: Linux
|
||||
|
||||
on: [push]
|
||||
|
||||
|
||||
env:
|
||||
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
||||
VCPKG_FORCE_SYSTEM_BINARIES: 1
|
||||
CMAKE_BUILD_TYPE: "Release"
|
||||
DEBIAN_FRONTEND: "noninteractive"
|
||||
|
||||
jobs:
|
||||
x86_64-matrix:
|
||||
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:
|
||||
image: ${{ matrix.distro }}:${{ matrix.version }}
|
||||
steps:
|
||||
- name: get-cmake
|
||||
uses: lukka/get-cmake@v3.28.1
|
||||
|
||||
- name: Export GitHub Actions cache environment variables
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||
|
||||
- name: Install git
|
||||
run: |
|
||||
apt-get update -y
|
||||
apt-get install -y git
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
|
||||
- name: Git config safe directory
|
||||
shell: bash
|
||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1.5-git-safe.sh
|
||||
|
||||
- name: Install Dependencies
|
||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1-install-deps.sh
|
||||
|
||||
- name: Create Build Environment
|
||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
||||
|
||||
- name: Build Server
|
||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/3-build.sh
|
||||
|
||||
- name: Archive server artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: BeamMP-Server.${{ matrix.distro }}.${{ matrix.version }}.x86_64
|
||||
path: ./bin/BeamMP-Server
|
||||
|
||||
- name: Archive server debug info artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: debuginfo.${{ matrix.distro }}.${{ matrix.version }}.x86_64
|
||||
path: ./bin/BeamMP-Server.debug
|
||||
|
||||
- name: Build Tests
|
||||
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:
|
||||
image: ${{ matrix.distro }}:${{ matrix.version }}
|
||||
steps:
|
||||
- name: get-cmake
|
||||
uses: lukka/get-cmake@v3.28.1
|
||||
|
||||
- name: Export GitHub Actions cache environment variables
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||
|
||||
- name: Install git
|
||||
run: |
|
||||
apt-get update -y
|
||||
apt-get install -y git
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
|
||||
- name: Git config safe directory
|
||||
shell: bash
|
||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1.5-git-safe.sh
|
||||
|
||||
- name: Install Dependencies
|
||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1-install-deps.sh
|
||||
|
||||
- name: Create Build Environment
|
||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
||||
|
||||
- name: Build Server
|
||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/3-build.sh
|
||||
|
||||
- name: Archive server artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: BeamMP-Server.${{ matrix.distro }}.${{ matrix.version }}.arm64
|
||||
path: ./bin/BeamMP-Server
|
||||
|
||||
- name: Archive server debug info artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: debuginfo.${{ matrix.distro }}.${{ matrix.version }}.arm64
|
||||
path: ./bin/BeamMP-Server.debug
|
||||
|
||||
- name: Build Tests
|
||||
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
|
||||
|
||||
115
.github/workflows/release-build.yml
vendored
115
.github/workflows/release-build.yml
vendored
@@ -1,115 +0,0 @@
|
||||
name: Release Create & Build
|
||||
on:
|
||||
push:
|
||||
# Sequence of patterns matched against refs/tags
|
||||
tags:
|
||||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
create-release:
|
||||
runs-on: ubuntu-latest
|
||||
name: Create Release
|
||||
outputs:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
steps:
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: ${{ github.ref }}
|
||||
draft: false
|
||||
prerelease: true
|
||||
body: |
|
||||
Files included in this release:
|
||||
- `BeamMP-Server.exe` is the windows build
|
||||
- `BeamMP-Server-linux` is a ubuntu build, so you need the dependencies listed in README.md to run it. For any other distros please build from source as described in README.md.
|
||||
|
||||
upload-release-files-linux:
|
||||
name: Upload Linux Release Files
|
||||
runs-on: ubuntu-22.04
|
||||
needs: create-release
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libz-dev rapidjson-dev liblua5.3 libssl-dev libwebsocketpp-dev libcurl4-openssl-dev libboost-dev libboost1.74-all-dev libboost1.74-dev
|
||||
|
||||
- name: Create Build Environment
|
||||
run: cmake -E make_directory ${{github.workspace}}/build-linux
|
||||
|
||||
- name: Configure CMake
|
||||
shell: bash
|
||||
working-directory: ${{github.workspace}}/build-linux
|
||||
env:
|
||||
beammp_sentry_url: ${{ secrets.BEAMMP_SECRET_SENTRY_URL }}
|
||||
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_COMPILER=g++-10 -DBEAMMP_SECRET_SENTRY_URL="$beammp_sentry_url"
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{github.workspace}}/build-linux
|
||||
shell: bash
|
||||
run: cmake --build . --config $BUILD_TYPE
|
||||
|
||||
- name: Upload Release Asset
|
||||
id: upload-release-asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.create-release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
||||
asset_path: ${{github.workspace}}/build-linux/BeamMP-Server
|
||||
asset_name: BeamMP-Server-linux
|
||||
asset_content_type: application/x-elf
|
||||
|
||||
upload-release-files-windows:
|
||||
name: Upload Windows Release Files
|
||||
runs-on: windows-latest
|
||||
needs: create-release
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
|
||||
- name: Restore artifacts, or run vcpkg, build and cache artifacts
|
||||
uses: lukka/run-vcpkg@v7
|
||||
id: runvcpkg
|
||||
with:
|
||||
vcpkgArguments: 'lua zlib rapidjson openssl websocketpp curl'
|
||||
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
|
||||
vcpkgGitCommitId: '06b5f4a769d848d1a20fa0acd556019728b56273'
|
||||
vcpkgTriplet: 'x64-windows-static'
|
||||
|
||||
- name: Create Build Environment
|
||||
run: cmake -E make_directory ${{github.workspace}}/build-windows
|
||||
|
||||
- name: Configure CMake
|
||||
shell: bash
|
||||
working-directory: ${{github.workspace}}/build-windows
|
||||
env:
|
||||
beammp_sentry_url: ${{ secrets.BEAMMP_SECRET_SENTRY_URL }}
|
||||
run: cmake $GITHUB_WORKSPACE -DSENTRY_BACKEND=breakpad -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE='${{ runner.workspace }}/b/vcpkg/scripts/buildsystems/vcpkg.cmake' -DVCPKG_TARGET_TRIPLET=x64-windows-static -DBEAMMP_SECRET_SENTRY_URL="$beammp_sentry_url"
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{github.workspace}}/build-windows
|
||||
shell: bash
|
||||
run: cmake --build . --config $BUILD_TYPE
|
||||
|
||||
- name: Upload Release Asset
|
||||
id: upload-release-asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.create-release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
||||
asset_path: ${{github.workspace}}/build-windows/Release/BeamMP-Server.exe
|
||||
asset_name: BeamMP-Server.exe
|
||||
asset_content_type: application/vnd.microsoft.portable-executable
|
||||
215
.github/workflows/release.yml
vendored
Normal file
215
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,215 @@
|
||||
name: Release Create & Build
|
||||
on:
|
||||
push:
|
||||
# Sequence of patterns matched against refs/tags
|
||||
tags:
|
||||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||
|
||||
env:
|
||||
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
||||
CMAKE_BUILD_TYPE: "Release"
|
||||
DEBIAN_FRONTEND: "noninteractive"
|
||||
|
||||
jobs:
|
||||
create-release:
|
||||
runs-on: ubuntu-latest
|
||||
name: Create Release
|
||||
outputs:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
steps:
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: ${{ github.ref }}
|
||||
draft: false
|
||||
prerelease: true
|
||||
body: |
|
||||
Files included in this release are:
|
||||
- `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.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.
|
||||
|
||||
x86_64-matrix:
|
||||
runs-on: ubuntu-22.04
|
||||
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:
|
||||
image: ${{ matrix.distro }}:${{ matrix.version }}
|
||||
steps:
|
||||
- name: get-cmake
|
||||
uses: lukka/get-cmake@v3.28.1
|
||||
|
||||
- name: Export GitHub Actions cache environment variables
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||
|
||||
- name: Install git
|
||||
run: |
|
||||
apt-get update -y
|
||||
apt-get install -y git
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
|
||||
- name: Git config safe directory
|
||||
shell: bash
|
||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1.5-git-safe.sh
|
||||
|
||||
- name: Install Dependencies
|
||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1-install-deps.sh
|
||||
|
||||
- name: Create Build Environment
|
||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
||||
|
||||
- name: Build Server
|
||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/3-build.sh
|
||||
|
||||
- name: Upload Release Asset
|
||||
id: upload-release-asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
asset_name: BeamMP-Server.${{ matrix.distro }}.${{ matrix.version }}.x86_64
|
||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||
asset_path: ./bin/BeamMP-Server
|
||||
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 }}.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
|
||||
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:
|
||||
image: ${{ matrix.distro }}:${{ matrix.version }}
|
||||
steps:
|
||||
- name: get-cmake
|
||||
uses: lukka/get-cmake@v3.28.1
|
||||
|
||||
- name: Export GitHub Actions cache environment variables
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||
|
||||
- name: Install git
|
||||
run: |
|
||||
apt-get update -y
|
||||
apt-get install -y git
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
|
||||
- name: Git config safe directory
|
||||
shell: bash
|
||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1.5-git-safe.sh
|
||||
|
||||
- name: Install Dependencies
|
||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1-install-deps.sh
|
||||
|
||||
- name: Create Build Environment
|
||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
||||
|
||||
- name: Build Server
|
||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/3-build.sh
|
||||
|
||||
- name: Upload Release Asset
|
||||
id: upload-release-asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
asset_name: BeamMP-Server.${{ matrix.distro }}.${{ matrix.version }}.arm64
|
||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||
asset_path: ./bin/BeamMP-Server
|
||||
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
|
||||
|
||||
upload-release-files-windows:
|
||||
name: Build and upload Windows Release Files
|
||||
runs-on: windows-latest
|
||||
needs: create-release
|
||||
env:
|
||||
VCPKG_DEFAULT_TRIPLET: x64-windows-static
|
||||
steps:
|
||||
- name: Export GitHub Actions cache environment variables
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
|
||||
- name: Create Build Environment
|
||||
shell: bash
|
||||
run: ./scripts/windows/1-configure.sh
|
||||
|
||||
- name: Build Server
|
||||
shell: bash
|
||||
run: bash ./scripts/windows/2-build.sh
|
||||
|
||||
- name: Upload Release Asset
|
||||
id: upload-release-asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||
asset_path: ./bin/Release/BeamMP-Server.exe
|
||||
asset_name: BeamMP-Server.exe
|
||||
asset_content_type: application/vnd.microsoft.portable-executable
|
||||
43
.github/workflows/windows.yml
vendored
Normal file
43
.github/workflows/windows.yml
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
name: Windows
|
||||
|
||||
on: [push]
|
||||
|
||||
env:
|
||||
VCPKG_DEFAULT_TRIPLET: x64-windows-static
|
||||
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
||||
CMAKE_BUILD_TYPE: "Release"
|
||||
|
||||
jobs:
|
||||
windows-build:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Export GitHub Actions cache environment variables
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
|
||||
- name: Setup vcpkg
|
||||
uses: lukka/run-vcpkg@v11
|
||||
with:
|
||||
runVcpkgInstall: true
|
||||
|
||||
- name: Create Build Environment
|
||||
shell: bash
|
||||
run: ./scripts/windows/1-configure.sh
|
||||
|
||||
- name: Build Server
|
||||
shell: bash
|
||||
run: bash ./scripts/windows/2-build.sh
|
||||
|
||||
- name: Archive server artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: BeamMP-Server-windows
|
||||
path: ./bin/Release/BeamMP-Server.exe
|
||||
|
||||
33
.gitmodules
vendored
33
.gitmodules
vendored
@@ -1,33 +1,6 @@
|
||||
[submodule "deps/commandline"]
|
||||
path = deps/commandline
|
||||
url = https://github.com/lionkor/commandline
|
||||
[submodule "deps/asio"]
|
||||
path = deps/asio
|
||||
url = https://github.com/chriskohlhoff/asio
|
||||
[submodule "deps/rapidjson"]
|
||||
path = deps/rapidjson
|
||||
url = https://github.com/Tencent/rapidjson
|
||||
[submodule "deps/toml11"]
|
||||
path = deps/toml11
|
||||
url = https://github.com/ToruNiina/toml11
|
||||
[submodule "deps/sentry-native"]
|
||||
path = deps/sentry-native
|
||||
url = https://github.com/getsentry/sentry-native
|
||||
[submodule "deps/sol2"]
|
||||
path = deps/sol2
|
||||
url = https://github.com/ThePhD/sol2
|
||||
[submodule "deps/libzip"]
|
||||
path = deps/libzip
|
||||
url = https://github.com/nih-at/libzip
|
||||
[submodule "deps/cpp-httplib"]
|
||||
path = deps/cpp-httplib
|
||||
url = https://github.com/yhirose/cpp-httplib
|
||||
[submodule "deps/json"]
|
||||
path = deps/json
|
||||
url = https://github.com/nlohmann/json
|
||||
[submodule "deps/fmt"]
|
||||
path = deps/fmt
|
||||
url = https://github.com/fmtlib/fmt
|
||||
[submodule "deps/doctest"]
|
||||
path = deps/doctest
|
||||
url = https://github.com/doctest/doctest
|
||||
[submodule "vcpkg"]
|
||||
path = vcpkg
|
||||
url = https://github.com/Microsoft/vcpkg.git
|
||||
|
||||
422
CMakeLists.txt
422
CMakeLists.txt
@@ -1,261 +1,215 @@
|
||||
# 3.4 is required for imported targets.
|
||||
cmake_minimum_required(VERSION 3.4 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
|
||||
|
||||
message(STATUS "You can find build instructions and a list of dependencies in the README at \
|
||||
https://github.com/BeamMP/BeamMP-Server")
|
||||
|
||||
project(BeamMP-Server
|
||||
DESCRIPTION "Server for BeamMP - The Multiplayer Mod for BeamNG.drive"
|
||||
HOMEPAGE_URL https://beammp.com
|
||||
LANGUAGES CXX C)
|
||||
|
||||
find_package(Git REQUIRED)
|
||||
# Update submodules as needed
|
||||
option(GIT_SUBMODULE "Check submodules during build" ON)
|
||||
if(GIT_SUBMODULE)
|
||||
message(STATUS "Submodule update")
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
RESULT_VARIABLE GIT_SUBMOD_RESULT)
|
||||
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
|
||||
message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
|
||||
endif()
|
||||
if (WIN32)
|
||||
set(VCPKG_TARGET_TRIPLET x64-windows-static)
|
||||
endif()
|
||||
|
||||
include(cmake/Vcpkg.cmake) # needs to happen before project()
|
||||
|
||||
set(HTTPLIB_REQUIRE_OPENSSL ON)
|
||||
set(SENTRY_BUILD_SHARED_LIBS OFF)
|
||||
project(
|
||||
"BeamMP-Server" # replace this
|
||||
VERSION 3.3.0
|
||||
)
|
||||
|
||||
add_compile_definitions(CPPHTTPLIB_OPENSSL_SUPPORT=1)
|
||||
include(cmake/StandardSettings.cmake)
|
||||
include(cmake/StaticAnalyzers.cmake)
|
||||
include(cmake/Git.cmake)
|
||||
|
||||
# ------------------------ APPLE ---------------------------------
|
||||
if(APPLE)
|
||||
if(IS_DIRECTORY /opt/homebrew/Cellar/lua@5.3/5.3.6)
|
||||
set(LUA_INCLUDE_DIR /opt/homebrew/Cellar/lua@5.3/5.3.6/include/lua5.3)
|
||||
link_directories(/opt/homebrew/Cellar/lua@5.3/5.3.6/lib)
|
||||
else()
|
||||
set(LUA_INCLUDE_DIR /usr/local/Cellar/lua@5.3/5.3.6/include/lua5.3)
|
||||
link_directories(/usr/local/Cellar/lua@5.3/5.3.6/lib)
|
||||
endif()
|
||||
set(LUA_LIBRARIES lua)
|
||||
if(IS_DIRECTORY /opt/homebrew/opt/openssl@1.1)
|
||||
include_directories(/opt/homebrew/opt/openssl@1.1/include)
|
||||
link_directories(/opt/homebrew/opt/openssl@1.1/lib)
|
||||
else()
|
||||
include_directories(/usr/local/opt/openssl@1.1/include)
|
||||
link_directories(/usr/local/opt/openssl@1.1/lib)
|
||||
endif()
|
||||
# ------------------------ WINDOWS ---------------------------------
|
||||
option(WIN32_STATIC_RUNTIME "Build statically-linked runtime on windows (don't touch unless you know what you're doing)" ON)
|
||||
elseif (WIN32)
|
||||
# this has to happen before sentry, so that crashpad on windows links with these settings.
|
||||
if (WIN32_STATIC_RUNTIME)
|
||||
message(STATUS "MSVC -> forcing use of statically-linked runtime.")
|
||||
STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
|
||||
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
|
||||
endif()
|
||||
# ------------------------ LINUX ---------------------------------
|
||||
elseif (UNIX)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -fno-builtin")
|
||||
option(SANITIZE "Turns on thread and UB sanitizers" OFF)
|
||||
if (SANITIZE)
|
||||
message(STATUS "sanitize is ON")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize={address,thread,undefined}")
|
||||
endif (SANITIZE)
|
||||
endif ()
|
||||
# below are options which should be changed
|
||||
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
# ------------------------ SENTRY ---------------------------------
|
||||
message(STATUS "Checking for Sentry URL")
|
||||
# this is set by the build system.
|
||||
# IMPORTANT: if you're building from source, just leave this empty
|
||||
if (NOT DEFINED BEAMMP_SECRET_SENTRY_URL)
|
||||
message(WARNING "No sentry URL configured. Sentry logging is disabled for this build. \
|
||||
This is not an error, and if you're building the BeamMP-Server yourself, this is expected and can be ignored.")
|
||||
set(BEAMMP_SECRET_SENTRY_URL "")
|
||||
set(SENTRY_BACKEND none)
|
||||
else()
|
||||
set(SENTRY_BACKEND breakpad)
|
||||
endif()
|
||||
add_subdirectory("deps/sentry-native")
|
||||
### SETTINGS ###
|
||||
|
||||
# ------------------------ C++ SETUP ---------------------------------
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
if (MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
|
||||
endif ()
|
||||
|
||||
# ------------------------ DEPENDENCIES ------------------------------
|
||||
message(STATUS "Adding local source dependencies")
|
||||
# this has to happen before -DDEBUG since it wont compile properly with -DDEBUG
|
||||
add_subdirectory(deps)
|
||||
|
||||
# ------------------------ VARIABLES ---------------------------------
|
||||
|
||||
include(FindLua)
|
||||
include(FindOpenSSL)
|
||||
include(FindThreads)
|
||||
include(FindZLIB)
|
||||
|
||||
find_package(Boost 1.70 REQUIRED COMPONENTS system)
|
||||
|
||||
set(BeamMP_Sources
|
||||
include/TConsole.h src/TConsole.cpp
|
||||
include/TServer.h src/TServer.cpp
|
||||
include/Compat.h src/Compat.cpp
|
||||
include/Common.h src/Common.cpp
|
||||
include/Client.h src/Client.cpp
|
||||
include/VehicleData.h src/VehicleData.cpp
|
||||
include/TConfig.h src/TConfig.cpp
|
||||
include/TLuaEngine.h src/TLuaEngine.cpp
|
||||
include/TLuaPlugin.h src/TLuaPlugin.cpp
|
||||
include/TResourceManager.h src/TResourceManager.cpp
|
||||
include/THeartbeatThread.h src/THeartbeatThread.cpp
|
||||
include/Http.h src/Http.cpp
|
||||
include/TSentry.h src/TSentry.cpp
|
||||
include/TPPSMonitor.h src/TPPSMonitor.cpp
|
||||
include/TNetwork.h src/TNetwork.cpp
|
||||
include/LuaAPI.h src/LuaAPI.cpp
|
||||
include/TScopedTimer.h src/TScopedTimer.cpp
|
||||
include/SignalHandling.h src/SignalHandling.cpp
|
||||
include/ArgsParser.h src/ArgsParser.cpp
|
||||
include/TPluginMonitor.h src/TPluginMonitor.cpp
|
||||
include/Environment.h
|
||||
# add all headers (.h, .hpp) to this
|
||||
set(PRJ_HEADERS
|
||||
include/ArgsParser.h
|
||||
include/BoostAliases.h
|
||||
include/Client.h
|
||||
include/Common.h
|
||||
include/Compat.h
|
||||
include/Cryptography.h
|
||||
include/CustomAssert.h
|
||||
include/Defer.h
|
||||
include/Environment.h
|
||||
include/Http.h
|
||||
include/IThreaded.h
|
||||
include/Json.h
|
||||
include/LuaAPI.h
|
||||
include/RWMutex.h
|
||||
include/SignalHandling.h
|
||||
include/TConfig.h
|
||||
include/TConsole.h
|
||||
include/THeartbeatThread.h
|
||||
include/TLuaEngine.h
|
||||
include/TLuaPlugin.h
|
||||
include/TNetwork.h
|
||||
include/TPluginMonitor.h
|
||||
include/TPPSMonitor.h
|
||||
include/TResourceManager.h
|
||||
include/TScopedTimer.h
|
||||
include/TServer.h
|
||||
include/VehicleData.h
|
||||
include/Env.h
|
||||
)
|
||||
# add all source files (.cpp) to this, except the one with main()
|
||||
set(PRJ_SOURCES
|
||||
src/ArgsParser.cpp
|
||||
src/Client.cpp
|
||||
src/Common.cpp
|
||||
src/Compat.cpp
|
||||
src/Http.cpp
|
||||
src/LuaAPI.cpp
|
||||
src/SignalHandling.cpp
|
||||
src/TConfig.cpp
|
||||
src/TConsole.cpp
|
||||
src/THeartbeatThread.cpp
|
||||
src/TLuaEngine.cpp
|
||||
src/TLuaPlugin.cpp
|
||||
src/TNetwork.cpp
|
||||
src/TPluginMonitor.cpp
|
||||
src/TPPSMonitor.cpp
|
||||
src/TResourceManager.cpp
|
||||
src/TScopedTimer.cpp
|
||||
src/TServer.cpp
|
||||
src/VehicleData.cpp
|
||||
src/Env.cpp
|
||||
)
|
||||
|
||||
set(BeamMP_Includes
|
||||
${LUA_INCLUDE_DIR}
|
||||
${CURL_INCLUDE_DIRS}
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/deps/cpp-httplib"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/deps/commandline"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/deps/json/single_include"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/deps/sol2/include"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/deps/rapidjson/include"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/deps/asio/asio/include"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/deps"
|
||||
)
|
||||
find_package(Lua REQUIRED)
|
||||
|
||||
set(BeamMP_Definitions
|
||||
SECRET_SENTRY_URL="${BEAMMP_SECRET_SENTRY_URL}"
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
list(APPEND BeamMP_Definitions _WIN32_WINNT=0x0601)
|
||||
list(APPEND BeamMP_Definitions _CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
if (UNIX)
|
||||
set(BeamMP_CompileOptions
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wpedantic
|
||||
|
||||
-Werror=uninitialized
|
||||
-Werror=float-equal
|
||||
-Werror=pointer-arith
|
||||
-Werror=double-promotion
|
||||
-Werror=write-strings
|
||||
-Werror=cast-qual
|
||||
-Werror=init-self
|
||||
-Werror=cast-align
|
||||
-Werror=unreachable-code
|
||||
-Werror=strict-aliasing -fstrict-aliasing
|
||||
-Werror=redundant-decls
|
||||
-Werror=missing-declarations
|
||||
-Werror=missing-field-initializers
|
||||
-Werror=write-strings
|
||||
-Werror=ctor-dtor-privacy
|
||||
-Werror=switch-enum
|
||||
-Werror=switch-default
|
||||
-Werror=old-style-cast
|
||||
-Werror=overloaded-virtual
|
||||
-Werror=overloaded-virtual
|
||||
-Werror=missing-include-dirs
|
||||
-Werror=unused-result
|
||||
|
||||
-fstack-protector
|
||||
-Wzero-as-null-pointer-constant
|
||||
)
|
||||
endif()
|
||||
|
||||
set(BeamMP_Libraries
|
||||
Boost::boost
|
||||
Boost::system
|
||||
doctest::doctest
|
||||
OpenSSL::SSL
|
||||
OpenSSL::Crypto
|
||||
sol2::sol2
|
||||
# set the source file containing main()
|
||||
set(PRJ_MAIN src/main.cpp)
|
||||
# set the source file containing the test's main
|
||||
set(PRJ_TEST_MAIN test/test_main.cpp)
|
||||
# set include paths not part of libraries
|
||||
set(PRJ_INCLUDE_DIRS ${LUA_INCLUDE_DIR})
|
||||
# set compile features (e.g. standard version)
|
||||
set(PRJ_COMPILE_FEATURES cxx_std_20)
|
||||
# set #defines (test enable/disable not included here)
|
||||
set(PRJ_DEFINITIONS CPPHTTPLIB_OPENSSL_SUPPORT)
|
||||
# add all libraries used by the project (WARNING: also set them in vcpkg.json!)
|
||||
set(PRJ_LIBRARIES
|
||||
fmt::fmt
|
||||
doctest::doctest
|
||||
Threads::Threads
|
||||
ZLIB::ZLIB
|
||||
commandline_static
|
||||
toml11::toml11
|
||||
rapidjson
|
||||
sol2
|
||||
httplib::httplib
|
||||
libzip::zip
|
||||
OpenSSL::SSL OpenSSL::Crypto
|
||||
${LUA_LIBRARIES}
|
||||
commandline
|
||||
sentry
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
set(BeamMP_PlatformLibs wsock32 ws2_32)
|
||||
endif ()
|
||||
# add dependency find_package calls and similar here
|
||||
find_package(fmt CONFIG REQUIRED)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(doctest CONFIG REQUIRED)
|
||||
find_package(Boost REQUIRED)
|
||||
find_package(httplib CONFIG REQUIRED)
|
||||
find_package(libzip CONFIG REQUIRED)
|
||||
find_package(RapidJSON CONFIG REQUIRED)
|
||||
find_package(sol2 CONFIG REQUIRED)
|
||||
find_package(toml11 CONFIG REQUIRED)
|
||||
|
||||
# ------------------------ BEAMMP SERVER -----------------------------
|
||||
include_directories(include)
|
||||
|
||||
add_executable(BeamMP-Server
|
||||
src/main.cpp
|
||||
${BeamMP_Sources}
|
||||
)
|
||||
# to enable multithreading and the Threads::Threads dependency
|
||||
include(FindThreads)
|
||||
|
||||
target_compile_definitions(BeamMP-Server PRIVATE
|
||||
${BeamMP_Definitions}
|
||||
DOCTEST_CONFIG_DISABLE
|
||||
)
|
||||
### END SETTINGS ###
|
||||
|
||||
target_compile_options(BeamMP-Server PRIVATE
|
||||
${BeamMP_CompileOptions}
|
||||
)
|
||||
# DONT change anything beyond this point unless you've read the cmake bible and
|
||||
# swore on it not to bonk up the ci/cd pipelines with your changes.
|
||||
|
||||
target_include_directories(BeamMP-Server PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
)
|
||||
####################
|
||||
|
||||
target_include_directories(BeamMP-Server SYSTEM PRIVATE
|
||||
${BeamMP_Includes}
|
||||
)
|
||||
|
||||
target_link_libraries(BeamMP-Server
|
||||
${BeamMP_Libraries}
|
||||
${BeamMP_PlatformLibs}
|
||||
)
|
||||
# enables compile_commands.json for clang-related tools (such as the clang LS)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# ------------------------ BEAMMP SERVER TESTS -----------------------
|
||||
|
||||
option(BUILD_TESTS "Build BeamMP-Server tests" ON)
|
||||
|
||||
if(BUILD_TESTS)
|
||||
add_executable(BeamMP-Server-tests
|
||||
test/test_main.cpp
|
||||
${BeamMP_Sources}
|
||||
)
|
||||
|
||||
target_compile_definitions(BeamMP-Server-tests PRIVATE
|
||||
${BeamMP_Definitions}
|
||||
)
|
||||
|
||||
target_compile_options(BeamMP-Server-tests PRIVATE
|
||||
${BeamMP_CompileOptions}
|
||||
)
|
||||
|
||||
target_include_directories(BeamMP-Server-tests PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
)
|
||||
|
||||
target_include_directories(BeamMP-Server-tests SYSTEM PRIVATE
|
||||
${BeamMP_Includes}
|
||||
)
|
||||
|
||||
target_link_libraries(BeamMP-Server-tests
|
||||
${BeamMP_Libraries}
|
||||
${BeamMP_PlatformLibs}
|
||||
)
|
||||
# build release builds by default (if not specified otherwise)
|
||||
if(NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
message(NOTICE "No build type specified, defaulting to 'Release'")
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
# this will allow to use same _DEBUG macro available in both Linux as well as Windows - MSCV environment. Easy to put Debug specific code.
|
||||
add_compile_options("$<$<CONFIG:DEBUG>:-D_DEBUG>")
|
||||
endif(UNIX)
|
||||
|
||||
if (WIN32)
|
||||
add_compile_options("-D_WIN32_WINNT=0x0601")
|
||||
endif(WIN32)
|
||||
|
||||
|
||||
include(cmake/CompilerWarnings.cmake)
|
||||
|
||||
# set MT library for msvc - this is required (says documentation)
|
||||
# linux/mac/etc should simply ignore this by default.
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
|
||||
set(PRJ_DEFINITIONS ${PRJ_DEFINITIONS}
|
||||
PRJ_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
|
||||
PRJ_VERSION_MINOR=${PROJECT_VERSION_MINOR}
|
||||
PRJ_VERSION_PATCH=${PROJECT_VERSION_PATCH}
|
||||
)
|
||||
|
||||
# build commandline manually for funky windows flags to carry over without a custom toolchain file
|
||||
add_library(commandline_static
|
||||
deps/commandline/src/impls.h
|
||||
deps/commandline/src/windows_impl.cpp
|
||||
deps/commandline/src/linux_impl.cpp
|
||||
deps/commandline/src/backends/InteractiveBackend.cpp
|
||||
deps/commandline/src/backends/InteractiveBackend.h
|
||||
deps/commandline/src/backends/Backend.cpp
|
||||
deps/commandline/src/backends/Backend.h
|
||||
deps/commandline/src/commandline.h
|
||||
deps/commandline/src/commandline.cpp
|
||||
deps/commandline/src/backends/BufferedBackend.cpp
|
||||
deps/commandline/src/backends/BufferedBackend.h
|
||||
)
|
||||
if (WIN32)
|
||||
target_compile_definitions(commandline_static PRIVATE -DPLATFORM_WINDOWS=1)
|
||||
else ()
|
||||
target_compile_definitions(commandline_static PRIVATE -DPLATFORM_LINUX=1)
|
||||
endif ()
|
||||
target_include_directories(commandline_static PUBLIC "deps/commandline/src")
|
||||
target_link_libraries(commandline_static Threads::Threads)
|
||||
# end of commandline custom build
|
||||
|
||||
add_executable(${PROJECT_NAME} ${PRJ_HEADERS} ${PRJ_SOURCES} ${PRJ_MAIN})
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
||||
MACOSX_BUNDLE TRUE
|
||||
WIN32_EXECUTABLE TRUE
|
||||
)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${PRJ_INCLUDE_DIRS})
|
||||
target_link_libraries(${PROJECT_NAME} ${PRJ_LIBRARIES})
|
||||
target_compile_features(${PROJECT_NAME} PRIVATE ${PRJ_COMPILE_FEATURES})
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE ${PRJ_DEFINITIONS} ${PRJ_WARNINGS}
|
||||
DOCTEST_CONFIG_DISABLE # disables all test code in the final executable
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
target_link_options(${PROJECT_NAME} PRIVATE "/SUBSYSTEM:CONSOLE")
|
||||
endif(MSVC)
|
||||
|
||||
# setup all warnings (from cmake/CompilerWarnings.cmake)
|
||||
set_project_warnings(${PROJECT_NAME})
|
||||
|
||||
if(${PROJECT_NAME}_ENABLE_UNIT_TESTING)
|
||||
message(STATUS "Unit tests are enabled and will be built as '${PROJECT_NAME}-tests'")
|
||||
add_executable(${PROJECT_NAME}-tests ${PRJ_HEADERS} ${PRJ_SOURCES} ${PRJ_TEST_MAIN})
|
||||
target_include_directories(${PROJECT_NAME}-tests PRIVATE ${PRJ_INCLUDE_DIRS})
|
||||
target_link_libraries(${PROJECT_NAME}-tests ${PRJ_LIBRARIES})
|
||||
target_compile_features(${PROJECT_NAME}-tests PRIVATE ${PRJ_COMPILE_FEATURES})
|
||||
target_compile_definitions(${PROJECT_NAME}-tests PRIVATE ${PRJ_DEFINITIONS} ${PRJ_WARNINGS})
|
||||
set_project_warnings(${PROJECT_NAME}-tests)
|
||||
if(MSVC)
|
||||
target_link_options(${PROJECT_NAME}-tests PRIVATE "/SUBSYSTEM:CONSOLE")
|
||||
endif(MSVC)
|
||||
endif()
|
||||
|
||||
|
||||
149
Changelog.md
149
Changelog.md
@@ -1,149 +0,0 @@
|
||||
|
||||
# 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
|
||||
141
README.md
141
README.md
@@ -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/).
|
||||
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
|
||||
|
||||
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)
|
||||
- **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
|
||||
|
||||
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.
|
||||
|
||||
@@ -51,133 +50,37 @@ You can find precompiled binaries under [Releases](https://github.com/BeamMP/Bea
|
||||
|
||||
## 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.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
Ubuntu 22.04
|
||||
</summary>
|
||||
Debian, Ubuntu and friends: `liblua5.3-0`
|
||||
|
||||
`apt-get install` the following libraries:
|
||||
```
|
||||
liblua5.3-0
|
||||
libssl3
|
||||
curl
|
||||
```
|
||||
</details>
|
||||
Other Linux distros: `liblua` of *some kind*.
|
||||
|
||||
<details>
|
||||
<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).
|
||||
|
||||
**Ubuntu 22.04**
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
Ubuntu 22.04
|
||||
</summary>
|
||||
|
||||
`apt-get install` the following libraries and programs:
|
||||
```
|
||||
git
|
||||
libz-dev
|
||||
rapidjson-dev
|
||||
liblua5.3
|
||||
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++
|
||||
cmake
|
||||
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 &`*.*
|
||||
Windows: No libraries.
|
||||
|
||||
## 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.
|
||||
|
||||
115
cmake/CompilerWarnings.cmake
Normal file
115
cmake/CompilerWarnings.cmake
Normal file
@@ -0,0 +1,115 @@
|
||||
# from here:
|
||||
#
|
||||
# https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Available.md
|
||||
# Courtesy of Jason Turner
|
||||
# License here: https://github.com/cpp-best-practices/cppbestpractices/blob/master/LICENSE
|
||||
#
|
||||
# This version has been modified by the owners of the current respository.
|
||||
# Modifications have mostly been marked with "modified" or similar, though this is not
|
||||
# strictly required.
|
||||
|
||||
function(set_project_warnings project_name)
|
||||
set(MSVC_WARNINGS
|
||||
/W4 # Baseline reasonable warnings
|
||||
/w14242 # 'identifier': conversion from 'type1' to 'type1', possible loss
|
||||
# of data
|
||||
/w14254 # 'operator': conversion from 'type1:field_bits' to
|
||||
# 'type2:field_bits', possible loss of data
|
||||
/w14263 # 'function': member function does not override any base class
|
||||
# virtual member function
|
||||
/w14265 # 'classname': class has virtual functions, but destructor is not
|
||||
# virtual instances of this class may not be destructed correctly
|
||||
/w14287 # 'operator': unsigned/negative constant mismatch
|
||||
/we4289 # nonstandard extension used: 'variable': loop control variable
|
||||
# declared in the for-loop is used outside the for-loop scope
|
||||
/w14296 # 'operator': expression is always 'boolean_value'
|
||||
/w14311 # 'variable': pointer truncation from 'type1' to 'type2'
|
||||
/w14545 # expression before comma evaluates to a function which is missing
|
||||
# an argument list
|
||||
/w14546 # function call before comma missing argument list
|
||||
/w14547 # 'operator': operator before comma has no effect; expected
|
||||
# operator with side-effect
|
||||
/w14549 # 'operator': operator before comma has no effect; did you intend
|
||||
# 'operator'?
|
||||
/w14555 # expression has no effect; expected expression with side- effect
|
||||
/w14619 # pragma warning: there is no warning number 'number'
|
||||
/w14640 # Enable warning on thread un-safe static member initialization
|
||||
/w14826 # Conversion from 'type1' to 'type_2' is sign-extended. This may
|
||||
# cause unexpected runtime behavior.
|
||||
/w14905 # wide string literal cast to 'LPSTR'
|
||||
/w14906 # string literal cast to 'LPWSTR'
|
||||
/w14928 # illegal copy-initialization; more than one user-defined
|
||||
# conversion has been implicitly applied
|
||||
/permissive- # standards conformance mode for MSVC compiler.
|
||||
)
|
||||
|
||||
set(CLANG_WARNINGS
|
||||
-Wall
|
||||
-Wextra # reasonable and standard
|
||||
-Wshadow # warn the user if a variable declaration shadows one from a
|
||||
# parent context
|
||||
-Wnon-virtual-dtor # warn the user if a class with virtual functions has a
|
||||
# non-virtual destructor. This helps catch hard to
|
||||
# track down memory errors
|
||||
-Wold-style-cast # warn for c-style casts
|
||||
-Wcast-align # warn for potential performance problem casts
|
||||
-Wunused # warn on anything being unused
|
||||
-Woverloaded-virtual # warn if you overload (not override) a virtual
|
||||
# function
|
||||
-Wpedantic # warn if non-standard C++ is used
|
||||
-Wconversion # warn on type conversions that may lose data
|
||||
-Wsign-conversion # warn on sign conversions
|
||||
-Wnull-dereference # warn if a null dereference is detected
|
||||
-Wdouble-promotion # warn if float is implicit promoted to double
|
||||
-Wformat=2 # warn on security issues around functions that format output
|
||||
# (ie printf)
|
||||
# modified; added more errors / warnings
|
||||
# some have been set to be errors, but the option _WARNINGS_AS_ERRORS
|
||||
# (see below) should still be used in strict pipelines.
|
||||
-Werror=uninitialized
|
||||
-Werror=float-equal
|
||||
-Werror=write-strings
|
||||
-Werror=strict-aliasing -fstrict-aliasing
|
||||
-Werror=missing-declarations
|
||||
-Werror=missing-field-initializers
|
||||
-Werror=ctor-dtor-privacy
|
||||
-Werror=switch-enum
|
||||
-Wswitch-default
|
||||
-Werror=unused-result
|
||||
-Werror=implicit-fallthrough
|
||||
-Werror=return-type
|
||||
-Wmissing-include-dirs
|
||||
)
|
||||
|
||||
if (${PROJECT_NAME}_WARNINGS_AS_ERRORS)
|
||||
set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror)
|
||||
set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX)
|
||||
endif()
|
||||
|
||||
set(GCC_WARNINGS
|
||||
${CLANG_WARNINGS}
|
||||
-Wmisleading-indentation # warn if indentation implies blocks where blocks
|
||||
# do not exist
|
||||
-Wduplicated-cond # warn if if / else chain has duplicated conditions
|
||||
-Wduplicated-branches # warn if if / else branches have duplicated code
|
||||
-Wlogical-op # warn about logical operations being used where bitwise were
|
||||
# probably wanted
|
||||
# -Wuseless-cast # warn if you perform a cast to the same type (modified: removed)
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
set(PRJ_WARNINGS ${MSVC_WARNINGS})
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
|
||||
set(PRJ_WARNINGS ${CLANG_WARNINGS})
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(PRJ_WARNINGS ${GCC_WARNINGS})
|
||||
else()
|
||||
message(AUTHOR_WARNING "No compiler warnings set for '${CMAKE_CXX_COMPILER_ID}' compiler.")
|
||||
endif()
|
||||
|
||||
target_compile_options(${project_name} PUBLIC ${PRJ_WARNINGS})
|
||||
|
||||
if(NOT TARGET ${project_name})
|
||||
message(AUTHOR_WARNING "${project_name} is not a target, thus no compiler warning were added.")
|
||||
endif()
|
||||
endfunction()
|
||||
21
cmake/Git.cmake
Normal file
21
cmake/Git.cmake
Normal file
@@ -0,0 +1,21 @@
|
||||
find_package(Git)
|
||||
if(${PROJECT_NAME}_CHECKOUT_GIT_SUBMODULES)
|
||||
if(Git_FOUND)
|
||||
message(STATUS "Git found, submodule update and init")
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
RESULT_VARIABLE GIT_SUBMOD_RESULT)
|
||||
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
|
||||
message(SEND_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules. This may result in missing dependencies.")
|
||||
endif()
|
||||
else()
|
||||
message(SEND_ERROR "git required for checking out submodules, but not found. Submodules will not be checked out - this may result in missing dependencies.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(Git_FOUND)
|
||||
|
||||
else()
|
||||
message(STATUS "Git not found - the version will not include a git hash.")
|
||||
set(PRJ_GIT_HASH "unknown")
|
||||
endif()
|
||||
44
cmake/StandardSettings.cmake
Normal file
44
cmake/StandardSettings.cmake
Normal file
@@ -0,0 +1,44 @@
|
||||
# Modified, original version from https://github.com/filipdutescu/modern-cpp-template (Unlicense)
|
||||
|
||||
option(${PROJECT_NAME}_WARNINGS_AS_ERRORS "Treat compiler warnings as errors." OFF)
|
||||
option(${PROJECT_NAME}_CHECKOUT_GIT_SUBMODULES "If git is found, initialize all submodules." ON)
|
||||
option(${PROJECT_NAME}_ENABLE_UNIT_TESTING "Enable unit tests for the projects (from the `test` subfolder)." ON)
|
||||
option(${PROJECT_NAME}_ENABLE_CLANG_TIDY "Enable static analysis with Clang-Tidy." OFF)
|
||||
option(${PROJECT_NAME}_ENABLE_CPPCHECK "Enable static analysis with Cppcheck." OFF)
|
||||
# TODO Implement code coverage
|
||||
# option(${PROJECT_NAME}_ENABLE_CODE_COVERAGE "Enable code coverage through GCC." OFF)
|
||||
option(${PROJECT_NAME}_ENABLE_DOXYGEN "Enable Doxygen documentation builds of source." OFF)
|
||||
|
||||
# Generate compile_commands.json for clang based tools
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# Export all symbols when building a shared library
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF)
|
||||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
|
||||
endif()
|
||||
|
||||
option(${PROJECT_NAME}_ENABLE_LTO "Enable Interprocedural Optimization, aka Link Time Optimization (LTO)." OFF)
|
||||
if(${PROJECT_NAME}_ENABLE_LTO)
|
||||
include(CheckIPOSupported)
|
||||
check_ipo_supported(RESULT result OUTPUT output)
|
||||
if(result)
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
else()
|
||||
message(SEND_ERROR "IPO is not supported: ${output}.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(${PROJECT_NAME}_ENABLE_CCACHE "Enable the usage of Ccache, in order to speed up rebuild times." ON)
|
||||
find_program(CCACHE_FOUND ccache)
|
||||
if(CCACHE_FOUND)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
||||
endif()
|
||||
|
||||
option(${PROJECT_NAME}_ENABLE_SANITIZER "Enable sanitizer to detect memory errors, undefined behavior, etc. (slows down the executable)." OFF)
|
||||
if(${PROJECT_NAME}_ENABLE_SANITIZER)
|
||||
add_compile_options(-fsanitize=address,undefined)
|
||||
add_link_options(-fsanitize=address,undefined)
|
||||
endif()
|
||||
20
cmake/StaticAnalyzers.cmake
Normal file
20
cmake/StaticAnalyzers.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
if(${PROJECT_NAME}_ENABLE_CLANG_TIDY)
|
||||
find_program(CLANGTIDY clang-tidy)
|
||||
if(CLANGTIDY)
|
||||
set(CMAKE_CXX_CLANG_TIDY ${CLANGTIDY} -extra-arg=-Wno-unknown-warning-option)
|
||||
message("Clang-Tidy finished setting up.")
|
||||
else()
|
||||
message(SEND_ERROR "Clang-Tidy requested but executable not found.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${PROJECT_NAME}_ENABLE_CPPCHECK)
|
||||
find_program(CPPCHECK cppcheck)
|
||||
if(CPPCHECK)
|
||||
set(CMAKE_CXX_CPPCHECK ${CPPCHECK} --suppress=missingInclude --enable=all
|
||||
--inline-suppr --inconclusive)
|
||||
message("Cppcheck finished setting up.")
|
||||
else()
|
||||
message(SEND_ERROR "Cppcheck requested but executable not found.")
|
||||
endif()
|
||||
endif()
|
||||
17
cmake/Vcpkg.cmake
Normal file
17
cmake/Vcpkg.cmake
Normal file
@@ -0,0 +1,17 @@
|
||||
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake)
|
||||
find_package(Git)
|
||||
if(Git_FOUND)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive vcpkg
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
RESULT_VARIABLE GIT_SUBMOD_RESULT)
|
||||
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
|
||||
message(SEND_ERROR "Checking out vcpkg in source tree failed with ${GIT_SUBMOD_RESULT}.")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Could not find git or vcpkg.cmake. Please either, install git and re-run cmake (or run `git submodule update --init --recursive`), or install vcpkg and add `-DCMAKE_TOOLCHAIN_FILE=<path-to-vcpkg>/scripts/buildsystems/vcpkg.cmake` to your cmake invocation. Please try again after making those changes.")
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake)
|
||||
endif()
|
||||
|
||||
6
deps/CMakeLists.txt
vendored
6
deps/CMakeLists.txt
vendored
@@ -1,6 +0,0 @@
|
||||
include_directories("${PROJECT_SOURCE_DIR}/deps")
|
||||
|
||||
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/commandline")
|
||||
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/fmt")
|
||||
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/sol2")
|
||||
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/doctest")
|
||||
1
deps/asio
vendored
1
deps/asio
vendored
Submodule deps/asio deleted from 4915cfd8a1
2
deps/commandline
vendored
2
deps/commandline
vendored
Submodule deps/commandline updated: 470cf2df4a...b2a29733f9
1
deps/cpp-httplib
vendored
1
deps/cpp-httplib
vendored
Submodule deps/cpp-httplib deleted from d92c314466
1
deps/doctest
vendored
1
deps/doctest
vendored
Submodule deps/doctest deleted from b7c21ec5ce
1
deps/fmt
vendored
1
deps/fmt
vendored
Submodule deps/fmt deleted from c4ee726532
1
deps/json
vendored
1
deps/json
vendored
Submodule deps/json deleted from 69d744867f
1
deps/libzip
vendored
1
deps/libzip
vendored
Submodule deps/libzip deleted from 5532f9baa0
1
deps/rapidjson
vendored
1
deps/rapidjson
vendored
Submodule deps/rapidjson deleted from 00dbcf2c6e
1
deps/sentry-native
vendored
1
deps/sentry-native
vendored
Submodule deps/sentry-native deleted from 28be51f5e3
1
deps/sol2
vendored
1
deps/sol2
vendored
Submodule deps/sol2 deleted from eba86625b7
1
deps/toml11
vendored
1
deps/toml11
vendored
Submodule deps/toml11 deleted from c7627ff6a1
@@ -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
|
||||
|
||||
#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
|
||||
|
||||
#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
|
||||
|
||||
#include <chrono>
|
||||
|
||||
@@ -1,7 +1,22 @@
|
||||
#pragma once
|
||||
// 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 "TSentry.h"
|
||||
extern TSentry Sentry;
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
@@ -46,9 +61,11 @@ public:
|
||||
struct TSettings {
|
||||
std::string ServerName { "BeamMP Server" };
|
||||
std::string ServerDesc { "BeamMP Default Description" };
|
||||
std::string ServerTags { "Freeroam" };
|
||||
std::string Resource { "Resources" };
|
||||
std::string MapName { "/levels/gridmap_v2/info.json" };
|
||||
std::string Key {};
|
||||
std::string Password{};
|
||||
std::string SSLKeyPath { "./.ssl/HttpServer/key.pem" };
|
||||
std::string SSLCertPath { "./.ssl/HttpServer/cert.pem" };
|
||||
bool HTTPServerEnabled { false };
|
||||
@@ -77,7 +94,7 @@ public:
|
||||
static void RegisterShutdownHandler(const TShutdownHandler& Handler);
|
||||
// Causes all threads to finish up and exit gracefull gracefully
|
||||
static void GracefullyShutdown();
|
||||
static TConsole& Console() { return *mConsole; }
|
||||
static TConsole& Console() { return mConsole; }
|
||||
static std::string ServerVersionString();
|
||||
static const Version& ServerVersion() { return mVersion; }
|
||||
static uint8_t ClientMajorVersion() { return 2; }
|
||||
@@ -103,9 +120,7 @@ public:
|
||||
static void SleepSafeSeconds(size_t Seconds);
|
||||
|
||||
static void InitializeConsole() {
|
||||
if (!mConsole) {
|
||||
mConsole = std::make_unique<TConsole>();
|
||||
}
|
||||
mConsole.InitializeCommandline();
|
||||
}
|
||||
|
||||
enum class Status {
|
||||
@@ -131,15 +146,17 @@ private:
|
||||
static inline SystemStatusMap mSystemStatusMap {};
|
||||
static inline std::mutex mSystemStatusMapMutex {};
|
||||
static inline std::string mPPS;
|
||||
static inline std::unique_ptr<TConsole> mConsole;
|
||||
static inline TConsole mConsole;
|
||||
static inline std::shared_mutex mShutdownMtx {};
|
||||
static inline bool mShutdown { false };
|
||||
static inline std::mutex mShutdownHandlersMutex {};
|
||||
static inline std::deque<TShutdownHandler> mShutdownHandlers {};
|
||||
|
||||
static inline Version mVersion { 3, 1, 0 };
|
||||
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);
|
||||
void RegisterThread(const std::string& str);
|
||||
#define RegisterThreadAuto() RegisterThread(__func__)
|
||||
@@ -192,7 +209,6 @@ void RegisterThread(const std::string& str);
|
||||
#define beammp_error(x) \
|
||||
do { \
|
||||
Application::Console().Write(_this_location + std::string("[ERROR] ") + (x)); \
|
||||
Sentry.AddErrorBreadcrumb((x), _file_basename, _line); \
|
||||
} while (false)
|
||||
#define beammp_lua_error(x) \
|
||||
do { \
|
||||
|
||||
@@ -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
|
||||
|
||||
#include "Environment.h"
|
||||
|
||||
@@ -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
|
||||
#include <array>
|
||||
|
||||
@@ -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
|
||||
@@ -63,12 +79,10 @@ inline void _assert([[maybe_unused]] const char* file, [[maybe_unused]] const ch
|
||||
bool result = (cond); \
|
||||
if (!result) { \
|
||||
beammp_errorf("Assertion failed in '{}:{}': {}.", __func__, _line, #cond); \
|
||||
Sentry.LogAssert(#cond, _file_basename, _line, __func__); \
|
||||
} \
|
||||
} while (false)
|
||||
#define beammp_assert_not_reachable() \
|
||||
do { \
|
||||
beammp_errorf("Assertion failed in '{}:{}': Unreachable code reached. This may result in a crash or undefined state of the program.", __func__, _line); \
|
||||
Sentry.LogAssert("code is unreachable", _file_basename, _line, __func__); \
|
||||
} while (false)
|
||||
#endif // DEBUG
|
||||
|
||||
@@ -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
|
||||
|
||||
#include <functional>
|
||||
|
||||
34
include/Env.h
Normal file
34
include/Env.h
Normal file
@@ -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
|
||||
|
||||
// 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
|
||||
|
||||
#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
|
||||
|
||||
#include <thread>
|
||||
@@ -8,7 +26,7 @@ public:
|
||||
IThreaded()
|
||||
// invokes operator() on this object
|
||||
: mThread() { }
|
||||
~IThreaded() noexcept {
|
||||
virtual ~IThreaded() noexcept {
|
||||
if (mThread.joinable()) {
|
||||
mThread.join();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
#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
|
||||
|
||||
#include "TLuaEngine.h"
|
||||
|
||||
@@ -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
|
||||
|
||||
/*
|
||||
|
||||
@@ -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
|
||||
|
||||
void SetupSignalHandlers();
|
||||
|
||||
@@ -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
|
||||
|
||||
#include "Common.h"
|
||||
@@ -6,7 +24,7 @@
|
||||
#include <filesystem>
|
||||
|
||||
#define TOML11_PRESERVE_COMMENTS_BY_DEFAULT
|
||||
#include <toml11/toml.hpp> // header-only version of TOML++
|
||||
#include <toml.hpp> // header-only version of TOML++
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
@@ -22,11 +40,12 @@ private:
|
||||
void CreateConfigFile();
|
||||
void ParseFromFile(std::string_view name);
|
||||
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, 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, std::string& 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, const std::string_view& Env, int& OutValue);
|
||||
|
||||
void ParseOldFormat();
|
||||
std::string TagsAsPrettyArray() const;
|
||||
bool IsDefault();
|
||||
bool mFailed { false };
|
||||
std::string mConfigFileName;
|
||||
|
||||
@@ -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
|
||||
|
||||
#include "Cryptography.h"
|
||||
@@ -5,6 +23,7 @@
|
||||
#include <atomic>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <unordered_map>
|
||||
@@ -16,12 +35,15 @@ class TConsole {
|
||||
public:
|
||||
TConsole();
|
||||
|
||||
// Initializes the commandline app to take over I/O
|
||||
void InitializeCommandline();
|
||||
|
||||
void Write(const std::string& str);
|
||||
void WriteRaw(const std::string& str);
|
||||
void InitializeLuaConsole(TLuaEngine& Engine);
|
||||
void BackupOldLog();
|
||||
void StartLoggingToFile();
|
||||
Commandline& Internal() { return mCommandline; }
|
||||
Commandline& Internal() { return *mCommandline; }
|
||||
|
||||
private:
|
||||
void RunAsCommand(const std::string& cmd, bool IgnoreNotACommand = false);
|
||||
@@ -55,7 +77,7 @@ private:
|
||||
{ "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> mCachedRegularHistory;
|
||||
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
|
||||
|
||||
#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
|
||||
|
||||
#include "TNetwork.h"
|
||||
@@ -13,7 +31,7 @@
|
||||
#include <queue>
|
||||
#include <random>
|
||||
#include <set>
|
||||
#include <toml11/toml.hpp>
|
||||
#include <toml.hpp>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
@@ -41,7 +59,14 @@ struct TLuaResult {
|
||||
sol::object Result { sol::lua_nil };
|
||||
TLuaStateId StateId;
|
||||
std::string Function;
|
||||
// TODO: Add condition_variable
|
||||
std::shared_ptr<std::mutex> ReadyMutex {
|
||||
std::make_shared<std::mutex>()
|
||||
};
|
||||
std::shared_ptr<std::condition_variable> ReadyCondition {
|
||||
std::make_shared<std::condition_variable>()
|
||||
};
|
||||
|
||||
void MarkAsReady();
|
||||
void WaitUntilReady();
|
||||
};
|
||||
|
||||
@@ -76,7 +101,7 @@ public:
|
||||
};
|
||||
|
||||
TLuaEngine();
|
||||
~TLuaEngine() noexcept {
|
||||
virtual ~TLuaEngine() noexcept {
|
||||
beammp_debug("Lua Engine terminated");
|
||||
}
|
||||
|
||||
@@ -98,8 +123,8 @@ public:
|
||||
return mLuaStates.size();
|
||||
}
|
||||
std::vector<std::string> GetLuaStateNames() {
|
||||
std::vector<std::string> names{};
|
||||
for(auto const& [stateId, _ ] : mLuaStates) {
|
||||
std::vector<std::string> names {};
|
||||
for (auto const& [stateId, _] : mLuaStates) {
|
||||
names.push_back(stateId);
|
||||
}
|
||||
return names;
|
||||
@@ -198,7 +223,7 @@ private:
|
||||
public:
|
||||
StateThreadData(const std::string& Name, TLuaStateId StateId, TLuaEngine& Engine);
|
||||
StateThreadData(const StateThreadData&) = delete;
|
||||
~StateThreadData() noexcept { beammp_debug("\"" + mStateId + "\" destroyed"); }
|
||||
virtual ~StateThreadData() noexcept { beammp_debug("\"" + mStateId + "\" destroyed"); }
|
||||
[[nodiscard]] std::shared_ptr<TLuaResult> EnqueueScript(const TLuaChunk& Script);
|
||||
[[nodiscard]] std::shared_ptr<TLuaResult> EnqueueFunctionCall(const std::string& FunctionName, const std::vector<TLuaArgTypes>& Args);
|
||||
[[nodiscard]] std::shared_ptr<TLuaResult> EnqueueFunctionCallFromCustomEvent(const std::string& FunctionName, const std::vector<TLuaArgTypes>& Args, const std::string& EventName, CallStrategy Strategy);
|
||||
|
||||
@@ -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"
|
||||
|
||||
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
|
||||
|
||||
#include "BoostAliases.h"
|
||||
@@ -52,4 +70,5 @@ private:
|
||||
static const uint8_t* SendSplit(TClient& c, ip::tcp::socket& Socket, const uint8_t* DataPtr, size_t Size);
|
||||
};
|
||||
|
||||
std::string HashPassword(const std::string& str);
|
||||
std::vector<uint8_t> StringToVector(const std::string& Str);
|
||||
|
||||
@@ -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
|
||||
|
||||
#include "Common.h"
|
||||
@@ -9,6 +27,7 @@ class TNetwork;
|
||||
class TPPSMonitor : public IThreaded {
|
||||
public:
|
||||
explicit TPPSMonitor(TServer& Server);
|
||||
virtual ~TPPSMonitor() {}
|
||||
|
||||
void operator()() override;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
#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
|
||||
|
||||
#include "Common.h"
|
||||
@@ -18,4 +36,4 @@ private:
|
||||
std::string mFileList;
|
||||
std::string mTrimmedList;
|
||||
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
|
||||
|
||||
#include <chrono>
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
#ifndef SENTRY_H
|
||||
#define SENTRY_H
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
enum class SentryLevel {
|
||||
Debug = -1,
|
||||
Info = 0,
|
||||
Warning = 1,
|
||||
Error = 2,
|
||||
Fatal = 3,
|
||||
};
|
||||
|
||||
// singleton, dont make this twice
|
||||
class TSentry final {
|
||||
public:
|
||||
TSentry();
|
||||
~TSentry();
|
||||
|
||||
void PrintWelcome();
|
||||
void SetupUser();
|
||||
void Log(SentryLevel level, const std::string& logger, const std::string& text);
|
||||
void LogError(const std::string& text, const std::string& file, const std::string& line);
|
||||
void SetContext(const std::string& context_name, const std::unordered_map<std::string, std::string>& map);
|
||||
void LogException(const std::exception& e, const std::string& file, const std::string& line);
|
||||
void LogAssert(const std::string& condition_string, const std::string& file, const std::string& line, const std::string& function);
|
||||
void AddErrorBreadcrumb(const std::string& msg, const std::string& file, const std::string& line);
|
||||
// cleared when Logged
|
||||
void SetTransaction(const std::string& id);
|
||||
[[nodiscard]] std::unique_lock<std::mutex> CreateExclusiveContext();
|
||||
|
||||
private:
|
||||
bool mValid { true };
|
||||
std::mutex mMutex;
|
||||
};
|
||||
|
||||
#endif // SENTRY_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
|
||||
|
||||
#include "IThreaded.h"
|
||||
@@ -26,7 +44,7 @@ public:
|
||||
void ForEachClient(const std::function<bool(std::weak_ptr<TClient>)>& Fn);
|
||||
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);
|
||||
RWMutex& GetClientMutex() const { return mClientsMutex; }
|
||||
|
||||
@@ -43,7 +61,7 @@ private:
|
||||
static bool ShouldSpawn(TClient& c, const std::string& CarJson, int ID);
|
||||
static bool IsUnicycle(TClient& c, const std::string& CarJson);
|
||||
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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
#include <string>
|
||||
|
||||
7
scripts/debian-11/1-install-deps.sh
Executable file
7
scripts/debian-11/1-install-deps.sh
Executable file
@@ -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
|
||||
7
scripts/debian-11/1.5-git-safe.sh
Normal file
7
scripts/debian-11/1.5-git-safe.sh
Normal file
@@ -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
|
||||
7
scripts/debian-11/2-configure.sh
Executable file
7
scripts/debian-11/2-configure.sh
Executable file
@@ -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
|
||||
5
scripts/debian-11/3-build-tests.sh
Executable file
5
scripts/debian-11/3-build-tests.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
cmake --build bin --parallel -t BeamMP-Server-tests
|
||||
10
scripts/debian-11/3-build.sh
Executable file
10
scripts/debian-11/3-build.sh
Executable file
@@ -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
scripts/debian-11/4-install-runtime-deps.sh
Executable file
8
scripts/debian-11/4-install-runtime-deps.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
apt-get update -y
|
||||
|
||||
apt-get install -y liblua5.3-0 curl
|
||||
|
||||
7
scripts/debian-12/1-install-deps.sh
Executable file
7
scripts/debian-12/1-install-deps.sh
Executable file
@@ -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
|
||||
7
scripts/debian-12/1.5-git-safe.sh
Normal file
7
scripts/debian-12/1.5-git-safe.sh
Normal file
@@ -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
|
||||
7
scripts/debian-12/2-configure.sh
Executable file
7
scripts/debian-12/2-configure.sh
Executable file
@@ -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
|
||||
5
scripts/debian-12/3-build-tests.sh
Executable file
5
scripts/debian-12/3-build-tests.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
cmake --build bin --parallel -t BeamMP-Server-tests
|
||||
10
scripts/debian-12/3-build.sh
Executable file
10
scripts/debian-12/3-build.sh
Executable file
@@ -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
scripts/debian-12/4-install-runtime-deps.sh
Executable file
8
scripts/debian-12/4-install-runtime-deps.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
apt-get update -y
|
||||
|
||||
apt-get install -y liblua5.3-0 curl
|
||||
|
||||
7
scripts/ubuntu-20.04/1-install-deps.sh
Executable file
7
scripts/ubuntu-20.04/1-install-deps.sh
Executable file
@@ -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
|
||||
7
scripts/ubuntu-20.04/1.5-git-safe.sh
Normal file
7
scripts/ubuntu-20.04/1.5-git-safe.sh
Normal file
@@ -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
|
||||
7
scripts/ubuntu-20.04/2-configure.sh
Executable file
7
scripts/ubuntu-20.04/2-configure.sh
Executable file
@@ -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
|
||||
5
scripts/ubuntu-20.04/3-build-tests.sh
Executable file
5
scripts/ubuntu-20.04/3-build-tests.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
cmake --build bin --parallel -t BeamMP-Server-tests
|
||||
10
scripts/ubuntu-20.04/3-build.sh
Executable file
10
scripts/ubuntu-20.04/3-build.sh
Executable file
@@ -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
scripts/ubuntu-20.04/4-install-runtime-deps.sh
Executable file
8
scripts/ubuntu-20.04/4-install-runtime-deps.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
apt-get update -y
|
||||
|
||||
apt-get install -y liblua5.3-0 curl
|
||||
|
||||
7
scripts/ubuntu-22.04/1-install-deps.sh
Executable file
7
scripts/ubuntu-22.04/1-install-deps.sh
Executable file
@@ -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
|
||||
7
scripts/ubuntu-22.04/1.5-git-safe.sh
Normal file
7
scripts/ubuntu-22.04/1.5-git-safe.sh
Normal file
@@ -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
|
||||
7
scripts/ubuntu-22.04/2-configure.sh
Executable file
7
scripts/ubuntu-22.04/2-configure.sh
Executable file
@@ -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
|
||||
5
scripts/ubuntu-22.04/3-build-tests.sh
Executable file
5
scripts/ubuntu-22.04/3-build-tests.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
cmake --build bin --parallel -t BeamMP-Server-tests
|
||||
10
scripts/ubuntu-22.04/3-build.sh
Executable file
10
scripts/ubuntu-22.04/3-build.sh
Executable file
@@ -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
scripts/ubuntu-22.04/4-install-runtime-deps.sh
Executable file
8
scripts/ubuntu-22.04/4-install-runtime-deps.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
apt-get update -y
|
||||
|
||||
apt-get install -y liblua5.3-0 curl
|
||||
|
||||
7
scripts/windows/1-configure.sh
Executable file
7
scripts/windows/1-configure.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
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
|
||||
5
scripts/windows/2-build-tests.sh
Executable file
5
scripts/windows/2-build-tests.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
cmake --build bin --parallel -t BeamMP-Server-tests
|
||||
5
scripts/windows/2-build.sh
Executable file
5
scripts/windows/2-build.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
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 "Common.h"
|
||||
#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 "Client.h"
|
||||
|
||||
#include "CustomAssert.h"
|
||||
@@ -6,6 +24,7 @@
|
||||
#include <optional>
|
||||
|
||||
void TClient::DeleteCar(int Ident) {
|
||||
// TODO: Send delete packets
|
||||
std::unique_lock lock(mVehicleDataMutex);
|
||||
auto iter = std::find_if(mVehicleData.begin(), mVehicleData.end(), [&](auto& elem) {
|
||||
return Ident == elem.ID();
|
||||
@@ -50,11 +69,11 @@ TClient::TVehicleDataLockPair TClient::GetAllCars() {
|
||||
std::string TClient::GetCarPositionRaw(int Ident) {
|
||||
std::unique_lock lock(mVehiclePositionMutex);
|
||||
try {
|
||||
return mVehiclePosition.at(Ident);
|
||||
return mVehiclePosition.at(size_t(Ident));
|
||||
} catch (const std::out_of_range& oor) {
|
||||
beammp_debugf("Failed to get vehicle position for {}: {}", Ident, oor.what());
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
void TClient::Disconnect(std::string_view Reason) {
|
||||
@@ -72,7 +91,7 @@ void TClient::Disconnect(std::string_view Reason) {
|
||||
|
||||
void TClient::SetCarPosition(int Ident, const std::string& Data) {
|
||||
std::unique_lock lock(mVehiclePositionMutex);
|
||||
mVehiclePosition[Ident] = Data;
|
||||
mVehiclePosition[size_t(Ident)] = Data;
|
||||
}
|
||||
|
||||
std::string TClient::GetCarData(int Ident) {
|
||||
@@ -145,6 +164,8 @@ std::optional<std::weak_ptr<TClient>> GetClient(TServer& Server, int ID) {
|
||||
MaybeClient = CPtr;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
beammp_debugf("Found an expired client while looking for id {}", ID);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -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 "Env.h"
|
||||
#include "TConsole.h"
|
||||
#include <array>
|
||||
#include <charconv>
|
||||
#include <fmt/core.h>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <regex>
|
||||
@@ -13,9 +33,6 @@
|
||||
#include "CustomAssert.h"
|
||||
#include "Http.h"
|
||||
|
||||
// global, yes, this is ugly, no, it cant be done another way
|
||||
TSentry Sentry {};
|
||||
|
||||
Application::TSettings Application::Settings = {};
|
||||
|
||||
void Application::RegisterShutdownHandler(const TShutdownHandler& Handler) {
|
||||
@@ -204,8 +221,11 @@ void Application::CheckForUpdates() {
|
||||
auto MyVersion = ServerVersion();
|
||||
auto RemoteVersion = Version(VersionStrToInts(Response));
|
||||
if (IsOutdated(MyVersion, RemoteVersion)) {
|
||||
std::string RealVersionString = 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));
|
||||
std::string RealVersionString = std::string("v") + RemoteVersion.AsString();
|
||||
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 {
|
||||
if (FirstTime) {
|
||||
beammp_info("Server up-to-date!");
|
||||
@@ -217,9 +237,6 @@ void Application::CheckForUpdates() {
|
||||
if (FirstTime) {
|
||||
beammp_debug("Failed to fetch version from: " + url);
|
||||
beammp_trace("got " + Response);
|
||||
auto Lock = Sentry.CreateExclusiveContext();
|
||||
Sentry.SetContext("get-response", { { "response", Response } });
|
||||
Sentry.LogError("failed to get server version", _file_basename, _line);
|
||||
Application::SetSubsystemStatus("UpdateCheck", Application::Status::Bad);
|
||||
}
|
||||
}
|
||||
@@ -354,3 +371,14 @@ std::string GetPlatformAgnosticErrorString() {
|
||||
return "(no human-readable errors on this platform)";
|
||||
#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 <cstring>
|
||||
|
||||
38
src/Env.cpp
Normal file
38
src/Env.cpp
Normal file
@@ -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 "";
|
||||
}
|
||||
18
src/Http.cpp
18
src/Http.cpp
@@ -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 "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 "Client.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 "Common.h"
|
||||
|
||||
|
||||
140
src/TConfig.cpp
140
src/TConfig.cpp
@@ -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 "TConfig.h"
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <istream>
|
||||
@@ -8,30 +27,36 @@
|
||||
|
||||
// General
|
||||
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 EnvStrPrivate = "BEAMMP_PRIVATE";
|
||||
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 EnvStrMaxCars = "BEAMMP_MAX_CARS";
|
||||
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 EnvStrMap = "BEAMMP_MAP";
|
||||
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 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 EnvStrResourceFolder = "BEAMMP_RESOURCE_FOLDER";
|
||||
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 EnvStrLogChat = "BEAMMP_LOG_CHAT";
|
||||
static constexpr std::string_view StrPassword = "Password";
|
||||
|
||||
// Misc
|
||||
static constexpr std::string_view StrSendErrors = "SendErrors";
|
||||
static constexpr std::string_view StrSendErrorsMessageEnabled = "SendErrorsShowMessage";
|
||||
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") {
|
||||
const std::string CfgFile = "beammp_server_testconfig.toml";
|
||||
fs::remove(CfgFile);
|
||||
@@ -55,7 +80,6 @@ TEST_CASE("TConfig::TConfig") {
|
||||
const auto table = toml::parse(CfgFile);
|
||||
CHECK(table.at("General").is_table());
|
||||
CHECK(table.at("Misc").is_table());
|
||||
CHECK(table.at("HTTP").is_table());
|
||||
|
||||
fs::remove(CfgFile);
|
||||
}
|
||||
@@ -101,32 +125,26 @@ void TConfig::FlushToFile() {
|
||||
data["General"][StrPrivate.data()] = Application::Settings.Private;
|
||||
data["General"][StrPort.data()] = Application::Settings.Port;
|
||||
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"][StrMaxPlayers.data()] = Application::Settings.MaxPlayers;
|
||||
data["General"][StrMap.data()] = Application::Settings.MapName;
|
||||
data["General"][StrDescription.data()] = Application::Settings.ServerDesc;
|
||||
data["General"][StrResourceFolder.data()] = Application::Settings.Resource;
|
||||
// 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.");
|
||||
// Misc
|
||||
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.");
|
||||
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;
|
||||
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`");
|
||||
// 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");
|
||||
SetComment(data["Misc"][StrSendErrorsMessageEnabled.data()].comments(), " You can turn on/off the SendErrors message you get on startup here");
|
||||
std::stringstream Ss;
|
||||
Ss << "# This is the BeamMP-Server config file.\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;
|
||||
auto File = std::fopen(mConfigFileName.c_str(), "w+");
|
||||
if (!File) {
|
||||
@@ -156,19 +174,38 @@ void TConfig::CreateConfigFile() {
|
||||
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()) {
|
||||
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()) {
|
||||
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()) {
|
||||
OutValue = int(Table[Category.c_str()][Key.data()].as_integer());
|
||||
}
|
||||
@@ -178,28 +215,23 @@ void TConfig::ParseFromFile(std::string_view name) {
|
||||
try {
|
||||
toml::value data = toml::parse<toml::preserve_comments>(name.data());
|
||||
// GENERAL
|
||||
TryReadValue(data, "General", StrDebug, Application::Settings.DebugModeEnabled);
|
||||
TryReadValue(data, "General", StrPrivate, Application::Settings.Private);
|
||||
TryReadValue(data, "General", StrPort, Application::Settings.Port);
|
||||
TryReadValue(data, "General", StrMaxCars, Application::Settings.MaxCars);
|
||||
TryReadValue(data, "General", StrMaxPlayers, Application::Settings.MaxPlayers);
|
||||
TryReadValue(data, "General", StrMap, Application::Settings.MapName);
|
||||
TryReadValue(data, "General", StrName, Application::Settings.ServerName);
|
||||
TryReadValue(data, "General", StrDescription, Application::Settings.ServerDesc);
|
||||
TryReadValue(data, "General", StrResourceFolder, Application::Settings.Resource);
|
||||
TryReadValue(data, "General", StrAuthKey, Application::Settings.Key);
|
||||
TryReadValue(data, "General", StrLogChat, Application::Settings.LogChat);
|
||||
TryReadValue(data, "General", StrDebug, EnvStrDebug, Application::Settings.DebugModeEnabled);
|
||||
TryReadValue(data, "General", StrPrivate, EnvStrPrivate, Application::Settings.Private);
|
||||
TryReadValue(data, "General", StrPort, EnvStrPort, Application::Settings.Port);
|
||||
TryReadValue(data, "General", StrMaxCars, EnvStrMaxCars, Application::Settings.MaxCars);
|
||||
TryReadValue(data, "General", StrMaxPlayers, EnvStrMaxPlayers, Application::Settings.MaxPlayers);
|
||||
TryReadValue(data, "General", StrMap, EnvStrMap, Application::Settings.MapName);
|
||||
TryReadValue(data, "General", StrName, EnvStrName, Application::Settings.ServerName);
|
||||
TryReadValue(data, "General", StrDescription, EnvStrDescription, Application::Settings.ServerDesc);
|
||||
TryReadValue(data, "General", StrTags, EnvStrTags, Application::Settings.ServerTags);
|
||||
TryReadValue(data, "General", StrResourceFolder, EnvStrResourceFolder, Application::Settings.Resource);
|
||||
TryReadValue(data, "General", StrAuthKey, EnvStrAuthKey, Application::Settings.Key);
|
||||
TryReadValue(data, "General", StrLogChat, EnvStrLogChat, Application::Settings.LogChat);
|
||||
TryReadValue(data, "General", StrPassword, "", Application::Settings.Password);
|
||||
// Misc
|
||||
TryReadValue(data, "Misc", StrSendErrors, Application::Settings.SendErrors);
|
||||
TryReadValue(data, "Misc", StrHideUpdateMessages, Application::Settings.HideUpdateMessages);
|
||||
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);
|
||||
TryReadValue(data, "Misc", StrSendErrors, "", Application::Settings.SendErrors);
|
||||
TryReadValue(data, "Misc", StrHideUpdateMessages, "", Application::Settings.HideUpdateMessages);
|
||||
TryReadValue(data, "Misc", StrSendErrorsMessageEnabled, "", Application::Settings.SendErrorsMessageEnabled);
|
||||
} catch (const std::exception& err) {
|
||||
beammp_error("Error parsing config file value: " + std::string(err.what()));
|
||||
mFailed = true;
|
||||
@@ -232,14 +264,12 @@ void TConfig::PrintDebug() {
|
||||
beammp_debug(std::string(StrMap) + ": \"" + Application::Settings.MapName + "\"");
|
||||
beammp_debug(std::string(StrName) + ": \"" + Application::Settings.ServerName + "\"");
|
||||
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(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!
|
||||
beammp_debug("Key Length: " + std::to_string(Application::Settings.Key.length()) + "");
|
||||
beammp_debug("Password Protected: " + std::string(Application::Settings.Password.empty() ? "false" : "true"));
|
||||
}
|
||||
|
||||
void TConfig::ParseOldFormat() {
|
||||
@@ -294,3 +324,13 @@ void TConfig::ParseOldFormat() {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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 "Common.h"
|
||||
#include "Compat.h"
|
||||
@@ -8,6 +26,7 @@
|
||||
#include "TLuaEngine.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <mutex>
|
||||
#include <sstream>
|
||||
|
||||
static inline bool StringStartsWith(const std::string& What, const std::string& StartsWith) {
|
||||
@@ -51,17 +70,6 @@ TEST_CASE("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() {
|
||||
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
|
||||
time_t tt = std::chrono::system_clock::to_time_t(now);
|
||||
@@ -156,13 +164,13 @@ void TConsole::ChangeToLuaConsole(const std::string& LuaStateId) {
|
||||
mIsLuaConsole = true;
|
||||
if (mStateId != mDefaultStateId) {
|
||||
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 {
|
||||
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();
|
||||
mCommandline.set_history(mCachedLuaHistory);
|
||||
mCachedRegularHistory = mCommandline->history();
|
||||
mCommandline->set_history(mCachedLuaHistory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,9 +182,9 @@ void TConsole::ChangeToRegularConsole() {
|
||||
} else {
|
||||
Application::Console().WriteRaw("Detached from Lua.");
|
||||
}
|
||||
mCachedLuaHistory = mCommandline.history();
|
||||
mCommandline.set_history(mCachedRegularHistory);
|
||||
mCommandline.set_prompt("> ");
|
||||
mCachedLuaHistory = mCommandline->history();
|
||||
mCommandline->set_history(mCachedRegularHistory);
|
||||
mCommandline->set_prompt("> ");
|
||||
mStateId = mDefaultStateId;
|
||||
}
|
||||
}
|
||||
@@ -198,10 +206,10 @@ bool TConsole::EnsureArgsCount(const std::vector<std::string>& args, size_t min,
|
||||
return EnsureArgsCount(args, min);
|
||||
} else {
|
||||
if (args.size() > max) {
|
||||
Application::Console().WriteRaw("Too many arguments. At most " + std::to_string(max) + " arguments expected, got " + std::to_string(args.size()) + " instead.");
|
||||
Application::Console().WriteRaw("Too many arguments. At most " + std::to_string(max) + " argument(s) expected, got " + std::to_string(args.size()) + " instead.");
|
||||
return false;
|
||||
} else if (args.size() < min) {
|
||||
Application::Console().WriteRaw("Too few arguments. At least " + std::to_string(max) + " arguments expected, got " + std::to_string(args.size()) + " instead.");
|
||||
Application::Console().WriteRaw("Too few arguments. At least " + std::to_string(min) + " argument(s) expected, got " + std::to_string(args.size()) + " instead.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -256,7 +264,7 @@ void TConsole::Command_Clear(const std::string&, const std::vector<std::string>&
|
||||
if (!EnsureArgsCount(args, 0, size_t(-1))) {
|
||||
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) {
|
||||
@@ -350,7 +358,7 @@ std::tuple<std::string, std::vector<std::string>> TConsole::ParseCommand(const s
|
||||
}
|
||||
|
||||
void TConsole::Command_Settings(const std::string&, const std::vector<std::string>& args) {
|
||||
if (!EnsureArgsCount(args, 0)) {
|
||||
if (!EnsureArgsCount(args, 1, 2)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -478,12 +486,12 @@ void TConsole::Command_Status(const std::string&, const std::vector<std::string>
|
||||
<< "\t\tEvent handlers: " << mLuaEngine->GetRegisteredEventHandlerCount() << "\n"
|
||||
<< "\tSubsystems:\n"
|
||||
<< "\t\tGood/Starting/Bad: " << SystemsGood << "/" << SystemsStarting << "/" << SystemsBad << "\n"
|
||||
<< "\t\tShutting down/Shut down: " << SystemsShuttingDown << "/" << SystemsShutdown << "\n"
|
||||
<< "\t\tShutting down/Shut down: " << SystemsShuttingDown << "/" << SystemsShutdown << "\n"
|
||||
<< "\t\tGood: [ " << SystemsGoodList << " ]\n"
|
||||
<< "\t\tStarting: [ " << SystemsStartingList << " ]\n"
|
||||
<< "\t\tBad: [ " << SystemsBadList << " ]\n"
|
||||
<< "\t\tShutting down: [ " << SystemsShuttingDownList << " ]\n"
|
||||
<< "\t\tShut down: [ " << SystemsShutdownList << " ]\n"
|
||||
<< "\t\tShut down: [ " << SystemsShutdownList << " ]\n"
|
||||
<< "";
|
||||
|
||||
Application::Console().WriteRaw(Status.str());
|
||||
@@ -588,16 +596,20 @@ Commands
|
||||
}
|
||||
|
||||
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();
|
||||
mCommandline.on_command = [this](Commandline& c) {
|
||||
mCommandline->on_command = [this](Commandline& c) {
|
||||
try {
|
||||
auto TrimmedCmd = c.get_command();
|
||||
TrimmedCmd = TrimString(TrimmedCmd);
|
||||
auto [cmd, args] = ParseCommand(TrimmedCmd);
|
||||
mCommandline.write(mCommandline.prompt() + TrimmedCmd);
|
||||
mCommandline->write(mCommandline->prompt() + TrimmedCmd);
|
||||
if (mIsLuaConsole) {
|
||||
if (!mLuaEngine) {
|
||||
beammp_info("Lua not started yet, please try again in a second");
|
||||
@@ -605,9 +617,7 @@ TConsole::TConsole() {
|
||||
HandleLuaInternalCommand(cmd.substr(1));
|
||||
} else {
|
||||
auto Future = mLuaEngine->EnqueueScript(mStateId, { std::make_shared<std::string>(TrimmedCmd), "", "" });
|
||||
while (!Future->Ready) {
|
||||
std::this_thread::yield(); // TODO: Add a timeout
|
||||
}
|
||||
Future->WaitUntilReady();
|
||||
if (Future->Error) {
|
||||
beammp_lua_error("error in " + mStateId + ": " + Future->ErrorMessage);
|
||||
}
|
||||
@@ -634,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.");
|
||||
}
|
||||
};
|
||||
mCommandline.on_autocomplete = [this](Commandline&, std::string stub, int) {
|
||||
mCommandline->on_autocomplete = [this](Commandline&, std::string stub, int) {
|
||||
std::vector<std::string> suggestions;
|
||||
try {
|
||||
if (mIsLuaConsole) { // if lua
|
||||
@@ -704,11 +714,21 @@ TConsole::TConsole() {
|
||||
|
||||
void TConsole::Write(const std::string& 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) {
|
||||
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) {
|
||||
|
||||
@@ -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 "Client.h"
|
||||
@@ -40,16 +58,6 @@ void THeartbeatThread::operator()() {
|
||||
Body += "&ip=" + Application::Settings.CustomIP;
|
||||
}
|
||||
|
||||
auto SentryReportError = [&](const std::string& transaction, int status) {
|
||||
auto Lock = Sentry.CreateExclusiveContext();
|
||||
Sentry.SetContext("heartbeat",
|
||||
{ { "response-body", T },
|
||||
{ "request-body", Body } });
|
||||
Sentry.SetTransaction(transaction);
|
||||
beammp_trace("sending log to sentry: " + std::to_string(status) + " for " + transaction);
|
||||
Sentry.Log(SentryLevel::Error, "default", Http::Status::ToString(status) + " (" + std::to_string(status) + ")");
|
||||
};
|
||||
|
||||
auto Target = "/heartbeat";
|
||||
unsigned int ResponseCode = 0;
|
||||
|
||||
@@ -63,10 +71,8 @@ void THeartbeatThread::operator()() {
|
||||
beammp_trace("Backend response failed to parse as valid json");
|
||||
beammp_trace("Response was: `" + T + "`");
|
||||
}
|
||||
Sentry.SetContext("JSON Response", { { "reponse", T } });
|
||||
SentryReportError(Url + Target, ResponseCode);
|
||||
} else if (ResponseCode != 200) {
|
||||
SentryReportError(Url + Target, ResponseCode);
|
||||
beammp_errorf("Response code from the heartbeat: {}", ResponseCode);
|
||||
} else {
|
||||
// all ok
|
||||
Ok = true;
|
||||
@@ -85,24 +91,20 @@ void THeartbeatThread::operator()() {
|
||||
if (Doc.HasMember(StatusKey) && Doc[StatusKey].IsString()) {
|
||||
Status = Doc[StatusKey].GetString();
|
||||
} else {
|
||||
Sentry.SetContext("JSON Response", { { StatusKey, "invalid string / missing" } });
|
||||
Ok = false;
|
||||
}
|
||||
if (Doc.HasMember(CodeKey) && Doc[CodeKey].IsString()) {
|
||||
Code = Doc[CodeKey].GetString();
|
||||
} else {
|
||||
Sentry.SetContext("JSON Response", { { CodeKey, "invalid string / missing" } });
|
||||
Ok = false;
|
||||
}
|
||||
if (Doc.HasMember(MessageKey) && Doc[MessageKey].IsString()) {
|
||||
Message = Doc[MessageKey].GetString();
|
||||
} else {
|
||||
Sentry.SetContext("JSON Response", { { MessageKey, "invalid string / missing" } });
|
||||
Ok = false;
|
||||
}
|
||||
if (!Ok) {
|
||||
beammp_error("Missing/invalid json members in backend response");
|
||||
Sentry.LogError("Missing/invalid json members in backend response", __FILE__, std::to_string(__LINE__));
|
||||
}
|
||||
} else {
|
||||
if (!Application::Settings.Private) {
|
||||
@@ -145,11 +147,13 @@ std::string THeartbeatThread::GenerateCall() {
|
||||
<< "&version=" << Application::ServerVersionString()
|
||||
<< "&clientversion=" << std::to_string(Application::ClientMajorVersion()) + ".0" // FIXME: Wtf.
|
||||
<< "&name=" << Application::Settings.ServerName
|
||||
<< "&tags=" << Application::Settings.ServerTags
|
||||
<< "&modlist=" << mResourceManager.TrimmedList()
|
||||
<< "&modstotalsize=" << mResourceManager.MaxModSize()
|
||||
<< "&modstotal=" << mResourceManager.ModsLoaded()
|
||||
<< "&playerslist=" << GetPlayers()
|
||||
<< "&desc=" << Application::Settings.ServerDesc;
|
||||
<< "&desc=" << Application::Settings.ServerDesc
|
||||
<< "&pass=" << (Application::Settings.Password.empty() ? "false" : "true");
|
||||
return Ret.str();
|
||||
}
|
||||
THeartbeatThread::THeartbeatThread(TResourceManager& ResourceManager, TServer& Server)
|
||||
|
||||
@@ -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 "Client.h"
|
||||
#include "CustomAssert.h"
|
||||
@@ -286,6 +304,7 @@ void TLuaEngine::WaitForAll(std::vector<std::shared_ptr<TLuaResult>>& Results, c
|
||||
bool Cancelled = false;
|
||||
size_t ms = 0;
|
||||
std::set<std::string> WarnedResults;
|
||||
|
||||
while (!Result->Ready && !Cancelled) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
ms += 10;
|
||||
@@ -300,6 +319,7 @@ void TLuaEngine::WaitForAll(std::vector<std::shared_ptr<TLuaResult>>& Results, c
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Cancelled) {
|
||||
beammp_lua_warn("'" + Result->Function + "' in '" + Result->StateId + "' failed to execute in time and was not waited for. It may still finish executing at a later time.");
|
||||
LuaAPI::MP::Engine->ReportErrors({ Result });
|
||||
@@ -425,7 +445,7 @@ sol::table TLuaEngine::StateThreadData::Lua_TriggerGlobalEvent(const std::string
|
||||
Result->Error = true;
|
||||
Result->ErrorMessage = "Function result in TriggerGlobalEvent was invalid";
|
||||
}
|
||||
Result->Ready = true;
|
||||
Result->MarkAsReady();
|
||||
Return.push_back(Result);
|
||||
}
|
||||
}
|
||||
@@ -599,7 +619,7 @@ std::pair<sol::table, std::string> TLuaEngine::StateThreadData::Lua_GetPositionR
|
||||
return Result;
|
||||
} else {
|
||||
// return std::make_tuple(sol::lua_nil, sol::make_object(StateView, "Client expired"));
|
||||
Result.second = "Client expired";
|
||||
Result.second = "No such player";
|
||||
return Result;
|
||||
}
|
||||
}
|
||||
@@ -955,7 +975,7 @@ void TLuaEngine::StateThreadData::operator()() {
|
||||
sol::error Err = Res;
|
||||
S.second->ErrorMessage = Err.what();
|
||||
}
|
||||
S.second->Ready = true;
|
||||
S.second->MarkAsReady();
|
||||
}
|
||||
}
|
||||
{ // StateFunctionQueue Scope
|
||||
@@ -1016,11 +1036,11 @@ void TLuaEngine::StateThreadData::operator()() {
|
||||
sol::error Err = Res;
|
||||
Result->ErrorMessage = Err.what();
|
||||
}
|
||||
Result->Ready = true;
|
||||
Result->MarkAsReady();
|
||||
} else {
|
||||
Result->Error = true;
|
||||
Result->ErrorMessage = BeamMPFnNotFoundError; // special error kind that we can ignore later
|
||||
Result->Ready = true;
|
||||
Result->MarkAsReady();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1070,11 +1090,19 @@ void TLuaEngine::StateThreadData::AddPath(const fs::path& Path) {
|
||||
mPaths.push(Path);
|
||||
}
|
||||
|
||||
void TLuaResult::WaitUntilReady() {
|
||||
while (!Ready) {
|
||||
std::this_thread::yield();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
void TLuaResult::MarkAsReady() {
|
||||
{
|
||||
std::lock_guard<std::mutex> readyLock(*this->ReadyMutex);
|
||||
this->Ready = true;
|
||||
}
|
||||
this->ReadyCondition->notify_all();
|
||||
}
|
||||
|
||||
void TLuaResult::WaitUntilReady() {
|
||||
std::unique_lock readyLock(*this->ReadyMutex);
|
||||
// wait if not ready yet
|
||||
if(!this->Ready)
|
||||
this->ReadyCondition->wait(readyLock);
|
||||
}
|
||||
|
||||
TLuaChunk::TLuaChunk(std::shared_ptr<std::string> Content, std::string FileName, std::string PluginPath)
|
||||
|
||||
@@ -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 <chrono>
|
||||
#include <functional>
|
||||
|
||||
139
src/TNetwork.cpp
139
src/TNetwork.cpp
@@ -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 "Client.h"
|
||||
#include "Common.h"
|
||||
@@ -11,6 +29,8 @@
|
||||
#include <boost/asio/ip/address_v4.hpp>
|
||||
#include <cstring>
|
||||
|
||||
typedef boost::asio::detail::socket_option::integer<SOL_SOCKET, SO_RCVTIMEO> rcv_timeout_option;
|
||||
|
||||
std::vector<uint8_t> StringToVector(const std::string& Str) {
|
||||
return std::vector<uint8_t>(Str.data(), Str.data() + Str.size());
|
||||
}
|
||||
@@ -99,7 +119,7 @@ void TNetwork::UDPServerMain() {
|
||||
Client->SetUDPAddr(client);
|
||||
Client->SetIsConnected(true);
|
||||
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;
|
||||
@@ -177,16 +197,29 @@ void TNetwork::Identify(TConnection&& RawConnection) {
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<TClient> Client { nullptr };
|
||||
if (Code == 'C') {
|
||||
Client = Authentication(std::move(RawConnection));
|
||||
} else if (Code == 'D') {
|
||||
HandleDownload(std::move(RawConnection));
|
||||
} else if (Code == 'P') {
|
||||
try {
|
||||
if (Code == 'C') {
|
||||
Client = Authentication(std::move(RawConnection));
|
||||
} else if (Code == 'D') {
|
||||
HandleDownload(std::move(RawConnection));
|
||||
} else if (Code == 'P') {
|
||||
boost::system::error_code ec;
|
||||
write(RawConnection.Socket, buffer("P"), ec);
|
||||
return;
|
||||
} else {
|
||||
beammp_errorf("Invalid code got in Identify: '{}'", Code);
|
||||
}
|
||||
} catch(const std::exception& e) {
|
||||
beammp_errorf("Error during handling of code {} - client left in invalid state, closing socket", Code);
|
||||
boost::system::error_code ec;
|
||||
write(RawConnection.Socket, buffer("P"), ec);
|
||||
return;
|
||||
} else {
|
||||
beammp_errorf("Invalid code got in Identify: '{}'", Code);
|
||||
RawConnection.Socket.shutdown(socket_base::shutdown_both, ec);
|
||||
if (ec) {
|
||||
beammp_debugf("Failed to shutdown client socket: {}", ec.message());
|
||||
}
|
||||
RawConnection.Socket.close(ec);
|
||||
if (ec) {
|
||||
beammp_debugf("Failed to close client socket: {}", ec.message());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,6 +245,15 @@ void TNetwork::HandleDownload(TConnection&& Conn) {
|
||||
});
|
||||
}
|
||||
|
||||
std::string HashPassword(const std::string& str) {
|
||||
std::stringstream ret;
|
||||
unsigned char* hash = SHA256(reinterpret_cast<const unsigned char*>(str.c_str()), str.length(), nullptr);
|
||||
for (int i = 0; i < 32; i++) {
|
||||
ret << std::hex << static_cast<int>(hash[i]);
|
||||
}
|
||||
return ret.str();
|
||||
}
|
||||
|
||||
std::shared_ptr<TClient> TNetwork::Authentication(TConnection&& RawConnection) {
|
||||
auto Client = CreateClient(std::move(RawConnection.Socket));
|
||||
Client->SetIdentifier("ip", RawConnection.SockAddr.address().to_string());
|
||||
@@ -235,7 +277,8 @@ std::shared_ptr<TClient> TNetwork::Authentication(TConnection&& RawConnection) {
|
||||
ClientKick(*Client, fmt::format("Invalid version header: '{}' ({})", std::string(reinterpret_cast<const char*>(Data.data()), Data.size()), Data.size()));
|
||||
return nullptr;
|
||||
}
|
||||
if (!TCPSend(*Client, StringToVector("S"))) {
|
||||
|
||||
if (!TCPSend(*Client, StringToVector("A"))) { //changed to A for Accepted version
|
||||
// TODO: handle
|
||||
}
|
||||
|
||||
@@ -246,12 +289,24 @@ std::shared_ptr<TClient> TNetwork::Authentication(TConnection&& RawConnection) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nlohmann::json AuthReq {
|
||||
{ "key", std::string(reinterpret_cast<const char*>(Data.data()), Data.size()) }
|
||||
};
|
||||
auto Target = "/pkToUser";
|
||||
unsigned int ResponseCode = 0;
|
||||
const auto AuthResStr = Http::POST(Application::GetBackendUrlForAuth(), 443, Target, AuthReq.dump(), "application/json", &ResponseCode);
|
||||
std::string key(reinterpret_cast<const char*>(Data.data()), Data.size());
|
||||
|
||||
nlohmann::json AuthReq{};
|
||||
std::string AuthResStr{};
|
||||
try {
|
||||
AuthReq = nlohmann::json {
|
||||
{ "key", key }
|
||||
};
|
||||
|
||||
auto Target = "/pkToUser";
|
||||
unsigned int ResponseCode = 0;
|
||||
AuthResStr = Http::POST(Application::GetBackendUrlForAuth(), 443, Target, AuthReq.dump(), "application/json", &ResponseCode);
|
||||
|
||||
} catch (const std::exception& e) {
|
||||
beammp_debugf("Invalid json sent by client, kicking: {}", e.what());
|
||||
ClientKick(*Client, "Invalid Key (invalid UTF8 string)!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
try {
|
||||
nlohmann::json AuthRes = nlohmann::json::parse(AuthResStr);
|
||||
@@ -279,6 +334,22 @@ std::shared_ptr<TClient> TNetwork::Authentication(TConnection&& RawConnection) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(!Application::Settings.Password.empty()) { // ask password
|
||||
if(!TCPSend(*Client, StringToVector("S"))) {
|
||||
// TODO: handle
|
||||
}
|
||||
beammp_info("Waiting for password");
|
||||
Data = TCPRcv(*Client);
|
||||
std::string Pass = std::string(reinterpret_cast<const char*>(Data.data()), Data.size());
|
||||
if(Pass != HashPassword(Application::Settings.Password)) {
|
||||
beammp_debug(Client->GetName() + " attempted to connect with a wrong password");
|
||||
ClientKick(*Client, "Wrong password!");
|
||||
return {};
|
||||
} else {
|
||||
beammp_debug(Client->GetName() + " used the correct password");
|
||||
}
|
||||
}
|
||||
|
||||
beammp_debug("Name -> " + Client->GetName() + ", Guest -> " + std::to_string(Client->IsGuest()) + ", Roles -> " + Client->GetRoles());
|
||||
mServer.ForEachClient([&](const std::weak_ptr<TClient>& ClientPtr) -> bool {
|
||||
std::shared_ptr<TClient> Cl;
|
||||
@@ -328,6 +399,7 @@ std::shared_ptr<TClient> TNetwork::Authentication(TConnection&& RawConnection) {
|
||||
} else {
|
||||
ClientKick(*Client, "Server full!");
|
||||
}
|
||||
|
||||
return Client;
|
||||
}
|
||||
|
||||
@@ -393,6 +465,12 @@ std::vector<uint8_t> TNetwork::TCPRcv(TClient& c) {
|
||||
}
|
||||
Header = *reinterpret_cast<int32_t*>(HeaderData.data());
|
||||
|
||||
if (Header < 0) {
|
||||
ClientKick(c, "Invalid packet - header negative");
|
||||
beammp_errorf("Client {} send negative TCP header, ignoring packet", c.GetID());
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<uint8_t> Data;
|
||||
// TODO: This is arbitrary, this needs to be handled another way
|
||||
if (Header < int32_t(100 * MB)) {
|
||||
@@ -425,7 +503,7 @@ std::vector<uint8_t> TNetwork::TCPRcv(TClient& c) {
|
||||
void TNetwork::ClientKick(TClient& c, const std::string& R) {
|
||||
beammp_info("Client kicked: " + R);
|
||||
if (!TCPSend(c, StringToVector("K" + R))) {
|
||||
beammp_debugf("tried to kick player '{}' (id {}), but was already connected", c.GetName(), c.GetID());
|
||||
beammp_debugf("tried to kick player '{}' (id {}), but was already disconnected", c.GetName(), c.GetID());
|
||||
}
|
||||
c.Disconnect("Kicked");
|
||||
}
|
||||
@@ -492,7 +570,7 @@ void TNetwork::TCPClient(const std::weak_ptr<TClient>& c) {
|
||||
Client->Disconnect("TCPRcv failed");
|
||||
break;
|
||||
}
|
||||
TServer::GlobalParser(c, std::move(res), mPPSMonitor, *this);
|
||||
mServer.GlobalParser(c, std::move(res), mPPSMonitor, *this);
|
||||
}
|
||||
|
||||
if (QueueSync.joinable())
|
||||
@@ -522,8 +600,14 @@ void TNetwork::UpdatePlayer(TClient& Client) {
|
||||
}
|
||||
|
||||
void TNetwork::OnDisconnect(const std::weak_ptr<TClient>& ClientPtr) {
|
||||
beammp_assert(!ClientPtr.expired());
|
||||
auto LockedClientPtr = ClientPtr.lock();
|
||||
std::shared_ptr<TClient> LockedClientPtr { nullptr };
|
||||
try {
|
||||
LockedClientPtr = ClientPtr.lock();
|
||||
} catch (const std::exception&) {
|
||||
beammp_warn("Client expired in OnDisconnect, this is unexpected");
|
||||
return;
|
||||
}
|
||||
beammp_assert(LockedClientPtr != nullptr);
|
||||
TClient& c = *LockedClientPtr;
|
||||
beammp_info(c.GetName() + (" Connection Terminated"));
|
||||
std::string Packet;
|
||||
@@ -540,7 +624,7 @@ void TNetwork::OnDisconnect(const std::weak_ptr<TClient>& ClientPtr) {
|
||||
SendToAll(&c, StringToVector(Packet), false, true);
|
||||
Packet.clear();
|
||||
auto Futures = LuaAPI::MP::Engine->TriggerEvent("onPlayerDisconnect", "", c.GetID());
|
||||
LuaAPI::MP::Engine->ReportErrors(Futures);
|
||||
LuaAPI::MP::Engine->WaitForAll(Futures);
|
||||
c.Disconnect("Already Disconnected (OnDisconnect)");
|
||||
mServer.RemoveClient(ClientPtr);
|
||||
}
|
||||
@@ -860,12 +944,13 @@ void TNetwork::SendToAll(TClient* c, const std::vector<uint8_t>& Data, bool Self
|
||||
bool ret = true;
|
||||
mServer.ForEachClient([&](std::weak_ptr<TClient> ClientPtr) -> bool {
|
||||
std::shared_ptr<TClient> Client;
|
||||
{
|
||||
try {
|
||||
ReadLock Lock(mServer.GetClientMutex());
|
||||
if (!ClientPtr.expired()) {
|
||||
Client = ClientPtr.lock();
|
||||
} else
|
||||
return true;
|
||||
Client = ClientPtr.lock();
|
||||
} catch (const std::exception&) {
|
||||
// continue
|
||||
beammp_warn("Client expired, shouldn't happen - if a client disconnected recently, you can ignore this");
|
||||
return true;
|
||||
}
|
||||
if (Self || Client.get() != c) {
|
||||
if (Client->IsSynced() || Client->IsSyncing()) {
|
||||
|
||||
@@ -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 "Client.h"
|
||||
#include "TNetwork.h"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user