Compare commits

..

No commits in common. "master" and "0.0.7" have entirely different histories.

14 changed files with 77 additions and 181 deletions

View File

@ -16,20 +16,18 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
env: env:
PREMAKE_VERSION: "5.0.0-beta6" PREMAKE_VERSION: "5.0.0-beta2"
jobs: jobs:
build-windows: build-win:
name: Build Windows name: Build Windows
runs-on: windows-latest runs-on: windows-latest
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
configuration: configuration:
- debug
- release - release
compiler:
- msvc
- clang
arch: arch:
- x86 - x86
- x64 - x64
@ -47,6 +45,7 @@ jobs:
with: with:
submodules: true submodules: true
fetch-depth: 0 fetch-depth: 0
# NOTE - If LFS ever starts getting used during builds, switch this to true!
lfs: false lfs: false
- name: Add msbuild to PATH - name: Add msbuild to PATH
@ -57,24 +56,19 @@ jobs:
with: with:
version: ${{ env.PREMAKE_VERSION }} version: ${{ env.PREMAKE_VERSION }}
- name: Generate project files (clang) - name: Generate project files
if: matrix.compiler == 'clang'
run: premake5 --cc=${{matrix.compiler}} vs2022
- name: Generate project files (msvc)
if: matrix.compiler == 'msvc'
run: premake5 vs2022 run: premake5 vs2022
- name: Set up problem matching - name: Set up problem matching
uses: ammaraskar/msvc-problem-matcher@master uses: ammaraskar/msvc-problem-matcher@master
- name: Build ${{matrix.arch}} ${{matrix.configuration}} ${{matrix.compiler}} binaries - name: Build ${{matrix.arch}} ${{matrix.configuration}} binaries
run: msbuild /m /p:Configuration=${{matrix.configuration}} /p:Platform=${{matrix.platform}} build/alterware-master.sln run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} /p:Platform=${{matrix.platform}} build/alterware-master.sln
- name: Upload ${{matrix.arch}} ${{matrix.configuration}} ${{matrix.compiler}} binaries - name: Upload ${{matrix.arch}} ${{matrix.configuration}} binaries
uses: actions/upload-artifact@main uses: actions/upload-artifact@main
with: with:
name: windows-${{matrix.arch}}-${{matrix.configuration}}-${{matrix.compiler}} name: windows-${{matrix.arch}}-${{matrix.configuration}}
path: | path: |
build/bin/${{matrix.arch}}/${{matrix.configuration}}/alterware-master.exe build/bin/${{matrix.arch}}/${{matrix.configuration}}/alterware-master.exe
build/bin/${{matrix.arch}}/${{matrix.configuration}}/alterware-master.pdb build/bin/${{matrix.arch}}/${{matrix.configuration}}/alterware-master.pdb
@ -82,38 +76,36 @@ jobs:
build-linux: build-linux:
name: Build Linux name: Build Linux
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: ubuntu:noble
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
configuration: configuration:
- debug
- release - release
arch: arch:
- x86 - x86
- amd64 - x64
steps: steps:
- name: Install g++ and multilib
run: |
apt-get update
apt-get install -y wget tar git make gcc-13 g++-13 gcc-13-multilib g++-13-multilib
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 13
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 13
update-alternatives --set gcc /usr/bin/gcc-13
update-alternatives --set g++ /usr/bin/g++-13
- name: Check out files - name: Check out files
uses: actions/checkout@main uses: actions/checkout@main
with: with:
submodules: true submodules: true
fetch-depth: 0 fetch-depth: 0
# NOTE - If LFS ever starts getting used during builds, switch this to true!
lfs: false lfs: false
- name: Install dependencies (arm64)
if: matrix.arch == 'arm64'
run: |
sudo apt-get update
sudo apt-get -y install crossbuild-essential-arm64
- name: Install dependencies (x86) - name: Install dependencies (x86)
if: matrix.arch == 'x86' if: matrix.arch == 'x86'
run: | run: |
dpkg --add-architecture i386 sudo dpkg --add-architecture i386
apt-get update sudo apt-get update
apt-get install -y gcc-13-multilib g++-13-multilib sudo apt-get -y install gcc-multilib g++-multilib
- name: Install Premake5 - name: Install Premake5
uses: diamante0018/setup-premake@master uses: diamante0018/setup-premake@master
@ -124,89 +116,25 @@ jobs:
uses: rui314/setup-mold@staging uses: rui314/setup-mold@staging
- name: Generate project files - name: Generate project files
working-directory: ${{ github.workspace }} run: premake5 gmake2
run: premake5 gmake
- name: Set up problem matching - name: Set up problem matching
uses: ammaraskar/gcc-problem-matcher@master uses: ammaraskar/gcc-problem-matcher@master
- name: Build ${{matrix.arch}} ${{matrix.configuration}} binaries - name: Set up CC environment variable
working-directory: ${{ github.workspace }} if: matrix.arch == 'arm64'
run: | run: |
make -C build config=${{matrix.configuration}}_${{matrix.arch}} -j$(nproc) echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- name: Upload ${{matrix.arch}} ${{matrix.configuration}} binaries - name: Set up CXX environment variable
uses: actions/upload-artifact@main if: matrix.arch == 'arm64'
with: run: |
name: linux-${{matrix.arch}}-${{matrix.configuration}} echo "CXX=aarch64-linux-gnu-g++" >> $GITHUB_ENV
path: |
build/bin/${{matrix.arch}}/${{matrix.configuration}}/alterware-master
prebuild-linux-arm64:
name: Prebuild Linux
runs-on: ubuntu-latest
steps:
- name: Check out files
uses: actions/checkout@main
with:
submodules: true
fetch-depth: 0
lfs: false
- name: Install Premake5
uses: diamante0018/setup-premake@master
with:
version: ${{ env.PREMAKE_VERSION }}
- name: Generate project files
run: premake5 --cc=clang gmake
- name: Upload project files
uses: actions/upload-artifact@main
with:
name: linux-project-files
path: |
build/
build-linux-arm64:
name: Build Linux
runs-on: ${{ matrix.os }}
needs: prebuild-linux-arm64
strategy:
fail-fast: false
matrix:
configuration:
- release
arch:
- arm64
include:
- arch: arm64
os: ubuntu-24.04-arm
steps:
- name: Check out files
uses: actions/checkout@main
with:
submodules: true
fetch-depth: 0
lfs: false
- name: Create the build directory
run: mkdir -p build
- name: Download project files
uses: actions/download-artifact@main
with:
name: linux-project-files
path: build/
- name: Build ${{matrix.arch}} ${{matrix.configuration}} binaries - name: Build ${{matrix.arch}} ${{matrix.configuration}} binaries
working-directory: ${{ github.workspace }}
run: | run: |
pushd build pushd build
make config=${{matrix.configuration}}_${{matrix.arch}} -j$(nproc) make config=${{matrix.configuration}}_${{matrix.arch}} -j$(nproc)
env:
CC: clang
CXX: clang++
- name: Upload ${{matrix.arch}} ${{matrix.configuration}} binaries - name: Upload ${{matrix.arch}} ${{matrix.configuration}} binaries
uses: actions/upload-artifact@main uses: actions/upload-artifact@main
@ -222,9 +150,9 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
configuration: configuration:
- debug
- release - release
arch: arch:
- amd64
- arm64 - arm64
steps: steps:
- name: Check out files - name: Check out files
@ -232,6 +160,7 @@ jobs:
with: with:
submodules: true submodules: true
fetch-depth: 0 fetch-depth: 0
# NOTE - If LFS ever starts getting used during builds, switch this to true!
lfs: false lfs: false
- name: Install Premake5 - name: Install Premake5
@ -240,7 +169,7 @@ jobs:
version: ${{ env.PREMAKE_VERSION }} version: ${{ env.PREMAKE_VERSION }}
- name: Generate project files - name: Generate project files
run: premake5 gmake run: premake5 gmake2
- name: Set up problem matching - name: Set up problem matching
uses: ammaraskar/gcc-problem-matcher@master uses: ammaraskar/gcc-problem-matcher@master
@ -259,7 +188,7 @@ jobs:
deploy: deploy:
name: Deploy artifacts name: Deploy artifacts
needs: [build-windows, build-linux, build-linux-arm64, build-macos] needs: [build-win, build-linux, build-macos]
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.ref_type == 'tag' if: github.ref_type == 'tag'
steps: steps:
@ -269,7 +198,7 @@ jobs:
- name: Download Release binaries - name: Download Release binaries
uses: actions/download-artifact@main uses: actions/download-artifact@main
with: with:
name: linux-amd64-release name: linux-x64-release
- name: Install SSH key - name: Install SSH key
uses: shimataro/ssh-key-action@v2.7.0 uses: shimataro/ssh-key-action@v2.7.0
@ -288,7 +217,7 @@ jobs:
docker: docker:
name: Create Docker Image name: Create Docker Image
needs: [build-windows, build-linux, build-linux-arm64, build-macos] needs: [build-win, build-linux, build-macos]
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.ref_type == 'tag' if: github.ref_type == 'tag'
steps: steps:
@ -314,20 +243,17 @@ jobs:
done done
shell: bash shell: bash
- name: Setup QEMU
uses: docker/setup-qemu-action@v3.6.0
- name: Setup Docker Buildx - name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3.10.0 uses: docker/setup-buildx-action@v3.6.1
- name: Login to DockerHub - name: Login to DockerHub
uses: docker/login-action@v3.4.0 uses: docker/login-action@v3.3.0
with: with:
username: ${{ secrets.DOCKERHUB_USER }} username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- id: meta - id: meta
uses: docker/metadata-action@v5.7.0 uses: docker/metadata-action@v5.5.1
with: with:
images: | images: |
alterware/master-server alterware/master-server
@ -337,10 +263,10 @@ jobs:
- name: Build and Push Docker Image - name: Build and Push Docker Image
id: build-and-push id: build-and-push
uses: docker/build-push-action@v6.15.0 uses: docker/build-push-action@v6.7.0
with: with:
context: . context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}

