mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-07-13 10:13:42 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f9b9d4642a | |||
| b4d6f90012 |
+29
-58
@@ -2,33 +2,16 @@ name: Linux
|
|||||||
|
|
||||||
on: [push]
|
on: [push]
|
||||||
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
||||||
VCPKG_FORCE_SYSTEM_BINARIES: 1
|
|
||||||
CMAKE_BUILD_TYPE: "Release"
|
CMAKE_BUILD_TYPE: "Release"
|
||||||
DEBIAN_FRONTEND: "noninteractive"
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
x86_64-matrix:
|
debian-11-build:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- distro: debian
|
|
||||||
version: 11
|
|
||||||
- distro: debian
|
|
||||||
version: 12
|
|
||||||
- distro: ubuntu
|
|
||||||
version: 22.04
|
|
||||||
- distro: ubuntu
|
|
||||||
version: 20.04
|
|
||||||
container:
|
container:
|
||||||
image: ${{ matrix.distro }}:${{ matrix.version }}
|
image: debian:11
|
||||||
steps:
|
steps:
|
||||||
- name: get-cmake
|
|
||||||
uses: lukka/get-cmake@v3.28.1
|
|
||||||
|
|
||||||
- name: Export GitHub Actions cache environment variables
|
- name: Export GitHub Actions cache environment variables
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
@@ -47,59 +30,43 @@ jobs:
|
|||||||
|
|
||||||
- name: Git config safe directory
|
- name: Git config safe directory
|
||||||
shell: bash
|
shell: bash
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1.5-git-safe.sh
|
run: bash ./scripts/debian-11/1.5-git-safe.sh
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1-install-deps.sh
|
run: bash ./scripts/debian-11/1-install-deps.sh
|
||||||
|
|
||||||
- name: Create Build Environment
|
- name: Create Build Environment
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
run: bash ./scripts/debian-11/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
||||||
|
|
||||||
- name: Build Server
|
- name: Build Server
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/3-build.sh
|
run: bash ./scripts/debian-11/3-build.sh
|
||||||
|
|
||||||
- name: Archive server artifact
|
- name: Archive server artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: BeamMP-Server.${{ matrix.distro }}.${{ matrix.version }}.x86_64
|
name: BeamMP-Server-debian
|
||||||
path: ./bin/BeamMP-Server
|
path: ./bin/BeamMP-Server
|
||||||
|
|
||||||
- name: Archive server debug info artifact
|
- name: Archive server debug info artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: debuginfo.${{ matrix.distro }}.${{ matrix.version }}.x86_64
|
name: BeamMP-Server-debian.debug
|
||||||
path: ./bin/BeamMP-Server.debug
|
path: ./bin/BeamMP-Server.debug
|
||||||
|
|
||||||
- name: Build Tests
|
- name: Build Tests
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/3-build-tests.sh
|
run: bash ./scripts/debian-11/3-build-tests.sh
|
||||||
|
|
||||||
- name: Install Runtime Dependencies
|
- name: Install Runtime Dependencies
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/4-install-runtime-deps.sh
|
run: bash ./scripts/debian-11/4-install-runtime-deps.sh
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: ./bin/BeamMP-Server-tests
|
run: ./bin/BeamMP-Server-tests
|
||||||
|
|
||||||
arm64-matrix:
|
ubuntu-22-04-build:
|
||||||
runs-on: [Linux, ARM64]
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
VCPKG_DEFAULT_TRIPLET: "arm64-linux"
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- distro: debian
|
|
||||||
version: 11
|
|
||||||
- distro: debian
|
|
||||||
version: 12
|
|
||||||
- distro: ubuntu
|
|
||||||
version: 22.04
|
|
||||||
- distro: ubuntu
|
|
||||||
version: 20.04
|
|
||||||
container:
|
container:
|
||||||
image: ${{ matrix.distro }}:${{ matrix.version }}
|
image: ubuntu:22.04
|
||||||
steps:
|
steps:
|
||||||
- name: get-cmake
|
|
||||||
uses: lukka/get-cmake@v3.28.1
|
|
||||||
|
|
||||||
- name: Export GitHub Actions cache environment variables
|
- name: Export GitHub Actions cache environment variables
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
@@ -118,35 +85,39 @@ jobs:
|
|||||||
|
|
||||||
- name: Git config safe directory
|
- name: Git config safe directory
|
||||||
shell: bash
|
shell: bash
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1.5-git-safe.sh
|
run: bash ./scripts/ubuntu-22.04/1.5-git-safe.sh
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1-install-deps.sh
|
run: bash ./scripts/ubuntu-22.04/1-install-deps.sh
|
||||||
|
|
||||||
|
- name: Setup vcpkg
|
||||||
|
uses: lukka/run-vcpkg@v11
|
||||||
|
with:
|
||||||
|
runVcpkgInstall: true
|
||||||
|
|
||||||
- name: Create Build Environment
|
- name: Create Build Environment
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
run: bash ./scripts/ubuntu-22.04/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
||||||
|
|
||||||
- name: Build Server
|
- name: Build Server
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/3-build.sh
|
run: bash ./scripts/ubuntu-22.04/3-build.sh
|
||||||
|
|
||||||
- name: Archive server artifact
|
- name: Archive server artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: BeamMP-Server.${{ matrix.distro }}.${{ matrix.version }}.arm64
|
name: BeamMP-Server-ubuntu
|
||||||
path: ./bin/BeamMP-Server
|
path: ./bin/BeamMP-Server
|
||||||
|
|
||||||
- name: Archive server debug info artifact
|
- name: Archive server debug info artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: debuginfo.${{ matrix.distro }}.${{ matrix.version }}.arm64
|
name: BeamMP-Server-ubuntu.debug
|
||||||
path: ./bin/BeamMP-Server.debug
|
path: ./bin/BeamMP-Server.debug
|
||||||
|
|
||||||
- name: Build Tests
|
- name: Build Tests
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/3-build-tests.sh
|
run: bash ./scripts/ubuntu-22.04/3-build-tests.sh
|
||||||
|
|
||||||
- name: Install Runtime Dependencies
|
- name: Install Runtime Dependencies
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/4-install-runtime-deps.sh
|
run: bash ./scripts/ubuntu-22.04/4-install-runtime-deps.sh
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: ./bin/BeamMP-Server-tests
|
run: ./bin/BeamMP-Server-tests
|
||||||
|
|
||||||
@@ -8,7 +8,6 @@ on:
|
|||||||
env:
|
env:
|
||||||
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
||||||
CMAKE_BUILD_TYPE: "Release"
|
CMAKE_BUILD_TYPE: "Release"
|
||||||
DEBIAN_FRONTEND: "noninteractive"
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
create-release:
|
create-release:
|
||||||
@@ -28,30 +27,18 @@ jobs:
|
|||||||
draft: false
|
draft: false
|
||||||
prerelease: true
|
prerelease: true
|
||||||
body: |
|
body: |
|
||||||
Files included in this release are:
|
Files included in this release:
|
||||||
- `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` is the windows build. You need to install the [Visual C++ Redistributables](https://aka.ms/vs/17/release/vc_redist.x64.exe) to run this.
|
||||||
- `BeamMP-Server.exe` for the Windows build (x86_64). You need to install the [Visual C++ Redistributables](https://aka.ms/vs/17/release/vc_redist.x64.exe) to run this.
|
- `BeamMP-Server-debian` is a Debian 11 build, requires `liblua5.3-0`.
|
||||||
|
- `BeamMP-Server-ubuntu` is a Ubuntu 22.04 build, requires `liblua5.3-0`.
|
||||||
|
|
||||||
x86_64-matrix:
|
upload-release-files-debian-11:
|
||||||
|
name: Build and upload Debian 11 Release Files
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
needs: create-release
|
needs: create-release
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- distro: debian
|
|
||||||
version: 11
|
|
||||||
- distro: debian
|
|
||||||
version: 12
|
|
||||||
- distro: ubuntu
|
|
||||||
version: 22.04
|
|
||||||
- distro: ubuntu
|
|
||||||
version: 20.04
|
|
||||||
container:
|
container:
|
||||||
image: ${{ matrix.distro }}:${{ matrix.version }}
|
image: debian:11
|
||||||
steps:
|
steps:
|
||||||
- name: get-cmake
|
|
||||||
uses: lukka/get-cmake@v3.28.1
|
|
||||||
|
|
||||||
- name: Export GitHub Actions cache environment variables
|
- name: Export GitHub Actions cache environment variables
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
@@ -70,16 +57,21 @@ jobs:
|
|||||||
|
|
||||||
- name: Git config safe directory
|
- name: Git config safe directory
|
||||||
shell: bash
|
shell: bash
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1.5-git-safe.sh
|
run: bash ./scripts/debian-11/1.5-git-safe.sh
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1-install-deps.sh
|
run: bash ./scripts/debian-11/1-install-deps.sh
|
||||||
|
|
||||||
|
- name: Setup vcpkg
|
||||||
|
uses: lukka/run-vcpkg@v11
|
||||||
|
with:
|
||||||
|
runVcpkgInstall: true
|
||||||
|
|
||||||
- name: Create Build Environment
|
- name: Create Build Environment
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
run: bash ./scripts/debian-11/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
||||||
|
|
||||||
- name: Build Server
|
- name: Build Server
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/3-build.sh
|
run: bash ./scripts/debian-11/3-build.sh
|
||||||
|
|
||||||
- name: Upload Release Asset
|
- name: Upload Release Asset
|
||||||
id: upload-release-asset
|
id: upload-release-asset
|
||||||
@@ -87,9 +79,9 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
asset_name: BeamMP-Server.${{ matrix.distro }}.${{ matrix.version }}.x86_64
|
|
||||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||||
asset_path: ./bin/BeamMP-Server
|
asset_path: ./bin/BeamMP-Server
|
||||||
|
asset_name: BeamMP-Server-debian
|
||||||
asset_content_type: application/x-elf
|
asset_content_type: application/x-elf
|
||||||
|
|
||||||
- name: Upload Debug Info
|
- name: Upload Debug Info
|
||||||
@@ -98,34 +90,18 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
asset_name: debuginfo.${{ matrix.distro }}.${{ matrix.version }}.x86_64
|
|
||||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||||
asset_path: ./bin/BeamMP-Server.debug
|
asset_path: ./bin/BeamMP-Server.debug
|
||||||
|
asset_name: debuginfo-debian.debug
|
||||||
asset_content_type: application/x-elf
|
asset_content_type: application/x-elf
|
||||||
|
|
||||||
arm64-matrix:
|
upload-release-files-ubuntu-22-04:
|
||||||
runs-on: [Linux, ARM64]
|
name: Build and upload Ubuntu 22.04 Release Files
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
needs: create-release
|
needs: create-release
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- distro: debian
|
|
||||||
version: 11
|
|
||||||
- distro: debian
|
|
||||||
version: 12
|
|
||||||
- distro: ubuntu
|
|
||||||
version: 22.04
|
|
||||||
- distro: ubuntu
|
|
||||||
version: 20.04
|
|
||||||
env:
|
|
||||||
VCPKG_DEFAULT_TRIPLET: "arm64-linux"
|
|
||||||
VCPKG_FORCE_SYSTEM_BINARIES: 1
|
|
||||||
container:
|
container:
|
||||||
image: ${{ matrix.distro }}:${{ matrix.version }}
|
image: ubuntu:22.04
|
||||||
steps:
|
steps:
|
||||||
- name: get-cmake
|
|
||||||
uses: lukka/get-cmake@v3.28.1
|
|
||||||
|
|
||||||
- name: Export GitHub Actions cache environment variables
|
- name: Export GitHub Actions cache environment variables
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
@@ -144,16 +120,16 @@ jobs:
|
|||||||
|
|
||||||
- name: Git config safe directory
|
- name: Git config safe directory
|
||||||
shell: bash
|
shell: bash
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1.5-git-safe.sh
|
run: bash ./scripts/ubuntu-22.04/1.5-git-safe.sh
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/1-install-deps.sh
|
run: bash ./scripts/ubuntu-22.04/1-install-deps.sh
|
||||||
|
|
||||||
- name: Create Build Environment
|
- name: Create Build Environment
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
run: bash ./scripts/ubuntu-22.04/2-configure.sh '-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake'
|
||||||
|
|
||||||
- name: Build Server
|
- name: Build Server
|
||||||
run: bash ./scripts/${{ matrix.distro }}-${{ matrix.version }}/3-build.sh
|
run: bash ./scripts/ubuntu-22.04/3-build.sh
|
||||||
|
|
||||||
- name: Upload Release Asset
|
- name: Upload Release Asset
|
||||||
id: upload-release-asset
|
id: upload-release-asset
|
||||||
@@ -161,9 +137,9 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
asset_name: BeamMP-Server.${{ matrix.distro }}.${{ matrix.version }}.arm64
|
|
||||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||||
asset_path: ./bin/BeamMP-Server
|
asset_path: ./bin/BeamMP-Server
|
||||||
|
asset_name: BeamMP-Server-ubuntu
|
||||||
asset_content_type: application/x-elf
|
asset_content_type: application/x-elf
|
||||||
|
|
||||||
- name: Upload Debug Info
|
- name: Upload Debug Info
|
||||||
@@ -172,9 +148,9 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
asset_name: debuginfo.${{ matrix.distro }}.${{ matrix.version }}.arm64
|
|
||||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||||
asset_path: ./bin/BeamMP-Server.debug
|
asset_path: ./bin/BeamMP-Server.debug
|
||||||
|
asset_name: debuginfo-ubuntu.debug
|
||||||
asset_content_type: application/x-elf
|
asset_content_type: application/x-elf
|
||||||
|
|
||||||
upload-release-files-windows:
|
upload-release-files-windows:
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ set(PRJ_HEADERS
|
|||||||
include/TScopedTimer.h
|
include/TScopedTimer.h
|
||||||
include/TServer.h
|
include/TServer.h
|
||||||
include/VehicleData.h
|
include/VehicleData.h
|
||||||
include/Env.h
|
|
||||||
)
|
)
|
||||||
# add all source files (.cpp) to this, except the one with main()
|
# add all source files (.cpp) to this, except the one with main()
|
||||||
set(PRJ_SOURCES
|
set(PRJ_SOURCES
|
||||||
@@ -71,7 +70,6 @@ set(PRJ_SOURCES
|
|||||||
src/TScopedTimer.cpp
|
src/TScopedTimer.cpp
|
||||||
src/TServer.cpp
|
src/TServer.cpp
|
||||||
src/VehicleData.cpp
|
src/VehicleData.cpp
|
||||||
src/Env.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package(Lua REQUIRED)
|
find_package(Lua REQUIRED)
|
||||||
|
|||||||
@@ -52,22 +52,20 @@ You can find precompiled binaries under [Releases](https://github.com/BeamMP/Bea
|
|||||||
|
|
||||||
On Linux, you need some dependencies to **build** the server (on Windows, you don't):
|
On Linux, you need some dependencies to **build** the server (on Windows, you don't):
|
||||||
|
|
||||||
|
For Debian, Ubuntu and others you can find scripts that do this in `scripts/`.
|
||||||
|
|
||||||
```
|
```
|
||||||
liblua5.3-dev curl zip unzip tar cmake make git g++
|
liblua5.3-dev curl zip unzip tar cmake make git g++
|
||||||
```
|
```
|
||||||
|
|
||||||
You can install these with your distribution's package manager. You will need sudo or need root for ONLY this step.
|
The names of each package may change depending on your platform. See in `scripts/` or use a search engine to find out what they're called for you.
|
||||||
|
|
||||||
The names of each package may change depending on your platform.
|
|
||||||
|
|
||||||
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:
|
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`.
|
1. Check out the repository with git: `git clone --recursive https://github.com/BeamMP/BeamMP-Server`.
|
||||||
2. Go into the directory `cd 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.
|
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`.
|
4. Build via `cmake --build bin --parallel -t BeamMP-Server`.
|
||||||
5. Your executable can be found in `bin/`.
|
5. Your executable can be found in `bin/`.
|
||||||
|
|
||||||
When you make changes to the code, you only have to run step 4 again.
|
When you make changes to the code, you only have to run step 4 again.
|
||||||
|
|||||||
+1
-1
@@ -134,7 +134,7 @@ private:
|
|||||||
static inline std::mutex mShutdownHandlersMutex {};
|
static inline std::mutex mShutdownHandlersMutex {};
|
||||||
static inline std::deque<TShutdownHandler> mShutdownHandlers {};
|
static inline std::deque<TShutdownHandler> mShutdownHandlers {};
|
||||||
|
|
||||||
static inline Version mVersion { 3, 2, 2 };
|
static inline Version mVersion { 3, 2, 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
void SplitString(std::string const& str, const char delim, std::vector<std::string>& out);
|
void SplitString(std::string const& str, const char delim, std::vector<std::string>& out);
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
#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);
|
|
||||||
|
|
||||||
}
|
|
||||||
+2
-2
@@ -26,7 +26,7 @@ public:
|
|||||||
void ForEachClient(const std::function<bool(std::weak_ptr<TClient>)>& Fn);
|
void ForEachClient(const std::function<bool(std::weak_ptr<TClient>)>& Fn);
|
||||||
size_t ClientCount() const;
|
size_t ClientCount() const;
|
||||||
|
|
||||||
void GlobalParser(const std::weak_ptr<TClient>& Client, std::vector<uint8_t>&& Packet, TPPSMonitor& PPSMonitor, TNetwork& Network);
|
static void GlobalParser(const std::weak_ptr<TClient>& Client, std::vector<uint8_t>&& Packet, TPPSMonitor& PPSMonitor, TNetwork& Network);
|
||||||
static void HandleEvent(TClient& c, const std::string& Data);
|
static void HandleEvent(TClient& c, const std::string& Data);
|
||||||
RWMutex& GetClientMutex() const { return mClientsMutex; }
|
RWMutex& GetClientMutex() const { return mClientsMutex; }
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ private:
|
|||||||
static bool ShouldSpawn(TClient& c, const std::string& CarJson, int ID);
|
static bool ShouldSpawn(TClient& c, const std::string& CarJson, int ID);
|
||||||
static bool IsUnicycle(TClient& c, const std::string& CarJson);
|
static bool IsUnicycle(TClient& c, const std::string& CarJson);
|
||||||
static void Apply(TClient& c, int VID, const std::string& pckt);
|
static void Apply(TClient& c, int VID, const std::string& pckt);
|
||||||
void HandlePosition(TClient& c, const std::string& Packet);
|
static void HandlePosition(TClient& c, const std::string& Packet);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BufferView {
|
struct BufferView {
|
||||||
|
|||||||
@@ -4,4 +4,4 @@ set -ex
|
|||||||
|
|
||||||
apt-get update -y
|
apt-get update -y
|
||||||
|
|
||||||
apt-get install -y liblua5.3-0 liblua5.3-dev curl zip unzip tar cmake make git g++ ninja-build
|
apt-get install -y liblua5.3-0 liblua5.3-dev curl zip unzip tar cmake make git g++
|
||||||
|
|||||||
@@ -2,6 +2,4 @@
|
|||||||
|
|
||||||
set -ex
|
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,--build-id=none -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" -DBeamMP-Server_ENABLE_LTO=ON
|
||||||
|
|
||||||
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
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/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
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/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
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/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
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
cmake --build bin --parallel -t BeamMP-Server-tests
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/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
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
apt-get update -y
|
|
||||||
|
|
||||||
apt-get install -y liblua5.3-0 curl
|
|
||||||
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/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
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/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
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/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
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
cmake --build bin --parallel -t BeamMP-Server-tests
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/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
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
apt-get update -y
|
|
||||||
|
|
||||||
apt-get install -y liblua5.3-0 curl
|
|
||||||
|
|
||||||
@@ -4,4 +4,4 @@ set -ex
|
|||||||
|
|
||||||
apt-get update -y
|
apt-get update -y
|
||||||
|
|
||||||
apt-get install -y liblua5.3-0 liblua5.3-dev curl zip unzip tar cmake make git g++ ninja-build
|
apt-get install -y liblua5.3-0 liblua5.3-dev curl zip unzip tar cmake make git g++
|
||||||
|
|||||||
@@ -2,6 +2,4 @@
|
|||||||
|
|
||||||
set -ex
|
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,--build-id=none -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" -DBeamMP-Server_ENABLE_LTO=ON
|
||||||
|
|
||||||
cmake . -B bin $1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O3 -g -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" -DBeamMP-Server_ENABLE_LTO=ON
|
|
||||||
|
|||||||
Executable → Regular
-2
@@ -2,6 +2,4 @@
|
|||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
vcpkg add port lua
|
|
||||||
|
|
||||||
cmake . -B bin $1 -DCMAKE_BUILD_TYPE=Release -DBeamMP-Server_ENABLE_LTO=ON -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
cmake . -B bin $1 -DCMAKE_BUILD_TYPE=Release -DBeamMP-Server_ENABLE_LTO=ON -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
||||||
|
|||||||
+1
-3
@@ -53,9 +53,9 @@ std::string TClient::GetCarPositionRaw(int Ident) {
|
|||||||
try {
|
try {
|
||||||
return mVehiclePosition.at(size_t(Ident));
|
return mVehiclePosition.at(size_t(Ident));
|
||||||
} catch (const std::out_of_range& oor) {
|
} catch (const std::out_of_range& oor) {
|
||||||
beammp_debugf("Failed to get vehicle position for {}: {}", Ident, oor.what());
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void TClient::Disconnect(std::string_view Reason) {
|
void TClient::Disconnect(std::string_view Reason) {
|
||||||
@@ -146,8 +146,6 @@ std::optional<std::weak_ptr<TClient>> GetClient(TServer& Server, int ID) {
|
|||||||
MaybeClient = CPtr;
|
MaybeClient = CPtr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
beammp_debugf("Found an expired client while looking for id {}", ID);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-7
@@ -1,10 +1,8 @@
|
|||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
#include "Env.h"
|
|
||||||
#include "TConsole.h"
|
#include "TConsole.h"
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <charconv>
|
#include <charconv>
|
||||||
#include <fmt/core.h>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
@@ -203,11 +201,8 @@ void Application::CheckForUpdates() {
|
|||||||
auto MyVersion = ServerVersion();
|
auto MyVersion = ServerVersion();
|
||||||
auto RemoteVersion = Version(VersionStrToInts(Response));
|
auto RemoteVersion = Version(VersionStrToInts(Response));
|
||||||
if (IsOutdated(MyVersion, RemoteVersion)) {
|
if (IsOutdated(MyVersion, RemoteVersion)) {
|
||||||
std::string RealVersionString = std::string("v") + RemoteVersion.AsString();
|
std::string RealVersionString = 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";
|
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));
|
||||||
auto UpdateMsg = Env::Get(Env::Key::PROVIDER_UPDATE_MESSAGE).value_or(DefaultUpdateMsg);
|
|
||||||
UpdateMsg = fmt::vformat(std::string_view(UpdateMsg), fmt::make_format_args(RealVersionString));
|
|
||||||
beammp_warnf("{}{}{}", ANSI_YELLOW_BOLD, UpdateMsg, ANSI_RESET);
|
|
||||||
} else {
|
} else {
|
||||||
if (FirstTime) {
|
if (FirstTime) {
|
||||||
beammp_info("Server up-to-date!");
|
beammp_info("Server up-to-date!");
|
||||||
|
|||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
#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 "";
|
|
||||||
}
|
|
||||||
+3
-3
@@ -120,9 +120,9 @@ void TConfig::FlushToFile() {
|
|||||||
data["Misc"][StrHideUpdateMessages.data()] = Application::Settings.HideUpdateMessages;
|
data["Misc"][StrHideUpdateMessages.data()] = Application::Settings.HideUpdateMessages;
|
||||||
SetComment(data["Misc"][StrHideUpdateMessages.data()].comments(), " Hides the periodic update message which notifies you of a new server version. You should really keep this on and always update as soon as possible. For more information visit https://wiki.beammp.com/en/home/server-maintenance#updating-the-server. An update message will always appear at startup regardless.");
|
SetComment(data["Misc"][StrHideUpdateMessages.data()].comments(), " Hides the periodic update message which notifies you of a new server version. You should really keep this on and always update as soon as possible. For more information visit https://wiki.beammp.com/en/home/server-maintenance#updating-the-server. An update message will always appear at startup regardless.");
|
||||||
data["Misc"][StrSendErrors.data()] = Application::Settings.SendErrors;
|
data["Misc"][StrSendErrors.data()] = Application::Settings.SendErrors;
|
||||||
SetComment(data["Misc"][StrSendErrors.data()].comments(), " If SendErrors is `true`, the server will send helpful info about crashes and other issues back to the BeamMP developers. This info may include your config, who is on your server at the time of the error, and similar general information. This kind of data is vital in helping us diagnose and fix issues faster. This has no impact on server performance. You can opt-out of this system by setting this to `false`");
|
SetComment(data["Misc"][StrSendErrors.data()].comments(), " You can turn on/off the SendErrors message you get on startup here");
|
||||||
data["Misc"][StrSendErrorsMessageEnabled.data()] = Application::Settings.SendErrorsMessageEnabled;
|
data["Misc"][StrSendErrorsMessageEnabled.data()] = Application::Settings.SendErrorsMessageEnabled;
|
||||||
SetComment(data["Misc"][StrSendErrorsMessageEnabled.data()].comments(), " You can turn on/off the SendErrors message you get on startup here");
|
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`");
|
||||||
std::stringstream Ss;
|
std::stringstream Ss;
|
||||||
Ss << "# This is the BeamMP-Server config file.\n"
|
Ss << "# This is the BeamMP-Server config file.\n"
|
||||||
"# Help & Documentation: `https://wiki.beammp.com/en/home/server-maintenance`\n"
|
"# Help & Documentation: `https://wiki.beammp.com/en/home/server-maintenance`\n"
|
||||||
@@ -313,6 +313,6 @@ std::string TConfig::TagsAsPrettyArray() const {
|
|||||||
for (size_t i = 0; i < TagsArray.size() - 1; ++i) {
|
for (size_t i = 0; i < TagsArray.size() - 1; ++i) {
|
||||||
Pretty += '\"' + TagsArray[i] + "\", ";
|
Pretty += '\"' + TagsArray[i] + "\", ";
|
||||||
}
|
}
|
||||||
Pretty += '\"' + TagsArray.at(TagsArray.size() - 1) + "\"";
|
Pretty += '\"' + TagsArray.at(TagsArray.size()-1) + "\"";
|
||||||
return Pretty;
|
return Pretty;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -601,7 +601,7 @@ std::pair<sol::table, std::string> TLuaEngine::StateThreadData::Lua_GetPositionR
|
|||||||
return Result;
|
return Result;
|
||||||
} else {
|
} else {
|
||||||
// return std::make_tuple(sol::lua_nil, sol::make_object(StateView, "Client expired"));
|
// return std::make_tuple(sol::lua_nil, sol::make_object(StateView, "Client expired"));
|
||||||
Result.second = "No such player";
|
Result.second = "Client expired";
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -101,7 +101,7 @@ void TNetwork::UDPServerMain() {
|
|||||||
Client->SetUDPAddr(client);
|
Client->SetUDPAddr(client);
|
||||||
Client->SetIsConnected(true);
|
Client->SetIsConnected(true);
|
||||||
Data.erase(Data.begin(), Data.begin() + 2);
|
Data.erase(Data.begin(), Data.begin() + 2);
|
||||||
mServer.GlobalParser(ClientPtr, std::move(Data), mPPSMonitor, *this);
|
TServer::GlobalParser(ClientPtr, std::move(Data), mPPSMonitor, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -552,7 +552,7 @@ void TNetwork::TCPClient(const std::weak_ptr<TClient>& c) {
|
|||||||
Client->Disconnect("TCPRcv failed");
|
Client->Disconnect("TCPRcv failed");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mServer.GlobalParser(c, std::move(res), mPPSMonitor, *this);
|
TServer::GlobalParser(c, std::move(res), mPPSMonitor, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QueueSync.joinable())
|
if (QueueSync.joinable())
|
||||||
|
|||||||
+24
-89
@@ -7,7 +7,6 @@
|
|||||||
#include <TLuaPlugin.h>
|
#include <TLuaPlugin.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <any>
|
#include <any>
|
||||||
#include <optional>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
@@ -52,30 +51,6 @@ TEST_CASE("GetPidVid") {
|
|||||||
CHECK_EQ(pid, 10);
|
CHECK_EQ(pid, 10);
|
||||||
CHECK_EQ(vid, 12);
|
CHECK_EQ(vid, 12);
|
||||||
}
|
}
|
||||||
SUBCASE("Valid doubledigit 2") {
|
|
||||||
const auto MaybePidVid = GetPidVid("10-2");
|
|
||||||
CHECK(MaybePidVid);
|
|
||||||
auto [pid, vid] = MaybePidVid.value();
|
|
||||||
|
|
||||||
CHECK_EQ(pid, 10);
|
|
||||||
CHECK_EQ(vid, 2);
|
|
||||||
}
|
|
||||||
SUBCASE("Valid doubledigit 3") {
|
|
||||||
const auto MaybePidVid = GetPidVid("33-23");
|
|
||||||
CHECK(MaybePidVid);
|
|
||||||
auto [pid, vid] = MaybePidVid.value();
|
|
||||||
|
|
||||||
CHECK_EQ(pid, 33);
|
|
||||||
CHECK_EQ(vid, 23);
|
|
||||||
}
|
|
||||||
SUBCASE("Valid doubledigit 4") {
|
|
||||||
const auto MaybePidVid = GetPidVid("3-23");
|
|
||||||
CHECK(MaybePidVid);
|
|
||||||
auto [pid, vid] = MaybePidVid.value();
|
|
||||||
|
|
||||||
CHECK_EQ(pid, 3);
|
|
||||||
CHECK_EQ(vid, 23);
|
|
||||||
}
|
|
||||||
SUBCASE("Empty string") {
|
SUBCASE("Empty string") {
|
||||||
const auto MaybePidVid = GetPidVid("");
|
const auto MaybePidVid = GetPidVid("");
|
||||||
CHECK(!MaybePidVid);
|
CHECK(!MaybePidVid);
|
||||||
@@ -105,17 +80,6 @@ TEST_CASE("GetPidVid") {
|
|||||||
TServer::TServer(const std::vector<std::string_view>& Arguments) {
|
TServer::TServer(const std::vector<std::string_view>& Arguments) {
|
||||||
beammp_info("BeamMP Server v" + Application::ServerVersionString());
|
beammp_info("BeamMP Server v" + Application::ServerVersionString());
|
||||||
Application::SetSubsystemStatus("Server", Application::Status::Starting);
|
Application::SetSubsystemStatus("Server", Application::Status::Starting);
|
||||||
if (Arguments.size() > 1) {
|
|
||||||
Application::Settings.CustomIP = Arguments[0];
|
|
||||||
size_t n = std::count(Application::Settings.CustomIP.begin(), Application::Settings.CustomIP.end(), '.');
|
|
||||||
auto p = Application::Settings.CustomIP.find_first_not_of(".0123456789");
|
|
||||||
if (p != std::string::npos || n != 3 || Application::Settings.CustomIP.substr(0, 3) == "127") {
|
|
||||||
Application::Settings.CustomIP.clear();
|
|
||||||
beammp_warn("IP Specified is invalid! Ignoring");
|
|
||||||
} else {
|
|
||||||
beammp_info("server started with custom IP");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Application::SetSubsystemStatus("Server", Application::Status::Good);
|
Application::SetSubsystemStatus("Server", Application::Status::Good);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +203,6 @@ void TServer::GlobalParser(const std::weak_ptr<TClient>& Client, std::vector<uin
|
|||||||
PPSMonitor.IncrementInternalPPS();
|
PPSMonitor.IncrementInternalPPS();
|
||||||
Network.SendToAll(LockedClient.get(), Packet, false, false);
|
Network.SendToAll(LockedClient.get(), Packet, false, false);
|
||||||
HandlePosition(*LockedClient, StringPacket);
|
HandlePosition(*LockedClient, StringPacket);
|
||||||
return;
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -414,7 +377,7 @@ void TServer::Apply(TClient& c, int VID, const std::string& pckt) {
|
|||||||
|
|
||||||
FoundPos = VD.find('{');
|
FoundPos = VD.find('{');
|
||||||
if (FoundPos == std::string::npos) {
|
if (FoundPos == std::string::npos) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
VD = VD.substr(FoundPos);
|
VD = VD.substr(FoundPos);
|
||||||
rapidjson::Document Veh, Pack;
|
rapidjson::Document Veh, Pack;
|
||||||
@@ -448,63 +411,35 @@ void TServer::InsertClient(const std::shared_ptr<TClient>& NewClient) {
|
|||||||
(void)mClients.insert(NewClient);
|
(void)mClients.insert(NewClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PidVidData {
|
void TServer::HandlePosition(TClient& c, const std::string& Packet) {
|
||||||
int PID;
|
|
||||||
int VID;
|
|
||||||
std::string Data;
|
|
||||||
};
|
|
||||||
|
|
||||||
static std::optional<PidVidData> ParsePositionPacket(const std::string& Packet) {
|
|
||||||
if (Packet.size() < 3) {
|
if (Packet.size() < 3) {
|
||||||
// invalid packet
|
// invalid packet
|
||||||
return std::nullopt;
|
return;
|
||||||
}
|
}
|
||||||
// Zp:PID-VID:DATA
|
// Zp:serverVehicleID:data
|
||||||
|
// Zp:0:data
|
||||||
std::string withoutCode = Packet.substr(3);
|
std::string withoutCode = Packet.substr(3);
|
||||||
|
auto NameDataSep = withoutCode.find(':', 2);
|
||||||
|
if (NameDataSep == std::string::npos || NameDataSep < 2) {
|
||||||
|
// invalid packet
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// FIXME: ensure that -2 does what it should... it seems weird.
|
||||||
|
std::string ServerVehicleID = withoutCode.substr(2, NameDataSep - 2);
|
||||||
|
if (NameDataSep + 1 > withoutCode.size()) {
|
||||||
|
// invalid packet
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::string Data = withoutCode.substr(NameDataSep + 1);
|
||||||
|
|
||||||
// parse veh ID
|
// parse veh ID
|
||||||
if (auto DataBeginPos = withoutCode.find('{'); DataBeginPos != std::string::npos && DataBeginPos != 0) {
|
auto MaybePidVid = GetPidVid(ServerVehicleID);
|
||||||
// separator is :{, so position of { minus one
|
if (MaybePidVid) {
|
||||||
auto PidVidOnly = withoutCode.substr(0, DataBeginPos - 1);
|
int PID = -1;
|
||||||
auto MaybePidVid = GetPidVid(PidVidOnly);
|
int VID = -1;
|
||||||
if (MaybePidVid) {
|
// FIXME: check that the VID and PID are valid, so that we don't waste memory
|
||||||
int PID = -1;
|
std::tie(PID, VID) = MaybePidVid.value();
|
||||||
int VID = -1;
|
|
||||||
// FIXME: check that the VID and PID are valid, so that we don't waste memory
|
|
||||||
std::tie(PID, VID) = MaybePidVid.value();
|
|
||||||
|
|
||||||
std::string Data = withoutCode.substr(DataBeginPos);
|
c.SetCarPosition(VID, Data);
|
||||||
return PidVidData {
|
|
||||||
.PID = PID,
|
|
||||||
.VID = VID,
|
|
||||||
.Data = Data,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
// invalid packet
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// invalid packet
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("ParsePositionPacket") {
|
|
||||||
const auto TestData = R"({"tim":10.428000331623,"vel":[-2.4171722121385e-05,-9.7184734153252e-06,-7.6420763232237e-06],"rot":[-0.0001296154171915,0.0031575385950029,0.98994906610295,0.14138903660382],"rvel":[5.3640324636461e-05,-9.9824529946024e-05,5.1664064641372e-05],"pos":[-0.27281248907838,-0.20515357944633,0.49695488960431],"ping":0.032999999821186})";
|
|
||||||
SUBCASE("All the pids and vids") {
|
|
||||||
for (int pid = 0; pid < 100; ++pid) {
|
|
||||||
for (int vid = 0; vid < 100; ++vid) {
|
|
||||||
std::optional<PidVidData> MaybeRes = ParsePositionPacket(fmt::format("Zp:{}-{}:{}", pid, vid, TestData));
|
|
||||||
CHECK(MaybeRes.has_value());
|
|
||||||
CHECK_EQ(MaybeRes.value().PID, pid);
|
|
||||||
CHECK_EQ(MaybeRes.value().VID, vid);
|
|
||||||
CHECK_EQ(MaybeRes.value().Data, TestData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TServer::HandlePosition(TClient& c, const std::string& Packet) {
|
|
||||||
if (auto Parsed = ParsePositionPacket(Packet); Parsed.has_value()) {
|
|
||||||
c.SetCarPosition(Parsed.value().VID, Parsed.value().Data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
Submodule vcpkg updated: 8397227251...72010900b7
+7
-7
@@ -2,18 +2,18 @@
|
|||||||
"name": "server",
|
"name": "server",
|
||||||
"version-string": "0.1.0",
|
"version-string": "0.1.0",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
|
"fmt",
|
||||||
|
"doctest",
|
||||||
"boost-asio",
|
"boost-asio",
|
||||||
|
"boost-variant",
|
||||||
"boost-spirit",
|
"boost-spirit",
|
||||||
"boost-uuid",
|
"boost-uuid",
|
||||||
"boost-variant",
|
|
||||||
"cpp-httplib",
|
"cpp-httplib",
|
||||||
"doctest",
|
"toml11",
|
||||||
"fmt",
|
|
||||||
"libzip",
|
"libzip",
|
||||||
|
"rapidjson",
|
||||||
"nlohmann-json",
|
"nlohmann-json",
|
||||||
"openssl",
|
"openssl",
|
||||||
"rapidjson",
|
"sol2"
|
||||||
"sol2",
|
|
||||||
"toml11"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user