Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0d454ae9b | ||
|
|
96a75df218 | ||
|
|
1a732f577f |
No files matched your search
@@ -1,4 +0,0 @@
|
||||
# Files that a Linux shell runs directly must keep LF line endings in a
|
||||
# Windows checkout (core.autocrlf): a CRLF shebang line does not start.
|
||||
*.sh text eol=lf
|
||||
port/android/gradlew text eol=lf
|
||||
@@ -1,38 +0,0 @@
|
||||
name: Problem report
|
||||
description: Something does not work as it should
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for reporting! Please do **not** ask for, link to or attach game files or disc images; such issues are closed and deleted.
|
||||
- type: dropdown
|
||||
id: headset
|
||||
attributes:
|
||||
label: Headset
|
||||
options:
|
||||
- Meta Quest 3
|
||||
- Meta Quest 3S
|
||||
- Steam Frame
|
||||
- Other
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: build
|
||||
attributes:
|
||||
label: Build number
|
||||
description: The release you installed, e.g. "build 180".
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: what
|
||||
attributes:
|
||||
label: What happened
|
||||
description: What you did, what you expected and what happened instead.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: log
|
||||
attributes:
|
||||
label: Log
|
||||
description: |
|
||||
Attach `debug.txt`. Quest: `Android/data/io.github.cesarus85.ringfall/files/debug.txt` (SideQuest's file manager). Steam Frame: `Documents/RingfallMjolnirVR/debug.txt`, and `logcat.txt` and `install.log` beside it.
|
||||
@@ -1,5 +0,0 @@
|
||||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: How to install
|
||||
url: https://github.com/Cesarus85/mjolnir-vr#install-on-meta-quest-3--3s
|
||||
about: Step-by-step installation for the Quest 3 / 3S and the Steam Frame.
|
||||
@@ -1,41 +1,29 @@
|
||||
name: Build
|
||||
|
||||
# Debug and release builds of the native ports (Linux, Windows, Android) and
|
||||
# the web port for every pushed commit, uploaded as artifacts.
|
||||
# tools/ci_build.py does each build; see it for the options.
|
||||
# Debug and release builds of the native ports (Linux, Windows, Android) for
|
||||
# every pushed commit, uploaded as artifacts. tools/ci_build.py does each
|
||||
# build; see it for the options.
|
||||
#
|
||||
# Kept cheap:
|
||||
# - one job per platform builds both configurations, so its set-up (tools,
|
||||
# downloads, caches) is paid once;
|
||||
# - compiles go through ccache, whose cache carries over from run to run, so
|
||||
# a commit only recompiles what it changed; downloads (SDL, musl, Gradle,
|
||||
# the Linux build's system root) are cached too;
|
||||
# a commit only recompiles what it changed; downloads (SDL, musl, Gradle)
|
||||
# are cached too;
|
||||
# - a newer push to the same branch cancels a run still going;
|
||||
# - pushes that only change documentation do not build;
|
||||
# - Windows, whose minutes cost twice Linux's, builds only Windows;
|
||||
# - Mjolnir VR builds only Android (the VR app): the Linux and
|
||||
# Windows jobs are kept, off (if: false), so that upstream's changes to
|
||||
# them still merge;
|
||||
# - artifacts are kept for three days.
|
||||
#
|
||||
# A successful build of main is also published as a GitHub release, the
|
||||
# newest marked latest, so that
|
||||
# https://github.com/<repository>/releases/latest/download/<file> always
|
||||
# gives the latest build; the last five are kept. Its web build is then the
|
||||
# site on GitHub Pages (https://halocombatevolved.com/, port/web/README.md).
|
||||
# gives the latest build; the last five are kept.
|
||||
on:
|
||||
# (Mjolnir VR: main only; its branches are tried on the headsets
|
||||
# from local builds)
|
||||
push:
|
||||
branches: [main]
|
||||
paths-ignore:
|
||||
- "**.md"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
profile:
|
||||
description: "Also build the profiling flavour (configure.py --profile) on Linux"
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
concurrency:
|
||||
group: build-${{ github.ref }}
|
||||
@@ -52,14 +40,8 @@ env:
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
# (off: Mjolnir VR ships the Android app only)
|
||||
if: ${{ false }}
|
||||
# Arch Linux has what the build needs as packages: clang 22 (for the
|
||||
# profile-guided optimisation in pgo/), and CMake, pkg-config and
|
||||
# wayland-scanner for the SDL 3 that the portable build brings. The build
|
||||
# links against Debian 11's 32-bit glibc (tools/linux_sysroot.py), not
|
||||
# Arch's, so that it starts on SteamOS and older distributions; Arch's
|
||||
# 32-bit glibc is for the tests.
|
||||
# profile-guided optimisation in pgo/) and 32-bit SDL 3.
|
||||
runs-on: ubuntu-24.04
|
||||
container: archlinux:latest
|
||||
timeout-minutes: 40
|
||||
@@ -68,7 +50,7 @@ jobs:
|
||||
run: |
|
||||
printf '\n[multilib]\nInclude = /etc/pacman.d/mirrorlist\n' >> /etc/pacman.conf
|
||||
pacman -Syu --noconfirm --needed git zstd python python-pytest ninja ccache \
|
||||
clang lld gcc lib32-glibc lib32-gcc-libs cmake pkgconf wayland
|
||||
clang lld gcc lib32-glibc lib32-gcc-libs lib32-sdl3
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -78,29 +60,14 @@ jobs:
|
||||
key: ccache-linux-${{ github.sha }}
|
||||
restore-keys: ccache-linux-
|
||||
|
||||
# the system root and SDL's source, which the build downloads
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: build/linux/third_party
|
||||
key: linux-third-party-${{ hashFiles('tools/linux_sysroot.py') }}
|
||||
|
||||
- name: Debug
|
||||
run: python tools/ci_build.py linux debug
|
||||
|
||||
# (the profiling build, configure.py --profile, which no other step
|
||||
# compiles: only when a run started by hand asks for it, as it costs a
|
||||
# build of its own)
|
||||
- name: Profile
|
||||
if: github.event_name == 'workflow_dispatch' && inputs.profile
|
||||
run: python tools/ci_build.py linux profile
|
||||
|
||||
- name: Release
|
||||
run: python tools/ci_build.py linux release
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
python -m pytest -q tools/test_linux_port.py tools/test_android_asm_convert.py tools/test_android_mirror_uploads.py tools/test_android_ce_texture_cache.py tools/test_host_watch_hash.py tools/test_touch_menu.py tools/harness tools/test_profile.py tools/stagekit/tests tools/test_net_compare.py
|
||||
python tools/test_light_storage.py
|
||||
run: python -m pytest -q tools/test_linux_port.py
|
||||
|
||||
- name: Compile cache
|
||||
run: ccache --show-stats
|
||||
@@ -125,15 +92,10 @@ jobs:
|
||||
- name: Install the toolchain
|
||||
run: |
|
||||
mkdir -p "$RUNNER_TEMP/tools"
|
||||
# (each download checked against the hash it had when it was pinned)
|
||||
curl -fsSL -o ninja.zip https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip
|
||||
curl -fsSL -o ccache.tar.xz https://github.com/ccache/ccache/releases/download/v4.10.2/ccache-4.10.2-linux-x86_64.tar.xz
|
||||
sha256sum -c - <<'EOF'
|
||||
6f98805688d19672bd699fbbfa2c2cf0fc054ac3df1f0e6a47664d963d530255 ninja.zip
|
||||
80cab87bd510eca796467aee8e663c398239e0df1c4800a0b5dff11dca0b4f18 ccache.tar.xz
|
||||
EOF
|
||||
unzip -q ninja.zip -d "$RUNNER_TEMP/tools" && rm ninja.zip
|
||||
tar -xJf ccache.tar.xz -C "$RUNNER_TEMP/tools" --strip-components=1 ccache-4.10.2-linux-x86_64/ccache && rm ccache.tar.xz
|
||||
curl -fsSL https://github.com/ccache/ccache/releases/download/v4.10.2/ccache-4.10.2-linux-x86_64.tar.xz \
|
||||
| tar -xJ -C "$RUNNER_TEMP/tools" --strip-components=1 ccache-4.10.2-linux-x86_64/ccache
|
||||
echo "$RUNNER_TEMP/tools" >> "$GITHUB_PATH"
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
@@ -148,7 +110,7 @@ jobs:
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: build/android/third_party
|
||||
key: android-third-party-${{ hashFiles('tools/android_build.py', 'port/android/patches/**') }}
|
||||
key: android-third-party-${{ hashFiles('tools/android_build.py') }}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
@@ -183,10 +145,6 @@ jobs:
|
||||
HALO_ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
|
||||
run: python3 tools/ci_build.py android release
|
||||
|
||||
# the touch controls' layout and gyroscope maths (the runner's JDK)
|
||||
- name: Test the touch layout
|
||||
run: python3 tools/test_touch_layout.py
|
||||
|
||||
- name: Compile cache
|
||||
run: ccache --show-stats
|
||||
|
||||
@@ -203,8 +161,6 @@ jobs:
|
||||
retention-days: 3
|
||||
|
||||
windows:
|
||||
# (off: Mjolnir VR ships the Android app only)
|
||||
if: ${{ false }}
|
||||
# The runner image has LLVM, Python and Visual Studio's x86 libraries and
|
||||
# Windows SDK.
|
||||
runs-on: windows-2025
|
||||
@@ -217,11 +173,8 @@ jobs:
|
||||
shell: pwsh
|
||||
run: |
|
||||
Invoke-WebRequest -OutFile ninja.zip https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-win.zip
|
||||
Invoke-WebRequest -OutFile ccache.zip https://github.com/ccache/ccache/releases/download/v4.10.2/ccache-4.10.2-windows-x86_64.zip
|
||||
# (each download checked against the hash it had when it was pinned)
|
||||
if ((Get-FileHash ninja.zip -Algorithm SHA256).Hash -ne "F550FEC705B6D6FF58F2DB3C374C2277A37691678D6ABA463ADCBB129108467A") { throw "ninja.zip: unexpected SHA-256" }
|
||||
if ((Get-FileHash ccache.zip -Algorithm SHA256).Hash -ne "6252F081876A9A9F700FAE13A5AEC5D0D486B28261D7F1F72AC11C7AD9DF4DA9") { throw "ccache.zip: unexpected SHA-256" }
|
||||
Expand-Archive ninja.zip -DestinationPath "$env:RUNNER_TEMP\tools"
|
||||
Invoke-WebRequest -OutFile ccache.zip https://github.com/ccache/ccache/releases/download/v4.10.2/ccache-4.10.2-windows-x86_64.zip
|
||||
Expand-Archive ccache.zip -DestinationPath $env:RUNNER_TEMP
|
||||
Copy-Item "$env:RUNNER_TEMP\ccache-4.10.2-windows-x86_64\ccache.exe" "$env:RUNNER_TEMP\tools"
|
||||
Remove-Item ninja.zip, ccache.zip
|
||||
@@ -247,9 +200,6 @@ jobs:
|
||||
- name: Release
|
||||
run: python tools/ci_build.py windows release
|
||||
|
||||
- name: Test light storage
|
||||
run: python tools/test_light_storage.py
|
||||
|
||||
- name: Compile cache
|
||||
run: ccache --show-stats
|
||||
|
||||
@@ -265,105 +215,12 @@ jobs:
|
||||
path: dist/halo-windows-release
|
||||
retention-days: 3
|
||||
|
||||
# the PDBs, for crash reports' backtraces (tools/ci_build.py)
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: halo-windows-debug-symbols
|
||||
path: dist/halo-windows-debug-symbols
|
||||
retention-days: 3
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: halo-windows-release-symbols
|
||||
path: dist/halo-windows-release-symbols
|
||||
retention-days: 3
|
||||
|
||||
web:
|
||||
# (off: Mjolnir VR ships the Android app only)
|
||||
if: ${{ false }}
|
||||
# Emscripten (emsdk, the version below, cached) builds the web port's
|
||||
# site (port/web/README.md); the tests check its graph, the page's
|
||||
# importer and service worker, its sockets, that it starts in a
|
||||
# headless Chromium (with no game data, as far as the menus' map), and
|
||||
# that two browsers join a room through a local MQTT broker.
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 40
|
||||
env:
|
||||
EMSDK_VERSION: 6.0.10
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/emsdk
|
||||
key: emsdk-${{ env.EMSDK_VERSION }}-${{ hashFiles('port/web/halo_sdl3.py') }}
|
||||
|
||||
- name: Install the toolchain
|
||||
run: |
|
||||
if [ ! -x ~/emsdk/upstream/emscripten/emcc ]; then
|
||||
rm -rf ~/emsdk
|
||||
git clone --depth 1 https://github.com/emscripten-core/emsdk.git ~/emsdk
|
||||
~/emsdk/emsdk install "$EMSDK_VERSION"
|
||||
fi
|
||||
~/emsdk/emsdk activate "$EMSDK_VERSION"
|
||||
sudo apt-get update -q
|
||||
sudo apt-get install -y -q ninja-build ccache python3-pytest mosquitto
|
||||
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: .ccache
|
||||
key: ccache-web-${{ github.sha }}
|
||||
restore-keys: ccache-web-
|
||||
|
||||
- name: Debug
|
||||
run: |
|
||||
source ~/emsdk/emsdk_env.sh
|
||||
python3 tools/ci_build.py web debug
|
||||
|
||||
- name: Release
|
||||
run: |
|
||||
source ~/emsdk/emsdk_env.sh
|
||||
python3 tools/ci_build.py web release
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
source ~/emsdk/emsdk_env.sh
|
||||
node --test "port/web/tests/*.test.js"
|
||||
python3 -m pytest -q tools/test_web_build.py
|
||||
|
||||
- name: Test in Chromium and Firefox
|
||||
run: |
|
||||
npm install --no-save --prefix "$RUNNER_TEMP/playwright" playwright@1.58
|
||||
"$RUNNER_TEMP/playwright/node_modules/.bin/playwright" install --with-deps chromium firefox
|
||||
NODE_PATH="$RUNNER_TEMP/playwright/node_modules" node port/web/tests/smoke.mjs dist/halo-web-release
|
||||
NODE_PATH="$RUNNER_TEMP/playwright/node_modules" node port/web/tests/rooms.mjs dist/halo-web-release
|
||||
# (the native builds' WebRTC, port/linux/src/p2p_webrtc.c, with both)
|
||||
NODE_PATH="$RUNNER_TEMP/playwright/node_modules" node port/web/tests/webrtc_native.mjs chromium firefox
|
||||
|
||||
- name: Compile cache
|
||||
run: ccache --show-stats
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: halo-web-debug
|
||||
path: dist/halo-web-debug
|
||||
include-hidden-files: true
|
||||
retention-days: 3
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: halo-web-release
|
||||
path: dist/halo-web-release
|
||||
include-hidden-files: true
|
||||
retention-days: 3
|
||||
|
||||
release:
|
||||
# The eight builds (and the Windows builds' PDBs) as a release, tagged
|
||||
# build-<run number> and marked latest
|
||||
# The six builds as a release, tagged build-<run number> and marked latest
|
||||
# (every file keeps its name from release to release, for the README's
|
||||
# latest/download links); then all but the newest five build-* releases
|
||||
# go, tags and all. Only for main, and only when every platform built.
|
||||
needs: [android]
|
||||
needs: [linux, android, windows]
|
||||
if: ${{ github.ref == 'refs/heads/main' }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 15
|
||||
@@ -375,12 +232,6 @@ jobs:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: |
|
||||
port/android
|
||||
tools
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: halo-*
|
||||
@@ -389,26 +240,13 @@ jobs:
|
||||
- name: Package
|
||||
run: |
|
||||
mkdir release
|
||||
# (Mjolnir VR publishes its Android builds only, under
|
||||
# its own name: Updater.java looks for them; the desktop ports are
|
||||
# built to keep them building)
|
||||
for config in debug release; do
|
||||
(cd "artifacts/halo-android-$config" &&
|
||||
zip -qr "$GITHUB_WORKSPACE/release/mjolnir-vr-android-$config.zip" .)
|
||||
for build in artifacts/*/; do
|
||||
name="$(basename "$build")"
|
||||
# stored, not deflated: the updater in builds up to 57 waits for
|
||||
# an end of stream the game's zlib 1.1 does not always report,
|
||||
# and fails on a deflated entry that unpacked correctly
|
||||
(cd "$build" && zip -0 -qr "$GITHUB_WORKSPACE/release/$name.zip" .)
|
||||
done
|
||||
# the Steam Frame's installer (port/android/STEAM_FRAME.md): its
|
||||
# bundle with the release APK, and the desktop file that fetches it
|
||||
python3 tools/steam_frame_bundle.py artifacts/halo-android-release/app-release.apk release "$GH_REPO"
|
||||
# the APK itself, for sideloading on the Quest (SideQuest, adb)
|
||||
cp artifacts/halo-android-release/app-release.apk release/MjolnirVR.apk
|
||||
# the same under the names before "Mjolnir VR" (Ringfall: Mjolnir
|
||||
# VR, builds 302 to 313): their updaters (Updater.java, the Frame's
|
||||
# launcher) and the links already shared ask for them
|
||||
cp release/mjolnir-vr-android-debug.zip release/ringfall-mjolnir-vr-android-debug.zip
|
||||
cp release/mjolnir-vr-android-release.zip release/ringfall-mjolnir-vr-android-release.zip
|
||||
cp release/mjolnir-vr-steam-frame.zip release/ringfall-mjolnir-vr-steam-frame.zip
|
||||
cp release/Install-Mjolnir-VR.desktop release/Install-Ringfall-Mjolnir-VR.desktop
|
||||
cp release/MjolnirVR.apk release/RingfallMjolnirVR.apk
|
||||
ls -l release
|
||||
|
||||
- name: Publish
|
||||
@@ -420,50 +258,12 @@ jobs:
|
||||
run: |
|
||||
tag="build-$GITHUB_RUN_NUMBER"
|
||||
subject="$(printf '%s' "${MESSAGE:-manual run}" | head -n 1)"
|
||||
readme="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
|
||||
{
|
||||
printf '%s\n\n' "$subject"
|
||||
printf '**Mjolnir VR** is an unofficial VR mod for Halo: Combat Evolved. It needs a disc image of your own, purchased Xbox copy of the game; no game files are included.\n\n'
|
||||
printf '| Headset | Download | How to install |\n| --- | --- | --- |\n'
|
||||
printf '| Meta Quest 3 / 3S | `MjolnirVR.apk` | [Install on Quest](%s#install-on-meta-quest-3--3s) |\n' "$readme"
|
||||
printf '| Steam Frame | `Install-Mjolnir-VR.desktop` (open it in Desktop Mode) | [Install on Steam Frame](%s#install-on-steam-frame) |\n\n' "$readme"
|
||||
printf 'The other files are for the built-in updater and the Steam Frame installer (those named `ringfall-…` / `Ringfall…`: the same, for the builds before the name Mjolnir VR).\n\n'
|
||||
printf 'Commit: %s\nBuild: %s\n' "$COMMIT_URL" "$RUN_URL"
|
||||
} > notes.md
|
||||
gh release create "$tag" release/* --target "$GITHUB_SHA" --latest \
|
||||
--title "Mjolnir VR, build $GITHUB_RUN_NUMBER (${GITHUB_SHA:0:7})" --notes-file notes.md
|
||||
printf '%s\n\nCommit: %s\nBuild: %s\n\nThe release builds are for playing; the debug builds stop at the first failed assertion and log it.\n' \
|
||||
"$subject" "$COMMIT_URL" "$RUN_URL" > notes.md
|
||||
gh release create "$tag" release/*.zip --target "$GITHUB_SHA" --latest \
|
||||
--title "Build $GITHUB_RUN_NUMBER (${GITHUB_SHA:0:7})" --notes-file notes.md
|
||||
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# The Windows builds' executables and PDBs to Sentry, which turns the
|
||||
# crash reports of these builds (port/windows/src/win32_crash.c) into
|
||||
# backtraces with function names and lines. Needs the SENTRY_AUTH_TOKEN
|
||||
# secret: an organization auth token of the Sentry organization, which
|
||||
# names the organization and its region itself. The SENTRY_PROJECT
|
||||
# variable can name the project (its slug), else the id in the DSN of
|
||||
# win32_crash.c; SENTRY_ORG and SENTRY_URL (https://de.sentry.io) are
|
||||
# for a personal token instead. A failed upload does not stop the
|
||||
# release.
|
||||
- name: Upload Windows symbols to Sentry
|
||||
continue-on-error: true
|
||||
env:
|
||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT || '4512207917744208' }}
|
||||
ORG: ${{ vars.SENTRY_ORG }}
|
||||
URL: ${{ vars.SENTRY_URL }}
|
||||
SENTRY_CLI_VERSION: 2.46.0
|
||||
run: |
|
||||
if [ -z "$SENTRY_AUTH_TOKEN" ]; then
|
||||
echo "::warning::no SENTRY_AUTH_TOKEN secret: crash reports of this build will have no function names"
|
||||
exit 0
|
||||
fi
|
||||
if [ -n "$ORG" ]; then export SENTRY_ORG="$ORG"; fi
|
||||
if [ -n "$URL" ]; then export SENTRY_URL="$URL"; fi
|
||||
curl -fsSL -o sentry-cli "https://github.com/getsentry/sentry-cli/releases/download/$SENTRY_CLI_VERSION/sentry-cli-Linux-x86_64"
|
||||
chmod +x sentry-cli
|
||||
./sentry-cli debug-files upload --wait \
|
||||
artifacts/halo-windows-release artifacts/halo-windows-release-symbols \
|
||||
artifacts/halo-windows-debug artifacts/halo-windows-debug-symbols
|
||||
|
||||
- name: Keep the last five
|
||||
run: |
|
||||
gh release list --limit 100 --json tagName,createdAt \
|
||||
@@ -472,87 +272,12 @@ jobs:
|
||||
gh release delete "$tag" --cleanup-tag --yes
|
||||
done
|
||||
|
||||
pages:
|
||||
# (off: Mjolnir VR ships the Android app only)
|
||||
if: ${{ false }}
|
||||
# The release's web build to GitHub Pages, which serves it at
|
||||
# https://halocombatevolved.com/ (port/web/README.md, "Hosting"). Only
|
||||
# main, only once every platform built and the release is out (the site
|
||||
# and the release are one build), and a deployment is never cancelled
|
||||
# halfway. The repository's Pages source must be GitHub Actions.
|
||||
needs: [release]
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
permissions:
|
||||
contents: write
|
||||
pages: write
|
||||
id-token: write
|
||||
concurrency:
|
||||
group: pages
|
||||
cancel-in-progress: false
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deploy.outputs.page_url }}
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: halo-web-release
|
||||
path: site
|
||||
|
||||
# The game's wasm, most of a build, from jsDelivr rather than GitHub
|
||||
# Pages, which serves 100 GB a month: the wasm alone in a commit of the
|
||||
# web-wasm branch (pushed over the last, so the repository keeps one),
|
||||
# which jsDelivr serves by its hash (with CORS; GitHub's release
|
||||
# downloads have none, so a page cannot fetch them), and version.json
|
||||
# names that copy and its SHA-256. The site's service worker takes the
|
||||
# wasm from there, checked, and from the site only when it cannot
|
||||
# (port/web/site/sw.js). A failure here leaves the site serving it.
|
||||
- name: The wasm on jsDelivr
|
||||
continue-on-error: true
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
sha256="$(sha256sum site/halo.wasm | cut -d' ' -f1)"
|
||||
mkdir wasm
|
||||
cp site/halo.wasm wasm/
|
||||
cd wasm
|
||||
git init -q -b web-wasm
|
||||
git -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
|
||||
add halo.wasm
|
||||
git -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
|
||||
commit -q -m "The web build's wasm (build $GITHUB_RUN_NUMBER, $GITHUB_SHA)"
|
||||
git push -q --force "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:refs/heads/web-wasm
|
||||
url="https://cdn.jsdelivr.net/gh/${GITHUB_REPOSITORY}@$(git rev-parse HEAD)/halo.wasm"
|
||||
# (jsDelivr fetches it now, and it must be the same file: it serves
|
||||
# files of at most 20 MB from GitHub)
|
||||
curl -fsSL --retry 6 --retry-delay 10 --retry-all-errors -o served.wasm "$url"
|
||||
echo "$sha256 served.wasm" | sha256sum -c -
|
||||
cd ..
|
||||
python3 - "$url" "$sha256" <<'EOF'
|
||||
import json, sys
|
||||
with open("site/version.json") as file:
|
||||
stamp = json.load(file)
|
||||
stamp["wasm"] = {"url": sys.argv[1], "sha256": sys.argv[2]}
|
||||
with open("site/version.json", "w") as file:
|
||||
json.dump(stamp, file, indent=1)
|
||||
EOF
|
||||
echo "the wasm from $url"
|
||||
|
||||
- uses: actions/configure-pages@v5
|
||||
|
||||
- uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: site
|
||||
|
||||
- id: deploy
|
||||
uses: actions/deploy-pages@v4
|
||||
|
||||
notify:
|
||||
# A Discord embed for the run, to the DISCORD_WEBHOOK secret (nothing
|
||||
# without it): green when every platform built, red when one did not,
|
||||
# with each platform's result, this run's release (main only), and links
|
||||
# to the latest release's builds.
|
||||
needs: [android, release]
|
||||
needs: [linux, android, windows, release]
|
||||
if: ${{ !cancelled() }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 5
|
||||
@@ -563,9 +288,6 @@ jobs:
|
||||
LINUX: ${{ needs.linux.result }}
|
||||
ANDROID: ${{ needs.android.result }}
|
||||
WINDOWS: ${{ needs.windows.result }}
|
||||
WEB: ${{ needs.web.result }}
|
||||
PAGES: ${{ needs.pages.result }}
|
||||
SITE_URL: https://halocombatevolved.com/
|
||||
RELEASE_TAG: ${{ needs.release.outputs.tag }}
|
||||
SERVER: ${{ github.server_url }}
|
||||
REPOSITORY: ${{ github.repository }}
|
||||
@@ -588,18 +310,15 @@ jobs:
|
||||
*) echo "➖ Skipped" ;;
|
||||
esac
|
||||
}
|
||||
if [ "$ANDROID" = success ]; then
|
||||
if [ "$LINUX" = success ] && [ "$ANDROID" = success ] && [ "$WINDOWS" = success ]; then
|
||||
title="Build succeeded"; color=5763719
|
||||
else
|
||||
title="Build failed"; color=15548997
|
||||
fi
|
||||
latest="$SERVER/$REPOSITORY/releases/latest"
|
||||
downloads="[Quest]($latest/download/mjolnir-vr-android-release.zip) · [Steam Frame]($latest/download/Install-Mjolnir-VR.desktop) ([all builds]($latest))"
|
||||
downloads="[Linux]($latest/download/halo-linux-release.zip) · [Windows]($latest/download/halo-windows-release.zip) · [Android]($latest/download/halo-android-release.zip) ([all builds]($latest))"
|
||||
if [ -n "$RELEASE_TAG" ]; then
|
||||
release="[$RELEASE_TAG]($SERVER/$REPOSITORY/releases/tag/$RELEASE_TAG)"
|
||||
if [ "$PAGES" = success ]; then
|
||||
release="$release, on [the site]($SITE_URL)"
|
||||
fi
|
||||
else
|
||||
release="None (only a successful build of main makes one)"
|
||||
fi
|
||||
@@ -609,7 +328,6 @@ jobs:
|
||||
--arg description "[\`${SHA:0:7}\`]($COMMIT_URL) $subject — $ACTOR ($BRANCH)" \
|
||||
--arg release "$release" --arg downloads "$downloads" \
|
||||
--arg linux "$(status "$LINUX")" --arg windows "$(status "$WINDOWS")" --arg android "$(status "$ANDROID")" \
|
||||
--arg web "$(status "$WEB")" \
|
||||
--arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
||||
'{embeds: [{
|
||||
title: $title, url: $url, color: $color, description: $description, timestamp: $timestamp,
|
||||
@@ -617,7 +335,6 @@ jobs:
|
||||
{name: "Linux", value: $linux, inline: true},
|
||||
{name: "Windows", value: $windows, inline: true},
|
||||
{name: "Android", value: $android, inline: true},
|
||||
{name: "Web", value: $web, inline: true},
|
||||
{name: "Release", value: $release},
|
||||
{name: "Latest release builds", value: $downloads}
|
||||
]
|
||||
|
||||
@@ -1,199 +0,0 @@
|
||||
name: Server image
|
||||
|
||||
# The dedicated server's container image (deploy/docker), made from a
|
||||
# release's halo-linux-release.zip, and the Helm chart's checks
|
||||
# (deploy/helm/opence-server).
|
||||
#
|
||||
# - After each successful Build of main (which publishes release build-<n>):
|
||||
# the image of that release, checked, pushed to
|
||||
# ghcr.io/opencommunityedition/opence-server as sha-<commit>, build-<n> and
|
||||
# latest, and signed keyless with cosign (this workflow's GitHub identity).
|
||||
# - Weekly, the latest release's image again, for Debian's fixes.
|
||||
# - By hand, any release's (latest moves only for the newest).
|
||||
#
|
||||
# The checks (no game data in CI: it is never published): the image runs as
|
||||
# 10001:10001; started on a read-only root without maps it writes its
|
||||
# settings to /state, says "server: no usable maps" and exits 2; halo
|
||||
# --version answers; the health check fails with nothing listening.
|
||||
#
|
||||
# Verify:
|
||||
# cosign verify ghcr.io/opencommunityedition/opence-server:latest \
|
||||
# --certificate-identity-regexp '^https://github\.com/OpenCommunityEdition/OpenCE/\.github/workflows/server-image\.yml@' \
|
||||
# --certificate-oidc-issuer https://token.actions.githubusercontent.com
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [Build]
|
||||
types: [completed]
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: "23 5 * * 1"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release:
|
||||
description: "The release to build the image of: a tag (build-206) or latest"
|
||||
default: latest
|
||||
|
||||
concurrency:
|
||||
group: server-image-${{ github.event_name }}-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
IMAGE: ghcr.io/opencommunityedition/opence-server
|
||||
|
||||
jobs:
|
||||
chart:
|
||||
# (off: Mjolnir VR ships no dedicated server image)
|
||||
if: ${{ false }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
|
||||
|
||||
- uses: azure/setup-helm@v4
|
||||
|
||||
- name: Lint
|
||||
run: |
|
||||
set -euo pipefail
|
||||
chart=deploy/helm/opence-server
|
||||
for values in "$chart"/ci/*-values.yaml; do
|
||||
helm lint "$chart" --strict -f "$values"
|
||||
helm template ci "$chart" -f "$values" > /dev/null
|
||||
done
|
||||
# the maps are never in the image: without game data the chart refuses to render
|
||||
if helm template ci "$chart" > /dev/null 2>&1; then
|
||||
echo "::error::the chart renders without gameData"; exit 1
|
||||
fi
|
||||
|
||||
- name: Unit tests
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# (Helm 4 checks plugins' signatures, which helm-unittest does not publish)
|
||||
if helm version --short | grep -q '^v3'; then verify=; else verify=--verify=false; fi
|
||||
helm plugin install https://github.com/helm-unittest/helm-unittest $verify
|
||||
helm unittest deploy/helm/opence-server
|
||||
|
||||
image:
|
||||
# (off: Mjolnir VR ships no dedicated server image)
|
||||
if: ${{ false }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 20
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
# keyless signing: the workflow's OIDC token gets a short-lived Sigstore certificate
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
|
||||
|
||||
- name: Release
|
||||
id: release
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
EVENT: ${{ github.event_name }}
|
||||
RUN_NUMBER: ${{ github.event.workflow_run.run_number }}
|
||||
WANTED: ${{ inputs.release }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
case "$EVENT" in
|
||||
workflow_run) tag="build-$RUN_NUMBER" ;;
|
||||
workflow_dispatch) tag="${WANTED:-latest}" ;;
|
||||
*) tag=latest ;;
|
||||
esac
|
||||
newest="$(gh release view --repo "$GITHUB_REPOSITORY" --json tagName -q .tagName)"
|
||||
if [ "$tag" = latest ]; then
|
||||
tag="$newest"
|
||||
fi
|
||||
commit="$(gh release view "$tag" --repo "$GITHUB_REPOSITORY" --json targetCommitish -q .targetCommitish)"
|
||||
gh release download "$tag" --repo "$GITHUB_REPOSITORY" --pattern halo-linux-release.zip --dir deploy/docker
|
||||
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
||||
echo "commit=$commit" >> "$GITHUB_OUTPUT"
|
||||
echo "newest=$([ "$tag" = "$newest" ] && echo true || echo false)" >> "$GITHUB_OUTPUT"
|
||||
echo "Release $tag (commit $commit; the newest: $newest)"
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
TAG: ${{ steps.release.outputs.tag }}
|
||||
COMMIT: ${{ steps.release.outputs.commit }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker build --pull -t opence-server:ci \
|
||||
--build-arg RELEASE=halo-linux-release.zip \
|
||||
--label org.opencontainers.image.source="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \
|
||||
--label org.opencontainers.image.revision="$COMMIT" \
|
||||
--label org.opencontainers.image.version="$TAG" \
|
||||
--label org.opencontainers.image.licenses=AGPL-3.0-or-later \
|
||||
--label org.opencontainers.image.title="OpenCE dedicated server" \
|
||||
deploy/docker
|
||||
|
||||
- name: Smoke test
|
||||
run: |
|
||||
set -euo pipefail
|
||||
[ "$(docker image inspect -f '{{.Config.User}}' opence-server:ci)" = 10001:10001 ] \
|
||||
|| { echo "::error::the image does not run as 10001:10001"; exit 1; }
|
||||
docker run --rm --read-only --entrypoint /opt/opence/halo opence-server:ci --version | tee version.txt
|
||||
grep -Eq '^OpenCE build-[0-9]+ \(network version [0-9]+\)$' version.txt \
|
||||
|| { echo "::error::halo --version did not answer"; exit 1; }
|
||||
# without maps, on a read-only root with /state the one writable folder
|
||||
docker volume create smoke-state > /dev/null
|
||||
status=0
|
||||
timeout 60 docker run --name smoke --read-only --cap-drop ALL --security-opt no-new-privileges \
|
||||
--tmpfs /tmp -v smoke-state:/state -e HALO_SERVER_WEB_PASSWORD=ci-smoke-password \
|
||||
opence-server:ci > server.log 2>&1 || status=$?
|
||||
cat server.log
|
||||
docker rm -f smoke > /dev/null
|
||||
[ "$status" = 2 ] || { echo "::error::the server without maps exited with $status, not 2"; exit 1; }
|
||||
grep -qF 'server: no usable maps' server.log \
|
||||
|| { echo "::error::no 'server: no usable maps' line"; exit 1; }
|
||||
if grep -qF 'server: ready' server.log; then echo "::error::the server said it was ready"; exit 1; fi
|
||||
docker run --rm -v smoke-state:/state --entrypoint /bin/bash opence-server:ci -c 'test -s /state/config.toml' \
|
||||
|| { echo "::error::no /state/config.toml"; exit 1; }
|
||||
# the health check, with nothing listening
|
||||
if docker run --rm --entrypoint /opt/opence/healthz.sh opence-server:ci; then
|
||||
echo "::error::the health check passed with no server"; exit 1
|
||||
fi
|
||||
docker volume rm smoke-state > /dev/null
|
||||
|
||||
- uses: docker/login-action@v3
|
||||
if: github.repository == 'OpenCommunityEdition/OpenCE'
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: sigstore/cosign-installer@v3
|
||||
if: github.repository == 'OpenCommunityEdition/OpenCE'
|
||||
|
||||
- name: Push and sign
|
||||
if: github.repository == 'OpenCommunityEdition/OpenCE'
|
||||
env:
|
||||
TAG: ${{ steps.release.outputs.tag }}
|
||||
COMMIT: ${{ steps.release.outputs.commit }}
|
||||
NEWEST: ${{ steps.release.outputs.newest }}
|
||||
IDENTITY: ^https://github\.com/${{ github.repository }}/\.github/workflows/server-image\.yml@
|
||||
run: |
|
||||
set -euo pipefail
|
||||
tags=("sha-${COMMIT:0:7}" "$TAG")
|
||||
if [ "$NEWEST" = true ]; then
|
||||
tags+=(latest)
|
||||
fi
|
||||
for tag in "${tags[@]}"; do
|
||||
docker tag opence-server:ci "$IMAGE:$tag"
|
||||
docker push "$IMAGE:$tag"
|
||||
done
|
||||
ref="$(docker image inspect -f '{{index .RepoDigests 0}}' "$IMAGE:$TAG")"
|
||||
test -n "$ref"
|
||||
cosign sign --yes "$ref"
|
||||
cosign verify "$ref" --certificate-identity-regexp "$IDENTITY" \
|
||||
--certificate-oidc-issuer https://token.actions.githubusercontent.com > /dev/null
|
||||
{
|
||||
echo "Pushed and signed $ref as ${tags[*]}."
|
||||
echo
|
||||
echo "Verify: cosign verify $IMAGE:$TAG --certificate-identity-regexp '$IDENTITY' --certificate-oidc-issuer https://token.actions.githubusercontent.com"
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
@@ -24,14 +24,7 @@ xbox/
|
||||
|
||||
# Locally extracted proprietary game data (never commit)
|
||||
assets/
|
||||
# (but the high-res assets, drawn for the port: tools/hud_assets.py)
|
||||
!port/assets/
|
||||
original/
|
||||
|
||||
# CI build outputs (tools/ci_build.py)
|
||||
dist/
|
||||
|
||||
# The app signing key's local settings and keys (port/android/app/build.gradle; never commit)
|
||||
port/android/signing.properties
|
||||
*.jks
|
||||
*.keystore
|
||||
@@ -1,251 +0,0 @@
|
||||
# Notes for agents
|
||||
|
||||
This repository ports the Halo: Combat Evolved decompilation (Xbox build
|
||||
01.01.14.2342, `cachebeta.exe`) to Linux, Windows, Android and the web. The game's C
|
||||
sources are the decompilation; the port adds a platform layer that
|
||||
implements the Xbox APIs the game calls, and features the Xbox game did not
|
||||
have (a new netcode, internet play, the PC version's menus, Custom Edition
|
||||
maps, touch controls). The project is published as OpenCE.
|
||||
|
||||
Start with [README.md](README.md). The other documents are listed at the
|
||||
end.
|
||||
|
||||
## Layout
|
||||
|
||||
| Path | Contents |
|
||||
| --- | --- |
|
||||
| `source/` | The game: 466 C files of the decompilation, compiled as they are with few changes (each marked, below) |
|
||||
| `port/linux/src/` | The platform layer the three ports share: Direct3D 8 on OpenGL (`d3d8_gl.c`), DirectSound and XInput on SDL3, files, threads, memory, sockets, settings (`port_config.c`), the mods folder (`port_mods.c`), internet play (`p2p*.c`), the dedicated server's platform side (`server_*.c`: the mode, the log, the rotation's grammar, HTTP, RCON, the master servers' publisher) and the master servers' list (`master_list.c`) |
|
||||
| `port/linux/game/` | The port's game-side code, compiled as the game's sources are: the distributed netcode (`network_*.c`), co-op, OpenCE's gametypes (`game_modes.c`, `infection.c`, `gun_game.c`), map sharing (`map_share*.c`), the menus (`menu_tags.c`, `menu_functions.c`), Custom Edition maps (`custom_edition_*.c`, `cache_file_formats.c`), the tag validator (`tag_validate.c`, `tag_schema_*.c`), mods (`mods.c`, `mod_*.c`), streamer mode's word filter (`text_filter*.c`), the dedicated server's director, commands, gametypes and status (`server_*.c`), touch, FOV and more |
|
||||
| `port/linux/include/` | The port's headers: the limits (`halo_port_limits.h`, with `HALO_PORT_NETWORK_VERSION`), capacities (`halo_port_capacity.h`), the prefix header, `halo_linux_source_fixups.h` (port functions the game's sources call) |
|
||||
| `port/include/xdk/` | Stand-ins for the Xbox SDK's headers (declarations only) |
|
||||
| `port/windows/` | The Windows build's own files (`win32_*.c`, headers) |
|
||||
| `port/android/` | The Android app: the guest runtime, the host library (`host/`), the Java app (`app/`), host imports (`host_imports.list`) |
|
||||
| `port/web/` | The web build: its runtime (`src/`: entry, sockets inside the page, memory watch), the page and its service worker (`site/`), the SDL port, tests |
|
||||
| `port/assets/` | What the builds embed or ship: high-res HUD (`hud/`), fonts, titles, menus (`menus/`), icons, network brokers and master servers, the dedicated server's web page (`server_ui/`) |
|
||||
| `port/third_party/` | Vendored libraries, each with a README naming its upstream, version and checksum |
|
||||
| `port/tools/` | Stand-alone tools (`cache_file_report.c`) |
|
||||
| `tools/` | Build scripts (`linux_build.py`, `windows_build.py`, `android_build.py`, `web_build.py`, `ci_build.py`, `web_serve.py`), generators (`ce_menus.py`, `port_settings.py`, `hud_assets.py`, `title_assets.py`, `embed_assets.py`, `server_ui_embed.py`, `xdk_headers.py`), the dedicated server's protocol simulator and remote console (`server_sim.py`, `opence_rcon.py`), tests, and `stagekit/` (scenarios staged and instrumented on the real engine, no retail assets) |
|
||||
| `docs/` | Longer design notes (`custom_edition_caches.md`, `mods.md`, `dedicated_server.md`, `master_protocol.md`) |
|
||||
| `pgo/` | Profile-guided optimisation profiles |
|
||||
| `deploy/` | Running a dedicated server: systemd, Docker, Pterodactyl, Helm, PufferPanel, MCSManager, example gametypes |
|
||||
| `assets/` | Game data for local runs (gitignored: `maps/`, `custom_maps/`) |
|
||||
| `.github/workflows/` | CI: builds every platform on each push, publishes releases from `main` |
|
||||
|
||||
## Building
|
||||
|
||||
```sh
|
||||
python configure.py # debug build; add --release, --portable, --profile, --pgo=off, --lto=off
|
||||
ninja linux # build/linux/halo
|
||||
ninja android # the Android guest image and native libraries
|
||||
ninja android_apk # the APK (Gradle)
|
||||
ninja web # build/web/site (Emscripten: port/web/README.md)
|
||||
ninja windows # on Windows, or on Linux after configure.py --windows-cross
|
||||
python tools/ci_build.py linux release # what CI builds
|
||||
```
|
||||
|
||||
- `configure.py` writes `build.ninja`; `configure_args` at its top records
|
||||
the options it was run with. Restore them after trying other options.
|
||||
- The Linux and Windows builds are 32-bit x86 with clang, in MSVC's ABI
|
||||
(`-fms-extensions -fshort-wchar -malign-double -fcommon`), C89 (`gnu89`):
|
||||
declarations come before statements.
|
||||
- Every native build compiles without fused multiply-add and with the
|
||||
vendored musl maths (`halo_math.h`), so that every machine of a network
|
||||
game computes the same results. Do not call the system's maths functions.
|
||||
- Android: the game is an ILP32 AArch64 guest (`arm64_32`) in a 64-bit app.
|
||||
Guest code can call only the host imports declared in
|
||||
`port/android/host_imports.list` and `port/android/guest/runtime/guest_host.h`,
|
||||
and only the SDL functions `guest_sdl.c` bridges. Run `ninja android`
|
||||
after changing anything it compiles: `port/linux/src`, `port/linux/game`,
|
||||
`port/android`, `source/`, the build scripts.
|
||||
- Web: the game is `wasm32` (also ILP32), run on a Web Worker; calls must
|
||||
match their callee's type exactly (the link fails on a mismatch), and
|
||||
WebGL 2 is ES 3.0. Run `ninja web` after changing what it compiles (as
|
||||
for Android, and `port/web`). Refer to [port/web/README.md](port/web/README.md).
|
||||
|
||||
### Defines
|
||||
|
||||
| Define | Set by | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `HALO_ANDROID` | Android | The app: its display, input, files and lifecycle |
|
||||
| `HALO_GLES` | Android, web | The OpenGL ES renderer |
|
||||
| `HALO_ARM64_GUEST` | Android | The guest's ABI (ILP32 AArch64) |
|
||||
| `HALO_WEB` | Web | The browser: its frames, storage, sockets and WebGL 2's limits (with `HALO_GLES`, not `HALO_ANDROID`) |
|
||||
| `HALO_WINDOWS` | Windows (`halo_windows_prefix.h`) | The Windows build |
|
||||
| `HALO_RELEASE` | `--release` | No assertions checked |
|
||||
| `HALO_PROFILE` | `--profile` | The profiling build; a normal build must be unchanged by it |
|
||||
|
||||
`HALO_LINUX` and `HALO_CUSTOM_EDITION` are **not** defined by any build:
|
||||
code guarded by them compiles to nothing. Custom Edition support is a
|
||||
setting (`game.custom_edition`), checked at run time with
|
||||
`custom_edition_cache_tags_loaded()`.
|
||||
|
||||
## Testing
|
||||
|
||||
```sh
|
||||
python -m pytest -q tools/harness tools/test_touch_menu.py # the engine's functions in a fake world
|
||||
python -m pytest -q tools/stagekit/tests # scenarios on the real engine, no retail assets (Linux)
|
||||
python -m pytest -q tools/test_linux_port.py # the build, the maps' checks (needs assets/maps)
|
||||
python -m pytest -q tools/test_mods.py # mods played over a map (needs assets/maps)
|
||||
python -m pytest -q tools/test_bots.py # the bots in local games (needs assets/maps)
|
||||
python -m pytest -q tools/test_cache_file_formats.py tools/test_bmp_files.py tools/test_profile.py
|
||||
python tools/test_touch_layout.py # the Android touch layout (JDK 17+)
|
||||
python tools/test_light_storage.py
|
||||
python tools/test_death_timing.py
|
||||
python -m pytest -q tools/test_web_build.py # the web build's graph, sockets, menus
|
||||
node --test "port/web/tests/*.test.js" # the web page's importer and service worker
|
||||
node port/web/tests/webrtc_native.mjs chromium firefox # the native builds' WebRTC with browsers (Playwright)
|
||||
python -m pytest -q tools/test_dedicated_server.py # the dedicated server with clients (needs assets/maps)
|
||||
python -m pytest -q tools/test_server_sim.py tools/test_egg.py # the server's web page and protocol simulator, the egg
|
||||
python -m pytest -q tools/test_net_compare.py # net_compare.py's judging of logs, its copies and their processes
|
||||
python tools/net_compare.py --a build/linux/halo --b <other build> --data <game data> --swap
|
||||
# two builds in one network game, in step (retail maps: local only)
|
||||
```
|
||||
|
||||
`tools/harness/README.md` explains how to add an asset-free test: the code
|
||||
under test is taken from the sources, not copied. `tools/stagekit/README.md`
|
||||
explains how to add a scenario: the real engine, with no retail assets.
|
||||
|
||||
Running the game without a person at it:
|
||||
|
||||
- `debug.network_test` (`HALO_NETWORK_TEST=host:<map>` or `join`) hosts or
|
||||
joins a game without the menus and logs each player's state every second;
|
||||
several copies play on one machine on different loopback addresses
|
||||
(`HALO_NET_ADDRESS`, `HALO_NET_BROADCAST`). `NETCODE.md` describes the
|
||||
test settings.
|
||||
- `halo --server` is a dedicated server (`docs/dedicated_server.md`), and
|
||||
`halo --probe [<invite>]` prints a game's advertisement as JSON and exits;
|
||||
`tools/test_dedicated_server.py` runs both with clients.
|
||||
- `debug.exit_after`, `debug.hidden_window`, `debug.null_renderer`,
|
||||
`debug.menu_open` (start on one menu screen), `debug.telnet_console`.
|
||||
- Use a virtual display (Xvfb, with `SDL_VIDEO_DRIVER=x11`) for windowed
|
||||
runs, never the desktop of the person you work for, and stop only the
|
||||
processes you started.
|
||||
|
||||
## Rules of the project
|
||||
|
||||
### The game's sources
|
||||
|
||||
- Change `source/` as little as possible, and mark each change from the
|
||||
original with a comment that starts `port:`. Write like the surrounding
|
||||
code: its naming, its comment density, and the project's plain,
|
||||
descriptive comment style.
|
||||
- A port function the game's sources call is declared in
|
||||
`halo_linux_source_fixups.h` or included with a note naming its file
|
||||
(`#include "view_fov.h" /* port: port/linux/game/view_fov.c */`).
|
||||
- Notes such as `BUG (original, preserved for exact matching)` mark the
|
||||
original's bugs. Fixing one is allowed; say so in a `port:` comment.
|
||||
|
||||
### The Xbox SDK
|
||||
|
||||
`port/include/xdk` was written without the SDK's headers, from the January
|
||||
build's debug information and public documentation. Never read the SDK's
|
||||
headers or anything derived from them, never copy from them, and do not
|
||||
read `xbox/include`. To add a name, follow `port/include/xdk/README.md`.
|
||||
|
||||
### Networking
|
||||
|
||||
- Raise `HALO_PORT_NETWORK_VERSION` (`port/linux/include/halo_port_limits.h`)
|
||||
with any change to what the machines send each other, or to anything they
|
||||
must agree on, and say why in the commit. Machines of different versions
|
||||
do not play together.
|
||||
- Only the host decides; clients predict their own players. Read
|
||||
`port/linux/NETCODE.md` before changing the netcode.
|
||||
- Internet play is the same code in every build, the web's too: a browser's
|
||||
tunnel is a WebRTC data channel (`port/web/src/web_p2p.c`), which the
|
||||
native builds take on their tunnel's socket (`p2p_webrtc.c`, `posix_dtls.c`).
|
||||
Check a change with both (`port/web/tests/webrtc_native.mjs`, and with the
|
||||
maps `port/web/tests/internet.mjs`).
|
||||
- Anything another machine sends is untrusted: check sizes, indices and
|
||||
rates, as the existing handlers do. `debug.network_corrupt` tests this.
|
||||
|
||||
### Menus
|
||||
|
||||
- The menus must match Halo Custom Edition's. Their XML (`port/assets/menus/ce/`)
|
||||
is generated by `tools/ce_menus.py` from the PC version's tags; the
|
||||
settings screens come from `tools/port_settings.py`. Do not edit the XML
|
||||
by hand: change the generator and run it (the command is in
|
||||
`port/assets/menus/README.md`, "Writing them again"), then check that
|
||||
`git status` shows only the screens meant to change.
|
||||
- Functions the menus call but the port has not wired are listed in
|
||||
`port/assets/menus/UNWIRED.md`.
|
||||
|
||||
### Art and credit
|
||||
|
||||
- Replacement HUD, title and menu art is made of hand-drawn redraws.
|
||||
- Prefer an existing redraw (the ui-svg-handmade set), then a new redraw. A
|
||||
Custom Edition picture that cannot reasonably be redrawn (a 3D render, a
|
||||
screenshot, a logo) may be used only if it is listed in
|
||||
`port/assets/menus/NON_HANDDRAWN.md`.
|
||||
- `AUTHORS.md` credits art only.
|
||||
- Fonts: Overpass and OpenCE (Newtown, respaced) only; see
|
||||
`port/assets/fonts/README.md`. Never ship the maps' commercial typefaces.
|
||||
|
||||
### Custom Edition maps
|
||||
|
||||
Custom Edition maps live in the data root's `custom_maps` folder with
|
||||
`bitmaps.map`, `sounds.map` and `loc.map`; their level names are
|
||||
`custom_maps\<name>`. OpenSauce features are not supported and must not be
|
||||
added: a map that needs them is refused, and one that only carries
|
||||
OpenSauce's header runs as stock Custom Edition runs it. Map files are
|
||||
untrusted input: read them through bounds-checked readers. See
|
||||
`docs/custom_edition_caches.md`.
|
||||
|
||||
### Settings
|
||||
|
||||
A setting is an entry in `port/linux/src/port_config.c`, with a default, an
|
||||
environment variable and a comment that `config.toml` gets. Document it in
|
||||
the settings table of `port/linux/README.md` (and the Android README for an
|
||||
Android-only one). A departure from the stock game's look or behaviour
|
||||
should be a setting, off or stock by default, unless the project decides
|
||||
otherwise.
|
||||
|
||||
### Third-party code and licences
|
||||
|
||||
The repository is `AGPL-3.0-or-later` (`LICENSE`); the commits before the
|
||||
change, and the releases built from them, stay CC0 (`LICENSES/CC0-1.0.txt`).
|
||||
The README's "Licence" section says what each part is under. Vendored code
|
||||
goes in `port/third_party/<name>`, copied unchanged, with a README naming
|
||||
the upstream, the version or commit, the licence, the checksum and what uses
|
||||
it. Its licence must let it be combined with the AGPL 3.0: MIT, BSD (without
|
||||
an advertising clause), ISC, zlib, Apache 2.0, MPL 2.0, LGPL or GPL 3.0 or
|
||||
later, public domain. GPL-2.0-only code and the 4-clause BSD licence cannot
|
||||
be. Code taken from another project, GPL 3.0 code included, keeps its
|
||||
notices and its licence, and says where it came from.
|
||||
The decompilation's upstream, punpckhdq/halo, is AGPL 3.0 from 17 October
|
||||
2026; bnunu/halo-1 is CC0.
|
||||
|
||||
### Commits and pull requests
|
||||
|
||||
- Commit subjects are plain sentences saying what changed; the body says
|
||||
why and what was checked.
|
||||
- A pull request is merged with a merge commit (`Merge pull request #N from
|
||||
<owner>/<branch>`), and follow-up changes go in separate commits whose
|
||||
subject ends with `(#N)`.
|
||||
- A commit taken from a fork keeps its author and is made with
|
||||
`git cherry-pick -x`.
|
||||
|
||||
## Documents
|
||||
|
||||
| Document | About |
|
||||
| --- | --- |
|
||||
| [README.md](README.md) | Downloads, game data, building, build options, profiling builds |
|
||||
| [port/linux/README.md](port/linux/README.md) | The Linux build, controls, menus, every setting, updates, frame rate, field of view, system link, internet play, voice chat, the server browser, map sharing, security, map checks, how the port operates, the game source changes |
|
||||
| [port/linux/NETCODE.md](port/linux/NETCODE.md) | The distributed netcode, network versions, joining a game in progress, map sharing, transport, testing |
|
||||
| [port/windows/README.md](port/windows/README.md) | The Windows build, its headers, inline functions, crash reports |
|
||||
| [port/android/README.md](port/android/README.md) | The Android build, the guest and host, touch controls, Android settings, finding problems |
|
||||
| [port/web/README.md](port/web/README.md) | The web build, the page, the game data in the browser, limits, how it operates, hosting on GitHub Pages |
|
||||
| [port/include/xdk/README.md](port/include/xdk/README.md) | How the SDK declarations were written and are checked |
|
||||
| [docs/custom_edition_caches.md](docs/custom_edition_caches.md) | Loading and converting Custom Edition maps, and the evidence for each layout |
|
||||
| [docs/dedicated_server.md](docs/dedicated_server.md) | The dedicated server: its command line, exit codes, commands, HTTP API, RCON, events and files |
|
||||
| [docs/master_protocol.md](docs/master_protocol.md) | The master servers' protocol: publishing, the probe, the signed list |
|
||||
| [docs/mods.md](docs/mods.md) | Mods: folders of Halo PC tag files whose sounds, bitmaps, text and models play over a map's on one machine |
|
||||
| [port/assets/text_filter/README.md](port/assets/text_filter/README.md) | Streamer mode's words: Surge AI's list, the review, the allowed words |
|
||||
| [port/assets/menus/README.md](port/assets/menus/README.md) | The menu files' format and how to write them again |
|
||||
| [port/assets/menus/NON_HANDDRAWN.md](port/assets/menus/NON_HANDDRAWN.md) | Menu pictures that are not redraws |
|
||||
| [port/assets/menus/UNWIRED.md](port/assets/menus/UNWIRED.md) | Menu functions that do nothing yet |
|
||||
| [port/assets/fonts/README.md](port/assets/fonts/README.md) | The fonts and their licences |
|
||||
| [tools/harness/README.md](tools/harness/README.md) | Asset-free regression tests |
|
||||
| [tools/stagekit/README.md](tools/stagekit/README.md) | Scenarios staged and instrumented on the real engine, no retail assets |
|
||||
| `port/third_party/*/README.md` | Each vendored library |
|
||||
| [AUTHORS.md](AUTHORS.md) | Art credits |
|
||||
@@ -1,25 +0,0 @@
|
||||
# Authors
|
||||
|
||||
## Art
|
||||
|
||||
- **The game's icon** (the Android app's launcher icon, `halo.exe`'s icon
|
||||
and the desktop windows' icon): by ORION (`port/assets/icon`).
|
||||
- **The controller's A, B, X and Y buttons** (the menus' button icons and
|
||||
the HUD messages'): redraws by saulob (`port/assets/buttons`).
|
||||
- **The high-res HUD** (its meters, icons, scopes and messages, and the
|
||||
weapons' reticles): redraws by MrBruh (`port/assets/hud`), based on
|
||||
reference photos by Aerocatia. The sniper rifle's zoom labels (2x, 10x)
|
||||
are set in Overpass (`port/assets/fonts`).
|
||||
- **The menus' mouse cursor** (the blue arrow the menus show for the
|
||||
mouse): by pugzysixtyfour (`port/assets/cursor`).
|
||||
|
||||
## Third-party art
|
||||
|
||||
- **Voice chat's speaker icons** (who talks, and who is muted, in the lobby,
|
||||
on the scoreboard and in the game): `volume-2` and `volume-x` from
|
||||
[Lucide](https://lucide.dev) 1.53.0, copyright (c) 2026 Lucide Icons and
|
||||
Contributors, under the ISC licence
|
||||
(`port/assets/icons/lucide/LICENSE`).
|
||||
- **The Mods menu's warning icons** (a mod out of its requested order, and
|
||||
a mod that cannot be played): `triangle-alert` and `circle-x` from
|
||||
[Lucide](https://lucide.dev) 1.53.0, under the same licence.
|
||||
@@ -1,661 +0,0 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
@@ -1,227 +1,140 @@
|
||||
<p align="center">
|
||||
<img src="port/android/steam_frame_grid/library.png" width="640" alt="Mjolnir VR">
|
||||
</p>
|
||||
# Halo: Combat Evolved for Linux, Windows and Android
|
||||
|
||||
# Mjolnir VR
|
||||
[](https://discord.gg/9gqcHyr5km)
|
||||
|
||||
**A VR mod for Halo: Combat Evolved** (the original Xbox game) on the
|
||||
**Meta Quest 3 / 3S** and the **Steam Frame**. Play the campaign and
|
||||
multiplayer in full 6DoF virtual reality, with your hands in the game.
|
||||
This project is a port of the Halo: Combat Evolved decompilation to Linux,
|
||||
Windows and Android. The decompilation is of the Xbox build 2342
|
||||
(`cachebeta.exe`, SHA-256
|
||||
`4cc87b45f721270392a96f1674ed2b5cd4a7bb4355faeab4531d1cf1884d9520`).
|
||||
|
||||
Mjolnir VR runs on your headset by itself, without a PC. It
|
||||
brings no game files: it uses a disc image of **your own, purchased copy**
|
||||
of the game.
|
||||
<img width="1289" height="995" alt="The game on Linux" src="https://github.com/user-attachments/assets/0d3ad50f-f8b8-46cf-aef8-e3661da2a7d7" />
|
||||
|
||||
> **Unofficial fan project.** Mjolnir VR is a free,
|
||||
> non-commercial fan project. It is not affiliated with, endorsed,
|
||||
> sponsored or approved by Microsoft, Xbox Game Studios, Halo Studios or
|
||||
> Bungie. See [Legal](#legal).
|
||||
The port starts from the decompilation of [bnunu/halo-1](https://github.com/bnunu/halo-1).
|
||||
That project is a fork of [punpckhdq/halo](https://github.com/punpckhdq/halo).
|
||||
|
||||
Until build 313 it was called *Ringfall: Mjolnir VR*. Installed builds
|
||||
update to the new name by themselves, and the old links lead here.
|
||||
## Download
|
||||
|
||||
## Contents
|
||||
GitHub Actions builds the game for each commit. These links download the
|
||||
builds of the latest release:
|
||||
|
||||
- [What you get](#what-you-get)
|
||||
- [What you can play](#what-you-can-play)
|
||||
- [What you need](#what-you-need)
|
||||
- [Install on Meta Quest 3 / 3S](#install-on-meta-quest-3--3s)
|
||||
- [Install on Steam Frame](#install-on-steam-frame)
|
||||
- [Playing](#playing)
|
||||
- [Problems and questions](#problems-and-questions)
|
||||
- [Credits](#credits)
|
||||
- [Legal](#legal)
|
||||
| Platform | Release | Debug |
|
||||
| --- | --- | --- |
|
||||
| Linux | [halo-linux-release.zip](https://github.com/cybersecurity/halo-ce-universal/releases/latest/download/halo-linux-release.zip) | [halo-linux-debug.zip](https://github.com/cybersecurity/halo-ce-universal/releases/latest/download/halo-linux-debug.zip) |
|
||||
| Windows | [halo-windows-release.zip](https://github.com/cybersecurity/halo-ce-universal/releases/latest/download/halo-windows-release.zip) | [halo-windows-debug.zip](https://github.com/cybersecurity/halo-ce-universal/releases/latest/download/halo-windows-debug.zip) |
|
||||
| Android | [halo-android-release.zip](https://github.com/cybersecurity/halo-ce-universal/releases/latest/download/halo-android-release.zip) | [halo-android-debug.zip](https://github.com/cybersecurity/halo-ce-universal/releases/latest/download/halo-android-debug.zip) |
|
||||
|
||||
## What you get
|
||||
Use the release build to play. The debug build stops at the first failed
|
||||
assertion and writes it to the log. Use the debug build to find and report
|
||||
problems.
|
||||
|
||||
- **Full VR**: stereo 6DoF at your headset's refresh rate (72 to 120 Hz);
|
||||
the HUD, menus, scope and crosshair float as layers of their own.
|
||||
- **Your hands in the game**: the weapon sits in your hand and fires
|
||||
where you point it; arms and fingers follow your controllers;
|
||||
two-handed weapons, melee by swinging, grenades thrown with your hand,
|
||||
crouching and leaning with your body.
|
||||
- **Vehicles**: steer the Warthog by turning its wheel with both hands;
|
||||
turrets with handles.
|
||||
- **Comfort**: snap or smooth turning in fine steps, comfort vignettes,
|
||||
left-handed mode, buttons remapped freely, graphics presets, refresh
|
||||
rate and resolution, all in the in-game VR options (**Y**).
|
||||
- **The PC version's menus**, clicked with a laser pointer, and an
|
||||
on-screen keyboard for names, codes and passwords.
|
||||
The game updates itself. At start-up it looks for a newer release, and asks
|
||||
if you want to install it. Refer to "Updates" in
|
||||
[port/linux/README.md](port/linux/README.md#updates).
|
||||
|
||||
## What you can play
|
||||
Each build of the `main` branch that passes on all three platforms is a new
|
||||
release. The [Releases](https://github.com/cybersecurity/halo-ce-universal/releases)
|
||||
page keeps the last five releases. If the latest build has a problem, get
|
||||
an older build from that page.
|
||||
|
||||
- **The whole campaign**: all ten missions, on every difficulty, saved as
|
||||
you go.
|
||||
- **Co-op campaign** with friends, online or on your local network, with
|
||||
settings for friendly fire and extra enemies per player.
|
||||
- **LAN multiplayer** (system link) with everyone on your network.
|
||||
- **Online multiplayer**, no server of your own needed: host a game and
|
||||
share its join code, find public games in the server browser, or protect
|
||||
a lobby with a password. Up to 128 players.
|
||||
- **Bots** to fill a game, on foot, in vehicles and at turrets; they make
|
||||
room when a person joins.
|
||||
- **All 13 multiplayer maps** and the Xbox game's game types: Slayer,
|
||||
Capture the Flag, King of the Hill, Oddball and Race.
|
||||
- **Cross-play**: VR players on the Quest and the Steam Frame, together with
|
||||
players of the PC and phone builds of
|
||||
[OpenCE](https://github.com/OpenCommunityEdition/OpenCE).
|
||||
## Game data
|
||||
|
||||
## What you need
|
||||
The port does not include the game data. Download an Xbox disc image
|
||||
(`.xiso` or `.iso`) of Halo: Combat Evolved. All versions of the game
|
||||
operate. The maps of the European (PAL) version were made for a slower
|
||||
console. The port changes them to play as the North American (NTSC) maps do,
|
||||
so players of the two versions can play together.
|
||||
|
||||
- A **Meta Quest 3 / 3S** or a **Steam Frame**.
|
||||
- A **disc image** (`.iso` or `.xiso`) of **Halo: Combat Evolved for the
|
||||
original Xbox**, made from **a disc you own**. Any region and version
|
||||
works. The game plays in the disc's language; on the European disc in
|
||||
Spanish and Italian it takes your headset's language (else the first).
|
||||
1. Start the game.
|
||||
2. At the first start, the game asks for the disc image. Select it.
|
||||
3. The game extracts the `maps/` folder. Then the game starts.
|
||||
|
||||
This project does not include, link to or help find game files. Please
|
||||
do not ask for or share disc images in issues or discussions; such posts
|
||||
are deleted.
|
||||
On Linux and Windows, the game puts `maps/` next to the executable. On
|
||||
Android, copy the disc image to the phone first. The app puts `maps/` in its
|
||||
data folder. Refer to [port/android/README.md](port/android/README.md).
|
||||
|
||||
## Install on Meta Quest 3 / 3S
|
||||
## Platforms
|
||||
|
||||
You install the game once with a computer (Windows, macOS or Linux); after
|
||||
that it updates itself.
|
||||
Each platform has its own instructions:
|
||||
|
||||
1. **Turn on Developer Mode** for your Quest, once: in the Meta Horizon
|
||||
app on your phone, open your headset's settings, then *Developer
|
||||
Mode* (Meta asks you to create a free developer account first).
|
||||
2. **Install [SideQuest](https://sidequestvr.com/setup-howto)** (the
|
||||
"Advanced Installer") on your computer and connect the Quest with a
|
||||
USB cable. In the headset, allow USB debugging for this computer.
|
||||
3. **Download `MjolnirVR.apk`** from the
|
||||
[latest release](../../releases/latest) and drag it onto the SideQuest
|
||||
window. It installs the game.
|
||||
4. **Copy your disc image** to the Quest's `Download` folder: in
|
||||
SideQuest, open the file manager (the folder icon), go to `Download`
|
||||
and drag the `.iso` file in.
|
||||
5. **In the headset**, open your *Library*, choose *Unknown Sources* and
|
||||
start **Mjolnir VR**. Select **Choose disc image** and pick
|
||||
your file in `Download`. The game copies what it needs (about 1.8 GB,
|
||||
a minute or two) and starts.
|
||||
| Platform | Instructions |
|
||||
| --- | --- |
|
||||
| Linux (32-bit x86 executable, OpenGL 4.5, SDL3) | [port/linux/README.md](port/linux/README.md) |
|
||||
| Windows (32-bit x86 executable, OpenGL 4.5, SDL3) | [port/windows/README.md](port/windows/README.md) |
|
||||
| Android (arm64 app, OpenGL ES 3, SDL3) | [port/android/README.md](port/android/README.md) |
|
||||
|
||||
You can delete the disc image from `Download` afterwards. When a new
|
||||
version comes out, the game asks you at start whether to update.
|
||||
The Linux README also gives the controls, the settings and the multiplayer
|
||||
functions. These are almost the same on all platforms.
|
||||
|
||||
## Install on Steam Frame
|
||||
## Multiplayer
|
||||
|
||||
No computer and no keyboard needed.
|
||||
The game can play system link games on a local network and on the internet:
|
||||
|
||||
1. **Switch to Desktop Mode**: press the Steam button, then *Power* >
|
||||
*Switch to Desktop*.
|
||||
2. **Put your disc image** in the `Downloads` folder (for example from a
|
||||
USB stick or memory card with the file manager, Dolphin).
|
||||
3. **Download `Install-Mjolnir-VR.desktop`** from the
|
||||
[latest release](../../releases/latest) with the web browser.
|
||||
4. **Open it**: in Dolphin, open `Downloads` and double-click the file.
|
||||
If you are asked whether to run it, choose to continue.
|
||||
5. **Answer the dialogs.** The installer finds your disc image, copies
|
||||
what the game needs, adds **Mjolnir VR** to your Steam
|
||||
library and offers to switch back to Gaming Mode.
|
||||
6. Start **Mjolnir VR** from your library (under *Non-Steam*).
|
||||
- A system link game can have up to 128 players on up to 128 machines.
|
||||
- Linux, Windows and Android machines can play in the same game.
|
||||
- An invite link lets a machine join a game on the internet. No server of
|
||||
this project is necessary.
|
||||
- The netcode is new. Each machine moves its own player at once,
|
||||
and the host makes the decisions for the game. Refer to
|
||||
[port/linux/NETCODE.md](port/linux/NETCODE.md).
|
||||
|
||||
The game updates itself: when a new version is out, it is downloaded
|
||||
while you play and used from the next start on. Your settings, saves and
|
||||
game data stay. More about the Steam Frame:
|
||||
[port/android/STEAM_FRAME.md](port/android/STEAM_FRAME.md).
|
||||
## Build the game
|
||||
|
||||
## Playing
|
||||
You do not need the Xbox SDK. The port supplies the SDK declarations that
|
||||
the game uses. Refer to [port/include/xdk](port/include/xdk/README.md).
|
||||
|
||||
- **Y** opens the VR options in the main and pause menus: turning,
|
||||
comfort, weapon hand, buttons, graphics, refresh rate and resolution.
|
||||
*Quit the game* is on its last page.
|
||||
- In the menus, point with a controller and pull the trigger to click.
|
||||
- The controller layout is on the VR options' *Controller buttons* page.
|
||||
- **Voice chat** in network games: hold the grip of the hand without the
|
||||
weapon to talk (not while it holds the weapon or the Warthog's wheel).
|
||||
The *BUTTONS* page can put push to talk on another button.
|
||||
To build the game:
|
||||
|
||||
## Problems and questions
|
||||
1. Install Python and [ninja](https://ninja-build.org/).
|
||||
2. Install the tools for your platform. Refer to the README for the
|
||||
platform.
|
||||
3. In the root folder of the repository, enter `python configure.py`.
|
||||
4. Enter `ninja` with the target for the platform:
|
||||
|
||||
Please open an [issue](../../issues) and include:
|
||||
| Target | Result |
|
||||
| --- | --- |
|
||||
| `ninja linux` | `build/linux/halo` |
|
||||
| `ninja windows` (on Windows) | `build/windows/halo.exe` and `SDL3.dll` |
|
||||
| `ninja android_apk` | `port/android/app/build/outputs/apk/debug/app-debug.apk` |
|
||||
|
||||
- your headset and the build number of the release you installed;
|
||||
- what you did and what happened;
|
||||
- the game's log, `debug.txt`:
|
||||
- Quest: `Android/data/io.github.cesarus85.ringfall/files/debug.txt`
|
||||
(SideQuest's file manager);
|
||||
- Steam Frame: `Documents/RingfallMjolnirVR/debug.txt` (and
|
||||
`logcat.txt` and `install.log` beside it).
|
||||
If you enter `ninja` without a target, ninja builds the game for the
|
||||
computer that you use.
|
||||
|
||||
What is done and what comes next: [port/android/VR_ROADMAP.md](port/android/VR_ROADMAP.md).
|
||||
`tools/ci_build.py` makes the same builds as GitHub Actions. For example,
|
||||
enter `python tools/ci_build.py linux release`.
|
||||
|
||||
**Network use.** The game connects to the internet only for what you
|
||||
use: the update check (GitHub), online games (to other players
|
||||
directly), and join codes and lobby lists through public MQTT brokers
|
||||
(listed in [brokers.txt](port/assets/network/brokers.txt)). There is no
|
||||
telemetry.
|
||||
### Build options
|
||||
|
||||
## Credits
|
||||
Give these options to `configure.py`:
|
||||
|
||||
Mjolnir VR stands on the work of others:
|
||||
| Option | Result |
|
||||
| --- | --- |
|
||||
| (none) | A debug build. A failed assertion stops the game. |
|
||||
| `--release` | A release build. The game does not examine assertions, as in the retail game. |
|
||||
| `--portable` | The Linux and Windows builds operate on all x86-64 processors. Use this option for builds that you give to other persons. |
|
||||
| `--lto=thin`, `--lto=off` | Less link-time optimization. The link is faster. |
|
||||
| `--pgo=off` | No profile-guided optimization. |
|
||||
| `--pgo=train` | Records a new optimization profile. Refer to "Optimization profiles". |
|
||||
|
||||
- **[OpenCE](https://github.com/OpenCommunityEdition/OpenCE)** (Open
|
||||
Community Edition): the port of the decompiled game to Linux, Windows
|
||||
and Android, with its renderer, netcode, PC menus and multiplayer, that
|
||||
this project builds on and follows.
|
||||
- **The decompilation**: [bnunu/halo-1](https://github.com/bnunu/halo-1),
|
||||
a fork of [punpckhdq/halo](https://github.com/punpckhdq/halo).
|
||||
- **[HaloCE-Quest-VR](https://github.com/moistman42069/HaloCE-Quest-VR)**
|
||||
by moistman42069 (CC0): the arm IK, the forearm's twist and the
|
||||
fingers' poses are taken from it (`port/linux/game/vr_arms.c`); the
|
||||
left-handed mode and the graphics presets follow its ideas.
|
||||
- **[HaloCE-VR](https://github.com/astromaddie/HaloCE-VR)** by astromaddie
|
||||
(CC0): the Steam Frame work, whose findings (such as quieting Mesa's
|
||||
trace markers) are used here.
|
||||
- **[xboxdevwiki](https://xboxdevwiki.net/XDVDFS)**: its description of
|
||||
the Xbox's disc file system, which the disc image readers are written
|
||||
from.
|
||||
- The libraries and fonts in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
||||
Without `--portable`, the Linux and Windows builds use all the instructions
|
||||
of the processor that builds them (`-march=native`). Such a build does not
|
||||
always start on a different computer.
|
||||
|
||||
Thank you all.
|
||||
### Optimization profiles
|
||||
|
||||
## Building it
|
||||
The builds use profiles of the game to optimize the code:
|
||||
|
||||
`python3 configure.py --release`, then `ninja android_apk` (Android SDK
|
||||
and NDK needed). See [port/android/README.md](port/android/README.md) for
|
||||
the details and [docs/OPENCE_README.md](docs/OPENCE_README.md) for the
|
||||
port it is built on.
|
||||
- `pgo/halo_linux.profdata` for Linux and Android.
|
||||
- `pgo/halo_windows.profdata` for Windows.
|
||||
|
||||
## Legal
|
||||
The profiles need clang 22 or later. With an older clang, the builds do not
|
||||
use the profiles.
|
||||
|
||||
Mjolnir VR is an unofficial, free, non-commercial fan project.
|
||||
It is not affiliated with, endorsed, sponsored or approved by Microsoft
|
||||
Corporation, Xbox Game Studios, Halo Studios or Bungie. Halo, Halo: Combat
|
||||
Evolved and Xbox are trademarks of Microsoft Corporation; they are named
|
||||
here only to say which game this mod works with. Meta Quest is a trademark
|
||||
of Meta Platforms, Inc.; Steam and Steam Frame are trademarks of Valve
|
||||
Corporation.
|
||||
To record a new profile:
|
||||
|
||||
No game data, art, music or other content of the game is included or
|
||||
distributed. You need your own, legally purchased copy of the game. If
|
||||
you enjoy this mod, please support the creators of the original by buying
|
||||
their games.
|
||||
1. Delete the profile.
|
||||
2. Enter `python configure.py --pgo=train`.
|
||||
3. Enter `ninja linux` or `ninja windows`.
|
||||
|
||||
### Licence
|
||||
|
||||
Mjolnir VR is free software: you can give it to others and change
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, version 3 of the License or (at your option)
|
||||
any later version (`AGPL-3.0-or-later`), as OpenCE, which it builds on, is.
|
||||
It comes with no warranty. The full text is in [LICENSE](LICENSE).
|
||||
|
||||
- **From build 312 on.** The AGPL applies from the commit that took in
|
||||
OpenCE's change of licence (19 October 2026), and to each release built
|
||||
from it or a later one. Earlier releases, and the source at every earlier
|
||||
commit, were released under [CC0 1.0](LICENSES/CC0-1.0.txt) and stay
|
||||
that way.
|
||||
- **Hosts and servers.** If you change the game and let other persons play
|
||||
with your version over a network (for example, as the host of an
|
||||
internet game), the AGPL asks you to offer them the source of your
|
||||
version. The game as released has its source here, and each release's
|
||||
source is its tag (`build-<n>`).
|
||||
- **Third-party code and fonts** keep their own licences: see
|
||||
[THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
||||
- **Halo is not covered.** The licence covers the work of this project's
|
||||
and OpenCE's authors. It gives no rights in Halo, its maps or anything
|
||||
else that Microsoft owns.
|
||||
The build then plays the main menu and the first minute of each campaign
|
||||
level. This procedure continues for approximately 15 minutes. The game
|
||||
data must be in `assets/`.
|
||||
@@ -1,48 +0,0 @@
|
||||
# Third-party notices
|
||||
|
||||
Mjolnir VR is released under the GNU Affero General Public
|
||||
License, version 3 or later ([LICENSE](LICENSE)); releases before build 312
|
||||
were released under [CC0 1.0](LICENSES/CC0-1.0.txt). It includes or builds
|
||||
on the following, under their own licenses; each license's full text is in
|
||||
the file named.
|
||||
|
||||
## Code
|
||||
|
||||
| Component | Used for | License | Text |
|
||||
| --- | --- | --- | --- |
|
||||
| [OpenCE](https://github.com/OpenCommunityEdition/OpenCE) and the decompilation ([bnunu/halo-1](https://github.com/bnunu/halo-1), [punpckhdq/halo](https://github.com/punpckhdq/halo)) | the game's code, the port | AGPL 3.0 or later (OpenCE from 19 October 2026, punpckhdq/halo from 17 October 2026; CC0 1.0 before); bnunu/halo-1: CC0 1.0 | [LICENSE](LICENSE), [LICENSES/CC0-1.0.txt](LICENSES/CC0-1.0.txt) |
|
||||
| [HaloCE-Quest-VR](https://github.com/moistman42069/HaloCE-Quest-VR) | the arm IK, forearm twist and finger poses (`port/linux/game/vr_arms.c`) | CC0 1.0 | (its repository) |
|
||||
| [HaloCE-VR](https://github.com/astromaddie/HaloCE-VR) | Steam Frame findings | CC0 1.0 | (its repository) |
|
||||
| [SDL 3](https://libsdl.org) | windows, input, sound | zlib | (in SDL's source, `LICENSE.txt`) |
|
||||
| [Khronos OpenXR loader](https://github.com/KhronosGroup/OpenXR-SDK) | VR runtime access | Apache 2.0 | (in the loader's package) |
|
||||
| [musl](https://musl.libc.org) | the C library of the game's code on Android, its maths | MIT | [port/third_party/musl-math](port/third_party/musl-math/README.md) |
|
||||
| [Expat](https://libexpat.github.io) | the PC menus' definitions | MIT | [port/third_party/expat/COPYING](port/third_party/expat/COPYING) |
|
||||
| [Mbed TLS](https://www.trustedfirmware.org/projects/mbed-tls/) | HTTPS for the desktop builds' updater (not in the Android app) | Apache 2.0 | [port/third_party/mbedtls/LICENSE](port/third_party/mbedtls/LICENSE) |
|
||||
| [miniupnpc](https://miniupnp.tuxfamily.org) | router port forwarding for online games | BSD 3-Clause | [port/third_party/miniupnpc/LICENSE](port/third_party/miniupnpc/LICENSE) |
|
||||
| [KCP](https://github.com/skywind3000/kcp) | reliable transport for online games | MIT | [port/third_party/kcp/LICENSE](port/third_party/kcp/LICENSE) |
|
||||
| [Monocypher](https://monocypher.org) | signing public games' listings (Ed25519); online play's other cryptography is the port's own | CC0 1.0 or BSD 2-Clause | [port/third_party/monocypher/LICENCE.md](port/third_party/monocypher/LICENCE.md) |
|
||||
| [tomlc17](https://github.com/cktan/tomlc17) | reading `config.toml` | MIT | [port/third_party/tomlc17/LICENSE](port/third_party/tomlc17/LICENSE) |
|
||||
| [stb](https://github.com/nothings/stb) | drawing the game's text sharply (stb_truetype) | MIT or public domain | [port/third_party/stb/LICENSE](port/third_party/stb/LICENSE) |
|
||||
| [SMAA](https://www.iryoku.com/smaa/) | anti-aliasing (flat screens; off in VR) | MIT | [port/third_party/smaa/LICENSE](port/third_party/smaa/LICENSE) |
|
||||
|
||||
The disc image readers (`XisoExtractor.java`, `steam_frame_xiso.py`,
|
||||
`xiso.c`) are written from a description of the Xbox's disc file system
|
||||
([xboxdevwiki's XDVDFS page](https://xboxdevwiki.net/XDVDFS)), not from
|
||||
extract-xiso, which earlier releases followed.
|
||||
|
||||
## Fonts
|
||||
|
||||
| Font | Used for | License | Text |
|
||||
| --- | --- | --- | --- |
|
||||
| Overpass (Red Hat, Delve Withrington) | the game's text, the library pictures | SIL Open Font License 1.1 | [port/assets/fonts/Overpass-OFL.txt](port/assets/fonts/Overpass-OFL.txt) |
|
||||
| OpenCE (after Newtown) | the menus' titles | SIL Open Font License 1.1 | [port/assets/fonts/OpenCE-OFL.txt](port/assets/fonts/OpenCE-OFL.txt) |
|
||||
| Newtown (Roger White) | OpenCE's source | public domain | [port/assets/fonts/Newtown-LICENSE.txt](port/assets/fonts/Newtown-LICENSE.txt) |
|
||||
|
||||
See [port/assets/fonts/README.md](port/assets/fonts/README.md) for where
|
||||
each font is used.
|
||||
|
||||
## Not included
|
||||
|
||||
No file of Halo: Combat Evolved (maps, sounds, art, music, fonts or
|
||||
executables) is part of this repository or its releases. The game reads
|
||||
them from the player's own disc image.
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# root build script: writes build.ninja for the native ports (Linux, Windows,
|
||||
# Android) and the web port
|
||||
# Android)
|
||||
|
||||
import argparse
|
||||
import io
|
||||
@@ -12,15 +12,9 @@ from types import SimpleNamespace
|
||||
|
||||
from tools import ninja_syntax
|
||||
from tools.android_build import android_configure_inputs, generate_android_build
|
||||
from tools.linux_build import check_profile_options, generate_linux_build, linux_configure_inputs
|
||||
from tools.web_build import generate_web_build, web_configure_inputs
|
||||
from tools.linux_build import generate_linux_build, linux_configure_inputs
|
||||
from tools.windows_build import generate_windows_build, windows_configure_inputs
|
||||
|
||||
|
||||
def is_windows() -> bool:
|
||||
return os.name == "nt"
|
||||
|
||||
|
||||
# arguments
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
@@ -37,13 +31,7 @@ parser.add_argument(
|
||||
parser.add_argument(
|
||||
"--release",
|
||||
action="store_true",
|
||||
help="release builds (Linux, Windows, Android, web): assertions are not checked",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--profile",
|
||||
action="store_true",
|
||||
help="profiling builds (Linux, Windows, Android): CPU scopes recorded on a "
|
||||
"console command or launch setting (README, \"Profiling builds\"); not with --pgo=train",
|
||||
help="release builds (Linux, Windows, Android): assertions are not checked",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--lto",
|
||||
@@ -56,11 +44,7 @@ parser.add_argument(
|
||||
"--portable",
|
||||
action="store_true",
|
||||
help="x86 builds (Linux, Windows): code for any x86-64 processor (SSE2) rather than for this "
|
||||
"machine's (-march=native, the default); use it for builds that run on other computers. On Linux it also "
|
||||
"builds against Debian 11's glibc 2.31 rather than this machine's, and brings its own SDL 3 (libSDL3.so.0, "
|
||||
"beside the executable), so that it starts on SteamOS and older distributions: the first build downloads "
|
||||
"the Debian packages and SDL's source (build/linux/third_party, tools/linux_sysroot.py), and needs CMake, "
|
||||
"pkgconf and wayland-scanner, not the 32-bit SDL 3",
|
||||
"machine's (-march=native, the default); use it for builds that run on other computers",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--pgo",
|
||||
@@ -89,48 +73,7 @@ parser.add_argument(
|
||||
type=str,
|
||||
help="clang with the arm64_32 target for the Android guest (default: clang)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--web-emcc",
|
||||
type=str,
|
||||
help="Emscripten's emcc for `ninja web` (default: emcc on the PATH, then EMSDK's or ~/emsdk's)",
|
||||
)
|
||||
|
||||
# no need to spam those extra flags when running on Windows
|
||||
if not is_windows():
|
||||
parser.add_argument(
|
||||
"--windows-cross",
|
||||
action="store_true",
|
||||
help="generate the Windows build (`ninja windows`) on Linux, cross-compiling "
|
||||
"with clang against an MSVC toolchain (--windows-vctools-dir and --windows-sdk-dir), "
|
||||
"and make it the default target",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--windows-cc",
|
||||
metavar="BINARY",
|
||||
help="compiler for the Windows cross build, `ninja windows` (default: clang). "
|
||||
"Only clang is supported for now.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--windows-vctools-dir",
|
||||
metavar="DIR",
|
||||
type=Path,
|
||||
help="the Visual C++ tools of the MSVC toolchain a --windows-cross build compiles "
|
||||
"and links against: the versioned folder under VC/Tools/MSVC, the one with `include` "
|
||||
"and `lib` (default: VCToolsInstallDir)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--windows-sdk-dir",
|
||||
metavar="DIR",
|
||||
type=Path,
|
||||
help="the Windows SDK a --windows-cross build compiles and links against: the "
|
||||
"folder with `Include` and `Lib`, each with a versioned folder (default: WindowsSdkDir)",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
check_profile_options(args.profile, args.pgo)
|
||||
except ValueError as error:
|
||||
parser.error(str(error))
|
||||
|
||||
# the settings the builds read
|
||||
sln = SimpleNamespace(
|
||||
@@ -138,20 +81,17 @@ sln = SimpleNamespace(
|
||||
linux_cc=args.linux_cc,
|
||||
compiler_launcher=args.compiler_launcher,
|
||||
port_release=args.release,
|
||||
port_profile=args.profile,
|
||||
port_lto=args.lto,
|
||||
port_portable=args.portable,
|
||||
port_pgo=args.pgo,
|
||||
port_pgo_profile=args.pgo_profile,
|
||||
android_ndk=args.android_ndk,
|
||||
android_guest_cc=args.android_guest_cc,
|
||||
web_emcc=args.web_emcc,
|
||||
)
|
||||
if not is_windows():
|
||||
sln.windows_cc = args.windows_cc
|
||||
sln.windows_cross = args.windows_cross
|
||||
sln.windows_vctools_dir = args.windows_vctools_dir
|
||||
sln.windows_sdk_dir = args.windows_sdk_dir
|
||||
|
||||
|
||||
def is_windows() -> bool:
|
||||
return os.name == "nt"
|
||||
|
||||
|
||||
# build.ninja
|
||||
@@ -172,7 +112,6 @@ n.newline()
|
||||
generate_linux_build(n, sln)
|
||||
generate_android_build(n, sln)
|
||||
generate_windows_build(n, sln)
|
||||
generate_web_build(n, sln)
|
||||
|
||||
n.comment("Reconfigure on change")
|
||||
n.rule(
|
||||
@@ -190,14 +129,13 @@ n.build(
|
||||
*linux_configure_inputs(),
|
||||
*android_configure_inputs(),
|
||||
*windows_configure_inputs(),
|
||||
*web_configure_inputs(),
|
||||
],
|
||||
)
|
||||
n.newline()
|
||||
|
||||
# the build for this computer, where it could be generated (the Windows
|
||||
# build is left out when SDL cannot be fetched, for instance)
|
||||
default = "windows" if is_windows() or sln.windows_cross else "linux"
|
||||
default = "windows" if is_windows() else "linux"
|
||||
if f"\nbuild {default}: " in out.getvalue():
|
||||
n.comment("Default rule: the build for this computer")
|
||||
n.default(default)
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
*
|
||||
!healthz.sh
|
||||
!*.zip
|
||||
@@ -1,2 +0,0 @@
|
||||
# a release zip copied here to build the image from (README.md, "Building it")
|
||||
*.zip
|
||||
@@ -1,60 +0,0 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
#
|
||||
# The dedicated server (docs/dedicated_server.md) as a container image, made
|
||||
# from a release's halo-linux-release.zip (the portable build: halo, its
|
||||
# libSDL3.so.0, brokers.txt, masters.txt):
|
||||
#
|
||||
# docker build -t opence-server deploy/docker
|
||||
# docker build -t opence-server --build-arg RELEASE=https://github.com/OpenCommunityEdition/OpenCE/releases/download/build-206/halo-linux-release.zip deploy/docker
|
||||
# docker build -t opence-server --build-arg RELEASE=halo-linux-release.zip deploy/docker (a zip in deploy/docker)
|
||||
#
|
||||
# The game data is never in the image: mount the folder that holds maps/ at
|
||||
# /data, read-only. /state is the only folder the server writes (config.toml,
|
||||
# the save root with its map cache, the logs), so the root can be read-only.
|
||||
# deploy/docker/README.md says how to run it.
|
||||
|
||||
FROM debian:bookworm-slim AS release
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends unzip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
# a URL, or a file beside this Dockerfile
|
||||
ARG RELEASE=https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-linux-release.zip
|
||||
ADD ${RELEASE} /tmp/halo-linux-release.zip
|
||||
COPY healthz.sh /opt/opence/healthz.sh
|
||||
RUN unzip -q /tmp/halo-linux-release.zip -d /opt/opence \
|
||||
&& test -f /opt/opence/halo \
|
||||
&& chmod 0755 /opt/opence/halo /opt/opence/healthz.sh \
|
||||
&& if [ -f /opt/opence/halo-server ]; then chmod 0755 /opt/opence/halo-server; fi
|
||||
|
||||
FROM debian:bookworm-slim
|
||||
# The 32-bit C runtime; the release's own libSDL3.so.0 needs nothing more for
|
||||
# a server, which opens no window or sound device. ca-certificates: the
|
||||
# master servers and the update check are HTTPS.
|
||||
RUN dpkg --add-architecture i386 \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends libc6:i386 libgcc-s1:i386 ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& groupadd -g 10001 opence \
|
||||
&& useradd -u 10001 -g 10001 -d /state -M -s /usr/sbin/nologin opence \
|
||||
&& mkdir -p /data /state \
|
||||
&& chown 10001:10001 /state
|
||||
COPY --from=release /opt/opence /opt/opence
|
||||
ENV HALO_SERVER=1 \
|
||||
HALO_CONFIG_FILE=/state/config.toml \
|
||||
HALO_DATA_ROOT=/data \
|
||||
HALO_SAVE_ROOT=/state/saves \
|
||||
HALO_LOG_ROOT=/state/logs \
|
||||
HALO_NET_TUNNEL_PORT=2302 \
|
||||
HALO_SERVER_WEB_BIND=0.0.0.0 \
|
||||
HALO_SERVER_WEB_PORT=8080 \
|
||||
HOME=/state
|
||||
VOLUME ["/state"]
|
||||
# Internet play's tunnel, and the web page, API and RCON (publish it on the
|
||||
# host's loopback, or behind a proxy with TLS). System link's 5150, 5151 and
|
||||
# 5153 are for a local network only.
|
||||
EXPOSE 2302/udp 8080/tcp
|
||||
USER 10001:10001
|
||||
WORKDIR /state
|
||||
HEALTHCHECK --interval=15s --timeout=3s --start-period=60s --retries=3 CMD ["/opt/opence/healthz.sh"]
|
||||
STOPSIGNAL SIGTERM
|
||||
ENTRYPOINT ["/opt/opence/halo", "--server"]
|
||||
@@ -1,134 +0,0 @@
|
||||
# The dedicated server in a container
|
||||
|
||||
`ghcr.io/opencommunityedition/opence-server` is the dedicated server
|
||||
(`docs/dedicated_server.md`) as a container image: a release's
|
||||
`halo-linux-release.zip` on Debian 12 with the 32-bit C runtime, run as
|
||||
`halo --server` by the user 10001. CI builds it from each release
|
||||
(`.github/workflows/server-image.yml`) and signs it with cosign; the tags are
|
||||
`latest`, the release's (`build-206`) and `sha-<commit>`.
|
||||
|
||||
The game data is never in the image. Mount the folder that holds `maps/`
|
||||
(from your own copy of the game: port/linux/README.md, "Game data") at
|
||||
`/data`, read-only. Without it the server exits with code 2 and says which
|
||||
maps it looked for.
|
||||
|
||||
## Running it
|
||||
|
||||
```sh
|
||||
docker run -d --name halo --restart unless-stopped \
|
||||
--read-only --cap-drop ALL --security-opt no-new-privileges --tmpfs /tmp \
|
||||
-p 2302:2302/udp -p 127.0.0.1:8080:8080 \
|
||||
-v /srv/halo/data:/data:ro -v halo-state:/state \
|
||||
-e HALO_SERVER_NAME="My server" \
|
||||
-e HALO_SERVER_ROTATION="bloodgulch:ctf, sidewinder:team_slayer" \
|
||||
-e HALO_SERVER_WEB_PASSWORD=changeme-please \
|
||||
ghcr.io/opencommunityedition/opence-server:latest
|
||||
docker logs -f halo
|
||||
```
|
||||
|
||||
Or with Compose: `compose.yaml` beside this file runs the same, with the
|
||||
settings taken from the shell or a `.env` file
|
||||
(`HALO_DATA=/srv/halo/data`, `HALO_SERVER_NAME=...`). Its `https` profile
|
||||
adds Caddy in front of the web port, with a certificate for
|
||||
`HALO_WEB_DOMAIN`:
|
||||
|
||||
```sh
|
||||
HALO_DATA=/srv/halo/data docker compose -f deploy/docker/compose.yaml up -d
|
||||
HALO_WEB_DOMAIN=halo.example.org docker compose -f deploy/docker/compose.yaml --profile https up -d
|
||||
```
|
||||
|
||||
The Compose file puts both on a network of its own, `172.30.80.0/24`, with
|
||||
Caddy at the fixed address `172.30.80.10` and the server's
|
||||
`HALO_SERVER_WEB_TRUSTED_PROXY` set to it: the server believes Caddy's
|
||||
`X-Forwarded-For`, `-Host` and `-Proto`, so its rate limits and log name the
|
||||
visitor rather than Caddy, and the session cookie is `Secure`. If that
|
||||
subnet overlaps one of the host's, change the subnet, Caddy's
|
||||
`ipv4_address` and the variable together.
|
||||
|
||||
`docker stop` sends SIGTERM: the game in progress goes to its postgame,
|
||||
the players are told, the listing is withdrawn, and the server exits 0
|
||||
within the 15 seconds Compose waits (`docker stop -t 15` otherwise).
|
||||
|
||||
## Folders
|
||||
|
||||
| Path | What |
|
||||
| --- | --- |
|
||||
| `/opt/opence` | The release: `halo`, `libSDL3.so.0`, `brokers.txt`, `masters.txt`, `healthz.sh`, the licences (read-only) |
|
||||
| `/data` | The game data: `maps/`, and if you have them `custom_maps/`, `gametypes/` and `init.txt` (yours, read-only) |
|
||||
| `/state` | The only folder written: `config.toml` (`HALO_CONFIG_FILE`), `publisher.key` beside it, the save root `saves/` with the map cache (about 115 MB), `logs/` (`debug.txt`, `bans.txt`, `cheaters.txt`) |
|
||||
|
||||
The image sets `HALO_CONFIG_FILE=/state/config.toml` rather than linking
|
||||
`config.toml` beside the executable into the volume: the settings file is
|
||||
then in the volume from the first start, and nothing in `/opt/opence` is
|
||||
written. The server writes every setting there at the first start, with
|
||||
the generated web password if none was given.
|
||||
|
||||
## Settings
|
||||
|
||||
Every setting is an environment variable (port/linux/README.md, "Dedicated
|
||||
server", and docs/dedicated_server.md). A variable that is set wins over
|
||||
`config.toml`, and the web page's settings cannot change it. The image sets:
|
||||
|
||||
| Variable | Value |
|
||||
| --- | --- |
|
||||
| `HALO_SERVER` | `1` |
|
||||
| `HALO_CONFIG_FILE` | `/state/config.toml` |
|
||||
| `HALO_DATA_ROOT` | `/data` |
|
||||
| `HALO_SAVE_ROOT` | `/state/saves` |
|
||||
| `HALO_LOG_ROOT` | `/state/logs` |
|
||||
| `HALO_NET_TUNNEL_PORT` | `2302` |
|
||||
| `HALO_SERVER_WEB_BIND` | `0.0.0.0` (within the container; publish the port on `127.0.0.1` or behind TLS) |
|
||||
| `HALO_SERVER_WEB_PORT` | `8080` |
|
||||
|
||||
The ones most often given: `HALO_SERVER_NAME`, `HALO_SERVER_ROTATION`,
|
||||
`HALO_SERVER_MAX_PLAYERS`, `HALO_SERVER_PASSWORD`, `HALO_SERVER_PUBLIC`,
|
||||
`HALO_SERVER_MOTD`, `HALO_SERVER_WEB_PASSWORD`, `HALO_NET_PUBLIC_ADDRESS`,
|
||||
`HALO_SERVER_PUBLISHER_KEY` (the master servers' key, as 64 hex
|
||||
characters; `docker run --rm -v halo-state:/state <image> --keygen` makes one
|
||||
into the volume instead), `HALO_SERVER_INSTANCE`, `HALO_SERVER_REGION`,
|
||||
`HALO_SERVER_LOG_FORMAT=json`.
|
||||
|
||||
A tunnel port other than 2302 is published as the same number on both sides
|
||||
(`-e HALO_NET_TUNNEL_PORT=2303 -p 2303:2303/udp`), as the server offers its
|
||||
own port to joiners. Behind a NAT that STUN cannot see through, give the
|
||||
public address and port in `HALO_NET_PUBLIC_ADDRESS`.
|
||||
|
||||
## Health
|
||||
|
||||
`HEALTHCHECK` runs `/opt/opence/healthz.sh`, which asks `GET /healthz` on
|
||||
the web port (bash's `/dev/tcp`: the image has no curl) and is healthy on a
|
||||
200: the server is hosting (lobby, loading, playing or postgame) and its
|
||||
frames run. With `HALO_SERVER_WEB_PORT=0` it always passes.
|
||||
|
||||
## Building it
|
||||
|
||||
```sh
|
||||
docker build -t opence-server deploy/docker # the latest release
|
||||
docker build -t opence-server --build-arg RELEASE=https://github.com/OpenCommunityEdition/OpenCE/releases/download/build-206/halo-linux-release.zip deploy/docker
|
||||
```
|
||||
|
||||
A build of your own (`python tools/ci_build.py linux release` leaves
|
||||
`dist/halo-linux-release/`) goes in as a zip beside the Dockerfile:
|
||||
|
||||
```sh
|
||||
(cd dist/halo-linux-release && zip -qr ../../deploy/docker/halo-linux-release.zip .)
|
||||
docker build -t opence-server --build-arg RELEASE=halo-linux-release.zip deploy/docker
|
||||
```
|
||||
|
||||
`RELEASE` is a URL or a file beside the Dockerfile. The image is 32-bit
|
||||
x86 and runs on amd64 hosts only.
|
||||
|
||||
## Networking
|
||||
|
||||
Bridge networking works for internet play: the tunnel port is published one
|
||||
to one, and the server needs no hole punching of its own. System link
|
||||
(UDP 5150 and 5151, TCP 5150 and 5153) finds other machines only with
|
||||
`--network host`.
|
||||
|
||||
Verify an image's signature:
|
||||
|
||||
```sh
|
||||
cosign verify ghcr.io/opencommunityedition/opence-server:latest \
|
||||
--certificate-identity-regexp '^https://github\.com/OpenCommunityEdition/OpenCE/\.github/workflows/server-image\.yml@' \
|
||||
--certificate-oidc-issuer https://token.actions.githubusercontent.com
|
||||
```
|
||||
@@ -1,92 +0,0 @@
|
||||
# The dedicated server with Docker Compose (deploy/docker/README.md):
|
||||
#
|
||||
# docker compose -f deploy/docker/compose.yaml up -d
|
||||
# docker compose -f deploy/docker/compose.yaml --profile https up -d (with Caddy in front of the web port)
|
||||
#
|
||||
# HALO_DATA is the folder that holds maps/ (and custom_maps/, gametypes/),
|
||||
# mounted read-only; settings come from the environment below or from a
|
||||
# .env file beside this one.
|
||||
name: opence
|
||||
|
||||
services:
|
||||
server:
|
||||
image: ${OPENCE_IMAGE:-ghcr.io/opencommunityedition/opence-server:latest}
|
||||
restart: unless-stopped
|
||||
read_only: true
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
tmpfs:
|
||||
- /tmp
|
||||
ports:
|
||||
- "${HALO_NET_TUNNEL_PORT:-2302}:${HALO_NET_TUNNEL_PORT:-2302}/udp"
|
||||
# (the web page on the host's loopback only; Caddy reaches it on the
|
||||
# compose network)
|
||||
- "127.0.0.1:${HALO_SERVER_WEB_PORT:-8080}:${HALO_SERVER_WEB_PORT:-8080}/tcp"
|
||||
volumes:
|
||||
- ${HALO_DATA:-./data}:/data:ro
|
||||
- state:/state
|
||||
# A variable named without a value is passed only when it is set (in the
|
||||
# shell or .env): one that is set wins over config.toml, and sv_set
|
||||
# cannot change it.
|
||||
environment:
|
||||
- HALO_NET_TUNNEL_PORT=${HALO_NET_TUNNEL_PORT:-2302}
|
||||
- HALO_SERVER_WEB_PORT=${HALO_SERVER_WEB_PORT:-8080}
|
||||
- HALO_SERVER_NAME
|
||||
- HALO_SERVER_ROTATION
|
||||
- HALO_SERVER_MAX_PLAYERS
|
||||
- HALO_SERVER_PASSWORD
|
||||
- HALO_SERVER_PUBLIC
|
||||
- HALO_SERVER_MOTD
|
||||
# (8 characters or more; unset: one is made at the first start, printed
|
||||
# in the log and kept in the state volume's config.toml)
|
||||
- HALO_SERVER_WEB_PASSWORD
|
||||
- HALO_NET_PUBLIC_ADDRESS
|
||||
- HALO_SERVER_PUBLISHER_KEY
|
||||
- HALO_SERVER_INSTANCE
|
||||
- HALO_SERVER_REGION
|
||||
- HALO_SERVER_LOG_FORMAT
|
||||
# Caddy's address on the network below (the https profile): its
|
||||
# X-Forwarded-For, -Host and -Proto are believed, so the page's rate
|
||||
# limits and log name the visitor, and its session cookie is Secure.
|
||||
# Nothing else has this address.
|
||||
- HALO_SERVER_WEB_TRUSTED_PROXY=172.30.80.10
|
||||
networks:
|
||||
- opence
|
||||
stop_grace_period: 15s
|
||||
|
||||
# HTTPS for the web page, with a certificate from Let's Encrypt for
|
||||
# HALO_WEB_DOMAIN (which must resolve to this host, ports 80 and 443 open).
|
||||
caddy:
|
||||
image: caddy:2
|
||||
profiles: [https]
|
||||
restart: unless-stopped
|
||||
depends_on: [server]
|
||||
ports:
|
||||
- "80:80/tcp"
|
||||
- "443:443/tcp"
|
||||
- "443:443/udp"
|
||||
command: ["caddy", "reverse-proxy", "--from", "${HALO_WEB_DOMAIN:-halo.example.org}", "--to", "server:${HALO_SERVER_WEB_PORT:-8080}"]
|
||||
volumes:
|
||||
- caddy-data:/data
|
||||
- caddy-config:/config
|
||||
networks:
|
||||
opence:
|
||||
# (server.web_trusted_proxy above; outside the range Docker hands
|
||||
# out, so no other container takes it)
|
||||
ipv4_address: 172.30.80.10
|
||||
|
||||
# A fixed subnet, so that Caddy's address is known in advance. Containers
|
||||
# other than Caddy get addresses from ip_range only. Change it (and the two
|
||||
# addresses above) if it overlaps a network of the host's.
|
||||
networks:
|
||||
opence:
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.30.80.0/24
|
||||
ip_range: 172.30.80.128/25
|
||||
gateway: 172.30.80.1
|
||||
|
||||
volumes:
|
||||
state:
|
||||
caddy-data:
|
||||
caddy-config:
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
# The image's health check: GET /healthz on the web port, healthy on a 200
|
||||
# (the server answers 200 while it hosts and its frames run, 503 otherwise).
|
||||
# Bash's /dev/tcp, as the image has no curl.
|
||||
port="${HALO_SERVER_WEB_PORT:-8080}"
|
||||
# (no web port: nothing to ask)
|
||||
if [ -z "$port" ] || [ "$port" = 0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
{ exec 3<>"/dev/tcp/127.0.0.1/$port"; } 2>/dev/null || exit 1
|
||||
printf 'GET /healthz HTTP/1.1\r\nHost: 127.0.0.1:%s\r\nConnection: close\r\n\r\n' "$port" >&3 || exit 1
|
||||
IFS=' ' read -r -t 3 version status _ <&3 || exit 1
|
||||
exec 3<&-
|
||||
case "$version" in
|
||||
HTTP/1.*) ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
[ "$status" = 200 ]
|
||||
@@ -1,29 +0,0 @@
|
||||
# Big team slayer: first team to 50 kills, vehicles as Halo PC places them.
|
||||
# Play it with server.rotation entries such as bloodgulch:btb_slayer.
|
||||
base = "team_slayer"
|
||||
name = "BTB Slayer"
|
||||
|
||||
[universal]
|
||||
teams = true
|
||||
score_to_win = 50
|
||||
lives = 0
|
||||
respawn_time = 5
|
||||
health = 100
|
||||
weapon_set = "normal"
|
||||
vehicle_set = "default"
|
||||
radar = true
|
||||
friend_indicators = true
|
||||
|
||||
[options]
|
||||
time_limit = 20
|
||||
friendly_fire = "shields_only"
|
||||
friendly_fire_penalty = 5
|
||||
vehicle_respawn_time = 60
|
||||
auto_team_balance = true
|
||||
radar_players = "friends"
|
||||
team_vehicles = "pc"
|
||||
|
||||
[slayer]
|
||||
no_death_bonus = false
|
||||
no_kill_penalty = false
|
||||
kill_in_order = false
|
||||
@@ -1,27 +0,0 @@
|
||||
# Capture the flag as players remember it: three captures, the flag must be
|
||||
# at home to score.
|
||||
base = "ctf"
|
||||
name = "Classic CTF"
|
||||
|
||||
[universal]
|
||||
teams = true
|
||||
score_to_win = 3
|
||||
respawn_time = 5
|
||||
weapon_set = "normal"
|
||||
vehicle_set = "default"
|
||||
radar = true
|
||||
|
||||
[options]
|
||||
time_limit = 25
|
||||
friendly_fire = "off"
|
||||
vehicle_respawn_time = 90
|
||||
auto_team_balance = true
|
||||
radar_players = "friends"
|
||||
team_vehicles = "pc"
|
||||
|
||||
[ctf]
|
||||
assault = false
|
||||
reset_on_capture = false
|
||||
flag_must_reset = false
|
||||
flag_at_home_to_score = true
|
||||
single_flag_time = 0
|
||||
@@ -1,17 +0,0 @@
|
||||
# King of the hill whose hill moves about the map, for teams.
|
||||
base = "team_king"
|
||||
name = "Moving Hill"
|
||||
|
||||
[universal]
|
||||
teams = true
|
||||
score_to_win = 3
|
||||
respawn_time = 5
|
||||
radar = true
|
||||
|
||||
[options]
|
||||
time_limit = 15
|
||||
friendly_fire = "off"
|
||||
auto_team_balance = true
|
||||
|
||||
[king]
|
||||
moving_hill = true
|
||||
@@ -1,23 +0,0 @@
|
||||
# Free for all slayer to 25 kills, starting with a pistol and an assault rifle.
|
||||
base = "slayer"
|
||||
name = "Lone Wolves"
|
||||
|
||||
[universal]
|
||||
teams = false
|
||||
score_to_win = 25
|
||||
respawn_time = 3
|
||||
health = 100
|
||||
radar = false
|
||||
|
||||
[options]
|
||||
time_limit = 15
|
||||
radar_players = "none"
|
||||
loadout = "custom"
|
||||
primary_weapon = "pistol"
|
||||
secondary_weapon = "assault_rifle"
|
||||
team_vehicles = "pc"
|
||||
|
||||
[slayer]
|
||||
no_death_bonus = false
|
||||
no_kill_penalty = false
|
||||
kill_in_order = false
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
exec "$(dirname "$0")/halo" --server "$@"
|
||||
@@ -1,3 +0,0 @@
|
||||
# Not part of the packaged chart: unit tests and CI values files.
|
||||
tests/
|
||||
ci/
|
||||
@@ -1,17 +0,0 @@
|
||||
apiVersion: v2
|
||||
name: opence-server
|
||||
description: >-
|
||||
The OpenCE dedicated server: a headless Halo: Combat Evolved host that plays games one after
|
||||
another, with no window, sound or player of its own. The game data (maps) is mounted from a
|
||||
volume you provide.
|
||||
type: application
|
||||
version: 0.1.0
|
||||
kubeVersion: ">=1.29.0-0"
|
||||
# Informational only: which image runs is set by image.repository, image.tag and image.digest.
|
||||
appVersion: "latest"
|
||||
home: https://github.com/OpenCommunityEdition/OpenCE
|
||||
sources:
|
||||
- https://github.com/OpenCommunityEdition/OpenCE/tree/main/deploy/helm/opence-server
|
||||
keywords:
|
||||
- halo
|
||||
- game-server
|
||||
@@ -1,111 +0,0 @@
|
||||
# opence-server
|
||||
|
||||
The OpenCE dedicated server (`docs/dedicated_server.md`) on Kubernetes: one
|
||||
pod of the image `ghcr.io/opencommunityedition/opence-server`
|
||||
(`deploy/docker`), its tunnel port behind a UDP Service, its web page behind
|
||||
a ClusterIP Service, probes on `GET /healthz`, and a NetworkPolicy.
|
||||
|
||||
The game data is never in the image or the chart: give a volume that holds
|
||||
`maps/` from your own copy of the game.
|
||||
|
||||
## Quick start
|
||||
|
||||
```sh
|
||||
kubectl create namespace halo
|
||||
# a claim (or an NFS export) holding maps/, read-only is enough
|
||||
helm install halo deploy/helm/opence-server -n halo \
|
||||
--set gameData.existingClaim=halo-maps \
|
||||
--set server.name="My server" \
|
||||
--set persistence.enabled=true
|
||||
kubectl -n halo logs -f deploy/halo-opence-server
|
||||
```
|
||||
|
||||
The admin password of the web page is made at the first install and kept in
|
||||
the release's Secret (NOTES.txt prints the command that shows it), unless
|
||||
`web.password` or `web.existingSecret` gives one. Reach the page with
|
||||
`kubectl -n halo port-forward deploy/halo-opence-server 8080`, or put an
|
||||
Ingress with TLS in front of the `-web` Service (and allow its namespace
|
||||
in `networkPolicy.webFrom`).
|
||||
|
||||
## Values
|
||||
|
||||
`values.yaml` describes each value. Each one under `server`, `web`,
|
||||
`network` and `publisherKey` is one of the server's `HALO_*` variables:
|
||||
|
||||
| Value | Variable |
|
||||
| --- | --- |
|
||||
| `server.name` | `HALO_SERVER_NAME` (15 characters) |
|
||||
| `server.rotation` (a list) | `HALO_SERVER_ROTATION`, joined with commas |
|
||||
| `server.maxPlayers` | `HALO_SERVER_MAX_PLAYERS` |
|
||||
| `server.public` | `HALO_SERVER_PUBLIC` |
|
||||
| `server.lobbySeconds` | `HALO_SERVER_LOBBY_SECONDS` |
|
||||
| `server.motd` | `HALO_SERVER_MOTD` |
|
||||
| `server.logFormat` | `HALO_SERVER_LOG_FORMAT` |
|
||||
| `server.instance`, `server.region` | `HALO_SERVER_INSTANCE`, `HALO_SERVER_REGION` |
|
||||
| `server.masterPublish` | `HALO_SERVER_MASTER_PUBLISH` |
|
||||
| `server.password` | `HALO_SERVER_PASSWORD` (from a Secret) |
|
||||
| `publisherKey` | `HALO_SERVER_PUBLISHER_KEY` (from a Secret) |
|
||||
| `web.port` | `HALO_SERVER_WEB_PORT` (0: none, and no probes) |
|
||||
| `web.password`, `web.existingSecret` | `HALO_SERVER_WEB_PASSWORD` (from a Secret) |
|
||||
| `web.moderatorPassword` | `HALO_SERVER_WEB_MODERATOR_PASSWORD` (from a Secret) |
|
||||
| `network.tunnelPort` | `HALO_NET_TUNNEL_PORT` |
|
||||
| `network.publicAddress` | `HALO_NET_PUBLIC_ADDRESS` |
|
||||
| `customMaps` | `HALO_CUSTOM_MAPS_ROOT=/custom_maps` |
|
||||
|
||||
The chart also sets `HALO_SERVER=1`, `HALO_CONFIG_FILE=/state/config.toml`,
|
||||
`HALO_DATA_ROOT=/data`, `HALO_SAVE_ROOT=/state/saves`,
|
||||
`HALO_LOG_ROOT=/state/logs`, `HALO_SERVER_CONSOLE=false` (a pod has no
|
||||
standard input) and, with a web port, `HALO_SERVER_WEB_BIND=0.0.0.0` (the
|
||||
kubelet's probes reach the pod's address). Any other setting goes in
|
||||
`extraEnv`, which comes last and so overrides the chart's.
|
||||
|
||||
A variable the chart sets wins over `config.toml`, and neither `sv_set` nor
|
||||
the web page's settings can change it. So the values under `server` are
|
||||
unset by default (empty, `[]` or `null`): the chart then sets no variable,
|
||||
and the setting is `config.toml`'s (or the server's default, which
|
||||
`values.yaml` names), changeable from the web page and kept in the state
|
||||
volume. Give a value only for a setting you want fixed.
|
||||
|
||||
## Web password
|
||||
|
||||
With neither `web.password` nor `web.existingSecret`, the chart makes an
|
||||
admin password at the first install and keeps it in the release's Secret;
|
||||
on an upgrade it finds that Secret again with `lookup`. `helm template`,
|
||||
and GitOps tools that render with it (Argo CD, Flux's dry runs,
|
||||
Kustomize's Helm support), have no cluster to look in: each render makes a
|
||||
new password, and the Secret changes at every sync. There, create the Secret
|
||||
yourself and name it:
|
||||
|
||||
```sh
|
||||
kubectl -n halo create secret generic halo-web \
|
||||
--from-literal=web-password="$(openssl rand -base64 18)" \
|
||||
--from-literal=web-moderator-password="$(openssl rand -base64 18)"
|
||||
helm template halo deploy/helm/opence-server -n halo \
|
||||
--set gameData.existingClaim=halo-maps --set web.existingSecret=halo-web
|
||||
```
|
||||
|
||||
(or a SealedSecret or an External Secrets object of the same name).
|
||||
`web.key` and `web.moderatorKey` name its keys; the moderator's is
|
||||
optional.
|
||||
|
||||
## Networking
|
||||
|
||||
`service.type` is `LoadBalancer` with `externalTrafficPolicy: Local` by
|
||||
default, so that the server sees the players' own addresses (its bans and
|
||||
limits are by address). `NodePort` works too; `ClusterIP` is for tests. The
|
||||
tunnel's Service port and `network.tunnelPort` should be the same number, as
|
||||
the server offers its own port to joiners; behind a NAT that STUN cannot see
|
||||
through, give the forwarded address in `network.publicAddress`.
|
||||
|
||||
The NetworkPolicy lets anyone reach the tunnel port and only `webFrom` the
|
||||
web port, and lets the pod reach DNS, TCP 1883 (the MQTT brokers) and 443
|
||||
(the master servers) and any UDP port on public addresses.
|
||||
|
||||
## Tests
|
||||
|
||||
```sh
|
||||
helm lint deploy/helm/opence-server --strict -f deploy/helm/opence-server/ci/full-values.yaml
|
||||
helm unittest deploy/helm/opence-server
|
||||
```
|
||||
|
||||
`.github/workflows/server-image.yml` runs both.
|
||||
@@ -1,87 +0,0 @@
|
||||
# Every option the chart has, for lint and the schema check (not installed: the NFS server is made
|
||||
# up).
|
||||
image:
|
||||
tag: build-206@sha256:0000000000000000000000000000000000000000000000000000000000000000
|
||||
imagePullSecrets:
|
||||
- name: registry-credentials
|
||||
gameData:
|
||||
nfs:
|
||||
server: nfs.example.com
|
||||
path: /exports/halo
|
||||
subPath: xbox
|
||||
customMaps:
|
||||
existingClaim: halo-custom-maps
|
||||
server:
|
||||
name: Example server
|
||||
rotation: [bloodgulch:ctf_classic, sidewinder:team_slayer+score=50, hangemhigh:king_moving]
|
||||
maxPlayers: 24
|
||||
public: true
|
||||
lobbySeconds: 20
|
||||
motd: Welcome
|
||||
logFormat: json
|
||||
instance: eu-1
|
||||
region: eu
|
||||
masterPublish: true
|
||||
password:
|
||||
existingSecret: halo-join
|
||||
key: password
|
||||
publisherKey:
|
||||
existingSecret: halo-publisher
|
||||
key: seed
|
||||
web:
|
||||
port: 8080
|
||||
existingSecret: halo-web
|
||||
key: admin
|
||||
moderatorKey: moderator
|
||||
network:
|
||||
tunnelPort: 2303
|
||||
publicAddress: halo.example.com:2303
|
||||
extraEnv:
|
||||
- name: HALO_SERVER_EMPTY_SECONDS
|
||||
value: "60"
|
||||
persistence:
|
||||
enabled: true
|
||||
storageClass: standard
|
||||
annotations:
|
||||
example.com/keep: "true"
|
||||
service:
|
||||
type: LoadBalancer
|
||||
port: 2303
|
||||
nodePort: 30703
|
||||
annotations:
|
||||
example.com/address: 192.0.2.10
|
||||
externalTrafficPolicy: Local
|
||||
loadBalancerSourceRanges: [0.0.0.0/0]
|
||||
tolerations:
|
||||
- key: dedicated
|
||||
operator: Equal
|
||||
value: games
|
||||
effect: NoSchedule
|
||||
podAnnotations:
|
||||
example.com/scrape: "true"
|
||||
podLabels:
|
||||
team: games
|
||||
probes:
|
||||
liveness:
|
||||
periodSeconds: 30
|
||||
readiness:
|
||||
enabled: false
|
||||
networkPolicy:
|
||||
webFrom:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: ingress-nginx
|
||||
extraEgress:
|
||||
- to:
|
||||
- ipBlock:
|
||||
cidr: 203.0.113.0/24
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 8443
|
||||
extraObjects:
|
||||
- apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: '{{ .Release.Name }}-extra'
|
||||
data:
|
||||
hello: world
|
||||
@@ -1,6 +0,0 @@
|
||||
# The smallest install that renders: no maps (an emptyDir in their place), so the server exits with
|
||||
# code 2 and the pod goes into CrashLoopBackOff. A real install gives gameData.existingClaim or
|
||||
# gameData.nfs instead.
|
||||
gameData:
|
||||
volume:
|
||||
emptyDir: {}
|
||||
@@ -1,33 +0,0 @@
|
||||
OpenCE dedicated server {{ .Chart.Version }}: {{ include "opence-server.fullname" . }} in namespace {{ .Release.Namespace }}.
|
||||
|
||||
Rotation: {{ join ", " .Values.server.rotation | default "the server's default" }}.
|
||||
{{- if kindIs "invalid" .Values.server.public }}
|
||||
Listed in everyone's server browser{{ with .Values.server.name }} as "{{ . }}"{{ end }}, unless config.toml or the web page turns server.public off.
|
||||
{{- else if .Values.server.public }}
|
||||
Listed in everyone's server browser{{ with .Values.server.name }} as "{{ . }}"{{ end }}.
|
||||
{{- else }}
|
||||
Not listed: players join with the invite link from the log, or on the LAN.
|
||||
{{- end }}
|
||||
|
||||
The log (the ready line, players, games):
|
||||
|
||||
kubectl -n {{ .Release.Namespace }} logs -f deploy/{{ include "opence-server.fullname" . }}
|
||||
|
||||
Players reach UDP port {{ .Values.service.port }} through Service {{ include "opence-server.fullname" . }} ({{ .Values.service.type }}).
|
||||
{{- if eq .Values.service.type "ClusterIP" }}
|
||||
A ClusterIP Service is not reachable from outside the cluster: set service.type to LoadBalancer or
|
||||
NodePort for internet play.
|
||||
{{- end }}
|
||||
{{- if gt (int .Values.web.port) 0 }}
|
||||
|
||||
The web page, API and remote console:
|
||||
|
||||
kubectl -n {{ .Release.Namespace }} port-forward deploy/{{ include "opence-server.fullname" . }} {{ .Values.web.port }}
|
||||
open http://127.0.0.1:{{ .Values.web.port }}/
|
||||
{{- if not .Values.web.existingSecret }}
|
||||
|
||||
The admin password:
|
||||
|
||||
kubectl -n {{ .Release.Namespace }} get secret {{ include "opence-server.secretName" . }} -o jsonpath='{.data.{{ .Values.web.key }}}' | base64 -d
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -1,84 +0,0 @@
|
||||
{{/* The objects' name: fullnameOverride, else the release name if it contains the chart's name,
|
||||
else <release>-<chart>. */}}
|
||||
{{- define "opence-server.fullname" -}}
|
||||
{{- if .Values.fullnameOverride -}}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||
{{- if contains $name .Release.Name -}}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "opence-server.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "opence-server.labels" -}}
|
||||
{{ include "opence-server.selectorLabels" . }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "opence-server.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "opence-server.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/* repository:tag, repository:tag@digest, or repository@digest; an empty tag is the appVersion. */}}
|
||||
{{- define "opence-server.image" -}}
|
||||
{{- $image := .Values.image -}}
|
||||
{{- $ref := $image.repository -}}
|
||||
{{- $tag := toString ($image.tag | default .Chart.AppVersion) -}}
|
||||
{{- if $image.digest }}{{ $tag = regexReplaceAll "@.*$" $tag "" }}{{ if hasPrefix "sha256:" $tag }}{{ $tag = "" }}{{ end }}{{ end -}}
|
||||
{{- if hasPrefix "sha256:" $tag }}{{ $ref = printf "%s@%s" $ref $tag }}
|
||||
{{- else if $tag }}{{ $ref = printf "%s:%s" $ref $tag }}{{ end -}}
|
||||
{{- if and $image.digest (not (contains "@" $ref)) }}{{ $ref = printf "%s@%s" $ref $image.digest }}{{ end -}}
|
||||
{{- $ref -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "opence-server.stateClaim" -}}
|
||||
{{- .Values.persistence.existingClaim | default (printf "%s-state" (include "opence-server.fullname" .)) -}}
|
||||
{{- end }}
|
||||
|
||||
{{/* The chart's Secret: the web passwords it makes or is given, the join password, the publisher
|
||||
key. */}}
|
||||
{{- define "opence-server.secretName" -}}
|
||||
{{- printf "%s-secrets" (include "opence-server.fullname" .) -}}
|
||||
{{- end }}
|
||||
|
||||
{{/* The Secret holding the web password: web.existingSecret, else the chart's. */}}
|
||||
{{- define "opence-server.webSecret" -}}
|
||||
{{- .Values.web.existingSecret | default (include "opence-server.secretName" .) -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "opence-server.hasGameData" -}}
|
||||
{{- with .Values.gameData -}}
|
||||
{{- if or .existingClaim (and .nfs.server .nfs.path) .volume }}true{{ end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "opence-server.hasCustomMaps" -}}
|
||||
{{- with .Values.customMaps -}}
|
||||
{{- if or .existingClaim (and .nfs.server .nfs.path) .volume }}true{{ end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{/* A volume source of gameData or customMaps (the dict), read-only. */}}
|
||||
{{- define "opence-server.volumeSource" -}}
|
||||
{{- if .existingClaim }}
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ .existingClaim }}
|
||||
readOnly: true
|
||||
{{- else if and .nfs.server .nfs.path }}
|
||||
nfs:
|
||||
server: {{ .nfs.server }}
|
||||
path: {{ .nfs.path }}
|
||||
readOnly: true
|
||||
{{- else }}
|
||||
{{- toYaml .volume }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -1,198 +0,0 @@
|
||||
{{- if not (include "opence-server.hasGameData" .) }}
|
||||
{{- fail "gameData: set existingClaim, nfs.server and nfs.path, or volume - the server needs the game's maps, which are never in the image" }}
|
||||
{{- end }}
|
||||
{{- $fullname := include "opence-server.fullname" . }}
|
||||
{{- $secret := include "opence-server.secretName" . }}
|
||||
{{- $webPort := int .Values.web.port }}
|
||||
{{- $env := list }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER" "value" "1") }}
|
||||
{{- $env = append $env (dict "name" "HALO_CONFIG_FILE" "value" "/state/config.toml") }}
|
||||
{{- $env = append $env (dict "name" "HALO_DATA_ROOT" "value" "/data") }}
|
||||
{{- $env = append $env (dict "name" "HALO_SAVE_ROOT" "value" "/state/saves") }}
|
||||
{{- $env = append $env (dict "name" "HALO_LOG_ROOT" "value" "/state/logs") }}
|
||||
{{- if include "opence-server.hasCustomMaps" . }}
|
||||
{{- $env = append $env (dict "name" "HALO_CUSTOM_MAPS_ROOT" "value" "/custom_maps") }}
|
||||
{{- end }}
|
||||
{{- /* (a pod has no standard input to read commands from) */}}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_CONSOLE" "value" "false") }}
|
||||
{{- $env = append $env (dict "name" "HALO_NET_TUNNEL_PORT" "value" (toString (int .Values.network.tunnelPort))) }}
|
||||
{{- with .Values.network.publicAddress }}
|
||||
{{- $env = append $env (dict "name" "HALO_NET_PUBLIC_ADDRESS" "value" .) }}
|
||||
{{- end }}
|
||||
{{- with .Values.server.name }}
|
||||
{{- if gt (len .) 15 }}
|
||||
{{- fail "server.name: 15 characters at most" }}
|
||||
{{- end }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_NAME" "value" .) }}
|
||||
{{- end }}
|
||||
{{- with .Values.server.rotation }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_ROTATION" "value" (join ", " .)) }}
|
||||
{{- end }}
|
||||
{{- /* (a value left null is not set, so that config.toml, sv_set and the web page's settings can
|
||||
change it) */}}
|
||||
{{- if not (kindIs "invalid" .Values.server.maxPlayers) }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_MAX_PLAYERS" "value" (toString (int .Values.server.maxPlayers))) }}
|
||||
{{- end }}
|
||||
{{- if not (kindIs "invalid" .Values.server.public) }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_PUBLIC" "value" (toString .Values.server.public)) }}
|
||||
{{- end }}
|
||||
{{- if not (kindIs "invalid" .Values.server.lobbySeconds) }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_LOBBY_SECONDS" "value" (toString (int .Values.server.lobbySeconds))) }}
|
||||
{{- end }}
|
||||
{{- with .Values.server.motd }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_MOTD" "value" .) }}
|
||||
{{- end }}
|
||||
{{- with .Values.server.logFormat }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_LOG_FORMAT" "value" .) }}
|
||||
{{- end }}
|
||||
{{- with .Values.server.instance }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_INSTANCE" "value" .) }}
|
||||
{{- end }}
|
||||
{{- with .Values.server.region }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_REGION" "value" .) }}
|
||||
{{- end }}
|
||||
{{- if not (kindIs "invalid" .Values.server.masterPublish) }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_MASTER_PUBLISH" "value" (toString .Values.server.masterPublish)) }}
|
||||
{{- end }}
|
||||
{{- if .Values.server.password.existingSecret }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_PASSWORD" "valueFrom" (dict "secretKeyRef" (dict "name" .Values.server.password.existingSecret "key" .Values.server.password.key))) }}
|
||||
{{- else if .Values.server.password.value }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_PASSWORD" "valueFrom" (dict "secretKeyRef" (dict "name" $secret "key" .Values.server.password.key))) }}
|
||||
{{- end }}
|
||||
{{- if .Values.publisherKey.existingSecret }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_PUBLISHER_KEY" "valueFrom" (dict "secretKeyRef" (dict "name" .Values.publisherKey.existingSecret "key" .Values.publisherKey.key))) }}
|
||||
{{- else if .Values.publisherKey.value }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_PUBLISHER_KEY" "valueFrom" (dict "secretKeyRef" (dict "name" $secret "key" .Values.publisherKey.key))) }}
|
||||
{{- end }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_WEB_PORT" "value" (toString $webPort)) }}
|
||||
{{- if gt $webPort 0 }}
|
||||
{{- /* (the kubelet's probes reach the pod's own address, not its loopback) */}}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_WEB_BIND" "value" "0.0.0.0") }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_WEB_PASSWORD" "valueFrom" (dict "secretKeyRef" (dict "name" (include "opence-server.webSecret" .) "key" .Values.web.key))) }}
|
||||
{{- if .Values.web.existingSecret }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_WEB_MODERATOR_PASSWORD" "valueFrom" (dict "secretKeyRef" (dict "name" .Values.web.existingSecret "key" .Values.web.moderatorKey "optional" true))) }}
|
||||
{{- else if .Values.web.moderatorPassword }}
|
||||
{{- $env = append $env (dict "name" "HALO_SERVER_WEB_MODERATOR_PASSWORD" "valueFrom" (dict "secretKeyRef" (dict "name" $secret "key" .Values.web.moderatorKey))) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $probe := dict "httpGet" (dict "path" "/healthz" "port" "web") }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ $fullname }}
|
||||
labels:
|
||||
{{- include "opence-server.labels" . | nindent 4 }}
|
||||
spec:
|
||||
# One server owns the tunnel port and the address players reach it at.
|
||||
replicas: 1
|
||||
strategy:
|
||||
{{- toYaml .Values.strategy | nindent 4 }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "opence-server.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "opence-server.selectorLabels" . | nindent 8 }}
|
||||
{{- with .Values.podLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.podAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
# The server never calls the Kubernetes API.
|
||||
automountServiceAccountToken: false
|
||||
enableServiceLinks: false
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.priorityClassName }}
|
||||
priorityClassName: {{ . }}
|
||||
{{- end }}
|
||||
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: opence-server
|
||||
image: {{ include "opence-server.image" . | quote }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
env:
|
||||
{{- toYaml $env | nindent 12 }}
|
||||
{{- with .Values.extraEnv }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: tunnel
|
||||
containerPort: {{ .Values.network.tunnelPort }}
|
||||
protocol: UDP
|
||||
{{- if gt $webPort 0 }}
|
||||
- name: web
|
||||
containerPort: {{ $webPort }}
|
||||
protocol: TCP
|
||||
{{- end }}
|
||||
{{- if gt $webPort 0 }}
|
||||
{{- range $name := list "startup" "readiness" "liveness" }}
|
||||
{{- $p := index $.Values.probes $name }}
|
||||
{{- if $p.enabled }}
|
||||
{{ $name }}Probe:
|
||||
{{- toYaml (merge (omit $p "enabled") $probe) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.securityContext | nindent 12 }}
|
||||
volumeMounts:
|
||||
- name: game-data
|
||||
mountPath: /data
|
||||
readOnly: true
|
||||
{{- with .Values.gameData.subPath }}
|
||||
subPath: {{ . }}
|
||||
{{- end }}
|
||||
# config.toml, publisher.key, the save root and its map cache, the logs
|
||||
- name: state
|
||||
mountPath: /state
|
||||
{{- if include "opence-server.hasCustomMaps" . }}
|
||||
- name: custom-maps
|
||||
mountPath: /custom_maps
|
||||
readOnly: true
|
||||
{{- with .Values.customMaps.subPath }}
|
||||
subPath: {{ . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
volumes:
|
||||
- name: game-data
|
||||
{{- include "opence-server.volumeSource" .Values.gameData | trim | nindent 10 }}
|
||||
- name: state
|
||||
{{- if .Values.persistence.enabled }}
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ include "opence-server.stateClaim" . }}
|
||||
{{- else }}
|
||||
emptyDir:
|
||||
sizeLimit: {{ .Values.persistence.emptyDirSizeLimit }}
|
||||
{{- end }}
|
||||
- name: tmp
|
||||
emptyDir:
|
||||
sizeLimit: 64Mi
|
||||
{{- if include "opence-server.hasCustomMaps" . }}
|
||||
- name: custom-maps
|
||||
{{- include "opence-server.volumeSource" .Values.customMaps | trim | nindent 10 }}
|
||||
{{- end }}
|
||||
@@ -1,4 +0,0 @@
|
||||
{{- range .Values.extraObjects }}
|
||||
---
|
||||
{{ tpl (toYaml .) $ }}
|
||||
{{- end }}
|
||||
@@ -1,66 +0,0 @@
|
||||
{{- if .Values.networkPolicy.enabled }}
|
||||
{{- $np := .Values.networkPolicy }}
|
||||
# In: the players' UDP on the tunnel port, and the web port from webFrom alone. Out: DNS, TCP to
|
||||
# the MQTT brokers and the master servers, UDP to the internet (STUN, the players' ports); nothing
|
||||
# on the private ranges.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: {{ include "opence-server.fullname" . }}
|
||||
labels:
|
||||
{{- include "opence-server.labels" . | nindent 4 }}
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
{{- include "opence-server.selectorLabels" . | nindent 6 }}
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
ingress:
|
||||
- ports:
|
||||
- protocol: UDP
|
||||
port: {{ .Values.network.tunnelPort }}
|
||||
{{- with $np.from }}
|
||||
from:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if and $np.webFrom (gt (int .Values.web.port) 0) }}
|
||||
- ports:
|
||||
- protocol: TCP
|
||||
port: {{ .Values.web.port }}
|
||||
from:
|
||||
{{- toYaml $np.webFrom | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with $np.extraIngress }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
egress:
|
||||
- to:
|
||||
{{- toYaml $np.dns.to | nindent 8 }}
|
||||
ports:
|
||||
- protocol: UDP
|
||||
port: 53
|
||||
- protocol: TCP
|
||||
port: 53
|
||||
{{- if or $np.internet.tcpPorts $np.internet.udp }}
|
||||
- to:
|
||||
- ipBlock:
|
||||
cidr: {{ $np.internet.cidr }}
|
||||
{{- with $np.internet.except }}
|
||||
except:
|
||||
{{- toYaml . | nindent 14 }}
|
||||
{{- end }}
|
||||
ports:
|
||||
{{- range $np.internet.tcpPorts }}
|
||||
- protocol: TCP
|
||||
port: {{ . }}
|
||||
{{- end }}
|
||||
{{- if $np.internet.udp }}
|
||||
# every UDP port: STUN (19302, 3478) and the players' own
|
||||
- protocol: UDP
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with $np.extraEgress }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -1,44 +0,0 @@
|
||||
{{- $data := dict }}
|
||||
{{- if and (gt (int .Values.web.port) 0) (not .Values.web.existingSecret) }}
|
||||
{{- $password := .Values.web.password }}
|
||||
{{- if $password }}
|
||||
{{- if lt (len $password) 8 }}
|
||||
{{- fail "web.password: 8 characters or more (the server refuses a shorter one beyond loopback)" }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- /* made once, then kept from the Secret the release already has */}}
|
||||
{{- $existing := lookup "v1" "Secret" .Release.Namespace (include "opence-server.secretName" .) }}
|
||||
{{- if and $existing $existing.data (hasKey $existing.data .Values.web.key) }}
|
||||
{{- $password = index $existing.data .Values.web.key | b64dec }}
|
||||
{{- else }}
|
||||
{{- $password = randAlphaNum 24 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $_ := set $data .Values.web.key ($password | b64enc) }}
|
||||
{{- with .Values.web.moderatorPassword }}
|
||||
{{- if lt (len .) 8 }}
|
||||
{{- fail "web.moderatorPassword: 8 characters or more" }}
|
||||
{{- end }}
|
||||
{{- $_ := set $data $.Values.web.moderatorKey (. | b64enc) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if and .Values.server.password.value (not .Values.server.password.existingSecret) }}
|
||||
{{- $_ := set $data .Values.server.password.key (.Values.server.password.value | b64enc) }}
|
||||
{{- end }}
|
||||
{{- if and .Values.publisherKey.value (not .Values.publisherKey.existingSecret) }}
|
||||
{{- if not (regexMatch "^[0-9a-f]{64}$" .Values.publisherKey.value) }}
|
||||
{{- fail "publisherKey.value: the 64 lower-case hex characters of the seed (halo --server --keygen)" }}
|
||||
{{- end }}
|
||||
{{- $_ := set $data .Values.publisherKey.key (.Values.publisherKey.value | b64enc) }}
|
||||
{{- end }}
|
||||
{{- if $data }}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ include "opence-server.secretName" . }}
|
||||
labels:
|
||||
{{- include "opence-server.labels" . | nindent 4 }}
|
||||
type: Opaque
|
||||
data:
|
||||
{{- toYaml $data | nindent 2 }}
|
||||
{{- end }}
|
||||
@@ -1,23 +0,0 @@
|
||||
{{- if and .Values.web.service.enabled (gt (int .Values.web.port) 0) }}
|
||||
# The web page, its API and the remote console, inside the cluster only: for an Ingress with TLS,
|
||||
# or kubectl port-forward.
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "opence-server.fullname" . }}-web
|
||||
labels:
|
||||
{{- include "opence-server.labels" . | nindent 4 }}
|
||||
{{- with .Values.web.service.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
{{- include "opence-server.selectorLabels" . | nindent 4 }}
|
||||
ports:
|
||||
- name: web
|
||||
port: {{ .Values.web.service.port }}
|
||||
targetPort: web
|
||||
protocol: TCP
|
||||
{{- end }}
|
||||
@@ -1,40 +0,0 @@
|
||||
# The tunnel port, UDP: the one port players need.
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "opence-server.fullname" . }}
|
||||
labels:
|
||||
{{- include "opence-server.labels" . | nindent 4 }}
|
||||
{{- with .Values.service.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with .Values.service.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
{{- if ne .Values.service.type "ClusterIP" }}
|
||||
{{- with .Values.service.externalTrafficPolicy }}
|
||||
externalTrafficPolicy: {{ . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .Values.service.type "LoadBalancer" }}
|
||||
{{- with .Values.service.loadBalancerClass }}
|
||||
loadBalancerClass: {{ . }}
|
||||
{{- end }}
|
||||
{{- with .Values.service.loadBalancerSourceRanges }}
|
||||
loadBalancerSourceRanges:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
selector:
|
||||
{{- include "opence-server.selectorLabels" . | nindent 4 }}
|
||||
ports:
|
||||
- name: tunnel
|
||||
port: {{ .Values.service.port }}
|
||||
targetPort: tunnel
|
||||
protocol: UDP
|
||||
{{- if and (ne .Values.service.type "ClusterIP") .Values.service.nodePort }}
|
||||
nodePort: {{ .Values.service.nodePort }}
|
||||
{{- end }}
|
||||
@@ -1,21 +0,0 @@
|
||||
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: {{ include "opence-server.stateClaim" . }}
|
||||
labels:
|
||||
{{- include "opence-server.labels" . | nindent 4 }}
|
||||
{{- with .Values.persistence.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
accessModes:
|
||||
{{- toYaml .Values.persistence.accessModes | nindent 4 }}
|
||||
{{- with .Values.persistence.storageClass }}
|
||||
storageClassName: {{ . }}
|
||||
{{- end }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.persistence.size }}
|
||||
{{- end }}
|
||||
@@ -1,221 +0,0 @@
|
||||
suite: deployment
|
||||
templates:
|
||||
- templates/deployment.yaml
|
||||
set:
|
||||
gameData.existingClaim: halo-maps
|
||||
tests:
|
||||
- it: refuses to render without game data, which is never in the image
|
||||
set:
|
||||
gameData.existingClaim: ""
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: "gameData: set existingClaim"
|
||||
|
||||
- it: mounts an existing claim read-only at /data
|
||||
asserts:
|
||||
- equal:
|
||||
path: 'spec.template.spec.volumes[0]'
|
||||
value: { name: game-data, persistentVolumeClaim: { claimName: halo-maps, readOnly: true } }
|
||||
- contains:
|
||||
path: 'spec.template.spec.containers[0].volumeMounts'
|
||||
content: { name: game-data, mountPath: /data, readOnly: true }
|
||||
|
||||
- it: mounts an NFS export read-only, with a subPath
|
||||
set:
|
||||
gameData: { existingClaim: "", nfs: { server: nfs.example.com, path: /halo }, subPath: xbox }
|
||||
asserts:
|
||||
- equal:
|
||||
path: 'spec.template.spec.volumes[0]'
|
||||
value: { name: game-data, nfs: { server: nfs.example.com, path: /halo, readOnly: true } }
|
||||
- contains:
|
||||
path: 'spec.template.spec.containers[0].volumeMounts'
|
||||
content: { name: game-data, mountPath: /data, readOnly: true, subPath: xbox }
|
||||
|
||||
- it: takes any other volume source
|
||||
set:
|
||||
gameData: { existingClaim: "", volume: { emptyDir: {} } }
|
||||
asserts:
|
||||
- equal:
|
||||
path: 'spec.template.spec.volumes[0]'
|
||||
value: { name: game-data, emptyDir: {} }
|
||||
|
||||
- it: runs one replica, replaced not rolled, hardened
|
||||
asserts:
|
||||
- equal: { path: spec.replicas, value: 1 }
|
||||
- equal: { path: spec.strategy.type, value: Recreate }
|
||||
- equal: { path: spec.template.spec.automountServiceAccountToken, value: false }
|
||||
- equal: { path: spec.template.spec.securityContext.runAsNonRoot, value: true }
|
||||
- equal: { path: spec.template.spec.securityContext.runAsUser, value: 10001 }
|
||||
- equal: { path: spec.template.spec.securityContext.seccompProfile.type, value: RuntimeDefault }
|
||||
- equal: { path: 'spec.template.spec.containers[0].securityContext.readOnlyRootFilesystem', value: true }
|
||||
- equal: { path: 'spec.template.spec.containers[0].securityContext.allowPrivilegeEscalation', value: false }
|
||||
- equal: { path: 'spec.template.spec.containers[0].securityContext.capabilities.drop', value: [ALL] }
|
||||
- equal: { path: spec.template.spec.nodeSelector, value: { kubernetes.io/os: linux, kubernetes.io/arch: amd64 } }
|
||||
- equal: { path: spec.template.spec.terminationGracePeriodSeconds, value: 15 }
|
||||
- exists: { path: 'spec.template.spec.containers[0].resources.limits.memory' }
|
||||
|
||||
- it: sets the server's paths and mode
|
||||
asserts:
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER, value: "1" } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_CONFIG_FILE, value: /state/config.toml } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_DATA_ROOT, value: /data } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SAVE_ROOT, value: /state/saves } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_LOG_ROOT, value: /state/logs } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_CONSOLE, value: "false" } }
|
||||
|
||||
- it: maps the values to the HALO_ variables
|
||||
set:
|
||||
server:
|
||||
name: Test server
|
||||
rotation: [bloodgulch:ctf, "sidewinder:team_slayer+score=50"]
|
||||
maxPlayers: 24
|
||||
public: false
|
||||
lobbySeconds: 30
|
||||
motd: Hello
|
||||
logFormat: json
|
||||
instance: eu-1
|
||||
region: eu
|
||||
masterPublish: false
|
||||
network: { tunnelPort: 2303, publicAddress: "halo.example.com:2303" }
|
||||
asserts:
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_NAME, value: Test server } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_ROTATION, value: "bloodgulch:ctf, sidewinder:team_slayer+score=50" } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_MAX_PLAYERS, value: "24" } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_PUBLIC, value: "false" } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_LOBBY_SECONDS, value: "30" } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_MOTD, value: Hello } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_LOG_FORMAT, value: json } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_INSTANCE, value: eu-1 } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_REGION, value: eu } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_MASTER_PUBLISH, value: "false" } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_NET_TUNNEL_PORT, value: "2303" } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_NET_PUBLIC_ADDRESS, value: "halo.example.com:2303" } }
|
||||
- equal: { path: 'spec.template.spec.containers[0].ports[0]', value: { name: tunnel, containerPort: 2303, protocol: UDP } }
|
||||
|
||||
- it: leaves empty values to config.toml
|
||||
asserts:
|
||||
- notContains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_NAME, value: "" } }
|
||||
- notContains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_MOTD, value: "" } }
|
||||
- notContains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_NET_PUBLIC_ADDRESS, value: "" } }
|
||||
|
||||
- it: leaves the settings the values do not give to config.toml, sv_set and the web page
|
||||
asserts:
|
||||
- notExists: { path: 'spec.template.spec.containers[0].env[?(@.name == "HALO_SERVER_ROTATION")]' }
|
||||
- notExists: { path: 'spec.template.spec.containers[0].env[?(@.name == "HALO_SERVER_MAX_PLAYERS")]' }
|
||||
- notExists: { path: 'spec.template.spec.containers[0].env[?(@.name == "HALO_SERVER_PUBLIC")]' }
|
||||
- notExists: { path: 'spec.template.spec.containers[0].env[?(@.name == "HALO_SERVER_LOBBY_SECONDS")]' }
|
||||
- notExists: { path: 'spec.template.spec.containers[0].env[?(@.name == "HALO_SERVER_LOG_FORMAT")]' }
|
||||
- notExists: { path: 'spec.template.spec.containers[0].env[?(@.name == "HALO_SERVER_MASTER_PUBLISH")]' }
|
||||
|
||||
- it: sets a false or zero value that is given
|
||||
set:
|
||||
server: { public: false, masterPublish: false, lobbySeconds: 0 }
|
||||
asserts:
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_PUBLIC, value: "false" } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_MASTER_PUBLISH, value: "false" } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_LOBBY_SECONDS, value: "0" } }
|
||||
|
||||
- it: refuses a name longer than the game's 15 characters (the values' schema, or the template)
|
||||
set:
|
||||
server.name: "A name too long!"
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: "server.name|/server/name|15 characters"
|
||||
|
||||
- it: takes the web password from the chart's Secret, bound beyond loopback for the probes
|
||||
release: { name: opence-server }
|
||||
asserts:
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_WEB_PORT, value: "8080" } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_WEB_BIND, value: 0.0.0.0 } }
|
||||
- contains:
|
||||
path: 'spec.template.spec.containers[0].env'
|
||||
content: { name: HALO_SERVER_WEB_PASSWORD, valueFrom: { secretKeyRef: { name: opence-server-secrets, key: web-password } } }
|
||||
- contains: { path: 'spec.template.spec.containers[0].ports', content: { name: web, containerPort: 8080, protocol: TCP } }
|
||||
|
||||
- it: takes the passwords and the publisher key from existing Secrets
|
||||
set:
|
||||
web: { existingSecret: halo-web, key: admin, moderatorKey: moderator }
|
||||
server.password: { existingSecret: halo-join, key: password }
|
||||
publisherKey: { existingSecret: halo-publisher, key: seed }
|
||||
asserts:
|
||||
- contains:
|
||||
path: 'spec.template.spec.containers[0].env'
|
||||
content: { name: HALO_SERVER_WEB_PASSWORD, valueFrom: { secretKeyRef: { name: halo-web, key: admin } } }
|
||||
- contains:
|
||||
path: 'spec.template.spec.containers[0].env'
|
||||
content: { name: HALO_SERVER_WEB_MODERATOR_PASSWORD, valueFrom: { secretKeyRef: { name: halo-web, key: moderator, optional: true } } }
|
||||
- contains:
|
||||
path: 'spec.template.spec.containers[0].env'
|
||||
content: { name: HALO_SERVER_PASSWORD, valueFrom: { secretKeyRef: { name: halo-join, key: password } } }
|
||||
- contains:
|
||||
path: 'spec.template.spec.containers[0].env'
|
||||
content: { name: HALO_SERVER_PUBLISHER_KEY, valueFrom: { secretKeyRef: { name: halo-publisher, key: seed } } }
|
||||
|
||||
- it: probes GET /healthz on the web port
|
||||
asserts:
|
||||
- equal: { path: 'spec.template.spec.containers[0].startupProbe.httpGet', value: { path: /healthz, port: web } }
|
||||
- equal: { path: 'spec.template.spec.containers[0].readinessProbe.httpGet', value: { path: /healthz, port: web } }
|
||||
- equal: { path: 'spec.template.spec.containers[0].livenessProbe.httpGet', value: { path: /healthz, port: web } }
|
||||
- equal: { path: 'spec.template.spec.containers[0].startupProbe.failureThreshold', value: 60 }
|
||||
|
||||
- it: drops a probe that is turned off
|
||||
set:
|
||||
probes.liveness.enabled: false
|
||||
asserts:
|
||||
- notExists: { path: 'spec.template.spec.containers[0].livenessProbe' }
|
||||
- exists: { path: 'spec.template.spec.containers[0].readinessProbe' }
|
||||
|
||||
- it: has no web port, password or probes with web.port 0
|
||||
set:
|
||||
web.port: 0
|
||||
asserts:
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_WEB_PORT, value: "0" } }
|
||||
- notContains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_SERVER_WEB_BIND, value: 0.0.0.0 } }
|
||||
- lengthEqual: { path: 'spec.template.spec.containers[0].ports', count: 1 }
|
||||
- notExists: { path: 'spec.template.spec.containers[0].startupProbe' }
|
||||
- notExists: { path: 'spec.template.spec.containers[0].livenessProbe' }
|
||||
|
||||
- it: puts extraEnv after the chart's variables, so it can override them
|
||||
set:
|
||||
extraEnv: [{ name: HALO_SERVER_LOBBY_SECONDS, value: "5" }]
|
||||
asserts:
|
||||
- equal:
|
||||
path: 'spec.template.spec.containers[0].env[-1:]'
|
||||
value: { name: HALO_SERVER_LOBBY_SECONDS, value: "5" }
|
||||
|
||||
- it: keeps the state in an emptyDir without persistence
|
||||
asserts:
|
||||
- contains: { path: spec.template.spec.volumes, content: { name: state, emptyDir: { sizeLimit: 1Gi } } }
|
||||
- lengthEqual: { path: spec.template.spec.volumes, count: 3 }
|
||||
|
||||
- it: uses the claim with persistence
|
||||
release: { name: opence-server }
|
||||
set:
|
||||
persistence.enabled: true
|
||||
asserts:
|
||||
- contains: { path: spec.template.spec.volumes, content: { name: state, persistentVolumeClaim: { claimName: opence-server-state } } }
|
||||
|
||||
- it: mounts a custom_maps claim read-only, with its variable
|
||||
set:
|
||||
customMaps: { existingClaim: halo-custom-maps, subPath: ce }
|
||||
asserts:
|
||||
- contains: { path: 'spec.template.spec.containers[0].env', content: { name: HALO_CUSTOM_MAPS_ROOT, value: /custom_maps } }
|
||||
- contains:
|
||||
path: spec.template.spec.volumes
|
||||
content: { name: custom-maps, persistentVolumeClaim: { claimName: halo-custom-maps, readOnly: true } }
|
||||
- contains:
|
||||
path: 'spec.template.spec.containers[0].volumeMounts'
|
||||
content: { name: custom-maps, mountPath: /custom_maps, readOnly: true, subPath: ce }
|
||||
|
||||
- it: takes a tag with a digest, and lets digest replace it
|
||||
set:
|
||||
image.tag: build-206@sha256:1111111111111111111111111111111111111111111111111111111111111111
|
||||
image.digest: sha256:2222222222222222222222222222222222222222222222222222222222222222
|
||||
asserts:
|
||||
- equal:
|
||||
path: 'spec.template.spec.containers[0].image'
|
||||
value: ghcr.io/opencommunityedition/opence-server:build-206@sha256:2222222222222222222222222222222222222222222222222222222222222222
|
||||
|
||||
- it: uses the appVersion as the default tag
|
||||
asserts:
|
||||
- equal: { path: 'spec.template.spec.containers[0].image', value: "ghcr.io/opencommunityedition/opence-server:latest" }
|
||||
@@ -1,39 +0,0 @@
|
||||
suite: network policy
|
||||
templates:
|
||||
- templates/networkpolicy.yaml
|
||||
tests:
|
||||
- it: lets anyone reach the tunnel port, and nothing else in
|
||||
asserts:
|
||||
- equal: { path: spec.policyTypes, value: [Ingress, Egress] }
|
||||
- equal: { path: spec.ingress, value: [{ ports: [{ protocol: UDP, port: 2302 }] }] }
|
||||
|
||||
- it: allows DNS, TCP 1883 and 443 and all UDP to public addresses only
|
||||
asserts:
|
||||
- equal: { path: 'spec.egress[0].ports', value: [{ protocol: UDP, port: 53 }, { protocol: TCP, port: 53 }] }
|
||||
- equal: { path: 'spec.egress[1].to[0].ipBlock.cidr', value: 0.0.0.0/0 }
|
||||
- contains: { path: 'spec.egress[1].to[0].ipBlock.except', content: 10.0.0.0/8 }
|
||||
- contains: { path: 'spec.egress[1].to[0].ipBlock.except', content: 192.168.0.0/16 }
|
||||
- equal: { path: 'spec.egress[1].ports', value: [{ protocol: TCP, port: 1883 }, { protocol: TCP, port: 443 }, { protocol: UDP }] }
|
||||
|
||||
- it: lets webFrom reach the web port
|
||||
set:
|
||||
networkPolicy.webFrom: [{ namespaceSelector: { matchLabels: { kubernetes.io/metadata.name: ingress-nginx } } }]
|
||||
asserts:
|
||||
- equal:
|
||||
path: 'spec.ingress[1]'
|
||||
value: { ports: [{ protocol: TCP, port: 8080 }], from: [{ namespaceSelector: { matchLabels: { kubernetes.io/metadata.name: ingress-nginx } } }] }
|
||||
|
||||
- it: narrows the players' sources and follows the tunnel port
|
||||
set:
|
||||
network.tunnelPort: 2303
|
||||
networkPolicy.from: [{ ipBlock: { cidr: 198.51.100.0/24 } }]
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.ingress
|
||||
value: [{ ports: [{ protocol: UDP, port: 2303 }], from: [{ ipBlock: { cidr: 198.51.100.0/24 } }] }]
|
||||
|
||||
- it: renders nothing when off
|
||||
set:
|
||||
networkPolicy.enabled: false
|
||||
asserts:
|
||||
- hasDocuments: { count: 0 }
|
||||
@@ -1,21 +0,0 @@
|
||||
suite: persistence
|
||||
templates:
|
||||
- templates/state-pvc.yaml
|
||||
release:
|
||||
name: opence-server
|
||||
tests:
|
||||
- it: makes no claim without persistence
|
||||
asserts:
|
||||
- hasDocuments: { count: 0 }
|
||||
- it: makes the state claim with persistence
|
||||
set:
|
||||
persistence: { enabled: true, size: 3Gi, storageClass: fast }
|
||||
asserts:
|
||||
- equal: { path: metadata.name, value: opence-server-state }
|
||||
- equal: { path: spec.resources.requests.storage, value: 3Gi }
|
||||
- equal: { path: spec.storageClassName, value: fast }
|
||||
- it: makes none for an existing claim
|
||||
set:
|
||||
persistence: { enabled: true, existingClaim: mine }
|
||||
asserts:
|
||||
- hasDocuments: { count: 0 }
|
||||
@@ -1,48 +0,0 @@
|
||||
suite: secret
|
||||
templates:
|
||||
- templates/secret.yaml
|
||||
release:
|
||||
name: opence-server
|
||||
tests:
|
||||
- it: makes a web password when none is given
|
||||
asserts:
|
||||
- hasDocuments: { count: 1 }
|
||||
- isKind: { of: Secret }
|
||||
- equal: { path: metadata.name, value: opence-server-secrets }
|
||||
- matchRegex: { path: data.web-password, pattern: "^[A-Za-z0-9+/]{32}$" }
|
||||
|
||||
- it: keeps a given web password, join password and publisher key
|
||||
set:
|
||||
web.password: correct-horse
|
||||
server.password.value: letmein
|
||||
publisherKey.value: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
|
||||
asserts:
|
||||
- equal: { path: data.web-password, value: Y29ycmVjdC1ob3JzZQ== }
|
||||
- equal: { path: data.password, value: bGV0bWVpbg== }
|
||||
- exists: { path: data.publisher-key }
|
||||
|
||||
- it: refuses a short web password
|
||||
set:
|
||||
web.password: short
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: "8 characters or more"
|
||||
|
||||
- it: refuses a publisher key that is not 64 hex characters
|
||||
set:
|
||||
publisherKey.value: not-a-key
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: "64 lower-case hex"
|
||||
|
||||
- it: makes none when every secret comes from elsewhere
|
||||
set:
|
||||
web.existingSecret: halo-web
|
||||
asserts:
|
||||
- hasDocuments: { count: 0 }
|
||||
|
||||
- it: makes none without a web port or secrets
|
||||
set:
|
||||
web.port: 0
|
||||
asserts:
|
||||
- hasDocuments: { count: 0 }
|
||||
@@ -1,43 +0,0 @@
|
||||
suite: service
|
||||
templates:
|
||||
- templates/service.yaml
|
||||
- templates/service-web.yaml
|
||||
release:
|
||||
name: opence-server
|
||||
tests:
|
||||
- it: exposes the tunnel port over UDP on a load balancer that keeps the players' addresses
|
||||
template: templates/service.yaml
|
||||
asserts:
|
||||
- equal: { path: metadata.name, value: opence-server }
|
||||
- equal: { path: spec.type, value: LoadBalancer }
|
||||
- equal: { path: spec.externalTrafficPolicy, value: Local }
|
||||
- equal: { path: 'spec.ports[0]', value: { name: tunnel, port: 2302, targetPort: tunnel, protocol: UDP } }
|
||||
|
||||
- it: ignores externalTrafficPolicy and nodePort on a ClusterIP Service
|
||||
template: templates/service.yaml
|
||||
set:
|
||||
service: { type: ClusterIP, nodePort: 30702 }
|
||||
asserts:
|
||||
- notExists: { path: spec.externalTrafficPolicy }
|
||||
- notExists: { path: 'spec.ports[0].nodePort' }
|
||||
|
||||
- it: sets a fixed node port
|
||||
template: templates/service.yaml
|
||||
set:
|
||||
service: { type: NodePort, nodePort: 30702 }
|
||||
asserts:
|
||||
- equal: { path: 'spec.ports[0].nodePort', value: 30702 }
|
||||
|
||||
- it: keeps the web port inside the cluster
|
||||
template: templates/service-web.yaml
|
||||
asserts:
|
||||
- equal: { path: metadata.name, value: opence-server-web }
|
||||
- equal: { path: spec.type, value: ClusterIP }
|
||||
- equal: { path: 'spec.ports[0]', value: { name: web, port: 8080, targetPort: web, protocol: TCP } }
|
||||
|
||||
- it: has no web Service without a web port
|
||||
template: templates/service-web.yaml
|
||||
set:
|
||||
web.port: 0
|
||||
asserts:
|
||||
- hasDocuments: { count: 0 }
|
||||
@@ -1,445 +0,0 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft-07/schema#",
|
||||
"title": "opence-server values",
|
||||
"description": "Strict where the chart defines the structure; free-form where values pass through to Kubernetes. values.yaml describes each value.",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"definitions": {
|
||||
"port": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 65535
|
||||
},
|
||||
"volume": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"existingClaim": {
|
||||
"type": "string"
|
||||
},
|
||||
"nfs": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"server": {
|
||||
"type": "string"
|
||||
},
|
||||
"path": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"volume": {
|
||||
"type": "object"
|
||||
},
|
||||
"subPath": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"secretValue": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"value": {
|
||||
"type": "string"
|
||||
},
|
||||
"existingSecret": {
|
||||
"type": "string"
|
||||
},
|
||||
"key": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"probe": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"initialDelaySeconds": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"periodSeconds": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"timeoutSeconds": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"failureThreshold": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"successThreshold": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"terminationGracePeriodSeconds": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"global": {
|
||||
"type": "object"
|
||||
},
|
||||
"nameOverride": {
|
||||
"type": "string"
|
||||
},
|
||||
"fullnameOverride": {
|
||||
"type": "string"
|
||||
},
|
||||
"image": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"repository"
|
||||
],
|
||||
"properties": {
|
||||
"repository": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"tag": {
|
||||
"type": [
|
||||
"string",
|
||||
"number"
|
||||
]
|
||||
},
|
||||
"digest": {
|
||||
"type": "string",
|
||||
"pattern": "^(sha256:[0-9a-f]{64})?$"
|
||||
},
|
||||
"pullPolicy": {
|
||||
"enum": [
|
||||
"Always",
|
||||
"IfNotPresent",
|
||||
"Never"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"imagePullSecrets": {
|
||||
"type": "array"
|
||||
},
|
||||
"gameData": {
|
||||
"$ref": "#/definitions/volume"
|
||||
},
|
||||
"customMaps": {
|
||||
"$ref": "#/definitions/volume"
|
||||
},
|
||||
"server": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"maxLength": 15,
|
||||
"pattern": "^[ -~]*$"
|
||||
},
|
||||
"rotation": {
|
||||
"type": "array",
|
||||
"maxItems": 64,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"maxPlayers": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"minimum": 2,
|
||||
"maximum": 127
|
||||
},
|
||||
"public": {
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"lobbySeconds": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"minimum": 0,
|
||||
"maximum": 300
|
||||
},
|
||||
"motd": {
|
||||
"type": "string",
|
||||
"maxLength": 127
|
||||
},
|
||||
"logFormat": {
|
||||
"enum": [
|
||||
"",
|
||||
"text",
|
||||
"json",
|
||||
null
|
||||
]
|
||||
},
|
||||
"instance": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z0-9_-]{0,32}$"
|
||||
},
|
||||
"region": {
|
||||
"type": "string",
|
||||
"maxLength": 16
|
||||
},
|
||||
"masterPublish": {
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"password": {
|
||||
"$ref": "#/definitions/secretValue"
|
||||
}
|
||||
}
|
||||
},
|
||||
"publisherKey": {
|
||||
"$ref": "#/definitions/secretValue"
|
||||
},
|
||||
"web": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"port": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 65535
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"existingSecret": {
|
||||
"type": "string"
|
||||
},
|
||||
"key": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"moderatorPassword": {
|
||||
"type": "string"
|
||||
},
|
||||
"moderatorKey": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"service": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"port": {
|
||||
"$ref": "#/definitions/port"
|
||||
},
|
||||
"annotations": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"network": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"tunnelPort": {
|
||||
"$ref": "#/definitions/port"
|
||||
},
|
||||
"publicAddress": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extraEnv": {
|
||||
"type": "array"
|
||||
},
|
||||
"persistence": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"existingClaim": {
|
||||
"type": "string"
|
||||
},
|
||||
"size": {
|
||||
"type": "string"
|
||||
},
|
||||
"storageClass": {
|
||||
"type": "string"
|
||||
},
|
||||
"accessModes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"annotations": {
|
||||
"type": "object"
|
||||
},
|
||||
"emptyDirSizeLimit": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"service": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"type": {
|
||||
"enum": [
|
||||
"ClusterIP",
|
||||
"NodePort",
|
||||
"LoadBalancer"
|
||||
]
|
||||
},
|
||||
"port": {
|
||||
"$ref": "#/definitions/port"
|
||||
},
|
||||
"nodePort": {
|
||||
"type": [
|
||||
"string",
|
||||
"integer"
|
||||
]
|
||||
},
|
||||
"annotations": {
|
||||
"type": "object"
|
||||
},
|
||||
"labels": {
|
||||
"type": "object"
|
||||
},
|
||||
"externalTrafficPolicy": {
|
||||
"enum": [
|
||||
"",
|
||||
"Cluster",
|
||||
"Local"
|
||||
]
|
||||
},
|
||||
"loadBalancerClass": {
|
||||
"type": "string"
|
||||
},
|
||||
"loadBalancerSourceRanges": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"strategy": {
|
||||
"type": "object"
|
||||
},
|
||||
"resources": {
|
||||
"type": "object"
|
||||
},
|
||||
"nodeSelector": {
|
||||
"type": "object"
|
||||
},
|
||||
"affinity": {
|
||||
"type": "object"
|
||||
},
|
||||
"tolerations": {
|
||||
"type": "array"
|
||||
},
|
||||
"priorityClassName": {
|
||||
"type": "string"
|
||||
},
|
||||
"podAnnotations": {
|
||||
"type": "object"
|
||||
},
|
||||
"podLabels": {
|
||||
"type": "object"
|
||||
},
|
||||
"terminationGracePeriodSeconds": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"podSecurityContext": {
|
||||
"type": "object"
|
||||
},
|
||||
"securityContext": {
|
||||
"type": "object"
|
||||
},
|
||||
"probes": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"startup": {
|
||||
"$ref": "#/definitions/probe"
|
||||
},
|
||||
"readiness": {
|
||||
"$ref": "#/definitions/probe"
|
||||
},
|
||||
"liveness": {
|
||||
"$ref": "#/definitions/probe"
|
||||
}
|
||||
}
|
||||
},
|
||||
"networkPolicy": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"from": {
|
||||
"type": "array"
|
||||
},
|
||||
"webFrom": {
|
||||
"type": "array"
|
||||
},
|
||||
"dns": {
|
||||
"type": "object"
|
||||
},
|
||||
"internet": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"cidr": {
|
||||
"type": "string"
|
||||
},
|
||||
"except": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"tcpPorts": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/port"
|
||||
}
|
||||
},
|
||||
"udp": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extraIngress": {
|
||||
"type": "array"
|
||||
},
|
||||
"extraEgress": {
|
||||
"type": "array"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extraObjects": {
|
||||
"type": "array"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,239 +0,0 @@
|
||||
# opence-server: the OpenCE dedicated server (docs/dedicated_server.md). One replica: the server
|
||||
# owns its tunnel port and the address players reach it at.
|
||||
|
||||
nameOverride: ""
|
||||
fullnameOverride: ""
|
||||
|
||||
image:
|
||||
repository: ghcr.io/opencommunityedition/opence-server
|
||||
# Empty: the chart's appVersion (latest). A release's tag (build-206) or sha-<commit> pins it;
|
||||
# <tag>@sha256:... as Argo CD Image Updater writes it works too.
|
||||
tag: ""
|
||||
# sha256:... ; replaces any digest in tag.
|
||||
digest: ""
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
imagePullSecrets: []
|
||||
|
||||
# The game data: the folder that holds maps/ (and custom_maps/, gametypes/ and init.txt if you have
|
||||
# them), from your own copy of the game. It is never in the image. Mounted read-only at /data
|
||||
# (HALO_DATA_ROOT). One source is required.
|
||||
gameData:
|
||||
# An existing PersistentVolumeClaim.
|
||||
existingClaim: ""
|
||||
# Or an NFS export.
|
||||
nfs:
|
||||
server: ""
|
||||
path: ""
|
||||
# Or any other volume source, as in a pod's volumes (without the name), e.g.
|
||||
# {hostPath: {path: /srv/halo, type: Directory}}. Without maps/ui.map and the rotation's maps the
|
||||
# server exits with code 2 and says which maps it looked for, and the pod goes into
|
||||
# CrashLoopBackOff.
|
||||
volume: {}
|
||||
# The folder within the volume that holds maps/. Empty: the volume's root.
|
||||
subPath: ""
|
||||
|
||||
# A custom_maps folder of its own (Custom Edition maps with bitmaps.map, sounds.map and loc.map),
|
||||
# mounted read-only at /custom_maps (HALO_CUSTOM_MAPS_ROOT). Optional: without one the server uses
|
||||
# gameData's custom_maps/.
|
||||
customMaps:
|
||||
existingClaim: ""
|
||||
nfs:
|
||||
server: ""
|
||||
path: ""
|
||||
volume: {}
|
||||
subPath: ""
|
||||
|
||||
# The server's settings, as its HALO_* environment variables (docs/dedicated_server.md and
|
||||
# port/linux/README.md, "Dedicated server"). A value given here wins over config.toml, and sv_set
|
||||
# and the web page's settings cannot change it. Each is unset by default (empty, or null): the
|
||||
# setting is then config.toml's, or the server's default (named below), and can be changed from
|
||||
# the web page.
|
||||
server:
|
||||
# server.name: 15 characters of printable ASCII (default "OpenCE Server").
|
||||
name: ""
|
||||
# server.rotation: map[:gametype[+rule=value...]] entries, played in turn, e.g.
|
||||
# [bloodgulch:ctf, sidewinder:team_slayer, prisoner:slayer] (the default).
|
||||
rotation: []
|
||||
# server.max_players: 2 to 127 (default 16).
|
||||
maxPlayers: null
|
||||
# server.public: list the server in everyone's server browser (default true).
|
||||
public: null
|
||||
# server.lobby_seconds (default 15).
|
||||
lobbySeconds: null
|
||||
# server.motd: a notice each player is shown on joining.
|
||||
motd: ""
|
||||
# server.log_format: text or json (default text).
|
||||
logFormat: ""
|
||||
# server.instance and server.region, as the master servers list them.
|
||||
instance: ""
|
||||
region: ""
|
||||
# server.master_publish: publish the server to the official master servers (needs a publisher
|
||||
# key, below; default true).
|
||||
masterPublish: null
|
||||
# server.password: the password the server browser asks for. value, or a key of an existing
|
||||
# Secret; empty for none.
|
||||
password:
|
||||
value: ""
|
||||
existingSecret: ""
|
||||
key: password
|
||||
|
||||
# The master servers' publisher key (HALO_SERVER_PUBLISHER_KEY): the 64 hex characters of the seed
|
||||
# halo --server --keygen writes. value, or a key of an existing Secret; empty: the state volume's
|
||||
# publisher.key, if there is one.
|
||||
publisherKey:
|
||||
value: ""
|
||||
existingSecret: ""
|
||||
key: publisher-key
|
||||
|
||||
# The web page, its API and the remote console (server.web_port), on which the probes ask
|
||||
# GET /healthz. 0 turns them off, and the probes with them.
|
||||
web:
|
||||
port: 8080
|
||||
# The admin password (server.web_password, 8 characters or more), from existingSecret's key, else
|
||||
# from password, else made at the first install and kept in the chart's Secret. The made one is
|
||||
# found again with lookup on upgrades, which helm template and GitOps tools (Argo CD, Flux's
|
||||
# dry runs) cannot do: they make a new one at each render. Give password or existingSecret
|
||||
# there (README.md, "Web password").
|
||||
password: ""
|
||||
existingSecret: ""
|
||||
key: web-password
|
||||
# server.web_moderator_password, from the same Secret's moderatorKey when it has one.
|
||||
moderatorPassword: ""
|
||||
moderatorKey: web-moderator-password
|
||||
# A ClusterIP Service for the web port, for an Ingress (with TLS) or kubectl port-forward.
|
||||
service:
|
||||
enabled: true
|
||||
port: 8080
|
||||
annotations: {}
|
||||
|
||||
network:
|
||||
# network.tunnel_port: the UDP port of internet play, which the Service exposes.
|
||||
tunnelPort: 2302
|
||||
# network.public_address: host[:port] players reach the tunnel port at, when the cluster is behind
|
||||
# a NAT that STUN cannot see through. Empty: what STUN finds.
|
||||
publicAddress: ""
|
||||
|
||||
# More environment variables, as in a pod spec ({name, value} or {name, valueFrom}); they come after
|
||||
# the chart's, so the same name overrides it.
|
||||
extraEnv: []
|
||||
|
||||
# /state: config.toml (HALO_CONFIG_FILE), publisher.key, the save root with its map cache (about
|
||||
# 115 MB for the multiplayer maps), the logs. Without persistence an emptyDir: the cache is built
|
||||
# again at each start, and settings changed from the web page are lost.
|
||||
persistence:
|
||||
enabled: false
|
||||
existingClaim: ""
|
||||
size: 2Gi
|
||||
storageClass: ""
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
annotations: {}
|
||||
emptyDirSizeLimit: 1Gi
|
||||
|
||||
# The tunnel port's Service. Players reach it from outside the cluster, so a real deployment needs
|
||||
# LoadBalancer or NodePort.
|
||||
service:
|
||||
type: LoadBalancer
|
||||
port: 2302
|
||||
nodePort: ""
|
||||
annotations: {}
|
||||
labels: {}
|
||||
# Local keeps the players' own addresses (no SNAT to a node), which bans and the server's limits
|
||||
# rely on.
|
||||
externalTrafficPolicy: Local
|
||||
loadBalancerClass: ""
|
||||
loadBalancerSourceRanges: []
|
||||
|
||||
strategy:
|
||||
type: Recreate
|
||||
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 192Mi
|
||||
limits:
|
||||
memory: 600Mi
|
||||
|
||||
# The image is 32-bit x86 Linux code, which runs on amd64 nodes only.
|
||||
nodeSelector:
|
||||
kubernetes.io/os: linux
|
||||
kubernetes.io/arch: amd64
|
||||
affinity: {}
|
||||
tolerations: []
|
||||
priorityClassName: ""
|
||||
|
||||
podAnnotations: {}
|
||||
podLabels: {}
|
||||
|
||||
# SIGTERM ends the game in progress, tells the players and exits 0; a second signal, or 5 seconds
|
||||
# on, exits at once.
|
||||
terminationGracePeriodSeconds: 15
|
||||
|
||||
podSecurityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 10001
|
||||
runAsGroup: 10001
|
||||
fsGroup: 10001
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop: ["ALL"]
|
||||
|
||||
# GET /healthz on the web port: 200 while the server hosts (lobby, loading, playing, postgame) and
|
||||
# its frames run. Each probe's fields override these; enabled: false drops it.
|
||||
probes:
|
||||
startup:
|
||||
enabled: true
|
||||
periodSeconds: 2
|
||||
failureThreshold: 60
|
||||
timeoutSeconds: 2
|
||||
readiness:
|
||||
enabled: true
|
||||
periodSeconds: 10
|
||||
failureThreshold: 3
|
||||
timeoutSeconds: 2
|
||||
liveness:
|
||||
enabled: true
|
||||
periodSeconds: 20
|
||||
failureThreshold: 3
|
||||
timeoutSeconds: 3
|
||||
|
||||
networkPolicy:
|
||||
enabled: true
|
||||
# Who may reach the tunnel port. Empty: anyone (players are on the internet).
|
||||
from: []
|
||||
# Who may reach the web port, as NetworkPolicy peers (an Ingress controller's namespace, say).
|
||||
# Empty: no pod; kubectl port-forward and the kubelet's probes still reach it.
|
||||
webFrom: []
|
||||
dns:
|
||||
to:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: kube-system
|
||||
podSelector:
|
||||
matchLabels:
|
||||
k8s-app: kube-dns
|
||||
# The internet: TCP to the MQTT brokers (1883) and the master servers (443), and UDP to anywhere
|
||||
# (STUN, and the players' own ports). The private ranges are excepted.
|
||||
internet:
|
||||
cidr: 0.0.0.0/0
|
||||
except:
|
||||
- 10.0.0.0/8
|
||||
- 172.16.0.0/12
|
||||
- 192.168.0.0/16
|
||||
- 100.64.0.0/10
|
||||
- 169.254.0.0/16
|
||||
tcpPorts:
|
||||
- 1883
|
||||
- 443
|
||||
udp: true
|
||||
extraIngress: []
|
||||
extraEgress: []
|
||||
|
||||
# More objects to render with the release (templated).
|
||||
extraObjects: []
|
||||
@@ -1,31 +0,0 @@
|
||||
# init.txt: commands a dedicated server runs once at its start, one a line,
|
||||
# as if typed at its console (docs/dedicated_server.md, "Commands"). Copy
|
||||
# this file to init.txt in the data folder (server.init_file), and take the
|
||||
# "# " off the lines you want. Lines starting with # or ; are comments.
|
||||
#
|
||||
# Settings are better given in config.toml or as HALO_* variables; these are
|
||||
# for what changes from one start to the next.
|
||||
|
||||
# The rotation, replacing server.rotation (and written to it):
|
||||
# sv_rotation_set bloodgulch:ctf, sidewinder:team_slayer+score=50, hangemhigh:king_moving
|
||||
# sv_rotation_add prisoner:slayer+time=10
|
||||
# sv_rotation_begin 2
|
||||
|
||||
# The game's name, players and notice (sv_set of the server.* settings):
|
||||
# sv_name My server
|
||||
# sv_maxplayers 12
|
||||
# sv_motd Welcome. Be nice; admins are watching.
|
||||
# sv_public 1
|
||||
# sv_password secret
|
||||
|
||||
# Any setting the server lists in sv_settings:
|
||||
# sv_set server.lobby_seconds 20
|
||||
# sv_set server.empty_seconds 60
|
||||
|
||||
# A first game other than the rotation's, which goes on after it:
|
||||
# sv_map bloodgulch ctf_classic
|
||||
|
||||
# The state of the server, in the log:
|
||||
# sv_status
|
||||
|
||||
# The game's own console commands run too, with the owner's role.
|
||||
@@ -1,40 +0,0 @@
|
||||
# The dedicated server on MCSManager
|
||||
|
||||
`mcsmanager-config.json` holds two MCSManager quick-install entries for the
|
||||
dedicated server (`docs/dedicated_server.md`). Each unzips a release's
|
||||
`halo-linux-release.zip` into the instance's folder and runs
|
||||
`./halo --server` there, stopped with `quit`.
|
||||
|
||||
| Entry | How it runs |
|
||||
| --- | --- |
|
||||
| Host | On the node itself, which needs the 32-bit C runtime (Debian and Ubuntu: `dpkg --add-architecture i386 && apt install libc6:i386`) |
|
||||
| Docker | In a container of `ghcr.io/ptero-eggs/games:source` (Debian 12 with the 32-bit libraries), the instance's folder mounted at `/workspace` |
|
||||
|
||||
## Using it
|
||||
|
||||
1. Add the entries to the node's quick-install list, and create an
|
||||
instance from one.
|
||||
2. Upload the `maps/` folder of your own copy of the game into the
|
||||
instance's folder. Without `maps/ui.map` and the rotation's maps the
|
||||
server exits with code 2 and says which maps it looked for.
|
||||
3. Start it.
|
||||
|
||||
## Folders
|
||||
|
||||
The Docker entry's container is made again at each start, so it sets
|
||||
`HALO_SAVE_ROOT=/workspace/saves` and `HALO_LOG_ROOT=/workspace/logs`: the
|
||||
save root with the map cache (about 115 MB, built at the first start) and
|
||||
the logs stay in the instance's folder rather than in the container. The
|
||||
host entry keeps the save root in the home folder of the daemon's user
|
||||
(`~/.local/share/halo-linux`), which every host instance of that user
|
||||
shares; give each its own with
|
||||
`HALO_SAVE_ROOT=saves` (in the instance's environment, or as
|
||||
`env HALO_SAVE_ROOT=saves ./halo --server` for its start command).
|
||||
`config.toml` is written beside `halo` at the first start.
|
||||
|
||||
## Ports
|
||||
|
||||
UDP 2302 is the tunnel port, the one players need; the web page, its API
|
||||
and the remote console are on 127.0.0.1:8080. A second instance on the node
|
||||
needs ports of its own: `HALO_NET_TUNNEL_PORT` and `HALO_SERVER_WEB_PORT`,
|
||||
and for the Docker entry its published ports to match.
|
||||
@@ -1,139 +0,0 @@
|
||||
{
|
||||
"_comment": "MCSManager quick-install entries for the OpenCE dedicated server (docs/dedicated_server.md). Each package unzips the release into the instance's folder; put the maps/ folder of your own copy of the game beside halo before the first start. Settings: config.toml beside halo, written at the first start, or HALO_* variables.",
|
||||
"languages": [
|
||||
{
|
||||
"label": "English",
|
||||
"value": "en_us"
|
||||
}
|
||||
],
|
||||
"packages": [
|
||||
{
|
||||
"language": "en_us",
|
||||
"platform": "Linux",
|
||||
"title": "OpenCE Dedicated Server",
|
||||
"category": "Halo: Combat Evolved",
|
||||
"runtime": "Linux x86-64 with 32-bit libraries",
|
||||
"hardware": "1 CPU core, 600 MB of memory",
|
||||
"size": "45 MB, and the game data you upload",
|
||||
"author": "OpenCE",
|
||||
"targetLink": "https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-linux-release.zip",
|
||||
"description": "The dedicated server run on the node itself, which needs the 32-bit C runtime (Debian and Ubuntu: dpkg --add-architecture i386 && apt install libc6:i386). Open UDP 2302; the web page is on http://127.0.0.1:8080/.",
|
||||
"remark": "Host",
|
||||
"setupInfo": {
|
||||
"nickname": "OpenCE Dedicated Server",
|
||||
"startCommand": "./halo --server",
|
||||
"stopCommand": "quit",
|
||||
"ie": "utf-8",
|
||||
"oe": "utf-8",
|
||||
"type": "universal",
|
||||
"tag": [
|
||||
"halo",
|
||||
"opence"
|
||||
],
|
||||
"processType": "general",
|
||||
"updateCommand": "",
|
||||
"crlf": 1,
|
||||
"actionCommandList": [
|
||||
{
|
||||
"name": "Status",
|
||||
"command": "sv_status"
|
||||
},
|
||||
{
|
||||
"name": "Players",
|
||||
"command": "sv_players"
|
||||
},
|
||||
{
|
||||
"name": "Next map",
|
||||
"command": "sv_map_next"
|
||||
},
|
||||
{
|
||||
"name": "Reload settings",
|
||||
"command": "sv_reload"
|
||||
}
|
||||
],
|
||||
"eventTask": {
|
||||
"autoStart": false,
|
||||
"autoRestart": true,
|
||||
"ignore": false
|
||||
},
|
||||
"terminalOption": {
|
||||
"haveColor": false,
|
||||
"pty": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"language": "en_us",
|
||||
"platform": "Linux",
|
||||
"title": "OpenCE Dedicated Server",
|
||||
"category": "Halo: Combat Evolved",
|
||||
"runtime": "Linux x86-64 with 32-bit libraries",
|
||||
"hardware": "1 CPU core, 600 MB of memory",
|
||||
"size": "45 MB, and the game data you upload",
|
||||
"author": "OpenCE",
|
||||
"targetLink": "https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-linux-release.zip",
|
||||
"description": "The dedicated server in a container of ghcr.io/ptero-eggs/games:source (Debian 12 with the 32-bit libraries), the instance's folder mounted as its working folder; the save root (with the map cache) and the logs are kept in it, as the container is made again at each start. Publishes UDP 2302 and the web page on the node's 127.0.0.1:8080 (each instance on a node needs ports of its own).",
|
||||
"remark": "Docker",
|
||||
"setupInfo": {
|
||||
"nickname": "OpenCE Dedicated Server",
|
||||
"startCommand": "./halo --server",
|
||||
"stopCommand": "quit",
|
||||
"ie": "utf-8",
|
||||
"oe": "utf-8",
|
||||
"type": "universal",
|
||||
"tag": [
|
||||
"halo",
|
||||
"opence"
|
||||
],
|
||||
"processType": "docker",
|
||||
"updateCommand": "",
|
||||
"crlf": 1,
|
||||
"actionCommandList": [
|
||||
{
|
||||
"name": "Status",
|
||||
"command": "sv_status"
|
||||
},
|
||||
{
|
||||
"name": "Players",
|
||||
"command": "sv_players"
|
||||
},
|
||||
{
|
||||
"name": "Next map",
|
||||
"command": "sv_map_next"
|
||||
},
|
||||
{
|
||||
"name": "Reload settings",
|
||||
"command": "sv_reload"
|
||||
}
|
||||
],
|
||||
"eventTask": {
|
||||
"autoStart": false,
|
||||
"autoRestart": true,
|
||||
"ignore": false
|
||||
},
|
||||
"terminalOption": {
|
||||
"haveColor": false,
|
||||
"pty": false
|
||||
},
|
||||
"docker": {
|
||||
"image": "ghcr.io/ptero-eggs/games:source",
|
||||
"ports": [
|
||||
"2302:2302/udp",
|
||||
"127.0.0.1:8080:8080/tcp"
|
||||
],
|
||||
"extraVolumes": [],
|
||||
"networkMode": "bridge",
|
||||
"networkAliases": [],
|
||||
"env": [
|
||||
"HALO_SERVER_WEB_BIND=0.0.0.0",
|
||||
"HALO_SAVE_ROOT=/workspace/saves",
|
||||
"HALO_LOG_ROOT=/workspace/logs"
|
||||
],
|
||||
"memory": 600,
|
||||
"workingDir": "/workspace/",
|
||||
"changeWorkdir": true
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
# The dedicated server on Pterodactyl and Pelican
|
||||
|
||||
`egg-opence-dedicated-server.json` is an egg (`PTDL_v2`) that installs a
|
||||
release of OpenCE from GitHub and runs it as a dedicated server
|
||||
(`docs/dedicated_server.md`). Pelican imports the same file.
|
||||
|
||||
## Importing it
|
||||
|
||||
1. Admin > Nests (Pelican: Eggs) > Import Egg, and choose the file.
|
||||
2. Create a server with the egg. Its primary allocation is the tunnel port
|
||||
(`network.tunnel_port`, UDP): the one port players need, from 1025 up
|
||||
(the container cannot bind lower ports).
|
||||
3. Upload the game data: the `maps/` folder of your own copy of the game
|
||||
(port/linux/README.md, "Game data"), into the server's folder over SFTP
|
||||
(the panel's SFTP details, on the Settings tab). Without `maps/ui.map`
|
||||
and the rotation's maps the server stops at once with exit code 2 and
|
||||
says which maps it looked for.
|
||||
4. Start it. The panel shows it running once it prints its ready line
|
||||
(`server: ready`, or `"msg":"ready (` with `server.log_format = "json"`).
|
||||
|
||||
## Files
|
||||
|
||||
| Path (in `/home/container`) | What |
|
||||
| --- | --- |
|
||||
| `halo`, `halo-server`, `libSDL3.so.0`, `brokers.txt`, `masters.txt`, the licences | The release (replaced on Reinstall) |
|
||||
| `maps/` | The game data (yours) |
|
||||
| `custom_maps/` | Custom Edition maps, with `bitmaps.map`, `sounds.map` and `loc.map` (shared with players who join) |
|
||||
| `gametypes/*.toml` | Gametypes of your own (the release adds examples, never replacing yours) |
|
||||
| `init.txt` | Commands run at each start (`init.txt.example` has examples) |
|
||||
| `config.toml` | Every setting, written at the first start |
|
||||
| `publisher.key` | The master servers' key: made by `./halo --server --keygen` on any machine with the release and uploaded, or given as the Publisher key variable instead |
|
||||
| `logs/` | `debug.txt`, `bans.txt`, `cheaters.txt` |
|
||||
|
||||
Reinstall (Settings tab) downloads the release again, the one the Release
|
||||
variable names, and keeps `config.toml`, `init.txt`, `publisher.key`,
|
||||
`gametypes/`, `custom_maps/`, `maps/` and `logs/`.
|
||||
|
||||
## Variables
|
||||
|
||||
Every variable is one of the server's settings, by its environment name
|
||||
(docs/dedicated_server.md and port/linux/README.md, "Dedicated server"). A
|
||||
variable wins over `config.toml`, and the web page's settings cannot
|
||||
change it.
|
||||
|
||||
| Variable | Setting |
|
||||
| --- | --- |
|
||||
| Release (`OPENCE_RELEASE`) | `latest` or a tag (`build-206`); used by Reinstall |
|
||||
| Server name (`HALO_SERVER_NAME`) | `server.name`, 15 characters |
|
||||
| Rotation (`HALO_SERVER_ROTATION`) | `server.rotation` |
|
||||
| Max players (`HALO_SERVER_MAX_PLAYERS`) | `server.max_players` |
|
||||
| Join password (`HALO_SERVER_PASSWORD`) | `server.password` |
|
||||
| Public (`HALO_SERVER_PUBLIC`) | `server.public` |
|
||||
| Message of the day (`HALO_SERVER_MOTD`) | `server.motd` |
|
||||
| Lobby seconds (`HALO_SERVER_LOBBY_SECONDS`) | `server.lobby_seconds` |
|
||||
| Web UI port (`HALO_SERVER_WEB_PORT`) | `server.web_port`; 0 for none |
|
||||
| Web UI password (`HALO_SERVER_WEB_PASSWORD`) | `server.web_password` |
|
||||
| Public address (`HALO_NET_PUBLIC_ADDRESS`) | `network.public_address` |
|
||||
| Publisher key (`HALO_SERVER_PUBLISHER_KEY`) | The master servers' key itself, in place of `publisher.key` |
|
||||
| Instance name (`HALO_SERVER_INSTANCE`) | `server.instance` |
|
||||
| Region (`HALO_SERVER_REGION`) | `server.region` |
|
||||
| Log format (`HALO_SERVER_LOG_FORMAT`) | `server.log_format` |
|
||||
|
||||
The startup command sets `HALO_NET_TUNNEL_PORT` to the primary allocation's
|
||||
port and `HALO_LOG_ROOT` to `logs/`. Two variables are the administrator's
|
||||
only: Web UI bind (`0.0.0.0`, as the allocation's address is the node's,
|
||||
not the container's) and GitHub repository (`OpenCommunityEdition/OpenCE`).
|
||||
|
||||
## The web page
|
||||
|
||||
The admin page, its API and the remote console need a second allocation:
|
||||
the node's administrator adds one to the server (or raises its allocation
|
||||
limit so the owner can, on the Network tab). Give its port as Web UI port
|
||||
and a password of 8 characters or more as Web UI password, restart, and
|
||||
open `http://<allocation address>:<port>/`. The page has no TLS of its own:
|
||||
put it behind a reverse proxy with HTTPS for anything but a private network.
|
||||
|
||||
## Stopping and restarting
|
||||
|
||||
The panel's Stop sends SIGINT, which the server takes as SIGTERM: the game
|
||||
in progress goes to its postgame, the players are told, the listing is
|
||||
withdrawn, and it exits 0. The console's `quit` command does the same, but
|
||||
Wings counts an exit it did not ask for as a crash and starts the server
|
||||
again; use Stop. `sv_restart` exits with code 5, which Wings also takes as a
|
||||
crash and restarts, which is what it asks for.
|
||||
|
||||
Updates: `server.auto_update` is for servers that own their files; on a
|
||||
panel, change the Release variable (or keep `latest`) and Reinstall, by hand
|
||||
or as a schedule.
|
||||
|
||||
## Checking the egg
|
||||
|
||||
`python tools/egg_build.py` copies `install.sh` into the egg and checks it;
|
||||
`python -m pytest -q tools/test_egg.py` checks the egg and runs `install.sh`
|
||||
in a `debian:bookworm-slim` container against a release served locally.
|
||||
@@ -1,203 +0,0 @@
|
||||
{
|
||||
"_comment": "DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PTERODACTYL PANEL - PTERODACTYL.IO",
|
||||
"meta": {
|
||||
"version": "PTDL_v2",
|
||||
"update_url": null
|
||||
},
|
||||
"exported_at": "2026-10-24T00:00:00+00:00",
|
||||
"name": "OpenCE Dedicated Server",
|
||||
"author": "opence@halocombatevolved.com",
|
||||
"description": "A dedicated server of OpenCE, the port of Halo: Combat Evolved: hosts multiplayer games one after another, with no window, sound or player of its own. Installs a release from GitHub. The game data is yours to upload: put the maps/ folder of your own copy of the game in the server's folder over SFTP; the server does not start without it.",
|
||||
"features": [],
|
||||
"docker_images": {
|
||||
"Debian 12 with 32-bit libraries (Pterodactyl)": "ghcr.io/ptero-eggs/games:source",
|
||||
"Debian 12 with 32-bit libraries (Pelican)": "ghcr.io/pelican-eggs/games:source"
|
||||
},
|
||||
"file_denylist": [],
|
||||
"startup": "HALO_NET_TUNNEL_PORT={{SERVER_PORT}} HALO_LOG_ROOT=/home/container/logs ./halo --server",
|
||||
"config": {
|
||||
"files": "{}",
|
||||
"startup": "{\r\n \"done\": [\r\n \"server: ready\",\r\n \"\\\"msg\\\":\\\"ready (\"\r\n ]\r\n}",
|
||||
"logs": "{}",
|
||||
"stop": "^C"
|
||||
},
|
||||
"scripts": {
|
||||
"installation": {
|
||||
"script": "#!/bin/bash\n# The OpenCE dedicated server egg's installation script (Pterodactyl and\n# Pelican), run as root in ghcr.io/ptero-eggs/installers:debian with the\n# server's folder at /mnt/server. tools/egg_build.py copies it into\n# egg-opence-dedicated-server.json.\n#\n# OPENCE_RELEASE: \"latest\" or a release tag (build-206).\n# OPENCE_REPOSITORY: the GitHub repository (owner/name) to download from.\n#\n# A reinstall replaces the release's files and keeps the owner's:\n# config.toml, init.txt, publisher.key, gametypes/, custom_maps/, maps/ and\n# logs/. The panel ignores this script's exit code, so each failure says\n# what went wrong.\n\nset -u\n\nSERVER_DIR=\"${SERVER_DIR:-/mnt/server}\"\nRELEASE=\"${OPENCE_RELEASE:-latest}\"\nREPOSITORY=\"${OPENCE_REPOSITORY:-OpenCommunityEdition/OpenCE}\"\nGITHUB_URL=\"${OPENCE_GITHUB_URL:-https://github.com}\"\nGITHUB_API=\"${OPENCE_GITHUB_API:-https://api.github.com}\"\nASSET=halo-linux-release.zip\n\nfail() {\n\techo \"INSTALL FAILED: $*\"\n\texit 1\n}\n\nif ! [[ \"$REPOSITORY\" =~ ^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$ ]]; then\n\tfail \"the repository \\\"$REPOSITORY\\\" is not owner/name\"\nfi\nif [ -z \"$RELEASE\" ] || [ \"$RELEASE\" = latest ]; then\n\t# (no API call, so no rate limit)\n\turl=\"$GITHUB_URL/$REPOSITORY/releases/latest/download/$ASSET\"\nelse\n\tif ! [[ \"$RELEASE\" =~ ^[A-Za-z0-9._-]+$ ]]; then\n\t\tfail \"the release \\\"$RELEASE\\\" is not a tag name (build-206) or latest\"\n\tfi\n\techo \"Looking up release $RELEASE of $REPOSITORY\"\n\trelease_json=\"$(curl -fsSL --retry 3 -H 'Accept: application/vnd.github+json' \\\n\t\t\"$GITHUB_API/repos/$REPOSITORY/releases/tags/$RELEASE\")\" \\\n\t\t|| fail \"no release $RELEASE in $REPOSITORY (or GitHub's API did not answer)\"\n\turl=\"$(printf '%s' \"$release_json\" | jq -r --arg name \"$ASSET\" \\\n\t\t'[.assets[]? | select(.name == $name) | .browser_download_url][0] // empty')\"\n\t[ -n \"$url\" ] || fail \"release $RELEASE has no $ASSET\"\nfi\n\nmkdir -p \"$SERVER_DIR\" || fail \"cannot make $SERVER_DIR\"\ncd \"$SERVER_DIR\" || fail \"cannot enter $SERVER_DIR\"\n\nwork=\"$(mktemp -d)\" || fail \"cannot make a temporary folder\"\ntrap 'rm -rf \"$work\"' EXIT\n\necho \"Downloading $url\"\ncurl -fL --retry 3 --progress-bar -o \"$work/$ASSET\" \"$url\" || fail \"the download of $url failed\"\nunzip -tq \"$work/$ASSET\" > /dev/null || fail \"$ASSET is not a zip file\"\nmkdir \"$work/release\"\nunzip -q \"$work/$ASSET\" -d \"$work/release\" || fail \"cannot unzip $ASSET\"\n[ -f \"$work/release/halo\" ] || fail \"$ASSET has no halo executable\"\n\n# the release's files, over the old release's; the owner's are never in it,\n# and gametypes/ only adds the examples not already there\nfor entry in \"$work/release\"/* \"$work/release\"/.[!.]*; do\n\t[ -e \"$entry\" ] || continue\n\tname=\"$(basename \"$entry\")\"\n\tcase \"$name\" in\n\tconfig.toml | init.txt | publisher.key | custom_maps | maps | logs)\n\t\tcontinue\n\t\t;;\n\tgametypes)\n\t\tmkdir -p gametypes\n\t\tcp -rn \"$entry\"/. gametypes/\n\t\tcontinue\n\t\t;;\n\tesac\n\trm -rf \"./$name\"\n\tcp -a \"$entry\" \"./$name\" || fail \"cannot copy $name\"\ndone\n\nchmod 0755 halo\nif [ ! -f halo-server ]; then\n\tprintf '#!/bin/sh\\nexec \"$(dirname \"$0\")/halo\" --server \"$@\"\\n' > halo-server\nfi\nchmod 0755 halo-server\nmkdir -p maps custom_maps gametypes logs\n\necho \"Checking that the server runs\"\nif version=\"$(HOME=\"$work\" HALO_SAVE_ROOT=\"$work/saves\" timeout 30 ./halo --version 2>&1)\"; then\n\techo \"$version\"\nelse\n\techo \"WARNING: ./halo --version did not run. The server needs the 32-bit C runtime\"\n\techo \"WARNING: (the egg's ghcr.io/ptero-eggs/games:source image has it):\"\n\techo \"$version\"\nfi\n\nif [ ! -f maps/ui.map ]; then\n\techo \"No game data yet: upload your maps/ folder (ui.map and the multiplayer maps)\"\n\techo \"over SFTP into the server's folder before starting it.\"\nfi\necho \"Installation completed\"\n",
|
||||
"container": "ghcr.io/ptero-eggs/installers:debian",
|
||||
"entrypoint": "bash"
|
||||
}
|
||||
},
|
||||
"variables": [
|
||||
{
|
||||
"name": "Release",
|
||||
"description": "A release tag (build-206) or latest. A change takes effect on Reinstall (Settings tab), which keeps config.toml, init.txt, gametypes/, custom_maps/ and maps/.",
|
||||
"env_variable": "OPENCE_RELEASE",
|
||||
"default_value": "latest",
|
||||
"user_viewable": true,
|
||||
"user_editable": true,
|
||||
"rules": "required|string|max:40|regex:/^[A-Za-z0-9._-]+$/",
|
||||
"field_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "Server name",
|
||||
"description": "The game's name in the lobby and the server browser: 15 characters of printable ASCII.",
|
||||
"env_variable": "HALO_SERVER_NAME",
|
||||
"default_value": "OpenCE Server",
|
||||
"user_viewable": true,
|
||||
"user_editable": true,
|
||||
"rules": "required|string|max:15|regex:/^[\\x20-\\x7E]+$/",
|
||||
"field_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "Rotation",
|
||||
"description": "The games played one after another, separated by commas: map:gametype, with +rule=value after a gametype (bloodgulch:ctf, sidewinder:team_slayer+score=50). A gametype is a built-in's name or a gametypes/<name>.toml of yours.",
|
||||
"env_variable": "HALO_SERVER_ROTATION",
|
||||
"default_value": "bloodgulch:ctf, sidewinder:team_slayer, prisoner:slayer",
|
||||
"user_viewable": true,
|
||||
"user_editable": true,
|
||||
"rules": "required|string|max:4096",
|
||||
"field_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "Max players",
|
||||
"description": "2 to 127.",
|
||||
"env_variable": "HALO_SERVER_MAX_PLAYERS",
|
||||
"default_value": "16",
|
||||
"user_viewable": true,
|
||||
"user_editable": true,
|
||||
"rules": "required|integer|between:2,127",
|
||||
"field_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "Join password",
|
||||
"description": "The password the server browser asks for; empty for none. The invite link joins without it.",
|
||||
"env_variable": "HALO_SERVER_PASSWORD",
|
||||
"default_value": "",
|
||||
"user_viewable": true,
|
||||
"user_editable": true,
|
||||
"rules": "nullable|string|max:64",
|
||||
"field_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "Public",
|
||||
"description": "List the server in everyone's server browser.",
|
||||
"env_variable": "HALO_SERVER_PUBLIC",
|
||||
"default_value": "true",
|
||||
"user_viewable": true,
|
||||
"user_editable": true,
|
||||
"rules": "required|string|in:true,false",
|
||||
"field_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "Message of the day",
|
||||
"description": "A notice each player is shown on joining (127 characters); empty for none.",
|
||||
"env_variable": "HALO_SERVER_MOTD",
|
||||
"default_value": "",
|
||||
"user_viewable": true,
|
||||
"user_editable": true,
|
||||
"rules": "nullable|string|max:127",
|
||||
"field_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "Lobby seconds",
|
||||
"description": "Seconds the lobby counts down before each game (0 to 300).",
|
||||
"env_variable": "HALO_SERVER_LOBBY_SECONDS",
|
||||
"default_value": "15",
|
||||
"user_viewable": true,
|
||||
"user_editable": true,
|
||||
"rules": "required|integer|between:0,300",
|
||||
"field_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "Web UI port",
|
||||
"description": "0: no web page. Else the port of an additional allocation (Network tab) for the admin page, its API and the remote console, at http://<allocation address>:<port>/; it needs a web UI password.",
|
||||
"env_variable": "HALO_SERVER_WEB_PORT",
|
||||
"default_value": "0",
|
||||
"user_viewable": true,
|
||||
"user_editable": true,
|
||||
"rules": "required|integer|between:0,65535",
|
||||
"field_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "Web UI password",
|
||||
"description": "The admin password of the web page, 8 characters or more.",
|
||||
"env_variable": "HALO_SERVER_WEB_PASSWORD",
|
||||
"default_value": "",
|
||||
"user_viewable": true,
|
||||
"user_editable": true,
|
||||
"rules": "nullable|string|min:8|max:64",
|
||||
"field_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "Public address",
|
||||
"description": "host[:port] offered to joiners first, for a node behind a NAT that STUN cannot see through; usually empty.",
|
||||
"env_variable": "HALO_NET_PUBLIC_ADDRESS",
|
||||
"default_value": "",
|
||||
"user_viewable": true,
|
||||
"user_editable": true,
|
||||
"rules": "nullable|string|max:253",
|
||||
"field_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "Publisher key",
|
||||
"description": "Your approved key for the master servers that list dedicated servers: the 64 hex characters of the seed ./halo --server --keygen writes to publisher.key. Empty: the key file, if there is one; the server is not listed on the masters without one.",
|
||||
"env_variable": "HALO_SERVER_PUBLISHER_KEY",
|
||||
"default_value": "",
|
||||
"user_viewable": true,
|
||||
"user_editable": true,
|
||||
"rules": "nullable|string|regex:/^[0-9a-f]{64}$/",
|
||||
"field_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "Instance name",
|
||||
"description": "Tells this server from your others on the master servers: letters, digits, dashes.",
|
||||
"env_variable": "HALO_SERVER_INSTANCE",
|
||||
"default_value": "main",
|
||||
"user_viewable": true,
|
||||
"user_editable": true,
|
||||
"rules": "required|string|alpha_dash|max:32",
|
||||
"field_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "Region",
|
||||
"description": "A label in the server browser (eu, na-east); empty for none.",
|
||||
"env_variable": "HALO_SERVER_REGION",
|
||||
"default_value": "",
|
||||
"user_viewable": true,
|
||||
"user_editable": true,
|
||||
"rules": "nullable|string|alpha_dash|max:16",
|
||||
"field_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "Log format",
|
||||
"description": "The console's lines: text, or json for a log collector.",
|
||||
"env_variable": "HALO_SERVER_LOG_FORMAT",
|
||||
"default_value": "text",
|
||||
"user_viewable": true,
|
||||
"user_editable": true,
|
||||
"rules": "required|string|in:text,json",
|
||||
"field_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "Web UI bind",
|
||||
"description": "The container's address the web port listens on: all of them, as the allocation's address is the node's.",
|
||||
"env_variable": "HALO_SERVER_WEB_BIND",
|
||||
"default_value": "0.0.0.0",
|
||||
"user_viewable": false,
|
||||
"user_editable": false,
|
||||
"rules": "required|string|in:0.0.0.0",
|
||||
"field_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "GitHub repository",
|
||||
"description": "owner/name the installation downloads the release from.",
|
||||
"env_variable": "OPENCE_REPOSITORY",
|
||||
"default_value": "OpenCommunityEdition/OpenCE",
|
||||
"user_viewable": false,
|
||||
"user_editable": false,
|
||||
"rules": "required|string|max:100|regex:/^[A-Za-z0-9._-]+\\/[A-Za-z0-9._-]+$/",
|
||||
"field_type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
#!/bin/bash
|
||||
# The OpenCE dedicated server egg's installation script (Pterodactyl and
|
||||
# Pelican), run as root in ghcr.io/ptero-eggs/installers:debian with the
|
||||
# server's folder at /mnt/server. tools/egg_build.py copies it into
|
||||
# egg-opence-dedicated-server.json.
|
||||
#
|
||||
# OPENCE_RELEASE: "latest" or a release tag (build-206).
|
||||
# OPENCE_REPOSITORY: the GitHub repository (owner/name) to download from.
|
||||
#
|
||||
# A reinstall replaces the release's files and keeps the owner's:
|
||||
# config.toml, init.txt, publisher.key, gametypes/, custom_maps/, maps/ and
|
||||
# logs/. The panel ignores this script's exit code, so each failure says
|
||||
# what went wrong.
|
||||
|
||||
set -u
|
||||
|
||||
SERVER_DIR="${SERVER_DIR:-/mnt/server}"
|
||||
RELEASE="${OPENCE_RELEASE:-latest}"
|
||||
REPOSITORY="${OPENCE_REPOSITORY:-OpenCommunityEdition/OpenCE}"
|
||||
GITHUB_URL="${OPENCE_GITHUB_URL:-https://github.com}"
|
||||
GITHUB_API="${OPENCE_GITHUB_API:-https://api.github.com}"
|
||||
ASSET=halo-linux-release.zip
|
||||
|
||||
fail() {
|
||||
echo "INSTALL FAILED: $*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if ! [[ "$REPOSITORY" =~ ^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$ ]]; then
|
||||
fail "the repository \"$REPOSITORY\" is not owner/name"
|
||||
fi
|
||||
if [ -z "$RELEASE" ] || [ "$RELEASE" = latest ]; then
|
||||
# (no API call, so no rate limit)
|
||||
url="$GITHUB_URL/$REPOSITORY/releases/latest/download/$ASSET"
|
||||
else
|
||||
if ! [[ "$RELEASE" =~ ^[A-Za-z0-9._-]+$ ]]; then
|
||||
fail "the release \"$RELEASE\" is not a tag name (build-206) or latest"
|
||||
fi
|
||||
echo "Looking up release $RELEASE of $REPOSITORY"
|
||||
release_json="$(curl -fsSL --retry 3 -H 'Accept: application/vnd.github+json' \
|
||||
"$GITHUB_API/repos/$REPOSITORY/releases/tags/$RELEASE")" \
|
||||
|| fail "no release $RELEASE in $REPOSITORY (or GitHub's API did not answer)"
|
||||
url="$(printf '%s' "$release_json" | jq -r --arg name "$ASSET" \
|
||||
'[.assets[]? | select(.name == $name) | .browser_download_url][0] // empty')"
|
||||
[ -n "$url" ] || fail "release $RELEASE has no $ASSET"
|
||||
fi
|
||||
|
||||
mkdir -p "$SERVER_DIR" || fail "cannot make $SERVER_DIR"
|
||||
cd "$SERVER_DIR" || fail "cannot enter $SERVER_DIR"
|
||||
|
||||
work="$(mktemp -d)" || fail "cannot make a temporary folder"
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
|
||||
echo "Downloading $url"
|
||||
curl -fL --retry 3 --progress-bar -o "$work/$ASSET" "$url" || fail "the download of $url failed"
|
||||
unzip -tq "$work/$ASSET" > /dev/null || fail "$ASSET is not a zip file"
|
||||
mkdir "$work/release"
|
||||
unzip -q "$work/$ASSET" -d "$work/release" || fail "cannot unzip $ASSET"
|
||||
[ -f "$work/release/halo" ] || fail "$ASSET has no halo executable"
|
||||
|
||||
# the release's files, over the old release's; the owner's are never in it,
|
||||
# and gametypes/ only adds the examples not already there
|
||||
for entry in "$work/release"/* "$work/release"/.[!.]*; do
|
||||
[ -e "$entry" ] || continue
|
||||
name="$(basename "$entry")"
|
||||
case "$name" in
|
||||
config.toml | init.txt | publisher.key | custom_maps | maps | logs)
|
||||
continue
|
||||
;;
|
||||
gametypes)
|
||||
mkdir -p gametypes
|
||||
cp -rn "$entry"/. gametypes/
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
rm -rf "./$name"
|
||||
cp -a "$entry" "./$name" || fail "cannot copy $name"
|
||||
done
|
||||
|
||||
chmod 0755 halo
|
||||
if [ ! -f halo-server ]; then
|
||||
printf '#!/bin/sh\nexec "$(dirname "$0")/halo" --server "$@"\n' > halo-server
|
||||
fi
|
||||
chmod 0755 halo-server
|
||||
mkdir -p maps custom_maps gametypes logs
|
||||
|
||||
echo "Checking that the server runs"
|
||||
if version="$(HOME="$work" HALO_SAVE_ROOT="$work/saves" timeout 30 ./halo --version 2>&1)"; then
|
||||
echo "$version"
|
||||
else
|
||||
echo "WARNING: ./halo --version did not run. The server needs the 32-bit C runtime"
|
||||
echo "WARNING: (the egg's ghcr.io/ptero-eggs/games:source image has it):"
|
||||
echo "$version"
|
||||
fi
|
||||
|
||||
if [ ! -f maps/ui.map ]; then
|
||||
echo "No game data yet: upload your maps/ folder (ui.map and the multiplayer maps)"
|
||||
echo "over SFTP into the server's folder before starting it."
|
||||
fi
|
||||
echo "Installation completed"
|
||||
@@ -1,49 +0,0 @@
|
||||
# The dedicated server on PufferPanel
|
||||
|
||||
`template.json` is a PufferPanel template for the dedicated server
|
||||
(`docs/dedicated_server.md`), run in PufferPanel's host environment: it
|
||||
downloads a release's `halo-linux-release.zip` into the server's folder,
|
||||
runs `./halo --server` there, and stops it by writing `quit` to its
|
||||
standard input.
|
||||
|
||||
## Using it
|
||||
|
||||
1. The node needs the 32-bit C runtime (Debian and Ubuntu:
|
||||
`dpkg --add-architecture i386 && apt install libc6:i386`). The template
|
||||
mounts `/lib32` and `/usr/lib32` into PufferPanel's sandbox, which does
|
||||
not otherwise; without them the 32-bit `halo` cannot start.
|
||||
2. Add the template (Templates, New, and paste the file), and create a
|
||||
server from it.
|
||||
3. Upload the `maps/` folder of your own copy of the game into the
|
||||
server's folder. Without `maps/ui.map` and the rotation's maps the server
|
||||
exits with code 2 and says which maps it looked for.
|
||||
4. Start it.
|
||||
|
||||
## Ports
|
||||
|
||||
The **Tunnel port** (UDP, 2302 by default) is the one port players need.
|
||||
The **Web UI port** is the web page, its API and the remote console, on
|
||||
127.0.0.1 only. Its default is 8090, because PufferPanel itself listens on
|
||||
8080. Each server on a node needs a tunnel port and a web port of its own
|
||||
(or a web port of 0, for none).
|
||||
|
||||
## Files
|
||||
|
||||
Everything the server writes stays in its folder: `config.toml` (every
|
||||
setting, written at the first start, with the web page's admin password if
|
||||
none was given), `saves/` (`HALO_SAVE_ROOT`: the profiles and the map cache,
|
||||
about 115 MB, built at the first start), `logs/` (`HALO_LOG_ROOT`:
|
||||
`debug.txt`, `bans.txt`, `cheaters.txt`) and `status.json`
|
||||
(`server.status_file`, the status every 2 seconds).
|
||||
|
||||
The template's variables are passed as `HALO_*` variables, which win over
|
||||
`config.toml`: `sv_set` and the web page cannot change those settings.
|
||||
|
||||
## PufferPanel versions
|
||||
|
||||
The template is in the format of PufferPanel 2's templates (`run.command`
|
||||
as a string, `run.stop` as the command written to standard input). We have
|
||||
not confirmed how PufferPanel 3 imports it, nor the form of its standard
|
||||
input settings; if a server made from it on PufferPanel 3 does not stop
|
||||
with `quit`, set its stop to send `quit` to standard input (or SIGTERM,
|
||||
which the server takes as well) in the server's settings.
|
||||
@@ -1,140 +0,0 @@
|
||||
{
|
||||
"type": "opence",
|
||||
"display": "OpenCE Dedicated Server",
|
||||
"install": [
|
||||
{
|
||||
"type": "download",
|
||||
"files": [
|
||||
"${release_url}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "command",
|
||||
"commands": [
|
||||
"unzip -o halo-linux-release.zip",
|
||||
"rm -f halo-linux-release.zip",
|
||||
"chmod 0755 halo halo-server",
|
||||
"mkdir -p maps custom_maps gametypes saves logs",
|
||||
"./halo --version"
|
||||
]
|
||||
}
|
||||
],
|
||||
"run": {
|
||||
"command": "./halo --server",
|
||||
"stop": "quit",
|
||||
"workingDirectory": "",
|
||||
"pre": [],
|
||||
"post": [],
|
||||
"environmentVars": {
|
||||
"HALO_NET_TUNNEL_PORT": "${port}",
|
||||
"HALO_SERVER_NAME": "${name}",
|
||||
"HALO_SERVER_ROTATION": "${rotation}",
|
||||
"HALO_SERVER_MAX_PLAYERS": "${max_players}",
|
||||
"HALO_SERVER_PUBLIC": "${public}",
|
||||
"HALO_SERVER_WEB_PORT": "${web_port}",
|
||||
"HALO_SERVER_LOG_FORMAT": "${log_format}",
|
||||
"HALO_SERVER_STATUS_FILE": "status.json",
|
||||
"HALO_SAVE_ROOT": "saves",
|
||||
"HALO_LOG_ROOT": "logs"
|
||||
},
|
||||
"autostart": false,
|
||||
"autorecover": true,
|
||||
"autorestart": false
|
||||
},
|
||||
"data": {
|
||||
"release_url": {
|
||||
"type": "string",
|
||||
"display": "Release",
|
||||
"desc": "The release's halo-linux-release.zip: .../releases/latest/download/halo-linux-release.zip, or .../releases/download/<tag>/halo-linux-release.zip. Used when the server is installed again.",
|
||||
"required": true,
|
||||
"value": "https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-linux-release.zip",
|
||||
"userEdit": true
|
||||
},
|
||||
"port": {
|
||||
"type": "integer",
|
||||
"display": "Tunnel port",
|
||||
"desc": "The UDP port of internet play (network.tunnel_port), the one port players need.",
|
||||
"required": true,
|
||||
"value": 2302,
|
||||
"userEdit": true
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"display": "Server name",
|
||||
"desc": "The game's name in the server browser: 15 characters of printable ASCII.",
|
||||
"required": true,
|
||||
"value": "OpenCE Server",
|
||||
"userEdit": true
|
||||
},
|
||||
"rotation": {
|
||||
"type": "string",
|
||||
"display": "Rotation",
|
||||
"desc": "The games played one after another: map:gametype entries separated by commas.",
|
||||
"required": true,
|
||||
"value": "bloodgulch:ctf, sidewinder:team_slayer, prisoner:slayer",
|
||||
"userEdit": true
|
||||
},
|
||||
"max_players": {
|
||||
"type": "integer",
|
||||
"display": "Max players",
|
||||
"desc": "2 to 127.",
|
||||
"required": true,
|
||||
"value": 16,
|
||||
"userEdit": true
|
||||
},
|
||||
"public": {
|
||||
"type": "boolean",
|
||||
"display": "Public",
|
||||
"desc": "List the server in everyone's server browser.",
|
||||
"required": true,
|
||||
"value": true,
|
||||
"userEdit": true
|
||||
},
|
||||
"web_port": {
|
||||
"type": "integer",
|
||||
"display": "Web UI port",
|
||||
"desc": "The web page, its API and the remote console, on 127.0.0.1 (server.web_port); 0 for none. Each server on a node needs a port of its own, and not PufferPanel's own (8080). The admin password is printed at the first start and kept in config.toml.",
|
||||
"required": true,
|
||||
"value": 8090,
|
||||
"userEdit": true
|
||||
},
|
||||
"log_format": {
|
||||
"type": "option",
|
||||
"display": "Log format",
|
||||
"desc": "The console's lines.",
|
||||
"required": true,
|
||||
"value": "text",
|
||||
"userEdit": true,
|
||||
"options": [
|
||||
{
|
||||
"value": "text",
|
||||
"display": "Text"
|
||||
},
|
||||
{
|
||||
"value": "json",
|
||||
"display": "JSON"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"environment": {
|
||||
"type": "host",
|
||||
"mounts": [
|
||||
"/lib32",
|
||||
"/usr/lib32"
|
||||
]
|
||||
},
|
||||
"supportedEnvironments": [
|
||||
{
|
||||
"type": "host",
|
||||
"mounts": [
|
||||
"/lib32",
|
||||
"/usr/lib32"
|
||||
]
|
||||
}
|
||||
],
|
||||
"requirements": {
|
||||
"os": "linux",
|
||||
"arch": "amd64"
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
d04e8b101007d1641cace8b95fcca76f7f44709f6885c3d031b52394dbdf9376
|
||||
@@ -1,52 +0,0 @@
|
||||
# The dedicated server under systemd
|
||||
|
||||
`halo-server@.service` runs the dedicated server (`docs/dedicated_server.md`)
|
||||
as a templated unit: one instance for each folder
|
||||
`/opt/opence/servers/<name>`, all sharing one release in `/opt/opence/bin`
|
||||
and one read-only copy of the game data in `/opt/opence/data`.
|
||||
|
||||
| Path | What |
|
||||
| --- | --- |
|
||||
| `/opt/opence/bin/` | The release (`halo-linux-release.zip`, unzipped) |
|
||||
| `/opt/opence/data/` | The game data, only read: `maps/`, `custom_maps/`, `gametypes/` |
|
||||
| `/opt/opence/servers/<name>/` | The instance's own, the only folder it may write: `config.toml`, `init.txt`, `publisher.key`, `server.env`, `saves/` (the map cache), `logs/` |
|
||||
|
||||
## Installing
|
||||
|
||||
```sh
|
||||
sudo useradd --system --home-dir /opt/opence --shell /usr/sbin/nologin halo
|
||||
sudo install -d -o halo -g halo -m 0750 /opt/opence/servers/main
|
||||
sudo cp deploy/systemd/halo-server@.service /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now halo-server@main
|
||||
journalctl -u halo-server@main -f
|
||||
```
|
||||
|
||||
Open UDP 2302 (the instance's `network.tunnel_port`) in the firewall.
|
||||
|
||||
## Settings
|
||||
|
||||
`server.env` in the instance's folder holds its settings as `HALO_*`
|
||||
variables, one a line (port/linux/README.md, "Dedicated server"). A
|
||||
variable set there wins over `config.toml`, and `sv_set` and the web page
|
||||
cannot change it; leave out what you want to change from the web page.
|
||||
|
||||
A second instance on the machine needs ports of its own, and its own
|
||||
loopback address for system link:
|
||||
|
||||
```sh
|
||||
HALO_NET_TUNNEL_PORT=2303
|
||||
HALO_SERVER_WEB_PORT=8081
|
||||
HALO_NET_ADDRESS=127.0.0.2
|
||||
HALO_NET_BROADCAST=127.0.0.1
|
||||
```
|
||||
|
||||
The web port stays on 127.0.0.1 unless `server.env` says otherwise (and
|
||||
then it needs a password, and TLS in front of it).
|
||||
|
||||
## Exit codes
|
||||
|
||||
Exit code 5 (`sv_restart`, or an update installed) restarts the server; 2
|
||||
(no usable maps) and 3 (bad configuration) do not, as a restart would fail
|
||||
the same way. The unit has no console (`StandardInput=null`): commands come
|
||||
from `init.txt` and the web port.
|
||||
@@ -1,96 +0,0 @@
|
||||
# A dedicated server under systemd (docs/dedicated_server.md), one instance
|
||||
# for each folder /opt/opence/servers/<name>:
|
||||
#
|
||||
# /opt/opence/bin/ the release (halo-linux-release.zip, unzipped)
|
||||
# /opt/opence/data/ the game data, shared by every instance and
|
||||
# only read: maps/, custom_maps/, gametypes/
|
||||
# /opt/opence/servers/<name>/ the instance's own: config.toml, init.txt,
|
||||
# publisher.key, server.env, logs/, saves/
|
||||
#
|
||||
# server.env holds the instance's settings as HALO_* variables, one a line.
|
||||
# A second instance on the machine needs its own ports, and its own loopback
|
||||
# address for system link:
|
||||
#
|
||||
# HALO_NET_TUNNEL_PORT=2303
|
||||
# HALO_SERVER_WEB_PORT=8081
|
||||
# HALO_NET_ADDRESS=127.0.0.2
|
||||
# HALO_NET_BROADCAST=127.0.0.1
|
||||
#
|
||||
# Install:
|
||||
# sudo useradd --system --home-dir /opt/opence --shell /usr/sbin/nologin halo
|
||||
# sudo install -d -o halo -g halo -m 0750 /opt/opence/servers/main
|
||||
# sudo cp deploy/systemd/halo-server@.service /etc/systemd/system/
|
||||
# sudo systemctl daemon-reload
|
||||
# sudo systemctl enable --now halo-server@main
|
||||
# journalctl -u halo-server@main -f
|
||||
#
|
||||
# Open UDP 2302 (each instance's network.tunnel_port) in the firewall. The
|
||||
# web port stays on 127.0.0.1 unless server.env says otherwise.
|
||||
#
|
||||
# Exit code 5 (sv_restart, or an update installed) restarts the server;
|
||||
# 2 (no usable maps) and 3 (bad configuration) do not, as a restart would
|
||||
# fail the same way.
|
||||
[Unit]
|
||||
Description=OpenCE dedicated server %i
|
||||
Documentation=https://github.com/OpenCommunityEdition/OpenCE/blob/main/docs/dedicated_server.md
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=exec
|
||||
User=halo
|
||||
Group=halo
|
||||
WorkingDirectory=/opt/opence/servers/%i
|
||||
Environment=HOME=/opt/opence/servers/%i
|
||||
Environment=HALO_CONFIG_FILE=/opt/opence/servers/%i/config.toml
|
||||
Environment=HALO_DATA_ROOT=/opt/opence/data
|
||||
Environment=HALO_SAVE_ROOT=/opt/opence/servers/%i/saves
|
||||
Environment=HALO_LOG_ROOT=/opt/opence/servers/%i/logs
|
||||
Environment=HALO_SERVER_INIT_FILE=/opt/opence/servers/%i/init.txt
|
||||
Environment=HALO_NET_TUNNEL_PORT=2302
|
||||
EnvironmentFile=-/opt/opence/servers/%i/server.env
|
||||
ExecStartPre=/bin/mkdir -p /opt/opence/servers/%i/logs /opt/opence/servers/%i/saves
|
||||
ExecStart=/opt/opence/bin/halo --server
|
||||
# (no console: commands come from init.txt and the web port)
|
||||
StandardInput=null
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
KillSignal=SIGTERM
|
||||
TimeoutStopSec=15
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
RestartForceExitStatus=5
|
||||
RestartPreventExitStatus=2 3
|
||||
# (no privileges, nothing writable but the instance's folder)
|
||||
NoNewPrivileges=yes
|
||||
CapabilityBoundingSet=
|
||||
AmbientCapabilities=
|
||||
ProtectSystem=strict
|
||||
ReadWritePaths=/opt/opence/servers/%i
|
||||
ProtectHome=yes
|
||||
PrivateTmp=yes
|
||||
PrivateDevices=yes
|
||||
ProtectKernelTunables=yes
|
||||
ProtectKernelModules=yes
|
||||
ProtectKernelLogs=yes
|
||||
ProtectControlGroups=yes
|
||||
ProtectClock=yes
|
||||
ProtectHostname=yes
|
||||
ProtectProc=invisible
|
||||
RestrictAddressFamilies=AF_INET AF_UNIX AF_NETLINK
|
||||
RestrictNamespaces=yes
|
||||
RestrictRealtime=yes
|
||||
RestrictSUIDSGID=yes
|
||||
LockPersonality=yes
|
||||
MemoryDenyWriteExecute=yes
|
||||
# (a 32-bit x86 program)
|
||||
SystemCallArchitectures=native x86
|
||||
SystemCallFilter=@system-service
|
||||
SystemCallFilter=~@privileged
|
||||
SystemCallErrorNumber=EPERM
|
||||
UMask=0027
|
||||
MemoryMax=600M
|
||||
TasksMax=64
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,240 +0,0 @@
|
||||
> This is the README of [OpenCE](https://github.com/OpenCommunityEdition/OpenCE),
|
||||
> the port Mjolnir VR is built on, kept for its build and
|
||||
> development notes. Its download links are OpenCE's. For the VR mod, see
|
||||
> the [main README](../README.md).
|
||||
|
||||
# Halo: Combat Evolved for Linux, Windows, Android and the web
|
||||
|
||||
[](https://discord.gg/9gqcHyr5km)
|
||||
|
||||
This project is a port of the Halo: Combat Evolved decompilation to Linux,
|
||||
Windows, Android and web browsers. The decompilation is of the Xbox build 2342
|
||||
(`cachebeta.exe`, SHA-256
|
||||
`4cc87b45f721270392a96f1674ed2b5cd4a7bb4355faeab4531d1cf1884d9520`).
|
||||
|
||||
<img width="1289" height="995" alt="The game on Linux" src="https://github.com/user-attachments/assets/0d3ad50f-f8b8-46cf-aef8-e3661da2a7d7" />
|
||||
|
||||
The port starts from the decompilation of [bnunu/halo-1](https://github.com/bnunu/halo-1).
|
||||
That project is a fork of [punpckhdq/halo](https://github.com/punpckhdq/halo).
|
||||
|
||||
## Download
|
||||
|
||||
GitHub Actions builds the game for each commit. These links download the
|
||||
builds of the latest release:
|
||||
|
||||
| Platform | Release | Debug |
|
||||
| --- | --- | --- |
|
||||
| Linux | [halo-linux-release.zip](https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-linux-release.zip) | [halo-linux-debug.zip](https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-linux-debug.zip) |
|
||||
| Windows | [halo-windows-release.zip](https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-windows-release.zip) | [halo-windows-debug.zip](https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-windows-debug.zip) |
|
||||
| Android | [halo-android-release.zip](https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-android-release.zip) | [halo-android-debug.zip](https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-android-debug.zip) |
|
||||
| Web | [halocombatevolved.com](https://halocombatevolved.com/) (or [halo-web-release.zip](https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-web-release.zip) for your own server) | [halo-web-debug.zip](https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-web-debug.zip) |
|
||||
|
||||
Use the release build to play. The debug build stops at the first failed
|
||||
assertion and writes it to the log. Use the debug build to find and report
|
||||
problems.
|
||||
|
||||
The game updates itself. At start-up it looks for a newer release, and asks
|
||||
if you want to install it. Refer to "Updates" in
|
||||
[port/linux/README.md](port/linux/README.md#updates). The web site offers
|
||||
each new build when it is out.
|
||||
|
||||
Each build of the `main` branch that passes on all four platforms is a new
|
||||
release, and the web site then plays it. The [Releases](https://github.com/OpenCommunityEdition/OpenCE/releases)
|
||||
page keeps the last five releases. If the latest build has a problem, get
|
||||
an older build from that page.
|
||||
|
||||
### Arch-based Linux Distributions
|
||||
|
||||
The above Linux binary release is available on the [AUR](https://aur.archlinux.org/packages/opence-bin).
|
||||
|
||||
## Game data
|
||||
|
||||
The port does not include the game data. Download an Xbox disc image
|
||||
(`.xiso` or `.iso`) of Halo: Combat Evolved. All versions of the game
|
||||
operate. The maps of the European (PAL) version were made for a slower
|
||||
console. The port changes them to play as the North American (NTSC) maps do,
|
||||
so players of the two versions can play together.
|
||||
|
||||
1. Start the game.
|
||||
2. At the first start, the game asks for the disc image. Select it.
|
||||
3. The game extracts the `maps/` folder. Then the game starts.
|
||||
|
||||
On Linux and Windows, the game puts `maps/` next to the executable. On
|
||||
Android, copy the disc image to the phone first. The app puts `maps/` in its
|
||||
data folder. Refer to [port/android/README.md](port/android/README.md). On
|
||||
the web, the page copies `maps/` out of the disc image into the browser's
|
||||
storage for the site; nothing is uploaded. Refer to
|
||||
[port/web/README.md](port/web/README.md).
|
||||
|
||||
## Mods
|
||||
|
||||
Mods are folders of Halo PC tag files, as the Halo Editing Kit and Invader
|
||||
write them, in `mods/` next to `maps/`: texture, sound, text and model packs
|
||||
that play over the maps' on your machine only, in any game. Each has a
|
||||
`mod.toml`. Every mod in the folder is on; the main menu's Mods turns them
|
||||
off and on and sets the order they load in.
|
||||
Refer to [docs/mods.md](docs/mods.md).
|
||||
|
||||
## Platforms
|
||||
|
||||
Each platform has its own instructions:
|
||||
|
||||
| Platform | Instructions |
|
||||
| --- | --- |
|
||||
| Linux (32-bit x86 executable, OpenGL 4.5, SDL3) | [port/linux/README.md](port/linux/README.md) |
|
||||
| Windows (32-bit x86 executable, OpenGL 4.5, SDL3) | [port/windows/README.md](port/windows/README.md) |
|
||||
| Android (arm64 app, OpenGL ES 3, SDL3) | [port/android/README.md](port/android/README.md) |
|
||||
| Web (WebAssembly, WebGL 2, SDL3; desktop Chrome, Edge and Firefox) | [port/web/README.md](port/web/README.md) |
|
||||
|
||||
The Linux README also gives the controls, the settings and the multiplayer
|
||||
functions. These are almost the same on all platforms.
|
||||
|
||||
## Multiplayer
|
||||
|
||||
The game can play system link games on a local network and on the internet:
|
||||
|
||||
- A system link game can have up to 128 players on up to 128 machines.
|
||||
- Linux, Windows and Android machines and browsers can play in the same
|
||||
game. On a local network, the native builds play system link; browsers
|
||||
play each other in rooms, over WebRTC
|
||||
([port/web/README.md](port/web/README.md)).
|
||||
- An invite link, or the server browser, lets a machine join a game on the
|
||||
internet, browsers too: a native build takes a browser's WebRTC
|
||||
([port/linux/README.md](port/linux/README.md), "Browsers"). No server of
|
||||
this project is necessary.
|
||||
- The netcode is new. Each machine moves its own player at once,
|
||||
and the host makes the decisions for the game. Refer to
|
||||
[port/linux/NETCODE.md](port/linux/NETCODE.md).
|
||||
|
||||
## Build the game
|
||||
|
||||
You do not need the Xbox SDK. The port supplies the SDK declarations that
|
||||
the game uses. Refer to [port/include/xdk](port/include/xdk/README.md).
|
||||
|
||||
To build the game:
|
||||
|
||||
1. Install Python and [ninja](https://ninja-build.org/).
|
||||
2. Install the tools for your platform. Refer to the README for the
|
||||
platform.
|
||||
3. In the root folder of the repository, enter `python configure.py`.
|
||||
4. Enter `ninja` with the target for the platform:
|
||||
|
||||
| Target | Result |
|
||||
| --- | --- |
|
||||
| `ninja linux` | `build/linux/halo` |
|
||||
| `ninja windows` (on Windows) | `build/windows/halo.exe` and `SDL3.dll` |
|
||||
| `ninja android_apk` | `port/android/app/build/outputs/apk/debug/app-debug.apk` |
|
||||
| `ninja web` | `build/web/site/`, the web site (`python tools/web_serve.py` serves it) |
|
||||
|
||||
If you enter `ninja` without a target, ninja builds the game for the
|
||||
computer that you use.
|
||||
|
||||
`tools/ci_build.py` makes the same builds as GitHub Actions. For example,
|
||||
enter `python tools/ci_build.py linux release`.
|
||||
|
||||
### Build options
|
||||
|
||||
Give these options to `configure.py`:
|
||||
|
||||
| Option | Result |
|
||||
| --- | --- |
|
||||
| (none) | A debug build. A failed assertion stops the game. |
|
||||
| `--release` | A release build. The game does not examine assertions, as in the retail game. |
|
||||
| `--portable` | The Linux and Windows builds operate on all x86-64 processors. The Linux build also operates on older distributions and on SteamOS: refer to "Portable build" in [port/linux/README.md](port/linux/README.md#portable-build). Use this option for builds that you give to other persons. |
|
||||
| `--lto=thin`, `--lto=off` | Less link-time optimization. The link is faster. |
|
||||
| `--pgo=off` | No profile-guided optimization. |
|
||||
| `--pgo=train` | Records a new optimization profile. Refer to "Optimization profiles". |
|
||||
| `--profile` | A profiling build. It records CPU times. Refer to "Profiling builds". |
|
||||
| `--web-emcc PATH` | The Emscripten `emcc` for `ninja web` (else the one on the PATH, or `~/emsdk`'s). |
|
||||
|
||||
Without `--portable`, the Linux and Windows builds use all the instructions
|
||||
of the processor that builds them (`-march=native`). Such a build does not
|
||||
always start on a different computer.
|
||||
|
||||
### Optimization profiles
|
||||
|
||||
The builds use profiles of the game to optimize the code:
|
||||
|
||||
- `pgo/halo_linux.profdata` for Linux and Android.
|
||||
- `pgo/halo_windows.profdata` for Windows.
|
||||
|
||||
The profiles need clang 22 or later. With an older clang, the builds do not
|
||||
use the profiles.
|
||||
|
||||
To record a new profile:
|
||||
|
||||
1. Delete the profile.
|
||||
2. Enter `python configure.py --pgo=train`.
|
||||
3. Enter `ninja linux` or `ninja windows`.
|
||||
|
||||
The build then plays the main menu and the first minute of each campaign
|
||||
level. This procedure continues for approximately 15 minutes. The game
|
||||
data must be in `assets/`.
|
||||
|
||||
### Profiling builds
|
||||
|
||||
A profiling build records where the game spends its time.
|
||||
|
||||
1. Enter `python configure.py --profile`, then build as usual.
|
||||
2. Start a recording. Enter `profile_record` in the console (or the telnet
|
||||
console), or set `debug.profile_record = true` in `config.toml`. To
|
||||
record each game of a session, also set
|
||||
`debug.profile_record_when = "game"`.
|
||||
3. Stop the recording. Enter `profile_stop`, load another map, or quit.
|
||||
|
||||
The game writes numbered `.part<n>.json` files under `profiles/` in its data root
|
||||
and logs their paths. Parts are retained after the recording stops. Logs go to
|
||||
standard error; a Windows release build without standard error writes them to
|
||||
`halo.log` next to `halo.exe`.
|
||||
|
||||
`tools/net_report.py` is a helper for developers. Enter
|
||||
`python tools/net_report.py <recording.part1.json>` to read a recording
|
||||
as tables. The command also writes `<recording>.summary.txt`, a short text
|
||||
file.
|
||||
|
||||
| Command | Result |
|
||||
| --- | --- |
|
||||
| `profile_record [seconds]` | Starts a recording. With a number of seconds, the recording stops after that time. |
|
||||
| `profile_stop` | Stops the recording. |
|
||||
|
||||
`debug.profile_memory` sets the memory of a recording in MB (default 256,
|
||||
from 4 to 1024). A recording has no length limit:
|
||||
the game writes a part each time the memory is full. Refer to "Settings" in
|
||||
[port/linux/README.md](port/linux/README.md).
|
||||
|
||||
On Android, the files are in `/sdcard/Android/data/com.halo.decomp/files/profiles/`.
|
||||
Enter `adb pull` to copy the recording parts to a computer.
|
||||
|
||||
A profiling build plays with normal builds. It does not use
|
||||
`--pgo=train`.
|
||||
|
||||
## Licence
|
||||
|
||||
OpenCE is free software: you can give it to others and change it under the
|
||||
terms of the GNU Affero General Public License as published by the Free
|
||||
Software Foundation, version 3 of the License or (at your option) any later
|
||||
version (`AGPL-3.0-or-later`). It comes with no warranty. The full text is in
|
||||
[LICENSE](LICENSE).
|
||||
|
||||
- **From the change.** The AGPL applies from the commit that made the change,
|
||||
and to each release built from that commit or a later one. Earlier
|
||||
releases, and the source at every earlier commit, were released under
|
||||
[CC0 1.0](LICENSES/CC0-1.0.txt) and stay that way.
|
||||
- **What OpenCE builds on.** The decompilation of
|
||||
[punpckhdq/halo](https://github.com/punpckhdq/halo) is under the AGPL 3.0
|
||||
from 17 October 2026, and under CC0 1.0 before that date.
|
||||
[bnunu/halo-1](https://github.com/bnunu/halo-1) is under CC0 1.0.
|
||||
- **Contributions** are under `AGPL-3.0-or-later`. A change taken from a
|
||||
project under GPL 3.0 keeps that licence and its notices; the GPL 3.0 and
|
||||
the AGPL 3.0 let the two be combined (section 13 of each).
|
||||
- **Hosts and servers.** If you change the game and let other persons play
|
||||
with your version over a network (for example, as the host of an internet
|
||||
game, or on a web site), the AGPL asks you to offer them the source of
|
||||
your version (section 13). The game as released has its source here, and
|
||||
each release's source is its tag (`build-<n>`).
|
||||
- **Third-party code, fonts and art** keep their own licences, which are
|
||||
next to them (`port/third_party`, `port/assets/fonts`,
|
||||
`port/assets/icons`, `port/assets/text_filter`). The release downloads and
|
||||
the web site's `licenses.txt` carry their notices.
|
||||
- **Halo is not covered.** The licence covers the work of OpenCE's authors.
|
||||
It gives no rights in Halo, its maps or anything else that Microsoft owns.
|
||||
@@ -1,656 +0,0 @@
|
||||
# Halo Custom Edition maps
|
||||
|
||||
The native builds (Linux, Windows, Android) load and run Halo Custom Edition
|
||||
caches (`.map`, cache version 609), with the Custom Edition resource maps
|
||||
`bitmaps.map`, `sounds.map` and `loc.map`. A cache that needs OpenSauce
|
||||
(its OpenSauce header asks for memory upgrades, mod data files or the like)
|
||||
is refused, and `.yelo` files are never looked for; a `.map` that only
|
||||
carries OpenSauce's header and its `project_yellow` tags (SPV3's
|
||||
backwards-compatible releases) is run as stock Custom Edition runs it,
|
||||
neither read. The loader and the conversions come from DamnationCE
|
||||
(xshxdex98/DamnationCE), whose documentation this file grew from; in this
|
||||
build a Custom Edition map's tags are also checked by the tag validator, as
|
||||
the Xbox maps' are, before anything reads them
|
||||
(`port/linux/game/tag_validate.c`, [Checks](#checks)).
|
||||
|
||||
## Running a map
|
||||
|
||||
Custom Edition maps run when the `game.custom_edition` setting is on, as it
|
||||
is by default (`custom_edition = true` under `[game]` in `config.toml`, or
|
||||
`HALO_CUSTOM_EDITION`). Put the maps and Custom Edition's `bitmaps.map`,
|
||||
`sounds.map` and `loc.map` in the data root's `custom_maps` folder, beside
|
||||
its `maps` folder, which holds the game's own maps only; or set
|
||||
`paths.custom_edition` to a Halo Custom Edition install, whose `maps` folder
|
||||
(the Xbox drive `h:\`) is looked in after `custom_maps`.
|
||||
|
||||
A Custom Edition map's level name is `custom_maps\<name>`
|
||||
(`custom_edition_cache.h`, `CUSTOM_EDITION_LEVEL_NAME_PREFIX`), which none
|
||||
of the game's own levels has: only such a name is loaded from the Custom
|
||||
Edition folders, and never from `maps`. So a map named as one of the game's
|
||||
own levels (CMT's `a30.map`, Custom Edition's `bloodgulch.map`) is played as
|
||||
itself, apart from the level of its name, in the menus, the loader and
|
||||
network games, and is never taken for one of the campaign's levels (saved
|
||||
games, progress, the next level). The game engine keeps 63 characters of a
|
||||
level name, so a map whose file name is longer than 51 is not listed.
|
||||
|
||||
Maps keep their names. A network game's level name is the map's own
|
||||
(`custom_maps\hugeass`), and its game record's map version is the first 32
|
||||
bits of the map's hash (`port/linux/game/map_share_files.c`), so a client
|
||||
plays its file of that name and version, whatever else it has of the name
|
||||
(`custom_edition_map_find_version`); a player without it downloads it
|
||||
(`port/linux/NETCODE.md`, "Map sharing"). A download beside another version
|
||||
of its name is named `hugeass_0e2b3ee4.map`, the first 8 hexadecimal digits
|
||||
of its hash after `_`, and the menus show it as "Hugeass (2)". A level name
|
||||
without the hash (a saved last map, a test's) finds the one map of that
|
||||
name in `custom_maps`, and one with it (an earlier build's, which named
|
||||
every map so) the map given its name back. Maps in a Custom Edition
|
||||
install's folder are found and shared as `custom_maps`' are.
|
||||
|
||||
A map needs only the resource maps that hold its tags: its tag index says
|
||||
which (`cache_file_resource_maps_needed`, `cache_file_formats.c`: a tag
|
||||
whose entry's word at 0x18 is set is held whole by `bitmaps.map` for a
|
||||
bitmap, `sounds.map` for a sound, `loc.map` for a font, string list or HUD
|
||||
message text). A map without such tags of a kind plays without that
|
||||
resource map; one that lacks a resource map it needs is refused, saying
|
||||
which.
|
||||
|
||||
### In the menus
|
||||
|
||||
The map lists (New Game's, and the Map screen of Create Game's INTERNET and
|
||||
LAN and of split screen) have four kinds in their first row's chooser:
|
||||
SINGLEPLAYER (the campaign's levels), MULTIPLAYER (the Xbox's maps), and
|
||||
CUSTOM SINGLEPLAYER and CUSTOM MULTIPLAYER, the Custom Edition maps of the
|
||||
custom maps folders by the scenario type their files give (solo or
|
||||
multiplayer). A map is played as its kind says
|
||||
(`port/linux/game/menu_functions.c`):
|
||||
|
||||
- **New Game**: a CUSTOM SINGLEPLAYER map is played as the campaign's
|
||||
levels are, at the difficulty chosen next (alone, or with split screen
|
||||
co-op's two players); a CUSTOM MULTIPLAYER map is walked around alone, as
|
||||
MULTIPLAYER's are.
|
||||
- **The Map screen**: a CUSTOM SINGLEPLAYER map lists the difficulties and
|
||||
is hosted as a network co-op game (Server Setup, then the lobby), as the
|
||||
campaign's levels are; a CUSTOM MULTIPLAYER map goes on to the gametypes,
|
||||
as MULTIPLAYER's do. Split screen hosts only the multiplayer kinds.
|
||||
|
||||
The Xbox menus' multiplayer level list offers the Custom Edition multiplayer
|
||||
maps after the thirteen Xbox levels. The pregame lobby shows a Custom
|
||||
Edition map by its name and picture, multiplayer or campaign, and the game
|
||||
lists by its name (`port/linux/game/custom_edition_maps.c`). The folders are
|
||||
looked in once, and again each time a map list opens, which then shows maps
|
||||
added since. A map is listed under its file's name, `the_bay_of_pigs.map` as
|
||||
"The Bay Of Pigs". Two optional files beside the map give it what the Xbox
|
||||
levels have:
|
||||
|
||||
- `<name>.bmp`, its picture: an uncompressed 24-bit or 32-bit Windows
|
||||
bitmap, up to 8192 pixels a side; the middle of it is shown with the
|
||||
shape of the level pictures, 140 by 114 (`port/linux/game/bmp_files.c`,
|
||||
which reads it as untrusted input).
|
||||
- `<name>.txt`, its description: plain text, its lines shown as written.
|
||||
Without one, the map is described as "Halo Custom Edition map".
|
||||
|
||||
A machine joining a network game on a map it has not (a Custom Edition map
|
||||
not in its `custom_maps`, or one of the game's own not in `maps`) leaves it
|
||||
with an error that names the map and the folder to copy it into, rather
|
||||
than the damaged disc error precaching a missing map gives
|
||||
(`cache_files_map_present`, called as the host's settings arrive): also when
|
||||
the map cannot run there (Custom Edition maps turned off, the file not a
|
||||
Custom Edition cache, or `bitmaps.map`, `sounds.map` and `loc.map` missing),
|
||||
when its copy of a Custom Edition map is another version than the host's
|
||||
(the host sends its map's hash's first 32 bits as the game record's map
|
||||
version, which the Xbox left 0: `cache_files_map_version`; a host that sends
|
||||
0 is not checked), and when the host names a Custom Edition map as other
|
||||
versions of this port do (`levels\test\<name>\<name>`) and the file is in
|
||||
`custom_maps`. The
|
||||
error's text is wrapped to its dialog, in the menus' smaller font when it
|
||||
would not fit; `debug.txt` has the details.
|
||||
|
||||
A Custom Edition campaign map has no next level: winning it ends the game
|
||||
as the campaign's last level does (alone) or plays it again (network
|
||||
co-op), and it is not the campaign's saved game.
|
||||
|
||||
### From the console
|
||||
|
||||
`map_name` takes the level name: `custom_maps\<name>` for a Custom Edition
|
||||
map (`custom_maps\hugeass` plays `custom_maps\hugeass.map`). A multiplayer
|
||||
scenario needs a game variant, or no starting location qualifies and no
|
||||
player spawns:
|
||||
|
||||
```
|
||||
game_variant slayer
|
||||
map_name custom_maps\hugeass
|
||||
```
|
||||
|
||||
## What the native builds do
|
||||
|
||||
- **With `game.custom_edition` on**, the platform reserves the address
|
||||
window Custom Edition tag data is linked to, `0x40440000`-`0x41B40000`
|
||||
(`port/linux/src/xbox_memory.c`, at start-up; 23 MB of address space,
|
||||
backed as it is touched), and a Custom Edition map is loaded into it,
|
||||
converted as below, checked, and run. It is read in place, never copied
|
||||
to the cache partition: every read the game makes of it (structure BSPs,
|
||||
bitmap pixels, sound samples) is served from the map, `bitmaps.map`,
|
||||
`sounds.map` or the sounds decoded at load, according to where its offset
|
||||
falls in their combined offset space (`custom_edition_cache_read`). A map
|
||||
that fails any check is logged in `debug.txt` and not loaded: the game
|
||||
goes back to its menus.
|
||||
- **With it off**, a Custom Edition cache is named and refused, instead of
|
||||
being rejected as "an old version" of this build's caches; so is one put
|
||||
in `maps`, which is told to go in `custom_maps`.
|
||||
- **Xbox caches** take the path they took before.
|
||||
|
||||
The desktop builds' Xbox memory window is 512 MB (Android's 128 MB), in
|
||||
which the texture cache is 256 MB: Custom Edition maps draw more texture
|
||||
than the Xbox's 22 MB cache holds, and their geometry is made into
|
||||
Direct3D buffers in the same memory (`port/linux/include/halo_port_capacity.h`).
|
||||
|
||||
## Loading and conversion
|
||||
|
||||
### The loader (`cache_file_formats.c`)
|
||||
|
||||
`port/linux/game/cache_file_formats.c` (`cache_file_formats.h`) holds the
|
||||
format code: standalone C with fixed-width types and no game dependencies,
|
||||
compiled into the native builds (as every `port/linux/game` unit is) and
|
||||
into the report tool. Map files are untrusted input: every field is read
|
||||
little-endian from a bounds-checked buffer, never through a structure laid
|
||||
over the file, and every offset, count and size is checked before use, with
|
||||
overflow-safe arithmetic. `port/tools/cache_file_report.c` reports what can
|
||||
be done with each file:
|
||||
|
||||
```sh
|
||||
clang --target=i686-pc-windows-msvc -fuse-ld=lld -Iport/linux/game \
|
||||
port/linux/game/cache_file_formats.c port/tools/cache_file_report.c -o cache_file_report.exe
|
||||
cache_file_report [--maps DIRECTORY] [--dump-tags FILE] FILE...
|
||||
```
|
||||
|
||||
Resource maps are looked for next to the cache (or in `--maps`):
|
||||
`bitmaps.map`, `sounds.map` and `loc.map`. `--dump-tags` writes the converted
|
||||
tags to a file, as they would sit at `0x40440000`.
|
||||
|
||||
Loading, step by step (`custom_edition_cache_load`):
|
||||
|
||||
1. The header: signatures, version 609, terminated strings, file length (0,
|
||||
as Invader leaves it, for the whole file) within the file and the size
|
||||
limit (`0x30000000`: Halo PC's was `0x18000000`, and Invader builds
|
||||
larger maps, which Chimera runs), no compression, tag data within the
|
||||
file and the tag cache (23 MB). A cache with OpenSauce's header (its
|
||||
`yelo` signature at offset `0x70`, which Custom Edition leaves as
|
||||
padding) that sets any of its flags (memory upgrades, mod data files and
|
||||
the rest) is refused; one that sets none is a Custom Edition cache.
|
||||
2. The tag data is read to the start of the tag cache, which stands for
|
||||
`0x40440000`.
|
||||
3. The tag index (`tags` signature), every tag instance (its handle must
|
||||
match its position, its name must lie in the tag data and be terminated,
|
||||
its address must lie in the tag data; only structure BSPs may have none;
|
||||
only bitmaps, sounds, fonts, unicode string lists and HUD message text may
|
||||
be held by resource maps; OpenSauce's `project_yellow` and
|
||||
`project_yellow_globals`, which nothing reads, are left as they are), the
|
||||
model data range, and the scenario tag.
|
||||
4. Every structure BSP: its tag, its range in the file, its place in the tag
|
||||
cache (above the tag data, within the tag cache), its header (`sbsp`
|
||||
signature, no Xbox vertex buffers, its structure pointer inside it), and
|
||||
its lightmaps and their materials: every block within the BSP and aligned,
|
||||
every material's uncompressed environment vertices (56 bytes) and
|
||||
lightmap vertices (20 bytes) within the BSP and of the size their counts
|
||||
give, at most 64000 of each (the game's limit, to which the validator
|
||||
cuts a material's counts), lightmap vertices exactly when the lightmap
|
||||
has a bitmap, and every normal, binormal, tangent and incident radiosity
|
||||
within ±1.005 (the game's vertex compressor asserts on anything further
|
||||
out).
|
||||
5. The header checksum is computed as OpenSauce computes it, before anything
|
||||
changes the tag data; a mismatch is reported, not refused.
|
||||
6. The tags held by resource maps are read into the tag cache after the tag
|
||||
data, below the lowest structure BSP, and their pointers relocated. A
|
||||
sound's header in the map lacks its sample rate, encoding, compression
|
||||
and longest permutation length; they are taken from the header's copy in
|
||||
`sounds.map` ([Evidence](#observed-not-stated-by-the-sources-established-on-the-sample-maps)).
|
||||
7. Every bitmap, sound, font, unicode string list, HUD message text, model
|
||||
(`mod2`) and transparent chicago shader (`schi`, `scex`) is walked through
|
||||
its blocks: every block and data pointer must lie within the loaded tags,
|
||||
every bitmap's pixels and sound's samples within their file, and every
|
||||
model part's strip and vertices within the model data, of the kinds Custom
|
||||
Edition writes (a precompiled strip, uncompressed 68-byte vertices), with
|
||||
at most 65535 vertices and at most 22 local nodes.
|
||||
|
||||
Then `custom_edition_cache_convert` changes what only needs its bytes
|
||||
changed:
|
||||
|
||||
- **Shader types.** Custom Edition inserted *transparent chicago extended*
|
||||
as shader type 7, so its water, glass, meter and plasma shaders are types
|
||||
8 to 11 where this build has 7 to 10 (and would draw a Custom Edition glass
|
||||
shader as meter, and so on, unnoticed). Every shader gets this build's
|
||||
number for its group; a type field saying otherwise (as map protection
|
||||
leaves them) is counted and given the group's.
|
||||
- **Transparent chicago extended shaders** (`scex`) become transparent
|
||||
chicago shaders (`schi`): the two layouts agree up to the maps, of which
|
||||
`scex` has two sets, for four and for two texture stages; the four-stage
|
||||
maps are kept (this build draws four stages), or the two-stage ones when
|
||||
there are no others, and the extra flags move to where `schi` has them.
|
||||
- **Bitmaps and sound permutations** get the state of ones not yet drawn or
|
||||
played, and name their own tags: `bitmaps.map` and `sounds.map` hold the
|
||||
tag handles of whatever map they were built with.
|
||||
- **Sounds this build cannot decode** (Custom Edition's Ogg Vorbis) are made
|
||||
unplayable, by emptying their pitch ranges, which the game skips.
|
||||
- **Animation overlays naming animations that do not exist** are made to
|
||||
name none, which the game skips. Maps built with the editing kit can have
|
||||
them; Custom Edition reads past the graph's animations there, and this
|
||||
build's debug builds stop on it.
|
||||
- **HUD elements drawn from double-resolution bitmaps.** Halo PC added a
|
||||
third scaling flag to HUD placements, *use high resolution scale*
|
||||
(OpenSauce `hud_definitions.hpp`), and draws a flagged element at half the
|
||||
size of its bitmap. Custom Edition's HUD bitmaps are made for that: in
|
||||
`bloodgulch.map` every flagged element draws a bitmap exactly twice the
|
||||
size of the one its Xbox counterpart draws (256×64 for 128×32, 512×512 for
|
||||
256×256), with the same scale, and every unflagged one a bitmap of the same
|
||||
size ([Evidence](#observed-not-stated-by-the-sources-established-on-the-sample-maps)).
|
||||
This build ignores the flag, so it drew them twice too large; the
|
||||
placements of the unit, weapon and grenade HUD interfaces and the HUD
|
||||
globals' messages that have it get half their scale, and lose the flag (32
|
||||
in `bloodgulch.map`). Halo PC reads the flag only on statics, meters and
|
||||
numbers (Chimera's `hud_bitmap_scale.cpp`): crosshair and overlay items
|
||||
keep their scale. A number's scale is not its
|
||||
digits', so a flagged number keeps the flag and `hud_draw_numbers` draws
|
||||
its digits at half their size, spaced as the digits tag says. A bitmap may ask the
|
||||
same of every element that draws it, with Halo PC's bitmap flags *half hud
|
||||
scale* and *force hud use highres scale* (Invader's `bitmap.json`): an
|
||||
element drawing such a bitmap (a static or meter, its bitmap after its
|
||||
placement; a crosshair's or overlay's items, their crosshair's or
|
||||
overlay's) gets half its scale too. None of the 18 Custom Edition maps on
|
||||
hand, nor `bitmaps.map`, sets either.
|
||||
- **Maps made around Halo PC's own behaviour.** Chimera fixes Halo PC to draw
|
||||
as the Xbox does, and keeps a list of the maps made around Halo PC's way
|
||||
instead, by map name (in lower case) and tag data checksum, with the
|
||||
behaviours each relies on (`map_hacks_config.json`, by SnowyMouse; here
|
||||
`port/linux/game/custom_edition_behaviours.inc`, generated from it). This
|
||||
build draws as the Xbox does, so for a listed map it follows these where it
|
||||
can, and logs each: HUD multitexture overlays' blend functions in Halo PC's
|
||||
order (`gearbox_multitexture_blend_modes`: Halo PC picks its shader by the
|
||||
Xbox's value from shaders in alphabetical order), overlays not drawn
|
||||
(`block_multitexture_overlays`), the HUD digits' metrics halved and every
|
||||
number's digits drawn at half size (`hud_number_scale`), bitmaps' HUD scale
|
||||
flags cleared (`disable_bitmap_hud_scale_flags`), and model shaders'
|
||||
detail after reflection flag flipped (`invert_detail_after_reflection`).
|
||||
Not yet: Halo PC's fixed-function meters (`gearbox_meters`), its
|
||||
transparent chicago multiply, bump attenuation and environment shader
|
||||
types, the old widescreen HUD and embedded Lua.
|
||||
- **The score hint.** String 100 of `ui\multiplayer_game_text` is Halo PC's
|
||||
`Hold "%s" for score`, which Halo PC fills in with its score key; this
|
||||
build copies it as it is (`game_engine.c`, the press-back-for-score
|
||||
message), so `"%s"` becomes `BACK`, the button this build reads for the
|
||||
score, in the same four characters.
|
||||
|
||||
### In the game (`custom_edition_cache.c`, `custom_edition_geometry.c`, `custom_edition_bitmaps.c`)
|
||||
|
||||
- **Models.** Every `mod2` part is given this build's part layout (the first
|
||||
0x68 bytes of the 0x84-byte Custom Edition part are the same fields; the
|
||||
parts are repacked in place), its vertices are compressed from the map's
|
||||
model data by the game's own `rasterizer_geometry_compress_vertices`, its
|
||||
node indices made the model's when its model's parts have local nodes, and
|
||||
its strip copied unchanged; the game's own `rasterizer_vertex_buffer_new`
|
||||
and `rasterizer_triangle_buffer_new` make its buffers, and the tags become
|
||||
`mode` tags. Before any of that, every index a part holds is checked
|
||||
against what it names (shaders, nodes, parts, vertices). This build's
|
||||
renderer skins at most 43 nodes at once, so a model of more is drawn a
|
||||
part's own nodes at a time: a model of more whose parts have no local
|
||||
nodes is given them, each part the nodes its vertices name, and is refused
|
||||
only when a part's vertices name more than a part holds.
|
||||
- **Structure BSPs.** When the game loads a BSP, every material's vertices
|
||||
are compressed the same way (environment and lightmap vertices), and the
|
||||
material gets buffers and the compressed vertices the game reads for
|
||||
visibility, collision and lights (`scenario_structure_bsp_load` in
|
||||
`cache_files.c` calls `custom_edition_structure_bsp_load`).
|
||||
- **Bitmaps.** Every bitmap must pass the game's own `bitmap_verify` and be
|
||||
of a kind the texture cache and the swizzling code handle (a format with a
|
||||
hardware texture, a compressed flag that agrees with the format,
|
||||
power-of-two sizes unless linear, square cube maps, all its pixels
|
||||
present). Halo PC draws a 2D bitmap of any size, so an uncompressed one
|
||||
whose sides are not powers of two is made linear as the map loads, and
|
||||
drawn from its first level (birdcage-plus's 3840 by 64 needler plasma).
|
||||
Its pixels are laid out for Halo PC, levels as the tag stores them,
|
||||
unswizzled; as they arrive, the game's own
|
||||
`rasterizer_xbox_bitmap_rebuild_hardware_format` lays them out as an Xbox
|
||||
cache would (swizzled, cube maps face by face, padded).
|
||||
- **Chicago extra layers.** January's transparent chicago shader draws its
|
||||
extra layers in a loop that never advances
|
||||
(`rasterizer_xbox_transparent_geometry.c`, marked as a preserved bug). No
|
||||
Xbox map has such layers, so January never hung on it, but Custom
|
||||
Edition's editing kit can make them: the native builds advance the loop.
|
||||
- **Channel orders.** Halo PC keeps two kinds of texture in other channels
|
||||
than this build reads them from (`enum custom_edition_channel_order`,
|
||||
[Evidence](#observed-not-stated-by-the-sources-established-on-the-sample-maps)):
|
||||
a model shader's *multipurpose map*, whose auxiliary (detail) mask,
|
||||
self-illumination, specular and color change masks Halo PC keeps in red,
|
||||
green, blue and alpha, where this build's model shaders read specular from
|
||||
red, self-illumination from green, color change from blue and the
|
||||
auxiliary mask from alpha; and a *HUD meter*, whose shape Halo PC keeps in
|
||||
color and fill order in alpha, where this build's meter shader
|
||||
(`rasterizer_xbox_dynavobgeom.c`) compares the color with the meter's value
|
||||
and discards what has no alpha. Reordering the pixels would mean
|
||||
decompressing them, which the texture cache has no room for, so the game
|
||||
finds the bitmaps drawn as multipurpose maps (by model shaders) and as
|
||||
meters (by unit and weapon HUD interfaces) when the map loads, and tells
|
||||
the renderer where each bitmap's pixels arrive and in which order their
|
||||
channels are; the renderer samples them with each channel taken from where
|
||||
Halo PC keeps it (`port/linux/src/xbox_textures.c`, a texture swizzle,
|
||||
which leaves them compressed). A bitmap also drawn another way (a
|
||||
multipurpose map that is also a base map, say) keeps its channels, since
|
||||
the renderer has one order for each texture, and is logged: 3 in
|
||||
`bloodgulch.map`, all multipurpose maps.
|
||||
- **Reads.** The renderer write-protects the memory it has made textures of
|
||||
and learns of changes from the faults writes take; the kernel fails a read
|
||||
into such memory instead. Every read of the map is therefore made into a
|
||||
64 KB staging buffer and copied, as the platform's file layer does.
|
||||
- **Texture memory.** A frame of `Elite_Alpha_Siege.map` draws more than the
|
||||
22 MB of textures the Xbox texture cache holds, and textures that did not
|
||||
fit were drawn as the default one. The desktop builds' texture cache is
|
||||
256 MB, in a 512 MB memory window (`halo_port_capacity.h`), for every map;
|
||||
Android's is the Xbox's.
|
||||
- **Scripts.** A compiled script names each function it calls, and each
|
||||
engine global it uses, by its index in the engine's tables, and Halo PC's
|
||||
tables have entries this build's do not, in among the ones both have: from
|
||||
some point on, an index names another entry here
|
||||
([Evidence](#observed-not-stated-by-the-sources-established-on-the-sample-maps)).
|
||||
`hugeass.map`'s day and night script would call `playback` instead of
|
||||
`switch_bsp`. A compiled script also keeps every name, in its string data,
|
||||
so every call and every engine global is found again by name with the
|
||||
game's own `hs_find_function_by_name` and `hs_find_global_by_name`
|
||||
(`custom_edition_scripts.c`); one this build does not have does nothing
|
||||
and is logged by name (Limits, below). The value types are numbered
|
||||
alike in both builds.
|
||||
- **Multiplayer vehicle placement.** This build places a multiplayer game's
|
||||
vehicles by type: only the first three of the globals' multiplayer
|
||||
vehicles are created, and of those the ones the variant's vehicle set
|
||||
names (`game_engine_remap_vehicle`; the built-in variants name the first).
|
||||
Custom Edition maps are made for retail Halo's rules: a vehicle placement's
|
||||
multiplayer spawn flags name the game types it is placed in by default,
|
||||
and a script may create any vehicle. `hugeass.map` depends on that (above).
|
||||
For a Custom Edition map in slayer, capture the flag, king of the hill or
|
||||
oddball, the native builds place the vehicles whose spawn flags name the
|
||||
game type by default and let any vehicle be created
|
||||
(`custom_edition_objects.c`, called from `object_types_place_all` and
|
||||
`game_engine_remap_vehicle`); a variant without
|
||||
vehicles still has none, and race, which has no spawn flag, keeps this
|
||||
build's rule.
|
||||
- **Multiplayer vehicles.** `game_engine_predict_resources` takes the three
|
||||
multiplayer vehicles Xbox globals always have; a Custom Edition map's
|
||||
globals can list fewer, and oddball stopped on such a map. With fewer than
|
||||
three, the native builds predict none (`game_engine.c`).
|
||||
|
||||
## Checks
|
||||
|
||||
The loader (`cache_file_formats.c`) checks the container: the header, the
|
||||
tag index, every structure BSP, every resource-held tag and its relocated
|
||||
pointers, every bitmap pixel and sound sample range, every model part's
|
||||
geometry in the model data. Then, once the loader and the conversion of
|
||||
bytes have made the tags this build's layout, the tag validator checks
|
||||
every tag as it checks an Xbox map's (`tag_validate_custom_edition_tags`,
|
||||
called by `custom_edition_cache_tags_load`): every block and data within
|
||||
the loaded tags and overlapping no other's, counts cut to the game's
|
||||
capacities, indices, enums and tag references corrected, runtime values
|
||||
reset, then the graph checks (collision BSPs, node trees, scripts' syntax),
|
||||
and a tag name that lies in any tag's block or data is emptied (what the
|
||||
game writes there could take away its end). A map whose pointers cannot be
|
||||
trusted is refused; what can be corrected is, and logged. What differs
|
||||
from an Xbox map:
|
||||
|
||||
- the tag header has no vertex or index buffers, and the tag cache is the
|
||||
Custom Edition one (23 MB);
|
||||
- bitmap pixels and sound samples are in several files: their offsets must
|
||||
lie in the map, the sounds decoded at load, `bitmaps.map` or `sounds.map`;
|
||||
- models are gbxmodels (`mod2`), whose parts keep their geometry in the
|
||||
map's model data and a table of local nodes, which are checked against
|
||||
the model's (`tag_schema_custom_edition_groups`, in `tag_schema_models.c`);
|
||||
the game takes them as models;
|
||||
- a structure BSP's material vertices are uncompressed, and are checked
|
||||
against its uncompressed vertex data.
|
||||
|
||||
Only after the validator has passed the tags are the scripts given this
|
||||
build's function and global indices, the bitmaps checked for the texture
|
||||
cache, and the models and each structure BSP (checked as it loads, as an
|
||||
Xbox map's) given compressed vertices and buffers. The script function
|
||||
allowlist (`hs.c`) applies to Custom Edition maps as to every map.
|
||||
|
||||
`build/linux/map_validate` runs the loader, the conversion of bytes and the
|
||||
validator on maps outside the game, with the resource maps beside each map
|
||||
or in `--maps`; `--fuzz` changes words of a map's file at random.
|
||||
|
||||
## Tested
|
||||
|
||||
### Automated tests
|
||||
|
||||
- `python -m pytest tools/test_cache_file_formats.py` (130 tests; needs
|
||||
clang): synthetic Custom Edition caches and resource maps, caches that
|
||||
need OpenSauce refused and those that only carry its data loaded, every
|
||||
check of the loader and the conversion, and seeded random corruptions,
|
||||
through `port/tools/cache_file_report.c`. With `HALO_CUSTOM_EDITION_MAPS`
|
||||
naming a folder of maps, four more check real maps: against DamnationCE's
|
||||
recorded results (which are of its copies of the stock maps), and that any
|
||||
`.yelo` map among them is either refused or a Custom Edition cache.
|
||||
- `python -m pytest tools/test_bmp_files.py` (41 tests): the map pictures'
|
||||
reader.
|
||||
- `tools/test_linux_port.py`: with `HALO_CUSTOM_EDITION_MAPS` (or the
|
||||
gitignored `assets/custom_edition`), every map is loaded and checked and
|
||||
none refused, and three are fuzzed (100 runs each); the retail Xbox maps
|
||||
still need no correction.
|
||||
|
||||
### Maps
|
||||
|
||||
Two folders were checked with `map_validate`: the 20 stock Custom Edition
|
||||
maps (the halopc-restored r220 copies) and 19 community maps (`area53`,
|
||||
`bigass`, `deltaruins`, `Elite_Alpha_Siege`, `extinction`, `Fission_Point`,
|
||||
`Floodgulch5.1`, `hugeass`, `immure`, `tactics`, `the_bay_of_pigs`,
|
||||
`the_rise_of_asis`, `WW_battlefield` and copies of stock levels). None is
|
||||
refused. The stock maps need one correction each, a character of
|
||||
`loc.map`'s gamespy font 5 pixels narrower than nothing; the community maps
|
||||
some more, their own data's mistakes (an enum past its values, a region
|
||||
index past its block, a particle state of a sequence with no sprites).
|
||||
Fuzzing, 200 runs of each of those 39 maps (7,800 runs): no crash, no hang,
|
||||
and every map let through clean when checked again.
|
||||
|
||||
Run in the game (Linux release build, 40 to 50 seconds each, slayer):
|
||||
`hugeass`, `bigass`, `extinction`, `deltaruins`, `Elite_Alpha_Siege`,
|
||||
`the_rise_of_asis`, `area53`, `tactics`, `Floodgulch5.1`, `immure`,
|
||||
`WW_battlefield`, `the_bay_of_pigs` and `Fission_Point` load, are checked,
|
||||
converted and played to the end of the run without a crash; `hugeass`'s
|
||||
hangar, HUD and first-person weapon were seen drawn.
|
||||
|
||||
Two campaign maps were checked with `map_validate`: CMT's `a30.map` (2006,
|
||||
"Halo"; 13 corrections) and CMT SPV3's backwards-compatible `a50.map` (2012,
|
||||
The Truth and Reconciliation, with OpenSauce's header setting no flags and
|
||||
its two `project_yellow` tags; 43 corrections); `a30` was also run. From the
|
||||
menus (on a virtual display): New Game's CUSTOM SINGLEPLAYER `a30` played as
|
||||
a campaign level at the difficulty chosen; the Map screen's (LAN) listed its
|
||||
difficulties, set up co-op in Server Setup and showed it in the lobby as
|
||||
co-op. With `debug.network_test`, two machines on loopback played
|
||||
`custom_maps\a30` as network co-op and `custom_maps\hugeass` as slayer; a
|
||||
joining machine with a maps folder missing the host's Xbox map was shown the
|
||||
error and left the game. A joining machine without `hugeass` (or without
|
||||
`sounds.map` and `loc.map` too) downloaded them and played (map sharing,
|
||||
`port/linux/NETCODE.md`): in the lobby, into a game in progress, from the
|
||||
host and another player at once with a second machine downloading beside it
|
||||
(on loopback, and through internet play's tunnels with a local broker), each
|
||||
file the same as the host's; with `network.map_download` off, or a host with
|
||||
`network.map_share` off, it was shown the error and left.
|
||||
|
||||
### Not tested
|
||||
|
||||
- **Playing**: nobody played the maps through.
|
||||
- **Android** builds, and was not run.
|
||||
|
||||
## Evidence
|
||||
|
||||
### Sources
|
||||
|
||||
- **OpenSauce** (GPL-3.0, Kornner Studios): the `OpenSauce-master.zip`
|
||||
archive of the upstream repository (SHA-256
|
||||
`f1097c9cf5975a208506c78c3af47d6b893f998a9f47dddf89c9bbcc1f4b7c73`; newest
|
||||
entry dated 2016-01-15; `yelo_version.hpp` names OpenSauce 4.0.0).
|
||||
- **Reclaimer** (GPL-3.0, Gravemind2401): the `Reclaimer-master.zip` archive
|
||||
(SHA-256 `72fd5270abbdf662ff07a54e9cce80a6158e479c51ecfdcd979f7f9fbd6c2d03`;
|
||||
newest entry dated 2026-09-20).
|
||||
- **The Xbox maps of retail build 01.10.12.2276** (`bloodgulch.map`,
|
||||
decompressed): not the 01.01.14.2342 build this repository reconstructs,
|
||||
but their model parts have its 0x68-byte layout and their shader types its
|
||||
numbering, which makes them a check on what the conversion produces.
|
||||
|
||||
No code from OpenSauce or Reclaimer (both GPL-3.0) was copied: they were
|
||||
read as documentation of the file formats, and every layout used was then
|
||||
checked against the sample maps.
|
||||
|
||||
### Documented facts (source, checked against the sample maps)
|
||||
|
||||
| Fact | Source |
|
||||
| --- | --- |
|
||||
| Cache header layout, version 609, `head`/`foot` signatures | OpenSauce `blamlib/Halo1/cache/cache_files_structures.hpp` (`s_cache_header`) |
|
||||
| Tag index (0x28 bytes, instances at 0x28, model data as file offsets) and tag instance (0x20 bytes, resource-map flag at 0x18) | same file (`s_cache_tag_header`, `s_cache_tag_instance`) |
|
||||
| OpenSauce's header at 0x70 begins with the `yelo` signature, where Custom Edition's header has padding, and has its flags (memory upgrades, mod data files, protected, game state upgrades, compression parameters) at 0x76 | OpenSauce `YeloLib/Halo1/cache/cache_files_structures_yelo.hpp` (`s_cache_header_yelo`) |
|
||||
| Tag cache at `0x40440000`, 23 MB; file size limits | OpenSauce `cache_constants.hpp`, `saved_game_constants.hpp` |
|
||||
| Resource map header and entries | OpenSauce `data_file_structures.hpp` |
|
||||
| Groups held by resource maps: bitmaps, sounds, fonts, unicode string lists, HUD message text | OpenSauce `blamlib/Halo1/cache/cache_files.cpp` (`cache_file_data_load`) |
|
||||
| Structure BSP reference (0x20), header (0x18), structure, lightmap and material layouts | OpenSauce `scenario_definitions.hpp`, `structure_bsp_definitions.hpp`; this build's `structure_bsp_definitions.h` agrees |
|
||||
| Bitmap, sequence, sprite, bitmap data layouts; pixels in `bitmaps.map` flag | OpenSauce `bitmaps/bitmap_group.hpp` |
|
||||
| Sound definition, pitch range, permutation layouts; samples-in-`sounds.map` flag | OpenSauce `sound/sound_definitions.hpp` |
|
||||
| Gbxmodel layout: the part (0x84 bytes) is this build's 0x68-byte part followed by a local node count and a 22-entry node table | OpenSauce `models/model_definitions.hpp` (`gbxmodel_geometry_part`) |
|
||||
| Where a part's strip and vertices lie in the model data (triangle count, strip offset, vertex count and offset in the buffer fields; 68-byte vertices) | Reclaimer `Blam/Halo1/GbxmodelTag.cs` (`ReadPCMeshes`) |
|
||||
| Shader types: *transparent chicago extended* inserted at 7, before water, glass, meter and plasma; its two map sets | OpenSauce `shaders/shader_definitions.hpp` |
|
||||
| Script syntax nodes: 19001 in the stock engine | OpenSauce `hs_constants.hpp` |
|
||||
| HUD message text layout | OpenSauce `interface/hud_messaging_definitions.hpp` |
|
||||
| Font (156 bytes) and unicode string list layouts | BlamLib `Blam/Halo1/Tags/Definitions/Misc.cs`, `Resources.cs` |
|
||||
| Bitmap tags in `bitmaps.map` by index, pixels by absolute offset | Reclaimer `Blam/Halo1/CacheFile.cs`, `BitmapTag.cs`, `BitmapsAddressTranslator.cs` |
|
||||
| The header checksum: CRC-32 of the structure BSPs (packed from 0x800), the model data and the tag data, not inverted | OpenSauce `cache_files_yelo.cpp` (`CalculateChecksumFromMemoryMap`), `memory_interface_base.cpp` (`CRC`); reproduces the stored checksum of 23 of the 24 sample caches |
|
||||
|
||||
### Observed (not stated by the sources; established on the sample maps)
|
||||
|
||||
| Fact | Evidence |
|
||||
| --- | --- |
|
||||
| Structure BSPs load at the top of the tag cache (`address + size` = `0x41B40000`) | all 24 caches (those with OpenSauce's memory upgrades at the top of its larger tag cache) |
|
||||
| Bitmaps, fonts, unicode string lists and HUD text held by resource maps: the tag's address field is the entry index, the entry's name is the tag's path, the entry is the whole tag with addresses counting from its start | 9,550 bitmaps, 68 fonts, 2,248 string lists, 23 HUD texts across the sample |
|
||||
| Sounds held by `sounds.map`: the map keeps the 0xA4-byte header, whose pitch range block has a count and no address; the entry named by the tag path holds the header again, then the pitch ranges and permutations, whose addresses count from the first pitch range | 7,397 sounds, 21,870 sample ranges |
|
||||
| The map's copy of a resource-held sound's header has its compression and longest permutation length zero, and its encoding and sample rate zero too; the entry's copy has them as the Xbox has them | in `bloodgulch.map` and `beavercreek_halo3.yelo`, the two copies of all 527 resource-held sounds differ only in those four fields, in pointers, and in the map's own promotion sound reference; for the 315 sounds the Xbox `bloodgulch.map` shares, the entry's sample rate, encoding and the runtime fields after the longest permutation length equal the Xbox's; its compression does except for the 38 that Custom Edition has as Ogg Vorbis, and its longest permutation length for 273 (the others differ by a few milliseconds or more, among them the Ogg Vorbis ones); its pitch ranges' runtime fields all do |
|
||||
| Sound permutations and resource-held bitmaps name tags of another map (the one the resource map was built with) | 632 of 676 bitmaps of `bloodgulch.map`; every resource-held permutation differs from the Xbox's own sound handle |
|
||||
| Model parts: the strip and vertex data are in the model data, never in the part's blocks; the triangle buffer is a precompiled strip and the vertices uncompressed; the part flag 2 is set on exactly the parts that have a node table | all 24 maps (10,934 parts) |
|
||||
| Converting a part's vertices with the game's compressor reproduces the Xbox's | for the 335 parts of the 60 models the Custom Edition and the Xbox `bloodgulch.map` share: identical strips; positions equal to within float rounding; texture coordinates and node weights exactly what the compressor makes of the Custom Edition values (clamped to ±1, as the Xbox also has them: `plant_broadleaf_short` has coordinates up to 3.0 in both); node indices the Custom Edition ones times 3, except that the Xbox writes an unweighted second node as -1 where the compressor writes the node Custom Edition names; normals within 0.002 |
|
||||
| Every node index of a vertex names a node of its part's table (in models whose parts have local nodes) or of its model, every table entry a node of the model, and every vector is within ±1.0001 | all 24 maps |
|
||||
| Structure BSP materials: environment vertices uncompressed (type 0), with lightmap vertices (as many as the environment ones) exactly in lightmaps that have a bitmap, and no compressed vertices | all 24 maps (the lightmap vertex type field is 0 or 2 regardless) |
|
||||
| Custom Edition shader type values are 7 to 11 for `scex`, `swat`, `sgla`, `smet`, `spla`; the Xbox's are 8, 9, 10 for `sgla`, `smet`, `spla` | every shader of the 24 maps, and of the Xbox `bloodgulch.map` |
|
||||
| Chicago shaders with extra layers: none in the stock maps or the Xbox `bloodgulch.map`; 2 in `beavercreek_halo3.yelo`, 2 in `celer_exile_odst_v2.yelo`, 4 in `extinctionrevanepic2.map`, 1 in `fy_killzone.yelo` | every `schi` and `scex` of the sample |
|
||||
| Compressed color plates are left out of caches: size kept, address 0 | every bitmap in `bitmaps.map` |
|
||||
| Font style references in `loc.map` are all `NONE` | all 3 fonts |
|
||||
| Sound compression value 3 is Ogg Vorbis, value 1 is Xbox ADPCM | in `sounds.map`, all 106 value-3 permutations start with `OggS`; all 1,365 value-1 permutations are whole 36-byte blocks |
|
||||
| `bitmaps.map` bitmaps are not swizzled, and cube maps hold each level's six faces together | all 1,467; 38 of 40 cube maps match that order when checked against their next level (one is uniform, one does not match) |
|
||||
| Multipurpose maps: Custom Edition's red, green, blue and alpha hold what the Xbox's alpha, green, red and blue do | the multipurpose maps the Custom Edition and the Xbox `bloodgulch.map` share, decoded and compared channel by channel (the cyborg's, the warthog's, the boulders') |
|
||||
| HUD meters: Custom Edition's alpha holds the Xbox's color (the fill order), and its color the Xbox's alpha (the shape) | `hud_ammo_meters`: Custom Edition's 512×512 A8R8G8B8 averaged down to the Xbox's 256×256 A8Y8 differs from the Xbox's luminance by 6.6 on average in alpha and 23 in color, and from its alpha by 12.3 in color and 23.4 in alpha; `hud_unit_meters` has its sprites rearranged, and shows the same swap when viewed. January's meter shader reads the fill order from color and discards texels without alpha |
|
||||
| HUD elements flagged *use high resolution scale* draw bitmaps twice the Xbox's size; others the same size | every unit and weapon HUD placement of `bloodgulch.map` whose tag the Xbox map also has (the motion sensor's foreground, unflagged, uses a 128×128 bitmap in both) |
|
||||
| Vehicle placements: the byte at 0x58 is the multiplayer team and the word at 0x5A the multiplayer spawn flags, default bits 0 to 3 (slayer, capture the flag, king of the hill, oddball) and allowed bits 8 to 11 | `hugeass.map`'s 78 vehicle placements: the byte is 1 on exactly the blue team's; the word is 0x0303 on warthogs, tachikomas and pelicans, 0x0F0F on ghosts, 0x0404 on 16 unnamed jets, 0x0808 on the night jet and 0 on vehicles its scripts create; OpenSauce leaves these bytes unnamed |
|
||||
| Script function and engine global tables: Halo PC's have entries this build's lacks, so a compiled index names another entry from some point on; value types are numbered alike | the compiled scripts of the sample, each call's function index against the name its first child keeps, and each engine global's index against its name: `timberland.map` 23 calls shifted (`player_effect_start` by 29), `ui.map` 11 (`camera_set` by 1), `hugeass.map` 3 calls and 1 global (`rider_ejection`, 158 against 147), `extinctionrevanepic2.map` 9 calls, and 4 of a function this build lacks; no other stock map has scripts; each call's value type is the type of its function here (1,485 of 1,485 in `hugeass.map`), or one the call site casts to |
|
||||
| Bitmaps the Xbox keeps in monochrome formats and Custom Edition as 32-bit color at the same size keep their channels (A8Y8 as A8R8G8B8 with red the luminance and alpha the alpha) | 24 of the 26 such bitmaps of `bloodgulch.map` decode to exactly the Xbox's values; the other 2 have other content |
|
||||
|
||||
### Assumptions (not verified)
|
||||
|
||||
- **Placement of resource-held tags.** They are placed after the tag data,
|
||||
aligned to 4 bytes, as OpenSauce's unimplemented loader outlines
|
||||
(`s_cache_file_data_load_state`); how Custom Edition itself places them is
|
||||
not known, and nothing found depends on it.
|
||||
- **Which chicago extended maps.** The four-stage maps are kept, as the
|
||||
renderer draws four stages; that Custom Edition's two-stage maps are a
|
||||
fallback for older hardware is an inference (BlamLib's exporter makes the
|
||||
same choice).
|
||||
- **Centroid nodes of local-node parts** are taken to be the model's nodes:
|
||||
they are within the model's node count in every map, and they are only
|
||||
used to sort transparent parts.
|
||||
- **Editing-kit pointers are cleared.** The definition pointers of relocated
|
||||
blocks and data are set to 0: they refer to nothing in the game process.
|
||||
- **Name comparison** is exact (case-sensitive), which matched every sample
|
||||
sound.
|
||||
|
||||
## Limits and remaining work
|
||||
|
||||
- **What the validator corrects is lost.** A community map's data that the
|
||||
validator corrects (an index past its block, an enum past its values) is
|
||||
what the game then runs; Halo PC read past such data unchecked.
|
||||
- **Ogg Vorbis sounds** are decoded when the map loads (stb_vorbis, with
|
||||
added bounds checks: `port/third_party/stb_vorbis`) and encoded again as
|
||||
Xbox ADPCM in memory (`port/linux/game/custom_edition_sounds.c`); one that
|
||||
cannot be decoded is silenced, and still logs when played.
|
||||
- **Models of 44 nodes or more** are drawn a part's nodes at a time, given
|
||||
local nodes when they have none; one whose part's vertices name more
|
||||
nodes than a part holds is refused.
|
||||
- **Linear bitmaps whose rows are not a multiple of 64 bytes**, and
|
||||
textures larger than 4096 pixels a side, are not drawn.
|
||||
- **Halo PC's HUD meters' minimum alpha** (where the Xbox's meters have an
|
||||
overlays block) is dropped, and **its weapon functions "primary firing on"
|
||||
and "secondary firing on"** are the Xbox's primary and secondary firing.
|
||||
- **Button prompts on replaced icon sheets** show what the map's icon bitmap
|
||||
has where the Xbox's buttons are.
|
||||
- **Channel orders are per texture**: multipurpose maps and meters also drawn
|
||||
another way keep Halo PC's channels.
|
||||
- **Scripts that use what this build does not have**: a call of a function
|
||||
this build lacks, or a read of an engine global it lacks, does nothing
|
||||
(a constant of its type's harmless value, logged by name:
|
||||
`custom_edition_scripts.c`); only one that gives a script's index refuses
|
||||
the map. Maps that need OpenSauce's runtime features are refused; a map
|
||||
that only carries its tags (`project_yellow`) runs without them, as on
|
||||
stock Custom Edition.
|
||||
- **Halo PC behaviours** some maps were made around (Chimera's map list,
|
||||
`custom_edition_behaviours.inc`) are followed where this build can, and
|
||||
each is logged.
|
||||
- **The conversions are one-way and in memory**: nothing is written to the
|
||||
map files.
|
||||
|
||||
### How far Custom Edition tags are from the Xbox tags
|
||||
|
||||
`tools/custom_edition_tag_footprints.py` compares the tags a Custom Edition
|
||||
cache and the Xbox cache of the same level both keep (same group, same name),
|
||||
without any tag definitions. A tag's *footprint* is the distance from its
|
||||
address to the next tag's (its structure and the block data after it); its
|
||||
*structure size* is estimated as the distance to the lowest address in the
|
||||
footprint that the footprint points at (its first child block). Equal
|
||||
footprints, level after level, suggest a group's layout is unchanged; they do
|
||||
not prove it.
|
||||
|
||||
The Xbox caches available are the retail ones, build 01.10.12.2276, not the
|
||||
01.01.14.2342 build this repository reconstructs: they stand in for it, and
|
||||
differences between the two Xbox builds are not measured. Run on the 14
|
||||
levels both sets have (13 multiplayer levels and `ui`):
|
||||
|
||||
```
|
||||
python tools/custom_edition_tag_footprints.py --blocks assets/custom_edition "<Xbox 2276>/maps"
|
||||
```
|
||||
|
||||
- **48 groups have the same footprint for every shared tag in every level**:
|
||||
`Soul actv ant! bipd colo cont deca eqip flag fog font foot grhi hmt hud#
|
||||
hudg itmc jpt! lens lifi ligh lsnd mach metr mgs2 mply part pctl phys pphy
|
||||
scen schi senv sgla sky smet snde soso spla ssce str# swat trak udlg unhi
|
||||
vcky vehi wind`. The shader groups among them have the same layout, but
|
||||
not the same type values (above).
|
||||
- **Groups whose footprints differ, but whose structures match**: UI widgets
|
||||
(`DeLa`, 464 of 657 footprints equal, 423 of 423 structures), animations
|
||||
(`antr`, 213/239), collision models (`coll`, 331/345), effects (`effe`,
|
||||
4140/4166), projectiles (`proj`, 197/210), weapon HUDs (`wphi`, 196/222),
|
||||
weapons (`weap`, 39/182, structures 182/182), globals (`matg`, 1/14,
|
||||
structures 14/14) and scenarios (`scnr`, 0/14, structures 13/14), plus, in
|
||||
`ui` only, bitmaps, sounds and string lists. These differ in their block
|
||||
data. The flamethrower's tags account for every `effe`, `proj` and `wphi`
|
||||
difference and all but one `coll` difference; 11 of the 14 weapons (every
|
||||
player weapon and both vehicle guns) differ in every level.
|
||||
- **What differs in those blocks** (`--blocks`: the top-level blocks of each
|
||||
differing tag, found without definitions and compared): almost always
|
||||
the number of elements, or whether a block has any, which is content:
|
||||
weapons 143 count and 26 presence differences, UI widgets 158 and 63,
|
||||
scenarios 36 and 13, projectiles 13, weapon HUDs 78 presence, collision
|
||||
models 26 count. Every weapon difference checked in Blood
|
||||
Gulch lies in a predicted-resources list (8-byte elements, weapon
|
||||
offset `0x4E4`; OpenSauce `weapon_definitions.hpp`), or, for the
|
||||
flamethrower, also in its attachments; the globals differ in their
|
||||
cheat powerups (16 against 14). The rest (flamethrower effects 26,
|
||||
globals 13, animations 39, one collision model, and 3 in `ui`) keep their element counts but
|
||||
span a different amount of data up to the next block, which this method
|
||||
cannot split into element size and nested content: for the globals, the
|
||||
block in question (`player_info`, 0xF4-byte elements without blocks of
|
||||
their own) spans more than its elements, so other data sits in the span.
|
||||
No difference found has to be a layout change, and the two maps run did
|
||||
not show one.
|
||||
- **Groups only Custom Edition has**: `mod2` (models), `scex` (a transparent
|
||||
shader type), `devc` and `tagc`, in all 14 levels; **only the Xbox has**:
|
||||
`mode` (models) and `sotr` (a transparent shader type), besides the groups
|
||||
Custom Edition keeps in resource maps.
|
||||
@@ -1,762 +0,0 @@
|
||||
# The dedicated server: reference
|
||||
|
||||
`halo --server` runs the game as a host with no window, sound or player of
|
||||
its own: other machines join it on the LAN, by its invite link or from the
|
||||
server browser, as they join any host. `port/linux/README.md`, "Dedicated
|
||||
server", says how to run one; this document is the reference for what it
|
||||
takes and answers: the command line, the exit codes, the commands, the
|
||||
HTTP API, the remote console (RCON) over WebSocket, the events, the log and
|
||||
the files. `docs/master_protocol.md` is the master servers' protocol, which
|
||||
the server publishes to and the server browser reads.
|
||||
|
||||
The code is `port/linux/src/server_*.c` (the platform side: the mode, the
|
||||
standard input, the log, the rotation's grammar, the HTTP and WebSocket
|
||||
server, the master servers' publisher) and `port/linux/game/server_*.c`
|
||||
(the game side: the director that plays one game after another, the
|
||||
commands, the gametypes, the status). The Android and web builds have no
|
||||
dedicated server: they compile those files to nothing, but for
|
||||
`server_json.c` (the JSON reader, which the server browser's list of master
|
||||
servers uses in every build) and `server_rotation.c` (the rotation's
|
||||
grammar and the gametype rules), which every build compiles.
|
||||
|
||||
## Panels and fleets
|
||||
|
||||
A game panel (Pterodactyl, PufferPanel, MCSManager: `deploy/`) runs one
|
||||
server and reads its standard output; `deploy/systemd` and `deploy/docker`
|
||||
run servers on one machine. For many servers on many machines, `opence-fleet`
|
||||
([github.com/OpenCommunityEdition/opence-fleet](https://github.com/OpenCommunityEdition/opence-fleet))
|
||||
is one control plane over them all: an agent on each machine runs the
|
||||
servers and drives each through this document's API, as the owner from
|
||||
the machine itself (`server.web_owner_password`, below). What it relies on
|
||||
is named in the status's and the RCON's `capabilities`: `owner_web` (the
|
||||
owner's role over the web, from loopback), `ban_address` (`sv_ban_address`,
|
||||
`POST /api/bans`), `stop` (`sv_stop`, `POST /api/stop`, the `drain` event),
|
||||
`event_addresses` (addresses in the player events) and `identity` (the
|
||||
status's `pid`, `instance`...).
|
||||
|
||||
## Command line
|
||||
|
||||
| Argument | What it does |
|
||||
| --- | --- |
|
||||
| `--server` | Dedicated server mode (as `HALO_SERVER=1` or `server.enabled = true`) |
|
||||
| `--config <path>` | The settings file; default `config.toml` beside the executable. `HALO_CONFIG_FILE`, when it is set, wins over `--config` |
|
||||
| `--version` | Prints `OpenCE build-<n> (network version <v>)` and exits 0 |
|
||||
| `--keygen` | Writes a new publisher key (`server.publisher_key_file`) unless one exists, prints its public key and key id, exits 0; exits 3 when the key cannot be made, read or written |
|
||||
| `--sign <text>` | Prints the publisher key's Ed25519 signature of the text, in hex (an application's proof of key), exits 0; exits 3 without a text or a usable key |
|
||||
| `--probe [<invite>]` | A look at a server, for a list site that shows its state: joins nothing and never starts a server (whatever `--server`, `HALO_SERVER` or `server.enabled` say). It finds the invite's game over its tunnel (without an invite, the LAN's first) and prints it as one line of JSON, the game of the invite's host alone (never another game that answers), and exits 0; when nothing answers in 30 seconds it prints `{"ok":false,"error":"no game answered in 30 seconds"}` and exits 1. Internet play is as set (`network.online`, on by default), which an invite needs |
|
||||
| `--help` | Prints these, exits 0 |
|
||||
|
||||
`--version`, `--help`, `--keygen`, `--sign` and `--probe` write no settings: the
|
||||
settings file is read, never completed or made. `--probe` wins over
|
||||
`--server`, `HALO_SERVER` and `server.enabled`: a probe never writes to
|
||||
`config.toml`.
|
||||
|
||||
A probe's line:
|
||||
|
||||
```json
|
||||
{"ok":true,"name":"OpenCE Server","map":"bloodgulch","gametype":"ctf","players":5,"max_players":16,
|
||||
"teams":true,"in_progress":true,"open":true,"dedicated":true,"network_version":38,"kind":0}
|
||||
```
|
||||
|
||||
`gametype` is the game engine's name (`ctf`, `slayer`, `oddball`, `king`,
|
||||
`race`, or `none`), `kind` the OpenCE gametype's kind the host sends (0 for
|
||||
none), `open` whether it takes players now.
|
||||
|
||||
The release has a `halo-server` script beside `halo`, which runs
|
||||
`halo --server` with its arguments.
|
||||
|
||||
## Exit codes and signals
|
||||
|
||||
| Code | Meaning |
|
||||
| --- | --- |
|
||||
| 0 | Stopped: `quit`, `sv_stop` (now, or at the end of its drain), SIGTERM or SIGINT |
|
||||
| 1 | A fatal error in the game (a halt, a map that failed to load); the last error lines were logged. The process exits within 5 seconds of the error, even when what runs at the exit (a hook, a listing's withdrawal) does not return |
|
||||
| 2 | No usable game data: `maps/ui.map`, or every rotation map, missing or not a cache file; nothing was bound |
|
||||
| 3 | Bad server configuration: no rotation entry that can be played (and `server.rotation_fallback` off), `server.web_port` past 65535, a web port the server may not bind (a port below 1024 without the right to it) or whose `server.web_bind` is an address the machine does not have, or a web password (admin, moderator or viewer) shorter than 8 characters with the web port bound beyond loopback (on loopback, a warning), or the owner's (`server.web_owner_password`) shorter than 8 wherever it is bound; `--keygen` or `--sign` failing. An entry that cannot be played (a bad gametype file among them) is left out with a warning: the server stops only when none is left |
|
||||
| 4 | A port in use: the tunnel's UDP port, or the web port (another program listens on it) |
|
||||
| 5 | Restart asked for (`sv_restart`, now or at the end of its drain, or an update installed: `server.auto_update = "install"` installs a new release once the server has been empty for 10 minutes, on a thread of its own: the server goes on meanwhile, and stops with 5 once it is empty again (a player who joined during the install plays on). An install that fails is tried again at the next check, 6 hours on) |
|
||||
| 128 + n | Stopped by signal n: a second SIGTERM or SIGINT, or the shutdown not done 5 seconds after the first |
|
||||
|
||||
SIGTERM and SIGINT stop the server: a game in progress goes to its
|
||||
postgame, every machine is told, the listings are withdrawn, and it exits 0.
|
||||
SIGHUP reloads the server's settings, the rotation and the gametype files
|
||||
(`sv_reload`). SIGUSR1 prints the status on standard output. SIGPIPE and
|
||||
SIGTTIN are ignored.
|
||||
|
||||
## Standard output
|
||||
|
||||
One line per event, for the operator and the panel:
|
||||
|
||||
```
|
||||
2026-10-19T18:03:11Z INFO server: ready (tunnel 2302/udp, web 127.0.0.1:8080, listing public)
|
||||
2026-10-19T18:03:40Z INFO player: Milenko joined (slot 0, machine 1)
|
||||
2026-10-19T18:04:02Z INFO game: started: CTF on bloodgulch, 2 players
|
||||
```
|
||||
|
||||
The fields are the time (UTC), the level (`INFO`, `WARN`, `ERROR`), the
|
||||
category (`server`, `lobby`, `game`, `player`, `chat`, `moderation`, `net`,
|
||||
`master`, `console`, `health`) and the text. `server: ready` is printed once,
|
||||
when the lobby is open and, for a public server, its listing has been
|
||||
published (or 10 seconds on, as the brokers are other people's): it is the
|
||||
line a panel waits for. With `server.log_format = "json"` each line is an
|
||||
object instead, and the line a panel waits for holds `"msg":"ready (`:
|
||||
|
||||
```json
|
||||
{"time":"2026-10-19T18:03:11Z","level":"info","cat":"server","msg":"ready (tunnel 2302/udp, ...)"}
|
||||
```
|
||||
|
||||
Every line is also kept in the log the web's viewers read (`/api/log`,
|
||||
`sv_log`, the RCON's `log` events), but for these, which go to standard
|
||||
output alone: the web password a first start makes, the invite (a
|
||||
private server's lets anyone in; `/api/status` gives it to admins), and
|
||||
the owner's console, the commands typed on standard input or read from the
|
||||
init file and what they answered (a password's command is shown as `(a
|
||||
password's command)` there too).
|
||||
|
||||
A health line comes once a minute: `health: players=3 frame_ms_max=4.1
|
||||
frame_ms_avg=1.20 cpu=2.1% rss=96MB` (the longest and the mean frame of
|
||||
the last minute, in milliseconds). Standard error keeps the platform
|
||||
layer's `halo-linux:` lines, and `debug.txt` everything, as for a player's
|
||||
game.
|
||||
|
||||
## Commands
|
||||
|
||||
The same commands come from standard input, `server.init_file` (run once at
|
||||
the start, a command a line, `#`, `;` and `//` starting comments), the telnet
|
||||
console (`debug.telnet_console`, loopback), the RCON, `POST /api/command`
|
||||
and the web page. Each runs on the game's thread between frames. Every
|
||||
command has a role; a caller may run it if their role is that one or above:
|
||||
**viewer** < **moderator** < **admin** < **owner** (standard input, the
|
||||
init file and the telnet console are the owner's: whoever holds the
|
||||
process; so is a sign-in to the web or the RCON with
|
||||
`server.web_owner_password` from the machine itself: "Signing in"). When
|
||||
standard input ends and `server.console_exit_on_eof` is on, its last line
|
||||
runs, whether or not a line's end ended it, and then the server stops.
|
||||
|
||||
A `<player>` is a slot number (`sv_players` lists them) or the start of a
|
||||
name; a name that begins more than one player's is refused. A `<duration>`
|
||||
is a number and a unit (`45s`, `30m`, `2h`, `7d`, `1w`), a bare number of
|
||||
minutes, or `forever`; ten years at most. A word in quotes (`"two words"`)
|
||||
is one word.
|
||||
|
||||
A command's text (a notice, a reason, `sv_set`'s value, a name) is kept to
|
||||
printable ASCII: control characters (a line's end, a tab) and other bytes
|
||||
outside it are dropped, as are the quotes around the whole text, and
|
||||
standard input's and the init file's lines are cleaned so before they run.
|
||||
The web is stricter where it takes a value as it is: `PUT /api/settings`
|
||||
refuses a value with a control character (`schema`), and nothing is changed
|
||||
for that setting. A command's reply is sent whole, however many lines.
|
||||
|
||||
Commands that are not the server's (the game's own console commands, the
|
||||
scripts' globals and functions) need the owner role: from the web or the
|
||||
RCON they are refused (`not a command of the server's`) but to the owner's
|
||||
session. The server's
|
||||
commands come first, so `kick` and `ban` are always the server's below, not
|
||||
the game's console commands of those names.
|
||||
|
||||
| Command | Role | What it does |
|
||||
| --- | --- | --- |
|
||||
| `help [command]` | viewer | The commands, or one command's use |
|
||||
| `sv_status [--json]` | viewer | The server's state, map, gametype, players, uptime, games played, network version, listing and next game |
|
||||
| `sv_players [--json]` | viewer | Each player's slot, name, team, score, kills, deaths, assists, ping and machine; with the owner role or `server.log_addresses`, their address and hardware id |
|
||||
| `sv_rotation` (`sv_mapcycle`), `sv_maps`, `sv_gametypes`, `sv_version`, `sv_log [n]` | viewer | Lists: the rotation, the maps there are, the gametypes, the build, the log's last n lines |
|
||||
| `sv_bans` (`sv_banlist`), `sv_settings` | admin | Lists: the bans of `bans.txt`, the settings `sv_set` changes |
|
||||
| `sv_masters`, `sv_publisher` | viewer | The master servers and how each answered; the publisher key's id and public key (never its seed) |
|
||||
| `say <text>` (`sv_say`) | moderator | A notice on every machine's screen |
|
||||
| `tell <player> <text>` | moderator | A notice on one player's machine |
|
||||
| `kick <player>` (`sv_kick`) | moderator | Drops the player's machine; it may join again |
|
||||
| `ban <player> [<duration>] [<reason>]` (`sv_ban`) | moderator (a day at most), admin | Drops the player's machine and bans its address and hardware id, for the duration (else for ever). A moderator must give a duration of a day or less: a ban for ever, or longer, is refused |
|
||||
| `unban <number\|address\|hardware id>` (`sv_unban`) | admin | Takes a ban out of `bans.txt`; the machine may join again at once, by the LAN or the internet |
|
||||
| `sv_ban_address <address\|hardware id> [<duration>] [<reason>]` | admin | Bans an IPv4 address (`a.b.c.d`) or a hardware id (up to 32 hex digits), its machine here or not: its line in `bans.txt` as `ban` writes it (the other part `none`), so that `sv_bans`, `unban` and `GET /api/bans` see it, and a machine present of that address or hardware id is dropped as `ban` drops it (`player_left`'s reason `banned`). Answers `ban <n> added` (`n`: its number in `sv_bans`) |
|
||||
| `mute <player> [<minutes>]`, `unmute <player>` | moderator | The host's mute of a player's chat and voice for everyone |
|
||||
| `sv_map <map> [<gametype>]`, `sv_map <entry>` | moderator | Plays that game (or a rotation entry, `map:gametype+rule=value`; a co-op one too), below |
|
||||
| `sv_map_next` (`sv_next`) | moderator | Ends the game without its scores and plays the rotation's next |
|
||||
| `sv_end_game` | moderator | Ends the game: its scores, then the next |
|
||||
| `sv_rotation_set <entries>`, `sv_rotation_add <entry>`, `sv_rotation_del <n>`, `sv_rotation_begin [<n>]` (`sv_mapcycle_add`, `_del`, `_begin`) | admin | Changes the rotation (written to `server.rotation`, 4096 characters at most) |
|
||||
| `sv_set <setting> <value>` | admin | Changes one of the server's settings, now where it can be, and in `config.toml` (below); a setting its environment variable sets is refused. A value is 256 characters at most |
|
||||
| `sv_name <name>`, `sv_maxplayers <n>`, `sv_password [<password>]`, `sv_public <0\|1>`, `sv_motd <text>` | admin | `sv_set` of `server.name`, `server.max_players`, `server.password`, `server.public`, `server.motd` |
|
||||
| `sv_reload` | admin | Reads `config.toml`'s server settings, the rotation and the gametype files again (as SIGHUP) |
|
||||
| `sv_stop [now\|game\|empty] [<notice>]`, `sv_stop cancel` | owner | Stops the server (exit code 0): `now` (the default) as `quit` does; `game` once the game being played is over, `empty` once nobody plays (a drain, below); `cancel` the drain waiting. The notice is said to every machine first |
|
||||
| `sv_restart [now\|game\|empty] [<notice>]`, `sv_restart cancel` | owner | As `sv_stop`, with exit code 5 (restart me) |
|
||||
| `quit` (`exit`) | owner | Stops the server (exit code 0) |
|
||||
|
||||
`sv_map`'s game is played as soon as it can be, and its answer says when:
|
||||
`next: <entry> (now)` in the lobby before its start was sent (the lobby
|
||||
takes the entry, and the rotation's entry it replaced is played after it),
|
||||
`(now: this game ends)` while a game is played (it ends at once, without
|
||||
its scores), and `(once this game is over)` once the lobby's start was sent
|
||||
or while a map loads (it is the next game). `sv_map` of the game being
|
||||
played plays it again. The rotation goes on after it.
|
||||
|
||||
A drain (`sv_stop` or `sv_restart` with `game` or `empty`, `POST
|
||||
/api/stop`) is a stop that waits: the listings are withdrawn as `sv_public
|
||||
0` withdraws them (a new invite, the masters told), without the setting
|
||||
changing; new machines are refused as while a map loads (the game is not
|
||||
open: the LAN's search shows it closed, a join by the invite is told the
|
||||
game is not open); then the server stops. With `game` it stops once no
|
||||
game is played nor about to be: at once in the lobby with nobody in it, or
|
||||
with no countdown running (fewer players than `server.min_players`);
|
||||
otherwise once the game played (or about to start) is over and its
|
||||
postgame shown. With `empty` it stops once nobody is on the server (at once
|
||||
if nobody is now). `sv_stop cancel` (or `sv_restart cancel`) ends the
|
||||
drain: the server is listed again as `server.public` says and takes new
|
||||
players. A `drain` event says each (`after`: `now`, `game`, `empty` or
|
||||
`cancel`), and the stop that ends a drain has the `shutdown` reason
|
||||
`drained`. `/api/status`'s `drain` is the drain waiting, or `null`.
|
||||
|
||||
A co-op entry (`<level>:coop`) is ended as a game is: by `sv_end_game`,
|
||||
`sv_map_next`, `sv_map`, `server.empty_seconds` and `server.idle_minutes`.
|
||||
It has no scores: the server goes back to the lobby at once (no postgame),
|
||||
and a level won ends it with `game_ended`'s reason `score`.
|
||||
|
||||
`sv_set` (and the settings of the web page, `PUT /api/settings`) changes
|
||||
these settings, which `sv_settings` and `GET /api/settings` list:
|
||||
`server.name`, `server.max_players`, `server.min_players`,
|
||||
`server.password`, `server.public`, `server.rotation_fallback`,
|
||||
`server.lobby_seconds`, `server.postgame_seconds`, `server.empty_seconds`,
|
||||
`server.idle_minutes`, `server.team_start`, `server.motd`,
|
||||
`server.frame_rate`, `server.web_password`,
|
||||
`server.web_moderator_password`, `server.log_format`,
|
||||
`server.log_addresses`, `server.status_file`, `server.auto_update`,
|
||||
`server.coop_difficulty`, `server.region`, `server.master_publish`,
|
||||
`server.chat_filter`, `server.chat_filter_slurs`, `server.chat_filter_swearing`,
|
||||
`server.chat_filter_insults`,
|
||||
`server.master_publish_address`, `server.metrics`, and `network.text_chat`,
|
||||
`network.voice_lobby`, `network.voice_mode`, `network.voice_kbps`,
|
||||
`network.votekick`, `network.votekick_minutes`,
|
||||
`network.votekick_ban_minutes`, `network.map_share`,
|
||||
`network.map_share_upload`, `network.public_address`,
|
||||
`network.coop_friendly_fire`, `network.coop_player_collisions`,
|
||||
`network.coop_ally_friendly_fire`, `network.shield_effects` and
|
||||
`network.fire_origins`. Of them,
|
||||
`server.status_file`, `server.auto_update` and `server.log_addresses` need
|
||||
the owner role: from the web's admin, `sv_set` of one of them (`POST
|
||||
/api/command`) answers `403 forbidden`, and `PUT /api/settings` leaves it
|
||||
out, in its `errors` with the code `forbidden` and the message `<setting>
|
||||
needs the owner role (the server's console)`; the owner's session changes
|
||||
them both ways. A web password is empty or
|
||||
8 characters or more. A value outside a setting's choices or range is
|
||||
refused (`400 failed` from `sv_set`, `schema` in `PUT /api/settings`'s
|
||||
`errors`), with `<setting> takes a whole number from <min> to <max>` (or
|
||||
`from <min>`) or `<setting> is one of <a>|<b>|<c>`; a choice may be given
|
||||
in either case, and is kept as the table spells it:
|
||||
|
||||
| Setting | Choices or range |
|
||||
| --- | --- |
|
||||
| `server.max_players` | 2 to 127 |
|
||||
| `server.min_players` | 1 to 16 |
|
||||
| `server.lobby_seconds`, `server.postgame_seconds` | 0 to 300 |
|
||||
| `server.empty_seconds`, `server.idle_minutes` | 0 or more |
|
||||
| `server.frame_rate` | 30 to 120 |
|
||||
| `server.team_start` | `one`, `both`, `skip` |
|
||||
| `server.log_format` | `text`, `json` |
|
||||
| `server.auto_update` | `off`, `check`, `install` |
|
||||
| `server.coop_difficulty` | `easy`, `normal`, `hard`, `impossible` |
|
||||
| `network.text_chat` | `on`, `links`, `off` |
|
||||
| `server.chat_filter` | `off`, `censor`, `block` |
|
||||
| `server.chat_filter_slurs`, `server.chat_filter_swearing`, `server.chat_filter_insults` | `off`, `severe`, `strong`, `mild` |
|
||||
| `network.voice_mode` | `off`, `team_proximity`, `team_enemy_proximity`, `team_global`, `team_global_enemy_proximity` |
|
||||
| `network.voice_kbps` | 8 to 64 |
|
||||
| `network.votekick_minutes` | 0 to 60 |
|
||||
| `network.votekick_ban_minutes` | 1 to 1440 |
|
||||
| `network.map_share_upload` | 16 to 20480 |
|
||||
| `network.coop_friendly_fire` | `off`, `on`, `shields_only`, `explosives_only` |
|
||||
| `network.shield_effects` | `stock`, `glow`, `light_show`, `overshield`, `glow_overshield`, `light_show_overshield`, `players` |
|
||||
|
||||
A dedicated server may also keep words out of its chat and its players'
|
||||
names (`server.chat_filter`, off by default): the words of streamer mode's
|
||||
list, by group, each group from the least severity its setting names
|
||||
(`server.chat_filter_slurs`, `mild` by default: every slur;
|
||||
`server.chat_filter_swearing` and `server.chat_filter_insults`, `off`).
|
||||
`censor` shows a line's words as stars to everyone; `block` refuses the
|
||||
line (its sender is told "Your line was not sent: it has words this server
|
||||
does not allow") and refuses at the door a machine whose player's name has
|
||||
them, which an updated game shows as "The host refused: your player name"
|
||||
(an older one says the game is closed). Each is logged (`chat filter: …`,
|
||||
`refusing a machine … its name has words the server's filter keeps out`).
|
||||
Links are `network.text_chat`'s, refused by default. A list of words is
|
||||
not a moderator: spaced letters and look-alikes get past it.
|
||||
|
||||
A dedicated server's text chat is its `network.text_chat`'s, listed or
|
||||
not: `on` by default (lines with links refused), `links`, or `off`, live
|
||||
(`sv_set network.text_chat off`). A game a player hosts has no text chat
|
||||
while it is listed in the server browser; a dedicated server is the
|
||||
exception, and the players who join it from the browser's dedicated servers
|
||||
have the chat as it says, as long as a master server lists it (the
|
||||
masters' word that it is an approved operator's; a listing's own flag is
|
||||
not enough, so a dedicated server listed by the brokers alone, before its
|
||||
operator is approved, has none for them).
|
||||
|
||||
The settings `sv_set` does not change (`server.web_viewer_password`,
|
||||
`server.web_owner_password`, `server.web_port`, `server.web_bind`, `server.web_trusted_proxy`, the
|
||||
paths, the master servers' files...) are changed in `config.toml` or their
|
||||
environment variables: `sv_reload` reads the file's `server.*` settings
|
||||
again, and the web port and its address are bound once, at the start. The
|
||||
rotation is changed by the `sv_rotation_*` commands.
|
||||
|
||||
## HTTP
|
||||
|
||||
The server listens on `server.web_port` (8080; 0 for none) at
|
||||
`server.web_bind` (`127.0.0.1`, an IPv4 address). Bound beyond loopback,
|
||||
every web password that is set (admin, moderator, viewer) must have 8
|
||||
characters or more, else the server exits with code 3; the owner's
|
||||
(`server.web_owner_password`) must have 8 or more wherever the port is
|
||||
bound. The page (`/`), the API
|
||||
(`/api/...`), the RCON (`/ws`), `/healthz` and `/metrics` share the port.
|
||||
|
||||
Requests are HTTP/1.1 (or 1.0), `GET`, `HEAD`, `POST`, `PUT` or `DELETE`
|
||||
(`HEAD` is answered as `GET` is, without the body, and counts as a read,
|
||||
as a `GET`; `/api/login` takes `POST` alone), a head of 8 KB at most whose
|
||||
lines end with CRLF (a bare LF, a CR inside a line, or more after the empty
|
||||
line that ends it: `400 bad_request`) and a body of 64 KB at most, sent within 10 seconds of the
|
||||
connection's opening or of its last answer (a connection that sends
|
||||
nothing is closed then too). `Transfer-Encoding` and `Expect` are refused.
|
||||
24 connections are taken at once; when they are all taken, the oldest that
|
||||
waits for a request (no RCON, no request being answered) is closed for a
|
||||
new one. A client that does not read its answers is read no further once
|
||||
256 KB of them wait, and is closed past 2 MB.
|
||||
|
||||
Every request but `/healthz` counts against its address's allowance, the
|
||||
page's files, `/metrics`, a sign-in and the RCON's upgrades (`/ws`) too: 60
|
||||
a minute, or 600 with a session (429 `rate_limited` past it, with
|
||||
`Retry-After: 60`). Behind `server.web_trusted_proxy`, a request's address
|
||||
is the last entry of its `X-Forwarded-For` (the one the proxy appended: an
|
||||
IPv4 address, `a.b.c.d` or `a.b.c.d:port`, or an IPv6 one, `v6`, `[v6]` or
|
||||
`[v6]:port`), and its `X-Forwarded-Host` and `X-Forwarded-Proto` are
|
||||
believed, whether or not it sends `X-Forwarded-For`; from any other
|
||||
address they are ignored. IPv6 clients are counted by their /64: one
|
||||
host's addresses share its allowance and its lockouts. Every answer is JSON
|
||||
(`Content-Type: application/json`) unless said, with
|
||||
`Cache-Control: no-store`, `X-Content-Type-Options: nosniff`,
|
||||
`Referrer-Policy: same-origin` (under `no-referrer` a browser would send
|
||||
the page's own changes with `Origin: null`) and
|
||||
`Content-Security-Policy: default-src 'self'; frame-ancestors 'none'`.
|
||||
|
||||
### Signing in
|
||||
|
||||
`POST /api/login` with `{"password":"…"}` answers
|
||||
`{"ok":true,"token":"<64 hex>","role":"admin","csrf":"<32 hex>","expires":<unix seconds>}`
|
||||
and sets the cookie `opence_session=<token>; HttpOnly; SameSite=Strict;
|
||||
Path=/`, with `Secure` when the request came through
|
||||
`server.web_trusted_proxy` with `X-Forwarded-Proto: https` (never from
|
||||
another address, whatever it says). The admin password
|
||||
(`server.web_password`) gives the admin role, the moderator password
|
||||
(`server.web_moderator_password`) the moderator role, the viewer password
|
||||
(`server.web_viewer_password`) the viewer role; `{"by":"…"}` beside the
|
||||
password names who signed in, in the log. A session lasts 12 hours, or 30
|
||||
minutes without a request (the RCON's messages do not count: a page left
|
||||
open asks `GET /api/session` now and then); 16 are kept at most, of every
|
||||
role.
|
||||
|
||||
The owner's password (`server.web_owner_password`, empty by default: none)
|
||||
gives the owner role, for a supervisor on the server's own machine (a
|
||||
fleet's agent, a panel's daemon): what standard input may do, over the
|
||||
API and the RCON (`quit`, `sv_stop`, `sv_restart`, `POST /api/stop`, the
|
||||
owner's settings by `sv_set` and `PUT /api/settings`, the game's own
|
||||
console commands by `POST /api/command`, the players' addresses and
|
||||
hardware ids in `/api/players` and the events). It signs in only when the
|
||||
connection's own peer address is in `127.0.0.0/8` and is not the trusted
|
||||
proxy's: never by `X-Forwarded-For`, and never through
|
||||
`server.web_trusted_proxy`, even one on the machine itself. From any other
|
||||
address the right owner's password is refused with `403 forbidden` (the
|
||||
RCON's `auth`: `{"code":"forbidden"}`, and the connection closes 1008),
|
||||
and counts toward the address's lockout as a wrong password does. An
|
||||
owner's session is used from the machine itself alone, as it was begun
|
||||
(from elsewhere its token is no session: `401`, the RCON's `auth` with it
|
||||
`denied`). A password that is also another role's gives the owner role
|
||||
from the machine itself and the other role from elsewhere: give the owner
|
||||
a password of its own.
|
||||
|
||||
A script passes `Authorization: Bearer <token>`. The page passes the
|
||||
cookie, and on every request that changes something the header
|
||||
`X-CSRF-Token: <csrf>`; the `Origin` of such a request (and of the
|
||||
WebSocket's) must be the server's own. An `Origin: null` is taken only
|
||||
when the browser's `Sec-Fetch-Site` says `same-origin`.
|
||||
|
||||
`POST /api/logout` ends the session (with the `X-CSRF-Token` by the
|
||||
cookie; `GET` answers 405). `GET /api/session` answers
|
||||
`{"ok":true,"role":…,"csrf":…,"expires":…}`, or 401.
|
||||
|
||||
When `server.web_password`, `server.web_moderator_password`,
|
||||
`server.web_viewer_password` or `server.web_owner_password` changes
|
||||
(`sv_set` and the settings change the first two; `sv_reload` reads any of
|
||||
them from `config.toml`), the sessions of its role end and that role's RCON
|
||||
connections close (1008, `the password changed`).
|
||||
|
||||
Five wrong passwords from an address (an IPv6 one's /64) in 10 minutes
|
||||
lock it out for 10 minutes (429), and no more than 30 passwords a minute
|
||||
are checked in all. `/api/login` takes `POST` alone (any other method:
|
||||
405).
|
||||
|
||||
### Errors
|
||||
|
||||
```json
|
||||
{"ok":false,"error":{"code":"forbidden","message":"needs the admin role"}}
|
||||
```
|
||||
|
||||
| Status | Codes |
|
||||
| --- | --- |
|
||||
| 400 | `bad_request`, `schema` (a field missing or out of range), `failed` (the command ran and failed: its lines in `lines`), `rejected` (rotation entries: `rejected[]`), `invalid` (a gametype file: `line`) |
|
||||
| 401 | `denied` (no session, or a wrong password) |
|
||||
| 403 | `forbidden` (the role; the owner's password from beyond the machine), `csrf`, `origin` |
|
||||
| 404 | `not_found` (also a command that is not one, a player or a ban that is not there) |
|
||||
| 405 | `method` |
|
||||
| 409 | `pinned` (a setting its environment variable sets), `changed` (a player's action whose slot holds another player now: the current name in `name`, nothing done) |
|
||||
| 413 | `too_large` |
|
||||
| 426 | `bad_request` (the WebSocket's version is not 13) |
|
||||
| 429 | `rate_limited`, `locked` (with `Retry-After`) |
|
||||
| 500 | `internal` (out of memory, a file that cannot be written) |
|
||||
| 503 | `loading` (the game did not answer in 20 seconds, as while a map loads; with `Retry-After: 5`), `starting`, `busy` (8 RCON connections already; with `Retry-After: 5`) |
|
||||
|
||||
### Endpoints
|
||||
|
||||
| Method, path | Role | Body → answer |
|
||||
| --- | --- | --- |
|
||||
| `GET /healthz` | none | `200 {"state":"lobby"}` (or `loading`, `playing`, `postgame`) while the server hosts and its frames run; `503` with `{"state":"starting"}`, `{"state":"stalled"}` (no frame for a minute) or the other state otherwise |
|
||||
| `GET /metrics` | none (`server.metrics`) | Prometheus text |
|
||||
| `GET /api/status` | viewer | The status (below) |
|
||||
| `GET /api/players` | viewer | `{"ok":true,"players":[<player>…]}` (with `address` and `hwid` for the owner, or every role with `server.log_addresses`) |
|
||||
| `POST /api/players/{slot}/kick` | moderator | `{"name":"<the player's name, checked>"}` → `{"ok":true,"lines":[…]}`, or `409 changed` when the slot holds another player |
|
||||
| `POST /api/players/{slot}/ban` | moderator | `{"name":…,"duration":"1d","reason":"…"}` (no duration: for ever, which a moderator's ban cannot be: `400 failed`) |
|
||||
| `POST /api/players/{slot}/mute` | moderator | `{"name":…,"minutes":10}` |
|
||||
| `POST /api/players/{slot}/unmute` | moderator | `{"name":…}` |
|
||||
| `POST /api/players/{slot}/tell` | moderator | `{"name":…,"text":"…"}` |
|
||||
| `POST /api/say` | moderator | `{"text":"…"}` |
|
||||
| `GET /api/rotation` | viewer | `{"ok":true,"index":0,"entries":[<entry>…],"next":<entry>}` |
|
||||
| `PUT /api/rotation` | admin | `{"entries":["bloodgulch:ctf",…]}` → the rotation, or `400 rejected` with `"error":{…,"rejected":[{"index":1,"entry":"…","reason":"…"}]}` and nothing changed |
|
||||
| `POST /api/rotation/next` | moderator | `{}`: `sv_map_next` |
|
||||
| `POST /api/rotation/play` | moderator | `{"map":"…","gametype":"…"}`: `sv_map` (a map or gametype that cannot be played: `400 failed`) |
|
||||
| `GET /api/gametypes` | viewer | `{"ok":true,"builtin":["slayer",…],"schema":{"fields":[<field>…]},"files":[{"name":…,"base":…,"description":…,"error":null}]}` (`builtin`: the Xbox's gametypes, then OpenCE's; a file that cannot be read has `base` and `description` empty and `error` saying why) |
|
||||
| `GET /api/gametypes/{name}` | viewer | `{"ok":true,"name":…,"text":"<the TOML>"}` |
|
||||
| `PUT /api/gametypes/{name}` | admin | `{"text":"<TOML>"}` → `{"ok":true}`, or `400 invalid` with `line` and `message` (a name is `a`–`z`, `0`–`9`, `_` and `-`, 32 at most) |
|
||||
| `DELETE /api/gametypes/{name}` | admin | `{"ok":true}` |
|
||||
| `GET /api/maps` | viewer | `{"ok":true,"maps":[{"name":"bloodgulch","level":"levels\\test\\bloodgulch\\bloodgulch","kind":"xbox","title":"Blood Gulch"}…]}` (`kind`: `xbox` or `custom`; `title` is the map's display name, else its `name`) |
|
||||
| `GET /api/bans` | admin | `{"ok":true,"bans":[{"n":0,"when":"2026-10-19 18:00:00","ip":"…","hwid":"…","players":"…","reason":"…","until":<unix>\|null}…]}` |
|
||||
| `POST /api/bans` | admin | `{"ip":"203.0.113.5","hwid":"…","names":"…","duration":"1d","reason":"…"}` (`ip` or `hwid`, or both; the rest may be left out: no duration is for ever) → `{"ok":true,"n":<the new ban's number in GET /api/bans>}`: `sv_ban_address`, a machine present of the address or the hardware id dropped; `400 schema` for an address that is not IPv4, a hardware id that is not hex, a duration that is not one |
|
||||
| `DELETE /api/bans/{n}` | admin | `{"ok":true}` |
|
||||
| `GET /api/settings` | admin | `{"ok":true,"settings":[<setting>…]}` |
|
||||
| `PUT /api/settings` | admin | `{"server.name":"…","server.max_players":16,"server.public":true,…}` (a value as JSON, a boolean, a number or a string, or its text: `"true"`, `"16"`; `null` empties it) → `{"ok":true,"applied":["server.name"],"errors":[{"name":…,"code":…,"message":…}]}`; each setting is changed or refused on its own |
|
||||
| `POST /api/command` | the command's | `{"line":"sv_status"}` (511 characters at most) → `{"ok":true,"lines":["…"]}`, or a refusal (`failed`, `forbidden`, `not_found`, `pinned`) with the command's `lines` |
|
||||
| `POST /api/stop` | owner | `{"after":"now\|game\|empty","notice":"…","restart":false}` (`notice` and `restart` may be left out) or `{"cancel":true}` → `{"ok":true,"lines":["…"]}`: `sv_stop` (`sv_restart` with `restart`) `after notice`, or `sv_stop cancel` (`400 failed` with no drain waiting); `400 schema` for another `after` |
|
||||
| `GET /api/log?after=<n>&limit=<m>` | viewer | `{"ok":true,"lines":[{"n":12,"time":<ms>,"level":"info","cat":"game","text":"…"}…],"next":12,"missed":0}` (`limit` 1 to 1024, 256 by default; the chat's lines for admins only) |
|
||||
| `GET /api/events?after=<seq>` | viewer | `{"ok":true,"events":[<event>…],"next":<seq>,"missed":0}` (`player_joined` and `player_left` with `address` and `hwid` for the owner, or every role with `server.log_addresses`) |
|
||||
| `GET /ws` | | The RCON (below) |
|
||||
| `GET /`, `/app.js`, `/app.css`, `/icon.svg` | none | The page (`server.web_ui`) |
|
||||
|
||||
`next` is the `after` of the next request: the last line's `n` (or event's
|
||||
`seq`) read. An `after` past the latest (as after a restart) reads from the
|
||||
start. `missed` counts lines or events that left the ring (2048 lines, 512
|
||||
events) before they were asked for.
|
||||
|
||||
### The status
|
||||
|
||||
```json
|
||||
{"ok":true,"time":1760900000123,"name":"OpenCE Server","state":"playing",
|
||||
"build":"build-206","network_version":38,"uptime":3600,"games_hosted":4,
|
||||
"map":"bloodgulch","level":"levels\\test\\bloodgulch\\bloodgulch","gametype":"ctf","variant":"CTF","teams":true,
|
||||
"players":5,"max_players":16,"machines":5,"countdown":-1,"game_seconds":312,"team_scores":[2,1],
|
||||
"listing":{"online":true,"public":true,"password":false,"invite":"halo://join/…"},
|
||||
"rotation":{"index":0,"count":3,"next":{"text":"sidewinder:team_slayer","map":"sidewinder","gametype":"team_slayer"}},
|
||||
"frame_ms_max":4.1,"frame_ms_avg":1.2,"tick_ms_avg":1.2,
|
||||
"masters":[{"url":"https://master1.example.org","listed":true,"probe":"ok","code":"","message":"","updated":1760899990}],
|
||||
"update":{"available":false,"build":""},
|
||||
"drain":null,
|
||||
"pid":4021,"started":1760896400,"instance":"eu-1","region":"eu","tunnel_port":2302,
|
||||
"publisher_key_id":"3f9a2c7d1e5b8a04","web_port":8080,
|
||||
"capabilities":["events","status","rotation","settings","bans","owner_web","ban_address","stop","event_addresses","identity"]}
|
||||
```
|
||||
|
||||
`state` is `waiting` (the menus settling), `hosting` (making the game),
|
||||
`lobby`, `loading`, `playing`, `postgame` or `stopping`. `countdown` is the
|
||||
lobby's seconds left, `-1` when it is not counting. `team_scores` is `null`
|
||||
in a game without teams. `frame_ms_max` and `frame_ms_avg` are the longest
|
||||
and the mean frame of the last minute (`tick_ms_avg` is the mean again, for
|
||||
older readers). `invite` is given to admins only (empty for others). An entry of the rotation is
|
||||
`{"text":"sidewinder:team_slayer+score=50","map":"sidewinder","gametype":"team_slayer","rules":{"score":50},"rejected":null}`
|
||||
(`rejected` is why it cannot be played, else `null`). `drain` is the
|
||||
drain waiting (`sv_stop game`...), `{"after":"game","restart":false,"since":<unix
|
||||
seconds>}`, else `null`. `pid` is the server's process, `started` when it
|
||||
started (seconds since 1970), `instance` the name the master servers know
|
||||
it by (`server.instance`, else the slug of `server.name` they are given),
|
||||
`region` `server.region`, `tunnel_port` the tunnel's UDP port
|
||||
(`network.tunnel_port`; 0 when `network.online` is off), `publisher_key_id`
|
||||
the publisher key's id (16 hex digits; empty without a key: `sv_publisher`)
|
||||
and `web_port` `server.web_port`. `capabilities` is the RCON's hello's. The rotation's
|
||||
`index` (in the status and `GET /api/rotation`) is the entry being played,
|
||||
`-1` while an `sv_map` game is played or before the first lobby; `next` is
|
||||
the entry after the one played last (the first while none has been).
|
||||
|
||||
A player is
|
||||
`{"slot":0,"name":"Milenko","team":0,"score":3,"kills":3,"deaths":1,"assists":0,"ping":42,"machine":1,"joined":1760899000,"muted":false}`;
|
||||
with the owner role, or `server.log_addresses`, also
|
||||
`"address":"203.0.113.5","hwid":"…"`. `team` is 0 (red), 1 (blue) or -1
|
||||
(no teams); `ping` is in milliseconds, `null` when it is not known yet.
|
||||
`client` is the player's machine's build as its game tells it (shortly
|
||||
after it joins), for every role:
|
||||
`{"build":282,"flavor":"release","version":"OpenCE Linux | build 282 (release)","repository":"OpenCommunityEdition/OpenCE","mods":["trollface 1.0"]}`
|
||||
(`build` 0 for a build CI did not number, `repository` empty when the build
|
||||
does not know it, `mods` the mods it plays in their load order, each its
|
||||
folder and its version), or `null` from a game that does not tell it. It is
|
||||
what the player's game says, which a changed build can make anything.
|
||||
|
||||
A setting is
|
||||
`{"name":"server.name","type":"string","value":"OpenCE Server","default":"OpenCE Server","comment":"…","env":"HALO_SERVER_NAME","pinned":false,"secret":false,"choices":null,"min":null,"max":null}`;
|
||||
`type` is `boolean`, `integer`, `real` or `string`, and `value` and
|
||||
`default` are of that type in JSON (`true`, `16`, `"OpenCE Server"`); a
|
||||
reader should also take their text (`"true"`, `"16"`), which older servers
|
||||
sent. `choices` lists a word setting's words, `min` and `max` bound a
|
||||
number's, each `null` where there is none (the table above). `env` is
|
||||
`null` for a setting no environment variable sets. A secret one (the
|
||||
passwords) has `value` and `default` empty and `"set":true` when it is
|
||||
set. `pinned` is a setting
|
||||
its environment variable (`env`) sets: it cannot be changed.
|
||||
|
||||
A gametype schema field is
|
||||
`{"key":"score_to_win","alias":"score","table":"universal","engine":"all","type":"integer","min":0,"max":999,"choices":null,"default":null,"description":"…"}`
|
||||
(`table`: the gametype file's table it goes in, `universal`, `options`,
|
||||
`ctf`, `slayer`, `oddball`, `king` or `race`; `engine`: `all`, or the game
|
||||
engine whose table it is; `type`: `integer`, `boolean` or `choice`).
|
||||
|
||||
## The RCON
|
||||
|
||||
`GET /ws` with `Upgrade: websocket` and the subprotocol `opence-rcon-1`.
|
||||
Every frame is text holding one JSON object. The server speaks first:
|
||||
|
||||
```
|
||||
→ {"type":"hello","protocol":1,"server":"OpenCE Server","build":"build-206","network_version":38,
|
||||
"capabilities":["events","status","rotation","settings","bans","owner_web","ban_address","stop","event_addresses","identity"]}
|
||||
← {"type":"auth","password":"…","by":"paul"} or {"type":"auth","token":"<session token>"}
|
||||
→ {"type":"auth","ok":true,"role":"admin"}
|
||||
→ {"type":"auth","ok":false,"error":{"code":"denied"}} and the connection closes (1008)
|
||||
← {"type":"command","id":1,"line":"kick Milenko"} or {"type":"command","id":1,"command":"say","args":["two words"]}
|
||||
→ {"type":"reply","id":1,"ok":true,"lines":["Milenko kicked by the host"]}
|
||||
→ {"type":"reply","id":2,"ok":false,"lines":["…why…"]} (the command ran and failed)
|
||||
→ {"type":"reply","id":3,"ok":false,"lines":[],"error":{"code":"busy","message":"…"}} (not run)
|
||||
← {"type":"subscribe","events":["player","chat","game","moderation","status","log","master"],"after":1830}
|
||||
→ {"type":"event","seq":1831,"time":1760900000123,"event":"player_joined","slot":3,"name":"Milenko",…,"replay":true}
|
||||
→ {"type":"event","seq":1831,"time":…,"event":"status","status":{…the status…}} (at the subscribe, then every 2 s)
|
||||
→ {"type":"event","time":…,"event":"log","n":5120,"level":"info","cat":"game","text":"…"} (no seq: n is its sequence)
|
||||
← {"type":"ping"}
|
||||
→ {"type":"pong"}
|
||||
→ {"type":"overflow"} and the connection closes (1013): the client read too slowly
|
||||
→ {"type":"error","id":…,"error":{"code":"…","message":"…"}} (an unknown type, a malformed message)
|
||||
```
|
||||
|
||||
A connection signed in with the page's cookie (on the same origin) needs no
|
||||
`auth` message: its `hello` is followed by `{"type":"auth","ok":true,…}`.
|
||||
The `capabilities` say what the server has beyond the first release's
|
||||
(`events`, `status`, `rotation`, `settings`, `bans`): `owner_web`,
|
||||
`ban_address`, `stop`, `event_addresses` and `identity` ("Panels and
|
||||
fleets"); a client checks for one before it uses it. The owner's password
|
||||
signs in from the server's own machine alone ("Signing in").
|
||||
A command is a `line`, or a `command` and its `args`, which the server
|
||||
joins with spaces, quoting an argument that holds a space or is empty (511
|
||||
characters in all at most). Ids are the client's (a number or a string),
|
||||
echoed in the reply; each command gets exactly one reply. A connection
|
||||
runs one command at a time: a command sent before the last one's reply is
|
||||
not run. A reply whose command ran has `ok` and the command's `lines`, and
|
||||
no `error`, whether it succeeded or failed; one that was not run has `ok`
|
||||
false, no lines and an `error`: `denied` (not signed in), `rate_limited`
|
||||
(32 commands a second, in bursts of 64), `bad_request` (no command, or too
|
||||
long), `busy` (another command's reply is awaited) or `loading` (the game
|
||||
did not answer in 20 seconds; the command may still have run, and is never
|
||||
sent again by the server). `after` replays the events still in the ring
|
||||
since that sequence number, marked `"replay":true`. A connection holds 1024
|
||||
messages for the client at most; 8 connections are taken at once (a ninth
|
||||
upgrade answers `503 busy`), and each upgrade counts against its address's
|
||||
allowance (above). The
|
||||
event groups are `player` (`player_joined`, `player_left`, `map_share`), `chat`
|
||||
(`chat`), `game` (`lobby_opened`, `countdown`, `game_started`,
|
||||
`game_ended`, `postgame`, `score`, `kill`), `moderation` (`kick`, `ban`,
|
||||
`unban`, `mute`, `unmute`, `speed_hack`), `status` (`status`), `log`
|
||||
(`log`, each log line as `{"n","level","cat","text"}`), `master`
|
||||
(`master`), and `server` (`server_started`, `reloaded`, `warning`,
|
||||
`drain`, `shutdown`), which every subscriber gets.
|
||||
The log's lines of the `chat` category go to the `chat` group, the others
|
||||
to `log`.
|
||||
`status` and `log` events go to their subscribers as they come and are
|
||||
not kept in the ring: `after` does not replay them (`/api/log` reads the
|
||||
log's own ring). A `status` event's `seq` is the latest event's (no new
|
||||
number: the same one comes again until another event), and a `log` event
|
||||
has no `seq`: its `n`, the log line's number and `/api/log`'s cursor, is
|
||||
its sequence. A client keeps one cursor for the events (`seq`, of the
|
||||
events of the ring) and another for the log's lines (`n`); a client that
|
||||
reconnects with `after` may get events it had, and drops those whose `seq`
|
||||
it has seen (a `status` event is never dropped so).
|
||||
|
||||
## Events
|
||||
|
||||
Every event has `seq` (rising, never reused while the server runs; a
|
||||
`status` event has the latest one's, a `log` event none: above), `time`
|
||||
(milliseconds since the epoch) and `event`:
|
||||
|
||||
| Event | Fields |
|
||||
| --- | --- |
|
||||
| `server_started` | `name, build, network_version, pid, started, instance, region, tunnel_port, publisher_key_id, web_port` (as the status's), `rotation[]` (the entries' texts) |
|
||||
| `lobby_opened` | `map, gametype, variant` (the gametype's name as the game shows it), `teams, index` (the rotation's entry) |
|
||||
| `countdown` | `seconds` (-1: paused) |
|
||||
| `game_started` | `map, gametype, variant, teams, team_scores[]` (team games), `players[]` |
|
||||
| `game_ended` | `map, gametype, variant, teams, reason` (`score`, `time`, `idle`, `empty`, `command`, `next`), `duration` (seconds), `team_scores[]` (team games), `players[]` |
|
||||
| `postgame` | `seconds` |
|
||||
| `player_joined` | `slot, name, team, machine`; `address, hwid` for the owner, or every role with `server.log_addresses` |
|
||||
| `player_left` | `slot, name, reason` (`left`; `kicked` and `banned` when the server's `kick`, `ban` or `sv_ban_address` dropped the machine, `banned` for a speed hack's drop too); `address, hwid` (as it joined) as `player_joined`'s |
|
||||
| `chat` | `channel` (`everyone`, `team`, `vehicle`), `slot, name, text` (admins only; the lines the host sends on) |
|
||||
| `kill` | `killer, victim` (slots; -1 for none), `weapon` (the killer's weapon's or the killing object's tag name, or null), `friendly_fire` |
|
||||
| `score` | `map, gametype, variant, teams, team_scores[]` (team games), `players[]` (once a second at most, on a change) |
|
||||
| `kick`, `ban`, `unban`, `mute`, `unmute` | `name, by, reason?, until?` |
|
||||
| `speed_hack` | `machine, names, rate, ahead_ticks, action` (`kicked`, or `unverified`: its datagrams alone said so, and it stays) |
|
||||
| `map_share` | `machine, map, state` (`asked`, `downloading` at each tenth, `downloaded` or `failed` once for each request), `progress` (0 to 100: a percentage already) |
|
||||
| `warning` | `text` (a newer release, with `server.auto_update`) |
|
||||
| `reloaded` | `rotation_changed, rejected[]` (`{"entry","reason"}` of each entry left out) |
|
||||
| `master` | `url, listed, probe, code, message` |
|
||||
| `drain` | `after` (`now`, `game`, `empty`, `cancel`), `restart` (exit code 5), `notice` (empty for none) |
|
||||
| `shutdown` | `reason` (`quit`, `sv_stop`, `sv_restart`, `drained`: a drain's end, `signal <n>`, `update installed`, `nothing to play`, `debug.exit_after`), `code` (the exit code) |
|
||||
|
||||
Players in events are as in `/api/players` for the viewer role (no
|
||||
addresses), but for `player_joined` and `player_left`, which carry the
|
||||
player's address and hardware id (`""` when not known) to the owner, and to
|
||||
every role when `server.log_addresses` is on (`/api/players`' rule), in the
|
||||
RCON's events, their replay and `GET /api/events` alike. `variant` is the gametype's name as the game shows it (`Co-op`
|
||||
in a co-op entry).
|
||||
|
||||
## Bans
|
||||
|
||||
A ban is a line of `bans.txt` (in `paths.logs`, else the data root). A
|
||||
timed ban is kept out by its line's `until=` alone, and ends then. A ban
|
||||
for ever, and a machine dropped for cheating, also keep the machine out
|
||||
for the rest of the run by its address, its real address or its hardware
|
||||
id. `sv_ban_address` and `POST /api/bans` write such a line for an address
|
||||
or a hardware id with no player of it needed (the part not given is
|
||||
`none`). `unban` takes the line out and readmits the machine by
|
||||
the line's address or hardware id, whether it joins on the LAN or by
|
||||
internet play.
|
||||
|
||||
## The rotation
|
||||
|
||||
`server.rotation` (and `sv_rotation_set`, `PUT /api/rotation`) is a list of
|
||||
entries, `map[:gametype[+rule=value...]]`, separated by commas, semicolons
|
||||
or new lines; a line that begins with `#` is a comment (to its line's end,
|
||||
commas and all). The text is 4096 characters at most (the entries past it
|
||||
are left out, with a warning), an entry 255 characters and the list 64
|
||||
entries. `config.toml` keeps a string setting of up to 4096 characters, so
|
||||
a rotation that long is saved whole and read back after a restart.
|
||||
|
||||
- The map is a multiplayer map's name (`bloodgulch`: the Xbox's
|
||||
`maps/<name>.map`, else a Custom Edition map of `custom_maps`),
|
||||
`custom_maps\<name>` (a Custom Edition map; `/` is taken for `\`), or a
|
||||
level's path (`levels\test\bloodgulch\bloodgulch`). A campaign level is
|
||||
played as co-op only: `<level>:coop`, at `server.coop_difficulty`.
|
||||
- The gametype (`slayer` when there is none) is a built-in's name
|
||||
(`slayer`, `team_slayer`, `slayer_pro`, `elimination`, `phantoms`,
|
||||
`endurance`, `rockets`, `snipers`, `stalker`, `ctf`, `ironctf`,
|
||||
`ctf_pro`, `invasion`, `oddball`, `team_oddball`, `reverse_tag`,
|
||||
`accumulation`, `juggernaut`, `king`, `team_king`, `king_pro`,
|
||||
`crazy_king`, `race`, `team_race`, `rally`, `team_rally`, and Halo PC's
|
||||
names `ffa`, `ffa_slayer`, `teamslayer`, `tslayer`, `koth`, `team_koth`,
|
||||
`iron_ctf`, `teamrace`, `teamoddball`), an OpenCE gametype's (`swat`,
|
||||
`infection`, `gun_game`, `hardcore`, `hardcore_ctf`, `hardcore_oddball`,
|
||||
`hardcore_king`), a gametype file's name (`gametypes/<name>.toml`), or
|
||||
`file=<name>` (a gametype a player's game saved, below). A gametype's
|
||||
name is letters, digits, `_`, `-` and `.`, in any case.
|
||||
- A rule is a gametype rule's name or its short name (`score`, `time`,
|
||||
`weapons`, `ff`...; `GET /api/gametypes`'s schema lists them), with a
|
||||
value it takes; a rule of another game engine than the gametype's is
|
||||
refused. 48 rules at most; a rule given twice is the last.
|
||||
|
||||
An entry that cannot be played (a map that is not there, a bad gametype
|
||||
file, a rule out of range) is left out with a warning, at the start and at
|
||||
`sv_reload`; `sv_rotation_set` and `PUT /api/rotation` change nothing when
|
||||
one of their entries cannot be played.
|
||||
|
||||
A change of the rotation (`sv_rotation_*`, `PUT /api/rotation`,
|
||||
`sv_reload`) keeps its place: the next game is the entry after the one
|
||||
played last, found again in the new list (the first entry only when none
|
||||
has been played yet). `sv_reload` takes the rotation again when its text
|
||||
changed, and also when only its entries' rejections changed (a map or a
|
||||
gametype file added or taken out since).
|
||||
|
||||
`server.team_start` decides how a team game starts. `one` (the default)
|
||||
starts it with the players of one team. `both` waits, saying nothing,
|
||||
for a player on each team. `skip`, when one player waits for a team game
|
||||
that `sv_map` did not ask for, plays the rotation's next entry without
|
||||
teams instead (if it has one); it is checked when the lobby opens and
|
||||
again when its countdown would begin. With no entry left, the server
|
||||
stops with exit code 3 (2 when no rotation map is there), or plays
|
||||
`bloodgulch:slayer` with `server.rotation_fallback`.
|
||||
|
||||
## Gametype files
|
||||
|
||||
A gametype file, `gametypes/<name>.toml` (the name `a`–`z`, `0`–`9`, `_`
|
||||
and `-`), is a built-in or OpenCE gametype (`base`) and rules over it:
|
||||
|
||||
```toml
|
||||
base = "team_king" # the gametype it starts from
|
||||
name = "Moving Hill" # the name the game shows: 11 characters of printable ASCII
|
||||
|
||||
[universal]
|
||||
score_to_win = 3
|
||||
|
||||
[options]
|
||||
time_limit = 15
|
||||
friendly_fire = "off"
|
||||
|
||||
[king]
|
||||
moving_hill = true
|
||||
```
|
||||
|
||||
Each rule goes in its table (the schema's `table`): `[universal]`,
|
||||
`[options]`, and one game engine's, `[ctf]`, `[slayer]`, `[oddball]`,
|
||||
`[king]` or `[race]`. A file gives each rule its full name
|
||||
(`vehicle_set`, `team_vehicles`, `score_to_win`): the short names
|
||||
(`vehicles`, `score`) are the rotation's alone. A file is 64 KB at most.
|
||||
`deploy/gametypes` has examples. The server reads the `gametypes` folder
|
||||
beside `config.toml` if there is one, else the data root's, and writes the
|
||||
web page's files to it.
|
||||
|
||||
A gametype a player's game saved is played with `file=<name>`: copy the
|
||||
saved gametype, as `<name>.gametype`, into the same `gametypes` folder
|
||||
(beside `config.toml` if there is one, else the data root's).
|
||||
|
||||
## The listing
|
||||
|
||||
A public server (`server.public`, with `network.online` and
|
||||
`network.public_lobby`) is published to each master server of
|
||||
`masters.txt` (`docs/master_protocol.md`). A change that a list shows (the
|
||||
listing made public or private, a player joining or leaving, the name, the
|
||||
map) is published within 5 seconds. Made private, the server makes a new
|
||||
invite and sends the masters a closed publish, which takes it off their
|
||||
lists;
|
||||
`network.public_lobby = false` stops the publishing too. A master's
|
||||
`Retry-After` is kept (a day at most). `key_revoked` and
|
||||
`publisher_revoked` stop the publishing to that master for the run;
|
||||
`unknown_key`, `publisher_pending`, `application_denied` and
|
||||
`listing_taken` are logged once a minute while they last.
|
||||
|
||||
## Files
|
||||
|
||||
| File | What |
|
||||
| --- | --- |
|
||||
| `config.toml` | Every setting (beside the executable; `HALO_CONFIG_FILE`, else `--config`, names another) |
|
||||
| `init.txt` (`server.init_file`) | Commands run at the start, in the data root unless a full path |
|
||||
| `gametypes/<name>.toml` | Gametype files: the `gametypes` folder beside `config.toml` if there is one, else the data root's |
|
||||
| `gametypes/<name>.gametype` | Gametypes saved by a player's game (`file=<name>` in the rotation): the same `gametypes` folder |
|
||||
| `publisher.key` | The publisher key for the master servers (beside `config.toml`). On Windows, a server's `config.toml` and `publisher.key` are given an access list of their owner alone (the entries inherited for Administrators and SYSTEM taken out) |
|
||||
| `masters.txt` | The master servers (`server.masters_file`: beside `config.toml`, else beside the executable); one that names none leaves the official master, built in |
|
||||
| `bans.txt`, `cheaters.txt`, `debug.txt` | In `paths.logs`, else the data root |
|
||||
| `status.json` (`server.status_file`) | The status, written every 2 seconds |
|
||||
| A password's file (`HALO_SERVER_WEB_PASSWORD_FILE`, `HALO_SERVER_WEB_OWNER_PASSWORD_FILE`, `HALO_SERVER_WEB_MODERATOR_PASSWORD_FILE`, `HALO_SERVER_WEB_VIEWER_PASSWORD_FILE`, `HALO_SERVER_PASSWORD_FILE`) | A container's secret: when the plain variable is not set, the file's first line (its CR and LF off) is the setting's value, which is then pinned as the plain variable's would be (`sv_set` and `PUT /api/settings` refuse it, `409 pinned`). Read once, at the start; a file that cannot be read is logged, and the setting is `config.toml`'s |
|
||||
|
||||
## Releases
|
||||
|
||||
Each release has `SHA256SUMS` (the SHA-256 of each of its files, as
|
||||
`sha256sum` writes them: `<hex> <name>`, written by `tools/ci_build.py
|
||||
sums`) and `SHA256SUMS.sig`: the Ed25519 signature of that file's exact
|
||||
bytes by the project's release key, in 128 lowercase hex digits and a
|
||||
newline (the form `opence-master-server`'s `cmd/release-sign` writes). The
|
||||
public key is `deploy/release-key.pub` (64 hex digits:
|
||||
`d04e8b101007d1641cace8b95fcca76f7f44709f6885c3d031b52394dbdf9376`).
|
||||
`tools/release_sign.sh verify SHA256SUMS` checks the signature (OpenSSL 3),
|
||||
and `sha256sum -c --ignore-missing SHA256SUMS` the files downloaded. The
|
||||
build workflow signs with the `RELEASE_SIGNING_KEY` secret (the key's seed,
|
||||
64 hex digits) and checks the signature against `deploy/release-key.pub`
|
||||
before it publishes the release.
|
||||
@@ -1,650 +0,0 @@
|
||||
# The master servers' protocol, version 1
|
||||
|
||||
A master server lists dedicated servers and vouches for who publishes them.
|
||||
An operator applies to a master once with the public half of an Ed25519
|
||||
key, the *publisher key*, through the master's Discord bot; once an
|
||||
approver approves the application, the
|
||||
operator's servers publish to the master with requests signed by that key,
|
||||
and the master lists them after probing their UDP port. The game's server
|
||||
browser fetches each master's list, checks the master's signature with the
|
||||
key pinned in `masters.txt`, and joins a listed game by the invite in its
|
||||
listing, as it joins a game heard on the brokers.
|
||||
|
||||
A master carries no game traffic: each list entry holds the host-signed
|
||||
listing the game publishes to the signalling brokers (`p2p_lobby.c`), so
|
||||
the join path is unchanged and nobody needs the master to be honest about a
|
||||
game's details.
|
||||
|
||||
This document is the contract between the game (the publisher in
|
||||
`port/linux/src/server_master.c`, the probe's answer, the list client in
|
||||
`port/linux/src/master_list.c`) and the masters' implementations. The
|
||||
project's implementation is `opence-master`
|
||||
(github.com/OpenCommunityEdition/opence-master-server, Go, AGPL-3.0-or-later),
|
||||
whose `testdata/vectors.json` holds fixed keys and every value this
|
||||
document derives from them, and whose `tests/conformance` is the test a
|
||||
master must pass to be an official one. `docs/dedicated_server.md` is the
|
||||
server's side: its settings, `--keygen` and `--sign`.
|
||||
|
||||
## Conventions
|
||||
|
||||
| Thing | Form |
|
||||
| --- | --- |
|
||||
| Hexadecimal | Lowercase, two digits a byte, no prefix |
|
||||
| Base64 | The standard alphabet (RFC 4648 section 4) with `=` padding |
|
||||
| Times | Unix seconds, decimal, UTC |
|
||||
| JSON | UTF-8; every string the protocol defines is printable ASCII (0x20 to 0x7E) |
|
||||
| Signatures | Ed25519 as RFC 8032 defines it (with SHA-512): Monocypher's `crypto_ed25519_sign` and `crypto_ed25519_check`, Go's `crypto/ed25519` |
|
||||
| Transport | HTTPS. A master refuses publishes, key changes and peers' requests over plain HTTP except from loopback |
|
||||
| Unknown JSON fields | Ignored by both sides, so later versions can add fields |
|
||||
|
||||
## Keys and identifiers
|
||||
|
||||
| Thing | Definition |
|
||||
| --- | --- |
|
||||
| Key file (`publisher.key`, `master.key`) | One line of 64 hexadecimal digits: the Ed25519 seed (32 bytes). Anything after `#` is a comment; blank lines are skipped. Mode 0600 |
|
||||
| Public key, as text | `ed25519:` and the 32-byte public key in hexadecimal (64 digits) |
|
||||
| Key id | The first 8 bytes of SHA-256 of the 32-byte public key. Written as 16 hexadecimal digits (`keyid=`, `key_id`, `Signature-Key`); in the probe's packets it is the 8 raw bytes |
|
||||
| Instance | A name the operator gives each server process (`server.instance`): 1 to 32 characters of `a-z`, `0-9`, `-` and `_`, the first a letter or a digit |
|
||||
| Server id | The first 16 hexadecimal digits (8 bytes) of SHA-256 of the ASCII text of the key id's 16 hexadecimal digits followed by the instance's text, with nothing between them |
|
||||
|
||||
The server id hashes the key id **as its 16 characters of text**, not its 8
|
||||
bytes. With the vectors' publisher key (RFC 8032's first test seed):
|
||||
|
||||
```
|
||||
seed 9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60
|
||||
public key ed25519:d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a
|
||||
key id 21fe31dfa154a261 (SHA-256 of the 32 key bytes: 21fe31dfa154a261...)
|
||||
instance main
|
||||
hashed "21fe31dfa154a261main" (20 ASCII bytes)
|
||||
server id 4c5f15237c866f6f (SHA-256 of those 20 bytes: 4c5f15237c866f6f...)
|
||||
```
|
||||
|
||||
The same instance under another key is another server id, so a server
|
||||
keeps its id across restarts as long as it keeps its key and its instance.
|
||||
A master refuses a public key whose point has a small order (its X25519
|
||||
form multiplied by a clamped scalar is zero, as `p2p_ed25519_verify`
|
||||
checks), since anyone can make signatures that verify under one.
|
||||
|
||||
`masters.txt` (the one beside `config.toml`, else the one beside the
|
||||
executable) lists the masters, one per line:
|
||||
`https://master1.example.org ed25519:<64 hex>`; `#` starts a comment; the
|
||||
first 4 are used. A file that names none (missing, empty, or comments alone,
|
||||
as the release's) leaves the official master, built into the game
|
||||
(`master_list_read_defaults` in `port/linux/src/master_list.c`) and the web
|
||||
page (`servers.js`):
|
||||
`https://master.opencommunityedition.com ed25519:89f4eda71229f11f3538679f49ef7fb0c2b407b380093f7f4fe02105b92225aa`.
|
||||
The web build reads its site's `masters.json` before the official master. The URL is an origin with no path, or a path
|
||||
the master is served under as it is (a proxy must not rewrite paths, since
|
||||
the path is signed).
|
||||
|
||||
## Signed requests
|
||||
|
||||
A publisher's requests carry a detached signature in one header:
|
||||
|
||||
```
|
||||
Authorization: OpenCE-Ed25519 keyid=<16 hex>, ts=<unix seconds>, nonce=<32 hex>, sig=<base64 of 64 bytes>
|
||||
```
|
||||
|
||||
The signature is the key's over the bytes of this string, its parts joined
|
||||
by single line feeds (0x0A) and no line feed at the end:
|
||||
|
||||
```
|
||||
OpenCE-Master-v1
|
||||
<the receiving master's key id>
|
||||
<METHOD>
|
||||
<PATH>
|
||||
<ts>
|
||||
<nonce>
|
||||
<SHA-256 of the body, in hexadecimal>
|
||||
```
|
||||
|
||||
| Part | Rule |
|
||||
| --- | --- |
|
||||
| Master key id | The key id of the master the request is sent to: the first 8 bytes of SHA-256 of the master's list-signing public key (the key pinned for it in `masters.txt`), as 16 lowercase hexadecimal digits. It binds the request to that master: a request signed for one master does not verify at another, even within the replay window. A master checks the signature with its own key id |
|
||||
| `METHOD` | The request's method in capitals: `PUT`, `DELETE`, `GET`, `POST` |
|
||||
| `PATH` | The path exactly as the request line sends it, without the query string: `/v1/servers/4c5f15237c866f6f`, `/v1/me`, `/v1/publishers` |
|
||||
| `ts` | The same decimal text as in the header: no sign, no leading zeros |
|
||||
| `nonce` | 16 random bytes in hexadecimal (32 digits), new for each request |
|
||||
| Body hash | Of the exact body bytes sent; an empty body's is SHA-256 of no bytes, `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855` |
|
||||
|
||||
The four parameters come once each, in any order, separated by commas with
|
||||
optional spaces; a publisher sends them in the order above. The master
|
||||
checks, in this order, and answers the first failure:
|
||||
|
||||
| Check | Failure |
|
||||
| --- | --- |
|
||||
| The header parses (scheme, the four parameters and their forms) | `401 bad_signature` |
|
||||
| `ts` is within 300 seconds of the master's clock | `401 clock` (the body's `master_time` is the master's clock, for the server to log) |
|
||||
| The key id is a publisher's, or an application's | `403 unknown_key` |
|
||||
| The signature verifies, for this master's key id | `401 bad_signature` |
|
||||
| The nonce was not seen with this key in the last 600 seconds | `401 replay` |
|
||||
|
||||
Since `unknown_key` is answered before the signature is checked, anyone can
|
||||
learn whether a key id is known to a master (a publisher's or an
|
||||
application's) by sending it with any signature. This is a known property
|
||||
of version 1: key ids are not secret (each is a hash of a public key, which
|
||||
an operator hands out when applying), and the answer says nothing more of
|
||||
the key than that the master has seen it.
|
||||
|
||||
The vectors' `GET /v1/me` to the vectors' master (key id
|
||||
`39f713d0a644253f`) at 1760900001 with the nonce
|
||||
`f0e0d0c0b0a090807060504030201000` signs
|
||||
|
||||
```
|
||||
OpenCE-Master-v1\n39f713d0a644253f\nGET\n/v1/me\n1760900001\nf0e0d0c0b0a090807060504030201000\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
```
|
||||
|
||||
and sends
|
||||
|
||||
```
|
||||
Authorization: OpenCE-Ed25519 keyid=21fe31dfa154a261, ts=1760900001, nonce=f0e0d0c0b0a090807060504030201000, sig=duRZ+WKAI8hbvidtC63U1XHxOSoeRN5mcrZvw4qihhlilhZjbVBCLYjsQLr4+F2C1gy6lN9/ixqevFX7dfNGDA==
|
||||
```
|
||||
|
||||
## Publishing
|
||||
|
||||
`PUT /v1/servers/{server_id}`, signed, with a JSON body of 16 KB at most.
|
||||
A server publishes to every master in `masters.txt` every 30 seconds, and
|
||||
within 5 seconds of a change (the lobby opened, a game started or ended, a
|
||||
player joined or left, the name or map changed). On shutdown it publishes
|
||||
`closed: true` (or `DELETE`s) and waits up to 2 seconds.
|
||||
|
||||
```json
|
||||
{"protocol":1,"instance":"main","name":"OpenCE Dedicated","map":"bloodgulch","gametype":"CTF","variant":"CTF",
|
||||
"players":5,"max_players":16,"teams":true,"in_progress":false,"password":false,"dedicated":true,
|
||||
"network_version":38,"build":"build-206","region":"eu","tunnel_port":2302,
|
||||
"listing":"<base64 of the host-signed listing>","closed":false,"serial":412}
|
||||
```
|
||||
|
||||
(The vectors' publish, made at network version 38: "The listing" says
|
||||
why the examples keep it.) The game's publisher sends `protocol`,
|
||||
`instance`, `listing` (but in a tombstone), `tunnel_port`, `dedicated`,
|
||||
`build`, `region` and `variant` when they are set, `address` with
|
||||
`server.master_publish_address`, `serial` and `closed`; the listing holds
|
||||
the rest. A server that goes private, or off the internet, sends one more
|
||||
publish, `closed: true`, to each master that listed it.
|
||||
|
||||
| Field | Type | Required | Meaning |
|
||||
| --- | --- | --- | --- |
|
||||
| `protocol` | number | yes | 1 |
|
||||
| `instance` | string | yes | The instance; the path's server id must be the server id of the signing key's id and this instance, else `400 server_id` |
|
||||
| `listing` | string | yes, but with `closed: true` | Base64 of the exact bytes `listing_make` makes, the bytes the game publishes to the brokers |
|
||||
| `tunnel_port` | number | yes, unless `address` is given | The UDP port the game's tunnel socket is bound to (`network.tunnel_port`), 1 to 65535 |
|
||||
| `address` | string | no | `"203.0.113.5:2302"`: an IP address (IPv4, or IPv6 in brackets) and a port to probe instead of the request's source address. Sent only with `server.master_publish_address`; a master serves it in its list only if its own policy allows (`MASTER_SERVE_ADDRESSES`). It must be globally routable (below); a private or loopback address is taken only from a private or loopback source |
|
||||
| `dedicated` | boolean | no | A dedicated server. Also read from the listing's flag 32, which a dedicated server sets; either makes the entry dedicated. A player's public game, published with the player's publisher key, sends `false` |
|
||||
| `variant` | string | no | The gametype's name as the server shows it; printable ASCII, cut to 24 |
|
||||
| `build` | string | no | The game's build (`build-206`); cut to 32 |
|
||||
| `region` | string | no | Up to 16 of `a-z`, `0-9` and `-` (`server.region`) |
|
||||
| `serial` | number | no | A whole number the server raises at each change; kept and shown to admins |
|
||||
| `closed` | boolean | no | `true`: unlist the server now |
|
||||
| `name`, `map`, `gametype`, `players`, `max_players`, `teams`, `in_progress`, `password`, `network_version` | | no | Informational only: the listing is authoritative. A value that differs from the listing's is ignored, and the answer's `warnings` says so |
|
||||
|
||||
The master parses the listing and checks the host's signature (below), and
|
||||
takes from it the name, the map, the gametype, the players and most
|
||||
players, the gametype's engine, the game's kind, the open, in-progress,
|
||||
teams and password flags, and the network version, so a publish cannot
|
||||
claim more than the host signed. A listing that does not parse or verify
|
||||
is `400 listing`. So is one whose own time is more than 3600 seconds from
|
||||
the master's clock. A listing with the same host key and a lower sequence
|
||||
than the one the master holds is not taken (the newer stays; a warning
|
||||
says so). A listing with the closed flag unlists the server, as
|
||||
`closed: true` does.
|
||||
|
||||
The master records the request's source address (behind a reverse proxy,
|
||||
the address its trusted proxy forwards) to probe the server. It keeps the
|
||||
addresses 7 days at most after a server's last publish, for probes and
|
||||
abuse handling, and never serves them.
|
||||
|
||||
The addresses a master probes and serves are an allowlist of globally
|
||||
routable unicast addresses: an IPv4 address outside IANA's special-purpose
|
||||
ranges (`0/8`, `10/8`, `100.64/10`, `127/8`, `169.254/16`, `172.16/12`,
|
||||
`192.0.0/24`, `192.0.2/24`, `192.88.99/24`, `192.168/16`, `198.18/15`,
|
||||
`198.51.100/24`, `203.0.113/24`, `224/4`, `240/4`); an IPv6 address in
|
||||
`2000::/3` outside `2001::/23`, `2001:db8::/32`, `3fff::/20` and
|
||||
`5f00::/16`; a 6to4 (`2002::/16`) or well-known NAT64 (`64:ff9b::/96`)
|
||||
address whose embedded IPv4 address is global. An IPv4-mapped address is
|
||||
judged as its IPv4 address. Everything else (link-local, site-local
|
||||
`fec0::/10`, unique local, multicast, `64:ff9b:1::/48`, zones) is refused
|
||||
(`400 schema`, `field: address`), except a private or loopback address
|
||||
from a private or loopback source (a master on the same network). A
|
||||
publish from a source address outside the allowlist without `address` is
|
||||
refused the same way when the master probes.
|
||||
|
||||
A listing's host key is published by one publisher at a time: a listing
|
||||
whose host key is that of a live server of another publisher is refused,
|
||||
`403 listing_taken`, so a listing's bytes copied from a list cannot be
|
||||
published by someone else. The same publisher may carry it under another
|
||||
server id (another key or instance). A host makes a new listing (a higher
|
||||
sequence) at each of its publishes, so a live server that has taken no newer
|
||||
listing of its host key for 90 seconds (3 intervals) is replaying a copy:
|
||||
a publish of a newer listing of that host key takes the host key from it,
|
||||
and its server is unlisted. A server an admin hid, or whose publisher or key
|
||||
is not approved, holds no host key. A master shows its admins the publishes
|
||||
it refused with `listing_taken`, to settle (see "Known limitations").
|
||||
|
||||
### The answer
|
||||
|
||||
`200` once the publish is taken and the master's decision for now is made;
|
||||
`202` while the first probe of the server's address is unanswered:
|
||||
|
||||
```json
|
||||
{"ok":true,"server_id":"4c5f15237c866f6f","listed":true,"interval":30,"ttl":90,"probe":"ok","reachable":true,
|
||||
"observed_address":"203.0.113.5","master_time":1760900000}
|
||||
{"ok":true,"server_id":"4c5f15237c866f6f","listed":false,"interval":30,"ttl":90,"probe":"pending","reachable":false,
|
||||
"observed_address":"203.0.113.5","probe_address":"203.0.113.5:2302","master_time":1760900000}
|
||||
```
|
||||
|
||||
| Field | Meaning |
|
||||
| --- | --- |
|
||||
| `listed` | Whether the list shows the server now |
|
||||
| `interval` | Seconds between publishes the master expects (30) |
|
||||
| `ttl` | Seconds after its last publish that a server is unlisted (90): one lost publish does not unlist it, three do |
|
||||
| `probe` | `pending` (no answer yet at this address), `ok`, `failed` (three attempts unanswered), `skipped` (an admin marked the server trusted), `off` (the master does not probe) |
|
||||
| `reachable` | The probe was answered |
|
||||
| `observed_address` | The address the master saw the request come from |
|
||||
| `probe_address` | With `pending` and `failed`: the address and port the master probes |
|
||||
| `hidden`, `reason` | An admin hid the server: it is listed to nobody, and `reason` says why. With `probe: failed`, `reason` is the hint to log: `let UDP port <n> through your firewall or NAT, or set network.public_address` |
|
||||
| `closed` | `true` after `closed: true`, a tombstone or `DELETE` |
|
||||
| `warnings` | Body fields the listing contradicts, which were ignored |
|
||||
| `master_time` | The master's clock |
|
||||
|
||||
A server with a failed probe is unlisted unless the master's policy lists
|
||||
unreachable servers (`MASTER_LIST_UNREACHABLE`), as `reachable: false`.
|
||||
The server logs each change of outcome once (not every 30 seconds), and
|
||||
the failed probe's hint once a minute until the probe passes.
|
||||
|
||||
`DELETE /v1/servers/{server_id}`, signed by any key of the server's
|
||||
publisher with an empty body, unlists the server at once and answers
|
||||
`200 {"ok":true,"server_id":…,"listed":false,"closed":true,…}`; `404
|
||||
not_found` for a server that is not the publisher's.
|
||||
|
||||
### Limits
|
||||
|
||||
| Limit | Answer |
|
||||
| --- | --- |
|
||||
| A server publishes at most once each 5 seconds, with a burst of 2 | `429 rate_limited` with `Retry-After` |
|
||||
| 120 publishes a minute per source address, and per key | `429 rate_limited` |
|
||||
| A body is 16 KB at most | `413 too_large` |
|
||||
| A publisher has at most its quota of live servers at once (default 4; live: published within `ttl` and not closed) | `403 quota_exceeded` |
|
||||
| An instance is published by one key of a publisher at a time | `403 instance_taken` (another key's server of that instance is live) |
|
||||
| A publisher holds at most its quota and 16 server records (one per server id); for a new server id past that, its oldest records that are not live are dropped, and if none can be | `403 too_many_instances` |
|
||||
|
||||
## The listing
|
||||
|
||||
The listing is `p2p_lobby.c`'s (`listing_make`, `listing_read`), in network
|
||||
byte order. The master reads it as `listing_read` does and checks its
|
||||
signature as `listing_signed` does.
|
||||
|
||||
| Offset | Size | Field |
|
||||
| --- | --- | --- |
|
||||
| 0 | 2 | `"HL"` |
|
||||
| 2 | 1 | Format: 1 |
|
||||
| 3 | 2 | Network version (`HALO_PORT_NETWORK_VERSION`, 39 now) |
|
||||
| 5 | 1 | Flags (below) |
|
||||
| 6 | 4 | Sequence: the host's count of its listings (the newest wins) |
|
||||
| 10 | 4 | The host's Unix time when it made the listing |
|
||||
| 14 | 32 | The host's Ed25519 public key (one per run of the game) |
|
||||
| 46 | 16, or 56 with the password flag | The invite's token (zero in a tombstone); with the password flag the token sealed with the password's key: nonce (24), MAC (16), the token encrypted (16), XChaCha20-Poly1305 with the host's key as additional data (`p2p_seal_token`) |
|
||||
| then | 1 | Players (at most 255) |
|
||||
| | 1 | Most players |
|
||||
| | 1 | The gametype's engine: 0 none (co-op), 1 CTF, 2 Slayer, 3 Oddball, 4 King of the Hill, 5 Race |
|
||||
| | 1 + up to 32 | The game's name: a length byte, then that many bytes |
|
||||
| | 1 + up to 32 | The map's name |
|
||||
| | 1 + up to 24 | The gametype's name |
|
||||
| | 8 | The stamp: the game's kind (`game_modes_kind`: the OpenCE mode, 1 SWAT, 2 Infection, 3 Gun Game, or 0; with 0x80 for Hardcore), then 7 reserved bytes, zero |
|
||||
| | 64 | The Ed25519 signature, by the listing's key, of the 12 ASCII bytes `hceu-lobby-1` followed by every byte before the signature |
|
||||
|
||||
| Flag | Meaning |
|
||||
| --- | --- |
|
||||
| 1 | Open: it takes players now |
|
||||
| 2 | In progress: a game is under way (or loading) |
|
||||
| 4 | Teams |
|
||||
| 8 | Closed: a tombstone, the host stopped |
|
||||
| 16 | Password: the token is sealed |
|
||||
| 32 | Dedicated: a dedicated server (`halo --server` sets it, since network version 39) |
|
||||
|
||||
A listing is 140 bytes at least (all names empty) and 268 at most (a
|
||||
password and every name at its length). A reader refuses one outside those
|
||||
sizes, without `"HL"` and format 1, with a name's length byte past its
|
||||
field's maximum or past the end, or whose stamp and signature do not end it
|
||||
exactly. The names are sanitised as the game's `sanitize` does: a byte
|
||||
outside 0x20 to 0x7E becomes `?`, and a zero ends the name. A master also
|
||||
refuses a listing whose key has a small order.
|
||||
|
||||
The vectors' first listing (an open team game of a dedicated server,
|
||||
sequence 412, 5 of 16 players, CTF on bloodgulch, named `OpenCE Dedicated`)
|
||||
is these 169 bytes, of which the first 105 are signed. The vectors were made
|
||||
at network version 38 and are kept as they are (the bytes and signatures
|
||||
are fixed): their listings carry version 38 with flag 32, which the game
|
||||
sets from version 39 on, so a game of version 39 reads them, checks their
|
||||
signatures and hides them from its browser as another version's games, as
|
||||
it does any. The examples' `network_version` of 38 in this document are the
|
||||
vectors' too.
|
||||
|
||||
| Field | Bytes |
|
||||
| --- | --- |
|
||||
| Magic, format | `484c` `01` |
|
||||
| Network version 38, flags 37 (open, teams, dedicated) | `0026` `25` |
|
||||
| Sequence 412, time 1760900000 | `0000019c` `68f533a0` |
|
||||
| Host key | `fc51cd8e6218a1a38da47ed00230f0580816ed13ba3303ac5deb911548908025` |
|
||||
| Token | `a0a1a2a3a4a5a6a7a8a9aaabacadaeaf` |
|
||||
| Players 5, most 16, engine 1 (CTF) | `05` `10` `01` |
|
||||
| Name, map, gametype | `10` `4f70656e434520446564696361746564`, `0a` `626c6f6f6467756c6368`, `03` `435446` |
|
||||
| Stamp (kind 0) | `0000000000000000` |
|
||||
| Signature | `633dc63eb27828d6e589e34dc4336dbb2d514b2018e4bf4a3adf5aeb774b6a523fe662c3d29241c6f91c8714a8ca2b5e493aacb32bcaeb9bce715f15b76d230f` |
|
||||
|
||||
(`testdata/vectors.json` has it whole, with a password game's, a
|
||||
tombstone's and an altered one that must be refused.)
|
||||
|
||||
## The probe
|
||||
|
||||
Before it lists a server, the master proves that the server's UDP port is
|
||||
reachable from the internet and that the publisher key's holder answers on
|
||||
it. It sends a datagram to the probe address (the published `address`, or
|
||||
the request's source address with `tunnel_port`) from its probe socket:
|
||||
|
||||
| Offset | Size | Probe (35 bytes) |
|
||||
| --- | --- | --- |
|
||||
| 0 | 10 | `"OPCE-PROBE"` |
|
||||
| 10 | 1 | 1 |
|
||||
| 11 | 8 | The master's key id, raw |
|
||||
| 19 | 16 | A nonce |
|
||||
|
||||
The game's tunnel socket, which dispatches what it receives by its first
|
||||
bytes, recognises the magic and answers from the same socket to the
|
||||
address the probe came from:
|
||||
|
||||
| Offset | Size | Answer (103 bytes) |
|
||||
| --- | --- | --- |
|
||||
| 0 | 14 | `"OPCE-PROBE-ACK"` |
|
||||
| 14 | 1 | 1 |
|
||||
| 15 | 8 | The master's key id, as the probe had it |
|
||||
| 23 | 16 | The nonce, as the probe had it |
|
||||
| 39 | 64 | The publisher key's Ed25519 signature of the 29 bytes `"probe"`, the master's key id, the nonce |
|
||||
|
||||
The server answers only a probe of exactly 35 bytes whose key id is that of
|
||||
a master in its `masters.txt`, only to the probe's source, a given nonce at
|
||||
most once per second, at most 2 answers a second to one source address and
|
||||
at most 10 answers a second in all, so the probe cannot be used to reflect
|
||||
traffic (a 103-byte answer to a 35-byte probe is the whole amplification),
|
||||
and probes forged from one address cannot use up the answers a master's
|
||||
probe needs. A probe whose nonce was answered in the same second counts
|
||||
against neither limit.
|
||||
The master takes only an answer from the probed address and port, with its
|
||||
own key id, a nonce it made for that address and key, and a signature that
|
||||
verifies with the key that signed the publish.
|
||||
|
||||
| Rule | Value |
|
||||
| --- | --- |
|
||||
| Attempts | 3, 2 seconds apart; failed 2 seconds after the third |
|
||||
| Again | Every 5 minutes while the server is reachable (it stays listed meanwhile); a failed server at its first publish a minute or more after the failure; at once when its probe address or key changes |
|
||||
| Nonce | Opaque to the server. A master uses a fresh nonce for each probe round (the round's attempts share it), and never the same one for two rounds of one address and key. `opence-master`'s is stateless: the first 16 bytes of HMAC-SHA-256(seed, `"opence-probe-1"` 0x00 address 0x00 key id 0x00 step), the step the decimal Unix time of the round's start divided by 30; it accepts the current and the previous hour's random seed and the current and the previous step, and starts rounds of one address and key at least a step apart |
|
||||
| Duplicates | A server answers a given nonce at most once per second: it remembers the nonces it answered (the last 64) with the Unix second they came in, and ignores a probe whose nonce it answered in the same second, whatever came between (A, B, A in one second: the second A is ignored). A master's retries, 2 seconds apart, are answered again; a nonce resent within the second is not |
|
||||
|
||||
With the vectors' master key (id `39f713d0a644253f`) and the nonce
|
||||
`101112131415161718191a1b1c1d1e1f`, the probe is
|
||||
`4f5043452d50524f42450139f713d0a644253f101112131415161718191a1b1c1d1e1f`, the
|
||||
signed message `70726f626539f713d0a644253f101112131415161718191a1b1c1d1e1f`,
|
||||
and the publisher's answer
|
||||
`4f5043452d50524f42452d41434b0139f713d0a644253f101112131415161718191a1b1c1d1e1f`
|
||||
followed by the signature
|
||||
`a63af355db038dff90e6c82abc0e252eddbd1ed3562580d7becaf3e4edbdd39cef7ef3163b91849ba57f6e83240b92df1efbce15dfa42f4a12981590a0234109`.
|
||||
|
||||
## The list
|
||||
|
||||
`GET /v1/servers`, with the optional query `network_version=<n>`,
|
||||
`dedicated=1` (or `0`), `region=<region>`, `q=<text>` (a case-insensitive
|
||||
substring of the name, map, gametype or variant; 32 characters at most).
|
||||
No signature is needed and plain HTTP is allowed: the body is signed.
|
||||
|
||||
```json
|
||||
{"protocol":1,"master":{"name":"OpenCE Master 1","key_id":"39f713d0a644253f","time":1760900000},
|
||||
"servers":[{"id":"4c5f15237c866f6f","publisher":{"id":"p_kz3c5lb2xvq7mdpa","name":"Milenko's servers","since":"2026-10"},
|
||||
"name":"OpenCE Dedicated","map":"bloodgulch","gametype":"CTF","variant":"CTF","players":5,"max_players":16,
|
||||
"teams":true,"in_progress":false,"password":false,"open":true,"dedicated":true,"kind":0,"engine":1,
|
||||
"network_version":38,"build":"build-206","region":"eu","reachable":true,"updated":1760899990,
|
||||
"listing":"<base64>"}]}
|
||||
```
|
||||
|
||||
| Entry field | Meaning |
|
||||
| --- | --- |
|
||||
| `id` | The server id |
|
||||
| `publisher` | The publisher's id (`p_` and up to 32 of `a-z0-9`), display name, and the year and month it was approved |
|
||||
| `name`, `map`, `gametype`, `players`, `max_players`, `teams`, `in_progress`, `password`, `open`, `kind`, `engine`, `network_version` | From the listing |
|
||||
| `variant`, `build`, `region` | From the publish |
|
||||
| `dedicated` | The listing's flag 32 or the publish's `dedicated` |
|
||||
| `reachable` | The last probe was answered (`false` for a trusted server or under `MASTER_LIST_UNREACHABLE`) |
|
||||
| `updated` | The time of the server's last publish |
|
||||
| `address` | Only with the operator's and the master's consent (above); absent otherwise |
|
||||
| `listing` | Base64 of the listing's exact bytes, as the server published them |
|
||||
|
||||
The list holds at most 512 entries: dedicated servers first, then by
|
||||
players. Its headers:
|
||||
|
||||
| Header | Value |
|
||||
| --- | --- |
|
||||
| `Signature` | `ed25519=` and the base64 of the master key's signature of the body's exact bytes (before any `Content-Encoding`) |
|
||||
| `Signature-Key` | The master's key id, 16 hexadecimal digits |
|
||||
| `Signature-Time` | The body's `master.time` |
|
||||
| `ETag` | `"` and the first 16 hexadecimal digits of SHA-256 of the body, and `"`; `If-None-Match` with it answers `304` |
|
||||
| `Cache-Control` | `public, max-age=5` (the master serves the same body for 5 seconds) |
|
||||
| `Content-Encoding` | `gzip` when the request's `Accept-Encoding` asks for it |
|
||||
| `Access-Control-Allow-Origin` | `*` (and `Access-Control-Expose-Headers` names the four above), for the web build |
|
||||
|
||||
A client:
|
||||
|
||||
1. checks `Signature` over the decompressed body bytes with the key in
|
||||
`masters.txt`, and that `Signature-Key` is that key's id, and refuses
|
||||
the whole body otherwise (a missing `Signature-Key` too; a client that
|
||||
cannot check Ed25519, such as an old browser, refuses every list rather
|
||||
than show one unchecked);
|
||||
2. parses the body, and refuses it unless `protocol` is 1, `master.key_id`
|
||||
is the key's id, and `master.time` is no older than 300 seconds and no
|
||||
more than 300 seconds ahead of the client's clock (a list dated ahead
|
||||
would be taken for longer when it is replayed later, and a clock that
|
||||
far off is wrong). The time is in the signed body: `Signature-Time` only
|
||||
repeats it, since a header is not signed, and a client need not read
|
||||
it;
|
||||
3. type-checks each entry, decodes its `listing`, runs `listing_read` and
|
||||
the host signature's check on it, and skips an entry that fails rather
|
||||
than the list; it shows the name, map, gametype and players of the
|
||||
signed listing (an entry's own fields are the master's word, and may
|
||||
differ); it filters control characters from every name, and takes at
|
||||
most 512 entries (a 512-entry list is some 26,000 JSON tokens: the game
|
||||
reads a list of 65,536 tokens at most);
|
||||
4. merges the masters' lists: entries with the same `id` are one game (the
|
||||
newest `updated` wins), and an entry whose listing key is also heard on
|
||||
the brokers is one game, shown as master-listed;
|
||||
5. never pings listed servers (that would tell every server the player's
|
||||
address): it shows the `region`, and the ping once a game is joined.
|
||||
|
||||
The vectors' signed body is
|
||||
`{"protocol":1,"master":{"name":"OpenCE Master 1","key_id":"39f713d0a644253f","time":1760900000},"servers":[]}`
|
||||
with `Signature: ed25519=18dmQnIfmRnC+wUwRJ/loxAH1VfASRBVnZgCfRuHrAw/2uo4thTibWnNQFScgRju+5lQtt709blK86BLT0fYCw==`
|
||||
and `ETag: "cd755a50c5cfc457"`.
|
||||
|
||||
`GET /v1/servers/{server_id}` answers one listed server the same way:
|
||||
`{"protocol":1,"master":{…},"server":{<entry>}}` with the same headers, or
|
||||
`404 not_found`.
|
||||
|
||||
## Other endpoints
|
||||
|
||||
| Request | Who | Answer |
|
||||
| --- | --- | --- |
|
||||
| `GET /v1/publishers/{id}` | anyone (the list's limit) | `{"ok":true,"id","name","since":"2026-10","status","servers":<listed now>}`, or `404` |
|
||||
| `POST /v1/applications`, `/v1/applications/…` | anyone | `410 applications_by_discord`: applications are made with the master's Discord bot (below), not over HTTP |
|
||||
| `POST /v1/keys` | signed, an approved publisher's active key | Body `{"public_key":"ed25519:…"}`: adds a key (8 active at most). `201 {"ok":true,"key_id","status":"active"}`; `409 key_exists`; `403 too_many_keys` |
|
||||
| `GET /v1/me` | signed, any key the master knows | The publisher's record: `{"ok":true,"key_id","status","publisher":{"id","name","since","status","quota","origin","keys":[{"key_id","public_key","status","updated","last_used"}],"servers":[{"id","instance","key_id","listed","probe","reachable","hidden","trusted","updated","name","players","max_players"}]}}`; for a key still in an application, `"publisher":null` and `"application":{"id","status","reason","created"}`; `403 key_revoked` |
|
||||
| `GET /v1/master` | anyone | The master's name, key id, public key, contact, data policy and limits (informational: clients use the key in `masters.txt`) |
|
||||
| `GET /healthz` | anyone | `200 {"ok":true,…}` while the database answers |
|
||||
| `GET /metrics` | anyone (the list's limit) | Prometheus text, read at most once each 5 seconds: `master_servers{reachable}`, `master_publishers{status}`, `master_publishes_total{result}`, `master_probes_total{result}`, `master_list_requests_total`, `master_peer_requests_total`, `master_build_info{version,protocol}` |
|
||||
| `GET /`, `GET /apply`, `/admin/*` | people | The list page (the list's limit), how to apply (the Discord bot, and an invite to its server), the admin pages |
|
||||
|
||||
## Applications
|
||||
|
||||
An operator applies with the master's Discord bot, in the master's
|
||||
Discord server (the `/apply` page links to it): the bot's `/apply` command
|
||||
takes the region (a menu of the master's choices) and the number of servers
|
||||
at once as its options, and answers the applicant alone with a nonce for
|
||||
the proof of key,
|
||||
`opence-apply-<unix>-<16 hex>`, good for 24 hours and bound to that Discord
|
||||
user (a nonce given to another user, or to none, does not prove this one's
|
||||
key), and a button that opens the application's form: a display name, the
|
||||
public key, the proof, and a note. The application's name is 3 to 32 printable ASCII characters,
|
||||
`servers` is 1 to 64, and the region up to 16 of `a-z`, `0-9` and `-`. The
|
||||
proof of key is required unless the master's policy says otherwise
|
||||
(`MASTER_REQUIRE_PROOF`, true by default): it is the publisher key's
|
||||
Ed25519 signature of the nonce's ASCII text, in hexadecimal (128 digits,
|
||||
what `halo --server --sign <nonce>` prints) or base64. An application
|
||||
without one is shown to the approvers as unproven. A key already a
|
||||
publisher's is refused, and so is a key with an application pending. The
|
||||
applicant is answered on Discord, and told of the decision by a direct
|
||||
message; the applicant's identity is their Discord user id and username.
|
||||
|
||||
Each application is posted to the master's log channel with Approve and
|
||||
Deny buttons, which only the members of the master's approver roles may
|
||||
press; the admin pages decide too. Once decided, anywhere, the message
|
||||
shows the outcome and who decided. The master's operator can also add an
|
||||
application on its command line (`opence-master challenge` for the nonce,
|
||||
then `add-application`), as the conformance test does.
|
||||
|
||||
A master limits applications, since each one is posted to its approvers:
|
||||
`opence-master` takes one pending application at a time and 3 a day per
|
||||
Discord user, 3 a day per key, and, of applications without a proof of key,
|
||||
100 an hour in all; one with a proof is not refused for the hour's number,
|
||||
but past 100 applications in an hour the approvers are alerted once and the
|
||||
next ones are not posted one by one (its settings change these numbers). It
|
||||
deletes a denied application 30 days after its denial.
|
||||
|
||||
The earlier HTTP application (`POST /v1/applications` with an e-mail
|
||||
address verified by a mailed link, `GET /v1/applications/challenge`, and
|
||||
the application's status by its mailed token) is gone: its endpoints
|
||||
answer `410 applications_by_discord`. A master keeps the applications made
|
||||
that way readable to its admins.
|
||||
|
||||
## Approval sharing between masters
|
||||
|
||||
The official masters share approvals, so an operator applies once. Each
|
||||
master fetches each peer's `GET /v1/publishers?since=<unix>` (every minute
|
||||
in `opence-master`), signed with its own master key in the request scheme
|
||||
above (`keyid` is its master key id, and the signed string's master key id
|
||||
is the peer's, the one it fetches from; a master answers only the peers it
|
||||
is configured with, else `403 not_a_peer`). The answer is signed as the list
|
||||
is (`Signature`, `Signature-Key`, `Signature-Time`, the body's
|
||||
`master.time`):
|
||||
|
||||
```json
|
||||
{"protocol":1,"master":{"name","key_id","time"},
|
||||
"publishers":[{"id","name","status","since","updated","origin","quota",
|
||||
"keys":[{"key_id","public_key","status","updated"}]}]}
|
||||
```
|
||||
|
||||
A master shares only what it holds a word of its own on: the publishers it
|
||||
approved or moderated (`status` is its own word: `approved`, `suspended` or
|
||||
`revoked`; `null` when it only vouches for keys), and the keys it added or
|
||||
revoked (`active` or `revoked`). `origin` is the key id of the master that
|
||||
approved the publisher, as the sharing master knows it (a master records a
|
||||
publisher new to it as come from the peer it fetched the record from,
|
||||
whatever origin the record claims, and only that peer's records rename
|
||||
it); `since` its approval time; `updated` the time of
|
||||
the newest word in the record; `since=` returns the records updated after
|
||||
it. The next fetch's `since` is the answer's `master.time` less 120 seconds,
|
||||
on the peer's own clock.
|
||||
|
||||
The importing master keeps each master's word apart and takes the most
|
||||
restrictive of the trusted masters' words as the publisher's status
|
||||
(`revoked` over `suspended` over `approved`) and the smallest quota given;
|
||||
a newer word from a master replaces that master's older one. So a
|
||||
suspension or revocation anywhere wins everywhere, and only the master that
|
||||
suspended a publisher can lift its suspension. A key revoked by any trusted
|
||||
master is revoked, for good; a key two publishers claim is refused. A
|
||||
master may refuse a peer's words (`MASTER_PEERS_TRUST`); they then count
|
||||
for nothing.
|
||||
|
||||
## Errors
|
||||
|
||||
Every error is `{"ok":false,"error":{"code":"…","message":"…","field":"…"?},"master_time":<unix>}`.
|
||||
The message is for people and may change; programs read the code.
|
||||
|
||||
| Status | Code | Meaning | A server's publisher should |
|
||||
| --- | --- | --- | --- |
|
||||
| 400 | `schema` | A field is missing, of the wrong type or out of range (`field` names it), or the body is not one JSON object | Log it once; it is a bug |
|
||||
| 400 | `server_id` | The path's id is not the key's and the instance's | Log it once |
|
||||
| 400 | `listing` | The listing does not parse, its signature fails, its key has a small order, or its time is an hour off | Log it once |
|
||||
| 401 | `bad_signature` | The Authorization header is malformed or its signature fails | Log it once |
|
||||
| 401 | `clock` | `ts` is more than 300 seconds from `master_time` | Log the difference (from the answer's `master_time`): the machine's clock is wrong |
|
||||
| 401 | `replay` | The nonce was used in the last 600 seconds | Send a new nonce |
|
||||
| 403 | `unknown_key` | No publisher or application has the key | Log `master: apply with key <id>` once a minute |
|
||||
| 403 | `publisher_pending` | The key's application waits for review | Log `master: publisher pending` once a minute; keep publishing every 30 s |
|
||||
| 403 | `application_denied` | The key's application was denied (`message` says why) | Log it once a minute |
|
||||
| 403 | `publisher_suspended` | The publisher is suspended | Log it; keep publishing slowly |
|
||||
| 403 | `publisher_revoked`, `key_revoked` | Revoked for good | Log it; stop publishing to that master |
|
||||
| 403 | `quota_exceeded` | The publisher has its quota of servers live | Log it |
|
||||
| 403 | `instance_taken` | Another key of the publisher has a live server of this instance | Log it; the old server expires after `ttl` |
|
||||
| 403 | `listing_taken` | The listing's host key is that of another publisher's live server, which has renewed it within 90 seconds | Log it once a minute; it is someone else's listing, or the host key is shared; keep publishing |
|
||||
| 403 | `too_many_instances` | The publisher holds its quota and 16 server records, none of which can be dropped | Log it; use fewer instance names |
|
||||
| 403 | `tls_required` | Plain HTTP from beyond loopback | Use the `https://` URL |
|
||||
| 403 | `not_a_peer` | A peer's request from a master not configured as a peer | |
|
||||
| 404 | `not_found` | No such server, publisher or endpoint | |
|
||||
| 409 | `key_exists` | The key added (`POST /v1/keys`) is known already | |
|
||||
| 410 | `applications_by_discord` | An application sent over HTTP: applications are made with the master's Discord bot | Log it: apply with the bot's `/apply` |
|
||||
| 413 | `too_large` | The body is over 16 KB | |
|
||||
| 429 | `rate_limited` | Too many requests; `Retry-After` gives the seconds to wait | Wait that long (the header's name read in any case; the game waits a day at most, and 30 seconds without one) |
|
||||
| 500 | `internal` | The master failed | Try again at the next interval |
|
||||
|
||||
## Privacy and limits
|
||||
|
||||
| What | Rule |
|
||||
| --- | --- |
|
||||
| Servers' addresses | Kept 7 days after the server's last publish, for probes and abuse handling; never served unless the operator and the master both chose to; not in the master's log unless its operator asks (`MASTER_LOG_ADDRESSES`) |
|
||||
| Applicants | Their Discord user id and username, seen by the master's admins and approvers (the log channel) only; no address is kept |
|
||||
| Applications | A denied one: deleted 30 days after the denial |
|
||||
| Servers' records | A closed server's: deleted an hour after it closed; one not published again: after 24 hours (unless an admin flagged it) |
|
||||
| Contacts | Discord names (and the earlier HTTP applications' e-mail addresses) are seen by the master's admins and approvers only, and are not shared with peers |
|
||||
| Strings | Printable ASCII, cut to the listing's lengths: name 32, map 32, gametype and variant 24, build 32 |
|
||||
| Requests | 60 list requests a minute per address (the list, one server, a publisher's page, the list page and the metrics together); the application limits above; bodies 16 KB at most; the publish limits above. Every limit by address counts an IPv6 address by its /64 |
|
||||
|
||||
## Known limitations
|
||||
|
||||
A listing's host key is bound to the first publisher whose live server
|
||||
publishes it, not to the host's own publisher: the listing does not say
|
||||
which publisher key the host chose. A publisher that copies a listing from a
|
||||
list while the host's publisher is not publishing (more than `ttl`) holds
|
||||
the host key, and the host's publisher is refused `listing_taken`, until the
|
||||
copy goes 90 seconds without a newer listing; one that keeps copying the
|
||||
host's newest listings from other lists keeps it until an admin hides its
|
||||
server or suspends it. The planned fix is in the listing: the host signs the
|
||||
key id of the publisher key it publishes with into the listing (a new
|
||||
listing format, with a new network version), and a master takes a listing
|
||||
only from that key.
|
||||
|
||||
## Versions
|
||||
|
||||
This is protocol 1: `protocol` in bodies, `/v1/` in paths and
|
||||
`OpenCE-Master-v1` in signed strings (followed by the receiving master's
|
||||
key id). A change that an older client or
|
||||
server would misread is a new version, with new paths; fields may be added
|
||||
to version 1, and both sides ignore what they do not know. The listing's
|
||||
own format follows the game's network version: a client hides entries
|
||||
whose `network_version` is not its own, as it does for the brokers'
|
||||
listings.
|
||||
|
||||
## Testing an implementation
|
||||
|
||||
`testdata/vectors.json` in the master's repository has, from fixed seeds:
|
||||
three key pairs with their key ids (the publisher's, the master's, a
|
||||
host's), a server id, a signed publish and a signed `GET /v1/me` to the
|
||||
vectors' master (its key id, the canonical strings, the signatures, the
|
||||
headers), a probe and its answer,
|
||||
four listings (a dedicated team game, a password game in progress with its
|
||||
sealed token, a tombstone, and an altered listing that must be refused), a
|
||||
signed list body with its headers and ETag, a small-order key that must be
|
||||
refused, and a proof of key. Monocypher's `crypto_ed25519_sign`,
|
||||
`crypto_ed25519_check` and `crypto_aead_lock` give the same bytes.
|
||||
`tests/conformance/opence_publisher.py` is a reference publisher in Python
|
||||
(keys, signatures, listings, publishing, the probe's answer), and
|
||||
`tests/conformance/test_master_protocol.py` runs a master through the whole
|
||||
flow: an application (on the master's command line, since the Discord bot
|
||||
is beyond a test's reach), the HTTP application's `410`, a pending
|
||||
publish, approval, the probe, the listed
|
||||
server's exact bytes in a signed list, closing, every refusal, and two
|
||||
masters sharing an approval, a suspension and a revocation.
|
||||
@@ -1,329 +0,0 @@
|
||||
# Mods
|
||||
|
||||
A mod is a folder of Halo PC tag files that the game plays over a map's own
|
||||
tags on your machine, as a resource pack does: sounds (a high-res audio
|
||||
pack), bitmaps (a texture pack, a HUD redraw), text (a translation) and
|
||||
models (higher-detail weapons, vehicles and scenery). Only the machine that
|
||||
has a mod plays it. Nothing of a mod is sent to another machine, and a mod
|
||||
changes nothing that the machines of a network game must agree on, so you
|
||||
can play with mods in any game, with players who have other mods or none. (A host's mod sounds of other lengths change how long
|
||||
the host's scripts and AI wait for dialogue to end; the host decides those
|
||||
for every machine, so they still agree.)
|
||||
|
||||
The game's code is `port/linux/game/mods.c` (with `mod_sounds.c`,
|
||||
`mod_bitmaps.c`, `mod_strings.c` and `mod_models.c`, one for each kind of
|
||||
tag) and `port/linux/src/port_mods.c` (the mods folder and its files).
|
||||
|
||||
## A mod's folder
|
||||
|
||||
The mods are in the `mods` folder of the data root (the folder with
|
||||
`maps/`; on Android the app's data folder, on the web the browser's storage
|
||||
for the site). Each mod is a folder in it, with a `mod.toml` and a `tags`
|
||||
folder:
|
||||
|
||||
```
|
||||
mods/
|
||||
hd_audio/
|
||||
mod.toml
|
||||
tags/
|
||||
sound/sfx/weapons/assault rifle/fire.sound
|
||||
sound/dialog/...
|
||||
german/
|
||||
mod.toml
|
||||
tags/
|
||||
ui/hud/hud_item_messages.unicode_string_list
|
||||
```
|
||||
|
||||
The files in `tags` have the paths of the tags they replace: a tag's name,
|
||||
then its group's extension, as the Halo Editing Kit and Invader keep them.
|
||||
`tags/sound/sfx/weapons/assault rifle/fire.sound` replaces the sound tag
|
||||
`sound\sfx\weapons\assault rifle\fire` of every map that has one. Names are
|
||||
not case-sensitive. The game only looks up the names of the map's tags among
|
||||
a mod's files: a mod cannot add tags, and no tag name of a map makes a path
|
||||
outside the mod.
|
||||
|
||||
`mod.toml` says what the mod is. Every key is optional:
|
||||
|
||||
```toml
|
||||
name = "High-res audio" # what the Mods menu shows (else the folder's name)
|
||||
id = "hd_audio" # what other mods name it by (else the folder's name)
|
||||
version = "1.0"
|
||||
authors = ["Someone", "Someone else"] # or one string
|
||||
description = "The game's sounds at 44 kHz"
|
||||
maps = ["a10", "bloodgulch"] # the maps it is for, by their files' names (else every map)
|
||||
load_after = ["hd_textures"] # mods it plays over: they load before it
|
||||
load_before = ["fixes"] # mods that play over it: they load after it
|
||||
incompatible = ["other_audio"] # mods it cannot be played with
|
||||
format = 1 # the mods' format it is made for
|
||||
```
|
||||
|
||||
`load_after`, `load_before` and `incompatible` name other mods by their `id`
|
||||
or their folder's name, not case-sensitive. A mod they name that is not in
|
||||
the mods folder is passed over. `maps = []` is every map.
|
||||
|
||||
A folder without `mod.toml` is not a mod. A mod made for a later `format`
|
||||
than the build's, or whose `maps` names no map, is not played. The game
|
||||
logs anything else wrong in `mod.toml` (an unknown key, a value of the
|
||||
wrong type) and uses the rest; a `mod.toml` that is not TOML at all is
|
||||
logged, and the mod played without what it says.
|
||||
|
||||
The game's log is its output: the terminal on Linux, `halo.log` beside
|
||||
`halo.exe` on Windows, logcat on Android, and the page's log on the web.
|
||||
|
||||
Limits: 256 mods, folder names of 63 bytes at most, 262144 files in all, 24
|
||||
folders deep under `tags`, and 64 maps in a mod's `maps`.
|
||||
|
||||
## The load order
|
||||
|
||||
Every mod in the mods folder is on until you turn it off. The mods load in
|
||||
an order, and where two mods have a file for the same tag, the one loaded
|
||||
later plays.
|
||||
|
||||
- The default order is the folders' names in alphabetical order (not
|
||||
case-sensitive), except that the mods a mod must load after (those it
|
||||
asks to load after, and those that ask to load before it) are taken to
|
||||
just before it. Mods that ask in a ring (a after b, b after a) load
|
||||
alphabetically, and the game's log says so.
|
||||
- The main menu's **Mods** (in the PC version's menus, `display.menus =
|
||||
"pc"`, the default) is laid out as the game lobby is: the mods on the
|
||||
left as a resource pack list has them, the one at the top playing over
|
||||
all those below it (the load order upside down: the mod loaded last is at
|
||||
the top), and the chosen mod's details in the frame on the right (its
|
||||
name, what is wrong with it, whether it is on, its priority, 1 the top,
|
||||
and its version, authors, folder, maps and description). Choosing a mod
|
||||
(A, or a click on the chosen one: the first click chooses it) turns it on
|
||||
or off (ON, OFF); left and right, or **Move up** and **Move down**, move
|
||||
the chosen mod (up: over one more mod). **OK** keeps the order and plays
|
||||
it at once (on a map that is loaded, too); **Cancel** leaves it as it was.
|
||||
- A warning sign beside a mod means it is on the wrong side of a mod it
|
||||
asks to load before or after (both on): a mod that loads after another is
|
||||
above it in the menu. A red cross means a mod that is on says it cannot be
|
||||
played with this one, or that it cannot be played at all (made for a later
|
||||
build, or its `maps` names none): it stays off. The details say which.
|
||||
|
||||
The menu keeps the order, and the mods turned off, in `mods/load_order.toml`,
|
||||
by the mods' folders' names:
|
||||
|
||||
```toml
|
||||
order = ["german", "hd_audio", "hd_textures"]
|
||||
disabled = ["hd_textures"]
|
||||
```
|
||||
|
||||
A mod added to the folder later is put where the default order puts it,
|
||||
after the mod before it there (but on the side it asks for of the mods it
|
||||
names), and is on. A mod gone from the folder is left out. When the file
|
||||
cannot be written, the game says so in its log and keeps the order until it
|
||||
quits.
|
||||
|
||||
### Mods that cannot be played together
|
||||
|
||||
When a mod that is on names another that is on as `incompatible`, the game
|
||||
asks as it starts, before the window opens:
|
||||
|
||||
- **Play anyway** plays them all (closing the box does too);
|
||||
- **Turn off ...** turns off the mods named as incompatible (if mod A says
|
||||
it cannot be played with mod B, B is turned off), and keeps that in
|
||||
`load_order.toml`;
|
||||
- **Quit** closes the game.
|
||||
|
||||
The Mods menu turns them on again. On the web, **Quit** starts the page
|
||||
again. A run nobody watches (`debug.hidden_window`, `debug.null_renderer`,
|
||||
`debug.exit_after` or `debug.network_test`) is not asked: it plays them all,
|
||||
and the game's log says which conflict.
|
||||
|
||||
At the console:
|
||||
|
||||
| Command | What it does |
|
||||
| --- | --- |
|
||||
| `mods_list` | Lists the mods in the mods folder in their load order, and which are on, then how many of the map's string lists, bitmaps, sounds and models the mods play. |
|
||||
| `mods_reload` | Finds the mods again and reads their files again: a changed file is read again (one that now fails a check leaves what was played before), a new one is played, and the map's tag comes back for a file that is gone. If a sound changed, all sounds stop. It does nothing while `mods_enable false`. |
|
||||
| `mods_enable false` | Plays the map's own tags until `mods_enable true` or the next map. |
|
||||
|
||||
These commands work in any game, a client's too: they change nothing of the
|
||||
game.
|
||||
|
||||
### Getting a mod onto each platform
|
||||
|
||||
- **Linux, Windows**: put the mod's folder in `mods/` next to `maps/`.
|
||||
- **Android**: put it in `mods/` in the app's data folder,
|
||||
`/sdcard/Android/data/com.halo.decomp/files/mods`, for example with
|
||||
`adb push hd_audio /sdcard/Android/data/com.halo.decomp/files/mods/`.
|
||||
- **Web**: on the page, **Mods**, **Add a mod folder…** copies a mod's
|
||||
`mod.toml` and `tags` folder into the browser's storage for the site.
|
||||
**Remove** deletes it again.
|
||||
|
||||
## What a mod can replace
|
||||
|
||||
The game plays these groups from a mod. It does not read the files of any
|
||||
other group (a `.weapon`, `.vehicle`, `.model_collision_geometry` or
|
||||
`.scenario`, for example): they would change what the machines of a network
|
||||
game must agree on.
|
||||
|
||||
| Group | Extension | What it is |
|
||||
| --- | --- | --- |
|
||||
| Sound | `.sound` | Sounds, music and dialogue |
|
||||
| Bitmap | `.bitmap` | Textures, sprites, the HUD's pictures |
|
||||
| Unicode string list | `.unicode_string_list` | The text the game shows |
|
||||
| String list | `.string_list` | Other text |
|
||||
| Model | `.gbxmodel` (Halo PC's), `.model` (the Xbox's) | What objects look like: weapons, first-person weapons and arms, vehicles, scenery, characters |
|
||||
|
||||
A file must be a Halo PC tag file of its group, as the Halo Editing Kit's
|
||||
tools and Invader write them (a model also as `invader-extract` writes an
|
||||
Xbox map's: `.model`). The game checks every count, size and offset
|
||||
in it against the file, and every value against what the game reads, before
|
||||
it uses the file. A file that fails a check is left out (the map's tag
|
||||
plays), and `debug.txt` and the console say why.
|
||||
|
||||
### Sounds
|
||||
|
||||
- The samples can be 16-bit PCM, Xbox ADPCM or Ogg Vorbis, mono or stereo,
|
||||
at 22 or 44 kHz. The game converts them to the Xbox ADPCM that it plays,
|
||||
as it does for Custom Edition maps: mono at 22 kHz, stereo at its own rate.
|
||||
- Empty values are filled in as a map's build fills them in: the defaults
|
||||
of the sound's class, the playback rates and the bend.
|
||||
- A sound must have permutations: a file with an empty pitch range (some
|
||||
Halo PC translations have them) is left out.
|
||||
- A permutation must fit in a block of the sound cache (one sound's samples:
|
||||
`MAXIMUM_SOUND_DATA_SIZE`).
|
||||
|
||||
### Bitmaps
|
||||
|
||||
- A bitmap's types and formats are those the game draws: 2D, 3D and cube
|
||||
maps; A8, Y8, AY8, A8Y8, R5G6B5, A1R5G5B5, A4R4G4B4, X8R8G8B8, A8R8G8B8,
|
||||
DXT1, DXT3, DXT5 and P8 bump. Sides are 4096 at most (512 for a 3D
|
||||
bitmap). A bitmap that is not a power of two on each side is drawn
|
||||
linear, as a Custom Edition map's is: it must be an uncompressed 2D
|
||||
bitmap.
|
||||
- One bitmap's pixels may take a quarter of the texture cache: 64 MB on
|
||||
Linux and Windows, 5.5 MB on Android and the web (a 2048 x 2048 DXT5 with
|
||||
its mipmaps fits on all of them).
|
||||
- A bitmap replaces the map's bitmap of its name, and the map's other tags
|
||||
use it as the map's: it must have at least as many bitmaps, of the same
|
||||
types, and as many sequences, each with at least as many sprites. It can
|
||||
be larger: a redraw at twice the size is drawn at the map's size, sharper.
|
||||
- The HUD draws a bitmap at its own size. So for each HUD element that draws
|
||||
a mod's bitmap, the game scales the element by the map's size of what it
|
||||
draws (its sprite, or with no sprites its bitmap) to the mod's, when that
|
||||
is the same ratio for all of them. A bitmap the HUD draws that is not the
|
||||
map's redrawn so (Halo PC's HUD bitmaps lay their sprites out to other
|
||||
sizes) is left out. The HUD's digits can be the map's size or twice it.
|
||||
- The menus draw a bitmap in their widgets' bounds, whatever its size.
|
||||
- Halo PC keeps the channels of a model shader's multipurpose maps and of
|
||||
the HUD's meters in another order than the Xbox. The game finds those
|
||||
bitmaps among the mod's and draws them in the Xbox's order, as it does for
|
||||
Custom Edition maps (`custom_edition_bitmaps.c`).
|
||||
- The pixels are read from the file when the texture cache loads them, not
|
||||
kept in memory.
|
||||
|
||||
### Text
|
||||
|
||||
- A list keeps the map's number of strings: a mod's strings past it are
|
||||
left out, and the map's own strings stay where the mod's list is shorter.
|
||||
- The game uses many strings as the format of what it prints
|
||||
(`%s was killed by %s`). A mod's string replaces the map's only if it has
|
||||
the same conversions in the same order (`%s`, `%d`, ...); otherwise the
|
||||
map's string stays. A translation keeps the conversions of the original.
|
||||
- Unicode strings are UTF-16, as the tool writes them.
|
||||
- The main menu is the port's own (the PC version's menus, `port/assets/menus`),
|
||||
whose text is in tags named `pc\...`. A mod's `ui\shell` lists change the
|
||||
Xbox's menus (`display.menus = "xbox"`) and the text shown while playing
|
||||
(HUD messages, the multiplayer messages, the pause menu).
|
||||
|
||||
### Models
|
||||
|
||||
A model is more than what is drawn: its nodes (its skeleton) are what its
|
||||
animations move, its markers are where projectiles leave a weapon, where a
|
||||
unit sits and where things attach, and its regions and permutations are what
|
||||
damage and an object's variant choose among. The machines of a network game
|
||||
agree on those, so a mod's model must have the map's:
|
||||
|
||||
- the same nodes: their names, hierarchy and default positions;
|
||||
- the same markers: their names, regions, permutations, nodes, positions
|
||||
and rotations (on the model's permutations, as the Halo Editing Kit keeps
|
||||
them, or on the model, as a map does);
|
||||
- the same regions and permutations: their names and flags.
|
||||
|
||||
Positions and rotations may differ from the map's by 0.001 at most (a model
|
||||
exported again is not always bit for bit the map's). Only what is drawn is
|
||||
the mod's: the geometries, their parts and vertices, which geometry each
|
||||
permutation draws at each detail level, the detail levels' cutoffs, the
|
||||
base map's scale, and which shaders each part is drawn with. A detail level
|
||||
the map draws must draw one of the mod's geometries, and one the map draws
|
||||
nothing at stays so. Every shader must be one the map has (a mod cannot add
|
||||
tags); a mod's bitmaps can redraw them.
|
||||
|
||||
The model is checked against each map's own model of its name as that map
|
||||
loads. On a map whose model of that name has other nodes, markers or
|
||||
regions (a custom map's own assault rifle, say), or lacks a shader the mod
|
||||
names, the mod's model is left out and the map's drawn; the mod's other
|
||||
files still play there. `maps` in `mod.toml` keeps a mod to the maps it is
|
||||
made for.
|
||||
|
||||
- Where a mod has both, its `.gbxmodel` plays; otherwise the file of the mod
|
||||
loaded later, whichever its format.
|
||||
- What the tool works out as it builds a map is worked out as it does: a
|
||||
part's strip is its triangles block, its centroid's nodes are its most
|
||||
weighted, its links of 0 to the parts drawn before and after it are none,
|
||||
a base map scale of 0 is 1, and a model whose tag asks for it has the
|
||||
normals of its vertices that share a position blended. The vertices are
|
||||
compressed as the game draws them.
|
||||
- A part's links to the parts drawn before and after it (for transparency)
|
||||
must not go round.
|
||||
- A model of 44 nodes or more (the renderer skins 43 at once; only Custom
|
||||
Edition maps' have so many) is drawn a part's own nodes at a time, as a
|
||||
Custom Edition map's is: a part's vertices may name 22 nodes at most.
|
||||
- The collision geometry, the animations and the object's tag are the map's:
|
||||
a larger weapon still hits and is hit where the map's does, and an object
|
||||
is still left undrawn by the map's bounds of it (a much larger model may
|
||||
vanish at the screen's edges).
|
||||
- Every model made from a file is kept until the map changes, a file edited
|
||||
and read again by `mods_reload` too, and counts against the mods' memory.
|
||||
|
||||
### Shaders
|
||||
|
||||
A model's parts can be drawn with a shader of every group Halo PC has but
|
||||
one: `shader_transparent_chicago_extended`, which Gearbox added for Halo PC.
|
||||
The Xbox game does not have it, so do not use it: use a
|
||||
`shader_transparent_chicago` shader instead. (A Custom Edition map's
|
||||
chicago extended shaders become chicago shaders as the map loads, keeping
|
||||
only their four-stage maps: see
|
||||
[custom_edition_caches.md](custom_edition_caches.md).) As for every
|
||||
shader, it must be one the map has.
|
||||
|
||||
## Making a mod
|
||||
|
||||
1. Get the tags you want to change as tag files. `invader-extract` extracts
|
||||
them from a map, and the Halo Editing Kit's tags are Halo PC's own.
|
||||
2. Change them with the Halo Editing Kit or Invader (`invader-bitmap`,
|
||||
`invader-sound` and `invader-model` build bitmaps, sounds and models from
|
||||
images, audio files and JMS files). Keep each tag's name.
|
||||
3. Put them in `tags/` of a folder in `mods/`, with a `mod.toml`.
|
||||
4. Load a map (a new mod is on). `mods_reload` at the console reads the
|
||||
files again as you change them, without loading the map again.
|
||||
|
||||
`debug.txt` has a line for every file the game leaves out, and why, and a
|
||||
summary of what each kind of tag plays from the mods:
|
||||
|
||||
```
|
||||
mods: 9 string lists from their files (9 new), 0 given back, 0 left out
|
||||
mods: 66 HUD placements scaled to draw larger bitmaps at the map's size
|
||||
mods: 354 bitmaps from their files (354 new), 0 given back, 6 left out
|
||||
mods: 313 sounds from their files (313 new), 0 given back, 2 left out
|
||||
mods: 4 models from their files (4 new), 0 given back, 1 left out
|
||||
```
|
||||
|
||||
## How it operates
|
||||
|
||||
- When a map's tags load, at `mods_reload` and at the Mods menu's **OK**,
|
||||
the game lists the files of the mods that are on, once, in a table of
|
||||
their tag paths. Each of the map's sound, bitmap, string list and model
|
||||
tags is looked up in it.
|
||||
- A tag replaced by a mod takes the file's values in place, so everything
|
||||
that holds the tag keeps it, and the map's own values come back when the
|
||||
file goes. A sound playing or a texture in the cache is never changed
|
||||
under the game: before a reload changes anything, the sounds stop and the
|
||||
caches let go of what they hold.
|
||||
- The mods' tags keep at most 512 MB in memory (192 MB on Android and the
|
||||
web): their files, their sounds' samples, their bitmaps' tags and their
|
||||
models' geometry.
|
||||
- A Custom Edition map takes mods as an Xbox map does.
|
||||
@@ -1,23 +1,16 @@
|
||||
# Android
|
||||
|
||||
The app of Mjolnir VR (application id `io.github.cesarus85.ringfall`, from
|
||||
the name before, "Ringfall: Mjolnir VR", kept so that installed apps update;
|
||||
its Java classes keep the decompilation's package, `com.halo.decomp`).
|
||||
`ninja android` builds the game for 64-bit ARM Android (arm64-v8a).
|
||||
`ninja android_apk` makes an app from it:
|
||||
`port/android/app/build/outputs/apk/debug/app-debug.apk`.
|
||||
|
||||
The game shows its graphics with OpenGL ES 3. It plays sound through SDL3
|
||||
(AAudio). It accepts input from game controllers, for example a PlayStation
|
||||
5 DualSense on Bluetooth, and from the touchscreen (refer to "Controls").
|
||||
The app needs Android 9 (API 28) or later. It operates on 64-bit-only
|
||||
devices, for example the Pixel 9 Pro XL.
|
||||
5 DualSense on Bluetooth. The app needs Android 9 (API 28) or later. It
|
||||
operates on 64-bit-only devices, for example the Pixel 9 Pro XL.
|
||||
|
||||
The Android build uses the platform layer of the Linux build
|
||||
(`port/linux/src`). Refer to [port/linux/README.md](../linux/README.md).
|
||||
Physical mice use the same control bindings. During play, F12 toggles mouse
|
||||
capture; captured mode hides Android's pointer and uses relative movement for
|
||||
continuous aiming, while releasing capture restores normal pointer behavior.
|
||||
|
||||
## Requirements
|
||||
|
||||
@@ -35,36 +28,6 @@ ninja) and these items:
|
||||
1.2.5 and SDL 3.4.16 to `build/android/third_party`. Gradle downloads the
|
||||
Android Gradle Plugin.
|
||||
|
||||
On Windows, build in WSL2 (Ubuntu 24.04). The Android build does not run
|
||||
on Windows itself. Enter
|
||||
`wsl -d Ubuntu -- bash tools/wsl_setup_android.sh` one time: it installs
|
||||
the tools and the Android SDK and NDK in WSL (apt asks for your
|
||||
password). Then enter
|
||||
`wsl -d Ubuntu -- bash tools/wsl_build_android.sh` for each build. The
|
||||
script copies the repository into WSL (`~/halo-build/src`) with LF line
|
||||
endings (a Windows checkout has CRLF line endings, which the build's text
|
||||
tools do not accept), builds there, and puts the APK in
|
||||
`dist/android/app-debug.apk`. Only the changed files are copied, so the
|
||||
next build is incremental. Install the APK with the adb of Windows.
|
||||
|
||||
A build that you make yourself has a different signature from the builds
|
||||
of GitHub Actions. Android installs it only after you remove the app, and
|
||||
removing the app deletes its data folder (`maps/`, `save/` and
|
||||
`config.toml`). Thus a change between the builds of GitHub Actions and your
|
||||
own builds loses the saved games, unless you copy them first (below).
|
||||
Your own builds all have the same signature (the debug key of WSL,
|
||||
`~/.android`), so they install over each other and keep the data
|
||||
(`adb install -r`).
|
||||
|
||||
To keep the saved games before you remove the app, enter
|
||||
`adb pull /sdcard/Android/data/io.github.cesarus85.ringfall/files/save/u` (the profiles).
|
||||
After the new install, before the first start of the app, enter
|
||||
`adb push u /sdcard/Android/data/io.github.cesarus85.ringfall/files/save/u`. The app reads
|
||||
and overwrites what adb pushes. adb cannot add files to `save/u` or `save/z` once the app made them, or
|
||||
change files that the app wrote, so push before the first start. adb cannot read
|
||||
some files that the app writes (the `blam.lst` files of `save/z`), so `adb pull`
|
||||
of the whole `save` folder stops there.
|
||||
|
||||
## Build and install the app
|
||||
|
||||
1. Go to the root folder of the repository.
|
||||
@@ -78,8 +41,8 @@ of the whole `save` folder stops there.
|
||||
## Game data
|
||||
|
||||
The game needs the `maps/` folder from an Xbox disc image (`.xiso` or
|
||||
`.iso`) made from your own copy of the game, any version. The app extracts `maps/` from the disc
|
||||
image. The app keeps the data in `/sdcard/Android/data/io.github.cesarus85.ringfall/files`.
|
||||
`.iso`) of any version of the game. The app extracts `maps/` from the disc
|
||||
image. The app keeps the data in `/sdcard/Android/data/com.halo.decomp/files`.
|
||||
|
||||
To install the data with the app:
|
||||
|
||||
@@ -94,19 +57,16 @@ To install the data with the app:
|
||||
To install the data from a computer:
|
||||
|
||||
1. Start the app one time. The app makes its folders.
|
||||
2. Enter `adb push <folder>/. /sdcard/Android/data/io.github.cesarus85.ringfall/files/`.
|
||||
2. Enter `adb push <folder>/. /sdcard/Android/data/com.halo.decomp/files/`.
|
||||
|
||||
| Item | Location in `/sdcard/Android/data/io.github.cesarus85.ringfall/files` |
|
||||
| Item | Location in `/sdcard/Android/data/com.halo.decomp/files` |
|
||||
| --- | --- |
|
||||
| Saved games (`z:\` and `u:\`) | `save` |
|
||||
| Mods (`docs/mods.md`) | `mods`: `adb push <mod folder> /sdcard/Android/data/com.halo.decomp/files/mods/`; the main menu's Mods orders them and turns them off |
|
||||
| Log | `debug.txt` |
|
||||
| Settings | `config.toml` |
|
||||
|
||||
To make a copy of the saved games, enter
|
||||
`adb pull /sdcard/Android/data/io.github.cesarus85.ringfall/files/save/u` (the profiles).
|
||||
An `adb pull` of the whole `save` folder stops at the `blam.lst` files of
|
||||
`save/z`, which adb cannot read.
|
||||
`adb pull /sdcard/Android/data/com.halo.decomp/files/save`.
|
||||
|
||||
## Controls
|
||||
|
||||
@@ -132,91 +92,17 @@ with the positions on the Xbox controller:
|
||||
| Create | back | |
|
||||
|
||||
The controller gets the rumble. The back gesture of Android is the B
|
||||
button. A Bluetooth or USB keyboard operates as on Linux.
|
||||
|
||||
The touchscreen operates the menus: tap an item to select it (on a
|
||||
setting with values, tap its left or right half), tap a button of the key
|
||||
at the bottom of a screen (for example "B = Back") to push it, and drag to
|
||||
scroll a list (down or right steps back, up or left steps forward). A drag
|
||||
stops at the first and the last item, and it does not change a setting's
|
||||
value. Touches that start in the edge-gesture zones of Android do not tap
|
||||
or scroll at the sides, and do not scroll at the top and bottom, because the
|
||||
first swipe from an edge in full screen only shows the system bars.
|
||||
|
||||
A tap during a cinematic that can be skipped skips it, as A does. On the
|
||||
on-screen keyboard, tap a key to press it, "B =BACK" to cancel and
|
||||
"A =ENTER" to accept the name.
|
||||
|
||||
### Touch controls
|
||||
|
||||
In a game, the app shows touch controls over the picture. They are a
|
||||
controller for player 1. With the default buttons of the profile:
|
||||
|
||||
| Control | Function in the game |
|
||||
| --- | --- |
|
||||
| stick (lower left) | move |
|
||||
| swipe on the screen away from the buttons | look |
|
||||
| Fire | right trigger |
|
||||
| Grenade | left trigger |
|
||||
| A / Jump, B / Melee, X / Reload, Y / Weapon | A, B, X, Y |
|
||||
| Crouch, Zoom | left and right stick clicks |
|
||||
| Light, Gren. type | white, black |
|
||||
| Pause, Back | start, back |
|
||||
| Up, Down, Left, Right | D-pad (in a network game, Up opens the text chat's keyboard) |
|
||||
|
||||
The names on the buttons follow the profile's "Button layout" (Settings >
|
||||
Gamepads): with "Swap triggers", the right trigger's button says "Grenade".
|
||||
The stick moves the player with every "Stick layout", southpaw too.
|
||||
|
||||
A finger that holds a button can also swipe to look, so you can fire and
|
||||
aim with one thumb. The controls are a finger wide (48 dp) or larger, but
|
||||
on a small screen of high density they stay apart rather than reach that
|
||||
size. A short tap reaches the game even when it is shorter than one frame.
|
||||
Swipes that start in the edge-gesture zones of Android do not turn the
|
||||
view. The swipe aims as the controller's stick does, not as a mouse: the
|
||||
aim slows over a target and follows a moving one, as with a controller,
|
||||
and it follows the profile's "invert look" (the gyroscope turns the view
|
||||
as the phone turns, never inverted). The setting `input.touch_aim_assist`
|
||||
turns the aim assist off. "Look sensitivity" sets how far a swipe turns;
|
||||
the mouse settings do not apply.
|
||||
|
||||
The touch controls show only in a game. In the menus and during
|
||||
cinematics they hide, and the touchscreen operates the menus as described
|
||||
above. They also hide when a controller is connected, for example the
|
||||
built-in controller of a handheld. A device without a touchscreen (a TV)
|
||||
never shows them. The setting `input.touch_controls` changes this (refer
|
||||
to "Settings").
|
||||
|
||||
The buttons at the top of the screen:
|
||||
|
||||
- "Hide" removes the controls (and stops the gyroscope aiming and the
|
||||
vibration) until you push "Touch"; the app remembers it.
|
||||
- "Options" opens these items:
|
||||
- "General": the phone's vibration (on by default; it follows the
|
||||
vibration setting of the game's profile), aiming with the gyroscope
|
||||
(off by default), a floating move stick (off by default: the stick goes
|
||||
where your thumb lands in the lower left of the screen), the opacity of
|
||||
the controls, "Hide or add buttons" (hide a button, add a copy of a
|
||||
button) and "Edit buttons size".
|
||||
- "Edit buttons layout": drag the controls to new positions, then push
|
||||
"Save". "Export" and "Import" write and read a layout file with the
|
||||
file picker of the system.
|
||||
- "Look sensitivity".
|
||||
|
||||
"Hide" and "Options" act when the finger lifts on them: a swipe that
|
||||
starts on them turns the view instead.
|
||||
|
||||
The app keeps the layout in its own preferences, not in `config.toml`.
|
||||
Removing the app's data or the app removes the layout.
|
||||
button. A Bluetooth or USB keyboard operates as on Linux. The screen does
|
||||
not accept touch input.
|
||||
|
||||
## Settings
|
||||
|
||||
The settings are in `config.toml` in the data folder of the app. To change
|
||||
them:
|
||||
|
||||
1. Enter `adb pull /sdcard/Android/data/io.github.cesarus85.ringfall/files/config.toml`.
|
||||
1. Enter `adb pull /sdcard/Android/data/com.halo.decomp/files/config.toml`.
|
||||
2. Change the file.
|
||||
3. Enter `adb push config.toml /sdcard/Android/data/io.github.cesarus85.ringfall/files/`.
|
||||
3. Enter `adb push config.toml /sdcard/Android/data/com.halo.decomp/files/`.
|
||||
|
||||
At the first start, the game writes the file with the default values. To
|
||||
get the default values again, delete the file.
|
||||
@@ -227,13 +113,8 @@ These settings are only for Android:
|
||||
|
||||
| Setting | Function |
|
||||
| --- | --- |
|
||||
| `input.touch_aim_assist` | `true` (the default): the touch controls' swipe aiming gets the aim assist of a controller (the aim slows over a target and follows a moving one). `false`: none, as with a mouse; the bullets' own autoaim stays. |
|
||||
| `input.touch_controls` | The touch controls in a game. `"auto"` (the default): shown on a touchscreen while no controller is connected. `"on"`: also shown with a controller. `"off"`: never shown. A device without a touchscreen never shows them. The menus take taps in any case. |
|
||||
| `display.screen_width` | The number of columns of the 480-line picture. `0` (the default): the shape of the display (1068 on a 20:9 phone). `640`: the 4:3 shape of the Xbox. |
|
||||
| `display.shader_cache` | `true` (the default): the linked shader programs are kept in `shader_cache` in the data folder (their binaries, the driver that made them and their sources), and each map's list of the programs it drew with; as a map loads, the programs on its list are made ready, so that its first frames do not wait for the driver to compile them. A driver update compiles them again from the kept sources. `false`: each program is compiled the first time it is drawn. The folder may be deleted at any time. |
|
||||
| `display.shader_worker` | `true` (the default): the shader programs are made on a thread of their own, whose GL context shares the game's (loaded from the shader cache, or compiled), and drawn with once there (`debug.shader_warm_up`: `"worker"`, `"load"` on the game's thread as a map loads, or `"off"`); a draw whose program is not made yet is left out for the frames it takes, and the frame does not wait. As a map loads, its own programs and then every map's (`shader_cache/all.txt`) are asked for. `false`: each is made on the game's thread when first drawn with. |
|
||||
| `debug.sample_seconds` | Refer to "Find problems". |
|
||||
| `debug.memory_watch` | `true` (the default): the app notices the game's writes to cached textures by page protection. `false`: it compares page contents once a frame instead, which is slower. Geometry uses the streaming path in either mode. Refer to "Limits". |
|
||||
|
||||
## Internet play
|
||||
|
||||
@@ -267,24 +148,16 @@ select "Yes":
|
||||
|
||||
1. The app downloads the new version.
|
||||
2. The package installer of Android opens. At the first update, Android asks
|
||||
you to let the game install apps. Allow it.
|
||||
you to let Halo install apps. Allow it.
|
||||
3. Select "Update". Android replaces the app.
|
||||
4. Select "Open" to start the new version.
|
||||
|
||||
To install over the previous version, each build must have the same
|
||||
signature. GitHub Actions signs each build with the key in the
|
||||
`ANDROID_KEYSTORE_BASE64` and `ANDROID_KEYSTORE_PASSWORD` secrets of the
|
||||
repository. A computer that builds for its own devices signs with the same
|
||||
key when `port/android/signing.properties` (not in the repository) names it:
|
||||
|
||||
storeFile=/path/to/ringfall-release.jks
|
||||
password=<the keystore's password>
|
||||
keyAlias=ringfall
|
||||
|
||||
Keep the keystore and its password safe: a lost key means every player must
|
||||
remove the app before the next version. If you installed a build that has a different signature, remove
|
||||
repository. If you installed a build that has a different signature, remove
|
||||
that build before you install a new build. Removing the app deletes its data
|
||||
folder: first make a copy of `maps/` and `save/u`.
|
||||
folder: first make a copy of `maps/` and `save/`.
|
||||
|
||||
## Widescreen
|
||||
|
||||
@@ -295,10 +168,7 @@ the Xbox:
|
||||
- The HUD stays at the edges of the screen.
|
||||
- The menus, the loading bar and the screens after a game have 640
|
||||
columns, at the center of the screen.
|
||||
- Black bars and fades cover all of the screen, and so do the menus' dims
|
||||
and backgrounds (the pause menu's dim, dialogs, the menus' gradient).
|
||||
|
||||
All the ports draw this way.
|
||||
- Black bars and fades cover all of the screen.
|
||||
|
||||
## VR
|
||||
|
||||
@@ -311,7 +181,7 @@ instead.
|
||||
|
||||
Controls in play (in the menus the buttons are the Xbox's by position):
|
||||
|
||||
| Controller | Game |
|
||||
| Controller | Halo |
|
||||
| --- | --- |
|
||||
| right trigger / left trigger | fire / throw grenade |
|
||||
| right grip / left grip | melee / switch weapon |
|
||||
@@ -359,7 +229,7 @@ through a shader that decodes to linear, and the stored bytes are the
|
||||
game's. Camera shake is off in VR.
|
||||
|
||||
A file named `xr_test` in the data folder
|
||||
(`adb shell touch /sdcard/Android/data/io.github.cesarus85.ringfall/files/xr_test`)
|
||||
(`adb shell touch /sdcard/Android/data/com.halo.decomp/files/xr_test`)
|
||||
starts a self-test instead of the game, which needs no game data: each eye
|
||||
in its own colour (red while the right trigger is held), a checkerboard
|
||||
screen in the room (its top-left square red), and the controllers' buttons
|
||||
@@ -369,6 +239,12 @@ Not done yet: aiming with the controller and the weapon in the hand, the
|
||||
HUD's parts on the controllers, zoom through the scope, a first-person view
|
||||
in vehicles, and a separate depth for the HUD's reticle.
|
||||
|
||||
## How it works
|
||||
|
||||
The changes are in `#ifdef HALO_ANDROID` in `rasterizer_xbox.c`, `render.c`,
|
||||
`ui_widget.c`, `cinematics.c`, `main.c` and
|
||||
`rasterizer_xbox_screen_effect.c`.
|
||||
|
||||
## How the port operates
|
||||
|
||||
### ILP32 code
|
||||
@@ -390,9 +266,7 @@ The guest is the game, the platform layer and a small runtime:
|
||||
AArch64 target of clang. The options `-U__APPLE__` and
|
||||
`-fno-define-target-os-macros` hide the Darwin environment.
|
||||
2. `tools/android_asm_convert.py` changes the Mach-O assembly to ELF
|
||||
assembly. It renames symbols, but keeps string literals (`.ascii`,
|
||||
`.asciz`) byte for byte: they hold tables as well as text
|
||||
(`tools/test_android_asm_convert.py`).
|
||||
assembly.
|
||||
3. The AArch64 assembler makes the objects.
|
||||
4. `ld.lld` links the objects with `guest/guest.ld` to a static image,
|
||||
`build/android/halo_guest.elf`, at a fixed address above the Xbox memory
|
||||
@@ -413,7 +287,7 @@ and supplies the thread pointer and TLS.
|
||||
|
||||
- Reserves the address space of the guest below 4 GB: the Xbox memory at
|
||||
`0x80000000`, the image, and pools for the memory of the guest
|
||||
(`host/host_memory.c`). Refer to "The fixed addresses".
|
||||
(`host/host_memory.c`).
|
||||
- Loads the image and fills its import table (`host/host_loader.c`).
|
||||
- Starts the `main` of the game and each guest thread on a stack in guest
|
||||
memory, because ILP32 code keeps stack addresses in 32-bit registers
|
||||
@@ -421,9 +295,8 @@ and supplies the thread pointer and TLS.
|
||||
- Gives the audio callback of SDL to a thread with a guest stack
|
||||
(`host/host_sdl.c`).
|
||||
- Does the calls of the guest: system calls (`host/host_syscall.c`), SDL
|
||||
(`host/host_sdl.c`), OpenGL ES (`host/host_gl.c`), and the file, socket,
|
||||
UPnP and DTLS functions of `port/linux/src/posix_*.c` (DTLS with Mbed TLS,
|
||||
for internet play with browsers: `posix_dtls.c`).
|
||||
(`host/host_sdl.c`), OpenGL ES (`host/host_gl.c`), and the file and socket
|
||||
functions of `port/linux/src/posix_*.c`.
|
||||
|
||||
The guest calls the host through stubs (`tools/android_imports.py`). The
|
||||
two ABIs use the same registers for 32-bit integers, floats and pointers.
|
||||
@@ -431,49 +304,6 @@ two ABIs use the same registers for 32-bit integers, floats and pointers.
|
||||
`port/linux/src/gl.h`. `tools/android_posix_stubs.py` makes the stubs of the
|
||||
`posix_*` functions, which copy the `errno` of the host.
|
||||
|
||||
### The fixed addresses
|
||||
|
||||
The guest needs the Xbox memory at `0x80000000` to `0x88000000` and the
|
||||
image above it, to `0x8c000000`. The cache files contain pointers to these
|
||||
addresses. The Java runtime of Android (ART) also reserves its spaces below
|
||||
4 GB. On some devices, for example handhelds with a large Java heap (the
|
||||
AYN Thor, the Retroid Pocket), ART's large object space covers
|
||||
`0x80000000`. ART fills that space from its bottom, so the part at
|
||||
`0x80000000` is usually empty.
|
||||
|
||||
Thus:
|
||||
|
||||
1. The game operates in a process of its own (`:game`), with a fresh Java
|
||||
heap. The launcher, the import of a disc image and an earlier game do
|
||||
not leave objects there.
|
||||
2. At the start of that process, `HaloApplication` loads `libmain.so`. Its
|
||||
`JNI_OnLoad` reserves the fixed addresses before the Java side
|
||||
allocates large objects.
|
||||
3. If ART's large object space is in the way, the host takes back only the
|
||||
part that covers the fixed addresses, and only if no page of it is in
|
||||
use (`/proc/self/pagemap`, or `mincore` and the swap of that part if
|
||||
the device refuses `pagemap`). The host never takes the other spaces of
|
||||
ART.
|
||||
|
||||
If the addresses are not available, the game shows a message, and writes
|
||||
the mappings below 4 GB to `memory_map.txt` in the data folder and to the
|
||||
log.
|
||||
|
||||
To test the reclaim on any device, set a system property before you start
|
||||
the game. The app then puts a stand-in for ART's large object space over
|
||||
the fixed addresses:
|
||||
|
||||
- `adb shell setprop debug.halo.art_overlap idle`: the stand-in is empty
|
||||
at `0x80000000`. The log shows `reclaimed idle ART range`, and the game
|
||||
starts.
|
||||
- `adb shell setprop debug.halo.art_overlap busy`: a page at `0x80100000`
|
||||
is in use. The game shows the message and writes `memory_map.txt`.
|
||||
- Add `-nopagemap` to either value (`idle-nopagemap`) to test as on a
|
||||
device that refuses `/proc/self/pagemap`. Add `-swapped`
|
||||
(`idle-nopagemap-swapped`) to also move the objects of the stand-in to
|
||||
swap; with `busy`, the page in the fixed addresses too.
|
||||
- `adb shell setprop debug.halo.art_overlap ""`: normal operation.
|
||||
|
||||
### OpenGL ES
|
||||
|
||||
The renderer (`port/linux/src/d3d8_gl.c`) uses OpenGL ES 3.0, and some
|
||||
@@ -491,11 +321,7 @@ functions of OpenGL ES 3.2 if they are available:
|
||||
changes the indices.
|
||||
- On OpenGL ES 3.1 and later, the visibility tests (lens flares) count
|
||||
samples with an atomic counter, as the NV2A did. OpenGL ES 3.0 tells only
|
||||
if a sample is visible. The GPU copies the counters at the end of each
|
||||
frame, and the CPU reads the copy two frames later, when the frame's fence
|
||||
has passed: a result is the latest count the GPU has finished, as with
|
||||
the query buffer of desktop OpenGL. A read of the counters themselves
|
||||
waits for the GPU, which halved the frame rate on Turnip (Zink).
|
||||
if a sample is visible.
|
||||
|
||||
### Calling conventions
|
||||
|
||||
@@ -518,17 +344,9 @@ floating-point contraction, as on x86.
|
||||
|
||||
### Game source changes
|
||||
|
||||
The port's code tells three things apart, each its own macro, which the
|
||||
Android build defines all of (`tools/android_build.py`):
|
||||
|
||||
- `HALO_ARM64_GUEST`: the guest's ABI (ILP32 AArch64 code in a 64-bit
|
||||
process);
|
||||
- `HALO_GLES`: the OpenGL ES renderer;
|
||||
- `HALO_ANDROID`: the app (its display, input, files and lifecycle).
|
||||
|
||||
The x86 inline assembly is replaced by C (refer to
|
||||
[port/linux/README.md](../linux/README.md#game-source-changes)).
|
||||
These changes are in `#ifdef HALO_ARM64_GUEST`:
|
||||
These changes are in `#ifdef HALO_ANDROID`:
|
||||
|
||||
- Seven `#pragma bss_seg(".bss")` lines are removed. The Darwin target does
|
||||
not accept them.
|
||||
@@ -543,23 +361,6 @@ assembly of the port is necessary:
|
||||
- The symbol aliases in `guest/libc/src_include/features.h`. The Darwin
|
||||
target does not accept alias attributes.
|
||||
|
||||
## Geometry uploads
|
||||
|
||||
Android streams vertex and index data from the current CPU bytes instead
|
||||
of reusing the persistent geometry mirror or its cached index extents.
|
||||
This is automatic; no console command or configuration change is needed.
|
||||
Affected players reported that bypassing the cache resolved stretched or
|
||||
missing geometry, with some also reporting better performance. The exact
|
||||
cache failure mechanism remains unconfirmed.
|
||||
|
||||
The Android-only guard in `mirror_range` uses the existing streaming
|
||||
fallback. Streamed upload methods, frame fences, shaders, texture caching
|
||||
and CPU write tracking are unchanged. Desktop and web retain their cache.
|
||||
Xbox and Custom Edition maps keep their existing loaders and resource
|
||||
paths. `tools/test_android_mirror_uploads.py` checks the bypass with large
|
||||
and reused ranges, frame-counter rollover and desktop/web cache controls;
|
||||
it does not substitute for device gameplay validation.
|
||||
|
||||
## Find problems
|
||||
|
||||
- Enter `adb logcat -s halo` to see the log of the port and the errors of
|
||||
@@ -572,28 +373,13 @@ it does not substitute for device gameplay validation.
|
||||
at this interval. This finds hangs on devices without root access.
|
||||
- Set `gl_debug = true` in `[debug]` of `config.toml`. The log then shows
|
||||
the OpenGL ES errors.
|
||||
- The log says which write tracking the app uses: "page protection"
|
||||
(devices) or "page hashes" (the emulator, or `debug.memory_watch = false`).
|
||||
|
||||
## Limits
|
||||
|
||||
- Bink video is not available. The game skips the movies.
|
||||
- The device must let the app reserve the fixed guest addresses, from
|
||||
`0x80000000` to `0x8c000000`. If ART uses them, the app shows a message
|
||||
(refer to "The fixed addresses").
|
||||
- Touch operates the menus and skips cinematics. In the game, the touch
|
||||
controls appear when no controller is connected; their size follows the
|
||||
height of the screen (larger on a tablet than on a phone), never smaller
|
||||
than a finger.
|
||||
`0x80000000` to approximately `0x89000000`. If the addresses are not
|
||||
available, the app shows a message.
|
||||
- The game does not accept touch input. Use a controller or a keyboard.
|
||||
- Kernels with 16 KB pages (a developer option of Android 15) do not
|
||||
operate. The Xbox memory uses 4 KB pages.
|
||||
- The x86 Android emulator runs the app through its ARM translation. The
|
||||
translation cannot deliver the page faults that the renderer uses to
|
||||
notice changed textures. On the emulator the app compares
|
||||
page contents once a frame instead ("write tracking: page hashes" in the
|
||||
log). This is slower, and texture changes may appear one frame later.
|
||||
`debug.memory_watch = false` does the same on a device. The translation
|
||||
also has no scalar conversion from floating
|
||||
point to an integer in a SIMD register (`fcvtzs s0, s1`, an illegal
|
||||
instruction there), so `tools/android_asm_convert.py` writes each as the
|
||||
vector form, which leaves the register and the exception flags the same.
|
||||
@@ -1,182 +0,0 @@
|
||||
# Steam Frame
|
||||
|
||||
The same APK as for the Quest runs on the Steam Frame, in Lepton (SteamOS's
|
||||
Android, a Waydroid fork: Android 11, arm64), with SteamVR's OpenXR runtime.
|
||||
What differs is found at run time, not by a build of its own.
|
||||
|
||||
## Installing it (players)
|
||||
|
||||
On the Frame, in Desktop Mode (Steam menu > Power > Switch to Desktop):
|
||||
1. Put your own disc image of Halo: Combat Evolved for the original Xbox (`.iso` or
|
||||
`.xiso`, any version) in Downloads (or Documents, the Desktop, a memory
|
||||
card).
|
||||
2. Download `Install-Mjolnir-VR.desktop` from the latest release and open it
|
||||
(double-click; confirm running it).
|
||||
3. Answer the dialogs: the installer finds the disc image (or asks for it),
|
||||
copies the game data out of it, adds "Mjolnir VR" to the Steam library
|
||||
and switches back to Gaming Mode. Start it from the library there.
|
||||
|
||||
The game updates itself: while it runs, its launcher looks for a newer
|
||||
release, fetches it and puts it in place as the next start begins
|
||||
(`steam_frame_launch.sh`; `update.auto = false` in `config.toml` stops it;
|
||||
`launcher.log` says what it did). Opening the same file again updates it
|
||||
too (settings, saves and game data stay).
|
||||
|
||||
The desktop file (`steam_frame_installer.desktop`) downloads the latest
|
||||
release's `mjolnir-vr-steam-frame.zip` (`tools/steam_frame_bundle.py`, made by
|
||||
the release job of `.github/workflows/build.yml`) and runs its
|
||||
`install.sh` (`steam_frame_install.sh`), with zenity dialogs:
|
||||
- `~/Documents/RingfallMjolnirVR`: the launcher (`ringfall-mjolnir-vr.sh`)
|
||||
and the release APK (`RingfallMjolnirVR.apk`); the folder of the builds
|
||||
before the name, `~/Documents/HaloCE`, renamed to it, and their "Halo VR"
|
||||
shortcut replaced. (These keep the name of builds 302 to 313, "Ringfall:
|
||||
Mjolnir VR": the Steam shortcut of an installed game starts the launcher
|
||||
there, and the launcher's update looks for them in the bundle.);
|
||||
- the maps folder out of the disc image (`steam_frame_xiso.py`, the app's
|
||||
`XisoExtractor.java` in Python), unless `maps/ui.map` is there;
|
||||
- the Steam shortcut, unless it is there: added by Steam itself
|
||||
(`steam://addnonsteamgame`, as SteamOS's "Add to Steam" does) from
|
||||
`Mjolnir VR.desktop` beside the game, then the library pictures
|
||||
under the id Steam gave it. Steam is not closed: on the Frame, Desktop
|
||||
Mode runs inside Gaming Mode's session, and closing Steam ends it (and the
|
||||
installer with it). An old "Halo VR" shortcut is left for the player to
|
||||
remove (Steam would write it back);
|
||||
- what it did in `install.log` beside the game.
|
||||
|
||||
`HALO_VR_UNATTENDED=1` (and `HALO_VR_IMAGE=<image>`) runs it without
|
||||
dialogs, for testing over adb; it leaves Steam and its shortcuts alone.
|
||||
|
||||
## The device
|
||||
|
||||
- Steam Settings > System > Enable Developer Mode; then start "Lepton
|
||||
Development" from the library. While the headset sleeps Lepton stops, and
|
||||
adb with it.
|
||||
- adb over the network: `adb connect <frame-ip>:5555`; over USB:
|
||||
`adb forward tcp:5555 tcp:5555` then `adb connect localhost:5555`.
|
||||
Always name the device (`adb -s <frame-ip>:5555 ...`): a Quest may be
|
||||
connected as well.
|
||||
- Install with `adb install -r --no-streaming`. It prints "Lepton post
|
||||
installation failed due to APP_PATH being unset", but installs. Start the
|
||||
game with `am start -n io.github.cesarus85.ringfall/com.halo.decomp.LauncherActivity`.
|
||||
- Lepton empties `/sdcard/Android/data` whenever it starts again: the game's
|
||||
data must live elsewhere (stage 2). `/sdcard/Documents` and
|
||||
`/sdcard/Download` are the SteamOS user's folders and are kept.
|
||||
|
||||
## What the port does for it
|
||||
|
||||
- SDL3's clipboard handler takes a clipboard service for granted, which
|
||||
Lepton has not: `tools/android_build.py` patches it to do without.
|
||||
- SteamVR lists an implicit OpenXR layer for Vulkan apps whose library an
|
||||
app cannot load: the APK carries a pass-through layer under its name
|
||||
(`port/android/xr_layer/fdm_injection_stub.c`).
|
||||
|
||||
## Stages
|
||||
|
||||
| # | Stage | State |
|
||||
| --- | --- | --- |
|
||||
| 1 | Base: the fixes above on the current main | done |
|
||||
| 2 | The game's data where Lepton keeps it | done: `/home/steamos/Documents/RingfallMjolnirVR` |
|
||||
| 3 | Menus, HUD and text visible (quad layers) | done: their alpha from their colour |
|
||||
| 4 | The freeze at the cryo bay's calibration | not seen again (2026-10-04) |
|
||||
| 5 | The Frame's controllers | done: their own profile, the Xbox's layout |
|
||||
| 6 | Frame rate, resolution | done: 72 Hz steady, multiview on |
|
||||
| 7 | Multiplayer, voice, cross-play with the Quest | |
|
||||
| 8 | A button in the Steam library | done: `steam_frame_launch.sh` |
|
||||
|
||||
## Starting it on the Frame
|
||||
|
||||
A button in the Steam library ("Mjolnir VR", a non-Steam game)
|
||||
runs `~/Documents/RingfallMjolnirVR/ringfall-mjolnir-vr.sh` (`port/android/steam_frame_launch.sh`),
|
||||
which starts the game as Steam starts an Android title of its own:
|
||||
`lepton waitforexitandrun -- ~/Documents/RingfallMjolnirVR/RingfallMjolnirVR.apk`, in a container
|
||||
of its own (`steamlaunch-4290000001`) that Lepton installs the APK into
|
||||
anew whenever the file is newer. Updating the game is replacing that APK.
|
||||
|
||||
What the script does that Steam would for an Android title:
|
||||
- a compat data path (`steamapps/compatdata/4290000001/internal`): after an
|
||||
install Lepton links the app's data to it, a dangling link without it;
|
||||
and the shader path, which Lepton reads Steam's shader dump path against;
|
||||
- a container id of its own: with the shortcut's id, SteamVR's client in the
|
||||
container stalled in xrCreateInstance;
|
||||
- a few starts: a new APK's first start only installs it, and a start that
|
||||
ends within 30 s is tried again (up to three times), unless the game was
|
||||
quit (it writes `quit_requested.txt`).
|
||||
|
||||
Steam's "Exit game" does not reach the game (its process is the container's,
|
||||
not Steam's): quit it with the VR options' "Quit the game" (Y in the main or
|
||||
pause menu, twice). A container ended within 30 s of its start makes
|
||||
Lepton drop the app's install, so the next start installs it again.
|
||||
|
||||
The shortcut is in `userdata/<id>/config/shortcuts.vdf` (Steam reads it when
|
||||
it starts; appid 3151454348 for this name and path), its pictures in
|
||||
`userdata/<id>/config/grid/` (from `port/android/steam_frame_grid/`). From
|
||||
the Mac, over USB the Frame's SteamOS is an adb device of its own, `frame`,
|
||||
beside Lepton's `<frame-ip>:5555`.
|
||||
|
||||
## The game's data
|
||||
|
||||
Lepton uninstalls the app and empties its folders whenever it starts again.
|
||||
The game's data lives in the SteamOS user's Documents instead: when
|
||||
`/home/steamos/Documents` can be written, the launcher makes
|
||||
`/home/steamos/Documents/RingfallMjolnirVR` and the launcher and the game take it as
|
||||
their data folder (config.toml, saves and debug.txt go there too), so a
|
||||
disc image imported in the app stays as well. The installer above fills it;
|
||||
by hand, once:
|
||||
|
||||
adb -s <frame-ip>:5555 shell mkdir -p /home/steamos/Documents/RingfallMjolnirVR/maps
|
||||
adb -s <frame-ip>:5555 push assets/maps/. /home/steamos/Documents/RingfallMjolnirVR/maps/
|
||||
adb -s <frame-ip>:5555 shell chmod -R 777 /home/steamos/Documents/RingfallMjolnirVR
|
||||
|
||||
After a Lepton restart only the APK is installed again. (Use the path under
|
||||
/home, not /sdcard/Documents: Android 11's scoped storage stands between the
|
||||
app and the latter.)
|
||||
|
||||
## The controllers
|
||||
|
||||
SteamVR offers the Frame's controllers as themselves
|
||||
(`XR_VALVE_frame_controller_interaction`,
|
||||
`/interaction_profiles/valve/frame_controller_valve`; Valve's "Steam Frame
|
||||
Input" page). Without bindings for it, SteamVR maps the Quest's onto them,
|
||||
and the left Touch controller's X and Y land on the D-pad. With them the
|
||||
game gets the Xbox's layout, as the right controller has it: A jump, B
|
||||
flashlight (held: switch grenades), X action and reload, Y switch weapon,
|
||||
menu pause; the left one's View is Back (scores), its D-pad the D-pad, the
|
||||
bumpers switch grenades (left) and the flashlight (right). The VR options'
|
||||
page of buttons shows this layout on the Frame.
|
||||
|
||||
## Findings
|
||||
|
||||
- 2026-10-02: runs flat and in VR (GLES 3.2 by Mesa zink on Turnip, eyes
|
||||
1728x1728, 72 Hz, XR_FB_display_refresh_rate absent). Quad layers
|
||||
(menus, HUD, instructions) are not shown; the projection layer is. Froze
|
||||
at the cryo bay's look calibration; its log was lost to Lepton's wipe.
|
||||
- 2026-10-04: SteamVR draws a quad's texels by their alpha alone; the
|
||||
game's menus and HUD have none in their additive parts, so nothing showed.
|
||||
On SteamVR (by the runtime's name) the overlays' alpha now comes from their
|
||||
colour (host_xr.c; `HALO_XR_QUAD_ALPHA=colour|keep` overrides). With it,
|
||||
menus, HUD and the campaign ran well (the user: "lief 1a"); no freeze.
|
||||
- 2026-10-04: no online games found: the public MQTT brokers had banned the
|
||||
home connection for a while (too many connections from tests that day);
|
||||
broker.emqx.io came back within minutes. Lepton's network is the Frame's
|
||||
own (same IP), DNS works.
|
||||
- 2026-10-04: the refresh rate is SteamOS's setting; the runtime offers
|
||||
only that one (the game asks for the highest at or below
|
||||
`vr.refresh_rate`, and logs the rates offered). At 72 Hz the game holds
|
||||
72 fps (about 11.6 ms a frame with multiview, eyes 7.6 ms; without it
|
||||
eyes about 9 ms). At 90 Hz it cannot (11.1 ms a frame), and SteamVR's
|
||||
making up of the missed frames showed as a doubled picture when turning
|
||||
the head. Keep the Frame at 72 Hz, or lower `vr.resolution_scale` (about
|
||||
0.85) for 90.
|
||||
- 2026-10-05: doubled pictures when turning at 72 Hz too, the game at the
|
||||
edge of its frame (12.5 of 13.9 ms; SteamVR reprojecting 2-8% of the
|
||||
frames). The time was not the drawing's but waits: the layer copies read
|
||||
the GL state back (glGet*) and released each image at once, and with
|
||||
Mesa's GL thread (zink) every read waits for the thread to run all that
|
||||
is queued, every release for the GPU (the left eye's copy took 4.5-7 ms
|
||||
of the frame, the right one's, just after it, 0.7). On SteamVR the copies
|
||||
are now deferred (host_xr.c): no state read back (the game sets its own
|
||||
again), the images released together as the frame ends, and the eyes'
|
||||
work flushed to the GPU as soon as they are copied.
|
||||
`debug.xr_deferred_copies` = 0 brings back the old copies for comparing,
|
||||
1 defers them on any runtime; `vr.log_performance` logs the frame's parts
|
||||
and, with the compositor's counters, each copy's time.
|
||||
@@ -1,600 +0,0 @@
|
||||
# VR roadmap
|
||||
|
||||
What Mjolnir VR (Quest 3, Steam Frame) has, and what comes next, in the
|
||||
agreed order. Updated with every step: a step is **done** once the user has
|
||||
tried it in the headset and it is merged into `main`; **built** means in a
|
||||
branch, not yet tried in the headset.
|
||||
|
||||
Several of the next steps follow
|
||||
[HaloCE-Quest-VR](https://github.com/moistman42069/HaloCE-Quest-VR) and the
|
||||
Steam Frame work it grew from,
|
||||
[astromaddie/HaloCE-VR](https://github.com/astromaddie/HaloCE-VR) (both
|
||||
CC0): their ideas, rebuilt into this port's own structure, with the source
|
||||
named where code is taken over.
|
||||
|
||||
## Done (in `main`)
|
||||
|
||||
| Area | What |
|
||||
| --- | --- |
|
||||
| Headsets | Quest 3; Steam Frame (Lepton): its controllers' layout, a Steam library tile that installs, starts, updates and quits the game, data kept in `~/Documents/RingfallMjolnirVR` |
|
||||
| Rendering | The eyes drawn one by one (both at once, multiview, only with `debug.multiview`: its eyes did not always fuse, see the open points); lens flares at their depth in stereo; HUD, menus, scope, crosshair and names as layers of their own |
|
||||
| Aiming | The weapon in the hand, its shots from the muzzle, laser and crosshair options; each weapon held so that its model's hand lands on the real one, as the free hand's (it learns where each weapon's animations hold the hand; the pistol's had been 15 cm before the real hand, the assault rifle's 8 cm aside), the scope's disc moved with it; `vr.weapon_hand_*` to adjust (2026-10-17) |
|
||||
| Body | Physical crouch (`vr.crouch_limit`) beside the crouch button, leaning (`vr.lean_limit`), melee by swinging, grenades thrown with the left hand, two-handed weapons |
|
||||
| Vehicles | The Warthog's wheel turned with the hands, right trigger throttle, left brake; first-person seats; turrets with handles |
|
||||
| Scores | The menu button held shows the scores on the Quest (a press pauses, as it is let go); the Steam Frame's View button as before; the text chat's lines where the desktop has them (2026-10-18) |
|
||||
| Comfort | Snap or smooth turning, a comfort vignette in vehicles, VR options in the main and pause menus (Y), a page of every controller button |
|
||||
| Menus | The PC version's menus in VR (`vr.menus`), clicked with a laser; text typed on the on-screen keyboard |
|
||||
| Multiplayer | Up to date with OpenCE (network version 32, 2026-10-20; HDR kept off in VR): cross-play, its server browser, co-op campaign, password lobbies; join codes and the VR online list |
|
||||
| Bots | Bots in multiplayer (`host_bots.c`; OpenCE's own, `bots.c`, are local split screen games' and off in VR): on foot (paths, items, objectives), in vehicles and at turrets; they make room for a joining person, on the LAN too (2026-10-18); they climb ladders (Damnation's) and take paths as near their goal as a search reaches, as OpenCE's do: on Damnation 0 searches of 1747 failed, 1078 of 1605 before (2026-10-20). Later: OpenCE's bots' aiming (lead, bursts, taps for the pistol and sniper rifle, field of view), learnt obstacles and map fixes into ours |
|
||||
| Voice chat | Push to talk on any button (`vr.button_talk`, BUTTONS page; the free hand's grip by default, sending nothing while it reaches for the foregrip or the wheel), open mic, off (2026-10-13) |
|
||||
| Builds | The Android build's assembly conversion (`tools/android_asm_convert.py`) keeps string data as it is: strings and tables starting with "_" or holding \" lost a "_" (Opus's pulse cache among them: the Steam Frame's crashes in online games while talking), 2026-10-13 |
|
||||
| Languages | The European disc in Spanish and Italian (a maps folder for each, `maps_es` and `maps_it`, none called `maps`) imported on the Quest and the Steam Frame: the headset's language's, its language the game's and the menus' (`maps/language.txt`, unless `game.language` is set), 2026-10-17; not yet tried with that disc |
|
||||
| Controls | Left-handed mode (`vr.handedness`): the weapon in the left hand, the arms and grips mirrored, sticks and buttons mirrored on both controllers (`vr.mirror_controls`), the assault rifle's counter read the right way round (2026-10-06) |
|
||||
| Graphics | Presets low / medium / high / max (`vr.graphics`), refresh rate and resolution in the VR options, all kept over a restart (2026-10-06) |
|
||||
| Arms and hands | Both arms by IK from shoulders that follow the torso, the elbow led by the hand's roll; fingers from trigger, grip and touch; `vr.body` arms / hands / off, `vr.fingers` (2026-10-06) |
|
||||
|
||||
## Next, in order
|
||||
|
||||
| # | Step | State |
|
||||
| --- | --- | --- |
|
||||
| 1 | Steam Frame CPU time: Mesa's trace markers off (after astromaddie/HaloCE-VR), no `glGet` stalls in the visibility counters' copies | **done** (in `main` 2026-10-06): markers quieted, no problems; the frame's work about unchanged (11-12.5 ms of 13.9 in a bot game) |
|
||||
| 3a | Visible arms and hands: the arms by IK to the controllers, fingers by trigger and grip | **done** (in `main` 2026-10-06; Quest 3 and Steam Frame good; 0.02 ms a frame) |
|
||||
| 2 | Controls and comfort: left-handed mode, buttons remapped, flashlight by tapping the head, finer turning and vignette choices, graphics presets and refresh rate in the VR options | first part **done** (in `main` 2026-10-06; Quest 3 and Steam Frame good): left-handed mode, graphics presets, refresh rate and resolution in the VR options. Second part **done** (in `main` 2026-10-06; Quest 3 good): buttons remapped, finer turning and vignette choices; the flashlight by tapping the head taken out (did not work) |
|
||||
| 3b | The whole body: torso from head and hands, legs and feet following in the room; full / arms only / hands only | **done** (in `main` 2026-10-10; Quest 3 good): `vr.body` "full" ("Full body" in the VR options; "arms" still the default), legs walking the way the player moves, feet on the ground. Also in: voice chat's push to talk on the free hand's grip. Steam Frame: its cost still to measure |
|
||||
| 3c | Weapons held physically, holsters at shoulder and hip (the buttons stay) | |
|
||||
| 3d | Other VR players shown with their heads, hands and bodies (today their bodies move as flat players' do: only their aim and throws come from their hands) | |
|
||||
| 4 | Later: disc image import in the launcher; moving by swinging the arms (in place of the stick, never faster than it: online too), and a sprint by swinging them harder (faster than the game allows: offline only) | import **done** (in `main` 2026-10-06): the app's import (tried on the Quest 3: all 24 maps; on the Frame kept in `~/Documents/RingfallMjolnirVR`), a Steam Frame installer from Desktop Mode (`STEAM_FRAME.md`; tried on the Frame: the old folder renamed, the shortcut added by Steam), a release signing key (CI and local builds the same). Arm swinging and its offline sprint still open |
|
||||
| 5 | Later: multiview again (both eyes in one pass, half the drawing's CPU cost): find why its eyes do not fuse in big online games on the Quest 3 (and now and then on the Steam Frame), then turn it back on | open: off by default since 2026-10-16 (`debug.multiview`); findings in the open points |
|
||||
| R | Release as **Ringfall: Mjolnir VR** (no "Halo" in the product's name): app name, id `io.github.cesarus85.ringfall`, icon and library pictures (`tools/ringfall_art.py`), Frame folder and installer, release assets, README; the repository renamed | **done** (in `main` 2026-10-06; Quest 3 and Steam Frame good) |
|
||||
| R2 | Renamed **Mjolnir VR** ("Ringfall" is another game's name): app and Steam names, logo (`tools/mjolnir_art.py`), release assets (also under the old names for the updaters of builds 302 to 313), updaters, README; the repository renamed `Cesarus85/mjolnir-vr` (GitHub forwards the old links). Kept: the app id, the signing key's alias, the Frame's `~/Documents/RingfallMjolnirVR` and the names inside its bundle (installed games and their shortcuts) | in `feature/rename-mjolnir-vr` (2026-10-21) |
|
||||
|
||||
## Step 2, first part (done)
|
||||
|
||||
Left-handed mode and graphics presets, after HaloCE-Quest-VR (CC0): its
|
||||
mirrored first-person model, its graphics switches.
|
||||
|
||||
Left-handed (`vr.handedness = "left"`):
|
||||
- The weapon in the left hand: aim, shots, muzzle, laser, crosshair,
|
||||
scope disc, turret aim. The first-person model is posed as the right
|
||||
hand's in a mirror image of the room ("model space", `halo_vr.h`) and
|
||||
mirrored back; a model whose node matrices mirror has its triangles'
|
||||
winding turned over (`rasterizer_set_model_skinning`, `d3d8_gl.c`). The
|
||||
arms reach to the other shoulders, the foregrip is gripped with the
|
||||
right hand, the right hand's fingers follow its controller.
|
||||
- Grenades held and thrown with the right trigger and hand; melee by the
|
||||
left grip (a swing of either hand, as before); the motion tracker on the
|
||||
right wrist (`halo_xr_submit.wrist_hand`); the rumble's light motor in
|
||||
the weapon hand.
|
||||
- The left trigger fires, the right one throws; at the Warthog's wheel the
|
||||
left trigger accelerates, the right one brakes.
|
||||
- With `vr.mirror_controls` (default): the right stick moves, the left
|
||||
turns and steers; their clicks, the bumpers and the face buttons change
|
||||
sides (Quest: X jumps, Y light / held grenades, A action and reload, B
|
||||
switch weapon; Steam Frame: the left D-pad does A, B, X, Y as their
|
||||
mirror image, down jump, left light, right action, up switch weapon,
|
||||
and A, B, X, Y do the D-pad's). The menus keep their buttons; the
|
||||
laser pointer works from either hand as before.
|
||||
- Other machines see the shots leave the left hand (the network message
|
||||
is unchanged: aim and muzzle from the camera).
|
||||
- The assault rifle's ammo counter and compass read the right way round
|
||||
on the mirrored model (2026-10-06): their geometry stays mirrored, each
|
||||
digit's bitmap is drawn turned over in u and the digits' order across
|
||||
the display swapped (numeric shaders drawn mirrored,
|
||||
`rasterizer_xbox_transparent_geometry.c`). Checked flat in the emulator
|
||||
with `debug.mirror_first_person` (the first-person weapon mirrored off
|
||||
the headset): 60, 48, 36 ... 06 read correctly. Steam Frame good
|
||||
(2026-10-06).
|
||||
- Kept as they are (accepted 2026-10-06): the small static icons under the
|
||||
counter (round and "x") stay mirror images (a texture atlas, not
|
||||
numeric). The game's prompts still name the Xbox's buttons.
|
||||
- Settings kept: on Android `config.toml` is written beside itself and
|
||||
renamed over (`port_config.c`), so one pushed by adb (the shell's, which
|
||||
the app could not open for writing) no longer loses the VR options'
|
||||
changes at a restart.
|
||||
- Headset tests 2026-10-06: Quest 3 and Steam Frame good (left hand,
|
||||
controls mirrored and not, counter, presets, refresh rates, resolution,
|
||||
settings kept over a restart).
|
||||
|
||||
Graphics (`vr.graphics`, `port/linux/game/vr_graphics.c`), set each frame
|
||||
on the game's own switches:
|
||||
|
||||
| Preset | Leaves out |
|
||||
| --- | --- |
|
||||
| `"high"` (default) | nothing: as before |
|
||||
| `"medium"` | object shadows, environment reflections, lens flares |
|
||||
| `"low"` | also specular light, bump maps, grass and other detail objects, the screen's fog layer, contrails, weather, camouflage's second pass |
|
||||
| `"max"` | nothing; models lit for each pixel, shadows at 512x512 |
|
||||
|
||||
A client in another's game keeps grass, lens flares and the fog layer as
|
||||
the host's rules have them (`cheats.c`). Shadows, specular passes,
|
||||
reflections and detail objects are draws (CPU, which the Frame's GL
|
||||
driver is short of); bump maps, fog, camouflage and per-pixel lighting
|
||||
the GPU's fill.
|
||||
|
||||
VR options (Y): two pages, PLAY (the comfort rows, "Weapon hand",
|
||||
"Mirrored controls") and MORE ("Graphics", "Refresh rate", "Resolution",
|
||||
the controller buttons page, Quit); four since the second part (below). The refresh rate steps through what
|
||||
the runtime offers and changes at once; on the Steam Frame the row shows
|
||||
SteamOS's rate. The resolution (`vr.resolution_scale`, 70-120%) takes a
|
||||
restart. The controller buttons page shows the layout as set.
|
||||
|
||||
| Setting | Values |
|
||||
| --- | --- |
|
||||
| `vr.handedness` | `"right"` (default), `"left"` |
|
||||
| `vr.mirror_controls` | `true` (default): sticks and buttons mirrored when left-handed; `false`: as right-handed (triggers and grips still follow the hands) |
|
||||
| `vr.graphics` | `"auto"` (default, branch `fix/vr-frame-hitches`), `"low"`, `"medium"`, `"high"`, `"max"` |
|
||||
| `vr.foveation` | `"off"` (default), `"low"`, `"medium"` (the Quest only; branch `fix/vr-frame-hitches`) |
|
||||
| `vr.refresh_rate` | Hz, as offered (Quest 3: 72, 80, 90, 120) |
|
||||
| `vr.resolution_scale` | 0.7 to 1.2, on restart |
|
||||
|
||||
To try in the headset (Quest 3 and Steam Frame):
|
||||
1. Left-handed: aim, laser, crosshair, scope of sniper and rocket
|
||||
launcher; weapon held right in the left hand, arms from the right
|
||||
shoulders, nothing inside out (faces culled the wrong way would show
|
||||
the inside of the gun or the glove).
|
||||
2. Two-handed grip with the right hand; grenades in the right hand (held
|
||||
and thrown); melee by grip and by swing; motion tracker on the right
|
||||
wrist.
|
||||
3. Buttons and sticks mirrored on the Touch and the Frame controllers
|
||||
(every function reachable), then `Mirrored controls: Off`.
|
||||
4. Vehicles: wheel, throttle and brake, steering stick, a gunner's aim;
|
||||
menus and the laser pointer; a network game (shots from the left hand
|
||||
on the other machine).
|
||||
5. Graphics: each preset's look and smoothness (`vr.log_performance`),
|
||||
in a bot game; Max on the Quest at 90 Hz; refresh rates 72/80/90/120
|
||||
on the Quest; the Frame's row.
|
||||
|
||||
## Step 2, second part (done)
|
||||
|
||||
In `main` 2026-10-06; tried on the Quest 3 (with the rename): good. The flashlight by tapping the head (after HaloCE-Quest-VR)
|
||||
did not work in the headset and was taken out again; the button stays.
|
||||
The VR
|
||||
options (Y) have four pages: PLAY ("Weapon hand", "Mirrored controls",
|
||||
laser, crosshair, motion tracker, body, fingers, the Warthog's wheel),
|
||||
COMFORT (turning, the vignettes), BUTTONS (the actions' buttons,
|
||||
"Reset buttons to defaults", the controller buttons page) and MORE (graphics, refresh rate, resolution, Quit).
|
||||
|
||||
Buttons remapped (BUTTONS page; `vr.c` `controls_remapped`):
|
||||
- Jump, the flashlight (held: switch grenades), action/reload, switch
|
||||
weapon, crouch, zoom, melee and push to talk each go on one of eight
|
||||
buttons: A, B, X, Y, the move stick's click, the turning stick's, the
|
||||
weapon hand's grip, the free hand's grip. Moving an action to a button
|
||||
swaps it with the action there, so none is ever left without one.
|
||||
- The free hand's grip as a button (`free_grip_down`): pressed once held
|
||||
0.15 s at the foregrip's threshold, and not at all while it holds the
|
||||
weapon's foregrip or the Warthog's wheel (taken in that time, the press
|
||||
is theirs until the grip opens).
|
||||
- The triggers, the menu button, the Steam Frame's
|
||||
bumpers, D-pad and View button keep theirs; the menus keep the buttons
|
||||
as they are.
|
||||
- Applied after the left-handed mirroring, on the gamepad's sides: the
|
||||
same on the Touch and the Frame controllers, and a left-handed player's
|
||||
buttons are the mirror image of the right-handed ones (on the Frame,
|
||||
mirrored, the left D-pad's). The defaults are the old layout, the
|
||||
host's bindings and the ABI unchanged.
|
||||
- The melee's aim and jab follow its button; the grips on a Warthog's
|
||||
wheel press nothing, whatever the grip does.
|
||||
- The controller buttons page shows each action where its button is.
|
||||
|
||||
Comfort (COMFORT page): snap turns 10 to 45 degrees by 5, 60, 75, 90;
|
||||
smooth turning 30 to 150 degrees a second by 15, then to 300 by 30; the
|
||||
vehicle vignette Off, 15 to 100%; the on-foot vignette (off by default)
|
||||
while the stick turns smoothly, or also while the move stick moves, as
|
||||
far as the sticks are pushed, with its own strength. The old values are
|
||||
among the steps; defaults unchanged.
|
||||
|
||||
Transparent geometry: room for 2048 groups a window (the Xbox's 384,
|
||||
below).
|
||||
|
||||
| Setting | Values |
|
||||
| --- | --- |
|
||||
| `vr.button_jump` | `"a"` (default), `"b"`, `"x"`, `"y"`, `"move_stick"`, `"turn_stick"`, `"grip"`: as right-handed, mirrored with `vr.mirror_controls` |
|
||||
| `vr.button_light` | the flashlight, held switch grenades; `"b"` (default) |
|
||||
| `vr.button_action` | action, reload; `"x"` (default) |
|
||||
| `vr.button_weapon` | switch weapon; `"y"` (default) |
|
||||
| `vr.button_crouch` | `"move_stick"` (default) |
|
||||
| `vr.button_zoom` | `"turn_stick"` (default) |
|
||||
| `vr.button_melee` | `"grip"` (default) |
|
||||
| `vr.foot_vignette` | `"off"` (default), `"turning"` (smooth turns), `"moving"` (and moving) |
|
||||
| `vr.foot_vignette_strength` | 0.15 to 1, `0.7` (default) |
|
||||
| `debug.vr_options` | `false` (default); `true` shows the VR options off the headset (the emulator) |
|
||||
|
||||
Checked in the emulator (`debug.vr_options`): the four pages without
|
||||
overlaps, each row's values, swaps and reset, the controller buttons page
|
||||
right- and left-handed after swaps, the settings kept over a restart, a
|
||||
15-bot game as before.
|
||||
|
||||
To try in the headset (Quest 3 and Steam Frame):
|
||||
1. Defaults: every button as before (jump, light/held grenades, action,
|
||||
switch weapon, crouch, zoom, melee by grip and by swing), right- and
|
||||
left-handed, mirrored and not; the menus' A and B.
|
||||
2. BUTTONS: swap jump and melee (jump on the grip, melee on A): both work,
|
||||
the melee jabs and aims where the head looks; light on a stick click
|
||||
(tap: light, hold: grenades); the controller buttons page says so.
|
||||
At the Warthog's wheel with jump on the grip: no jump while holding
|
||||
the wheel. Reset: all back.
|
||||
3. The same left-handed with mirrored controls (on the Frame the left
|
||||
D-pad), and with `Mirrored controls: Off`.
|
||||
4. COMFORT: snap 10 and 90, smooth 30 and 300; vehicle vignette 15% and
|
||||
100%; on-foot vignette "Smooth turns" (nothing with snap turns),
|
||||
"Moving, turning", strength 15% and 100%; no vignette in a vehicle
|
||||
from the on-foot one, none in the menus.
|
||||
5. A game of 30 and more players: effects, glass and water stay; the log
|
||||
(`adb logcat -s halo`) says `rasterizer: N transparent geometry groups
|
||||
in a window` once a window passes 384; frame time as before.
|
||||
|
||||
## Step 3a (done)
|
||||
|
||||
Tried on the Quest 3 and the Steam Frame, in `main`. The arm IK,
|
||||
the forearm's twist and the fingers' poses follow HaloCE-Quest-VR (CC0),
|
||||
in `port/linux/game/vr_arms.c`.
|
||||
|
||||
- The first-person pose (weapon, arms) is built once a frame instead of
|
||||
per eye and scope view (SteamVR: two to three times before).
|
||||
- `vr.log_performance` reports its cost (`VR: first person: ... ms a
|
||||
frame in ... builds (arms ... ms), ... kept`) and, once, how the hands'
|
||||
skin hangs from its bones (none from the root: no triangle filter
|
||||
needed).
|
||||
- Both arms bend from shoulders below the neck, square to the torso. The
|
||||
torso follows the head beyond 15 degrees and turns towards the hands;
|
||||
snap and smooth turns carry it at once.
|
||||
- The free left arm bends at the elbow to the controller (before: carried
|
||||
rigidly). The hand's roll is shared along forearm and upper arm.
|
||||
- The free hand's fingers follow the controller: index from the trigger,
|
||||
the others from the grip, the thumb from where it rests (touch on the
|
||||
Quest's, Index and Steam Frame controllers; half curled where unknown),
|
||||
closed round a held grenade. The weapon hand keeps its grip; its index
|
||||
finger lifts off the trigger when the controller says it is off.
|
||||
- host_xr: touch actions for thumb and index; `suggest()` takes 64
|
||||
bindings (was 32, silently cut) and retries a profile without the
|
||||
touch paths should the runtime refuse them.
|
||||
|
||||
Settings (`[vr]` in config.toml; the first two also in the VR options,
|
||||
Y on the main or pause menu):
|
||||
|
||||
| Setting | Values |
|
||||
| --- | --- |
|
||||
| `vr.body` | `"arms"` (default), `"hands"` (hands alone, the arms shrunk behind the wrists), `"off"` (the weapon alone) |
|
||||
| `vr.fingers` | `true` (default): fingers follow the controller; `false`: as the weapon's animation has them |
|
||||
| `vr.arm_ik` | `true` (default): the free arm bends at the elbow; `false`: rigid as before, should its skin tear |
|
||||
|
||||
After the first Quest tries (2026-10-06):
|
||||
- The shoulders 13 cm behind the eyes and 20 cm below the neck: the open
|
||||
end of the sleeve was in view. Looking hard down to the side one still
|
||||
sees into the arm (the model ends at the shoulder): left as it is.
|
||||
- The elbow bends in the arm's plane (`vr_align_elbow`): it had turned in
|
||||
with the elbow out to the side; the upper arm takes none of the hand's
|
||||
roll.
|
||||
- The free arm is solved first and its hand turned after (as
|
||||
HaloCE-Quest-VR does): turned first, its skin stretched like a rubber
|
||||
band.
|
||||
- The elbow follows the hand's roll (lifted out, the controller rolls in):
|
||||
before, it bent only towards a fixed direction.
|
||||
- Arm length, shoulder width, fingers, grenade grip, body modes, scope,
|
||||
vehicles: fine.
|
||||
|
||||
Not in it (3a.7): the glove fitted to each weapon's grip (gun anchor) and
|
||||
the left hand animated through reloads.
|
||||
|
||||
## Step 3b (done)
|
||||
|
||||
On `feature/vr-voice-and-body`, not yet tried in the headset. The neck
|
||||
pivot, the planted feet with their steps and the leg's clamped reach follow
|
||||
HaloCE-Quest-VR (CC0), its full body, rebuilt in
|
||||
`port/linux/game/vr_body.c` on this port's skeleton (`vr_arms.c`).
|
||||
|
||||
- `vr.body = "full"` (VR options, Body: "Full body") draws the player's own
|
||||
biped under the first-person arms and weapon: its torso, hips and legs, in
|
||||
the map's own model and colours. "arms" stays the default until the
|
||||
headsets have tried it.
|
||||
- Drawn among the world's objects, so it sorts against the world by depth;
|
||||
the first-person weapon and arms, drawn before the world into the
|
||||
stencil, stay over it, as before. In both eyes (multiview on the Quest,
|
||||
each eye on SteamVR), posed once a frame for every eye and the scope.
|
||||
- The torso: the torso's heading (the head's beyond 15 degrees, drawn
|
||||
towards the hands, the stick's turns at once), upright from the hips to a
|
||||
neck 14 cm behind and 20 cm below the eyes as the head turns about it
|
||||
(looking down, the eyes go forward and the chest stays behind them). The
|
||||
aiming's twist and bend of the third-person torso are taken out.
|
||||
- The hips: down with the physical crouch (and back a little, the torso
|
||||
leaning forward), a third of the way with a lean (the spine tilts the
|
||||
rest). The body's model has its neck higher than the eyes' pivot: it is
|
||||
moved down to it, so the shoulders stay below the eyes, crouched by the
|
||||
button too.
|
||||
- The legs: the game's own animation (walking, running, jumping, crouched
|
||||
by the button). Moving, the hips and legs stay as the game faces them, so
|
||||
its own choice of animation (forward, back, aside, as for any player,
|
||||
by the way it moves against the way it faces) runs along the way the
|
||||
player moves, and the spine turns the torso; standing, the hips turn to
|
||||
the torso's heading (eased, 0.12 s). Walking off, the feet ease from
|
||||
where they stood into the walk (0.2 s); stopping, they stay where the
|
||||
walk left them and step into place. Standing still, the feet stay
|
||||
planted and step, one at a time (0.22 s, 6 cm lifted), when the body has
|
||||
turned 35 degrees from them or their place moved 18 cm; the knees bend by
|
||||
IK to them as the hips go down. Moved 80 cm at once (a teleporter), they
|
||||
are put down there.
|
||||
- The ground: put down, each foot rests on the ground under it (a slope, a
|
||||
stair), its height above the ground as the animation has it, tilted with
|
||||
the slope (no steeper than 45 degrees), up to 45 cm from the ground under
|
||||
the body; a foot's ground below it lowers the hips as far. Rays straight
|
||||
down, read only, cast only as the feet are put down (three: under the
|
||||
body and each foot) and as one steps (one), none while walking, where
|
||||
the animation's feet are kept; eased (0.08 s) in and out. Nothing found
|
||||
(a ledge): level.
|
||||
- Hidden: the head and neck (shrunk onto the neck's root: no head or
|
||||
collar seen from inside), the third-person arms (shrunk onto their
|
||||
shoulders), the third-person weapon and all the biped carries.
|
||||
- The first-person arms hang from the body's shoulders: beside its neck,
|
||||
as wide as its shoulder joints within 14 to 24 cm (the aiming's shrug
|
||||
left out). Left-handed, the shoulders go into the mirror with the arms
|
||||
(the room's left one is the model's right): the body itself is the
|
||||
room's, not mirrored.
|
||||
- Seats: a passenger in an open vehicle (the Warthog's back) sits as the
|
||||
seat's animation has it, the head and arms shrunk alike; at a wheel or a
|
||||
gun the body is drawn whole as before (its hands on them, no
|
||||
first-person weapon); in a closed seat (Ghost, Banshee, tank) none.
|
||||
- Not drawn when dead, in cutscenes, in third person, in a mirror's view;
|
||||
camouflage as the game has it.
|
||||
- Only drawn, on this machine: the game's own pose, hit boxes, markers and
|
||||
network messages are unchanged.
|
||||
- Cost: `vr.log_performance` adds `body ... ms a frame in ... poses` to the
|
||||
`first person:` line. In the emulator 0.006 to 0.025 ms a pose standing
|
||||
(as busy as the emulator was), up to 0.1 ms averaged while turning with
|
||||
the feet's rays (at most a few a second); the drawing is one more biped
|
||||
model (as one more player close by).
|
||||
|
||||
| Setting | Values |
|
||||
| --- | --- |
|
||||
| `vr.body` | `"full"` (the whole body), `"arms"` (default), `"hands"`, `"off"` |
|
||||
| `debug.vr_body` | `"off"` (default); off the headset (the emulator) the body posed from the flat camera: `"eye"`, `"down"` (looking down 60 degrees, 90 degrees wide), `"front"`, `"side"`, `"back"` (the camera 2.6 m away); after a colon the head's motion: `"cycle"` (turning, crouching, leaning, 5 s each), `"still"`, `"turn"`, `"crouch"`, `"lean"`, `"raw"` (the game's pose, only shrunk). Logs its pose once a second |
|
||||
|
||||
Checked in the emulator (`debug.vr_body`): the cyborg's 19 nodes (bip01
|
||||
pelvis, spine, spine1, neck, head, clavicles, arms, thighs, calves, feet);
|
||||
the body standing, crouched physically and by the button, leaning,
|
||||
turning with the feet stepping; looking down, the shoulders below the eyes
|
||||
and no head or collar; two-minute bot games on Blood Gulch with it on and
|
||||
off, deaths and respawns, nothing in the log. Then the legs by the way of
|
||||
moving (strafing, backwards, diagonally with the touch stick: the game's
|
||||
sideways and backwards walk) and the feet on the ground: on the ramp of a
|
||||
Blood Gulch base, the upper foot 15 cm up, the lower 10 cm down, both on
|
||||
it; stairs not reached in the emulator (Prisoner's spawn was level). Three
|
||||
rays when the feet are put down, one a step, none walking. Screenshots in
|
||||
`build/body-shots/` (local).
|
||||
|
||||
Push to talk is built on the same branch: voice chat's talking on the free
|
||||
hand's grip, while it holds neither the weapon's foregrip nor the Warthog's
|
||||
wheel (`audio.voice_chat`, VR options PLAY page "Voice chat": push to talk
|
||||
(grip), open mic, off).
|
||||
|
||||
To try in the headset (Quest 3 and Steam Frame), with `vr.body = "full"`
|
||||
(VR options, Body: Full body) and `vr.log_performance = true`:
|
||||
1. Standing, looking down: torso, hips, legs and feet, the shoulders below
|
||||
the eyes, no head, collar or helmet in view, the chest not in the way;
|
||||
the arms from the shoulders, lined up with the body, the weapon as
|
||||
before.
|
||||
2. Turning the head alone: the body stays within about 15 degrees, then
|
||||
follows; turning further, the feet step after it, one at a time, and
|
||||
settle. Snap and smooth turns: the body turns, the feet step.
|
||||
3. Physical crouch: the knees bend, the feet stay; kneeling deep, nothing
|
||||
of the body in the eyes. Leaning forward and aside: the torso tilts, the
|
||||
feet stay. Crouch button: the game's crouch, shoulders below the eyes.
|
||||
4. Walking, running, jumping by the stick: the legs walk with the game's
|
||||
animation, no sliding when starting or stopping. Strafing left and
|
||||
right, walking backwards and diagonally, also with the head turned away
|
||||
from the way of walking: the legs step the way the body moves (sideways,
|
||||
backwards), the torso facing as the head and hands have it; stopping,
|
||||
the hips turn back under the torso and the feet step into place.
|
||||
4a. Ground: standing still on a slope (Blood Gulch's hills and the bases'
|
||||
ramps), across it and along it: both feet on the ground, tilted with
|
||||
it, the lower knee straighter, the hips down with the lower foot; on
|
||||
stairs (Prisoner, Chill Out, Damnation), one foot a step higher than
|
||||
the other, turning in place there: each step lands on its stair. At a
|
||||
ledge, one foot over it: level, nothing odd.
|
||||
5. Left-handed (`vr.handedness = left`, mirrored or not): the arms from
|
||||
the body's shoulders, the weapon in the left hand, the body as
|
||||
right-handed.
|
||||
6. Vehicles: Warthog driver and gunner as before (body with its hands on
|
||||
the wheel or gun); Warthog passenger: seated legs and torso, the
|
||||
first-person arms from its shoulders; Ghost, Banshee, Scorpion: no body.
|
||||
7. Dying and respawning, a teleporter, a cutscene (campaign), the menus
|
||||
and pause menu, the scope, camouflage, a game with 15 bots: nothing
|
||||
broken, no body where it should not be.
|
||||
8. Body "Arms and hands", "Hands only", "Weapon only": as before.
|
||||
9. Performance: `first person: ... body ... ms` in `adb logcat -s halo`;
|
||||
the Quest holds 90 Hz in a bot game; the Steam Frame's working time
|
||||
against "arms" (about 12 ms of 13.9 before).
|
||||
10. Push to talk (Voice chat: push to talk), in a network game with
|
||||
another player: holding the free grip away from the weapon talks;
|
||||
nothing while the free hand holds the foregrip or the Warthog's wheel;
|
||||
"Open mic" talks without the grip; "Off" sends nothing (others still
|
||||
heard).
|
||||
|
||||
## Frame hitches and GPU time (built: branch `fix/vr-frame-hitches`)
|
||||
|
||||
Measured on the Quest 3 (2026-10-12; 90 Hz, multiview, graphics "high",
|
||||
full body, a 15-bot game on Blood Gulch): the game's CPU work 5-6 ms a
|
||||
frame; the app's GPU time 5.5-6.4 ms (`xr: metrics`), the same with
|
||||
foveation off, low, medium and high: **the GPU is not the bottleneck**.
|
||||
The doubled pictures come from single long frames: shader programs compiled
|
||||
in a frame (29 new ones in a 794 ms frame 22 s into a match, single ones
|
||||
18-64 ms), draws of 254 ms (the first frame in a map) and 74 ms with
|
||||
nothing compiled (most likely the driver making a program's variants at
|
||||
its first draw), and the menus' PNG pictures (7 in 108 ms).
|
||||
|
||||
What the branch has:
|
||||
|
||||
| Part | What |
|
||||
| --- | --- |
|
||||
| Long frames | `VR: long frame N ms: input, ticks, camera, draw, present; shaders compiled or linked, programs from the cache; textures uploaded, menu pictures, render targets; draw calls N ms, the slowest N ms (vertex program, program key); N draws left out waiting for their programs`. The 5 s report counts the draws left out |
|
||||
| GPU time | XR_META_performance_metrics on with `vr.log_performance`: `xr: metrics (mean/most) app/gpu_frametime=... compositor/dropped_frame_count=...` |
|
||||
| Foveation | `vr.foveation` "off" (default) / "low" / "medium" on the MORE page (GL_QCOM_texture_foveated, the eyes only, lens centres); "high" taken out (it drew a grey rectangle below the player). Kept for later, no gain measured |
|
||||
| Shader cache | `display.shader_cache`: programs kept in `shader_cache/` (binary, driver, sources); each map's list (`maps/<map>.txt`) and every map's (`all.txt`) |
|
||||
| Worker | `display.shader_worker` (default true): programs made on a thread with a GL context sharing the game's (`gl worker: running`), from the cache's binary or compiled; a draw whose program is not made yet is left out for those frames, the frame never waits. As a map loads, its programs and then every map's are asked for |
|
||||
| Warm-up | `debug.shader_warm_up`: "worker" (default: each program drawn with once on the worker into a small target of the eyes' kinds), "load" (the map's programs drawn with on the game's thread as it loads), "off" |
|
||||
| Menus | The PC menus' pictures decoded on a thread of their own, drawn transparent for the frames that takes |
|
||||
|
||||
Second Quest test (latest build): the worker works, no long frame after the
|
||||
map's first frames (245 ms and 72 ms there, each one draw of 67-75 ms with
|
||||
vertex program 4). But doubled pictures in spells of seconds with the GPU
|
||||
at 9-13 ms a frame (GPU% 0.91-0.94, 4-37 stale frames a second), 5-7 ms in
|
||||
between: "high" is too much for 90 Hz in heavy scenes, "medium" holds.
|
||||
Hence:
|
||||
|
||||
| Part | What |
|
||||
| --- | --- |
|
||||
| Graphics "auto" | `vr.graphics = "auto"`, the new default (Graphics row: Auto): "high" while the GPU keeps up. Past 4/5 of the frame (8.9 ms at 90 Hz) for a quarter second it leaves out the next steps (shield glow, shadows, reflections, specular light, lens flares, bump maps, the rest of "low"), as many as their learnt costs say; brings one back once GPU time + its cost stays under 7/10 of the frame for 3 s (longer if it had to go again within 10 s). Logs `VR graphics auto: shadows left out (step 2): the GPU 10.2 ms a frame of 11.1`, `... saved 1.9 ms`, `... back`. On the Steam Frame (no GPU time from SteamVR) "auto" is "high" |
|
||||
| Measuring | `debug.vr_graphics_measure = true`: each effect left out in turn (1.5 s on, 1.5 s off), `VR graphics measure: shadows 2.10 ms (...)` and means each round |
|
||||
|
||||
What the effects cost, from the code (to be measured with the option above):
|
||||
object shadows are drawn once a frame with multiview (the scene is drawn
|
||||
once), twice one eye at a time; each shadow-casting object (every bot, its
|
||||
weapon, vehicles) renders its map, blurs it and projects it onto the level
|
||||
beneath: a pass of fill on both eyes per object. Reflections and specular
|
||||
light are passes over the level's geometry. The shield's glow
|
||||
(`display.shield_glow`, off by default) is a dynamic light per flaring unit
|
||||
(at most 8), each lighting the level's surfaces in its reach once more, not
|
||||
a pass per object; upstream's shield colour on the arms only changes a
|
||||
colour. The whole body adds the player's own model and its shadow.
|
||||
|
||||
Not done, and why:
|
||||
- Drawing the eyes straight into the swapchain: moot now (GPU not the
|
||||
bottleneck); it needs GL_EXT_sRGB_write_control, the vignette as a pass
|
||||
of its own and array swapchains acquired mid-frame.
|
||||
- Decoding all menu pictures ahead: 165 pictures, about 350 MB decoded with
|
||||
their mipmaps.
|
||||
- Later: XR_KHR_visibility_mask.
|
||||
|
||||
### Headset test, graphics "auto" (Quest 3)
|
||||
|
||||
1. VR options, MORE: Graphics **Auto** (a `config.toml` written before
|
||||
still says "high"), Foveation Off; `vr.log_performance = true`.
|
||||
2. Log at start: `xr: performance metrics on (... the app's GPU time read)`,
|
||||
`VR: graphics auto`.
|
||||
3. 15-bot match on Blood Gulch, a few minutes, also into the busy middle:
|
||||
- `VR graphics auto: ... left out (step N): the GPU X ms` within a
|
||||
quarter to half a second of a heavy spell, `... saved Y ms`, and
|
||||
`... back` a few seconds after it.
|
||||
- VrApi: `Stale=` 0 nearly every second (at most a few in the second a
|
||||
spell begins), no `ASW=1` spells; App GPU under about 9 ms.
|
||||
- Look for effects that pop: shadows going and coming back. If they
|
||||
change more than every ten seconds or so, note the log lines.
|
||||
4. Costs: a second match with `debug.vr_graphics_measure = true` (Graphics
|
||||
setting ignored meanwhile; stand somewhere busy, a few minutes):
|
||||
`VR graphics measure: means (ms of GPU a frame): shadows ...;
|
||||
reflections ...`. The steps' order should follow the largest costs.
|
||||
5. The first frames of a map (245/72 ms, vertex program 4): try
|
||||
`debug.shader_warm_up = "load"` once and compare those lines.
|
||||
|
||||
### Headset test, shader worker (Quest 3)
|
||||
|
||||
Before: `adb logcat -G 16M` (again after any reboot); in `config.toml`
|
||||
`vr.log_performance = true`, 90 Hz, graphics "high", multiview, full body;
|
||||
Foveation Off (VR options, MORE: the config may still say "medium"). After
|
||||
each test: `adb logcat -d -s halo VrApi > test.txt`. The shader cache from
|
||||
the earlier tests stays.
|
||||
|
||||
1. Start: `gl worker: running (ES 3, surfaceless, programs warmed up)` and
|
||||
`shader cache: ... N programs kept (... N listed) ...; programs made on
|
||||
the worker, warmed up there`. As the menus load: `shader cache:
|
||||
levels_ui_ui: N programs listed; N asked of the worker ...; N of other
|
||||
maps to ask for`.
|
||||
2. Bot match on Blood Gulch: as it loads, `... bloodgulch: N listed; ...
|
||||
N there already` (made while in the menus). In play no `VR: long frame`
|
||||
with shaders compiled; at most a few `draws left out` (objects appearing
|
||||
a frame or two late), and VrApi `Stale=0` most seconds, no `ASW=1`.
|
||||
Any long frame left: its `draw calls ... the slowest N ms (vertex program
|
||||
N, program K)` says whether a draw (a driver variant) is the cause.
|
||||
3. A map not played yet (Damnation): as it loads, `N programs listed` is 0
|
||||
but `N there already` should not matter: its programs mostly come from
|
||||
every map's list (made in the menus). New ones are compiled on the worker
|
||||
(`draws left out` for a moment, no long frame).
|
||||
4. If draws of 70-250 ms remain with nothing compiled: `debug.shader_warm_up
|
||||
= "load"` (the log: `shader cache: N programs drawn with once as the map
|
||||
loaded, in N ms`), then compare; and `"off"` for the baseline.
|
||||
5. Menus: open new screens; pictures may appear a frame late, no long
|
||||
frames with `menu pictures`.
|
||||
6. If anything breaks (missing objects for good, a crash):
|
||||
`display.shader_worker = false` brings the game's-thread compiling back.
|
||||
|
||||
Steam Frame: the worker also runs there if its EGL shares contexts (the log
|
||||
says `gl worker: running` or why not); no foveation. A short bot game to
|
||||
see that nothing is missing or slower.
|
||||
|
||||
## Open points outside the order
|
||||
|
||||
- Multiview's doubled pictures (2026-10-16): on the developer's Quest 3,
|
||||
doubled and shifted pictures from the start of big online games (26-35
|
||||
players) as the head turned, nauseating; none in a local game with 48
|
||||
bots; none online either with the eyes drawn one by one. Not the frame
|
||||
rate: one by one, online at 72 Hz, the compositor repeated as many
|
||||
frames (about 4 a second) and nothing was seen. Not the facing jumps
|
||||
(respawns only) nor the camera (it moves every frame). Before: the
|
||||
Steam Frame's (2026-10-05), each eye alone sharp. So the eyes are drawn
|
||||
one by one by default now (`debug.multiview` for both at once). To do:
|
||||
find what the shared pass draws wrongly online, e.g. by saving both
|
||||
eyes' pictures in a big online game and comparing what is doubled
|
||||
(sprites and effects projected by the game itself, `mv_depth`; programs
|
||||
made on the shader worker; the sky rows), then turn it back on: it
|
||||
halves the drawing's CPU cost.
|
||||
- Big online games (2026-10-16): doubled pictures on a 32-player server,
|
||||
none in a local game with 48 bots. Not the GPU (60–80 %): the ticks cost
|
||||
3.3–4.6 ms as a client there (1.3–1.9 ms with bots or 16 players), so
|
||||
47–70 of 150 frames with a tick missed 90 Hz's 11.1 ms (the doubling
|
||||
itself was multiview's, above). In `main` 2026-10-16 (Quest 3 good):
|
||||
`vr.refresh_rate_auto`
|
||||
(VR options MORE, "Lower it when frames are late", on by default) steps
|
||||
the rate down a step (90, 80, 72 Hz) while more than one frame in 32
|
||||
comes late, and back up once they would keep up; "VR: refresh rate" in
|
||||
the log. First try: 90 to 80 Hz a few seconds into a 30-player game, no
|
||||
doubled picture seen; 2-5 stale frames a second left at 80, hence one
|
||||
in 32 (was 16). Later:
|
||||
why a client's ticks cost that much per remote player.
|
||||
|
||||
- Doubled pictures when turning on the developer's Quest 3 (2026-10-12):
|
||||
with every build tried, back to 2026-10-06's, at 90 and at 72 Hz, even
|
||||
in seconds the compositor reported no stale frame. That Quest runs
|
||||
Horizon OS from the Public Test Channel (PTC; its build 2026-10-08),
|
||||
the likeliest cause. Released with `vr.graphics` "medium" as the
|
||||
default (smooth there). To do: try this and later builds with "high" on
|
||||
a Quest 3 outside PTC (the developer's wife's), and set the default
|
||||
back to "high" or "auto" if it holds.
|
||||
Resolved 2026-10-16: multiview (above), not the Horizon OS PTC.
|
||||
|
||||
- Multiview on the Steam Frame: why the eyes do not fuse there (suspected
|
||||
Mesa zink/Turnip); tools in branch `frame/doubled-images` (86335828),
|
||||
not merged.
|
||||
- Transparent geometry groups: the Xbox's 384 a window overflowed in
|
||||
games of 30 and more players (the last submitted, glass, water,
|
||||
particles, contrails, vanished). Raised to 2048 (320 KB), in `main`;
|
||||
still to check in a game of 30 and more players; upstream raised them
|
||||
to 2048 too (2026-10-12).
|
||||
|
||||
## Headset tests (2026-10-06, all three in `main`)
|
||||
|
||||
Quest 3, 2026-10-06: menus, laser, VR options, head turning, arms and
|
||||
hands, fingers, body modes, scope, vehicles, a bot game (bots spread and
|
||||
leave their bases) and a large online game: all good.
|
||||
Steam Frame, 2026-10-06: buttons, picture (no doubled image), arms, hands,
|
||||
fingers, wheel: all good; SteamVR reprojected 18% of the frames, unseen.
|
||||
What follows is left for the two headsets together.
|
||||
|
||||
Upstream merge (`merge/upstream-2026-10-06`):
|
||||
- Menus, a bot game, head turning (no doubled image), co-op briefly.
|
||||
- A password game hosted on the Frame, joined from the Quest.
|
||||
- A bot making room for a person joining a full lobby.
|
||||
|
||||
Performance (`frame/performance-2`, and the merge's upstream speed-ups),
|
||||
with `vr.log_performance = true`:
|
||||
- Frame: the log says `trace markers: N descriptors to /dev/null`; frame
|
||||
time ("working") against before (about 12.5 ms in a bot game on Blood
|
||||
Gulch); SteamVR's reprojected share (vrcompositor.txt) against before
|
||||
(2 to 17 %); no doubled image.
|
||||
- Lens flares still appear and hide as before (their visibility counters'
|
||||
copies changed).
|
||||
- The pose cache (3a.1): `first person: ... builds` about one a frame;
|
||||
scope, crosshair, laser and the weapon in the hand as before.
|
||||
- Quest: 90 Hz held as before in a bot game and in a large online game;
|
||||
nothing slower than the last build.
|
||||
|
||||
Arms and hands (3a): on the Steam Frame, as on the Quest (fingers on its
|
||||
controllers, every button still working).
|
||||
@@ -13,30 +13,16 @@ def buildNumberText = System.getenv("HALO_BUILD_NUMBER") ?: "0"
|
||||
def buildNumber = buildNumberText.isInteger() ? buildNumberText.toInteger() : 0
|
||||
|
||||
// the workflow's signing key (.github/workflows/build.yml): every build of
|
||||
// main signed with it can install over the one before; on a computer that
|
||||
// builds for its own devices, the same key from port/android/signing.properties
|
||||
// (not in the repository: storeFile, password, keyAlias), so that its
|
||||
// builds and the releases install over each other; without either, the
|
||||
// main signed with it can install over the one before; without it, the
|
||||
// debug key of the computer that builds
|
||||
def signingKey = System.getenv("HALO_ANDROID_KEYSTORE")
|
||||
def signingPassword = System.getenv("HALO_ANDROID_KEYSTORE_PASSWORD")
|
||||
def signingAlias = System.getenv("HALO_ANDROID_KEY_ALIAS") ?: "ringfall"
|
||||
def signingProperties = new File(rootDir, "signing.properties")
|
||||
if (!signingKey && signingProperties.isFile()) {
|
||||
def properties = new Properties()
|
||||
signingProperties.withInputStream { properties.load(it) }
|
||||
signingKey = properties.getProperty("storeFile")
|
||||
signingPassword = properties.getProperty("password")
|
||||
signingAlias = properties.getProperty("keyAlias", "ringfall")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace "com.halo.decomp"
|
||||
compileSdk 35
|
||||
|
||||
defaultConfig {
|
||||
// (the app's own id; the Java classes keep the decompilation's package)
|
||||
applicationId "io.github.cesarus85.ringfall"
|
||||
applicationId "com.halo.decomp"
|
||||
minSdk 28
|
||||
targetSdk 35
|
||||
versionCode Math.max(1, buildNumber)
|
||||
@@ -74,9 +60,9 @@ android {
|
||||
if (signingKey) {
|
||||
halo {
|
||||
storeFile file(signingKey)
|
||||
storePassword signingPassword
|
||||
keyAlias signingAlias
|
||||
keyPassword signingPassword
|
||||
storePassword System.getenv("HALO_ANDROID_KEYSTORE_PASSWORD")
|
||||
keyAlias System.getenv("HALO_ANDROID_KEY_ALIAS") ?: "halo"
|
||||
keyPassword System.getenv("HALO_ANDROID_KEYSTORE_PASSWORD")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,25 +19,20 @@
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
|
||||
<!-- voice chat's microphone (asked for only when voice chat first talks) -->
|
||||
<!-- the voice chat in multiplayer (host_voice.c) -->
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
<!-- installing a new version of the game (Updater) -->
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
<!-- enableOnBackInvokedCallback: the back button and the back gesture
|
||||
stay KEYCODE_BACK, which SDL passes to the game as B; with
|
||||
predictive back (the default once an app targets Android 16) the
|
||||
system would take them and the game would never see them -->
|
||||
<application
|
||||
android:name=".HaloApplication"
|
||||
android:label="@string/app_name"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:allowBackup="false"
|
||||
android:isGame="true"
|
||||
android:appCategory="game"
|
||||
android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"
|
||||
android:hardwareAccelerated="true"
|
||||
android:enableOnBackInvokedCallback="false">
|
||||
android:hardwareAccelerated="true">
|
||||
|
||||
<!-- a game, for the system (isGame and appCategory above; the game
|
||||
modes' configuration) and for launchers that look for this -->
|
||||
@@ -76,10 +71,7 @@
|
||||
(without them Horizon OS shows it as a flat panel, and the OpenXR
|
||||
session never gets focus); phones ignore them. The launcher,
|
||||
a flat panel on a headset, starts it once the game data is
|
||||
there. (port: upstream runs it in a process of its own,
|
||||
":game", for handhelds whose Java heap covers the Xbox window;
|
||||
not here: on the Steam Frame Lepton waits for the app's process
|
||||
to end, and the headsets have no such overlap) -->
|
||||
there. -->
|
||||
<activity
|
||||
android:name=".HaloActivity"
|
||||
android:exported="true"
|
||||
@@ -104,7 +96,7 @@
|
||||
<!-- the downloaded new version, for the package installer (Updater) -->
|
||||
<provider
|
||||
android:name=".UpdateProvider"
|
||||
android:authorities="${applicationId}.update"
|
||||
android:authorities="com.halo.decomp.update"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true" />
|
||||
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
package com.halo.decomp;
|
||||
|
||||
/**
|
||||
* Gyroscope aiming (TouchControls): integrates the sensor's angular velocity,
|
||||
* turned into the display's coordinates for its rotation, into radians of
|
||||
* view turn between samples.
|
||||
*/
|
||||
final class GyroscopeAim {
|
||||
/** below this (radians a second) a reading is the sensor's noise at rest, which must not drift the view */
|
||||
private static final float NOISE = 0.01f;
|
||||
/** a gap longer than this (seconds) starts over rather than turn at once */
|
||||
private static final float LONGEST_GAP = 0.1f;
|
||||
|
||||
private long previousTime;
|
||||
private int previousRotation = -1;
|
||||
private float previousX;
|
||||
private float previousY;
|
||||
|
||||
void reset() {
|
||||
previousTime = 0;
|
||||
previousRotation = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* takes one sample (its time in nanoseconds, the angular velocity about
|
||||
* the device's x and y axes, the display's rotation 0..3) and puts the turn
|
||||
* since the last into delta {yaw, pitch}; false while there is none
|
||||
*/
|
||||
boolean sample(long time, float x, float y, int rotation, float[] delta) {
|
||||
delta[0] = 0;
|
||||
delta[1] = 0;
|
||||
if (!Float.isFinite(x) || !Float.isFinite(y) || rotation < 0 || rotation > 3) {
|
||||
reset();
|
||||
return false;
|
||||
}
|
||||
float screenX = x;
|
||||
float screenY = y;
|
||||
switch (rotation) {
|
||||
case 1:
|
||||
screenX = y;
|
||||
screenY = -x;
|
||||
break;
|
||||
case 2:
|
||||
screenX = -x;
|
||||
screenY = -y;
|
||||
break;
|
||||
case 3:
|
||||
screenX = -y;
|
||||
screenY = x;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (Math.abs(screenX) < NOISE)
|
||||
screenX = 0;
|
||||
if (Math.abs(screenY) < NOISE)
|
||||
screenY = 0;
|
||||
float seconds = (time - previousTime) * 1e-9f;
|
||||
boolean valid = previousTime != 0 && rotation == previousRotation && seconds > 0 && seconds <= LONGEST_GAP;
|
||||
if (valid) {
|
||||
// the trapezoid rule over the two samples
|
||||
delta[0] = -(screenY + previousY) * 0.5f * seconds;
|
||||
delta[1] = -(screenX + previousX) * 0.5f * seconds;
|
||||
}
|
||||
previousTime = time;
|
||||
previousRotation = rotation;
|
||||
previousX = screenX;
|
||||
previousY = screenY;
|
||||
return valid && (delta[0] != 0 || delta[1] != 0);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,10 @@
|
||||
package com.halo.decomp;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Insets;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Display;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
@@ -30,16 +15,6 @@ import org.libsdl.app.SDLActivity;
|
||||
public class HaloActivity extends SDLActivity {
|
||||
/** lets system link's broadcasts in over Wi-Fi while the game runs */
|
||||
private WifiManager.MulticastLock multicastLock;
|
||||
/**
|
||||
* the latest system gesture insets {left, top, right, bottom}, in pixels;
|
||||
* written on the UI thread, read by the game's thread: replaced as a
|
||||
* whole, never changed in place
|
||||
*/
|
||||
private volatile int[] gestureInsets = new int[] { 0, 0, 0, 0 };
|
||||
/** the on-screen touch controls, over SDL's surface */
|
||||
private TouchControls touchControls;
|
||||
private static final int EXPORT_LAYOUT = 401, IMPORT_LAYOUT = 402;
|
||||
private String pendingLayoutExport;
|
||||
|
||||
@Override
|
||||
protected String[] getLibraries() {
|
||||
@@ -49,208 +24,21 @@ public class HaloActivity extends SDLActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (savedInstanceState != null)
|
||||
pendingLayoutExport = savedInstanceState.getString("pending-layout-export");
|
||||
if (mLayout != null) {
|
||||
touchControls = new TouchControls(this);
|
||||
mLayout.addView(touchControls, new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
}
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
preferHighestRefreshRate();
|
||||
trackGestureInsets();
|
||||
acquireMulticastLock();
|
||||
// a new version looked for while the game starts
|
||||
Updater.start(this);
|
||||
}
|
||||
|
||||
/** the system's file picker, for the touch layout; no storage permission */
|
||||
public void chooseLayoutFile(boolean export, String configuration) {
|
||||
String message = export
|
||||
? "Choose the folder and the name of the touch layout file."
|
||||
: "Choose a touch layout file. It replaces your buttons, the look sensitivity and the General settings.";
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(export ? "Export the layout" : "Import a layout")
|
||||
.setMessage(message)
|
||||
.setNegativeButton("Cancel", null)
|
||||
.setPositiveButton(export ? "Choose the place" : "Choose the file", (dialog, which) -> {
|
||||
Intent intent = new Intent(export ? Intent.ACTION_CREATE_DOCUMENT : Intent.ACTION_OPEN_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType(export ? "text/plain" : "*/*");
|
||||
if (export) {
|
||||
pendingLayoutExport = configuration;
|
||||
intent.putExtra(Intent.EXTRA_TITLE, "halo-touch-layout.halolayout");
|
||||
}
|
||||
try {
|
||||
startActivityForResult(intent, export ? EXPORT_LAYOUT : IMPORT_LAYOUT);
|
||||
} catch (android.content.ActivityNotFoundException e) {
|
||||
pendingLayoutExport = null;
|
||||
Toast.makeText(this, "This device has no file picker.", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle state) {
|
||||
super.onSaveInstanceState(state);
|
||||
state.putString("pending-layout-export", pendingLayoutExport);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int request, int result, Intent data) {
|
||||
if (request != EXPORT_LAYOUT && request != IMPORT_LAYOUT) {
|
||||
super.onActivityResult(request, result, data);
|
||||
return;
|
||||
}
|
||||
String exported = pendingLayoutExport;
|
||||
pendingLayoutExport = null;
|
||||
if (result != RESULT_OK || data == null || data.getData() == null)
|
||||
return;
|
||||
Uri document = data.getData();
|
||||
// (the file is read and written away from the UI thread)
|
||||
new Thread(() -> {
|
||||
try {
|
||||
if (request == EXPORT_LAYOUT)
|
||||
writeLayoutFile(document, exported);
|
||||
else
|
||||
readLayoutFile(document);
|
||||
} catch (Exception e) {
|
||||
runOnUiThread(() -> layoutFileError(e));
|
||||
}
|
||||
}, "halo-touch-layout-file").start();
|
||||
}
|
||||
|
||||
private void writeLayoutFile(Uri document, String configuration) throws IOException {
|
||||
if (configuration == null)
|
||||
throw new IOException("the layout to export is gone");
|
||||
try (OutputStream output = getContentResolver().openOutputStream(document, "wt")) {
|
||||
if (output == null)
|
||||
throw new IOException("the file cannot be opened");
|
||||
output.write(configuration.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
runOnUiThread(() -> Toast.makeText(this, "The layout is exported.", Toast.LENGTH_SHORT).show());
|
||||
}
|
||||
|
||||
private void readLayoutFile(Uri document) throws IOException {
|
||||
ByteArrayOutputStream contents = new ByteArrayOutputStream();
|
||||
try (InputStream input = getContentResolver().openInputStream(document)) {
|
||||
if (input == null)
|
||||
throw new IOException("the file cannot be opened");
|
||||
byte[] buffer = new byte[4096];
|
||||
int size;
|
||||
while ((size = input.read(buffer)) != -1) {
|
||||
if (contents.size() + size > 65536)
|
||||
throw new IOException("the file is too large");
|
||||
contents.write(buffer, 0, size);
|
||||
}
|
||||
}
|
||||
String configuration = new String(contents.toByteArray(), StandardCharsets.UTF_8);
|
||||
// checked here, then applied to the overlay at once
|
||||
TouchLayout.importConfiguration(configuration);
|
||||
runOnUiThread(() -> {
|
||||
if (isFinishing() || isDestroyed() || touchControls == null)
|
||||
return;
|
||||
try {
|
||||
touchControls.importLayout(configuration);
|
||||
Toast.makeText(this, "The layout is imported and saved.", Toast.LENGTH_SHORT).show();
|
||||
} catch (IllegalArgumentException e) {
|
||||
layoutFileError(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void layoutFileError(Exception error) {
|
||||
if (isFinishing() || isDestroyed())
|
||||
return;
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("Touch layout file")
|
||||
.setMessage("The operation did not complete: " + error.getMessage())
|
||||
.setPositiveButton("OK", null)
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (touchControls != null && getWindow().getDecorView().hasWindowFocus())
|
||||
touchControls.startDeviceInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
if (touchControls != null)
|
||||
touchControls.stopDeviceInput();
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
if (touchControls != null) {
|
||||
if (hasFocus)
|
||||
touchControls.startDeviceInput();
|
||||
else
|
||||
touchControls.stopDeviceInput();
|
||||
}
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (touchControls != null)
|
||||
touchControls.stopDeviceInput();
|
||||
if (multicastLock != null && multicastLock.isHeld())
|
||||
multicastLock.release();
|
||||
multicastLock = null;
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* keeps gestureInsets current; Android sends the insets again when the
|
||||
* activity rotates (after the game's native code has started on a phone
|
||||
* launched from portrait), so a single read at startup would keep the
|
||||
* portrait values; the listener hands the insets on so SDL's own
|
||||
* handling still sees them
|
||||
*/
|
||||
private void trackGestureInsets() {
|
||||
getWindow().getDecorView().setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
|
||||
@Override
|
||||
public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
|
||||
gestureInsets = readGestureInsets(insets);
|
||||
return view.onApplyWindowInsets(insets);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") // getSystemGestureInsets is the only call on Android 10
|
||||
private static int[] readGestureInsets(WindowInsets insets) {
|
||||
Insets gesture;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
|
||||
gesture = insets.getInsets(WindowInsets.Type.systemGestures());
|
||||
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
|
||||
gesture = insets.getSystemGestureInsets();
|
||||
else
|
||||
return new int[] { 0, 0, 0, 0 };
|
||||
return new int[] { gesture.left, gesture.top, gesture.right, gesture.bottom };
|
||||
}
|
||||
|
||||
/**
|
||||
* the edges of the screen where Android keeps its gestures; in sticky
|
||||
* full screen the first swipe from an edge only shows the system bars,
|
||||
* and Android hands that swipe to the game as an ordinary finger, so
|
||||
* the game (port/linux/src/touch_input.c) must ignore touches that
|
||||
* begin there; returns a copy of {left, top, right, bottom} in pixels:
|
||||
* all 0 before Android 10 (which has no insets) and until the first
|
||||
* insets arrive. The game's native code calls this through JNI by name
|
||||
* and signature (host_main.c GetMethodID(...,
|
||||
* "getSystemGestureInsetsPixels", "()[I")), at every finger down, so
|
||||
* it must not be renamed, retyped or removed as unused
|
||||
*/
|
||||
public int[] getSystemGestureInsetsPixels() {
|
||||
return gestureInsets.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Many phones drop the Wi-Fi's broadcast and multicast datagrams to
|
||||
* save power unless an app holds this: without it they would not see
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.halo.decomp;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
/**
|
||||
* The game (HaloActivity) runs in a process of its own, ":game", so that
|
||||
* its Java runtime starts fresh for it: nothing the launcher, the disc
|
||||
* image import or an earlier game did is left in its heap.
|
||||
*
|
||||
* There the native library is loaded first thing, and reserves the fixed
|
||||
* addresses the game needs at 0x80000000 (port/android/host/host_main.c,
|
||||
* JNI_OnLoad) before the Java side has allocated anything large: on some
|
||||
* devices, handhelds with a large Java heap especially, ART's large object
|
||||
* space covers those addresses, and only an idle part of it can be taken
|
||||
* back (port/android/host/host_memory.c).
|
||||
*/
|
||||
public class HaloApplication extends Application {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
String process = Application.getProcessName();
|
||||
if (process == null || !process.endsWith(":game"))
|
||||
return;
|
||||
try {
|
||||
// in SDLActivity's order (HaloActivity.getLibraries); it
|
||||
// finds them loaded
|
||||
System.loadLibrary("SDL3");
|
||||
System.loadLibrary("main");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
// SDLActivity reports it
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.halo.decomp;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@@ -27,7 +30,7 @@ import java.nio.channels.FileChannel;
|
||||
* Starts the game once its data is in place.
|
||||
*
|
||||
* The game reads the Xbox game data (the folder holding maps/) from the
|
||||
* app's external files directory, /sdcard/Android/data/<application id>/files.
|
||||
* app's external files directory, /sdcard/Android/data/com.halo.decomp/files.
|
||||
* If it is missing, this screen lets the player pick an Xbox disc image of
|
||||
* the game (.xiso or .iso, any version) with the system file picker, and
|
||||
* copies its maps folder there (XisoExtractor), as the desktop games do; or
|
||||
@@ -35,7 +38,7 @@ import java.nio.channels.FileChannel;
|
||||
*/
|
||||
public class LauncherActivity extends Activity {
|
||||
private static final int PICK_IMAGE = 1;
|
||||
static final String SHARED_DATA_ROOT = "/home/steamos/Documents/RingfallMjolnirVR";
|
||||
private static final int ASK_MICROPHONE = 2;
|
||||
|
||||
private File dataRoot;
|
||||
private TextView status;
|
||||
@@ -47,17 +50,6 @@ public class LauncherActivity extends Activity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
dataRoot = getExternalFilesDir(null);
|
||||
// the Steam Frame: Lepton empties the app's own folders whenever it
|
||||
// starts again; the game's data lives in the SteamOS user's
|
||||
// Documents instead, whenever they can be written, so that a disc
|
||||
// image imported here stays too (port/android/STEAM_FRAME.md; the
|
||||
// same choice as host_main.c's)
|
||||
File shared = new File(SHARED_DATA_ROOT);
|
||||
if (shared.getParentFile().canWrite() || shared.canWrite()) {
|
||||
shared.mkdirs();
|
||||
if (shared.canWrite())
|
||||
dataRoot = shared;
|
||||
}
|
||||
// created by the app, so that files pushed into it with adb stay
|
||||
// readable (a directory adb creates there belongs to the shell user)
|
||||
if (dataRoot != null)
|
||||
@@ -65,12 +57,37 @@ public class LauncherActivity extends Activity {
|
||||
passOnHardwareId();
|
||||
passOnInvite(getIntent());
|
||||
if (haveData()) {
|
||||
startGame();
|
||||
if (!askForMicrophone())
|
||||
startGame();
|
||||
return;
|
||||
}
|
||||
buildInterface();
|
||||
}
|
||||
|
||||
/**
|
||||
* The voice chat's microphone (port/android/host/host_voice.c), asked
|
||||
* for here, once, on this flat panel, before the game starts: in the
|
||||
* game, the question would stop it. Returns true if it asked (the game
|
||||
* starts on the answer).
|
||||
*/
|
||||
private boolean askForMicrophone() {
|
||||
SharedPreferences preferences = getSharedPreferences("launcher", MODE_PRIVATE);
|
||||
|
||||
if (checkSelfPermission(Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED
|
||||
|| preferences.getBoolean("asked_microphone", false))
|
||||
return false;
|
||||
preferences.edit().putBoolean("asked_microphone", true).apply();
|
||||
requestPermissions(new String[] { Manifest.permission.RECORD_AUDIO }, ASK_MICROPHONE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] results) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, results);
|
||||
if (requestCode == ASK_MICROPHONE)
|
||||
startGame();
|
||||
}
|
||||
|
||||
/**
|
||||
* An internet play invite link the app was opened with: the game
|
||||
* (port/linux/src/p2p.c) picks it up from join_link.txt, whether it is
|
||||
@@ -123,6 +140,23 @@ public class LauncherActivity extends Activity {
|
||||
partial.delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the microphone may be used, for the game (port/linux/src/
|
||||
* voice.c), which opens it only then: opening it otherwise would have
|
||||
* Android ask in the middle of the game.
|
||||
*/
|
||||
private void passOnMicrophonePermission() {
|
||||
if (dataRoot == null)
|
||||
return;
|
||||
boolean granted =
|
||||
checkSelfPermission(Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED;
|
||||
try (OutputStream out = new FileOutputStream(new File(dataRoot, "microphone_permission.txt"))) {
|
||||
out.write((granted ? "1" : "0").getBytes("UTF-8"));
|
||||
} catch (java.io.IOException e) {
|
||||
// the game then does without the microphone
|
||||
}
|
||||
}
|
||||
|
||||
/** The game data, or the marker file of the VR self-test (host_xr.c). */
|
||||
private boolean haveData() {
|
||||
return dataRoot != null && (new File(dataRoot, "maps/ui.map").isFile() ||
|
||||
@@ -130,6 +164,7 @@ public class LauncherActivity extends Activity {
|
||||
}
|
||||
|
||||
private void startGame() {
|
||||
passOnMicrophonePermission();
|
||||
startActivity(new Intent(this, HaloActivity.class));
|
||||
finish();
|
||||
}
|
||||
@@ -147,15 +182,15 @@ public class LauncherActivity extends Activity {
|
||||
layout.setBackgroundColor(Color.rgb(12, 16, 20));
|
||||
|
||||
TextView title = new TextView(this);
|
||||
title.setText("Mjolnir VR needs game data");
|
||||
title.setText("Halo needs its game data");
|
||||
title.setTextColor(Color.WHITE);
|
||||
title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
|
||||
title.setGravity(Gravity.CENTER);
|
||||
layout.addView(title);
|
||||
|
||||
TextView message = new TextView(this);
|
||||
message.setText("Choose your own disc image of Halo: Combat Evolved for the original Xbox (an .iso or "
|
||||
+ ".xiso file, any version) on this device. Its maps folder is copied into the app's storage (about 1.8 GB), "
|
||||
message.setText("Choose an Xbox disc image of Halo: Combat Evolved (an .iso or .xiso file, any "
|
||||
+ "version) on this device. Its maps folder is copied into the app's storage (about 1.8 GB), "
|
||||
+ "and you can delete the image afterwards.\n\n"
|
||||
+ "You can also copy a maps folder from a computer:\n"
|
||||
+ "adb push <folder with maps>/. " + (dataRoot != null ? dataRoot.getAbsolutePath() : "") + "/");
|
||||
|
||||
@@ -1,335 +0,0 @@
|
||||
package com.halo.decomp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* The touch controls' layout (TouchControls): each control's kind, place,
|
||||
* size and whether it shows, with the settings that go with them, in the
|
||||
* overlay's logical units. Places are kept for the display the layout is
|
||||
* on and saved on a 960 x 540 grid, so a layout moves between displays of
|
||||
* other shapes. A layout file is Java properties text (version 3; 1 and 2
|
||||
* are still read).
|
||||
*/
|
||||
final class TouchLayout {
|
||||
/** the kinds of control: a button of TouchControls's list, by index */
|
||||
static final int LEFT = 16;
|
||||
static final int FIRE_LEFT = 17;
|
||||
static final int BASE_COUNT = 18;
|
||||
static final int MAX_CONTROLS = 64;
|
||||
static final float MIN_SIZE = 0.5f;
|
||||
static final float MAX_SIZE = 2f;
|
||||
static final float MIN_OPACITY = 0.2f;
|
||||
static final float MAX_OPACITY = 1f;
|
||||
static final float MIN_SENSITIVITY = 0.25f;
|
||||
static final float MAX_SENSITIVITY = 4f;
|
||||
/**
|
||||
* the largest minimum radius: a finger's width is capped here on a small,
|
||||
* dense display, where the D-pad's buttons (69 apart) would overlap
|
||||
*/
|
||||
static final float MAX_MINIMUM_RADIUS = 34;
|
||||
|
||||
/** the saved grid */
|
||||
private static final float GRID_WIDTH = 960;
|
||||
private static final float GRID_HEIGHT = 540;
|
||||
private static final int VERSION = 3;
|
||||
private static final int MAX_FILE_LENGTH = 65536;
|
||||
|
||||
/** each kind's default place on the grid, and its radius */
|
||||
private static final float[][] DEFAULTS = {
|
||||
{856, 447}, {913, 377}, {794, 377}, {850, 312}, {915, 239}, {802, 239},
|
||||
{236, 449}, {691, 449}, {360, 490}, {438, 490}, {570, 36}, {390, 36},
|
||||
{100, 237}, {100, 335}, {51, 286}, {149, 286}, {115, 440}, {255, 239}
|
||||
};
|
||||
private static final float[] RADII = {
|
||||
36, 32, 34, 32, 39, 35, 32, 32, 27, 29, 28, 28, 25, 25, 25, 25, 64, 39
|
||||
};
|
||||
|
||||
private static final class Control {
|
||||
final int type;
|
||||
float x;
|
||||
float y;
|
||||
boolean shown = true;
|
||||
float size = 1f;
|
||||
|
||||
Control(int type, float x, float y) {
|
||||
this.type = type;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
|
||||
/** a layout and the sensitivity saved with it */
|
||||
static final class Configuration {
|
||||
final TouchLayout layout;
|
||||
final float sensitivity;
|
||||
|
||||
Configuration(TouchLayout layout, float sensitivity) {
|
||||
this.layout = layout;
|
||||
this.sensitivity = sensitivity;
|
||||
}
|
||||
}
|
||||
|
||||
private final ArrayList<Control> controls = new ArrayList<>();
|
||||
private float width = GRID_WIDTH;
|
||||
private float height = GRID_HEIGHT;
|
||||
/** the smallest radius a control is drawn and touched at, in logical units */
|
||||
private float minimumRadius;
|
||||
|
||||
boolean rumbleEnabled = true;
|
||||
boolean gyroscopeEnabled = false;
|
||||
/** how solid the controls are drawn, MIN_OPACITY..MAX_OPACITY */
|
||||
float opacity = 1f;
|
||||
/** the move stick goes where the thumb lands in the lower left, not at its place */
|
||||
boolean floatingStick = false;
|
||||
|
||||
TouchLayout() {
|
||||
resetDefaults();
|
||||
}
|
||||
|
||||
/** places the layout on a display of this size, in logical units */
|
||||
void bounds(float width, float height) {
|
||||
if (!Float.isFinite(width) || !Float.isFinite(height) || width <= 0 || height <= 0)
|
||||
throw new IllegalArgumentException("Invalid display dimensions");
|
||||
for (Control control : controls) {
|
||||
control.x *= width / this.width;
|
||||
control.y *= height / this.height;
|
||||
}
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
keepAllInside();
|
||||
}
|
||||
|
||||
/**
|
||||
* the smallest radius, in logical units, at which a control is drawn and
|
||||
* touched (a finger's width, whatever the display's density), at most
|
||||
* MAX_MINIMUM_RADIUS
|
||||
*/
|
||||
void setMinimumRadius(float radius) {
|
||||
minimumRadius = Float.isFinite(radius) && radius > 0 ? Math.min(radius, MAX_MINIMUM_RADIUS) : 0;
|
||||
keepAllInside();
|
||||
}
|
||||
|
||||
int size() {
|
||||
return controls.size();
|
||||
}
|
||||
|
||||
int type(int control) {
|
||||
return controls.get(control).type;
|
||||
}
|
||||
|
||||
float x(int control) {
|
||||
return controls.get(control).x;
|
||||
}
|
||||
|
||||
float y(int control) {
|
||||
return controls.get(control).y;
|
||||
}
|
||||
|
||||
float savedX(int control) {
|
||||
return x(control) * GRID_WIDTH / width;
|
||||
}
|
||||
|
||||
float savedY(int control) {
|
||||
return y(control) * GRID_HEIGHT / height;
|
||||
}
|
||||
|
||||
float radius(int control) {
|
||||
return Math.max(RADII[type(control)] * sizeScale(control), minimumRadius);
|
||||
}
|
||||
|
||||
float sizeScale(int control) {
|
||||
return controls.get(control).size;
|
||||
}
|
||||
|
||||
void setSize(int control, float size) {
|
||||
if (!Float.isFinite(size) || size < MIN_SIZE || size > MAX_SIZE)
|
||||
throw new IllegalArgumentException("Button size must be between 50% and 200%");
|
||||
controls.get(control).size = size;
|
||||
move(control, x(control), y(control));
|
||||
}
|
||||
|
||||
boolean shown(int control) {
|
||||
return controls.get(control).shown;
|
||||
}
|
||||
|
||||
void setShown(int control, boolean shown) {
|
||||
controls.get(control).shown = shown;
|
||||
}
|
||||
|
||||
void setOpacity(float opacity) {
|
||||
if (!validOpacity(opacity))
|
||||
throw new IllegalArgumentException("Opacity must be between 20% and 100%");
|
||||
this.opacity = opacity;
|
||||
}
|
||||
|
||||
/** the default controls, at their default places, sizes and visibility */
|
||||
void resetDefaults() {
|
||||
controls.clear();
|
||||
for (int i = 0; i < DEFAULTS.length; i++)
|
||||
controls.add(new Control(i, DEFAULTS[i][0] * width / GRID_WIDTH, DEFAULTS[i][1] * height / GRID_HEIGHT));
|
||||
keepAllInside();
|
||||
}
|
||||
|
||||
/** adds a copy of a control beside it; -1 if there may be no more (or it is the stick) */
|
||||
int duplicate(int source) {
|
||||
if (size() >= MAX_CONTROLS || type(source) == LEFT)
|
||||
return -1;
|
||||
float offset = radius(source) * 2 + 12;
|
||||
Control added = new Control(type(source), x(source) + offset, y(source));
|
||||
added.size = sizeScale(source);
|
||||
controls.add(added);
|
||||
int index = size() - 1;
|
||||
// where there is no room to the right, the copy goes to the left
|
||||
if (added.x > width - radius(index))
|
||||
added.x = x(source) - offset;
|
||||
move(index, added.x, added.y);
|
||||
return index;
|
||||
}
|
||||
|
||||
/** shows a hidden control of this kind, or else adds a copy; -1 if neither can be */
|
||||
int add(int type) {
|
||||
if (type < 0 || type >= BASE_COUNT)
|
||||
return -1;
|
||||
for (int i = 0; i < size(); i++) {
|
||||
if (type(i) == type && !shown(i)) {
|
||||
setShown(i, true);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return duplicate(type);
|
||||
}
|
||||
|
||||
/** moves a control, keeping all of it on the display */
|
||||
void move(int control, float x, float y) {
|
||||
if (!Float.isFinite(x) || !Float.isFinite(y))
|
||||
return;
|
||||
float radius = radius(control);
|
||||
controls.get(control).x = Math.max(radius, Math.min(width - radius, x));
|
||||
controls.get(control).y = Math.max(radius, Math.min(height - radius, y));
|
||||
}
|
||||
|
||||
/** puts a control at a saved place on the grid, if it is a valid one */
|
||||
void restore(int control, float x, float y) {
|
||||
if (Float.isFinite(x) && Float.isFinite(y) && x >= 0 && x <= GRID_WIDTH && y >= 0 && y <= GRID_HEIGHT) {
|
||||
controls.get(control).x = x;
|
||||
controls.get(control).y = y;
|
||||
}
|
||||
}
|
||||
|
||||
private void keepAllInside() {
|
||||
for (int i = 0; i < size(); i++)
|
||||
move(i, x(i), y(i));
|
||||
}
|
||||
|
||||
/** the layout as a layout file's text, with the look sensitivity */
|
||||
String exportConfiguration(float sensitivity) {
|
||||
if (!validSensitivity(sensitivity))
|
||||
throw new IllegalArgumentException("Invalid sensitivity");
|
||||
Properties values = new Properties();
|
||||
values.setProperty("format", "halo-touch-layout");
|
||||
values.setProperty("version", Integer.toString(VERSION));
|
||||
values.setProperty("rumble", Boolean.toString(rumbleEnabled));
|
||||
values.setProperty("gyroscope", Boolean.toString(gyroscopeEnabled));
|
||||
values.setProperty("opacity", Float.toString(opacity));
|
||||
values.setProperty("floating-stick", Boolean.toString(floatingStick));
|
||||
values.setProperty("count", Integer.toString(size()));
|
||||
values.setProperty("sensitivity", Float.toString(sensitivity));
|
||||
for (int i = 0; i < size(); i++) {
|
||||
String key = "control." + i + ".";
|
||||
values.setProperty(key + "type", Integer.toString(type(i)));
|
||||
values.setProperty(key + "x", Float.toString(savedX(i)));
|
||||
values.setProperty(key + "y", Float.toString(savedY(i)));
|
||||
values.setProperty(key + "visible", Boolean.toString(shown(i)));
|
||||
values.setProperty(key + "size", Float.toString(sizeScale(i)));
|
||||
}
|
||||
StringWriter text = new StringWriter();
|
||||
try {
|
||||
values.store(text, "Halo Android touch layout");
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
/** reads a layout file's text; throws IllegalArgumentException for anything not valid */
|
||||
static Configuration importConfiguration(String text) {
|
||||
if (text == null || text.length() > MAX_FILE_LENGTH)
|
||||
throw new IllegalArgumentException("Invalid layout file");
|
||||
Properties values = new Properties();
|
||||
try {
|
||||
values.load(new StringReader(text));
|
||||
int version = readVersion(values);
|
||||
int count = Integer.parseInt(values.getProperty("count"));
|
||||
float sensitivity = Float.parseFloat(values.getProperty("sensitivity"));
|
||||
if (count < BASE_COUNT || count > MAX_CONTROLS || !validSensitivity(sensitivity))
|
||||
throw new IllegalArgumentException("Invalid layout settings");
|
||||
TouchLayout layout = new TouchLayout();
|
||||
layout.controls.clear();
|
||||
if (version >= 2) {
|
||||
layout.rumbleEnabled = readBoolean(values, "rumble");
|
||||
layout.gyroscopeEnabled = readBoolean(values, "gyroscope");
|
||||
}
|
||||
if (version >= 3) {
|
||||
float opacity = Float.parseFloat(values.getProperty("opacity"));
|
||||
if (!validOpacity(opacity))
|
||||
throw new IllegalArgumentException("Invalid opacity");
|
||||
layout.opacity = opacity;
|
||||
layout.floatingStick = readBoolean(values, "floating-stick");
|
||||
}
|
||||
for (int i = 0; i < count; i++)
|
||||
layout.controls.add(readControl(values, i, version));
|
||||
return new Configuration(layout, sensitivity);
|
||||
} catch (IOException | NullPointerException e) {
|
||||
throw new IllegalArgumentException("Incomplete layout file", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static int readVersion(Properties values) {
|
||||
if (!"halo-touch-layout".equals(values.getProperty("format")))
|
||||
throw new IllegalArgumentException("Unsupported layout file");
|
||||
String version = values.getProperty("version");
|
||||
for (int known = 1; known <= VERSION; known++) {
|
||||
if (Integer.toString(known).equals(version))
|
||||
return known;
|
||||
}
|
||||
throw new IllegalArgumentException("Unsupported layout file");
|
||||
}
|
||||
|
||||
private static Control readControl(Properties values, int index, int version) {
|
||||
String key = "control." + index + ".";
|
||||
int type = Integer.parseInt(values.getProperty(key + "type"));
|
||||
float x = Float.parseFloat(values.getProperty(key + "x"));
|
||||
float y = Float.parseFloat(values.getProperty(key + "y"));
|
||||
String shown = values.getProperty(key + "visible");
|
||||
float size = version >= 2 ? Float.parseFloat(values.getProperty(key + "size")) : 1f;
|
||||
boolean validType = type >= 0 && type < BASE_COUNT && (index >= BASE_COUNT ? type != LEFT : type == index);
|
||||
boolean validPlace = Float.isFinite(x) && Float.isFinite(y) && x >= 0 && x <= GRID_WIDTH
|
||||
&& y >= 0 && y <= GRID_HEIGHT;
|
||||
boolean validSize = Float.isFinite(size) && size >= MIN_SIZE && size <= MAX_SIZE;
|
||||
if (!validType || !validPlace || !validSize || !("true".equals(shown) || "false".equals(shown)))
|
||||
throw new IllegalArgumentException("Invalid control in layout file");
|
||||
Control control = new Control(type, x, y);
|
||||
control.shown = Boolean.parseBoolean(shown);
|
||||
control.size = size;
|
||||
return control;
|
||||
}
|
||||
|
||||
private static boolean readBoolean(Properties values, String key) {
|
||||
String value = values.getProperty(key);
|
||||
if (!("true".equals(value) || "false".equals(value)))
|
||||
throw new IllegalArgumentException("Invalid " + key + " option");
|
||||
return Boolean.parseBoolean(value);
|
||||
}
|
||||
|
||||
static boolean validSensitivity(float value) {
|
||||
return Float.isFinite(value) && value >= MIN_SENSITIVITY && value <= MAX_SENSITIVITY;
|
||||
}
|
||||
|
||||
static boolean validOpacity(float value) {
|
||||
return Float.isFinite(value) && value >= MIN_OPACITY && value <= MAX_OPACITY;
|
||||
}
|
||||
}
|
||||
@@ -13,13 +13,13 @@ import java.io.FileNotFoundException;
|
||||
|
||||
/**
|
||||
* Hands Android's package installer the downloaded new version of the app
|
||||
* (Updater), read-only, the one file content://<application id>.update/update.apk.
|
||||
* (Updater), read-only, the one file content://com.halo.decomp.update/halo.apk.
|
||||
* (The app has no AndroidX, whose FileProvider does the same.)
|
||||
*/
|
||||
public class UpdateProvider extends ContentProvider {
|
||||
static final String AUTHORITY = BuildConfig.APPLICATION_ID + ".update";
|
||||
static final String AUTHORITY = "com.halo.decomp.update";
|
||||
static final String DIRECTORY = "update";
|
||||
static final String APK = "update.apk";
|
||||
static final String APK = "halo.apk";
|
||||
|
||||
private File apk() {
|
||||
return new File(new File(getContext().getCacheDir(), DIRECTORY), APK);
|
||||
|
||||
@@ -36,8 +36,7 @@ import java.util.zip.ZipInputStream;
|
||||
* the latest release when it starts, on a thread of its own, and if it is
|
||||
* newer asks the player whether to update:
|
||||
*
|
||||
* - Yes: the release's app (mjolnir-vr-android-release.zip or
|
||||
* -debug.zip) is
|
||||
* - Yes: the release's app (halo-android-release.zip or -debug.zip) is
|
||||
* downloaded and handed to Android's package installer, which replaces the
|
||||
* game (closing it) and offers to open the new version.
|
||||
* - No: nothing, until the next start.
|
||||
@@ -46,19 +45,13 @@ import java.util.zip.ZipInputStream;
|
||||
*
|
||||
* Every build of main is signed with the same key (the workflow's), which an
|
||||
* app must keep for Android to install a new version over it.
|
||||
*
|
||||
* Not on the Steam Frame: Lepton installs the APK in the game's folder there
|
||||
* at every start, so its launcher updates that (steam_frame_launch.sh).
|
||||
*/
|
||||
final class Updater {
|
||||
/* the VR port's own releases: the original's, made without VR, must
|
||||
never replace it (they share the package name) */
|
||||
private static final String APP_NAME = "Mjolnir VR";
|
||||
private static final String REPOSITORY = "Cesarus85/mjolnir-vr";
|
||||
private static final String REPOSITORY = "Cesarus85/halo-ce-vr";
|
||||
private static final String USER_AGENT = "halo-ce-universal-updater";
|
||||
private static final int TIMEOUT_MILLISECONDS = 20000;
|
||||
/** the most a download (a release's zip, about 35 MB) or the app in it may be */
|
||||
private static final long MAXIMUM_UPDATE_SIZE = 256L * 1024 * 1024;
|
||||
|
||||
private Updater() {
|
||||
}
|
||||
@@ -67,8 +60,7 @@ final class Updater {
|
||||
static void start(Activity activity) {
|
||||
File config = configFile(activity);
|
||||
|
||||
if (BuildConfig.HALO_BUILD_NUMBER <= 0 || config == null || !autoUpdate(config) ||
|
||||
new File(LauncherActivity.SHARED_DATA_ROOT).isDirectory())
|
||||
if (BuildConfig.HALO_BUILD_NUMBER <= 0 || config == null || !autoUpdate(config))
|
||||
return;
|
||||
new Thread(() -> {
|
||||
int latest = latestRelease();
|
||||
@@ -210,8 +202,8 @@ final class Updater {
|
||||
if (activity.isFinishing())
|
||||
return;
|
||||
new AlertDialog.Builder(activity)
|
||||
.setTitle(APP_NAME + ": new version")
|
||||
.setMessage("A new version of " + APP_NAME + " was detected (build " + latest + "; this is build "
|
||||
.setTitle("Halo: new version")
|
||||
.setMessage("A new version of Halo was detected (build " + latest + "; this is build "
|
||||
+ BuildConfig.HALO_BUILD_NUMBER + ").\n\nDo you want to update? The game will close and start "
|
||||
+ "the new version.")
|
||||
.setCancelable(false)
|
||||
@@ -223,7 +215,7 @@ final class Updater {
|
||||
|
||||
private static void confirmNever(Activity activity) {
|
||||
new AlertDialog.Builder(activity)
|
||||
.setTitle(APP_NAME + ": new version")
|
||||
.setTitle("Halo: new version")
|
||||
.setMessage("Stop asking about new versions?\n\nTo ask again, set auto = true in the [update] section "
|
||||
+ "of config.toml.")
|
||||
.setCancelable(false)
|
||||
@@ -240,7 +232,7 @@ final class Updater {
|
||||
/* ---------- updating */
|
||||
|
||||
private static void update(Activity activity, int latest) {
|
||||
String asset = "mjolnir-vr-android-" + (BuildConfig.DEBUG ? "debug" : "release") + ".zip";
|
||||
String asset = "halo-android-" + (BuildConfig.DEBUG ? "debug" : "release") + ".zip";
|
||||
File directory = new File(activity.getCacheDir(), UpdateProvider.DIRECTORY);
|
||||
LinearLayout layout = new LinearLayout(activity);
|
||||
TextView status = new TextView(activity);
|
||||
@@ -255,7 +247,7 @@ final class Updater {
|
||||
layout.addView(status);
|
||||
layout.addView(bar);
|
||||
AlertDialog progress = new AlertDialog.Builder(activity)
|
||||
.setTitle(APP_NAME + ": new version")
|
||||
.setTitle("Halo: new version")
|
||||
.setView(layout)
|
||||
.setCancelable(false)
|
||||
.show();
|
||||
@@ -283,7 +275,7 @@ final class Updater {
|
||||
activity.runOnUiThread(() -> {
|
||||
progress.dismiss();
|
||||
new AlertDialog.Builder(activity)
|
||||
.setTitle(APP_NAME + ": new version")
|
||||
.setTitle("Halo: new version")
|
||||
.setMessage("The update failed:\n\n" + e.getMessage())
|
||||
.setPositiveButton("OK", null)
|
||||
.show();
|
||||
@@ -312,10 +304,8 @@ final class Updater {
|
||||
int count;
|
||||
|
||||
while ((count = in.read(buffer)) > 0) {
|
||||
received += count;
|
||||
if (received > MAXIMUM_UPDATE_SIZE)
|
||||
throw new IOException("the download is larger than expected");
|
||||
out.write(buffer, 0, count);
|
||||
received += count;
|
||||
if (received - reported >= 256 * 1024 || received == total) {
|
||||
progress.report(received, total);
|
||||
reported = received;
|
||||
@@ -339,15 +329,10 @@ final class Updater {
|
||||
continue;
|
||||
try (OutputStream out = new FileOutputStream(apk)) {
|
||||
byte[] buffer = new byte[65536];
|
||||
long written = 0;
|
||||
int count;
|
||||
|
||||
while ((count = in.read(buffer)) > 0) {
|
||||
written += count;
|
||||
if (written > MAXIMUM_UPDATE_SIZE)
|
||||
throw new IOException("the app in the download is larger than expected");
|
||||
while ((count = in.read(buffer)) > 0)
|
||||
out.write(buffer, 0, count);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4,101 +4,94 @@ import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Copies the maps folder out of the player's Xbox disc image of Halo, for
|
||||
* LauncherActivity, as the desktop games do (port/linux/src/xiso.c; the web
|
||||
* page's is port/web/site/xiso-worker.js). The image is a document the
|
||||
* player picked, read through its FileChannel at absolute positions.
|
||||
* Copies the maps folder out of an Xbox disc image (an "xiso", or a whole
|
||||
* disc's ".iso"), as the desktop games do (port/linux/src/xiso.c, which this
|
||||
* follows).
|
||||
*
|
||||
* Written from a description of the Xbox's disc file system, XDVDFS
|
||||
* (xboxdevwiki's XDVDFS page, https://xboxdevwiki.net/XDVDFS, and the format
|
||||
* facts OpenCE's readers rely on). What this class relies on:
|
||||
* The image's file system is XDVDFS, read as extract-xiso does
|
||||
* (https://github.com/XboxDev/extract-xiso, extract-xiso.c, whose format
|
||||
* handling this follows; its license is below and in
|
||||
* port/third_party/extract-xiso/LICENSE.TXT): 2048-byte sectors; a volume
|
||||
* descriptor at 0x10000 that starts and ends with "MICROSOFT*XBOX*MEDIA" and
|
||||
* gives the root directory's sector and size; and directories whose entries
|
||||
* form a binary tree (each entry: left and right subtree offsets in 4-byte
|
||||
* units, the start sector, the size, attributes, the name's length and the
|
||||
* name, 4-byte aligned). Images made from a whole disc put the game partition
|
||||
* further in, at one of the offsets below.
|
||||
*
|
||||
* - Sectors are 2048 bytes and integers little-endian. Sector numbers count
|
||||
* from the start of the game partition: an image of the partition alone
|
||||
* has it at 0, an image of a whole disc further in (0x0FD90000, 0x02080000
|
||||
* or 0x18300000 for XGD2, XGD3 and XGD1 discs). They are tried in that
|
||||
* order.
|
||||
* - The volume descriptor is the partition's sector 32 (at 0x10000). It
|
||||
* holds "MICROSOFT*XBOX*MEDIA" at its start and again at 0x7EC, and the
|
||||
* root directory table's start sector (u32 at 0x14) and size in bytes (u32
|
||||
* at 0x18).
|
||||
* - A directory table is a binary tree of entries whose root is the entry at
|
||||
* offset 0. An entry is a left and a right subtree link (u16 each, in
|
||||
* 4-byte units from the table's start, 0 for none), the start sector and
|
||||
* the size of the file or of the subdirectory's table (u32 each), the
|
||||
* attributes (u8, 0x10 for a directory), the name's length (u8) and the
|
||||
* name. Unused bytes of a table are 0xFF, so a left link of 0xFFFF is
|
||||
* padding, not an entry.
|
||||
* - A file is one contiguous run of bytes from the start of its sector.
|
||||
* The files are written to maps.partial first and moved into maps once they
|
||||
* all are, so an interrupted extraction never leaves maps/ui.map behind.
|
||||
*
|
||||
* The image is the player's file and nothing read from it is trusted. Only
|
||||
* the root's table and the maps folder's are read, each whole and at most
|
||||
* 4 MB; the walk of a table visits each offset once, goes at most 64 links
|
||||
* deep and looks at most 4096 entries; and a file is written only under a
|
||||
* plain name that no file before it had (ignoring case).
|
||||
* Some parts of this code are copyright in@fishtank.com. This product
|
||||
* includes software developed by in <in@fishtank.com>.
|
||||
*
|
||||
* The loading screen's picture, which the retail disc has no file of, is
|
||||
* taken out of the root's default.xbe (read whole, at most 64 MB) and
|
||||
* written beside the maps as the loading.tga the game reads, when the maps
|
||||
* folder has none (loadingPicture, as xiso.c's xiso_write_loading_picture);
|
||||
* without it the light sweeps over black, as the game's own does.
|
||||
* Copyright (c) 2003 in <in@fishtank.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* The app starts the game once maps/ui.map exists, and makes the maps folder
|
||||
* itself, so the copy is written to maps.partial (emptied first of what an
|
||||
* earlier attempt left) and its files moved into maps once all are
|
||||
* complete, ui.map last.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
*
|
||||
* This product includes software developed by in <in@fishtank.com>.
|
||||
*
|
||||
* 4. Neither the name of "in" nor the email address "in@fishtank.com"
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED `AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
final class XisoExtractor {
|
||||
private static final int SECTOR_SIZE = 2048;
|
||||
private static final int DESCRIPTOR_OFFSET = 0x10000;
|
||||
private static final byte[] MAGIC = "MICROSOFT*XBOX*MEDIA".getBytes(StandardCharsets.ISO_8859_1);
|
||||
private static final int SECOND_MAGIC_OFFSET = 0x7EC;
|
||||
private static final int ENTRY_FIXED_SIZE = 14;
|
||||
private static final long VOLUME_DESCRIPTOR_OFFSET = 0x10000;
|
||||
private static final int ENTRY_HEADER_SIZE = 14;
|
||||
private static final int ATTRIBUTE_DIRECTORY = 0x10;
|
||||
private static final int PADDING_LINK = 0xFFFF;
|
||||
/** where the game partition may start, in the order they are tried */
|
||||
private static final long[] PARTITION_STARTS = {
|
||||
0x00000000L, // an image of the game partition alone
|
||||
0x0FD90000L, // a whole XGD2 disc
|
||||
0x02080000L, // a whole XGD3 disc
|
||||
0x18300000L, // a whole XGD1 disc (the original Xbox's)
|
||||
};
|
||||
/** directory tables are a few sectors; anything much larger is not one */
|
||||
private static final int MAXIMUM_TABLE_SIZE = 4 * 1024 * 1024;
|
||||
private static final int MAXIMUM_DEPTH = 64;
|
||||
private static final int MAXIMUM_VISITS = 4096;
|
||||
private static final int MAXIMUM_ENTRIES = 256;
|
||||
private static final int COPY_CHUNK = 1024 * 1024;
|
||||
private static final String PARTIAL_DIRECTORY = "maps.partial";
|
||||
/** the loading screen's picture (source/interface/progress_bar.c), out of default.xbe; the executable is a few MB */
|
||||
private static final int LOADING_WIDTH = 320;
|
||||
private static final int LOADING_HEIGHT = 240;
|
||||
private static final int TGA_HEADER_SIZE = 18;
|
||||
private static final long MAXIMUM_XBE_SIZE = 64 * 1024 * 1024;
|
||||
private static final String LOADING_PICTURE = "loading.tga";
|
||||
/* directory tables are a few sectors; anything much larger is not one */
|
||||
private static final long MAXIMUM_DIRECTORY_SIZE = 4 << 20;
|
||||
private static final int MAXIMUM_FILES = 256;
|
||||
private static final int COPY_BUFFER_SIZE = 1 << 20;
|
||||
private static final byte[] VOLUME_MAGIC = "MICROSOFT*XBOX*MEDIA".getBytes(StandardCharsets.US_ASCII);
|
||||
|
||||
/* where the game partition starts: a plain image, and whole-disc images
|
||||
(extract-xiso's GLOBAL, XGD3 and XGD1 offsets) */
|
||||
private static final long[] PARTITION_OFFSETS = { 0, 0x0FD90000L, 0x02080000L, 0x18300000L };
|
||||
|
||||
/** Told as the copy goes: the file being copied, and the bytes copied of all the files'. */
|
||||
interface Progress {
|
||||
void report(String file, long done, long total);
|
||||
}
|
||||
|
||||
/** A reason the player can act on: its message is shown as it is. */
|
||||
/** a reason the player can act on */
|
||||
static final class ExtractException extends IOException {
|
||||
ExtractException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
/** a file or folder found in a directory table */
|
||||
private static final class Entry {
|
||||
final String name;
|
||||
final long sector;
|
||||
@@ -111,414 +104,172 @@ final class XisoExtractor {
|
||||
}
|
||||
}
|
||||
|
||||
private XisoExtractor() {
|
||||
private final FileChannel image;
|
||||
private long partition;
|
||||
|
||||
private XisoExtractor(FileChannel image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
/** Copies the image's maps folder to destination/maps. */
|
||||
/** copies the image's maps folder to destination/maps */
|
||||
static void extractMaps(FileChannel image, File destination, Progress progress) throws IOException {
|
||||
long imageSize = image.size();
|
||||
long partition = -1;
|
||||
long rootSector = 0, rootSize = 0;
|
||||
ByteBuffer descriptor = ByteBuffer.allocate(SECTOR_SIZE);
|
||||
new XisoExtractor(image).extract(destination, progress);
|
||||
}
|
||||
|
||||
for (long start : PARTITION_STARTS) {
|
||||
if (start + DESCRIPTOR_OFFSET + SECTOR_SIZE > imageSize)
|
||||
continue;
|
||||
descriptor.clear();
|
||||
if (!readFully(image, descriptor, start + DESCRIPTOR_OFFSET))
|
||||
continue;
|
||||
byte[] bytes = descriptor.array();
|
||||
if (!hasMagic(bytes, 0) || !hasMagic(bytes, SECOND_MAGIC_OFFSET))
|
||||
continue;
|
||||
partition = start;
|
||||
rootSector = u32(bytes, 0x14);
|
||||
rootSize = u32(bytes, 0x18);
|
||||
break;
|
||||
private void readAt(long offset, ByteBuffer buffer) throws IOException {
|
||||
while (buffer.hasRemaining()) {
|
||||
int count = image.read(buffer, offset);
|
||||
|
||||
if (count <= 0)
|
||||
throw new ExtractException("Could not read the disc image (is it complete?).");
|
||||
offset += count;
|
||||
}
|
||||
if (partition < 0)
|
||||
throw new ExtractException("This is not an Xbox disc image.");
|
||||
buffer.flip();
|
||||
}
|
||||
|
||||
// the root's maps folder
|
||||
byte[] root = readTable(image, partition, rootSector, rootSize, "The disc image's file system is damaged.");
|
||||
private static boolean magicAt(ByteBuffer buffer, int offset) {
|
||||
for (int index = 0; index < VOLUME_MAGIC.length; index++) {
|
||||
if (buffer.get(offset + index) != VOLUME_MAGIC[index])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** the partition's volume descriptor: the root directory's sector and size */
|
||||
private long[] findVolume() throws IOException {
|
||||
for (long offset : PARTITION_OFFSETS) {
|
||||
ByteBuffer descriptor = ByteBuffer.allocate(SECTOR_SIZE).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
try {
|
||||
readAt(offset + VOLUME_DESCRIPTOR_OFFSET, descriptor);
|
||||
} catch (IOException e) {
|
||||
continue;
|
||||
}
|
||||
if (!magicAt(descriptor, 0) || !magicAt(descriptor, 0x7EC))
|
||||
continue;
|
||||
partition = offset;
|
||||
return new long[] {
|
||||
descriptor.getInt(20) & 0xFFFFFFFFL, descriptor.getInt(24) & 0xFFFFFFFFL,
|
||||
};
|
||||
}
|
||||
throw new ExtractException("This is not an Xbox disc image.");
|
||||
}
|
||||
|
||||
/** a directory's table, read whole */
|
||||
private ByteBuffer readDirectory(long sector, long size, String what) throws IOException {
|
||||
if (size <= 0 || size > MAXIMUM_DIRECTORY_SIZE)
|
||||
throw new ExtractException(what);
|
||||
ByteBuffer table = ByteBuffer.allocate((int) size).order(ByteOrder.LITTLE_ENDIAN);
|
||||
readAt(partition + sector * SECTOR_SIZE, table);
|
||||
return table;
|
||||
}
|
||||
|
||||
/**
|
||||
* collects the entries of the subtree at offset (4-byte units), files or
|
||||
* directories as asked
|
||||
*/
|
||||
private static void walk(ByteBuffer table, long offset, int depth, boolean directories, List<Entry> out,
|
||||
int[] visited) {
|
||||
offset *= 4;
|
||||
/* a malformed table must not loop or run off its end */
|
||||
if (depth > 64 || ++visited[0] > 4096 || offset + ENTRY_HEADER_SIZE > table.limit())
|
||||
return;
|
||||
int at = (int) offset;
|
||||
int left = table.getShort(at) & 0xFFFF;
|
||||
int right = table.getShort(at + 2) & 0xFFFF;
|
||||
/* 0xFFFF: padding, an empty directory */
|
||||
if (left == 0xFFFF)
|
||||
return;
|
||||
int nameLength = table.get(at + 13) & 0xFF;
|
||||
if (left != 0)
|
||||
walk(table, left, depth + 1, directories, out, visited);
|
||||
boolean isDirectory = (table.get(at + 12) & ATTRIBUTE_DIRECTORY) != 0;
|
||||
if (at + ENTRY_HEADER_SIZE + nameLength <= table.limit() && nameLength > 0 && isDirectory == directories
|
||||
&& out.size() < MAXIMUM_FILES) {
|
||||
byte[] bytes = new byte[nameLength];
|
||||
for (int index = 0; index < nameLength; index++)
|
||||
bytes[index] = table.get(at + ENTRY_HEADER_SIZE + index);
|
||||
String name = new String(bytes, StandardCharsets.ISO_8859_1);
|
||||
/* (as extract-xiso refuses them: no name may leave the folder) */
|
||||
if (!name.equals(".") && !name.equals("..") && name.indexOf('/') < 0 && name.indexOf('\\') < 0)
|
||||
out.add(new Entry(name, table.getInt(at + 4) & 0xFFFFFFFFL, table.getInt(at + 8) & 0xFFFFFFFFL));
|
||||
}
|
||||
if (right != 0)
|
||||
walk(table, right, depth + 1, directories, out, visited);
|
||||
}
|
||||
|
||||
private void extract(File destination, Progress progress) throws IOException {
|
||||
long[] root = findVolume();
|
||||
|
||||
/* the root's maps folder */
|
||||
ByteBuffer table = readDirectory(root[0], root[1], "The disc image's file system is damaged.");
|
||||
List<Entry> directories = new ArrayList<>();
|
||||
walk(table, 0, 0, true, directories, new int[1]);
|
||||
Entry maps = null;
|
||||
Entry xbe = null;
|
||||
for (Entry entry : walkTable(root, false)) {
|
||||
if (entry.name.equalsIgnoreCase("default.xbe"))
|
||||
xbe = entry;
|
||||
}
|
||||
List<Entry> directories = walkTable(root, true);
|
||||
for (Entry entry : directories) {
|
||||
if (entry.name.equalsIgnoreCase("maps")) {
|
||||
if (entry.name.equalsIgnoreCase("maps"))
|
||||
maps = entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// (Mjolnir VR: a European disc in two languages, Spanish and Italian,
|
||||
// has no maps folder but one for each, maps_es and maps_it: the
|
||||
// device's language's is taken, else English's, else the first, and
|
||||
// its language written to maps/language.txt, which the game asks the
|
||||
// Xbox for while game.language is unset: port/linux/src/xbox_xapi.c)
|
||||
String language = null;
|
||||
if (maps == null) {
|
||||
String wanted = Locale.getDefault().getLanguage();
|
||||
Entry english = null, first = null;
|
||||
|
||||
for (Entry entry : walkTable(root, true)) {
|
||||
String code = mapsLanguage(entry.name);
|
||||
|
||||
if (code == null)
|
||||
continue;
|
||||
if (code.equals(wanted) && maps == null)
|
||||
maps = entry;
|
||||
if (code.equals("en") && english == null)
|
||||
english = entry;
|
||||
if (first == null)
|
||||
first = entry;
|
||||
}
|
||||
if (maps == null)
|
||||
maps = english != null ? english : first;
|
||||
if (maps != null)
|
||||
language = mapsLanguage(maps.name);
|
||||
}
|
||||
if (maps == null)
|
||||
throw new ExtractException("The disc image has no maps folder: it is not a Halo disc.");
|
||||
|
||||
// its files
|
||||
byte[] table = readTable(image, partition, maps.sector, maps.size, "The disc image's maps folder is damaged.");
|
||||
List<Entry> files = walkTable(table, false);
|
||||
Entry userInterface = null;
|
||||
boolean hasLoading = false;
|
||||
for (Entry file : files) {
|
||||
if (file.name.equalsIgnoreCase("ui.map"))
|
||||
userInterface = file;
|
||||
hasLoading |= file.name.equalsIgnoreCase(LOADING_PICTURE);
|
||||
}
|
||||
if (userInterface == null)
|
||||
throw new ExtractException("The disc image's maps folder has no ui.map: it is not a Halo disc.");
|
||||
// (an image that ends before a file does is refused before anything
|
||||
// is written; an empty file's sector need not be anywhere)
|
||||
/* its files */
|
||||
table = readDirectory(maps.sector, maps.size, "The disc image's maps folder is damaged.");
|
||||
List<Entry> files = new ArrayList<>();
|
||||
walk(table, 0, 0, false, files, new int[1]);
|
||||
long total = 0;
|
||||
boolean hasUi = false;
|
||||
for (Entry file : files) {
|
||||
if (file.size > 0 && partition + file.sector * SECTOR_SIZE + file.size > imageSize)
|
||||
throw new ExtractException(readFailure(file));
|
||||
total += file.size;
|
||||
hasUi |= file.name.equalsIgnoreCase("ui.map");
|
||||
}
|
||||
if (!hasUi)
|
||||
throw new ExtractException("The disc image's maps folder has no ui.map: it is not a Halo disc.");
|
||||
|
||||
// the copy, to maps.partial
|
||||
File partial = new File(destination, PARTIAL_DIRECTORY);
|
||||
if (partial.isDirectory()) {
|
||||
File[] leftovers = partial.listFiles();
|
||||
if (leftovers != null) {
|
||||
for (File leftover : leftovers)
|
||||
leftover.delete();
|
||||
}
|
||||
} else {
|
||||
partial.delete();
|
||||
partial.mkdirs();
|
||||
}
|
||||
if (!partial.isDirectory())
|
||||
throw new ExtractException("Could not create " + partial.getPath() + ".");
|
||||
ByteBuffer buffer = ByteBuffer.allocate(COPY_CHUNK);
|
||||
File partial = new File(destination, "maps.partial");
|
||||
File finished = new File(destination, "maps");
|
||||
if (!partial.isDirectory() && !partial.mkdirs())
|
||||
throw new ExtractException("Could not create " + partial + ".");
|
||||
ByteBuffer buffer = ByteBuffer.allocateDirect(COPY_BUFFER_SIZE);
|
||||
long done = 0;
|
||||
for (Entry file : files)
|
||||
done = copyFile(image, partition, file, new File(partial, file.name), buffer, done, total, progress);
|
||||
if (!hasLoading && writeLoadingPicture(image, imageSize, partition, xbe, new File(partial, LOADING_PICTURE)))
|
||||
files.add(new Entry(LOADING_PICTURE, 0, 0));
|
||||
for (Entry file : files) {
|
||||
File path = new File(partial, file.name);
|
||||
long offset = partition + file.sector * SECTOR_SIZE;
|
||||
long remaining = file.size;
|
||||
|
||||
// then into maps, ui.map (the app's sign that the data is there) last
|
||||
File mapsFolder = new File(destination, "maps");
|
||||
if (!mapsFolder.isDirectory() && !mapsFolder.mkdirs() && !mapsFolder.isDirectory())
|
||||
throw new ExtractException("Could not create " + mapsFolder.getPath() + ".");
|
||||
// (the language of a language's maps folder: before ui.map is there)
|
||||
File languageFile = new File(mapsFolder, "language.txt");
|
||||
languageFile.delete();
|
||||
if (language != null) {
|
||||
try (FileOutputStream out = new FileOutputStream(languageFile)) {
|
||||
out.write((language + "\n").getBytes(StandardCharsets.US_ASCII));
|
||||
try (FileOutputStream out = new FileOutputStream(path)) {
|
||||
FileChannel output = out.getChannel();
|
||||
|
||||
while (remaining > 0) {
|
||||
buffer.clear();
|
||||
buffer.limit((int) Math.min(remaining, COPY_BUFFER_SIZE));
|
||||
readAt(offset, buffer);
|
||||
int count = buffer.remaining();
|
||||
while (buffer.hasRemaining())
|
||||
output.write(buffer);
|
||||
offset += count;
|
||||
remaining -= count;
|
||||
done += count;
|
||||
progress.report(file.name, done, total);
|
||||
}
|
||||
} catch (ExtractException e) {
|
||||
throw new ExtractException("Could not read " + file.name + " from the disc image (is it complete?).");
|
||||
} catch (IOException e) {
|
||||
throw new ExtractException("Could not write " + languageFile.getPath() + " (is the storage full?).");
|
||||
throw new ExtractException("Could not write " + path + " (is the storage full?).");
|
||||
}
|
||||
}
|
||||
List<Entry> order = new ArrayList<>(files);
|
||||
order.remove(userInterface);
|
||||
order.add(userInterface);
|
||||
for (Entry file : order) {
|
||||
File target = new File(mapsFolder, file.name);
|
||||
target.delete();
|
||||
if (!new File(partial, file.name).renameTo(target))
|
||||
throw new ExtractException("Could not move " + file.name + " into " + mapsFolder.getPath() + ".");
|
||||
|
||||
/* (the maps folder may be there, empty: the app makes it for adb) */
|
||||
if (!finished.isDirectory() && !finished.mkdirs())
|
||||
throw new ExtractException("Could not create " + finished + ".");
|
||||
for (Entry file : files) {
|
||||
File from = new File(partial, file.name);
|
||||
File to = new File(finished, file.name);
|
||||
|
||||
to.delete();
|
||||
if (!from.renameTo(to))
|
||||
throw new ExtractException("Could not move " + file.name + " into " + finished + ".");
|
||||
}
|
||||
partial.delete();
|
||||
}
|
||||
|
||||
/** a language's maps folder's language ("maps_it": "it"), else null */
|
||||
static String mapsLanguage(String name) {
|
||||
if (name.length() != 7 || !name.regionMatches(true, 0, "maps_", 0, 5))
|
||||
return null;
|
||||
String code = name.substring(5).toLowerCase(Locale.ROOT);
|
||||
return Character.isLetter(code.charAt(0)) && Character.isLetter(code.charAt(1)) ? code : null;
|
||||
}
|
||||
|
||||
/** No path, no . or .., and only printable ASCII that every file system takes as a plain name. */
|
||||
static boolean isPlainName(String name) {
|
||||
if (name == null || name.isEmpty() || name.equals(".") || name.equals(".."))
|
||||
return false;
|
||||
for (int index = 0; index < name.length(); index++) {
|
||||
char character = name.charAt(index);
|
||||
|
||||
if (character < 0x20 || character > 0x7E || "/\\:*?\"<>|".indexOf(character) >= 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ---------- the image */
|
||||
|
||||
private static long u16(byte[] bytes, int offset) {
|
||||
return (bytes[offset] & 0xFF) | (bytes[offset + 1] & 0xFF) << 8;
|
||||
}
|
||||
|
||||
private static long u32(byte[] bytes, int offset) {
|
||||
return u16(bytes, offset) | u16(bytes, offset + 2) << 16;
|
||||
}
|
||||
|
||||
private static boolean hasMagic(byte[] bytes, int offset) {
|
||||
for (int index = 0; index < MAGIC.length; index++) {
|
||||
if (bytes[offset + index] != MAGIC[index])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Fills buffer from the image at position; false if the image ends first. */
|
||||
private static boolean readFully(FileChannel image, ByteBuffer buffer, long position) throws IOException {
|
||||
while (buffer.hasRemaining()) {
|
||||
int count = image.read(buffer, position);
|
||||
|
||||
if (count <= 0)
|
||||
return false;
|
||||
position += count;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static byte[] readTable(FileChannel image, long partition, long sector, long size, String damaged)
|
||||
throws IOException {
|
||||
if (size == 0 || size > MAXIMUM_TABLE_SIZE)
|
||||
throw new ExtractException(damaged);
|
||||
ByteBuffer table = ByteBuffer.allocate((int) size);
|
||||
if (!readFully(image, table, partition + sector * SECTOR_SIZE))
|
||||
throw new ExtractException("Could not read the disc image (is it complete?).");
|
||||
return table.array();
|
||||
}
|
||||
|
||||
/* ---------- directory tables */
|
||||
|
||||
private static final class Walk {
|
||||
final byte[] table;
|
||||
final boolean directories;
|
||||
final BitSet visited = new BitSet();
|
||||
final List<Entry> entries = new ArrayList<>();
|
||||
int visits;
|
||||
boolean stopped;
|
||||
|
||||
Walk(byte[] table, boolean directories) {
|
||||
this.table = table;
|
||||
this.directories = directories;
|
||||
}
|
||||
}
|
||||
|
||||
/** The folders (or the files) of a table with plain names, in the tree's order. */
|
||||
private static List<Entry> walkTable(byte[] table, boolean directories) {
|
||||
Walk walk = new Walk(table, directories);
|
||||
|
||||
walkEntry(walk, 0, 0);
|
||||
return walk.entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* The subtree whose root entry is at offset: its left subtree, the
|
||||
* entry, its right subtree. A link to padding, past the table or back to
|
||||
* an entry already visited ends that branch.
|
||||
*/
|
||||
private static void walkEntry(Walk walk, int offset, int depth) {
|
||||
byte[] table = walk.table;
|
||||
|
||||
if (walk.stopped || depth > MAXIMUM_DEPTH)
|
||||
return;
|
||||
if (offset >= table.length || table.length - offset < ENTRY_FIXED_SIZE)
|
||||
return;
|
||||
int left = (int) u16(table, offset);
|
||||
int right = (int) u16(table, offset + 2);
|
||||
if (left == PADDING_LINK || walk.visited.get(offset / 4))
|
||||
return;
|
||||
walk.visited.set(offset / 4);
|
||||
if (walk.visits >= MAXIMUM_VISITS) {
|
||||
walk.stopped = true;
|
||||
return;
|
||||
}
|
||||
walk.visits++;
|
||||
|
||||
if (left != 0)
|
||||
walkEntry(walk, left * 4, depth + 1);
|
||||
int nameLength = table[offset + 13] & 0xFF;
|
||||
if (nameLength != 0 && nameLength <= table.length - offset - ENTRY_FIXED_SIZE)
|
||||
collect(walk, offset, nameLength);
|
||||
if (right != 0)
|
||||
walkEntry(walk, right * 4, depth + 1);
|
||||
}
|
||||
|
||||
private static void collect(Walk walk, int offset, int nameLength) {
|
||||
byte[] table = walk.table;
|
||||
boolean directory = (table[offset + 12] & ATTRIBUTE_DIRECTORY) != 0;
|
||||
|
||||
if (directory != walk.directories || walk.entries.size() >= MAXIMUM_ENTRIES)
|
||||
return;
|
||||
String name = new String(table, offset + ENTRY_FIXED_SIZE, nameLength, StandardCharsets.ISO_8859_1);
|
||||
if (!isPlainName(name))
|
||||
return;
|
||||
// (the destination's file system may ignore case)
|
||||
for (Entry entry : walk.entries) {
|
||||
if (entry.name.equalsIgnoreCase(name))
|
||||
return;
|
||||
}
|
||||
walk.entries.add(new Entry(name, u32(table, offset + 4), u32(table, offset + 8)));
|
||||
}
|
||||
|
||||
/* ---------- the loading screen's picture */
|
||||
|
||||
/**
|
||||
* The loading screen's picture out of a default.xbe, as the TGA the game
|
||||
* reads (uncompressed, 24 bits, rows from the bottom), or null. The
|
||||
* executable holds it, 320 by 240, as runs of 4-bit greys (a byte each:
|
||||
* the grey's high four bits in its low nibble, the run's length in its
|
||||
* high one) after the width and height as u32s: found by those two
|
||||
* numbers followed by runs that fill the picture exactly (a run of none,
|
||||
* or one past the picture's end, is not it).
|
||||
*/
|
||||
static byte[] loadingPicture(byte[] xbe) {
|
||||
int pixels = LOADING_WIDTH * LOADING_HEIGHT;
|
||||
byte[] greys = new byte[pixels];
|
||||
boolean found = false;
|
||||
|
||||
for (int at = 0; at + 8 <= xbe.length && !found; at++) {
|
||||
if (u32(xbe, at) != LOADING_WIDTH || u32(xbe, at + 4) != LOADING_HEIGHT)
|
||||
continue;
|
||||
int pixel = 0;
|
||||
for (int next = at + 8; next < xbe.length && pixel < pixels; next++) {
|
||||
int run = (xbe[next] & 0xFF) >> 4;
|
||||
|
||||
if (run == 0 || run > pixels - pixel)
|
||||
break;
|
||||
Arrays.fill(greys, pixel, pixel + run, (byte) ((xbe[next] & 0x0F) << 4));
|
||||
pixel += run;
|
||||
}
|
||||
found = pixel == pixels;
|
||||
}
|
||||
if (!found)
|
||||
return null;
|
||||
byte[] tga = new byte[TGA_HEADER_SIZE + pixels * 3];
|
||||
tga[2] = 2;
|
||||
tga[12] = (byte) (LOADING_WIDTH & 0xFF);
|
||||
tga[13] = (byte) (LOADING_WIDTH >> 8);
|
||||
tga[14] = (byte) (LOADING_HEIGHT & 0xFF);
|
||||
tga[15] = (byte) (LOADING_HEIGHT >> 8);
|
||||
tga[16] = 24;
|
||||
for (int y = 0; y < LOADING_HEIGHT; y++) {
|
||||
int row = (LOADING_HEIGHT - 1 - y) * LOADING_WIDTH;
|
||||
for (int x = 0; x < LOADING_WIDTH; x++) {
|
||||
int out = TGA_HEADER_SIZE + (y * LOADING_WIDTH + x) * 3;
|
||||
|
||||
tga[out] = tga[out + 1] = tga[out + 2] = greys[row + x];
|
||||
}
|
||||
}
|
||||
return tga;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes default.xbe's picture to output, if it has one; whether it did.
|
||||
* One that cannot be written whole is removed (the loading screen would
|
||||
* read past one cut short).
|
||||
*/
|
||||
private static boolean writeLoadingPicture(FileChannel image, long imageSize, long partition, Entry xbe,
|
||||
File output) {
|
||||
if (xbe == null || xbe.size <= 0 || xbe.size > MAXIMUM_XBE_SIZE
|
||||
|| partition + xbe.sector * SECTOR_SIZE + xbe.size > imageSize)
|
||||
return false;
|
||||
try {
|
||||
ByteBuffer bytes = ByteBuffer.allocate((int) xbe.size);
|
||||
if (!readFully(image, bytes, partition + xbe.sector * SECTOR_SIZE))
|
||||
return false;
|
||||
byte[] tga = loadingPicture(bytes.array());
|
||||
if (tga == null)
|
||||
return false;
|
||||
try (FileOutputStream stream = new FileOutputStream(output)) {
|
||||
stream.write(tga);
|
||||
}
|
||||
return true;
|
||||
} catch (IOException | OutOfMemoryError exception) {
|
||||
output.delete();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- the copy */
|
||||
|
||||
private static String readFailure(Entry file) {
|
||||
return "Could not read " + file.name + " from the disc image (is it complete?).";
|
||||
}
|
||||
|
||||
/** Copies one file of the image to output; returns the bytes copied of all the files so far. */
|
||||
private static long copyFile(FileChannel image, long partition, Entry file, File output, ByteBuffer buffer,
|
||||
long done, long total, Progress progress) throws IOException {
|
||||
String writeFailure = "Could not write " + output.getPath() + " (is the storage full?).";
|
||||
long position = partition + file.sector * SECTOR_SIZE;
|
||||
long remaining = file.size;
|
||||
FileOutputStream stream = null;
|
||||
|
||||
try {
|
||||
stream = new FileOutputStream(output);
|
||||
FileChannel channel = stream.getChannel();
|
||||
while (remaining > 0) {
|
||||
int count = (int) Math.min(remaining, COPY_CHUNK);
|
||||
boolean read;
|
||||
|
||||
buffer.clear();
|
||||
buffer.limit(count);
|
||||
try {
|
||||
read = readFully(image, buffer, position);
|
||||
} catch (IOException exception) {
|
||||
read = false;
|
||||
}
|
||||
if (!read)
|
||||
throw new ExtractException(readFailure(file));
|
||||
buffer.flip();
|
||||
while (buffer.hasRemaining()) {
|
||||
if (channel.write(buffer) <= 0)
|
||||
throw new ExtractException(writeFailure);
|
||||
}
|
||||
position += count;
|
||||
remaining -= count;
|
||||
done += count;
|
||||
if (progress != null)
|
||||
progress.report(file.name, done, total);
|
||||
}
|
||||
FileOutputStream closing = stream;
|
||||
stream = null;
|
||||
closing.close();
|
||||
} catch (ExtractException exception) {
|
||||
throw exception;
|
||||
} catch (IOException exception) {
|
||||
throw new ExtractException(writeFailure);
|
||||
} finally {
|
||||
if (stream != null) {
|
||||
try {
|
||||
stream.close();
|
||||
} catch (IOException ignored) {
|
||||
// (the copy failed already)
|
||||
}
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 12 KiB |
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Mjolnir VR</string>
|
||||
<string name="app_name">Halo</string>
|
||||
</resources>
|
||||
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 5.8 KiB |
@@ -46,8 +46,6 @@ unsigned int host_memory_watch_generation(unsigned int address, unsigned int siz
|
||||
unsigned int host_memory_watch_serial(void);
|
||||
void host_memory_watch_prepare_write(unsigned int address, unsigned int size);
|
||||
void host_memory_watch_forget(unsigned int address, unsigned int size);
|
||||
/* memory_watch_begin_frame (port/linux/src/platform.h) */
|
||||
void host_memory_watch_begin_frame(void);
|
||||
|
||||
/* ---------- SDL (guest/runtime/guest_sdl.c)
|
||||
|
||||
@@ -70,15 +68,8 @@ int host_sdl_gl_swap_window(unsigned int window);
|
||||
int host_sdl_poll_event(void *event);
|
||||
int host_sdl_set_clipboard_text(const char *text);
|
||||
void host_sdl_get_clipboard_text(char *buffer, unsigned int size);
|
||||
/* the keyboard's keys by name (the controls' bindings, xinput_sdl.c) */
|
||||
void host_sdl_scancode_name(int scancode, char *buffer, unsigned int size);
|
||||
int host_sdl_scancode_from_name(const char *name);
|
||||
int host_sdl_show_toast(const char *message, int duration, int gravity, int x, int y);
|
||||
int host_sdl_show_simple_message_box(unsigned int flags, const char *title, const char *message);
|
||||
/* SDL_ShowMessageBox of up to three buttons (SDL_MessageBoxData has not the
|
||||
guest's layout): the index of the one chosen, else -1 */
|
||||
int host_sdl_show_message_box(unsigned int flags, const char *title, const char *message, int default_index,
|
||||
const char *button0, const char *button1, const char *button2);
|
||||
int host_sdl_get_gamepads(unsigned int *ids, int capacity);
|
||||
unsigned int host_sdl_open_gamepad(unsigned int id);
|
||||
unsigned int host_sdl_gamepad_from_id(unsigned int id);
|
||||
@@ -86,16 +77,11 @@ int host_sdl_gamepad_axis(unsigned int gamepad, int axis);
|
||||
int host_sdl_gamepad_button(unsigned int gamepad, int button);
|
||||
int host_sdl_gamepad_type(unsigned int gamepad);
|
||||
int host_sdl_rumble_gamepad(unsigned int gamepad, unsigned int low, unsigned int high, unsigned int milliseconds);
|
||||
void host_sdl_close_gamepad(unsigned int gamepad);
|
||||
/* callback: void (*)(void *userdata, unsigned int stream, int additional, int total),
|
||||
called on the audio thread */
|
||||
unsigned int host_sdl_open_audio_stream(unsigned int device, const void *spec, unsigned int callback, unsigned int userdata);
|
||||
int host_sdl_put_audio_stream_data(unsigned int stream, const void *data, int length);
|
||||
int host_sdl_resume_audio_stream_device(unsigned int stream);
|
||||
/* (voice chat's microphone, a stream without a callback) */
|
||||
int host_sdl_get_audio_stream_data(unsigned int stream, void *data, int length);
|
||||
int host_sdl_get_audio_stream_available(unsigned int stream);
|
||||
void host_sdl_destroy_audio_stream(unsigned int stream);
|
||||
|
||||
/* ---------- OpenGL ES */
|
||||
|
||||
@@ -103,9 +89,8 @@ void host_sdl_destroy_audio_stream(unsigned int stream);
|
||||
void host_gl_get_string(unsigned int name, int index, char *buffer, unsigned int size);
|
||||
/* nonzero if the context supports the named extension */
|
||||
int host_gl_has_extension(const char *name);
|
||||
/* copies size bytes at offset of a GL buffer object into data, waiting for
|
||||
the GPU's writes to it */
|
||||
void host_gl_read_buffer(unsigned int buffer, unsigned int offset, unsigned int size, void *data);
|
||||
/* a 32-bit word of a GL buffer object, waiting for the GPU */
|
||||
unsigned int host_gl_read_buffer_word(unsigned int buffer, unsigned int offset);
|
||||
/* unsynchronized write into the buffer bound to target */
|
||||
void host_gl_buffer_write(unsigned int target, unsigned int offset, unsigned int size, const void *data);
|
||||
/* persistent, coherent storage for the buffer bound to target (0: the driver
|
||||
@@ -120,23 +105,6 @@ void host_gl_wait_frame(unsigned int slot);
|
||||
reads a snapshot once its frame is finished */
|
||||
void host_gl_counters_snapshot(unsigned int buffer, unsigned int size, unsigned int slot);
|
||||
int host_gl_counters_read(unsigned int slot, void *out, unsigned int size);
|
||||
/* the shader programs' worker (port/android/host/host_gl_worker.c), for
|
||||
port/linux/src/xgpu_program_cache.c: started on the game's thread with its
|
||||
context current (1: running); a program asked for (its binary tried first,
|
||||
else its sources compiled; urgent: a draw waits for it), a job's number or
|
||||
0; hurried along; polled (1 done: *program, its kept binary's size, the
|
||||
time it took; 0 not yet; -1 failed); its kept binary copied out; the job
|
||||
forgotten; how many jobs are not done; and a warm-up draw with a program on
|
||||
the calling thread's context */
|
||||
int host_gl_worker_start(int warm_up);
|
||||
unsigned int host_gl_program_request(int urgent, const char *vertex_source, const char *fragment_source,
|
||||
unsigned int binary_format, const void *binary, unsigned int binary_size, int keep_binary);
|
||||
void host_gl_program_hurry(unsigned int id);
|
||||
int host_gl_program_poll(unsigned int id, unsigned int *program, unsigned int *binary_size, unsigned int *microseconds);
|
||||
unsigned int host_gl_program_binary(unsigned int id, void *buffer, unsigned int size, unsigned int *format);
|
||||
void host_gl_program_release(unsigned int id);
|
||||
unsigned int host_gl_worker_waiting(void);
|
||||
void host_gl_program_warm_up(unsigned int program, int multiview);
|
||||
|
||||
/* ---------- OpenXR (port/android/host/host_xr.c; the structures are in
|
||||
halo_xr_abi.h) */
|
||||
@@ -148,9 +116,7 @@ headset before the game started, and set HALO_VR); 0 on failure */
|
||||
int host_xr_initialize(struct halo_xr_info *info, float wanted_refresh_rate);
|
||||
/* waits for the next frame and reports the predicted poses */
|
||||
int host_xr_begin_frame(struct halo_xr_frame *frame);
|
||||
/* copies a render target texture (0: clears) into a layer's image: 0 not
|
||||
copied, 1 copied with the GL state put back, 2 copied with the copy's GL
|
||||
state left (the deferred copies, host_xr.c), which the game sets again */
|
||||
/* copies a render target texture (0: clears) into a layer's image */
|
||||
int host_xr_copy_layer(int layer, unsigned int texture, int clear_alpha);
|
||||
/* the same for part of the texture: left, top, right, bottom, 0..1 from its
|
||||
top left */
|
||||
@@ -164,46 +130,25 @@ into a layer's image, opaque */
|
||||
int host_xr_copy_layer_array(int layer, unsigned int texture, int array_layer);
|
||||
/* darkens the eye images from their edges, strength 0..1 (0: off) */
|
||||
void host_xr_set_vignette(float strength);
|
||||
/* the refresh rates the headset offers (Hz, at most maximum of them; 0 when
|
||||
it lets none be chosen), and the one it runs at (0: unknown); and asking
|
||||
for the highest offered at or below wanted (0: the highest) */
|
||||
int host_xr_refresh_rates(float *rates, int maximum, float *current);
|
||||
void host_xr_set_refresh_rate(float wanted);
|
||||
/* the app's GPU time of a recent frame (ms; 0: the runtime does not tell
|
||||
it), for vr.graphics "auto" */
|
||||
float host_xr_gpu_time(void);
|
||||
|
||||
/* ---------- the voice chat (host_voice.c) */
|
||||
|
||||
/* opens the voices' playback, and the microphone if asked (else closes
|
||||
it): their volume, and the level (0..1 of full scale) the microphone's
|
||||
sound must reach to be sent */
|
||||
int host_voice_start(int microphone, float volume, float threshold);
|
||||
void host_voice_stop(void);
|
||||
/* the microphone's speech since asked: Opus packets, each after a byte of
|
||||
its length; returns the bytes */
|
||||
int host_voice_take_packets(void *buffer, int size);
|
||||
/* the microphone's level (0..1000) */
|
||||
int host_voice_level(void);
|
||||
/* a speaker's packet (sequence numbered), played at these gains */
|
||||
void host_voice_play(int id, int sequence, const void *data, int length, float gain_left, float gain_right);
|
||||
|
||||
/* ---------- Android */
|
||||
|
||||
/* the storage directories the port uses, copied into buffer */
|
||||
void host_android_path(int which, char *buffer, unsigned int size);
|
||||
|
||||
/* the edges where Android keeps its gestures, as left, top, right, bottom
|
||||
in pixels of the current orientation, into insets[4]; all 0 when unknown */
|
||||
void host_gesture_insets(int *insets);
|
||||
|
||||
/* ---------- the on-screen touch controls (host_touch.c) */
|
||||
|
||||
/* the overlay's controller: the SDL axes (left x, y, right x, y, left
|
||||
trigger, right trigger) and the SDL button bits, into state[7] */
|
||||
void host_touch_read(int *state);
|
||||
/* the overlay's view swipe, then its gyroscope turn, since the last read,
|
||||
into delta[4] */
|
||||
void host_touch_look_read(float *delta);
|
||||
/* port 0's motors, for the phone's vibration */
|
||||
void host_touch_rumble(unsigned int low, unsigned int high);
|
||||
/* tells the overlay when to show: touch_input.c's _touch_scene_* */
|
||||
void host_touch_scene(int scene);
|
||||
/* the game control on each of the 16 controller buttons (touch_game.c),
|
||||
for the overlay's labels */
|
||||
void host_touch_bindings(const int *controls);
|
||||
|
||||
/* ---------- the server browser's master servers (host_https.c) */
|
||||
|
||||
/* a GET of an https:// url (port/linux/src/master_list.c): 1 with the
|
||||
status, the headers ("Name: value" lines) and up to body_capacity bytes of
|
||||
the body (its size in body_size), else 0 and why in error */
|
||||
int host_https_get(const char *url, int *status, char *headers, int headers_size, char *body, int body_capacity,
|
||||
int *body_size, char *error, int error_size);
|
||||
|
||||
#endif
|
||||
@@ -39,8 +39,3 @@ void memory_watch_forget(void *address, unsigned long size)
|
||||
{
|
||||
host_memory_watch_forget((unsigned int)address, size);
|
||||
}
|
||||
|
||||
void memory_watch_begin_frame(void)
|
||||
{
|
||||
host_memory_watch_begin_frame();
|
||||
}
|
||||
@@ -39,19 +39,6 @@ const char *SDL_GetError(void)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
const char *SDL_GetScancodeName(SDL_Scancode scancode)
|
||||
{
|
||||
static __thread char buffer[64];
|
||||
|
||||
host_sdl_scancode_name((int)scancode, buffer, sizeof(buffer));
|
||||
return buffer;
|
||||
}
|
||||
|
||||
SDL_Scancode SDL_GetScancodeFromName(const char *name)
|
||||
{
|
||||
return (SDL_Scancode)host_sdl_scancode_from_name(name);
|
||||
}
|
||||
|
||||
Uint64 SDL_GetTicks(void)
|
||||
{
|
||||
return (Uint64)host_sdl_ticks();
|
||||
@@ -95,31 +82,6 @@ bool SDL_ShowSimpleMessageBox(SDL_MessageBoxFlags flags, const char *title, cons
|
||||
return host_sdl_show_simple_message_box((unsigned int)flags, title, message) != 0;
|
||||
}
|
||||
|
||||
/* (up to three buttons, their ids those of the guest's) */
|
||||
bool SDL_ShowMessageBox(const SDL_MessageBoxData *data, int *buttonid)
|
||||
{
|
||||
const char *labels[3] = { NULL, NULL, NULL };
|
||||
int default_index = -1;
|
||||
int index;
|
||||
int chosen;
|
||||
|
||||
if (!data || data->numbuttons < 1 || data->numbuttons > 3)
|
||||
return false;
|
||||
for (index = 0; index < data->numbuttons; index++)
|
||||
{
|
||||
labels[index] = data->buttons[index].text;
|
||||
if (data->buttons[index].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT)
|
||||
default_index = index;
|
||||
}
|
||||
chosen = host_sdl_show_message_box((unsigned int)data->flags, data->title, data->message, default_index,
|
||||
labels[0], labels[1], labels[2]);
|
||||
if (chosen < 0 || chosen >= data->numbuttons)
|
||||
return false;
|
||||
if (buttonid)
|
||||
*buttonid = data->buttons[chosen].buttonID;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDL_Delay(Uint32 milliseconds)
|
||||
{
|
||||
struct timespec duration;
|
||||
@@ -241,11 +203,6 @@ bool SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low, Uint16 high, Uint32 mil
|
||||
return host_sdl_rumble_gamepad((unsigned int)gamepad, low, high, milliseconds) != 0;
|
||||
}
|
||||
|
||||
void SDL_CloseGamepad(SDL_Gamepad *gamepad)
|
||||
{
|
||||
host_sdl_close_gamepad((unsigned int)gamepad);
|
||||
}
|
||||
|
||||
/* ---------- audio */
|
||||
|
||||
SDL_AudioStream *SDL_OpenAudioDeviceStream(SDL_AudioDeviceID device, const SDL_AudioSpec *spec,
|
||||
@@ -264,18 +221,3 @@ bool SDL_ResumeAudioStreamDevice(SDL_AudioStream *stream)
|
||||
{
|
||||
return host_sdl_resume_audio_stream_device((unsigned int)stream) != 0;
|
||||
}
|
||||
|
||||
int SDL_GetAudioStreamData(SDL_AudioStream *stream, void *data, int length)
|
||||
{
|
||||
return host_sdl_get_audio_stream_data((unsigned int)stream, data, length);
|
||||
}
|
||||
|
||||
int SDL_GetAudioStreamAvailable(SDL_AudioStream *stream)
|
||||
{
|
||||
return host_sdl_get_audio_stream_available((unsigned int)stream);
|
||||
}
|
||||
|
||||
void SDL_DestroyAudioStream(SDL_AudioStream *stream)
|
||||
{
|
||||
host_sdl_destroy_audio_stream((unsigned int)stream);
|
||||
}
|
||||
@@ -25,7 +25,6 @@ extern void (*__guest_init_end[])(void);
|
||||
void __guest_start(const struct halo_guest_boot *boot);
|
||||
void __guest_thread_start(unsigned int thread);
|
||||
unsigned int __guest_thread_attach(void);
|
||||
void __guest_thread_detach(void);
|
||||
void __guest_thread_initialize_main(void);
|
||||
|
||||
extern char **__environ;
|
||||
@@ -42,7 +41,6 @@ const struct halo_guest_header __guest_header =
|
||||
(uint32_t)__guest_start,
|
||||
(uint32_t)__guest_thread_start,
|
||||
(uint32_t)__guest_thread_attach,
|
||||
(uint32_t)__guest_thread_detach,
|
||||
(uint32_t)__guest_init_start,
|
||||
(uint32_t)__guest_init_end,
|
||||
};
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
GUEST_STRING.C
|
||||
|
||||
String functions faster than musl's generic C ones, which the guest takes
|
||||
in their place (tools/android_build.py MUSL_EXCLUDE). The renderer's state
|
||||
caches compare their keys with memcmp on every draw (the pixel shaders'
|
||||
keys, the vertex constants, the uniforms), and musl's compares a byte at a
|
||||
time.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
/* eight bytes at a time while they match (AArch64 loads them unaligned),
|
||||
then the bytes that differ, or the tail. no_builtin: clang would turn the
|
||||
loops back into a call to memcmp */
|
||||
__attribute__((no_builtin)) int memcmp(const void *left, const void *right, size_t size)
|
||||
{
|
||||
const unsigned char *l = left, *r = right;
|
||||
|
||||
for (; size >= 8; size -= 8, l += 8, r += 8)
|
||||
{
|
||||
uint64_t a, b;
|
||||
|
||||
__builtin_memcpy(&a, l, 8);
|
||||
__builtin_memcpy(&b, r, 8);
|
||||
if (a != b)
|
||||
break;
|
||||
}
|
||||
for (; size; size--, l++, r++)
|
||||
{
|
||||
if (*l != *r)
|
||||
return *l - *r;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -125,18 +125,6 @@ unsigned int __guest_thread_attach(void)
|
||||
return (unsigned int)thread;
|
||||
}
|
||||
|
||||
/* a host thread that ran guest code (__guest_thread_attach) is ending:
|
||||
its struct pthread goes */
|
||||
void __guest_thread_detach(void)
|
||||
{
|
||||
struct guest_thread *thread = (struct guest_thread *)host_get_tp();
|
||||
|
||||
if (!thread || thread == &main_thread)
|
||||
return;
|
||||
host_set_tp(0);
|
||||
thread_free(thread);
|
||||
}
|
||||
|
||||
int pthread_create(pthread_t *restrict result, const pthread_attr_t *restrict attributes,
|
||||
void *(*start)(void *), void *restrict argument)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,6 @@ port/android/include/halo_android_abi.h for the guest contract.
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "halo_android_abi.h"
|
||||
|
||||
@@ -36,21 +35,8 @@ Xbox window and the image's range at start-up, and hands out pages for
|
||||
everything else (the guest's malloc arenas, thread stacks, anonymous
|
||||
mappings) from pools of address space it reserves below 4 GB on demand. */
|
||||
|
||||
/* reserves the fixed ranges (the Xbox window and the image's) as early as
|
||||
the process allows: from JNI_OnLoad, before the Java side of the game's
|
||||
process allocates much (host_main.c); a failure is reported again by
|
||||
host_memory_initialize */
|
||||
void host_memory_reserve_early(void);
|
||||
/* takes the fixed ranges for the image; returns 0 on success */
|
||||
/* reserves the fixed ranges; returns 0 on success */
|
||||
int host_memory_initialize(uint32_t image_base, uint32_t image_size);
|
||||
/* 1 if the fixed ranges could not be reserved (something else holds them) */
|
||||
int host_memory_fixed_unavailable(void);
|
||||
/* lists the mappings below 4 GB in logcat and, if file is not NULL, in it */
|
||||
void host_memory_report_low_mappings(FILE *file);
|
||||
/* Makes the write tracking compare page contents instead of catching page
|
||||
faults (host_watch_hash.h), for when the app cannot receive its own
|
||||
SIGSEGV (ARM translation). Call before the guest starts. */
|
||||
void host_memory_watch_use_hashes(void);
|
||||
/* page-granular allocations below 4 GB; NULL on failure */
|
||||
void *host_low_map(size_t size, int protection);
|
||||
void host_low_unmap(void *address, size_t size);
|
||||
@@ -106,17 +92,6 @@ void *host_resolve_import(const char *name);
|
||||
/* ---------- SDL / GL (host_sdl.c, host_gl.c) */
|
||||
|
||||
void *host_gl_resolve(const char *name);
|
||||
int host_gl_quiet_trace_markers(void);
|
||||
/* the shader programs' worker (host_gl_worker.c; the guest's imports) */
|
||||
int host_gl_worker_start(int warm_up);
|
||||
uint32_t host_gl_program_request(int urgent, const char *vertex_source, const char *fragment_source,
|
||||
uint32_t binary_format, const void *binary, uint32_t binary_size, int keep_binary);
|
||||
void host_gl_program_hurry(uint32_t id);
|
||||
int host_gl_program_poll(uint32_t id, uint32_t *program, uint32_t *binary_size, uint32_t *microseconds);
|
||||
uint32_t host_gl_program_binary(uint32_t id, void *buffer, uint32_t size, uint32_t *format);
|
||||
void host_gl_program_release(uint32_t id);
|
||||
uint32_t host_gl_worker_waiting(void);
|
||||
void host_gl_program_warm_up(uint32_t program, int multiview);
|
||||
|
||||
/* ---------- VR (host_xr.c) */
|
||||
|
||||
|
||||
@@ -11,52 +11,8 @@ already have host types by then. Only strings need copying back.
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES3/gl32.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#include <dirent.h>
|
||||
#include <dlfcn.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Valve's Mesa (the Steam Frame's Lepton) writes a marker to the kernel's
|
||||
trace_marker around every flush and context switch, a couple of hundred a
|
||||
frame, whether or not anything traces. The descriptors it holds open on that
|
||||
file are pointed at /dev/null instead (not closed: a reused descriptor would
|
||||
take the markers elsewhere). After astromaddie/HaloCE-VR (CC0). Returns how
|
||||
many were. */
|
||||
int host_gl_quiet_trace_markers(void)
|
||||
{
|
||||
DIR *directory = opendir("/proc/self/fd");
|
||||
struct dirent *entry;
|
||||
int quieted = 0, null_fd;
|
||||
|
||||
if (!directory)
|
||||
return 0;
|
||||
null_fd = open("/dev/null", O_WRONLY | O_CLOEXEC);
|
||||
while (null_fd >= 0 && (entry = readdir(directory)) != NULL)
|
||||
{
|
||||
char link[64], target[256];
|
||||
ssize_t length;
|
||||
int fd = atoi(entry->d_name);
|
||||
|
||||
if (entry->d_name[0] < '0' || entry->d_name[0] > '9' || fd == null_fd)
|
||||
continue;
|
||||
snprintf(link, sizeof(link), "/proc/self/fd/%d", fd);
|
||||
length = readlink(link, target, sizeof(target) - 1);
|
||||
if (length <= 0)
|
||||
continue;
|
||||
target[length] = 0;
|
||||
if (strstr(target, "tracing/trace_marker") && dup3(null_fd, fd, O_CLOEXEC) == fd)
|
||||
quieted++;
|
||||
}
|
||||
if (null_fd >= 0)
|
||||
close(null_fd);
|
||||
closedir(directory);
|
||||
if (quieted)
|
||||
host_logf(HOST_LOG_INFO, "trace markers: %d descriptors to /dev/null", quieted);
|
||||
return quieted;
|
||||
}
|
||||
|
||||
void *host_gl_resolve(const char *name)
|
||||
{
|
||||
@@ -101,26 +57,25 @@ int host_gl_has_extension(const char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* copies size bytes of a buffer object (the snapshots of the visibility
|
||||
tests' counters, d3d8_gl.c); ES has no glGetBufferSubData, and the mapping
|
||||
it offers instead is a host pointer. Binds GL_COPY_READ_BUFFER, which the
|
||||
renderer uses only for its copies, and leaves it unbound. */
|
||||
void host_gl_read_buffer(uint32_t buffer, uint32_t offset, uint32_t size, void *data)
|
||||
/* one 32-bit word of a buffer object (the visibility test counters of
|
||||
d3d8_gl.c); ES has no glGetBufferSubData, and the mapping it offers
|
||||
instead is a host pointer */
|
||||
uint32_t host_gl_read_buffer_word(uint32_t buffer, uint32_t offset)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
GLint previous = 0;
|
||||
const void *mapping;
|
||||
|
||||
glBindBuffer(GL_COPY_READ_BUFFER, buffer);
|
||||
mapping = glMapBufferRange(GL_COPY_READ_BUFFER, offset, size, GL_MAP_READ_BIT);
|
||||
glGetIntegerv(GL_ATOMIC_COUNTER_BUFFER_BINDING, &previous);
|
||||
glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, buffer);
|
||||
mapping = glMapBufferRange(GL_ATOMIC_COUNTER_BUFFER, offset, sizeof(value), GL_MAP_READ_BIT);
|
||||
if (mapping)
|
||||
{
|
||||
memcpy(data, mapping, size);
|
||||
glUnmapBuffer(GL_COPY_READ_BUFFER);
|
||||
memcpy(&value, mapping, sizeof(value));
|
||||
glUnmapBuffer(GL_ATOMIC_COUNTER_BUFFER);
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(data, 0, size);
|
||||
}
|
||||
glBindBuffer(GL_COPY_READ_BUFFER, 0);
|
||||
glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, (GLuint)previous);
|
||||
return value;
|
||||
}
|
||||
|
||||
/* The visibility tests' counters (d3d8_gl.c), copied at the end of each
|
||||
@@ -133,13 +88,14 @@ half-drawn targets out of tile memory, for every lens flare. */
|
||||
static GLuint counter_snapshots[COUNTER_SNAPSHOTS];
|
||||
static uint32_t counter_snapshot_sizes[COUNTER_SNAPSHOTS];
|
||||
|
||||
/* (the copy bindings are left unbound after: the renderer binds them itself
|
||||
for each copy. Asking GL what they were would wait for Mesa's GL thread, on
|
||||
the Frame, to run everything queued) */
|
||||
void host_gl_counters_snapshot(uint32_t buffer, uint32_t size, uint32_t slot)
|
||||
{
|
||||
GLint read_binding = 0, write_binding = 0;
|
||||
|
||||
if (slot >= COUNTER_SNAPSHOTS || !buffer || !size)
|
||||
return;
|
||||
glGetIntegerv(GL_COPY_READ_BUFFER_BINDING, &read_binding);
|
||||
glGetIntegerv(GL_COPY_WRITE_BUFFER_BINDING, &write_binding);
|
||||
if (!counter_snapshots[slot])
|
||||
glGenBuffers(1, &counter_snapshots[slot]);
|
||||
glBindBuffer(GL_COPY_WRITE_BUFFER, counter_snapshots[slot]);
|
||||
@@ -152,17 +108,19 @@ void host_gl_counters_snapshot(uint32_t buffer, uint32_t size, uint32_t slot)
|
||||
glMemoryBarrier(GL_ATOMIC_COUNTER_BARRIER_BIT | GL_BUFFER_UPDATE_BARRIER_BIT);
|
||||
glBindBuffer(GL_COPY_READ_BUFFER, buffer);
|
||||
glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, size);
|
||||
glBindBuffer(GL_COPY_READ_BUFFER, 0);
|
||||
glBindBuffer(GL_COPY_WRITE_BUFFER, 0);
|
||||
glBindBuffer(GL_COPY_READ_BUFFER, (GLuint)read_binding);
|
||||
glBindBuffer(GL_COPY_WRITE_BUFFER, (GLuint)write_binding);
|
||||
}
|
||||
|
||||
/* copies a snapshot out; its frame must be finished (host_gl_wait_frame) */
|
||||
int host_gl_counters_read(uint32_t slot, void *out, uint32_t size)
|
||||
{
|
||||
GLint write_binding = 0;
|
||||
const void *mapping;
|
||||
|
||||
if (slot >= COUNTER_SNAPSHOTS || !counter_snapshots[slot] || size > counter_snapshot_sizes[slot])
|
||||
return 0;
|
||||
glGetIntegerv(GL_COPY_WRITE_BUFFER_BINDING, &write_binding);
|
||||
glBindBuffer(GL_COPY_WRITE_BUFFER, counter_snapshots[slot]);
|
||||
mapping = glMapBufferRange(GL_COPY_WRITE_BUFFER, 0, size, GL_MAP_READ_BIT);
|
||||
if (mapping)
|
||||
@@ -170,7 +128,7 @@ int host_gl_counters_read(uint32_t slot, void *out, uint32_t size)
|
||||
memcpy(out, mapping, size);
|
||||
glUnmapBuffer(GL_COPY_WRITE_BUFFER);
|
||||
}
|
||||
glBindBuffer(GL_COPY_WRITE_BUFFER, 0);
|
||||
glBindBuffer(GL_COPY_WRITE_BUFFER, (GLuint)write_binding);
|
||||
return mapping != NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,671 +0,0 @@
|
||||
/*
|
||||
HOST_GL_WORKER.C
|
||||
|
||||
The shader programs' worker (port/linux/src/xgpu_program_cache.c): a thread
|
||||
with a GL context of its own, sharing the game's objects, that makes the
|
||||
programs the game asks for while the game goes on drawing. The drivers
|
||||
compile a program the first time it is drawn with, 10 to 70 ms each on the
|
||||
Quest's, and the frame waited for it: in VR a frame shown late, the picture
|
||||
doubled as the head turns.
|
||||
|
||||
- host_gl_worker_start, on the game's thread with its context current:
|
||||
makes a context that shares the game's (surfaceless, or on a 1x1
|
||||
pbuffer) and the thread that keeps it current.
|
||||
- host_gl_program_request: a program of these sources, from their binary
|
||||
where one is given and the driver takes it, else compiled and linked
|
||||
(its binary kept for the cache's file). The sources and the binary are
|
||||
copied: the caller's may go at once. Urgent requests (a draw waits for
|
||||
them) go before the others (a map's programs made ready as it loads).
|
||||
- On the worker each program is linked, its samplers set to their units
|
||||
(as d3d8_gl.c sets them), drawn with once into a small target of its own
|
||||
(a degenerate triangle: the driver makes the variants it makes at a
|
||||
first draw now, not in the game's frame; "warm up"), and a fence put
|
||||
after it all.
|
||||
- host_gl_program_poll, on the game's thread: done once the fence has
|
||||
passed (GL's rule for an object made in one context and used in another:
|
||||
the work finished before the other binds it); then the program is the
|
||||
game's (a program name is the same in both contexts).
|
||||
|
||||
host_gl_program_warm_up draws once with a program on the calling thread's
|
||||
context instead (debug.shader_warm_up "load": on the game's, as a map
|
||||
loads), for comparing the two.
|
||||
*/
|
||||
|
||||
#include "host.h"
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include <GLES3/gl32.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#define JOB_BUCKETS 1024
|
||||
/* the warm-up's target, each way */
|
||||
#define WARM_UP_SIZE 16
|
||||
|
||||
enum
|
||||
{
|
||||
JOB_QUEUED,
|
||||
JOB_WORKING,
|
||||
JOB_DONE,
|
||||
JOB_FAILED,
|
||||
};
|
||||
|
||||
struct job
|
||||
{
|
||||
struct job *next_in_bucket;
|
||||
struct job *next_in_queue;
|
||||
uint32_t id;
|
||||
int urgent;
|
||||
char *sources[2];
|
||||
void *binary;
|
||||
uint32_t binary_size;
|
||||
uint32_t binary_format;
|
||||
int keep_binary;
|
||||
int state;
|
||||
/* the results */
|
||||
GLuint program;
|
||||
GLsync sync;
|
||||
int from_binary;
|
||||
void *kept_binary;
|
||||
uint32_t kept_size;
|
||||
uint32_t kept_format;
|
||||
uint32_t microseconds;
|
||||
};
|
||||
|
||||
/* a context's warm-up target: the eyes' kinds, one layer and two
|
||||
(multiview), RGBA8 with a depth and stencil buffer */
|
||||
struct warm_up_targets
|
||||
{
|
||||
int made;
|
||||
/* each kind's framebuffer complete */
|
||||
int complete[2];
|
||||
GLuint framebuffers[2];
|
||||
GLuint textures[4];
|
||||
GLuint vertex_array;
|
||||
GLuint counters;
|
||||
};
|
||||
|
||||
static struct
|
||||
{
|
||||
int started;
|
||||
int running;
|
||||
int warm_up;
|
||||
EGLDisplay display;
|
||||
EGLContext context;
|
||||
EGLSurface surface;
|
||||
pthread_t thread;
|
||||
pthread_mutex_t lock;
|
||||
pthread_cond_t wake;
|
||||
pthread_cond_t ready;
|
||||
struct job *buckets[JOB_BUCKETS];
|
||||
struct job *urgent_first, *urgent_last;
|
||||
struct job *later_first, *later_last;
|
||||
uint32_t next_id;
|
||||
uint32_t waiting;
|
||||
int failures_logged;
|
||||
PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC framebuffer_texture_multiview;
|
||||
struct warm_up_targets targets[2];
|
||||
} worker;
|
||||
|
||||
static uint64_t now_us(void)
|
||||
{
|
||||
struct timespec now;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
return (uint64_t)now.tv_sec * 1000000u + (uint64_t)now.tv_nsec / 1000u;
|
||||
}
|
||||
|
||||
/* ---------- the warm-up draw */
|
||||
|
||||
static int targets_make(struct warm_up_targets *targets)
|
||||
{
|
||||
GLint major = 0, minor = 0;
|
||||
int kind;
|
||||
|
||||
if (targets->made)
|
||||
return targets->made > 0;
|
||||
targets->made = -1;
|
||||
glGenTextures(4, targets->textures);
|
||||
glGenFramebuffers(2, targets->framebuffers);
|
||||
for (kind = 0; kind < 2; kind++)
|
||||
{
|
||||
GLenum target = kind ? GL_TEXTURE_2D_ARRAY : GL_TEXTURE_2D;
|
||||
|
||||
glBindTexture(target, targets->textures[kind * 2]);
|
||||
if (kind)
|
||||
glTexStorage3D(target, 1, GL_RGBA8, WARM_UP_SIZE, WARM_UP_SIZE, 2);
|
||||
else
|
||||
glTexStorage2D(target, 1, GL_RGBA8, WARM_UP_SIZE, WARM_UP_SIZE);
|
||||
glBindTexture(target, targets->textures[kind * 2 + 1]);
|
||||
if (kind)
|
||||
glTexStorage3D(target, 1, GL_DEPTH24_STENCIL8, WARM_UP_SIZE, WARM_UP_SIZE, 2);
|
||||
else
|
||||
glTexStorage2D(target, 1, GL_DEPTH24_STENCIL8, WARM_UP_SIZE, WARM_UP_SIZE);
|
||||
glBindTexture(target, 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, targets->framebuffers[kind]);
|
||||
if (kind)
|
||||
{
|
||||
if (!worker.framebuffer_texture_multiview)
|
||||
continue;
|
||||
worker.framebuffer_texture_multiview(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, targets->textures[2], 0, 0, 2);
|
||||
worker.framebuffer_texture_multiview(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, targets->textures[3], 0,
|
||||
0, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, targets->textures[0], 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, targets->textures[1], 0);
|
||||
}
|
||||
targets->complete[kind] = glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE;
|
||||
if (!targets->complete[kind])
|
||||
host_logf(HOST_LOG_WARN, "gl worker: the %s warm-up target is incomplete; no warm-up there",
|
||||
kind ? "multiview" : "plain");
|
||||
}
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glGenVertexArrays(1, &targets->vertex_array);
|
||||
/* (the visibility tests' programs count samples into binding 0) */
|
||||
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
||||
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
||||
if (major > 3 || (major == 3 && minor >= 1))
|
||||
{
|
||||
glGenBuffers(1, &targets->counters);
|
||||
glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, targets->counters);
|
||||
glBufferData(GL_ATOMIC_COUNTER_BUFFER, 64, NULL, GL_DYNAMIC_DRAW);
|
||||
glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, 0);
|
||||
}
|
||||
targets->made = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* one degenerate triangle with the program into the target of its kind,
|
||||
depth tested and blended as most of the game's draws are; the GL state it
|
||||
changes is left changed (the worker's context has no other use, and the
|
||||
game's sets it again: d3d8_host_state_changed) */
|
||||
static void warm_up_draw(struct warm_up_targets *targets, GLuint program, int multiview)
|
||||
{
|
||||
if (!targets_make(targets) || !targets->complete[multiview ? 1 : 0])
|
||||
return;
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, targets->framebuffers[multiview ? 1 : 0]);
|
||||
glViewport(0, 0, WARM_UP_SIZE, WARM_UP_SIZE);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glDepthMask(GL_TRUE);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBindVertexArray(targets->vertex_array);
|
||||
if (targets->counters)
|
||||
glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, targets->counters);
|
||||
glUseProgram(program);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
glUseProgram(0);
|
||||
glBindVertexArray(0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
void host_gl_program_warm_up(uint32_t program, int multiview)
|
||||
{
|
||||
if (!worker.running || !program)
|
||||
return;
|
||||
warm_up_draw(&worker.targets[0], program, multiview);
|
||||
}
|
||||
|
||||
/* ---------- the worker's jobs */
|
||||
|
||||
static struct job *job_find(uint32_t id)
|
||||
{
|
||||
struct job *job;
|
||||
|
||||
for (job = worker.buckets[id % JOB_BUCKETS]; job; job = job->next_in_bucket)
|
||||
{
|
||||
if (job->id == id)
|
||||
return job;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void queue_append(struct job *job)
|
||||
{
|
||||
struct job **first = job->urgent ? &worker.urgent_first : &worker.later_first;
|
||||
struct job **last = job->urgent ? &worker.urgent_last : &worker.later_last;
|
||||
|
||||
job->next_in_queue = NULL;
|
||||
if (*last)
|
||||
(*last)->next_in_queue = job;
|
||||
else
|
||||
*first = job;
|
||||
*last = job;
|
||||
}
|
||||
|
||||
static struct job *queue_take(void)
|
||||
{
|
||||
struct job *job = worker.urgent_first;
|
||||
|
||||
if (job)
|
||||
{
|
||||
worker.urgent_first = job->next_in_queue;
|
||||
if (!worker.urgent_first)
|
||||
worker.urgent_last = NULL;
|
||||
return job;
|
||||
}
|
||||
job = worker.later_first;
|
||||
if (job)
|
||||
{
|
||||
worker.later_first = job->next_in_queue;
|
||||
if (!worker.later_first)
|
||||
worker.later_last = NULL;
|
||||
}
|
||||
return job;
|
||||
}
|
||||
|
||||
static GLuint shader_compile(GLenum type, const char *source)
|
||||
{
|
||||
GLuint shader = glCreateShader(type);
|
||||
GLint status = 0;
|
||||
|
||||
glShaderSource(shader, 1, &source, NULL);
|
||||
glCompileShader(shader);
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
|
||||
if (!status)
|
||||
{
|
||||
char log[1024];
|
||||
|
||||
log[0] = 0;
|
||||
glGetShaderInfoLog(shader, sizeof(log), NULL, log);
|
||||
if (worker.failures_logged++ < 4)
|
||||
host_logf(HOST_LOG_WARN, "gl worker: a %s shader does not compile: %s",
|
||||
type == GL_VERTEX_SHADER ? "vertex" : "pixel", log);
|
||||
glDeleteShader(shader);
|
||||
return 0;
|
||||
}
|
||||
return shader;
|
||||
}
|
||||
|
||||
/* the job's program (outside the lock: only the worker touches a job
|
||||
being worked on) */
|
||||
static void job_work(struct job *job)
|
||||
{
|
||||
uint64_t start = now_us();
|
||||
GLuint program = 0;
|
||||
GLint status = 0;
|
||||
|
||||
if (job->binary && job->binary_size)
|
||||
{
|
||||
program = glCreateProgram();
|
||||
glProgramBinary(program, (GLenum)job->binary_format, job->binary, (GLsizei)job->binary_size);
|
||||
glGetProgramiv(program, GL_LINK_STATUS, &status);
|
||||
if (status)
|
||||
job->from_binary = 1;
|
||||
else
|
||||
{
|
||||
glDeleteProgram(program);
|
||||
program = 0;
|
||||
while (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!program && job->sources[0] && job->sources[1])
|
||||
{
|
||||
GLuint vertex = shader_compile(GL_VERTEX_SHADER, job->sources[0]);
|
||||
GLuint fragment = vertex ? shader_compile(GL_FRAGMENT_SHADER, job->sources[1]) : 0;
|
||||
|
||||
if (vertex && fragment)
|
||||
{
|
||||
program = glCreateProgram();
|
||||
glProgramParameteri(program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
|
||||
glAttachShader(program, vertex);
|
||||
glAttachShader(program, fragment);
|
||||
glLinkProgram(program);
|
||||
glGetProgramiv(program, GL_LINK_STATUS, &status);
|
||||
if (!status)
|
||||
{
|
||||
char log[1024];
|
||||
|
||||
log[0] = 0;
|
||||
glGetProgramInfoLog(program, sizeof(log), NULL, log);
|
||||
if (worker.failures_logged++ < 4)
|
||||
host_logf(HOST_LOG_WARN, "gl worker: a program does not link: %s", log);
|
||||
glDeleteProgram(program);
|
||||
program = 0;
|
||||
}
|
||||
}
|
||||
/* (attached, they go with the program) */
|
||||
if (vertex)
|
||||
glDeleteShader(vertex);
|
||||
if (fragment)
|
||||
glDeleteShader(fragment);
|
||||
if (program && job->keep_binary)
|
||||
{
|
||||
GLint length = 0;
|
||||
GLsizei written = 0;
|
||||
GLenum format = 0;
|
||||
|
||||
glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH, &length);
|
||||
if (length > 0 && (job->kept_binary = malloc((size_t)length)) != NULL)
|
||||
{
|
||||
glGetProgramBinary(program, length, &written, &format, job->kept_binary);
|
||||
if (written > 0 && written <= length)
|
||||
{
|
||||
job->kept_size = (uint32_t)written;
|
||||
job->kept_format = (uint32_t)format;
|
||||
}
|
||||
else
|
||||
{
|
||||
free(job->kept_binary);
|
||||
job->kept_binary = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (program)
|
||||
{
|
||||
int unit;
|
||||
|
||||
/* the samplers' units, as d3d8_gl.c's program_get sets them (a
|
||||
first draw with two kinds of sampler on one unit draws nothing) */
|
||||
glUseProgram(program);
|
||||
for (unit = 0; unit < 4; unit++)
|
||||
{
|
||||
char name[8];
|
||||
|
||||
snprintf(name, sizeof(name), "tex%d", unit);
|
||||
glUniform1i(glGetUniformLocation(program, name), unit);
|
||||
}
|
||||
glUseProgram(0);
|
||||
if (worker.warm_up)
|
||||
warm_up_draw(&worker.targets[1], program,
|
||||
job->sources[0] && strstr(job->sources[0], "GL_OVR_multiview") != NULL);
|
||||
job->sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
}
|
||||
glFlush();
|
||||
job->program = program;
|
||||
job->microseconds = (uint32_t)(now_us() - start);
|
||||
}
|
||||
|
||||
static void *worker_main(void *unused)
|
||||
{
|
||||
(void)unused;
|
||||
if (!eglMakeCurrent(worker.display, worker.surface, worker.surface, worker.context))
|
||||
{
|
||||
host_logf(HOST_LOG_ERROR, "gl worker: its context cannot be made current (0x%x)", eglGetError());
|
||||
pthread_mutex_lock(&worker.lock);
|
||||
worker.started = -1;
|
||||
pthread_cond_broadcast(&worker.ready);
|
||||
pthread_mutex_unlock(&worker.lock);
|
||||
return NULL;
|
||||
}
|
||||
pthread_mutex_lock(&worker.lock);
|
||||
worker.started = 1;
|
||||
pthread_cond_broadcast(&worker.ready);
|
||||
for (;;)
|
||||
{
|
||||
struct job *job;
|
||||
|
||||
while ((job = queue_take()) == NULL)
|
||||
pthread_cond_wait(&worker.wake, &worker.lock);
|
||||
job->state = JOB_WORKING;
|
||||
pthread_mutex_unlock(&worker.lock);
|
||||
job_work(job);
|
||||
pthread_mutex_lock(&worker.lock);
|
||||
free(job->binary);
|
||||
job->binary = NULL;
|
||||
free(job->sources[0]);
|
||||
free(job->sources[1]);
|
||||
job->sources[0] = job->sources[1] = NULL;
|
||||
job->state = job->program ? JOB_DONE : JOB_FAILED;
|
||||
worker.waiting--;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ---------- the game's */
|
||||
|
||||
int host_gl_worker_start(int warm_up)
|
||||
{
|
||||
EGLDisplay display = eglGetCurrentDisplay();
|
||||
EGLContext shared = eglGetCurrentContext();
|
||||
EGLint config_id = 0, count = 0, version = 3;
|
||||
EGLint config_attributes[] = { EGL_CONFIG_ID, 0, EGL_NONE };
|
||||
EGLint context_attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE };
|
||||
EGLConfig config;
|
||||
const char *extensions;
|
||||
int started;
|
||||
|
||||
if (worker.running)
|
||||
return 1;
|
||||
if (worker.started)
|
||||
return 0;
|
||||
worker.warm_up = warm_up;
|
||||
if (display == EGL_NO_DISPLAY || shared == EGL_NO_CONTEXT)
|
||||
{
|
||||
host_logf(HOST_LOG_WARN, "gl worker: no current context to share");
|
||||
worker.started = -1;
|
||||
return 0;
|
||||
}
|
||||
eglQueryContext(display, shared, EGL_CONFIG_ID, &config_id);
|
||||
eglQueryContext(display, shared, EGL_CONTEXT_CLIENT_VERSION, &version);
|
||||
config_attributes[1] = config_id;
|
||||
if (!eglChooseConfig(display, config_attributes, &config, 1, &count) || count != 1)
|
||||
{
|
||||
host_logf(HOST_LOG_WARN, "gl worker: the game's context's configuration is not found");
|
||||
worker.started = -1;
|
||||
return 0;
|
||||
}
|
||||
context_attributes[1] = version;
|
||||
extensions = eglQueryString(display, EGL_EXTENSIONS);
|
||||
worker.surface = EGL_NO_SURFACE;
|
||||
if (!extensions || !strstr(extensions, "EGL_KHR_surfaceless_context"))
|
||||
{
|
||||
/* (a 1x1 pbuffer to be current on, of a configuration that has one) */
|
||||
EGLint pbuffer_config[] = { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR, EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
|
||||
EGL_NONE };
|
||||
EGLint pbuffer_size[] = { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE };
|
||||
|
||||
if (!eglChooseConfig(display, pbuffer_config, &config, 1, &count) || count != 1 ||
|
||||
(worker.surface = eglCreatePbufferSurface(display, config, pbuffer_size)) == EGL_NO_SURFACE)
|
||||
{
|
||||
host_logf(HOST_LOG_WARN, "gl worker: neither surfaceless contexts nor a pbuffer");
|
||||
worker.started = -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
worker.context = eglCreateContext(display, config, shared, context_attributes);
|
||||
if (worker.context == EGL_NO_CONTEXT)
|
||||
{
|
||||
host_logf(HOST_LOG_WARN, "gl worker: no context sharing the game's (0x%x)", eglGetError());
|
||||
worker.started = -1;
|
||||
return 0;
|
||||
}
|
||||
worker.display = display;
|
||||
worker.next_id = 1;
|
||||
worker.framebuffer_texture_multiview = (PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC)eglGetProcAddress(
|
||||
"glFramebufferTextureMultiviewOVR");
|
||||
pthread_mutex_init(&worker.lock, NULL);
|
||||
pthread_cond_init(&worker.wake, NULL);
|
||||
pthread_cond_init(&worker.ready, NULL);
|
||||
if (pthread_create(&worker.thread, NULL, worker_main, NULL) != 0)
|
||||
{
|
||||
eglDestroyContext(display, worker.context);
|
||||
worker.started = -1;
|
||||
return 0;
|
||||
}
|
||||
pthread_mutex_lock(&worker.lock);
|
||||
while (!worker.started)
|
||||
pthread_cond_wait(&worker.ready, &worker.lock);
|
||||
started = worker.started > 0;
|
||||
pthread_mutex_unlock(&worker.lock);
|
||||
worker.running = started;
|
||||
/* (Mesa's trace markers, for the new context's too: host_gl.c) */
|
||||
if (started)
|
||||
host_gl_quiet_trace_markers();
|
||||
host_logf(HOST_LOG_INFO, "gl worker: %s (ES %d, %s%s)", started ? "running" : "failed", (int)version,
|
||||
worker.surface == EGL_NO_SURFACE ? "surfaceless" : "on a pbuffer", warm_up ? ", programs warmed up" : "");
|
||||
return started;
|
||||
}
|
||||
|
||||
uint32_t host_gl_program_request(int urgent, const char *vertex_source, const char *fragment_source,
|
||||
uint32_t binary_format, const void *binary, uint32_t binary_size, int keep_binary)
|
||||
{
|
||||
struct job *job;
|
||||
uint32_t id;
|
||||
|
||||
if (!worker.running)
|
||||
return 0;
|
||||
job = calloc(1, sizeof(*job));
|
||||
if (!job)
|
||||
return 0;
|
||||
job->urgent = urgent != 0;
|
||||
job->keep_binary = keep_binary != 0;
|
||||
job->sources[0] = vertex_source ? strdup(vertex_source) : NULL;
|
||||
job->sources[1] = fragment_source ? strdup(fragment_source) : NULL;
|
||||
if (binary && binary_size && (job->binary = malloc(binary_size)) != NULL)
|
||||
{
|
||||
memcpy(job->binary, binary, binary_size);
|
||||
job->binary_size = binary_size;
|
||||
job->binary_format = binary_format;
|
||||
}
|
||||
pthread_mutex_lock(&worker.lock);
|
||||
id = job->id = worker.next_id++;
|
||||
if (!worker.next_id)
|
||||
worker.next_id = 1;
|
||||
job->state = JOB_QUEUED;
|
||||
job->next_in_bucket = worker.buckets[id % JOB_BUCKETS];
|
||||
worker.buckets[id % JOB_BUCKETS] = job;
|
||||
queue_append(job);
|
||||
worker.waiting++;
|
||||
pthread_cond_signal(&worker.wake);
|
||||
pthread_mutex_unlock(&worker.lock);
|
||||
return id;
|
||||
}
|
||||
|
||||
/* a queued job a draw now waits for: before the others */
|
||||
void host_gl_program_hurry(uint32_t id)
|
||||
{
|
||||
struct job *job, **link;
|
||||
|
||||
if (!worker.running)
|
||||
return;
|
||||
pthread_mutex_lock(&worker.lock);
|
||||
job = job_find(id);
|
||||
if (job && job->state == JOB_QUEUED && !job->urgent)
|
||||
{
|
||||
for (link = &worker.later_first; *link; link = &(*link)->next_in_queue)
|
||||
{
|
||||
if (*link == job)
|
||||
{
|
||||
struct job *previous = NULL, *walk;
|
||||
|
||||
*link = job->next_in_queue;
|
||||
/* (the last of the later queue found again) */
|
||||
for (walk = worker.later_first; walk; walk = walk->next_in_queue)
|
||||
previous = walk;
|
||||
worker.later_last = previous;
|
||||
job->urgent = 1;
|
||||
queue_append(job);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&worker.lock);
|
||||
}
|
||||
|
||||
int host_gl_program_poll(uint32_t id, uint32_t *program, uint32_t *binary_size, uint32_t *microseconds)
|
||||
{
|
||||
struct job *job;
|
||||
int result = 0;
|
||||
|
||||
if (!worker.running)
|
||||
return -1;
|
||||
pthread_mutex_lock(&worker.lock);
|
||||
job = job_find(id);
|
||||
if (!job || job->state == JOB_FAILED)
|
||||
result = -1;
|
||||
else if (job->state == JOB_DONE)
|
||||
{
|
||||
/* (the fence passed: everything the worker did with the program is
|
||||
done, and this context may use it) */
|
||||
if (job->sync)
|
||||
{
|
||||
GLenum waited = glClientWaitSync(job->sync, 0, 0);
|
||||
|
||||
if (waited == GL_ALREADY_SIGNALED || waited == GL_CONDITION_SATISFIED || waited == GL_WAIT_FAILED)
|
||||
{
|
||||
glDeleteSync(job->sync);
|
||||
job->sync = NULL;
|
||||
}
|
||||
}
|
||||
if (!job->sync)
|
||||
{
|
||||
*program = job->program;
|
||||
*binary_size = job->kept_size;
|
||||
*microseconds = job->microseconds;
|
||||
result = 1;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&worker.lock);
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t host_gl_program_binary(uint32_t id, void *buffer, uint32_t size, uint32_t *format)
|
||||
{
|
||||
struct job *job;
|
||||
uint32_t copied = 0;
|
||||
|
||||
if (!worker.running)
|
||||
return 0;
|
||||
pthread_mutex_lock(&worker.lock);
|
||||
job = job_find(id);
|
||||
if (job && job->state == JOB_DONE && job->kept_binary && size >= job->kept_size)
|
||||
{
|
||||
memcpy(buffer, job->kept_binary, job->kept_size);
|
||||
*format = job->kept_format;
|
||||
copied = job->kept_size;
|
||||
}
|
||||
pthread_mutex_unlock(&worker.lock);
|
||||
return copied;
|
||||
}
|
||||
|
||||
/* forgets a job (its program stays: the game's); a job still queued or
|
||||
being worked on is let go when it is done */
|
||||
void host_gl_program_release(uint32_t id)
|
||||
{
|
||||
struct job *job, **link;
|
||||
|
||||
if (!worker.running)
|
||||
return;
|
||||
pthread_mutex_lock(&worker.lock);
|
||||
for (link = &worker.buckets[id % JOB_BUCKETS]; (job = *link) != NULL; link = &job->next_in_bucket)
|
||||
{
|
||||
if (job->id != id)
|
||||
continue;
|
||||
if (job->state == JOB_QUEUED || job->state == JOB_WORKING)
|
||||
break;
|
||||
*link = job->next_in_bucket;
|
||||
if (job->sync)
|
||||
glDeleteSync(job->sync);
|
||||
free(job->kept_binary);
|
||||
free(job);
|
||||
break;
|
||||
}
|
||||
pthread_mutex_unlock(&worker.lock);
|
||||
}
|
||||
|
||||
uint32_t host_gl_worker_waiting(void)
|
||||
{
|
||||
uint32_t waiting;
|
||||
|
||||
if (!worker.running)
|
||||
return 0;
|
||||
pthread_mutex_lock(&worker.lock);
|
||||
waiting = worker.waiting;
|
||||
pthread_mutex_unlock(&worker.lock);
|
||||
return waiting;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
HOST_HTTPS.C
|
||||
|
||||
The server browser's requests to the master servers (host_https_get,
|
||||
port/android/guest/runtime/guest_host.h; port/linux/src/master_list.c), made
|
||||
in the host with the desktop's HTTPS client (port/linux/src/posix_update.c's
|
||||
update_https_request, Mbed TLS, the system's certificate authorities): the
|
||||
guest has no TLS of its own, and its memory is the host's to read and write.
|
||||
*/
|
||||
|
||||
#include "host.h"
|
||||
#include "../../linux/src/update.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int host_https_get(const char *url, int *status, char *headers, int headers_size, char *body, int body_capacity,
|
||||
int *body_size, char *error, int error_size)
|
||||
{
|
||||
struct update_response response;
|
||||
|
||||
*status = 0;
|
||||
*body_size = 0;
|
||||
if (!update_https_request("GET", url, NULL, NULL, 0, (unsigned long)body_capacity, &response, error, error_size))
|
||||
return 0;
|
||||
*status = response.status;
|
||||
snprintf(headers, (size_t)headers_size, "%s", response.headers);
|
||||
if (response.body_size > (unsigned long)body_capacity)
|
||||
response.body_size = (unsigned long)body_capacity;
|
||||
memcpy(body, response.body, response.body_size);
|
||||
*body_size = (int)response.body_size;
|
||||
free(response.body);
|
||||
return 1;
|
||||
}
|
||||
@@ -25,14 +25,12 @@ that runs here.
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <android/log.h>
|
||||
#include <jni.h>
|
||||
#include <errno.h>
|
||||
#include <ftw.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/system_properties.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
@@ -65,7 +63,7 @@ void host_fatal(const char *format, ...)
|
||||
vsnprintf(message, sizeof(message), format, arguments);
|
||||
va_end(arguments);
|
||||
__android_log_write(ANDROID_LOG_FATAL, "halo", message);
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Mjolnir VR", message, NULL);
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Halo", message, NULL);
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@@ -92,8 +90,6 @@ int host_errno(void)
|
||||
|
||||
static char data_root[512];
|
||||
static char save_root[512];
|
||||
/* where a device that empties the app's folders keeps the game's data */
|
||||
#define SHARED_DATA_ROOT "/home/steamos/Documents/RingfallMjolnirVR"
|
||||
|
||||
void host_android_path(int which, char *buffer, uint32_t size)
|
||||
{
|
||||
@@ -139,52 +135,6 @@ struct environment
|
||||
int count;
|
||||
};
|
||||
|
||||
/* asks the activity for Android's system gesture insets via JNI
|
||||
(HaloActivity.getSystemGestureInsetsPixels); the guest calls it at every
|
||||
finger down because the insets change when the phone rotates; the method is
|
||||
found on the activity's own class because the game's native thread has the
|
||||
system's class loader, which does not know the app's classes; a change is
|
||||
logged so the log shows the value the game works with; all 0 on any failure
|
||||
(the touch controls then use the whole screen) */
|
||||
void host_gesture_insets(int *insets)
|
||||
{
|
||||
static int logged[4] = { -1, -1, -1, -1 };
|
||||
JNIEnv *env = (JNIEnv *)SDL_GetAndroidJNIEnv();
|
||||
jobject activity = (jobject)SDL_GetAndroidActivity();
|
||||
jint values[4] = { 0, 0, 0, 0 };
|
||||
int index;
|
||||
|
||||
if (env && activity)
|
||||
{
|
||||
jclass activity_class = (*env)->GetObjectClass(env, activity);
|
||||
jmethodID method = activity_class ? (*env)->GetMethodID(env, activity_class, "getSystemGestureInsetsPixels", "()[I") : NULL;
|
||||
jintArray array = method ? (jintArray)(*env)->CallObjectMethod(env, activity, method) : NULL;
|
||||
|
||||
if (array && !(*env)->ExceptionCheck(env) && (*env)->GetArrayLength(env, array) == 4)
|
||||
(*env)->GetIntArrayRegion(env, array, 0, 4, values);
|
||||
/* a Java exception left pending would break the next JNI call of the
|
||||
thread, and a failed read must leave zeros */
|
||||
if ((*env)->ExceptionCheck(env))
|
||||
{
|
||||
(*env)->ExceptionClear(env);
|
||||
for (index = 0; index < 4; index++)
|
||||
values[index] = 0;
|
||||
}
|
||||
if (array)
|
||||
(*env)->DeleteLocalRef(env, array);
|
||||
if (activity_class)
|
||||
(*env)->DeleteLocalRef(env, activity_class);
|
||||
(*env)->DeleteLocalRef(env, activity);
|
||||
}
|
||||
for (index = 0; index < 4; index++)
|
||||
insets[index] = (int)values[index];
|
||||
if (memcmp(logged, insets, sizeof(logged)))
|
||||
{
|
||||
memcpy(logged, insets, sizeof(logged));
|
||||
host_logf(HOST_LOG_INFO, "system gesture insets %d,%d,%d,%d", insets[0], insets[1], insets[2], insets[3]);
|
||||
}
|
||||
}
|
||||
|
||||
static void environment_set(struct environment *environment, const char *name, const char *value)
|
||||
{
|
||||
size_t length = strlen(name);
|
||||
@@ -253,37 +203,6 @@ static double config_number(const char *path, const char *key, double fallback)
|
||||
return value;
|
||||
}
|
||||
|
||||
/* a boolean setting of config.toml (a dotted name), or otherwise when the
|
||||
file, the setting or a boolean is missing */
|
||||
static int config_boolean_or(const char *path, const char *name, int otherwise)
|
||||
{
|
||||
toml_result_t result = toml_parse_file_ex(path);
|
||||
int value = otherwise;
|
||||
|
||||
if (!result.ok)
|
||||
return otherwise;
|
||||
{
|
||||
toml_datum_t datum = toml_seek(result.toptab, name);
|
||||
|
||||
if (datum.type == TOML_BOOLEAN)
|
||||
value = datum.u.boolean ? 1 : 0;
|
||||
}
|
||||
toml_free(result);
|
||||
return value;
|
||||
}
|
||||
|
||||
/* Whether the app runs through an ARM translator. The x86 emulator runs the
|
||||
app's ARM code through one, which ro.dalvik.vm.native.bridge names; it
|
||||
cannot deliver the page faults of the write tracking to the app
|
||||
(host_memory.c). */
|
||||
static int native_bridge_active(void)
|
||||
{
|
||||
char value[PROP_VALUE_MAX] = "";
|
||||
|
||||
__system_property_get("ro.dalvik.vm.native.bridge", value);
|
||||
return value[0] && strcmp(value, "0") != 0;
|
||||
}
|
||||
|
||||
/* POSIX TZ for the current local offset (the guest's musl has no zone
|
||||
database) */
|
||||
static void time_zone(char *buffer, size_t size)
|
||||
@@ -336,11 +255,6 @@ static uint32_t make_boot(const struct environment *environment)
|
||||
|
||||
#define MAIN_STACK_SIZE (16 * 1024 * 1024)
|
||||
|
||||
/* the thread that runs the game: passes the display and its density, the
|
||||
time zone and the data and save folders to the guest through its
|
||||
environment, chooses the write tracking (page protection, or page hashes when
|
||||
translated or when debug.memory_watch is false), and runs the guest's main;
|
||||
never returns normally */
|
||||
static void *game_main(void *unused)
|
||||
{
|
||||
struct environment environment = { { 0 }, 0 };
|
||||
@@ -355,12 +269,6 @@ static void *game_main(void *unused)
|
||||
external = SDL_GetAndroidExternalStoragePath();
|
||||
if (!external)
|
||||
host_fatal("Android storage is unavailable: %s", SDL_GetError());
|
||||
/* the Steam Frame: Lepton empties the app's own folders whenever it
|
||||
starts again; the game's data lives in the SteamOS user's Documents
|
||||
instead, whenever they can be written (port/android/STEAM_FRAME.md; the
|
||||
same choice as LauncherActivity's, which makes the folder) */
|
||||
if (access(SHARED_DATA_ROOT, W_OK) == 0)
|
||||
external = SHARED_DATA_ROOT;
|
||||
snprintf(data_root, sizeof(data_root), "%s", external);
|
||||
snprintf(save_root, sizeof(save_root), "%s/save", external);
|
||||
/* readable by adb (the shell user), for managing saves */
|
||||
@@ -376,7 +284,7 @@ static void *game_main(void *unused)
|
||||
}
|
||||
if (!directory_has_maps(data_root))
|
||||
{
|
||||
host_fatal("The game data was not found.\n\nCopy the PAL game data (build 01.01.14.2342), "
|
||||
host_fatal("The Halo game data was not found.\n\nCopy the PAL game data (build 01.01.14.2342), "
|
||||
"the folder that contains maps, into\n%s\nor import it from the launcher screen.", data_root);
|
||||
}
|
||||
|
||||
@@ -385,68 +293,18 @@ static void *game_main(void *unused)
|
||||
environment_set(&environment, "HALO_SAVE_ROOT", save_root);
|
||||
time_zone(zone, sizeof(zone));
|
||||
environment_set(&environment, "TZ", zone);
|
||||
/* internet play's MQTT brokers (network.brokers_file): the APK's list,
|
||||
written beside config.toml at each start, as a desktop update replaces
|
||||
the file beside its game */
|
||||
{
|
||||
size_t brokers_size = 0;
|
||||
void *brokers = SDL_LoadFile("brokers.txt", &brokers_size);
|
||||
|
||||
snprintf(path, sizeof(path), "%s/brokers.txt", data_root);
|
||||
if (!brokers || !SDL_SaveFile(path, brokers, brokers_size))
|
||||
host_logf(HOST_LOG_ERROR, "cannot write %s: %s", path, SDL_GetError());
|
||||
SDL_free(brokers);
|
||||
}
|
||||
snprintf(path, sizeof(path), "%s/config.toml", data_root);
|
||||
|
||||
image = SDL_LoadFile("halo_guest.elf", &image_size);
|
||||
if (!image)
|
||||
host_fatal("cannot read the game image from the APK: %s", SDL_GetError());
|
||||
if (host_load_image(image, image_size) != 0)
|
||||
{
|
||||
FILE *report;
|
||||
|
||||
if (!host_memory_fixed_unavailable())
|
||||
host_fatal("cannot load the game image; see logcat (tag \"halo\") for details");
|
||||
|
||||
snprintf(path, sizeof(path), "%s/memory_map.txt", data_root);
|
||||
report = fopen(path, "w");
|
||||
host_memory_report_low_mappings(report);
|
||||
if (report)
|
||||
fclose(report);
|
||||
host_fatal("The game cannot start: the memory it needs at 0x80000000 is taken by Android's "
|
||||
"Java runtime on this device.\n\nRestarting the device may help. Please report it with "
|
||||
"memory_map.txt from\n%s\n(or adb logcat -s halo).", data_root);
|
||||
}
|
||||
host_fatal("cannot load the game image; see logcat (tag \"halo\") for details");
|
||||
SDL_free(image);
|
||||
|
||||
/* after the image, whose loading reserves the guest's fixed address
|
||||
ranges: the headset's runtime, loaded by the probe, maps its libraries
|
||||
wherever there is room, the Xbox window at 0x80000000 included */
|
||||
snprintf(path, sizeof(path), "%s/config.toml", data_root);
|
||||
{
|
||||
/* (debug.gl_thread: Mesa's GL thread on or off, as the driver's
|
||||
mesa_glthread, before the GL context is made; -1 leaves it be) */
|
||||
double gl_thread = config_number(path, "debug.gl_thread", -1.0);
|
||||
|
||||
if (gl_thread >= 0.0)
|
||||
{
|
||||
setenv("mesa_glthread", gl_thread != 0.0 ? "true" : "false", 1);
|
||||
host_logf(HOST_LOG_INFO, "Mesa's GL thread %s (debug.gl_thread)", gl_thread != 0.0 ? "on" : "off");
|
||||
}
|
||||
}
|
||||
{
|
||||
/* (debug.xr_deferred_copies: the headset's layer copies deferred,
|
||||
host_xr.c, or one by one; -1 as the runtime has it, deferred on
|
||||
SteamVR) */
|
||||
double deferred = config_number(path, "debug.xr_deferred_copies", -1.0);
|
||||
|
||||
if (deferred >= 0.0)
|
||||
setenv("HALO_XR_DEFERRED", deferred != 0.0 ? "1" : "0", 1);
|
||||
}
|
||||
/* (vr.log_performance: the compositor's counters too, host_xr.c) */
|
||||
if (config_boolean_or(path, "vr.log_performance", 0))
|
||||
setenv("HALO_XR_LOG_PERFORMANCE", "1", 1);
|
||||
{
|
||||
int eye_width, eye_height;
|
||||
|
||||
@@ -471,7 +329,6 @@ static void *game_main(void *unused)
|
||||
(landscape) unless display.screen_width says otherwise (d3d8_gl.c) */
|
||||
const SDL_DisplayMode *mode;
|
||||
char width[16];
|
||||
char text_density[16];
|
||||
|
||||
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
||||
mode = SDL_GetDesktopDisplayMode(SDL_GetPrimaryDisplay());
|
||||
@@ -484,18 +341,6 @@ static void *game_main(void *unused)
|
||||
environment_set(&environment, "HALO_DISPLAY_WIDTH", width);
|
||||
host_logf(HOST_LOG_INFO, "display %dx%d: rendering %sx480", mode->w, mode->h, width);
|
||||
}
|
||||
{
|
||||
/* dp for the touch controls (port/linux/src/touch_input.c): SDL
|
||||
gives Android's densityDpi / 160 */
|
||||
float density = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
||||
|
||||
if (density > 0.0f)
|
||||
{
|
||||
snprintf(text_density, sizeof(text_density), "%g", density);
|
||||
environment_set(&environment, "HALO_DISPLAY_DENSITY", text_density);
|
||||
host_logf(HOST_LOG_INFO, "display density %s", text_density);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,42 +350,16 @@ static void *game_main(void *unused)
|
||||
if (config_sample_seconds(path, seconds, sizeof(seconds)))
|
||||
host_debug_start_sampler(seconds);
|
||||
}
|
||||
if (native_bridge_active())
|
||||
{
|
||||
host_memory_watch_use_hashes();
|
||||
host_logf(HOST_LOG_INFO, "write tracking: page hashes (ARM translation)");
|
||||
}
|
||||
else if (!config_boolean_or(path, "debug.memory_watch", 1))
|
||||
{
|
||||
host_memory_watch_use_hashes();
|
||||
host_logf(HOST_LOG_INFO, "write tracking: page hashes (debug.memory_watch = false)");
|
||||
}
|
||||
else
|
||||
{
|
||||
host_logf(HOST_LOG_INFO, "write tracking: page protection");
|
||||
}
|
||||
boot = make_boot(&environment);
|
||||
host_logf(HOST_LOG_INFO, "data %s, saves %s", data_root, save_root);
|
||||
host_run_guest_main(boot);
|
||||
}
|
||||
|
||||
/* Called when HaloApplication loads this library at the start of the
|
||||
game's own process (":game"), before its Java side has allocated anything
|
||||
large: ART's large object space, which on some devices covers the Xbox
|
||||
window, is then idle there and can be reclaimed (host_memory.c). */
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
|
||||
{
|
||||
(void)vm;
|
||||
(void)reserved;
|
||||
host_memory_reserve_early();
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
host_logf(HOST_LOG_INFO, "Mjolnir VR starting");
|
||||
host_logf(HOST_LOG_INFO, "Halo for Android starting");
|
||||
host_install_signal_handlers();
|
||||
if (host_native_thread_create(game_main, NULL, MAIN_STACK_SIZE) != 0)
|
||||
host_fatal("cannot start the game thread");
|
||||
|
||||
@@ -17,25 +17,18 @@ This file also implements guest memory write tracking (the interface of
|
||||
port/linux/src/memory_watch.c): the renderer write-protects the pages behind
|
||||
the textures it caches, and the SIGSEGV handler here records the first
|
||||
write to each. Other faults are reported (with guest-relative addresses) and
|
||||
passed on to the previous handler. Under ARM translation (the x86 emulator)
|
||||
page faults cannot be caught, and the tracking compares page contents
|
||||
instead (host_watch_hash.c).
|
||||
passed on to the previous handler.
|
||||
*/
|
||||
|
||||
#include "host.h"
|
||||
#include "host_watch_hash.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/system_properties.h>
|
||||
#include <ucontext.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -108,264 +101,58 @@ static uint64_t find_gap(uint64_t size, uint64_t minimum)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* ART reserves its spaces at addresses chosen at zygote start, and on some
|
||||
devices one of them covers the fixed Xbox memory window. ART's heap
|
||||
(dalvik.vm.heapsize) decides how much of the low 4 GB its spaces take: on
|
||||
handhelds with a large heap (the Retroid Pocket Flip2, the AYN Thor) the
|
||||
free-list large object space usually lands right above the boot image, over
|
||||
0x80000000.
|
||||
|
||||
That space commits pages lazily from its bottom, and the game's process
|
||||
(HaloActivity runs in a process of its own, ":game", and reserves the
|
||||
window from JNI_OnLoad before its Java side has done anything:
|
||||
host_memory_reserve_early) hardly allocates large objects, so the slice
|
||||
over the window is normally idle address space: unmap exactly the
|
||||
intersection (never more) and let the caller retry. Only that space, and
|
||||
only a slice with no page in use (present or swapped out): ART's other
|
||||
spaces (its heap, bitmaps and card tables) are live, and unmapping them
|
||||
would corrupt it where failing to start is at least clear. */
|
||||
/* ART reserves its spaces (notably the free-list large object space) at
|
||||
addresses chosen at zygote start; on some devices (for example the Retroid
|
||||
Pocket Flip2, kernel 4.19) that reservation covers the fixed Xbox memory
|
||||
window. That space commits pages lazily from its bottom, and the Java side
|
||||
of this app hardly allocates large objects, so the slice over the window is
|
||||
normally idle address space: unmap exactly the intersection (never more)
|
||||
and let the caller retry. Only that space, and only a slice with no page in
|
||||
use (present or swapped out, from /proc/self/pagemap): ART's other spaces
|
||||
(its heap, bitmaps and card tables) are live, and unmapping them would
|
||||
corrupt it where failing to start is at least clear. */
|
||||
#define ART_LARGE_OBJECT_SPACE "[anon:dalvik-free list large object space]"
|
||||
|
||||
/* what range_usage found */
|
||||
enum
|
||||
/* whether no page from..to (page aligned) is present or swapped out; 0 if
|
||||
it cannot tell */
|
||||
static int range_unused(uint64_t from, uint64_t to)
|
||||
{
|
||||
RANGE_UNUSED,
|
||||
RANGE_IN_USE,
|
||||
RANGE_UNKNOWN
|
||||
};
|
||||
|
||||
/* why the fixed ranges could not be had: each reason also goes to the
|
||||
log, and the report (host_memory_report_low_mappings) starts with them, so
|
||||
memory_map.txt alone tells which case it was */
|
||||
static char findings[2048];
|
||||
|
||||
static void finding(int priority, const char *format, ...)
|
||||
{
|
||||
char line[512];
|
||||
size_t used = strlen(findings);
|
||||
va_list arguments;
|
||||
|
||||
va_start(arguments, format);
|
||||
vsnprintf(line, sizeof(line), format, arguments);
|
||||
va_end(arguments);
|
||||
host_logf(priority, "%s", line);
|
||||
if (used + strlen(line) + 2 < sizeof(findings))
|
||||
snprintf(findings + used, sizeof(findings) - used, "%s\n", line);
|
||||
}
|
||||
|
||||
struct range_usage
|
||||
{
|
||||
uint64_t pages_in_use;
|
||||
uint64_t lowest_in_use, highest_in_use;
|
||||
const char *method;
|
||||
};
|
||||
|
||||
static void note_in_use(struct range_usage *usage, uint64_t address)
|
||||
{
|
||||
if (!usage->pages_in_use++)
|
||||
usage->lowest_in_use = address;
|
||||
usage->highest_in_use = address;
|
||||
}
|
||||
|
||||
/* debug.halo.art_overlap's -nopagemap (simulate_art_overlap) */
|
||||
static int simulated_no_pagemap;
|
||||
|
||||
/* from /proc/self/pagemap: bit 63 present, bit 62 swapped out */
|
||||
static int range_usage_pagemap(uint64_t from, uint64_t to, struct range_usage *usage)
|
||||
{
|
||||
int descriptor = simulated_no_pagemap ? -1 : open("/proc/self/pagemap", O_RDONLY | O_CLOEXEC);
|
||||
FILE *pagemap = fopen("/proc/self/pagemap", "rb");
|
||||
uint64_t entries[512];
|
||||
uint64_t page = from / PAGE;
|
||||
int unused = 1;
|
||||
|
||||
if (simulated_no_pagemap)
|
||||
errno = EACCES;
|
||||
if (descriptor < 0)
|
||||
{
|
||||
finding(HOST_LOG_WARN, "cannot read /proc/self/pagemap (%s)", strerror(errno));
|
||||
return RANGE_UNKNOWN;
|
||||
}
|
||||
usage->method = "pagemap";
|
||||
while (page < to / PAGE)
|
||||
if (!pagemap)
|
||||
return 0;
|
||||
if (fseeko(pagemap, (off_t)(page * sizeof(uint64_t)), SEEK_SET) != 0)
|
||||
unused = 0;
|
||||
while (unused && page < to / PAGE)
|
||||
{
|
||||
size_t wanted = (size_t)(to / PAGE - page);
|
||||
ssize_t bytes;
|
||||
size_t count, index;
|
||||
size_t count;
|
||||
size_t index;
|
||||
|
||||
if (wanted > sizeof(entries) / sizeof(entries[0]))
|
||||
wanted = sizeof(entries) / sizeof(entries[0]);
|
||||
bytes = pread(descriptor, entries, wanted * sizeof(entries[0]), (off_t)(page * sizeof(entries[0])));
|
||||
if (bytes <= 0 || bytes % sizeof(entries[0]))
|
||||
count = fread(entries, sizeof(entries[0]), wanted, pagemap);
|
||||
if (count != wanted)
|
||||
{
|
||||
finding(HOST_LOG_WARN, "cannot read /proc/self/pagemap at %08llx (%s)",
|
||||
(unsigned long long)(page * PAGE), bytes < 0 ? strerror(errno) : "short read");
|
||||
close(descriptor);
|
||||
return RANGE_UNKNOWN;
|
||||
unused = 0;
|
||||
break;
|
||||
}
|
||||
count = (size_t)bytes / sizeof(entries[0]);
|
||||
/* (bit 63 present, bit 62 swapped) */
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
if (entries[index] & (3ULL << 62))
|
||||
note_in_use(usage, (page + index) * PAGE);
|
||||
{
|
||||
unused = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
page += count;
|
||||
}
|
||||
close(descriptor);
|
||||
return usage->pages_in_use ? RANGE_IN_USE : RANGE_UNUSED;
|
||||
}
|
||||
|
||||
/* the Swap: line of the /proc/self/smaps entry starting at start, in kB; -1
|
||||
if it cannot be read (or no entry starts there); with end, the entry must
|
||||
also end there. dont_dump, if not NULL, tells whether its VmFlags have dd
|
||||
(MADV_DONTDUMP). */
|
||||
static long mapping_swap_kb_ending(uint64_t start, uint64_t end, int *dont_dump)
|
||||
{
|
||||
FILE *smaps = fopen("/proc/self/smaps", "r");
|
||||
char line[512];
|
||||
int inside = 0;
|
||||
long result = -1;
|
||||
|
||||
if (dont_dump)
|
||||
*dont_dump = 0;
|
||||
if (!smaps)
|
||||
return -1;
|
||||
while (fgets(line, sizeof(line), smaps))
|
||||
{
|
||||
unsigned long long lo, hi;
|
||||
long kb;
|
||||
|
||||
if (sscanf(line, "%llx-%llx ", &lo, &hi) == 2 && strchr(line, '-') < strchr(line, ' '))
|
||||
{
|
||||
if (inside)
|
||||
break;
|
||||
inside = lo == start && (!end || hi == end);
|
||||
continue;
|
||||
}
|
||||
if (!inside)
|
||||
continue;
|
||||
if (sscanf(line, "Swap: %ld kB", &kb) == 1)
|
||||
result = kb;
|
||||
else if (dont_dump && !strncmp(line, "VmFlags:", 8))
|
||||
*dont_dump = strstr(line, " dd") != NULL;
|
||||
}
|
||||
fclose(smaps);
|
||||
return result;
|
||||
}
|
||||
|
||||
static long mapping_swap_kb(uint64_t start)
|
||||
{
|
||||
return mapping_swap_kb_ending(start, 0, NULL);
|
||||
}
|
||||
|
||||
/* whether any of from..to (in the mapping starting at mapping_start) is
|
||||
swapped out, when that mapping has swap somewhere: smaps counts swap per
|
||||
mapping, so the range is made a mapping of its own for a moment
|
||||
(MADV_DONTDUMP splits it off and changes nothing about its pages: neither
|
||||
ART nor the game ever dumps core), read, and merged back (MADV_DODUMP). Not
|
||||
for a mapping already marked so (the restore would then change it). -1 if
|
||||
that cannot be done */
|
||||
static long range_swap_kb(uint64_t mapping_start, uint64_t from, uint64_t to)
|
||||
{
|
||||
int dont_dump;
|
||||
long kb;
|
||||
|
||||
if (mapping_swap_kb_ending(mapping_start, 0, &dont_dump) < 0)
|
||||
{
|
||||
finding(HOST_LOG_WARN, "cannot read the smaps entry of ART's large object space at %08llx",
|
||||
(unsigned long long)mapping_start);
|
||||
return -1;
|
||||
}
|
||||
if (dont_dump)
|
||||
{
|
||||
finding(HOST_LOG_WARN, "ART's large object space at %08llx is marked not to be dumped; "
|
||||
"the swap of %08llx-%08llx cannot be read on its own", (unsigned long long)mapping_start,
|
||||
(unsigned long long)from, (unsigned long long)to);
|
||||
return -1;
|
||||
}
|
||||
if (madvise((void *)from, (size_t)(to - from), MADV_DONTDUMP) != 0)
|
||||
{
|
||||
finding(HOST_LOG_WARN, "cannot split %08llx-%08llx off ART's large object space (%s)",
|
||||
(unsigned long long)from, (unsigned long long)to, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
kb = mapping_swap_kb_ending(from, to, NULL);
|
||||
madvise((void *)from, (size_t)(to - from), MADV_DODUMP);
|
||||
if (kb < 0)
|
||||
finding(HOST_LOG_WARN, "no smaps entry for %08llx-%08llx once split off", (unsigned long long)from,
|
||||
(unsigned long long)to);
|
||||
return kb;
|
||||
}
|
||||
|
||||
/* without pagemap (some kernels or policies refuse it): mincore() tells
|
||||
which pages are resident, and smaps whether any of the range is swapped
|
||||
out, which mincore cannot see */
|
||||
static int range_usage_mincore(uint64_t mapping_start, uint64_t from, uint64_t to, struct range_usage *usage)
|
||||
{
|
||||
unsigned char residency[4096];
|
||||
uint64_t address = from;
|
||||
long swapped = mapping_swap_kb(mapping_start);
|
||||
|
||||
usage->method = "mincore";
|
||||
if (swapped < 0)
|
||||
{
|
||||
finding(HOST_LOG_WARN, "cannot read the smaps entry of ART's large object space at %08llx",
|
||||
(unsigned long long)mapping_start);
|
||||
return RANGE_UNKNOWN;
|
||||
}
|
||||
if (swapped > 0)
|
||||
{
|
||||
/* (swap somewhere in the space: only the range's own matters) */
|
||||
long range_swapped = range_swap_kb(mapping_start, from, to);
|
||||
|
||||
if (range_swapped < 0)
|
||||
return RANGE_UNKNOWN;
|
||||
if (range_swapped > 0)
|
||||
{
|
||||
/* (objects there, swapped out: which pages smaps does not say) */
|
||||
usage->method = "the range's swap in smaps";
|
||||
usage->pages_in_use = (uint64_t)range_swapped * 1024 / PAGE;
|
||||
usage->lowest_in_use = from;
|
||||
usage->highest_in_use = to - PAGE;
|
||||
return RANGE_IN_USE;
|
||||
}
|
||||
finding(HOST_LOG_INFO, "ART's large object space at %08llx: %ld kB of it swapped out, none of %08llx-%08llx",
|
||||
(unsigned long long)mapping_start, swapped, (unsigned long long)from, (unsigned long long)to);
|
||||
}
|
||||
while (address < to)
|
||||
{
|
||||
uint64_t length = to - address;
|
||||
size_t index;
|
||||
|
||||
if (length > sizeof(residency) * PAGE)
|
||||
length = sizeof(residency) * PAGE;
|
||||
if (mincore((void *)address, length, residency) != 0)
|
||||
{
|
||||
finding(HOST_LOG_WARN, "mincore at %08llx failed (%s)", (unsigned long long)address, strerror(errno));
|
||||
return RANGE_UNKNOWN;
|
||||
}
|
||||
for (index = 0; index < length / PAGE; index++)
|
||||
{
|
||||
if (residency[index] & 1)
|
||||
note_in_use(usage, address + index * PAGE);
|
||||
}
|
||||
address += length;
|
||||
}
|
||||
return usage->pages_in_use ? RANGE_IN_USE : RANGE_UNUSED;
|
||||
}
|
||||
|
||||
/* whether any page from..to (page aligned) of the mapping starting at
|
||||
mapping_start holds data */
|
||||
static int range_usage(uint64_t mapping_start, uint64_t from, uint64_t to, struct range_usage *usage)
|
||||
{
|
||||
int result;
|
||||
|
||||
memset(usage, 0, sizeof(*usage));
|
||||
result = range_usage_pagemap(from, to, usage);
|
||||
if (result == RANGE_UNKNOWN)
|
||||
{
|
||||
memset(usage, 0, sizeof(*usage));
|
||||
result = range_usage_mincore(mapping_start, from, to, usage);
|
||||
}
|
||||
return result;
|
||||
fclose(pagemap);
|
||||
return unused;
|
||||
}
|
||||
|
||||
static int reclaim_art_overlap(uint64_t address, uint64_t size)
|
||||
@@ -380,7 +167,6 @@ static int reclaim_art_overlap(uint64_t address, uint64_t size)
|
||||
{
|
||||
unsigned long long lo, hi;
|
||||
uint64_t from, to;
|
||||
struct range_usage usage;
|
||||
char *name;
|
||||
int name_offset = 0;
|
||||
|
||||
@@ -394,31 +180,21 @@ static int reclaim_art_overlap(uint64_t address, uint64_t size)
|
||||
to = hi < address + size ? hi : address + size;
|
||||
if (strcmp(name, ART_LARGE_OBJECT_SPACE))
|
||||
{
|
||||
finding(HOST_LOG_ERROR, "a fixed guest range is overlapped by %08llx-%08llx (%s), which is not ART's large object space; left alone",
|
||||
host_logf(HOST_LOG_ERROR, "a fixed guest range is overlapped by %08llx-%08llx (%s), which is not ART's large object space; left alone",
|
||||
lo, hi, name[0] ? name : "unnamed");
|
||||
continue;
|
||||
}
|
||||
switch (range_usage(lo, from, to, &usage))
|
||||
if (!range_unused(from, to))
|
||||
{
|
||||
case RANGE_IN_USE:
|
||||
finding(HOST_LOG_ERROR,
|
||||
"ART's large object space %08llx-%08llx holds objects over %08llx-%08llx "
|
||||
"(%llu pages in use, %08llx-%08llx, by %s); left alone",
|
||||
lo, hi, (unsigned long long)from, (unsigned long long)to,
|
||||
(unsigned long long)usage.pages_in_use, (unsigned long long)usage.lowest_in_use,
|
||||
(unsigned long long)usage.highest_in_use + PAGE, usage.method);
|
||||
continue;
|
||||
case RANGE_UNKNOWN:
|
||||
finding(HOST_LOG_ERROR,
|
||||
"ART's large object space %08llx-%08llx covers %08llx-%08llx, and whether that part is in use "
|
||||
"cannot be told; left alone", lo, hi, (unsigned long long)from, (unsigned long long)to);
|
||||
host_logf(HOST_LOG_ERROR, "ART's large object space over %08llx-%08llx is in use (or its pages cannot be read); left alone",
|
||||
(unsigned long long)from, (unsigned long long)to);
|
||||
continue;
|
||||
}
|
||||
if (munmap((void *)from, to - from) == 0)
|
||||
{
|
||||
host_logf(HOST_LOG_INFO,
|
||||
"reclaimed idle ART range %08llx-%08llx of %08llx-%08llx (%s, checked by %s)",
|
||||
(unsigned long long)from, (unsigned long long)to, lo, hi, name, usage.method);
|
||||
"reclaimed idle ART range %08llx-%08llx (%s)",
|
||||
(unsigned long long)from, (unsigned long long)to, name);
|
||||
reclaimed = 1;
|
||||
}
|
||||
}
|
||||
@@ -438,10 +214,8 @@ static int reserve(uint64_t address, uint64_t size, int reclaim_art)
|
||||
return 0;
|
||||
if (result != MAP_FAILED)
|
||||
{
|
||||
/* (a kernel older than 4.17 takes MAP_FIXED_NOREPLACE as a hint,
|
||||
and maps elsewhere when something is in the way) */
|
||||
munmap(result, size);
|
||||
errno = EEXIST;
|
||||
return -1;
|
||||
}
|
||||
if (reclaim_art && errno == EEXIST)
|
||||
{
|
||||
@@ -459,47 +233,11 @@ static int reserve(uint64_t address, uint64_t size, int reclaim_art)
|
||||
if (result == (void *)address)
|
||||
return 0;
|
||||
if (result != MAP_FAILED)
|
||||
{
|
||||
munmap(result, size);
|
||||
errno = EEXIST;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* the mappings below 4 GB, for a report of why the fixed ranges could not
|
||||
be had (logcat, and memory_map.txt in the data folder: host_main.c) */
|
||||
void host_memory_report_low_mappings(FILE *file)
|
||||
{
|
||||
FILE *maps = fopen("/proc/self/maps", "r");
|
||||
char line[512];
|
||||
char model[PROP_VALUE_MAX] = "", heap[PROP_VALUE_MAX] = "", release[PROP_VALUE_MAX] = "";
|
||||
|
||||
__system_property_get("ro.product.model", model);
|
||||
__system_property_get("dalvik.vm.heapsize", heap);
|
||||
__system_property_get("ro.build.version.release", release);
|
||||
if (file)
|
||||
{
|
||||
fprintf(file, "device: %s, Android %s, Java heap %s\n", model[0] ? model : "unknown",
|
||||
release[0] ? release : "unknown", heap[0] ? heap : "unknown");
|
||||
fprintf(file, "why:\n%s\nmappings below 4 GB:\n", findings[0] ? findings : "(no reason recorded)\n");
|
||||
}
|
||||
if (!maps)
|
||||
return;
|
||||
while (fgets(line, sizeof(line), maps))
|
||||
{
|
||||
unsigned long long lo, hi;
|
||||
|
||||
if (sscanf(line, "%llx-%llx", &lo, &hi) != 2 || lo >= LOW_LIMIT)
|
||||
continue;
|
||||
line[strcspn(line, "\n")] = '\0';
|
||||
host_logf(HOST_LOG_INFO, "low mapping: %s", line);
|
||||
if (file)
|
||||
fprintf(file, "%s\n", line);
|
||||
}
|
||||
fclose(maps);
|
||||
}
|
||||
|
||||
static struct pool *pool_new(void)
|
||||
{
|
||||
/* above the image first: ART allocates its own low-4 GB memory from
|
||||
@@ -536,122 +274,24 @@ static struct pool *pool_new(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* The fixed ranges: the Xbox window and, right above it, room for the guest
|
||||
image (HALO_GUEST_IMAGE_RESERVE), reserved as early as the process allows
|
||||
(host_memory_reserve_early, from JNI_OnLoad) or else when the image loads. */
|
||||
static int fixed_reserved;
|
||||
static int fixed_error;
|
||||
|
||||
/* when: the attempt, as the report names it (the reasons below it are
|
||||
those of that attempt) */
|
||||
static int reserve_fixed(const char *when)
|
||||
{
|
||||
size_t used = strlen(findings);
|
||||
|
||||
if (fixed_reserved)
|
||||
return 0;
|
||||
snprintf(findings + used, sizeof(findings) - used, "%s:\n", when);
|
||||
if (reserve(HALO_GUEST_WINDOW_BASE, HALO_GUEST_WINDOW_SIZE, 1) != 0)
|
||||
{
|
||||
fixed_error = errno;
|
||||
finding(HOST_LOG_ERROR, "cannot reserve the Xbox memory window at %08llx (%s)",
|
||||
(unsigned long long)HALO_GUEST_WINDOW_BASE, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (reserve(HALO_GUEST_IMAGE_BASE, HALO_GUEST_IMAGE_RESERVE, 1) != 0)
|
||||
{
|
||||
fixed_error = errno;
|
||||
finding(HOST_LOG_ERROR, "cannot reserve the guest image range at %08llx (%s)",
|
||||
(unsigned long long)HALO_GUEST_IMAGE_BASE, strerror(errno));
|
||||
munmap((void *)(uintptr_t)HALO_GUEST_WINDOW_BASE, HALO_GUEST_WINDOW_SIZE);
|
||||
return -1;
|
||||
}
|
||||
fixed_reserved = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int host_memory_fixed_unavailable(void)
|
||||
{
|
||||
return !fixed_reserved && fixed_error != 0;
|
||||
}
|
||||
|
||||
/* For testing the reclaim on any device: with the system property
|
||||
debug.halo.art_overlap set (adb shell setprop debug.halo.art_overlap idle,
|
||||
or busy), a mapping named as ART's large object space is put over the fixed
|
||||
ranges first, idle, or with a page in use inside the window, the way ART's
|
||||
is on the devices that need the reclaim. Players never set it.
|
||||
|
||||
Either may be followed by -nopagemap, for devices that refuse
|
||||
/proc/self/pagemap (the check then falls back to mincore and smaps), and
|
||||
by -swapped, which pushes the stand-in's objects (its bottom pages, and the
|
||||
window's page if busy) out to swap, as they can be on those devices. */
|
||||
#ifndef MADV_PAGEOUT
|
||||
#define MADV_PAGEOUT 21
|
||||
#endif
|
||||
#define PR_SET_VMA_ 0x53564d41
|
||||
#define PR_SET_VMA_ANON_NAME_ 0
|
||||
#define SIMULATED_SPACE_BASE 0x7c000000ULL
|
||||
#define SIMULATED_SPACE_SIZE 0x14000000ULL
|
||||
|
||||
static void simulate_art_overlap(void)
|
||||
{
|
||||
char value[PROP_VALUE_MAX] = "";
|
||||
char *window_page = (char *)(uintptr_t)HALO_GUEST_WINDOW_BASE + 0x100000;
|
||||
int busy;
|
||||
void *space;
|
||||
|
||||
if (__system_property_get("debug.halo.art_overlap", value) <= 0 || (strncmp(value, "idle", 4) && strncmp(value, "busy", 4)))
|
||||
return;
|
||||
busy = !strncmp(value, "busy", 4);
|
||||
space = mmap((void *)SIMULATED_SPACE_BASE, SIMULATED_SPACE_SIZE, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_FIXED_NOREPLACE, -1, 0);
|
||||
if (space != (void *)SIMULATED_SPACE_BASE)
|
||||
{
|
||||
host_logf(HOST_LOG_WARN, "debug.halo.art_overlap: %08llx-%08llx is not free",
|
||||
SIMULATED_SPACE_BASE, SIMULATED_SPACE_BASE + SIMULATED_SPACE_SIZE);
|
||||
if (space != MAP_FAILED)
|
||||
munmap(space, SIMULATED_SPACE_SIZE);
|
||||
return;
|
||||
}
|
||||
prctl(PR_SET_VMA_, PR_SET_VMA_ANON_NAME_, space, SIMULATED_SPACE_SIZE, "dalvik-free list large object space");
|
||||
/* objects at its bottom, as ART allocates them */
|
||||
memset(space, 0x5a, 4 * PAGE);
|
||||
if (busy)
|
||||
memset(window_page, 0x5a, PAGE);
|
||||
if (strstr(value, "-swapped"))
|
||||
{
|
||||
if (madvise(space, 4 * PAGE, MADV_PAGEOUT) != 0 || (busy && madvise(window_page, PAGE, MADV_PAGEOUT) != 0))
|
||||
host_logf(HOST_LOG_WARN, "debug.halo.art_overlap: cannot page out the stand-in (%s)", strerror(errno));
|
||||
}
|
||||
simulated_no_pagemap = strstr(value, "-nopagemap") != NULL;
|
||||
host_logf(HOST_LOG_WARN, "debug.halo.art_overlap=%s: a stand-in for ART's large object space at %08llx-%08llx "
|
||||
"(%ld kB of it swapped out)", value, SIMULATED_SPACE_BASE, SIMULATED_SPACE_BASE + SIMULATED_SPACE_SIZE,
|
||||
mapping_swap_kb(SIMULATED_SPACE_BASE));
|
||||
}
|
||||
|
||||
void host_memory_reserve_early(void)
|
||||
{
|
||||
simulate_art_overlap();
|
||||
if (reserve_fixed("at start-up (JNI_OnLoad)") == 0)
|
||||
host_logf(HOST_LOG_INFO, "reserved the Xbox memory window and the image range at start-up");
|
||||
}
|
||||
|
||||
int host_memory_initialize(uint32_t base, uint32_t size)
|
||||
{
|
||||
if (base != HALO_GUEST_IMAGE_BASE || size > HALO_GUEST_IMAGE_RESERVE)
|
||||
{
|
||||
host_logf(HOST_LOG_ERROR, "the guest image (%08x, %u bytes) does not fit its range", base, size);
|
||||
return -1;
|
||||
}
|
||||
if (reserve_fixed("when the image loaded") != 0)
|
||||
{
|
||||
errno = fixed_error;
|
||||
return -1;
|
||||
}
|
||||
window_base = HALO_GUEST_WINDOW_BASE;
|
||||
window_end = window_base + HALO_GUEST_WINDOW_SIZE;
|
||||
if (reserve(window_base, HALO_GUEST_WINDOW_SIZE, 1) != 0)
|
||||
{
|
||||
host_logf(HOST_LOG_ERROR, "cannot reserve the Xbox memory window at %08llx (%s)",
|
||||
(unsigned long long)window_base, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
image_base = base;
|
||||
image_end = base + round_up(size);
|
||||
if (reserve(image_base, image_end - image_base, 1) != 0)
|
||||
{
|
||||
host_logf(HOST_LOG_ERROR, "cannot reserve the guest image range at %08llx (%s)",
|
||||
(unsigned long long)image_base, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -834,29 +474,10 @@ long host_guest_mprotect(uint64_t address, uint64_t size, int protection)
|
||||
|
||||
#define WATCH_PAGE_COUNT (HALO_GUEST_WINDOW_SIZE / PAGE)
|
||||
|
||||
/* (each page: 0 not watched, 1 watched and read-only, 2 made writable by a
|
||||
watched write. A fault on a page at 2 is a write another thread made as
|
||||
this one was making the page writable, and is made again; one on a page at
|
||||
0, freed memory or none of the watch's, is a crash) */
|
||||
static uint8_t page_protected[WATCH_PAGE_COUNT];
|
||||
static uint32_t page_generation[WATCH_PAGE_COUNT];
|
||||
static volatile uint32_t current_generation = 1;
|
||||
static int watch_active;
|
||||
static int watch_hashing;
|
||||
static uint8_t page_hash_watched[WATCH_PAGE_COUNT];
|
||||
static uint64_t page_hash[WATCH_PAGE_COUNT];
|
||||
static uint32_t page_hashed_frame[WATCH_PAGE_COUNT];
|
||||
static struct watch_hash page_hashes =
|
||||
{
|
||||
.base = (const uint8_t *)(uintptr_t)HALO_GUEST_WINDOW_BASE,
|
||||
.page_count = WATCH_PAGE_COUNT,
|
||||
.watched = page_hash_watched,
|
||||
.hash = page_hash,
|
||||
.hashed_frame = page_hashed_frame,
|
||||
.generation = page_generation,
|
||||
.current_generation = ¤t_generation,
|
||||
.frame = 1,
|
||||
};
|
||||
|
||||
static int in_window(uint64_t address)
|
||||
{
|
||||
@@ -871,7 +492,7 @@ static uint64_t watch_page(uint64_t address)
|
||||
static void mark_written(uint64_t page)
|
||||
{
|
||||
page_generation[page] = __sync_add_and_fetch(¤t_generation, 1);
|
||||
page_protected[page] = 2;
|
||||
page_protected[page] = 0;
|
||||
mprotect((void *)(HALO_GUEST_WINDOW_BASE + page * PAGE), PAGE, PROT_READ | PROT_WRITE);
|
||||
}
|
||||
|
||||
@@ -938,13 +559,11 @@ static void segv_handler(int signal_number, siginfo_t *information, void *contex
|
||||
{
|
||||
uint64_t page = watch_page(address);
|
||||
|
||||
if (page_protected[page] == 1)
|
||||
if (page_protected[page])
|
||||
{
|
||||
mark_written(page);
|
||||
return;
|
||||
}
|
||||
if (page_protected[page] == 2)
|
||||
return;
|
||||
}
|
||||
report_crash(signal_number, information, context);
|
||||
chain(&previous_segv, signal_number, information, context);
|
||||
@@ -982,14 +601,6 @@ void host_memory_watch_initialize(void)
|
||||
watch_active = 1;
|
||||
}
|
||||
|
||||
void host_memory_watch_use_hashes(void)
|
||||
{
|
||||
watch_hashing = 1;
|
||||
}
|
||||
|
||||
/* memory_watch_protect: write-protects the pages of a range, or keeps their
|
||||
hash under host_memory_watch_use_hashes; a size outside the guest window
|
||||
is ignored */
|
||||
void host_memory_watch_protect(uint32_t address, uint32_t size)
|
||||
{
|
||||
uint64_t first, last, page;
|
||||
@@ -1000,14 +611,9 @@ void host_memory_watch_protect(uint32_t address, uint32_t size)
|
||||
last = watch_page((uint64_t)address + size - 1);
|
||||
if (last >= WATCH_PAGE_COUNT)
|
||||
last = WATCH_PAGE_COUNT - 1;
|
||||
if (watch_hashing)
|
||||
{
|
||||
watch_hash_protect(&page_hashes, (uint32_t)first, (uint32_t)last);
|
||||
return;
|
||||
}
|
||||
for (page = first; page <= last; page++)
|
||||
{
|
||||
if (page_protected[page] != 1)
|
||||
if (!page_protected[page])
|
||||
{
|
||||
page_protected[page] = 1;
|
||||
mprotect((void *)(HALO_GUEST_WINDOW_BASE + page * PAGE), PAGE, PROT_READ);
|
||||
@@ -1020,8 +626,6 @@ uint32_t host_memory_watch_serial(void)
|
||||
return current_generation;
|
||||
}
|
||||
|
||||
/* memory_watch_generation: the newest generation of the pages of a range.
|
||||
Under hashing this hashes the pages again, once a frame. */
|
||||
uint32_t host_memory_watch_generation(uint32_t address, uint32_t size)
|
||||
{
|
||||
uint64_t first, last, page;
|
||||
@@ -1033,8 +637,6 @@ uint32_t host_memory_watch_generation(uint32_t address, uint32_t size)
|
||||
last = watch_page((uint64_t)address + size - 1);
|
||||
if (last >= WATCH_PAGE_COUNT)
|
||||
last = WATCH_PAGE_COUNT - 1;
|
||||
if (watch_hashing)
|
||||
return watch_hash_generation(&page_hashes, (uint32_t)first, (uint32_t)last);
|
||||
for (page = first; page <= last; page++)
|
||||
{
|
||||
if (page_generation[page] > newest)
|
||||
@@ -1043,14 +645,11 @@ uint32_t host_memory_watch_generation(uint32_t address, uint32_t size)
|
||||
return newest;
|
||||
}
|
||||
|
||||
/* memory_watch_prepare_write: unprotects the pages the host itself is about
|
||||
to write into. Nothing under hashing: the write shows in the next hash and
|
||||
there is no protection to fault on. */
|
||||
void host_memory_watch_prepare_write(uint32_t address, uint32_t size)
|
||||
{
|
||||
uint64_t start = address, first, last, page;
|
||||
|
||||
if (!watch_active || watch_hashing || !size)
|
||||
if (!watch_active || !size)
|
||||
return;
|
||||
if (start + size <= HALO_GUEST_WINDOW_BASE || start >= (uint64_t)HALO_GUEST_WINDOW_BASE + HALO_GUEST_WINDOW_SIZE)
|
||||
return;
|
||||
@@ -1062,13 +661,11 @@ void host_memory_watch_prepare_write(uint32_t address, uint32_t size)
|
||||
last = WATCH_PAGE_COUNT - 1;
|
||||
for (page = first; page <= last; page++)
|
||||
{
|
||||
if (page_protected[page] == 1)
|
||||
if (page_protected[page])
|
||||
mark_written(page);
|
||||
}
|
||||
}
|
||||
|
||||
/* memory_watch_forget: the pages of a range were remapped or reprotected, so
|
||||
treat them as written and unwatched */
|
||||
void host_memory_watch_forget(uint32_t address, uint32_t size)
|
||||
{
|
||||
uint64_t first, last, page;
|
||||
@@ -1079,22 +676,9 @@ void host_memory_watch_forget(uint32_t address, uint32_t size)
|
||||
last = watch_page((uint64_t)address + size - 1);
|
||||
if (last >= WATCH_PAGE_COUNT)
|
||||
last = WATCH_PAGE_COUNT - 1;
|
||||
if (watch_hashing)
|
||||
{
|
||||
watch_hash_forget(&page_hashes, (uint32_t)first, (uint32_t)last);
|
||||
return;
|
||||
}
|
||||
for (page = first; page <= last; page++)
|
||||
{
|
||||
page_protected[page] = 0;
|
||||
page_generation[page] = __sync_add_and_fetch(¤t_generation, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* memory_watch_begin_frame: pages may be hashed again; nothing under page
|
||||
protection */
|
||||
void host_memory_watch_begin_frame(void)
|
||||
{
|
||||
if (watch_hashing)
|
||||
watch_hash_begin_frame(&page_hashes);
|
||||
}
|
||||
@@ -32,8 +32,6 @@ struct handle
|
||||
{
|
||||
int type;
|
||||
void *object;
|
||||
/* an audio stream with a callback: its binding (below) */
|
||||
void *binding;
|
||||
};
|
||||
|
||||
static struct handle handles[HANDLE_COUNT];
|
||||
@@ -61,7 +59,6 @@ static uint32_t handle_new(int type, void *object)
|
||||
{
|
||||
handles[index].type = type;
|
||||
handles[index].object = object;
|
||||
handles[index].binding = NULL;
|
||||
pthread_mutex_unlock(&handle_lock);
|
||||
return index;
|
||||
}
|
||||
@@ -84,30 +81,6 @@ static void *handle_get(uint32_t handle, int type)
|
||||
return object;
|
||||
}
|
||||
|
||||
/* the object of a handle, which the handle no longer refers to; NULL when
|
||||
there is none. *binding gets what handle_new's caller stored (audio) */
|
||||
static void *handle_release(uint32_t handle, int type, void **binding)
|
||||
{
|
||||
void *object = NULL;
|
||||
|
||||
if (binding)
|
||||
*binding = NULL;
|
||||
if (handle == 0 || handle >= HANDLE_COUNT)
|
||||
return NULL;
|
||||
pthread_mutex_lock(&handle_lock);
|
||||
if (handles[handle].type == type)
|
||||
{
|
||||
object = handles[handle].object;
|
||||
if (binding)
|
||||
*binding = handles[handle].binding;
|
||||
handles[handle].type = _handle_free;
|
||||
handles[handle].object = NULL;
|
||||
handles[handle].binding = NULL;
|
||||
}
|
||||
pthread_mutex_unlock(&handle_lock);
|
||||
return object;
|
||||
}
|
||||
|
||||
/* ---------- general */
|
||||
|
||||
int host_sdl_init(uint32_t flags)
|
||||
@@ -125,16 +98,6 @@ void host_sdl_get_error(char *buffer, uint32_t size)
|
||||
SDL_strlcpy(buffer, SDL_GetError(), size);
|
||||
}
|
||||
|
||||
void host_sdl_scancode_name(int32_t scancode, char *buffer, uint32_t size)
|
||||
{
|
||||
SDL_strlcpy(buffer, SDL_GetScancodeName((SDL_Scancode)scancode), size);
|
||||
}
|
||||
|
||||
int32_t host_sdl_scancode_from_name(const char *name)
|
||||
{
|
||||
return (int32_t)SDL_GetScancodeFromName(name);
|
||||
}
|
||||
|
||||
int64_t host_sdl_ticks(void)
|
||||
{
|
||||
return (int64_t)SDL_GetTicks();
|
||||
@@ -178,11 +141,7 @@ uint32_t host_sdl_gl_create_context(uint32_t window)
|
||||
{
|
||||
SDL_Window *object = handle_get(window, _handle_window);
|
||||
|
||||
uint32_t context = object ? handle_new(_handle_context, SDL_GL_CreateContext(object)) : 0;
|
||||
|
||||
/* (the driver opens its trace markers with the context) */
|
||||
host_gl_quiet_trace_markers();
|
||||
return context;
|
||||
return object ? handle_new(_handle_context, SDL_GL_CreateContext(object)) : 0;
|
||||
}
|
||||
|
||||
int host_sdl_gl_make_current(uint32_t window, uint32_t context)
|
||||
@@ -248,15 +207,6 @@ uint32_t host_sdl_gamepad_from_id(uint32_t id)
|
||||
return handle_new(_handle_gamepad, SDL_GetGamepadFromID((SDL_JoystickID)id));
|
||||
}
|
||||
|
||||
/* (the event thread, when the controller goes: sdl_platform.c) */
|
||||
void host_sdl_close_gamepad(uint32_t gamepad)
|
||||
{
|
||||
SDL_Gamepad *object = handle_release(gamepad, _handle_gamepad, NULL);
|
||||
|
||||
if (object)
|
||||
SDL_CloseGamepad(object);
|
||||
}
|
||||
|
||||
int host_sdl_gamepad_axis(uint32_t gamepad, int axis)
|
||||
{
|
||||
SDL_Gamepad *object = handle_get(gamepad, _handle_gamepad);
|
||||
@@ -303,8 +253,6 @@ struct audio_binding
|
||||
pthread_cond_t requested;
|
||||
pthread_cond_t done;
|
||||
int pending;
|
||||
/* the stream is destroyed: the thread frees the binding and ends */
|
||||
int quit;
|
||||
int additional;
|
||||
int total;
|
||||
unsigned char *buffer;
|
||||
@@ -324,10 +272,8 @@ static void *audio_thread(void *context)
|
||||
{
|
||||
int additional, total;
|
||||
|
||||
while (!binding->pending && !binding->quit)
|
||||
while (!binding->pending)
|
||||
pthread_cond_wait(&binding->requested, &binding->lock);
|
||||
if (binding->quit)
|
||||
break;
|
||||
additional = binding->additional;
|
||||
total = binding->total;
|
||||
pthread_mutex_unlock(&binding->lock);
|
||||
@@ -338,12 +284,6 @@ static void *audio_thread(void *context)
|
||||
binding->pending = 0;
|
||||
pthread_cond_signal(&binding->done);
|
||||
}
|
||||
pthread_mutex_unlock(&binding->lock);
|
||||
pthread_cond_destroy(&binding->done);
|
||||
pthread_cond_destroy(&binding->requested);
|
||||
pthread_mutex_destroy(&binding->lock);
|
||||
SDL_free(binding->buffer);
|
||||
SDL_free(binding);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -389,19 +329,9 @@ static int audio_keep(struct audio_binding *binding, const void *data, int lengt
|
||||
|
||||
uint32_t host_sdl_open_audio_stream(uint32_t device, const void *spec, uint32_t callback, uint32_t userdata)
|
||||
{
|
||||
struct audio_binding *binding;
|
||||
struct audio_binding *binding = SDL_calloc(1, sizeof(*binding));
|
||||
SDL_AudioStream *stream;
|
||||
|
||||
/* (one without a callback, the microphone's, which the guest reads:
|
||||
nothing to bind) */
|
||||
if (!callback)
|
||||
{
|
||||
stream = SDL_OpenAudioDeviceStream((SDL_AudioDeviceID)device, spec, NULL, NULL);
|
||||
return stream ? handle_new(_handle_audio, stream) : 0;
|
||||
}
|
||||
binding = SDL_calloc(1, sizeof(*binding));
|
||||
if (!binding)
|
||||
return 0;
|
||||
binding->callback = callback;
|
||||
binding->userdata = userdata;
|
||||
pthread_mutex_init(&binding->lock, NULL);
|
||||
@@ -416,19 +346,7 @@ uint32_t host_sdl_open_audio_stream(uint32_t device, const void *spec, uint32_t
|
||||
}
|
||||
/* the device starts paused, so no callback can run before this */
|
||||
binding->handle = handle_new(_handle_audio, stream);
|
||||
if (!binding->handle)
|
||||
{
|
||||
SDL_DestroyAudioStream(stream);
|
||||
pthread_cond_destroy(&binding->done);
|
||||
pthread_cond_destroy(&binding->requested);
|
||||
pthread_mutex_destroy(&binding->lock);
|
||||
SDL_free(binding);
|
||||
return 0;
|
||||
}
|
||||
pthread_mutex_lock(&handle_lock);
|
||||
handles[binding->handle].binding = binding;
|
||||
pthread_mutex_unlock(&handle_lock);
|
||||
if (host_native_thread_create(audio_thread, binding, 256 * 1024) != 0)
|
||||
if (callback && host_native_thread_create(audio_thread, binding, 256 * 1024) != 0)
|
||||
host_fatal("cannot start the audio thread");
|
||||
return binding->handle;
|
||||
}
|
||||
@@ -451,43 +369,6 @@ int host_sdl_resume_audio_stream_device(uint32_t stream)
|
||||
return object ? SDL_ResumeAudioStreamDevice(object) : 0;
|
||||
}
|
||||
|
||||
/* (voice chat's microphone: port/linux/src/voice_audio.c) */
|
||||
int host_sdl_get_audio_stream_data(uint32_t stream, void *data, int length)
|
||||
{
|
||||
SDL_AudioStream *object = handle_get(stream, _handle_audio);
|
||||
|
||||
return object ? SDL_GetAudioStreamData(object, data, length) : -1;
|
||||
}
|
||||
|
||||
int host_sdl_get_audio_stream_available(uint32_t stream)
|
||||
{
|
||||
SDL_AudioStream *object = handle_get(stream, _handle_audio);
|
||||
|
||||
return object ? SDL_GetAudioStreamAvailable(object) : -1;
|
||||
}
|
||||
|
||||
/* (a stream with a callback has a thread the guest's callbacks run on:
|
||||
once no callback can run any more, it is told to end, and frees the
|
||||
binding and its stack as it goes) */
|
||||
void host_sdl_destroy_audio_stream(uint32_t stream)
|
||||
{
|
||||
void *context;
|
||||
SDL_AudioStream *object = handle_release(stream, _handle_audio, &context);
|
||||
struct audio_binding *binding = context;
|
||||
|
||||
if (!object)
|
||||
return;
|
||||
/* (returns once a callback that is running has finished) */
|
||||
SDL_DestroyAudioStream(object);
|
||||
if (binding)
|
||||
{
|
||||
pthread_mutex_lock(&binding->lock);
|
||||
binding->quit = 1;
|
||||
pthread_cond_signal(&binding->requested);
|
||||
pthread_mutex_unlock(&binding->lock);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- the clipboard (internet play's invite links) */
|
||||
|
||||
int host_sdl_set_clipboard_text(const char *text)
|
||||
@@ -514,35 +395,3 @@ int host_sdl_show_simple_message_box(uint32_t flags, const char *title, const ch
|
||||
{
|
||||
return SDL_ShowSimpleMessageBox((SDL_MessageBoxFlags)flags, title, message, NULL) ? 1 : 0;
|
||||
}
|
||||
|
||||
/* ---------- a question for the player (the mods at startup: port_mods.c) */
|
||||
|
||||
int host_sdl_show_message_box(uint32_t flags, const char *title, const char *message, int default_index,
|
||||
const char *button0, const char *button1, const char *button2)
|
||||
{
|
||||
const char *labels[3] = { button0, button1, button2 };
|
||||
SDL_MessageBoxButtonData buttons[3];
|
||||
SDL_MessageBoxData question;
|
||||
int count = 0;
|
||||
int answer = -1;
|
||||
int index;
|
||||
|
||||
for (index = 0; index < 3; index++)
|
||||
{
|
||||
if (!labels[index])
|
||||
continue;
|
||||
buttons[count].flags = index == default_index ?
|
||||
SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT | SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT : 0;
|
||||
buttons[count].buttonID = index;
|
||||
buttons[count].text = labels[index];
|
||||
count++;
|
||||
}
|
||||
question.flags = (SDL_MessageBoxFlags)flags;
|
||||
question.window = NULL;
|
||||
question.title = title;
|
||||
question.message = message;
|
||||
question.numbuttons = count;
|
||||
question.buttons = buttons;
|
||||
question.colorScheme = NULL;
|
||||
return SDL_ShowMessageBox(&question, &answer) ? answer : -1;
|
||||
}
|
||||
@@ -131,10 +131,6 @@ static void *thread_main(void *context)
|
||||
free(context);
|
||||
host_debug_thread_started();
|
||||
start.function(start.argument);
|
||||
/* (a thread the guest made has let its struct pthread go by now; one
|
||||
of the host's that ran guest code, the audio thread, has it still) */
|
||||
if (guest_tp)
|
||||
((guest_function)(uintptr_t)host_image.header->thread_detach)(0, 0, 0, 0);
|
||||
host_debug_thread_exited();
|
||||
guest_tp = 0;
|
||||
|
||||
|
||||
@@ -1,229 +0,0 @@
|
||||
/*
|
||||
HOST_TOUCH.C
|
||||
|
||||
The on-screen touch controls between the overlay and the game. The overlay
|
||||
(app/.../TouchControls.java) is an Android view over SDL's surface: it
|
||||
hands its stick, buttons, view swipes and gyroscope turns over JNI on the UI
|
||||
thread, and the game reads them through host imports when it reads port 0's
|
||||
controller (port/linux/src/xinput_sdl.c). The game hands back what the
|
||||
overlay needs to know: whether it is in a game with no menu or cinematic up
|
||||
and the input.touch_controls setting (host_touch_scene), the profile's
|
||||
button mapping, which names the buttons (host_touch_bindings), and how hard
|
||||
port 0 rumbles.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
/* a press shorter than this still reaches the game: it reads the
|
||||
controller once a frame and acts at 30 ticks a second, and a quick tap can
|
||||
go down and up between two reads */
|
||||
#define TOUCH_TAP_NS 60000000LL
|
||||
/* view motion and rumble older than this are dropped: left over from the
|
||||
menus, a cinematic or the app in the background */
|
||||
#define TOUCH_STALE_NS 150000000LL
|
||||
|
||||
/* SDL's 15 gamepad buttons, then the left and right triggers */
|
||||
#define TOUCH_INPUTS 17
|
||||
|
||||
static pthread_mutex_t touch_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
/* the SDL axes (left x, y, right x, y, left trigger, right trigger), then
|
||||
the SDL button bits */
|
||||
static int32_t touch_state[7];
|
||||
static int64_t touch_pressed_ns[TOUCH_INPUTS];
|
||||
static float look_delta[2];
|
||||
static int64_t look_ns;
|
||||
/* the gyroscope's turn, apart: the profile's invert is the swipe's only */
|
||||
static float gyro_delta[2];
|
||||
static int64_t gyro_ns;
|
||||
static int rumble_amplitude;
|
||||
static int64_t rumble_ns;
|
||||
static volatile int touch_scene;
|
||||
/* the game control on each controller button (-1: none), and a count of
|
||||
its changes, which the overlay polls */
|
||||
#define TOUCH_BUTTONS 16
|
||||
static int32_t touch_bindings[TOUCH_BUTTONS];
|
||||
static int touch_bindings_serial;
|
||||
|
||||
static int64_t now_ns(void)
|
||||
{
|
||||
struct timespec now;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
return (int64_t)now.tv_sec * 1000000000LL + now.tv_nsec;
|
||||
}
|
||||
|
||||
/* the inputs of a state as bits: buttons, then the triggers */
|
||||
static uint32_t touch_inputs(const int32_t *state)
|
||||
{
|
||||
return ((uint32_t)state[6] & 0x7fff) | (state[4] ? 1u << 15 : 0) | (state[5] ? 1u << 16 : 0);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_halo_decomp_TouchControls_nativeState(
|
||||
JNIEnv *env, jclass cls, jint lx, jint ly, jint rx, jint ry,
|
||||
jint lt, jint rt, jint buttons)
|
||||
{
|
||||
int32_t next[] = { lx, ly, rx, ry, lt, rt, buttons };
|
||||
uint32_t pressed;
|
||||
int64_t now = now_ns();
|
||||
int input;
|
||||
|
||||
(void)env;
|
||||
(void)cls;
|
||||
pthread_mutex_lock(&touch_lock);
|
||||
pressed = touch_inputs(next) & ~touch_inputs(touch_state);
|
||||
for (input = 0; input < TOUCH_INPUTS; input++)
|
||||
{
|
||||
if (pressed & (1u << input))
|
||||
touch_pressed_ns[input] = now;
|
||||
}
|
||||
memcpy(touch_state, next, sizeof(next));
|
||||
pthread_mutex_unlock(&touch_lock);
|
||||
}
|
||||
|
||||
/* the guest's: the overlay's controller state, with each press held for
|
||||
at least TOUCH_TAP_NS */
|
||||
void host_touch_read(int32_t *state)
|
||||
{
|
||||
int64_t now = now_ns();
|
||||
int input;
|
||||
|
||||
pthread_mutex_lock(&touch_lock);
|
||||
memcpy(state, touch_state, sizeof(touch_state));
|
||||
for (input = 0; input < TOUCH_INPUTS; input++)
|
||||
{
|
||||
if (touch_pressed_ns[input] && now - touch_pressed_ns[input] < TOUCH_TAP_NS)
|
||||
{
|
||||
if (input < 15)
|
||||
state[6] |= 1 << input;
|
||||
else if (!state[4 + input - 15])
|
||||
state[4 + input - 15] = 32767;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&touch_lock);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_halo_decomp_TouchControls_nativeLook(
|
||||
JNIEnv *env, jclass cls, jfloat dx, jfloat dy)
|
||||
{
|
||||
(void)env;
|
||||
(void)cls;
|
||||
pthread_mutex_lock(&touch_lock);
|
||||
look_delta[0] += dx;
|
||||
look_delta[1] += dy;
|
||||
look_ns = now_ns();
|
||||
pthread_mutex_unlock(&touch_lock);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_halo_decomp_TouchControls_nativeGyro(
|
||||
JNIEnv *env, jclass cls, jfloat dx, jfloat dy)
|
||||
{
|
||||
(void)env;
|
||||
(void)cls;
|
||||
pthread_mutex_lock(&touch_lock);
|
||||
gyro_delta[0] += dx;
|
||||
gyro_delta[1] += dy;
|
||||
gyro_ns = now_ns();
|
||||
pthread_mutex_unlock(&touch_lock);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_halo_decomp_TouchControls_nativeLookReset(JNIEnv *env, jclass cls)
|
||||
{
|
||||
(void)env;
|
||||
(void)cls;
|
||||
pthread_mutex_lock(&touch_lock);
|
||||
look_delta[0] = look_delta[1] = 0.0f;
|
||||
gyro_delta[0] = gyro_delta[1] = 0.0f;
|
||||
pthread_mutex_unlock(&touch_lock);
|
||||
}
|
||||
|
||||
/* the guest's: the view swipe, then the gyroscope's turn, since the last
|
||||
read, into delta[4], in the overlay's logical pixels with its sensitivity
|
||||
applied */
|
||||
void host_touch_look_read(float *delta)
|
||||
{
|
||||
int64_t now = now_ns();
|
||||
|
||||
pthread_mutex_lock(&touch_lock);
|
||||
memcpy(delta, look_delta, sizeof(look_delta));
|
||||
memcpy(delta + 2, gyro_delta, sizeof(gyro_delta));
|
||||
if (now - look_ns > TOUCH_STALE_NS)
|
||||
delta[0] = delta[1] = 0.0f;
|
||||
if (now - gyro_ns > TOUCH_STALE_NS)
|
||||
delta[2] = delta[3] = 0.0f;
|
||||
look_delta[0] = look_delta[1] = 0.0f;
|
||||
gyro_delta[0] = gyro_delta[1] = 0.0f;
|
||||
pthread_mutex_unlock(&touch_lock);
|
||||
}
|
||||
|
||||
/* the guest's: port 0's motors (XInputSetState), each 0..65535; the game
|
||||
sends them every frame, and zero while paused or with the profile's
|
||||
vibration off */
|
||||
void host_touch_rumble(unsigned int low, unsigned int high)
|
||||
{
|
||||
unsigned int strength = low > high ? low : high;
|
||||
|
||||
pthread_mutex_lock(&touch_lock);
|
||||
rumble_amplitude = strength ? 64 + (int)(strength * 191u / 65535u) : 0;
|
||||
rumble_ns = now_ns();
|
||||
pthread_mutex_unlock(&touch_lock);
|
||||
}
|
||||
|
||||
/* the phone's vibration strength, 0 or 64..255 */
|
||||
JNIEXPORT jint JNICALL Java_com_halo_decomp_TouchControls_nativeRumble(JNIEnv *env, jclass cls)
|
||||
{
|
||||
int amplitude;
|
||||
|
||||
(void)env;
|
||||
(void)cls;
|
||||
pthread_mutex_lock(&touch_lock);
|
||||
amplitude = now_ns() - rumble_ns > TOUCH_STALE_NS ? 0 : rumble_amplitude;
|
||||
pthread_mutex_unlock(&touch_lock);
|
||||
return amplitude;
|
||||
}
|
||||
|
||||
/* the guest's, at every read of port 0: port/linux/src/touch_input.c's
|
||||
_touch_scene_* bits */
|
||||
void host_touch_scene(int scene)
|
||||
{
|
||||
touch_scene = scene;
|
||||
}
|
||||
|
||||
/* the guest's, when the profile's mapping changes: the game control on
|
||||
each of the 16 controller buttons (port/linux/game/touch_game.c) */
|
||||
void host_touch_bindings(const int32_t *controls)
|
||||
{
|
||||
pthread_mutex_lock(&touch_lock);
|
||||
memcpy(touch_bindings, controls, sizeof(touch_bindings));
|
||||
touch_bindings_serial++;
|
||||
pthread_mutex_unlock(&touch_lock);
|
||||
}
|
||||
|
||||
/* the mapping into controls[16]; returns its count of changes (0 before the
|
||||
game has sent it) */
|
||||
JNIEXPORT jint JNICALL Java_com_halo_decomp_TouchControls_nativeBindings(JNIEnv *env, jclass cls,
|
||||
jintArray controls)
|
||||
{
|
||||
int32_t copy[TOUCH_BUTTONS];
|
||||
int serial;
|
||||
|
||||
(void)cls;
|
||||
pthread_mutex_lock(&touch_lock);
|
||||
memcpy(copy, touch_bindings, sizeof(copy));
|
||||
serial = touch_bindings_serial;
|
||||
pthread_mutex_unlock(&touch_lock);
|
||||
if (controls && (*env)->GetArrayLength(env, controls) >= TOUCH_BUTTONS)
|
||||
(*env)->SetIntArrayRegion(env, controls, 0, TOUCH_BUTTONS, (const jint *)copy);
|
||||
return serial;
|
||||
}
|
||||
|
||||
/* 0 until the game has read its controller once */
|
||||
JNIEXPORT jint JNICALL Java_com_halo_decomp_TouchControls_nativeScene(JNIEnv *env, jclass cls)
|
||||
{
|
||||
(void)env;
|
||||
(void)cls;
|
||||
return touch_scene;
|
||||
}
|
||||
@@ -0,0 +1,494 @@
|
||||
/*
|
||||
HOST_VOICE.C
|
||||
|
||||
The voice chat's sound (the VR port's; port/linux/game/network_voice.c
|
||||
sends and receives it): the microphone, Opus, and the voices played. It
|
||||
runs here, natively, where SDL's audio threads may call it.
|
||||
|
||||
- The microphone: SDL's default recording device, mono at 16 kHz, with
|
||||
Android's voice communication preset (its echo cancelling and noise
|
||||
suppression: SDL_HINT_ANDROID_AAUDIO_INPUT_PRESET). Every 20 ms of it
|
||||
that is loud enough to be speech (or follows speech closely, VAD_HANGOVER)
|
||||
is encoded (Opus, VOIP, 16 kbit/s) for the guest to send.
|
||||
- The voices: each speaker's packets, decoded as they come (a gap in their
|
||||
numbers concealed by Opus's packet loss concealment), wait in the
|
||||
speaker's buffer until JITTER_START of them is there, and are mixed, each
|
||||
at the gains its latest packet was given (left and right: where the
|
||||
speaker is), into a stream of their own.
|
||||
|
||||
The devices are opened and closed on a thread of their own (voice_worker):
|
||||
opening a microphone can take a long while (an emulator's took a minute),
|
||||
which the game, whose clock the other machines follow, must not wait for.
|
||||
*/
|
||||
|
||||
#include "host.h"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <opus.h>
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
|
||||
enum
|
||||
{
|
||||
VOICE_RATE = 16000,
|
||||
FRAME_SAMPLES = VOICE_RATE / 50,
|
||||
MAXIMUM_PACKET = 200,
|
||||
MAXIMUM_SPEAKERS = 32,
|
||||
/* a speaker's buffer: two seconds */
|
||||
SPEAKER_BUFFER = VOICE_RATE * 2,
|
||||
/* played from once this much is there, after silence */
|
||||
JITTER_START = FRAME_SAMPLES * 3,
|
||||
/* more than this behind: the oldest dropped */
|
||||
JITTER_MAXIMUM = FRAME_SAMPLES * 15,
|
||||
/* frames sent on after the voice drops below the threshold */
|
||||
VAD_HANGOVER = 15,
|
||||
BITRATE = 16000,
|
||||
};
|
||||
|
||||
struct speaker
|
||||
{
|
||||
int used;
|
||||
int id;
|
||||
OpusDecoder *decoder;
|
||||
int has_sequence;
|
||||
unsigned short sequence;
|
||||
short buffer[SPEAKER_BUFFER];
|
||||
int read;
|
||||
int count;
|
||||
int playing;
|
||||
float gain_left;
|
||||
float gain_right;
|
||||
unsigned long long heard_ticks;
|
||||
};
|
||||
|
||||
static struct
|
||||
{
|
||||
SDL_Mutex *lock;
|
||||
/* the devices wanted, which the worker opens and closes to match
|
||||
(under worker_lock); the recording stream is read under it too */
|
||||
pthread_mutex_t worker_lock;
|
||||
pthread_cond_t worker_wake;
|
||||
int worker_started;
|
||||
int want_playback;
|
||||
int want_recording;
|
||||
/* the microphone */
|
||||
SDL_AudioStream *recording;
|
||||
OpusEncoder *encoder;
|
||||
short frame[FRAME_SAMPLES];
|
||||
int frame_count;
|
||||
int hangover;
|
||||
float threshold;
|
||||
int level;
|
||||
/* the voices */
|
||||
SDL_AudioStream *playback;
|
||||
struct speaker speakers[MAXIMUM_SPEAKERS];
|
||||
float volume;
|
||||
} voice;
|
||||
|
||||
static void voice_lock(void)
|
||||
{
|
||||
if (!voice.lock)
|
||||
voice.lock = SDL_CreateMutex();
|
||||
SDL_LockMutex(voice.lock);
|
||||
}
|
||||
|
||||
static void voice_unlock(void)
|
||||
{
|
||||
SDL_UnlockMutex(voice.lock);
|
||||
}
|
||||
|
||||
/* the voices mixed, as SDL asks for them (on its audio thread) */
|
||||
static void SDLCALL voice_playback_callback(void *userdata, SDL_AudioStream *stream, int additional, int total)
|
||||
{
|
||||
short mixed[2 * 512];
|
||||
(void)userdata;
|
||||
(void)total;
|
||||
|
||||
while (additional > 0)
|
||||
{
|
||||
int frames = additional / 4;
|
||||
int frame;
|
||||
int index;
|
||||
|
||||
if (frames > 512)
|
||||
frames = 512;
|
||||
if (frames <= 0)
|
||||
frames = 1;
|
||||
memset(mixed, 0, sizeof(mixed));
|
||||
voice_lock();
|
||||
for (index = 0; index < MAXIMUM_SPEAKERS; index++)
|
||||
{
|
||||
struct speaker *speaker = &voice.speakers[index];
|
||||
|
||||
if (!speaker->used)
|
||||
continue;
|
||||
if (!speaker->playing && speaker->count >= JITTER_START)
|
||||
speaker->playing = 1;
|
||||
if (!speaker->playing)
|
||||
continue;
|
||||
for (frame = 0; frame < frames && speaker->count > 0; frame++)
|
||||
{
|
||||
float sample = (float)speaker->buffer[speaker->read] * voice.volume;
|
||||
int left = mixed[2 * frame] + (int)(sample * speaker->gain_left);
|
||||
int right = mixed[2 * frame + 1] + (int)(sample * speaker->gain_right);
|
||||
|
||||
mixed[2 * frame] = (short)(left > 32767 ? 32767 : left < -32768 ? -32768 : left);
|
||||
mixed[2 * frame + 1] = (short)(right > 32767 ? 32767 : right < -32768 ? -32768 : right);
|
||||
speaker->read = (speaker->read + 1) % SPEAKER_BUFFER;
|
||||
speaker->count--;
|
||||
}
|
||||
/* (run dry: wait for enough again) */
|
||||
if (!speaker->count)
|
||||
speaker->playing = 0;
|
||||
}
|
||||
voice_unlock();
|
||||
SDL_PutAudioStreamData(stream, mixed, frames * 4);
|
||||
additional -= frames * 4;
|
||||
}
|
||||
}
|
||||
|
||||
static int voice_open_playback(void)
|
||||
{
|
||||
SDL_AudioSpec spec;
|
||||
|
||||
if (voice.playback)
|
||||
return 1;
|
||||
spec.format = SDL_AUDIO_S16;
|
||||
spec.channels = 2;
|
||||
spec.freq = VOICE_RATE;
|
||||
voice.playback = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec, voice_playback_callback,
|
||||
NULL);
|
||||
if (!voice.playback)
|
||||
{
|
||||
host_logf(HOST_LOG_WARN, "voice: cannot open the playback stream: %s", SDL_GetError());
|
||||
return 0;
|
||||
}
|
||||
SDL_ResumeAudioStreamDevice(voice.playback);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static SDL_AudioStream *voice_open_recording(void)
|
||||
{
|
||||
SDL_AudioSpec spec;
|
||||
SDL_AudioStream *recording;
|
||||
int error;
|
||||
|
||||
if (!voice.encoder)
|
||||
{
|
||||
voice.encoder = opus_encoder_create(VOICE_RATE, 1, OPUS_APPLICATION_VOIP, &error);
|
||||
if (!voice.encoder)
|
||||
{
|
||||
host_logf(HOST_LOG_WARN, "voice: cannot make the encoder (%d)", error);
|
||||
return NULL;
|
||||
}
|
||||
opus_encoder_ctl(voice.encoder, OPUS_SET_BITRATE(BITRATE));
|
||||
opus_encoder_ctl(voice.encoder, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE));
|
||||
opus_encoder_ctl(voice.encoder, OPUS_SET_INBAND_FEC(1));
|
||||
opus_encoder_ctl(voice.encoder, OPUS_SET_PACKET_LOSS_PERC(10));
|
||||
}
|
||||
/* Android's voice communication preset: echo cancelling, noise
|
||||
suppression (AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION) */
|
||||
SDL_SetHint(SDL_HINT_ANDROID_AAUDIO_INPUT_PRESET, "7");
|
||||
spec.format = SDL_AUDIO_S16;
|
||||
spec.channels = 1;
|
||||
spec.freq = VOICE_RATE;
|
||||
recording = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_RECORDING, &spec, NULL, NULL);
|
||||
if (!recording)
|
||||
{
|
||||
host_logf(HOST_LOG_WARN, "voice: cannot open the microphone: %s", SDL_GetError());
|
||||
return NULL;
|
||||
}
|
||||
SDL_ResumeAudioStreamDevice(recording);
|
||||
host_logf(HOST_LOG_INFO, "voice: the microphone is open");
|
||||
return recording;
|
||||
}
|
||||
|
||||
static void voice_close_recording(void)
|
||||
{
|
||||
SDL_AudioStream *recording;
|
||||
|
||||
pthread_mutex_lock(&voice.worker_lock);
|
||||
recording = voice.recording;
|
||||
voice.recording = NULL;
|
||||
voice.level = 0;
|
||||
pthread_mutex_unlock(&voice.worker_lock);
|
||||
if (!recording)
|
||||
return;
|
||||
SDL_DestroyAudioStream(recording);
|
||||
host_logf(HOST_LOG_INFO, "voice: the microphone is closed");
|
||||
}
|
||||
|
||||
static void voice_close_playback(void)
|
||||
{
|
||||
SDL_AudioStream *playback = voice.playback;
|
||||
|
||||
voice.playback = NULL;
|
||||
if (playback)
|
||||
SDL_DestroyAudioStream(playback);
|
||||
}
|
||||
|
||||
/* opens and closes the devices as wanted, for as long as the app runs */
|
||||
static void *voice_worker(void *unused)
|
||||
{
|
||||
(void)unused;
|
||||
pthread_mutex_lock(&voice.worker_lock);
|
||||
for (;;)
|
||||
{
|
||||
int want_playback = voice.want_playback;
|
||||
int want_recording = voice.want_recording;
|
||||
int have_playback = voice.playback != NULL;
|
||||
int have_recording = voice.recording != NULL;
|
||||
|
||||
if (want_playback == have_playback && want_recording == have_recording)
|
||||
{
|
||||
pthread_cond_wait(&voice.worker_wake, &voice.worker_lock);
|
||||
continue;
|
||||
}
|
||||
pthread_mutex_unlock(&voice.worker_lock);
|
||||
if (want_recording && !have_recording)
|
||||
{
|
||||
/* (opened outside the lock, which the game reads it under) */
|
||||
SDL_AudioStream *recording = voice_open_recording();
|
||||
|
||||
pthread_mutex_lock(&voice.worker_lock);
|
||||
voice.recording = recording;
|
||||
pthread_mutex_unlock(&voice.worker_lock);
|
||||
/* (a microphone that will not open is not tried again until
|
||||
wanted anew) */
|
||||
if (!recording)
|
||||
{
|
||||
pthread_mutex_lock(&voice.worker_lock);
|
||||
voice.want_recording = 0;
|
||||
pthread_mutex_unlock(&voice.worker_lock);
|
||||
}
|
||||
}
|
||||
else if (!want_recording && have_recording)
|
||||
{
|
||||
voice_close_recording();
|
||||
}
|
||||
if (want_playback && !have_playback)
|
||||
{
|
||||
if (!voice_open_playback())
|
||||
{
|
||||
pthread_mutex_lock(&voice.worker_lock);
|
||||
voice.want_playback = 0;
|
||||
pthread_mutex_unlock(&voice.worker_lock);
|
||||
}
|
||||
}
|
||||
else if (!want_playback && have_playback)
|
||||
{
|
||||
voice_close_playback();
|
||||
}
|
||||
pthread_mutex_lock(&voice.worker_lock);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void voice_want(int playback, int recording)
|
||||
{
|
||||
if (!voice.worker_started)
|
||||
{
|
||||
voice.worker_started = 1;
|
||||
pthread_mutex_init(&voice.worker_lock, NULL);
|
||||
pthread_cond_init(&voice.worker_wake, NULL);
|
||||
if (host_native_thread_create(voice_worker, NULL, 256 * 1024) != 0)
|
||||
{
|
||||
host_logf(HOST_LOG_WARN, "voice: cannot start the device thread");
|
||||
return;
|
||||
}
|
||||
}
|
||||
pthread_mutex_lock(&voice.worker_lock);
|
||||
voice.want_playback = playback;
|
||||
voice.want_recording = recording;
|
||||
pthread_cond_signal(&voice.worker_wake);
|
||||
pthread_mutex_unlock(&voice.worker_lock);
|
||||
}
|
||||
|
||||
/* ---------- the guest's side */
|
||||
|
||||
int host_voice_start(int microphone, float volume, float threshold)
|
||||
{
|
||||
voice_lock();
|
||||
voice.volume = volume < 0.0f ? 0.0f : volume > 4.0f ? 4.0f : volume;
|
||||
voice.threshold = threshold;
|
||||
voice_unlock();
|
||||
voice_want(1, microphone);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void host_voice_stop(void)
|
||||
{
|
||||
int index;
|
||||
|
||||
voice_want(0, 0);
|
||||
voice_lock();
|
||||
for (index = 0; index < MAXIMUM_SPEAKERS; index++)
|
||||
{
|
||||
if (voice.speakers[index].decoder)
|
||||
opus_decoder_destroy(voice.speakers[index].decoder);
|
||||
}
|
||||
memset(voice.speakers, 0, sizeof(voice.speakers));
|
||||
voice_unlock();
|
||||
}
|
||||
|
||||
int host_voice_take_packets(void *buffer, int size)
|
||||
{
|
||||
unsigned char *out = buffer;
|
||||
int used = 0;
|
||||
|
||||
if (!voice.worker_started)
|
||||
return 0;
|
||||
pthread_mutex_lock(&voice.worker_lock);
|
||||
if (!voice.recording)
|
||||
{
|
||||
voice.frame_count = 0;
|
||||
voice.hangover = 0;
|
||||
pthread_mutex_unlock(&voice.worker_lock);
|
||||
return 0;
|
||||
}
|
||||
for (;;)
|
||||
{
|
||||
int wanted = (FRAME_SAMPLES - voice.frame_count) * (int)sizeof(short);
|
||||
int got = SDL_GetAudioStreamData(voice.recording, voice.frame + voice.frame_count, wanted);
|
||||
double energy = 0.0;
|
||||
int index;
|
||||
|
||||
if (got <= 0)
|
||||
break;
|
||||
voice.frame_count += got / (int)sizeof(short);
|
||||
if (voice.frame_count < FRAME_SAMPLES)
|
||||
break;
|
||||
voice.frame_count = 0;
|
||||
for (index = 0; index < FRAME_SAMPLES; index++)
|
||||
energy += (double)voice.frame[index] * voice.frame[index];
|
||||
energy = SDL_sqrt(energy / FRAME_SAMPLES) / 32768.0;
|
||||
voice.level = (int)(energy * 1000.0);
|
||||
if (energy >= voice.threshold)
|
||||
voice.hangover = VAD_HANGOVER;
|
||||
else if (voice.hangover > 0)
|
||||
voice.hangover--;
|
||||
else
|
||||
continue;
|
||||
if (used + 1 + MAXIMUM_PACKET > size)
|
||||
continue;
|
||||
{
|
||||
int length = opus_encode(voice.encoder, voice.frame, FRAME_SAMPLES, out + used + 1, MAXIMUM_PACKET);
|
||||
|
||||
if (length > 0 && length < 256)
|
||||
{
|
||||
out[used] = (unsigned char)length;
|
||||
used += 1 + length;
|
||||
}
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&voice.worker_lock);
|
||||
return used;
|
||||
}
|
||||
|
||||
int host_voice_level(void)
|
||||
{
|
||||
return voice.level;
|
||||
}
|
||||
|
||||
void host_voice_play(int id, int sequence, const void *data, int length, float gain_left, float gain_right)
|
||||
{
|
||||
struct speaker *speaker = NULL;
|
||||
struct speaker *oldest = NULL;
|
||||
short decoded[FRAME_SAMPLES * 6];
|
||||
int frames[4];
|
||||
int frame_count = 0;
|
||||
int index;
|
||||
|
||||
if (length <= 0 || length > MAXIMUM_PACKET)
|
||||
return;
|
||||
voice_lock();
|
||||
for (index = 0; index < MAXIMUM_SPEAKERS && !speaker; index++)
|
||||
{
|
||||
if (voice.speakers[index].used && voice.speakers[index].id == id)
|
||||
speaker = &voice.speakers[index];
|
||||
}
|
||||
if (!speaker)
|
||||
{
|
||||
for (index = 0; index < MAXIMUM_SPEAKERS && !speaker; index++)
|
||||
{
|
||||
if (!voice.speakers[index].used)
|
||||
speaker = &voice.speakers[index];
|
||||
else if (!oldest || voice.speakers[index].heard_ticks < oldest->heard_ticks)
|
||||
oldest = &voice.speakers[index];
|
||||
}
|
||||
if (!speaker)
|
||||
speaker = oldest;
|
||||
if (!speaker->decoder)
|
||||
{
|
||||
int error;
|
||||
|
||||
speaker->decoder = opus_decoder_create(VOICE_RATE, 1, &error);
|
||||
if (!speaker->decoder)
|
||||
{
|
||||
voice_unlock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
opus_decoder_ctl(speaker->decoder, OPUS_RESET_STATE);
|
||||
}
|
||||
speaker->used = 1;
|
||||
speaker->id = id;
|
||||
speaker->has_sequence = 0;
|
||||
speaker->read = speaker->count = 0;
|
||||
speaker->playing = 0;
|
||||
}
|
||||
speaker->heard_ticks = SDL_GetTicks();
|
||||
speaker->gain_left = gain_left;
|
||||
speaker->gain_right = gain_right;
|
||||
{
|
||||
unsigned short number = (unsigned short)sequence;
|
||||
|
||||
if (speaker->has_sequence)
|
||||
{
|
||||
short gap = (short)(number - speaker->sequence);
|
||||
|
||||
/* (late, or again: dropped) */
|
||||
if (gap <= 0)
|
||||
{
|
||||
voice_unlock();
|
||||
return;
|
||||
}
|
||||
/* (lost ones: concealed, a few) */
|
||||
if (gap > 1 && gap <= 4 && speaker->count > 0)
|
||||
{
|
||||
int missing;
|
||||
|
||||
for (missing = 1; missing < gap && frame_count < 3; missing++)
|
||||
{
|
||||
frames[frame_count] = opus_decode(speaker->decoder, NULL, 0, decoded + frame_count * FRAME_SAMPLES,
|
||||
FRAME_SAMPLES, 0);
|
||||
frame_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
speaker->has_sequence = 1;
|
||||
speaker->sequence = number;
|
||||
}
|
||||
frames[frame_count] = opus_decode(speaker->decoder, data, length, decoded + frame_count * FRAME_SAMPLES,
|
||||
FRAME_SAMPLES * 2, 0);
|
||||
frame_count++;
|
||||
for (index = 0; index < frame_count; index++)
|
||||
{
|
||||
int sample;
|
||||
|
||||
for (sample = 0; sample < frames[index] && sample < FRAME_SAMPLES * 2; sample++)
|
||||
{
|
||||
if (speaker->count >= JITTER_MAXIMUM)
|
||||
{
|
||||
speaker->read = (speaker->read + 1) % SPEAKER_BUFFER;
|
||||
speaker->count--;
|
||||
}
|
||||
speaker->buffer[(speaker->read + speaker->count) % SPEAKER_BUFFER] =
|
||||
decoded[index * FRAME_SAMPLES + sample];
|
||||
speaker->count++;
|
||||
}
|
||||
}
|
||||
voice_unlock();
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
/*
|
||||
HOST_WATCH_HASH.C
|
||||
|
||||
Write tracking by page contents (host_watch_hash.h).
|
||||
*/
|
||||
|
||||
#include "host_watch_hash.h"
|
||||
|
||||
#ifdef __wasm_simd128__
|
||||
/*
|
||||
FNV-style mixing in sixteen independent 32-bit lanes, four vectors of four
|
||||
(WebAssembly's SIMD: the web build, web_memory_watch.c), so that no lane
|
||||
waits for another and the multiplies are the vector unit's own; its 64-bit
|
||||
multiplies are scalar, which made the hashing of every watched page each
|
||||
frame a quarter of the web build's frame, twice what this takes. A change of
|
||||
one word changes its lane's state for good (xor and an odd multiply are both
|
||||
invertible), and the fold keeps every lane's bits, so a single-word write
|
||||
always shows. Changes of several words could cancel each other, which is
|
||||
unlikely for game data. (host_watch_hash.h)
|
||||
*/
|
||||
typedef uint32_t watch_hash_lanes __attribute__((vector_size(16), aligned(4), may_alias));
|
||||
|
||||
uint64_t watch_hash_page(const uint8_t *page)
|
||||
{
|
||||
const watch_hash_lanes *words = (const watch_hash_lanes *)page;
|
||||
const watch_hash_lanes prime = { 0x01000193u, 0x01000193u, 0x01000193u, 0x01000193u };
|
||||
watch_hash_lanes lane0 = { 0x811c9dc5u, 0x9e3779b9u, 0x85ebca6bu, 0xc2b2ae35u };
|
||||
watch_hash_lanes lane1 = { 0x27d4eb2fu, 0x165667b1u, 0xd3a2646cu, 0xfd7046c5u };
|
||||
watch_hash_lanes lane2 = { 0xb55a4f09u, 0x7feb352du, 0x846ca68bu, 0x2c1b3c6du };
|
||||
watch_hash_lanes lane3 = { 0x297a2d39u, 0xe6546b64u, 0xcc9e2d51u, 0x1b873593u };
|
||||
watch_hash_lanes folded;
|
||||
uint32_t index;
|
||||
|
||||
for (index = 0; index < WATCH_HASH_PAGE_SIZE / sizeof(watch_hash_lanes); index += 4)
|
||||
{
|
||||
lane0 = (lane0 ^ words[index + 0]) * prime;
|
||||
lane1 = (lane1 ^ words[index + 1]) * prime;
|
||||
lane2 = (lane2 ^ words[index + 2]) * prime;
|
||||
lane3 = (lane3 ^ words[index + 3]) * prime;
|
||||
}
|
||||
/* (each vector's lanes turned before they are combined, so that the same
|
||||
change in two of them does not cancel) */
|
||||
folded = lane0 ^ ((lane1 << 8) | (lane1 >> 24)) ^ ((lane2 << 16) | (lane2 >> 16)) ^ ((lane3 << 24) | (lane3 >> 8));
|
||||
return ((uint64_t)(folded[0] ^ ((folded[2] << 13) | (folded[2] >> 19))) << 32) |
|
||||
(folded[1] ^ ((folded[3] << 13) | (folded[3] >> 19)));
|
||||
}
|
||||
#else
|
||||
/*
|
||||
FNV-style mixing in four independent lanes, so that the multiplies of
|
||||
one lane do not wait for another's. A change of one word changes its
|
||||
lane's state for good (xor and an odd multiply are both invertible), so
|
||||
a single-word write always shows. Changes of several words could cancel
|
||||
each other, which is unlikely for game data. (host_watch_hash.h)
|
||||
*/
|
||||
uint64_t watch_hash_page(const uint8_t *page)
|
||||
{
|
||||
const uint64_t *words = (const uint64_t *)page;
|
||||
uint64_t lane0 = 0xcbf29ce484222325ULL, lane1 = 0x9e3779b97f4a7c15ULL;
|
||||
uint64_t lane2 = 0xc2b2ae3d27d4eb4fULL, lane3 = 0x165667b19e3779f9ULL;
|
||||
uint32_t index;
|
||||
|
||||
for (index = 0; index < WATCH_HASH_PAGE_SIZE / 8; index += 4)
|
||||
{
|
||||
lane0 = (lane0 ^ words[index + 0]) * 0x100000001b3ULL;
|
||||
lane1 = (lane1 ^ words[index + 1]) * 0x100000001b3ULL;
|
||||
lane2 = (lane2 ^ words[index + 2]) * 0x100000001b3ULL;
|
||||
lane3 = (lane3 ^ words[index + 3]) * 0x100000001b3ULL;
|
||||
}
|
||||
return lane0 ^ ((lane1 << 16) | (lane1 >> 48)) ^ ((lane2 << 32) | (lane2 >> 32)) ^
|
||||
((lane3 << 48) | (lane3 >> 16));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* clamps last to the watched memory; 0 when nothing is left of the range */
|
||||
static int clamp(const struct watch_hash *watch, uint32_t first, uint32_t *last)
|
||||
{
|
||||
if (first >= watch->page_count || first > *last)
|
||||
return 0;
|
||||
if (*last >= watch->page_count)
|
||||
*last = watch->page_count - 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const uint8_t *page_memory(const struct watch_hash *watch, uint32_t page)
|
||||
{
|
||||
return watch->base + (uint64_t)page * WATCH_HASH_PAGE_SIZE;
|
||||
}
|
||||
|
||||
void watch_hash_protect(struct watch_hash *watch, uint32_t first, uint32_t last)
|
||||
{
|
||||
uint32_t page;
|
||||
|
||||
if (!clamp(watch, first, &last))
|
||||
return;
|
||||
for (page = first; page <= last; page++)
|
||||
{
|
||||
if (watch->watched[page])
|
||||
continue;
|
||||
watch->watched[page] = 1;
|
||||
watch->hash[page] = watch_hash_page(page_memory(watch, page));
|
||||
watch->hashed_frame[page] = watch->frame;
|
||||
if (watch->unchanged)
|
||||
watch->unchanged[page] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* a stable page hashed recently enough: not hashed again yet
|
||||
(host_watch_hash.h) */
|
||||
static int stable_for_now(const struct watch_hash *watch, uint32_t page)
|
||||
{
|
||||
return watch->unchanged && watch->unchanged[page] >= WATCH_HASH_STABLE_CHECKS &&
|
||||
watch->frame - watch->hashed_frame[page] < WATCH_HASH_STABLE_FRAMES;
|
||||
}
|
||||
|
||||
uint32_t watch_hash_generation(struct watch_hash *watch, uint32_t first, uint32_t last)
|
||||
{
|
||||
uint32_t page, newest = 0;
|
||||
|
||||
if (!clamp(watch, first, &last))
|
||||
return 0;
|
||||
for (page = first; page <= last; page++)
|
||||
{
|
||||
if (watch->watched[page] && watch->hashed_frame[page] != watch->frame && !stable_for_now(watch, page))
|
||||
{
|
||||
uint64_t hash = watch_hash_page(page_memory(watch, page));
|
||||
|
||||
watch->hashed_frame[page] = watch->frame;
|
||||
if (hash != watch->hash[page])
|
||||
{
|
||||
watch->hash[page] = hash;
|
||||
watch->generation[page] = __sync_add_and_fetch(watch->current_generation, 1);
|
||||
if (watch->unchanged)
|
||||
watch->unchanged[page] = 0;
|
||||
}
|
||||
else if (watch->unchanged && watch->unchanged[page] < WATCH_HASH_STABLE_CHECKS)
|
||||
{
|
||||
watch->unchanged[page]++;
|
||||
}
|
||||
}
|
||||
if (watch->generation[page] > newest)
|
||||
newest = watch->generation[page];
|
||||
}
|
||||
return newest;
|
||||
}
|
||||
|
||||
void watch_hash_forget(struct watch_hash *watch, uint32_t first, uint32_t last)
|
||||
{
|
||||
uint32_t page;
|
||||
|
||||
if (!clamp(watch, first, &last))
|
||||
return;
|
||||
for (page = first; page <= last; page++)
|
||||
{
|
||||
watch->watched[page] = 0;
|
||||
watch->generation[page] = __sync_add_and_fetch(watch->current_generation, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void watch_hash_prepare_write(struct watch_hash *watch, uint32_t first, uint32_t last)
|
||||
{
|
||||
uint32_t page;
|
||||
|
||||
if (!watch->unchanged || !clamp(watch, first, &last))
|
||||
return;
|
||||
for (page = first; page <= last; page++)
|
||||
watch->unchanged[page] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
The serial changes each frame, so a cache that skips generation queries
|
||||
while the serial stays the same (xbox_textures.c's recent_textures) asks
|
||||
again once a frame. (host_watch_hash.h)
|
||||
*/
|
||||
void watch_hash_begin_frame(struct watch_hash *watch)
|
||||
{
|
||||
watch->frame++;
|
||||
if (!watch->frame)
|
||||
watch->frame = 1;
|
||||
__sync_add_and_fetch(watch->current_generation, 1);
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
HOST_WATCH_HASH.H
|
||||
|
||||
Write tracking by page contents, for processes that cannot catch their own
|
||||
page protection faults: the ARM translation of the x86 Android emulator
|
||||
cannot deliver SIGSEGV to the app, so the protection-based tracking of
|
||||
host_memory.c would stop the game at its first write to a cached page.
|
||||
|
||||
A watched page's hash is kept. Asking for its generation hashes it again,
|
||||
at most once a frame (watch_hash_begin_frame), and a different hash counts
|
||||
as a write. A write is therefore seen in the next frame, not at once.
|
||||
|
||||
Hashing every page drawn from each frame is a large part of the frame on
|
||||
the web (port/web/src/web_memory_watch.c), where most of them never change
|
||||
once loaded. With the optional unchanged counts, a page whose hash stayed the
|
||||
same WATCH_HASH_STABLE_CHECKS times in a row is hashed only every
|
||||
WATCH_HASH_STABLE_FRAMES frames, until a write into it is announced
|
||||
(watch_hash_prepare_write: the file layer's reads, the Direct3D locks) or
|
||||
its hash changes. A write that is not announced into such a page is seen up
|
||||
to that many frames late.
|
||||
*/
|
||||
|
||||
#ifndef HOST_WATCH_HASH_H
|
||||
#define HOST_WATCH_HASH_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define WATCH_HASH_PAGE_SIZE 0x1000u
|
||||
#define WATCH_HASH_STABLE_CHECKS 30u
|
||||
#define WATCH_HASH_STABLE_FRAMES 60u
|
||||
|
||||
struct watch_hash
|
||||
{
|
||||
/* the memory of page 0 */
|
||||
const uint8_t *base;
|
||||
uint32_t page_count;
|
||||
/* page_count entries each */
|
||||
uint8_t *watched;
|
||||
uint64_t *hash;
|
||||
uint32_t *hashed_frame;
|
||||
/* shared with the protection-based tracking (host_memory.c) */
|
||||
uint32_t *generation;
|
||||
volatile uint32_t *current_generation;
|
||||
uint32_t frame;
|
||||
/* NULL, or page_count entries: the checks in a row that found the page
|
||||
unchanged (up to WATCH_HASH_STABLE_CHECKS) */
|
||||
uint8_t *unchanged;
|
||||
};
|
||||
|
||||
/* a hash of one page (WATCH_HASH_PAGE_SIZE bytes, 8-byte aligned) that
|
||||
changes whenever a word of it changes */
|
||||
uint64_t watch_hash_page(const uint8_t *page);
|
||||
|
||||
/* Starts watching pages first to last (inclusive), remembering their hashes.
|
||||
Pages already watched keep their hash; pages beyond page_count are
|
||||
ignored. */
|
||||
void watch_hash_protect(struct watch_hash *watch, uint32_t first, uint32_t last);
|
||||
|
||||
/* The newest generation among pages first to last (inclusive), after hashing
|
||||
again the watched ones not yet hashed this frame (a stable one may wait,
|
||||
above); a page whose hash changed gets a new generation. 0 if the range is
|
||||
outside the watched memory. */
|
||||
uint32_t watch_hash_generation(struct watch_hash *watch, uint32_t first, uint32_t last);
|
||||
|
||||
/* The pages were remapped: treat them as written and unwatched. */
|
||||
void watch_hash_forget(struct watch_hash *watch, uint32_t first, uint32_t last);
|
||||
|
||||
/* The pages are about to be written: hash them every frame again. */
|
||||
void watch_hash_prepare_write(struct watch_hash *watch, uint32_t first, uint32_t last);
|
||||
|
||||
/* A new frame: pages may be hashed again, and the serial changes. */
|
||||
void watch_hash_begin_frame(struct watch_hash *watch);
|
||||
|
||||
#endif
|
||||