View File

@ -1,20 +1,14 @@
FROM ubuntu:noble FROM alpine:latest
ARG TARGETARCH
WORKDIR /master-server RUN apk add --no-cache gcompat libstdc++
RUN groupadd alterware-master && useradd -r -g alterware-master alterware-master COPY --chmod=755 ./linux-x64-release/alterware-master /usr/local/bin/
RUN mkdir -p /master-server && \
chown alterware-master:alterware-master /master-server && \
chmod 775 /master-server
COPY --chown=alterware-master:alterware-master --chmod=755 ./linux-${TARGETARCH}-release/alterware-master /master-server
RUN addgroup -S alterware-master && adduser -S alterware-master -G alterware-master
USER alterware-master USER alterware-master
EXPOSE 20810/udp EXPOSE 20810/udp
ENV AW_STATS_LOCATION="" ENV AW_STATS_LOCATION=""
ENTRYPOINT ["/master-server/alterware-master"] ENTRYPOINT ["/usr/local/bin/alterware-master"]

View File

@ -11,29 +11,6 @@ Run using [Docker][docker-link]
docker run -p 20810:20810/udp -e AW_STATS_LOCATION=<UTF-8 C-string> alterware/master-server:latest docker run -p 20810:20810/udp -e AW_STATS_LOCATION=<UTF-8 C-string> alterware/master-server:latest
``` ```
or run as a systemd service
```
[Unit]
Description=AlterWare Master Server
After=network.target
[Service]
Type=simple
ExecStart=<working dir>/alterware-master
WorkingDirectory=<working dir>
Environment="AW_STATS_LOCATION=/var/www/<domain name>/html/stats.json"
StandardOutput=null
Restart=on-failure
RestartSec=10
KillMode=process
User=<username>
Group=<group name>
[Install]
WantedBy=multi-user.target
```
## Build ## Build
- Install [Premake5][premake5-link] and add it to your system PATH - Install [Premake5][premake5-link] and add it to your system PATH
- Clone this repository using [Git][git-link] - Clone this repository using [Git][git-link]
@ -46,9 +23,10 @@ Requirements for Unix systems:
- Dependencies: Ensure the LLVM C++ Standard library is installed - Dependencies: Ensure the LLVM C++ Standard library is installed
- Alternative compilers: If you opt for a different compiler such as GCC, use the [Mold][mold-link] linker - Alternative compilers: If you opt for a different compiler such as GCC, use the [Mold][mold-link] linker
- Customization: Modifications to the Premake5.lua script may be required - Customization: Modifications to the Premake5.lua script may be required
- Platform support: Details regarding supported platforms are available in [build.yml](.github/workflows/build.yml). Linux ARM64 should be supported out of the box even if it's not present in the CI scripts - Platform support: Details regarding supported platforms are available in [build.yml][build-link]
[docker-link]: https://www.docker.com [docker-link]: https://www.docker.com
[premake5-link]: https://premake.github.io [premake5-link]: https://premake.github.io
[git-link]: https://git-scm.com [git-link]: https://git-scm.com
[mold-link]: https://github.com/rui314/mold [mold-link]: https://github.com/rui314/mold
[build-link]: https://github.com/alterware/master-server/blob/master/.github/workflows/build.yml

2
deps/GSL vendored

@ -1 +1 @@
Subproject commit 3325bbd33d24d1f8f5a0f69e782c92ad5a39a68e Subproject commit f1a494cfd2ce55fe88b5134eab985f5852667b8d

2
deps/libtomcrypt vendored

@ -1 +1 @@
Subproject commit a6b9aff7aab857fe1b491710a5c5b9e2be49cb08 Subproject commit fc6b42025b080a19a0a201a427bb8512f251bb7b

2
deps/libtommath vendored

@ -1 +1 @@
Subproject commit e823b0c34cea291bdb94d672731e1c1f08525557 Subproject commit 5809141a3a6ec1bf3443c927c02b955e19224016

View File

@ -47,8 +47,6 @@ function libtomcrypt.project()
"LTC_SOURCE", "LTC_SOURCE",
"_LIB", "_LIB",
"USE_LTM", "USE_LTM",
"LTC_NO_TEST",
"LTC_NO_PROTOTYPES"
} }
removedefines { removedefines {
@ -56,13 +54,15 @@ function libtomcrypt.project()
"_USRDLL", "_USRDLL",
} }
filter { "system:macosx", "platforms:arm64" } if os.istarget("darwin") then
buildoptions "-mcpu=apple-m1" filter "platforms:x64"
buildoptions "-march=native"
filter {} filter {}
filter { "system:macosx", "platforms:amd64" } filter "platforms:arm64"
buildoptions "-mcpu=x86-64" buildoptions "-mcpu=apple-m1"
filter {} filter {}
end
warnings "Off" warnings "Off"
kind "StaticLib" kind "StaticLib"

2
deps/rapidjson vendored

@ -1 +1 @@
Subproject commit 24b5e7a8b27f42fa16b96fc70aade9106cf7102f Subproject commit 7c73dd7de7c4f14379b781418c6e947ad464c818

2
deps/zlib vendored

@ -1 +1 @@
Subproject commit 5a82f71ed1dfc0bec044d9702463dbdf84ea3b71 Subproject commit d476828316d05d54c6fd6a068b121b30c147b5cd

View File

@ -41,10 +41,8 @@ configurations {"debug", "release"}
language "C++" language "C++"
cppdialect "C++20" cppdialect "C++20"
if os.istarget("linux") then if os.istarget("darwin") then
platforms {"x86", "amd64", "arm64"} platforms {"x64", "arm64"}
elseif os.istarget("macosx") then
platforms {"amd64", "arm64"}
else else
platforms {"x86", "x64", "arm64"} platforms {"x86", "x64", "arm64"}
end end
@ -57,10 +55,6 @@ filter "platforms:x64"
architecture "x86_64" architecture "x86_64"
filter {} filter {}
filter "platforms:amd64"
architecture "x86_64"
filter {}
filter "platforms:arm64" filter "platforms:arm64"
architecture "ARM64" architecture "ARM64"
filter {} filter {}
@ -83,16 +77,14 @@ if os.istarget("linux") then
filter {} filter {}
filter { "toolset:clang*" } filter { "toolset:clang*" }
buildoptions "-stdlib=libc++"
linkoptions "-stdlib=libc++"
-- always try to use lld. LD or Gold will not work -- always try to use lld. LD or Gold will not work
linkoptions "-fuse-ld=lld" linkoptions "-fuse-ld=lld"
filter {} filter {}
end end
filter { "system:macosx", "platforms:amd64" }
buildoptions "-arch x86_64"
linkoptions "-arch x86_64"
filter {}
filter { "system:macosx", "platforms:arm64" } filter { "system:macosx", "platforms:arm64" }
buildoptions "-arch arm64" buildoptions "-arch arm64"
linkoptions "-arch arm64" linkoptions "-arch arm64"
@ -107,7 +99,7 @@ flags {"NoIncrementalLink", "NoMinimalRebuild", "MultiProcessorCompile", "No64Bi
filter "configurations:release" filter "configurations:release"
optimize "Size" optimize "Size"
defines "NDEBUG" defines "NDEBUG"
fatalwarnings {"All"} flags "FatalCompileWarnings"
filter {} filter {}
filter "configurations:debug" filter "configurations:debug"

View File

@ -65,7 +65,11 @@ namespace console
{ {
static thread_local char buffer[0x1000]; static thread_local char buffer[0x1000];
#ifdef _WIN32
const int count = vsnprintf_s(buffer, _TRUNCATE, message, *ap);
#else
const int count = vsnprintf(buffer, sizeof(buffer), message, *ap); const int count = vsnprintf(buffer, sizeof(buffer), message, *ap);
#endif
if (count < 0) return {}; if (count < 0) return {};
return {buffer, static_cast<size_t>(count)}; return {buffer, static_cast<size_t>(count)};

View File

@ -39,7 +39,7 @@ int main(const int argc, const char** argv)
} }
catch (std::exception& e) catch (std::exception& e)
{ {
console::error("Fatal error: %s", e.what()); console::error("Fatal error: %s\n", e.what());
return -1; return -1;
} }

View File

@ -41,12 +41,10 @@ namespace
const auto location = utils::env::get_value("AW_STATS_LOCATION"); const auto location = utils::env::get_value("AW_STATS_LOCATION");
if (location.empty()) if (location.empty())
{ {
console::error("The environment variable 'AW_STATS_LOCATION' is not set. Please set 'AW_STATS_LOCATION' to specify the save location for 'stats.json'"); console::error("The environment variable 'AW_STATS_LOCATION' is not set. Please set 'AW_STATS_LOCATION' to specify the save location for 'stats.json'\n");
return; return;
} }
console::info("Writing stats to %s", location.c_str());
utils::io::write_file(location, root_data); utils::io::write_file(location, root_data);
} }
} }

View File

@ -29,7 +29,11 @@ namespace utils::string
while (true) while (true)
{ {
#ifdef _WIN32
const auto res = vsnprintf_s(entry->buffer_, entry->size_, _TRUNCATE, format, ap);
#else
const auto res = vsnprintf(entry->buffer_, entry->size_, format, ap); const auto res = vsnprintf(entry->buffer_, entry->size_, format, ap);
#endif
if (res > 0) break; // Success if (res > 0) break; // Success
if (res == 0) return nullptr; // Error if (res == 0) return nullptr; // Error