mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-18 19:25:56 +00:00
Compare commits
77
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d71c5635e3 | ||
|
|
755761d0de | ||
|
|
550e475962 | ||
|
|
b4dc30b84a | ||
|
|
73a6cca753 | ||
|
|
705bee7d56 | ||
|
|
5aa9b32283 | ||
|
|
711f378ae8 | ||
|
|
c29d56e2b3 | ||
|
|
d63e85bb18 | ||
|
|
c513649beb | ||
|
|
d2e6fef188 | ||
|
|
2224afd2ea | ||
|
|
3a5558f388 | ||
|
|
173248efbe | ||
|
|
5697a1d36e | ||
|
|
bc62ae206f | ||
|
|
076fba185c | ||
|
|
23cbb108ad | ||
|
|
1a1976d9ad | ||
|
|
dc3fcab7e1 | ||
|
|
ba5816e3ae | ||
|
|
56faaa3a2a | ||
|
|
35084dbce8 | ||
|
|
7e7216979a | ||
|
|
7c0c4cda1f | ||
|
|
642da8fdc1 | ||
|
|
30d2f56997 | ||
|
|
4d1a6e0b21 | ||
|
|
bda38b9f26 | ||
|
|
c004b90c54 | ||
|
|
d44e00f9ad | ||
|
|
dad10d8a5d | ||
|
|
b33821e7eb | ||
|
|
1288a84da2 | ||
|
|
e7b76137d1 | ||
|
|
7bb0ea9472 | ||
|
|
1dab6154c7 | ||
|
|
06a6302732 | ||
|
|
65631450ff | ||
|
|
2d9c6a65bb | ||
|
|
ce83f04d9d | ||
|
|
81f031b30f | ||
|
|
ee3ca2c517 | ||
|
|
50e858dcd5 | ||
|
|
8bbf16ed4f | ||
|
|
324e9810cc | ||
|
|
a8ab201d7d | ||
|
|
733d73ef76 | ||
|
|
5525325160 | ||
|
|
1aade1dcf9 | ||
|
|
787549237f | ||
|
|
088cd05e4f | ||
|
|
dc97095bd6 | ||
|
|
c6d8e5554d | ||
|
|
0900a4a143 | ||
|
|
eeb102e260 | ||
|
|
ea376a66d3 | ||
|
|
88747c8da1 | ||
|
|
8e1eb825df | ||
|
|
4fcf0dde3f | ||
|
|
e4791fc45c | ||
|
|
f55a9fb42b | ||
|
|
8ad06fd78a | ||
|
|
af82963f35 | ||
|
|
321ac597ce | ||
|
|
925a81f4f2 | ||
|
|
df1901ea90 | ||
|
|
569d5fffc4 | ||
|
|
7888dbc763 | ||
|
|
f0e8a8c12f | ||
|
|
af5a9717d4 | ||
|
|
bf2fffcffa | ||
|
|
4a99dd3a6a | ||
|
|
306003b698 | ||
|
|
d9be2b9d82 | ||
|
|
55b0087455 |
No files matched your search
@@ -25,4 +25,6 @@ jobs:
|
||||
- run: npm ci
|
||||
- run: node tools/check-i18n.mjs
|
||||
- run: npm run build
|
||||
- run: node --experimental-strip-types --test tools/*.test.mjs
|
||||
- run: python -B -m unittest discover -s tools -p test_launcher_bridge.py
|
||||
- run: cargo test --workspace --locked
|
||||
@@ -69,8 +69,12 @@ jobs:
|
||||
with:
|
||||
node-version: 22
|
||||
- run: npm ci
|
||||
# tauri::generate_context! needs ../dist; without a warm target cache the tests do not compile without it.
|
||||
- run: npm run build
|
||||
- name: Tests
|
||||
run: cargo test --workspace -- --test-threads=1
|
||||
run: cargo test --workspace --locked -- --test-threads=1
|
||||
- run: node --experimental-strip-types --test tools/*.test.mjs
|
||||
- run: python -B -m unittest discover -s tools -p test_launcher_bridge.py
|
||||
- name: Build and sign (publish only when requested)
|
||||
id: tauri
|
||||
uses: tauri-apps/tauri-action@v0
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
name: sign-local-installer
|
||||
on:
|
||||
push:
|
||||
branches: [release/20261108-manager]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
build_run_id:
|
||||
description: Successful manager-local run in coa-server-build
|
||||
required: true
|
||||
permissions:
|
||||
contents: read
|
||||
actions: read
|
||||
jobs:
|
||||
sign:
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
- name: Verify local build provenance
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
BUILD_RUN: ${{ inputs.build_run_id }}
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
import json, os, subprocess
|
||||
run = os.environ['BUILD_RUN']
|
||||
if not run.isdigit():
|
||||
raise RuntimeError('Invalid build run')
|
||||
data = json.loads(subprocess.check_output(['gh', 'api', f'repos/Corfirean/coa-server-build/actions/runs/{run}']))
|
||||
if data['conclusion'] != 'success' or data['path'] != '.github/workflows/manager-local.yml':
|
||||
raise RuntimeError('Not a successful local Manager build')
|
||||
subprocess.run(['gh', 'run', 'download', run, '-R', 'Corfirean/coa-server-build', '-n', 'unsigned-manager-windows', '-D', '_prepared-manager'], check=True)
|
||||
from pathlib import Path
|
||||
import hashlib
|
||||
root = Path('_prepared-manager')
|
||||
meta = json.loads((root / 'prepared-source.json').read_text())
|
||||
version = json.loads(Path('package.json').read_text())['version']
|
||||
name = meta['installer']
|
||||
if Path(name).name != name or meta['source'] != os.environ['GITHUB_SHA'] or meta['version'] != version or str(meta['run']) != run:
|
||||
raise RuntimeError('Installer identity differs')
|
||||
if hashlib.sha256((root / name).read_bytes()).hexdigest() != meta['sha256']:
|
||||
raise RuntimeError('Installer hash differs')
|
||||
PY
|
||||
- run: npm ci
|
||||
- name: Sign exact locally compiled bytes
|
||||
env:
|
||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
||||
run: |
|
||||
node --input-type=module <<'JS'
|
||||
import { readFileSync, writeFileSync } from 'node:fs';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { createHash } from 'node:crypto';
|
||||
const root = '_prepared-manager/';
|
||||
const meta = JSON.parse(readFileSync(root + 'prepared-source.json'));
|
||||
execFileSync('node_modules/.bin/tauri', ['signer', 'sign', '--app-version', meta.version, root + meta.installer], {stdio: 'inherit'});
|
||||
if (createHash('sha256').update(readFileSync(root + meta.installer)).digest('hex') !== meta.sha256) throw new Error('Signed bytes changed');
|
||||
const signature = readFileSync(root + meta.installer + '.sig', 'utf8').trim();
|
||||
const url = `https://github.com/Corfirean/coa-server-manager/releases/download/v${meta.version}/${encodeURIComponent(meta.installer)}`;
|
||||
writeFileSync(root + 'latest.json', JSON.stringify({version: meta.version, notes: 'See the release notes.', pub_date: new Date().toISOString(), platforms: {'windows-x86_64': {signature, url}}}, null, 2) + '\n');
|
||||
meta.signingRun = process.env.GITHUB_RUN_ID;
|
||||
writeFileSync(root + 'prepared-source.json', JSON.stringify(meta, null, 2) + '\n');
|
||||
JS
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: prepared-manager-windows
|
||||
path: _prepared-manager/*
|
||||
retention-days: 14
|
||||
if-no-files-found: error
|
||||
@@ -35,6 +35,16 @@ Every published Manager version, including a clearly marked Pre-release, belongs
|
||||
CHANGELOG.md and changelog/history.json. Its GitHub release notes use the same reviewed record.
|
||||
Promotion updates that entry without duplicating it; Manager and server histories remain separate.
|
||||
|
||||
Translated release notes are a required preparation step before freezing a new Manager source. Follow the
|
||||
runbook's "Mandatory translated release notes during preparation" checklist: translate every new reviewed
|
||||
Manager/server note into Russian, German, French, Spanish and Simplified Chinese in
|
||||
`src/data/latest-note-translations.json`, keyed by exact canonical English text. Preserve existing translations
|
||||
and released fragments. Refresh the bundled server-history snapshot from a pinned canonical commit and record
|
||||
its provenance. Run `node --test tools/release-history.test.mjs`, `node tools/check-i18n.mjs` and `npm run build`;
|
||||
verify each new record, all six viewer languages, English fallback and offline use. Save source/version and checks
|
||||
in the handoff. Translations ship with Manager: a server-only release must record the carrying Manager version or
|
||||
pending translation delivery, without forcing another Manager release or changing already signed installers.
|
||||
|
||||
Before preparing or publishing a Manager/server release, read the maintained
|
||||
[release runbook](https://github.com/Corfirean/coa-server-build/blob/main/docs/server-release.md)
|
||||
and [build agent instructions](https://github.com/Corfirean/coa-server-build/blob/main/AGENTS.md).
|
||||
|
||||
+107
@@ -8,6 +8,113 @@ Published releases and previews. Pre-release entries do not change the stable up
|
||||
|
||||
Dates follow GitHub publication (UTC); legacy records retain their archived dates. Newest releases first.
|
||||
|
||||
## 0.9.10 — 2026-11-08
|
||||
|
||||
- Custom Races patch installation recovers from interrupted downloads.
|
||||
|
||||
[Release](https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.10) · [Source changes](https://github.com/Corfirean/coa-server-manager/compare/v0.9.9...v0.9.10)
|
||||
|
||||
## 0.9.9 — 2026-11-04
|
||||
|
||||
- Update and recovery checks use the temporary login port even with a Windows override.
|
||||
|
||||
[Release](https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.9) · [Source changes](https://github.com/Corfirean/coa-server-manager/compare/v0.9.8...v0.9.9)
|
||||
|
||||
## 0.9.8 — 2026-11-01
|
||||
|
||||
- Dungeon Clear can be enabled when SQUID bots are active.
|
||||
- Diagnostic exports include launcher stages and lock owner records.
|
||||
- Choose normal logs, errors only or no server logs in maintenance settings.
|
||||
- Update checks temporarily suspend bot population and restore your configuration.
|
||||
- Update validation keeps MySQL running between compatible checks.
|
||||
|
||||
[Release](https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.8) · [Source changes](https://github.com/Corfirean/coa-server-manager/compare/v0.9.7...v0.9.8)
|
||||
|
||||
## 0.9.7 — 2026-10-30
|
||||
|
||||
- Show available update notes even when release history is cached.
|
||||
|
||||
[Release](https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.7) · [Source changes](https://github.com/Corfirean/coa-server-manager/compare/v0.9.5...v0.9.7)
|
||||
|
||||
## 0.9.5 — 2026-10-30
|
||||
|
||||
- Account creation verifies a lost console reply against the requested login.
|
||||
- Abandoned game relay tunnels close their local connection immediately.
|
||||
- Keep disabled graphics components disabled during client updates.
|
||||
- Force-stop an unresponsive world after a failed normal shutdown.
|
||||
- Crash history includes reports from every world and Windows text files.
|
||||
- Show the online bot count for Playerbots on the overview.
|
||||
- Disable public server browsing in Settings.
|
||||
- Keep deliberate stops and update shutdowns from triggering crash restart.
|
||||
- Server startup waits for a responsive console before reporting success.
|
||||
- Restore the existing Manager window when launching it again.
|
||||
|
||||
[Release](https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.5) · [Source changes](https://github.com/Corfirean/coa-server-manager/compare/v0.9.4...v0.9.5)
|
||||
|
||||
## 0.9.4 — 2026-10-29
|
||||
|
||||
**Portable Characters are experimental and may contain bugs.**
|
||||
|
||||
- Settings group updates, startup and maintenance with translated release history.
|
||||
- Update and launch without updating share a divided button.
|
||||
- Maximizing the window keeps text and controls at a comfortable size.
|
||||
|
||||
[Release](https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.4) · [Source changes](https://github.com/Corfirean/coa-server-manager/compare/v0.9.3...v0.9.4)
|
||||
|
||||
## 0.9.3 — 2026-10-29
|
||||
|
||||
**Portable Characters are experimental and may contain bugs.**
|
||||
|
||||
- Slow server startup no longer triggers an early update rollback.
|
||||
|
||||
[Release](https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.3) · [Source changes](https://github.com/Corfirean/coa-server-manager/compare/v0.9.2...v0.9.3)
|
||||
|
||||
## 0.9.2 — 2026-10-28
|
||||
|
||||
**Portable Characters are experimental and may contain bugs.**
|
||||
|
||||
- New server installation waits for slower database startup.
|
||||
- Find and edit CoA options in the existing server settings.
|
||||
- Simultaneous update checks share results or wait their turn.
|
||||
- Recovery can stop an unfinished world startup after restoring an older launcher.
|
||||
|
||||
[Release](https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.2) · [Source changes](https://github.com/Corfirean/coa-server-manager/compare/v0.9.1...v0.9.2)
|
||||
|
||||
## 0.9.1 — 2026-10-28
|
||||
|
||||
**Portable Characters are experimental and may contain bugs.**
|
||||
|
||||
- Existing unsupported character records no longer block unrelated server updates.
|
||||
|
||||
[Release](https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.1) · [Source changes](https://github.com/Corfirean/coa-server-manager/compare/v0.9.0...v0.9.1)
|
||||
|
||||
## 0.9.0 — 2026-10-28
|
||||
|
||||
**Portable Characters are experimental and may contain bugs.**
|
||||
|
||||
- Choose Parallel or Global level scaling in module settings.
|
||||
- Report Content Scaling problems directly to its repository.
|
||||
- Send custom race problem reports directly to their maintainer.
|
||||
- Internet sharing restores the LAN address after server restarts.
|
||||
- Configure custom race availability for new characters.
|
||||
- Public listing offers every realm that starts together, not just the main one.
|
||||
- Public listing is a short list of realms with a window for the details.
|
||||
- Configure profession and defense skill gains in server settings.
|
||||
- Starting a server sets the character classes of the realm chosen on Overview.
|
||||
- Start Wildcard and Warcraft Reborn together with Conquest of Azeroth.
|
||||
- Control portable characters and keep Manager running in the system tray.
|
||||
|
||||
[Release](https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.0) · [Source changes](https://github.com/Corfirean/coa-server-manager/compare/v0.8.2...v0.9.0)
|
||||
|
||||
## 0.8.2 — 2026-10-27
|
||||
|
||||
**Portable Characters are experimental and may contain bugs.**
|
||||
|
||||
- Installs the verified CoA Custom 1.9.2 client patches and quest safety addon, while recognizing existing 1.9.1 installations.
|
||||
- Server updates preserve the order of database migrations introduced during merges, preventing older snapshots from overwriting newer progression.
|
||||
|
||||
[Release](https://github.com/Corfirean/coa-server-manager/releases/tag/v0.8.2) · [Source changes](https://github.com/Corfirean/coa-server-manager/compare/v0.8.1...v0.8.2)
|
||||
|
||||
## 0.8.1 — 2026-10-25
|
||||
|
||||
**Portable Characters are experimental and may contain bugs.**
|
||||
|
||||
Generated
+20
-3
@@ -586,7 +586,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "coa-core"
|
||||
version = "0.8.2"
|
||||
version = "0.9.12"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"chrono",
|
||||
@@ -634,7 +634,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "coa-release"
|
||||
version = "0.8.2"
|
||||
version = "0.9.12"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"coa-core",
|
||||
@@ -643,7 +643,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "coa-server-manager"
|
||||
version = "0.8.2"
|
||||
version = "0.9.12"
|
||||
dependencies = [
|
||||
"coa-control-proto",
|
||||
"coa-core",
|
||||
@@ -655,6 +655,7 @@ dependencies = [
|
||||
"tauri-plugin-dialog",
|
||||
"tauri-plugin-opener",
|
||||
"tauri-plugin-process",
|
||||
"tauri-plugin-single-instance",
|
||||
"tauri-plugin-updater",
|
||||
"tracing",
|
||||
]
|
||||
@@ -4606,6 +4607,22 @@ dependencies = [
|
||||
"tauri-plugin",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-single-instance"
|
||||
version = "2.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "726b6da0dd5bd1344f84f4108a622c07d01923baacb5c803a605189672c5352f"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
"thiserror 2.0.21",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"windows-sys 0.61.2",
|
||||
"zbus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-updater"
|
||||
version = "2.13.1"
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ members = ["crates/coa-core", "crates/coa-release", "crates/coa-registry-proto",
|
||||
exclude = ["services/coa-registry", "services/coa-registry-e2e", "services/coa-coordinator", "services/coa-relay"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.8.2"
|
||||
version = "0.9.12"
|
||||
edition = "2021"
|
||||
license = "AGPL-3.0-only"
|
||||
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
# Per-race availability audit
|
||||
|
||||
Date: 2026-10-27. This is an internal implementation audit, not a supported-feature guide.
|
||||
|
||||
## Frozen sources
|
||||
|
||||
Separate `feat/per-race-toggles` branches and checkouts:
|
||||
|
||||
| Component | Checkout | Fetched base |
|
||||
| --- | --- | --- |
|
||||
| Manager | `C:/games/source/per-race-manager` | `origin/master`, `925a81f` |
|
||||
| Core | `C:/games/source/per-race-core` | `origin/coa-bots`, `1c658cab46d5057a8972cebd84c840aa6fbc4a91` |
|
||||
| CoA Companions | `C:/games/source/per-race-companions` | `origin/master`, `6a289fc2230ce9425924ca86dee02d0bb8d3d344` |
|
||||
| Build | `C:/games/source/per-race-build` | `origin/main`, `89795b6` |
|
||||
|
||||
The build runbook explicitly selects `Corfirean/azerothcore-wotlk-coa:coa-bots`, not its `main`.
|
||||
The old `C:/games/source/server/azerothcore-wotlk-coa` checkout instead tracks jealous-sound upstream
|
||||
and has local modifications. It must not be used as the feature's release base.
|
||||
The primary Manager and Companions checkouts also contain unrelated work and remain untouched.
|
||||
|
||||
SQUID is a separate repository, `Zyth45/mod-playerbots`, not `Corfirean/mod-coa-playerbots`.
|
||||
Existing research checkout: `C:/games/source/squid-playerbots`. Its current local branch is
|
||||
`fix/custom-races-existing-bots`, one commit ahead of `origin/coa`. Build policy selects the highest
|
||||
stable numeric tag, so that local branch must not silently become the shipped dependency.
|
||||
|
||||
## Manager integration points
|
||||
|
||||
- `crates/coa-core/src/custom_races.rs`: package version `1.9.2`, release URLs, MPQ/root/addon lists,
|
||||
hash manifests, client status, install, enable/disable and uninstall.
|
||||
- `PatchTransaction`, `SavedFile`, `recover_patch_transaction`: shared client-relative journal in
|
||||
`.coa-races-transaction/journal.json`, saved files and `committed` marker. Uncommitted changes roll back.
|
||||
Paths use `fsx::safe_join`; file moves handle cross-volume addon locations.
|
||||
- `patch_lock`: exclusive OS file lock on `.coa-races.lock`. The empty file's existence is normal and
|
||||
does not prove another operation is active. Do not delete it as a stale-lock workaround.
|
||||
- Client mutations reject `client::is_running`; reuse this gate and lock for availability changes.
|
||||
- `patch_files`, `matches_patch`, `preserve_original`: ownership and preservation depend on manifests
|
||||
and hashes, not just a filename. Availability overlay ownership needs its own verified record.
|
||||
- `modules/catalog.json`: `custom-races` uses `coa_custom_races.conf` and `CoACustomRaces.Enable`.
|
||||
Companions use `mod_coa_playerbots.conf` / `CoaBots.Enable`; SQUID uses
|
||||
`playerbots.conf` / `AiPlayerbot.Enabled`.
|
||||
- `crates/coa-core/src/modules.rs`: `toggle`, `settings_in`, `save_settings_in` write current module
|
||||
configuration. Bot switches enforce stopped servers and the existing control lock.
|
||||
- `src/screens/ModulesPage.tsx`: Custom Races card, master toggle, install/progress/status UI.
|
||||
- `src/lib/api.ts` and `src-tauri/src/lib.rs`: existing `custom_races_status`,
|
||||
`custom_races_install`, `custom_races_uninstall`, `custom_races_toggle_client` commands.
|
||||
There is no per-race command or verified availability status yet.
|
||||
- `src-tauri/src/lib.rs::play`: local launch reads `realms::state`, calls `client::sync_realm`, then
|
||||
launches. Remote launch has a separate realmlist override path; it cannot infer a remote race policy.
|
||||
- `crates/coa-core/src/realms.rs`: modes CoA, Wildcard and Warcraft Reborn; current configs are captured
|
||||
under `Settings/realm-profiles/<mode>.json`. Use this mechanism rather than a parallel realm store.
|
||||
Existing bot restrictions for non-CoA modes must remain effective.
|
||||
- `crates/coa-core/src/clientdl.rs::apply`: manifest-based client updates, `keep_modified`, staging,
|
||||
preservation of replaced files. No availability-overlay invalidation or rebuild exists today.
|
||||
|
||||
### Confirmed reconciliation risk
|
||||
|
||||
`custom_races.rs::sync_bot_races_config` writes a replacement `AiPlayerbot.ExcludedBotRaces` value:
|
||||
recommended full exclusions or experimental `65,72,77,80,81`. It does not preserve arbitrary user
|
||||
exclusions. `modules.rs` calls it from the master switch and BotsEnable saving; some callers discard
|
||||
errors. Per-race integration cannot rely on this overwrite behavior.
|
||||
|
||||
`playerbots_conf_paths` can also copy a `.dist` file when no active config exists; it is not a purely
|
||||
read-only discovery API. Status inspection should avoid adding more implicit writes.
|
||||
|
||||
## Core gates and bypasses
|
||||
|
||||
- `modules/mod-coa-custom-races/src/mod_coa_custom_races.cpp`: `WorldScript` loads the master switch;
|
||||
`AccountScript::CanAccountCreateCharacter` accepts stock IDs 1–8, 10, 11 or an enabled master switch.
|
||||
No disabled-ID list is implemented. Stock ID 9 is deliberately not included.
|
||||
- `modules/mod-coa-custom-races/conf/coa_custom_races.conf.dist`: Enable and BotsEnable exist;
|
||||
DisabledRaceIds does not.
|
||||
- `src/server/game/Handlers/CharacterHandler.cpp`: normal character creation invokes
|
||||
`sScriptMgr->CanAccountCreateCharacter` inside its finalization callback and rejects with
|
||||
`CHAR_CREATE_DISABLED`. A packet from an unpatched client reaches that gate too.
|
||||
- `src/server/game/Scripting/ScriptDefines/AccountScript.cpp`: hook aggregation must be preserved.
|
||||
- `src/server/game/DataStores/DBCStores.cpp::LoadDBCStores`: chooses `DataDir/dbc_races/<file>` if
|
||||
the master switch is enabled and that file exists, otherwise `DataDir/dbc/<file>`.
|
||||
Per-race creation policy must not remove DBC rows or change login data.
|
||||
- `.agents/docs/systems/ascension-character-creation.md`: native client compatibility depends on
|
||||
`CharBaseInfo.dbc`; race button indices are not RaceIDs. Existing race/class checks must stay intact.
|
||||
|
||||
## Both bot systems
|
||||
|
||||
### CoA Companions
|
||||
|
||||
`module/src/BotSpawnRandom.cpp::GetValidBotRaces` reads the global and bot custom-race switches,
|
||||
`CoaBots.CustomRaces.Enable`, and both AiPlayerbot/CoaBots exclusion lists. It checks DBC presence.
|
||||
Its experimental defaults apply only when the combined exclusion set is empty: adding an owner list
|
||||
to that set would silently remove those defaults. Keep those policies independent.
|
||||
|
||||
`CreateBotClone`, `CreateOneRandomBot`, and leveled spawning clone SQL character data directly;
|
||||
they bypass the account creation hook. Enforce new-character policy at the common clone creation
|
||||
entry as well as random selection. Preserve existing bots and faction selection via
|
||||
`Player::TeamIdForRace`.
|
||||
|
||||
Additional confirmed callers: `module/src/BotBattlegroundFill.cpp::QueueBotForSide` and
|
||||
`module/src/BotLfgFill.cpp` call `CreateOneRandomBot` after trying to reuse an existing bot.
|
||||
The existing-bot reuse path must remain separate from creation restrictions.
|
||||
|
||||
`tools/offline_bot_factory.py` is another direct-SQL creation path. Its main loop chooses a
|
||||
template by class and faction, then copies `template.race` into the new character overrides.
|
||||
It currently does not read the custom-race creation policy. Reject or filter prohibited
|
||||
templates before generating new accounts, GUIDs or SQL; do not rewrite their races.
|
||||
|
||||
### SQUID Playerbots
|
||||
|
||||
`src/PlayerbotAIConfig.cpp` loads `AiPlayerbot.ExcludedBotRaces` and adds
|
||||
`AiPlayerbot.CrashingBotRaces`; it reads BotsEnable. `src/CoaBotRacePolicy.h` implements
|
||||
`IsCoaBotRaceAllowed`. `src/Bot/Factory/RandomPlayerbotFactory.cpp::CreateRandomBot` applies
|
||||
that policy before faction and race/class selection.
|
||||
|
||||
The same predicate also appears in `src/Bot/RandomPlayerbotMgr.cpp` and
|
||||
`src/Bot/PlayerbotMgr.cpp`, including existing-character admission. Do not append owner creation
|
||||
restrictions globally to this shared exclusion vector: that would also affect existing bots.
|
||||
The predicate currently does not itself require `CoACustomRaces.Enable`.
|
||||
`RandomPlayerbotFactory.cpp` calls `Player::Create` directly without the account hook.
|
||||
Use a creation-only check in this factory, leaving existing-character admission unchanged.
|
||||
|
||||
## Portable Characters
|
||||
|
||||
Manager import code is under `crates/coa-core/src/portable/realm/`.
|
||||
`import.rs` validates identity namespaces and race/class start data (`UnknownRaceClass`).
|
||||
Availability policy must not become an import rejection or an identity rewrite. The inspected
|
||||
creation hook is in the normal packet handler, not this importer. In the core,
|
||||
`src/server/coa/CoAPortableImport.cpp` checks `GetPlayerInfo(model.Race, model.Class)` and writes
|
||||
`model.Race` to the imported character and character cache. It does not invoke the account
|
||||
creation hook. Preserve this separation. Live compatibility is still untested.
|
||||
|
||||
## Client experiment, actual observations
|
||||
|
||||
The owner updated `C:/games/Ascension` from 1.9.1 to 1.9.2 during this audit; its manifest now says
|
||||
`# CoA Custom 1.9.2`. A separate physical client copy is being prepared under
|
||||
`C:/games/source/per-race-evidence/client`; game assets are outside Git. The copy completed:
|
||||
25646 files copied, zero failures. The separate server file copy also completed, but has not
|
||||
been configured or started. No database service has been started for this task.
|
||||
|
||||
Read-only MPQ membership probing found ChrRaces in patch-ZZZF, ZZZE, ZZZC, ZZZ, ZZW, ZZV, ZZU,
|
||||
ZZS, T, M and several locale archives. CharacterCreate.lua has multiple owners too.
|
||||
The old `mpqprobe.py` precedence model explicitly admits an inference for Ascension multi-letter
|
||||
archives. Therefore `patch-ZZZF.MPQ` is a candidate source, not runtime-confirmed effective data.
|
||||
`patch-ZZZZ.MPQ` exists already; no overlay filename has been qualified.
|
||||
|
||||
Extracted from `patch-ZZZF.MPQ`:
|
||||
|
||||
- WDBC, 95 records, 69 fields, record size 276, string block 2428, total bytes 28668.
|
||||
- SHA-256 `b78635b08bf0bd63d2898fce97c1fb162c8a9c41632703172eefa88bae79061f`.
|
||||
- Actual rows: Sethrak 82, Gnoll 83, Saberon 97. Their Flags are 12.
|
||||
- String block starts with `Hu`, not NUL; imposing an initial empty-string invariant incorrectly
|
||||
rejects this real table. String boundaries and referenced offsets still need validation.
|
||||
- Sethrak experiment changes only Flags 12 → 13. All other bytes compare equal.
|
||||
- One generated MPQ was read back through StormLib; its DBC equals the expected patched bytes.
|
||||
- The installed `pympq` Python extension crashed during interpreter finalization. The experimental
|
||||
tool instead uses the installed Unicode StormLib DLL directly. It is not a runtime dependency
|
||||
proposal for Manager or its users.
|
||||
|
||||
`tools/race_availability_poc.py` requires an explicit source archive and creates output only in a new
|
||||
directory. It does not select an archive order, install an overlay or assert in-game success.
|
||||
`tools/test_race_availability_poc.py` uses synthetic bytes only.
|
||||
|
||||
### Background verification after interactive testing was deferred
|
||||
|
||||
The owner requested no screen capture/input and no client/server/MySQL launches while other bot
|
||||
tests run. These restrictions remain active. The owner reported that the copied client launches;
|
||||
this does not confirm creation behavior or effective DBC loading.
|
||||
|
||||
- 17 DBC/fingerprint tests and 8 synthetic MPQ integration tests pass (25 total, none skipped).
|
||||
- Native tests use the explicitly selected existing Unicode StormLib DLL, with no new install.
|
||||
- Output is built and verified in a temporary directory before publishing the offline result folder.
|
||||
Failures leave no published result; this is not the future client transaction implementation.
|
||||
- One and fifty disabled races both produce one MPQ. StormLib adds an internal `(listfile)`;
|
||||
the sole game payload is `DBFilesClient/ChrRaces.dbc`.
|
||||
- Every referenced localized race-name offset is bounds-checked; invalid UTF-8 is rejected.
|
||||
- The experimental fingerprint includes original DBC SHA-256, normalized IDs, algorithm version
|
||||
and explicitly recorded profile. A profile label does not prove client compatibility.
|
||||
- The real three-race offline experiment is in
|
||||
`C:/games/source/per-race-evidence/multiple-races-offline/report.json`.
|
||||
Source MPQ SHA-256: `40eac695cfcafb598b8376f3b9a61ecc037e4d445b87279cfe387a91edad32c3`.
|
||||
Generated DBC SHA-256: `243fb36837b76ebd6943da574cc095be548b4530be7f06487debea6703db10d3`.
|
||||
|
||||
The first copy launch showed a missing-critical-files message and subsequently crashed on exit.
|
||||
The crash report identifies `AMDXN32.DLL` in the AMD graphics driver at the fault address; this
|
||||
does not establish the root cause. EXE, Extensions, dinput8, d3d9, dxgi, EsteriaAppearance and
|
||||
patch-ZZZF hashes matched the primary client during comparison. The experimental overlay was
|
||||
not installed. No graphics-driver or client-runtime changes were made to work around the crash.
|
||||
|
||||
## Reference implementations and update preservation
|
||||
|
||||
Inspected read-only reference clones:
|
||||
|
||||
- `aspollon/AFK-Realm` at `ea9c5bf691c98cace8cc03c06183c161022946de`.
|
||||
- `aspollon/mod-custom-races` at `5a8f2ff8a0d494ffadf64e677a438aa7f5a6671b`.
|
||||
|
||||
`mod-custom-races/afk-realm.json` declares client patch generation and GlueXML Lua insertion.
|
||||
`client/CustomRaces.lua` extends and lays out buttons, using race names/files and configured IDs.
|
||||
This is a reference, not evidence of compatibility with the current CoA/Esteria UI or a reason
|
||||
to replace CSM's prebuilt-server distribution.
|
||||
|
||||
`crates/coa-core/src/config/merge.rs` performs additive `.dist` merging: missing keys are added,
|
||||
existing user values and unknown keys are retained. A new DisabledRaceIds key should use this
|
||||
path. Existing realm snapshots already capture module `.conf` files. Neither mechanism currently
|
||||
coordinates an availability overlay with client update/repair; that remains implementation work.
|
||||
|
||||
## Open gates
|
||||
|
||||
Update after the owner found the existing Hide Races panel: see
|
||||
[existing-filter research](docs/PER_RACE_EXISTING_FILTER_RESEARCH.md). The inspected Lua already
|
||||
supports personal name/index-based hiding, but it is not a realm-scoped RaceID policy. Nine
|
||||
offline Lua 5.1 probes confirmed key behavior and limitations. Reusing its layout/UI is now a
|
||||
candidate to investigate before choosing a production DBC implementation. This is not evidence
|
||||
that the DBC approach failed, and it does not qualify client support.
|
||||
|
||||
The owner subsequently confirmed the GlueXML probe: restricted races disappeared from selection
|
||||
and were grey, unchecked and disabled in Hide Races. The production client integration should
|
||||
reuse this filter; changing DBC flags is no longer the selected implementation path.
|
||||
|
||||
Server controls, strict catalog-bound configuration, the core creation hook and both bot factory
|
||||
guards are implemented and have passed offline checks and native builds. Existing-bot admission
|
||||
and user/crashing exclusions remain separate from the new creation policy.
|
||||
|
||||
Remaining gates:
|
||||
1. Integrate automatic client reconciliation, ownership and recovery with realm settings.
|
||||
2. Qualify client update/repair and shared-client PLAY behavior.
|
||||
3. Verify live creation rejection/re-enable, existing-character login, imports and both bot systems
|
||||
when the owner's database test environment becomes available.
|
||||
|
||||
Status: **PARTIAL** — server implementation and builds pass; live server acceptance and production
|
||||
client synchronization remain pending. See docs/PER_RACE_TOGGLES_TESTS.md for exact scope.
|
||||
No existing character data, production service, release channel, or primary client archive was changed.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: added
|
||||
audience: admins
|
||||
title: Choose Parallel or Global level scaling in module settings
|
||||
---
|
||||
Content Scaling progression can now be set to Parallel (Classic over 1 to the level cap, TBC and WotLK over 45 to the cap) or Global (all expansions over 1 to the cap) without editing the config file by hand.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: added
|
||||
audience: admins
|
||||
title: Report Content Scaling problems directly to its repository
|
||||
---
|
||||
The report form now includes a separate Content Scaling destination.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: added
|
||||
audience: admins
|
||||
title: Send custom race problem reports directly to their maintainer
|
||||
---
|
||||
The report form now includes Custom Races as a separate destination.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Internet sharing restores the LAN address after server restarts
|
||||
---
|
||||
Friends on the local network receive the server's LAN address and network mask while internet players keep using its public address.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: added
|
||||
audience: admins
|
||||
title: Configure custom race availability for new characters
|
||||
---
|
||||
Choose individual races in a compact table inside module settings using the installed server catalog. Saving requires a compatible server build and a stopped server. Client synchronization is not yet automatic.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Public listing offers every realm that starts together, not just the main one
|
||||
---
|
||||
With Wildcard or Warcraft Reborn started next to Conquest of Azeroth, Settings now has one listing block per realm, each with its own name, description and access options.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: changed
|
||||
audience: admins
|
||||
title: Public listing is a short list of realms with a window for the details
|
||||
---
|
||||
Settings shows one line per realm with its state, and publishing opens a window. Publish all realms at once. Account creation and portable characters are chosen before publishing; portable characters are on by default.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: added
|
||||
audience: admins
|
||||
title: Configure profession and defense skill gains in server settings
|
||||
---
|
||||
Advanced rate settings now include prospecting and milling skill gains, plus the points gained from crafting, defense and gathering.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Starting a server sets the character classes of the realm chosen on Overview
|
||||
---
|
||||
A new Conquest of Azeroth server could show two class models, or none, on the character creation screen. The Manager now sets the model of the chosen realm before every start.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: added
|
||||
audience: admins
|
||||
title: Start Wildcard and Warcraft Reborn together with Conquest of Azeroth
|
||||
---
|
||||
Settings now has two options, one for Wildcard and one for Warcraft Reborn. Turn on either one, or both to run all three realms at once, each with its own characters and port.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: added
|
||||
audience: admins
|
||||
title: Find and edit CoA options in the existing server settings
|
||||
---
|
||||
Search includes the separate CoA configuration, including legacy mount flight. Changes go to the correct file; realm profile controls stay managed by the Manager.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Existing unsupported character records no longer block unrelated server updates
|
||||
---
|
||||
Updates compare each affected character with its saved pre-update state. Unchanged older problems are reported as warnings without changing characters. Newly missing race/class data still blocks the update and triggers recovery; schema and identity checks remain enforced.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Recovery can stop an unfinished world startup after restoring an older launcher
|
||||
---
|
||||
If the world console is unavailable, stop only the verified recorded world process. Keep MySQL running if ownership or shutdown cannot be confirmed.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: New server installation waits for slower database startup
|
||||
---
|
||||
Allow up to five minutes for MySQL to become ready. Failed installations stop their temporary database before cleaning up its files.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: added
|
||||
audience: admins
|
||||
title: Control portable characters and keep Manager running in the system tray
|
||||
---
|
||||
Realm access settings can enable portable characters. Closing the window keeps Manager in the tray, with commands to reopen or exit. Offline realm messages explain why players cannot connect.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: changed
|
||||
audience: admins
|
||||
title: Settings group updates, startup and maintenance with translated release history
|
||||
---
|
||||
Server and Manager keep separate update controls. Read their published changes in one place, including translations of the latest releases in all six interface languages. Saved notes remain available offline. Find public realm controls under Play with friends.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: changed
|
||||
audience: admins
|
||||
title: Update and launch without updating share a divided button
|
||||
---
|
||||
Server and game client actions each use two adjacent segments of equal height. Both actions remain visible and keep their own availability checks.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Simultaneous update checks share results or wait their turn
|
||||
---
|
||||
Repeated checks no longer compete with another foreground or background check in the same Manager window. Maintenance and recovery locks remain enforced.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Maximizing the window keeps text and controls at a comfortable size
|
||||
---
|
||||
The interface no longer enlarges with window width. System display scaling and browser zoom still work, and large action buttons use more compact spacing.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Slow server startup no longer triggers an early update rollback
|
||||
---
|
||||
World startup now allows up to 25 minutes with either bot system and waits for both game and console ports within one deadline. Servers that stop during startup still fail immediately.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Account creation verifies a lost console reply against the requested login
|
||||
---
|
||||
Confirm the requested credentials after a lost reply, block creation during another server action, and explicitly report accounts whose administrator access could not be confirmed.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Abandoned game relay tunnels close their local connection immediately
|
||||
---
|
||||
Dropping a tunnel shuts down its shared socket directly instead of relying only on a background message, releasing its local read and write connection.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Keep disabled graphics components disabled during client updates
|
||||
---
|
||||
Client settings can disable DXVK and graphics enhancements. Existing launcher DISABLED files are respected.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: added
|
||||
audience: admins
|
||||
title: Force-stop an unresponsive world after a failed normal shutdown
|
||||
---
|
||||
Confirm the risk of unsaved progress before stopping verified server processes. Shared databases stay running until every owned world has stopped.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Crash history includes reports from every world and Windows text files
|
||||
---
|
||||
Create and verify the crash report folder before native startup, and include reports from simultaneous worlds and files containing Windows ANSI text.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Show the online bot count for Playerbots on the overview
|
||||
---
|
||||
The overview displays bot population for both supported bot systems.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: added
|
||||
audience: admins
|
||||
title: Disable public server browsing in Settings
|
||||
---
|
||||
Turn off public server browsing to block catalog list and detail requests. When browsing is enabled, load the list with Refresh.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Keep deliberate stops and update shutdowns from triggering crash restart
|
||||
---
|
||||
Status checks no longer forget a stop request while the world is still shutting down. Update validation and recovery do not trigger automatic crash restarts.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Show available update notes even when release history is cached
|
||||
---
|
||||
Fetch the release notes for the offered update when they are missing from the cached history, including when an update becomes available while the history is open.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Server startup waits for a responsive console before reporting success
|
||||
---
|
||||
An open port no longer marks a loading world as ready. Account creation checks that the console processes commands before sending a create request.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Restore the existing Manager window when launching it again
|
||||
---
|
||||
Choose whether closing the window exits the Manager or minimizes it to the tray. Tray actions restore the window on the UI thread.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: added
|
||||
audience: admins
|
||||
title: Dungeon Clear can be enabled when SQUID bots are active
|
||||
---
|
||||
Dungeon Clear starts disabled. Switching SQUID bots off also switches Dungeon Clear off; enabling SQUID again leaves Dungeon Clear off until you choose to enable it.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: added
|
||||
audience: admins
|
||||
title: Diagnostic exports include launcher stages and lock owner records
|
||||
---
|
||||
Support packages include recent launcher diagnostics for each realm, with sensitive fields removed. Recorded lock owners help diagnose overlapping startup and shutdown actions.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Custom Races patch installation recovers from interrupted downloads
|
||||
---
|
||||
Unfinished downloads resume automatically. Invalid archives in Downloads are skipped without changing them, and damaged cached archives are downloaded again.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: added
|
||||
audience: admins
|
||||
title: Choose normal logs, errors only or no server logs in maintenance settings
|
||||
---
|
||||
The logging preset updates both the game world and login server, including their configuration templates. Previous settings are saved in configuration snapshots. Restart the server to apply the change.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Update checks temporarily suspend bot population and restore your configuration
|
||||
---
|
||||
Validation preserves the selected bot system and its population limits. Original configuration files are restored after validation, including recovery from interrupted updates.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Update validation keeps MySQL running between compatible checks
|
||||
---
|
||||
Database checks and the temporary server startup share one MySQL session. The server still stops before files or database snapshots are replaced or restored.
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
area: manager
|
||||
type: fixed
|
||||
audience: admins
|
||||
title: Update and recovery checks use the temporary login port even with a Windows override
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: added
|
||||
audience: admins
|
||||
title: Settings for how much help bots get in dungeons and raids
|
||||
---
|
||||
Bot damage, healing, damage taken and tank threat can now be tuned under Bots, Combat. Everything defaults to 1 (no change); a switch turns the extra help for four hard bosses on.
|
||||
+209
-1
@@ -123,6 +123,7 @@
|
||||
"Corfirean/coa-server-manager:20261021-scaling-health-settings.md",
|
||||
"Corfirean/coa-server-manager:20261021-warcraft-reborn-realm.md",
|
||||
"Corfirean/coa-server-manager:20261022-custom-races-client.md",
|
||||
"Corfirean/coa-server-manager:20261022-scaling-progression-modes.md",
|
||||
"Corfirean/coa-server-manager:20261023-ah-bot-single-switch.md",
|
||||
"Corfirean/coa-server-manager:20261023-interface-language-coverage.md",
|
||||
"Corfirean/coa-server-manager:20261023-online-players-exclude-squid-bots.md",
|
||||
@@ -136,7 +137,46 @@
|
||||
"Corfirean/coa-server-manager:20261024-relay-recovery.md",
|
||||
"Corfirean/coa-server-manager:20261024-remote-progress.md",
|
||||
"Corfirean/coa-server-manager:20261024-remote-refresh.md",
|
||||
"Corfirean/coa-server-manager:20261025-custom-races-191.md"
|
||||
"Corfirean/coa-server-manager:20261025-custom-races-191.md",
|
||||
"Corfirean/coa-server-manager:20261026-custom-races-192.md",
|
||||
"Corfirean/coa-server-manager:20261027-content-scaling-reports.md",
|
||||
"Corfirean/coa-server-manager:20261027-custom-races-reports.md",
|
||||
"Corfirean/coa-server-manager:20261027-internet-lan-address.md",
|
||||
"Corfirean/coa-server-manager:20261027-merged-database-migration-order.md",
|
||||
"Corfirean/coa-server-manager:20261027-per-race-server-settings.md",
|
||||
"Corfirean/coa-server-manager:20261027-public-list-shows-every-running-realm.md",
|
||||
"Corfirean/coa-server-manager:20261027-public-listing-window.md",
|
||||
"Corfirean/coa-server-manager:20261027-skill-gain-controls.md",
|
||||
"Corfirean/coa-server-manager:20261027-start-checks-the-realm-class-setting.md",
|
||||
"Corfirean/coa-server-manager:20261027-start-wildcard-and-reborn-with-coa.md",
|
||||
"Corfirean/coa-server-manager:20261028-coa-config-search.md",
|
||||
"Corfirean/coa-server-manager:20261028-existing-character-update-validation.md",
|
||||
"Corfirean/coa-server-manager:20261028-legacy-world-shutdown.md",
|
||||
"Corfirean/coa-server-manager:20261028-mysql-install-startup.md",
|
||||
"Corfirean/coa-server-manager:20261028-portable-settings-and-tray.md",
|
||||
"Corfirean/coa-server-manager:20261028-settings-release-history.md",
|
||||
"Corfirean/coa-server-manager:20261028-split-update-actions.md",
|
||||
"Corfirean/coa-server-manager:20261028-update-check-queue.md",
|
||||
"Corfirean/coa-server-manager:20261028-window-density.md",
|
||||
"Corfirean/coa-server-manager:20261029-slow-world-startup.md",
|
||||
"Corfirean/coa-server-manager:20261030-account-console-confirmation.md",
|
||||
"Corfirean/coa-server-manager:20261030-close-abandoned-relay-sockets.md",
|
||||
"Corfirean/coa-server-manager:20261030-disabled-client-renderers.md",
|
||||
"Corfirean/coa-server-manager:20261030-force-stop-unresponsive-world.md",
|
||||
"Corfirean/coa-server-manager:20261030-native-crash-reports.md",
|
||||
"Corfirean/coa-server-manager:20261030-playerbots-overview-count.md",
|
||||
"Corfirean/coa-server-manager:20261030-public-server-browsing-control.md",
|
||||
"Corfirean/coa-server-manager:20261030-stop-does-not-trigger-auto-restart.md",
|
||||
"Corfirean/coa-server-manager:20261030-update-history-target-cache.md",
|
||||
"Corfirean/coa-server-manager:20261030-wait-for-world-console-readiness.md",
|
||||
"Corfirean/coa-server-manager:20261030-window-lifecycle.md",
|
||||
"Corfirean/coa-server-manager:20261031-dungeon-clear-dependency.md",
|
||||
"Corfirean/coa-server-manager:20261031-launcher-diagnostics-export.md",
|
||||
"Corfirean/coa-server-manager:20261031-recover-client-patch-downloads.md",
|
||||
"Corfirean/coa-server-manager:20261031-server-logging-controls.md",
|
||||
"Corfirean/coa-server-manager:20261031-validation-bot-population.md",
|
||||
"Corfirean/coa-server-manager:20261031-validation-mysql-reuse.md",
|
||||
"Corfirean/coa-server-manager:20261103-isolated-login-port.md"
|
||||
],
|
||||
"releases": [
|
||||
{
|
||||
@@ -704,6 +744,174 @@
|
||||
"experimentalFeatures": [
|
||||
"portable-characters"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "v0.8.2",
|
||||
"version": "0.8.2",
|
||||
"date": "2026-10-27",
|
||||
"url": "https://github.com/Corfirean/coa-server-manager/releases/tag/v0.8.2",
|
||||
"notes": [
|
||||
"Installs the verified CoA Custom 1.9.2 client patches and quest safety addon, while recognizing existing 1.9.1 installations",
|
||||
"Server updates preserve the order of database migrations introduced during merges, preventing older snapshots from overwriting newer progression"
|
||||
],
|
||||
"commit": "81b040ef02763c7cf7a3a3da1424b73177e9d433",
|
||||
"compare": "https://github.com/Corfirean/coa-server-manager/compare/v0.8.1...v0.8.2",
|
||||
"experimentalFeatures": [
|
||||
"portable-characters"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "v0.9.0",
|
||||
"version": "0.9.0",
|
||||
"date": "2026-10-28",
|
||||
"url": "https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.0",
|
||||
"notes": [
|
||||
"Choose Parallel or Global level scaling in module settings",
|
||||
"Report Content Scaling problems directly to its repository",
|
||||
"Send custom race problem reports directly to their maintainer",
|
||||
"Internet sharing restores the LAN address after server restarts",
|
||||
"Configure custom race availability for new characters",
|
||||
"Public listing offers every realm that starts together, not just the main one",
|
||||
"Public listing is a short list of realms with a window for the details",
|
||||
"Configure profession and defense skill gains in server settings",
|
||||
"Starting a server sets the character classes of the realm chosen on Overview",
|
||||
"Start Wildcard and Warcraft Reborn together with Conquest of Azeroth",
|
||||
"Control portable characters and keep Manager running in the system tray"
|
||||
],
|
||||
"commit": "dc97095bd6b36d9b5111f04f0cfd88e1fb2ab1f1",
|
||||
"compare": "https://github.com/Corfirean/coa-server-manager/compare/v0.8.2...v0.9.0",
|
||||
"experimentalFeatures": [
|
||||
"portable-characters"
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.9.1",
|
||||
"tag": "v0.9.1",
|
||||
"date": "2026-10-28",
|
||||
"notes": [
|
||||
"Existing unsupported character records no longer block unrelated server updates"
|
||||
],
|
||||
"experimentalFeatures": [
|
||||
"portable-characters"
|
||||
],
|
||||
"url": "https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.1",
|
||||
"compare": "https://github.com/Corfirean/coa-server-manager/compare/v0.9.0...v0.9.1",
|
||||
"commit": "8bbf16ed4f14e9b78c680783e4be5d8c580cc06b"
|
||||
},
|
||||
{
|
||||
"tag": "v0.9.2",
|
||||
"version": "0.9.2",
|
||||
"date": "2026-10-28",
|
||||
"url": "https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.2",
|
||||
"notes": [
|
||||
"New server installation waits for slower database startup",
|
||||
"Find and edit CoA options in the existing server settings",
|
||||
"Simultaneous update checks share results or wait their turn",
|
||||
"Recovery can stop an unfinished world startup after restoring an older launcher"
|
||||
],
|
||||
"commit": "2d9c6a65bbb1e296dc919e4c9e5785ed9d4a070b",
|
||||
"compare": "https://github.com/Corfirean/coa-server-manager/compare/v0.9.1...v0.9.2",
|
||||
"experimentalFeatures": [
|
||||
"portable-characters"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "v0.9.3",
|
||||
"version": "0.9.3",
|
||||
"date": "2026-10-29",
|
||||
"url": "https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.3",
|
||||
"notes": [
|
||||
"Slow server startup no longer triggers an early update rollback"
|
||||
],
|
||||
"commit": "e7b76137d1b22a7596c2b1fa05ca9d12403b99d3",
|
||||
"compare": "https://github.com/Corfirean/coa-server-manager/compare/v0.9.2...v0.9.3",
|
||||
"experimentalFeatures": [
|
||||
"portable-characters"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "v0.9.4",
|
||||
"version": "0.9.4",
|
||||
"date": "2026-10-29",
|
||||
"url": "https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.4",
|
||||
"notes": [
|
||||
"Settings group updates, startup and maintenance with translated release history",
|
||||
"Update and launch without updating share a divided button",
|
||||
"Maximizing the window keeps text and controls at a comfortable size"
|
||||
],
|
||||
"commit": "c004b90c54fa358b3037c56b093cf019dfcf02b8",
|
||||
"compare": "https://github.com/Corfirean/coa-server-manager/compare/v0.9.3...v0.9.4",
|
||||
"experimentalFeatures": [
|
||||
"portable-characters"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "v0.9.5",
|
||||
"version": "0.9.5",
|
||||
"date": "2026-10-30",
|
||||
"url": "https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.5",
|
||||
"notes": [
|
||||
"Account creation verifies a lost console reply against the requested login",
|
||||
"Abandoned game relay tunnels close their local connection immediately",
|
||||
"Keep disabled graphics components disabled during client updates",
|
||||
"Force-stop an unresponsive world after a failed normal shutdown",
|
||||
"Crash history includes reports from every world and Windows text files",
|
||||
"Show the online bot count for Playerbots on the overview",
|
||||
"Disable public server browsing in Settings",
|
||||
"Keep deliberate stops and update shutdowns from triggering crash restart",
|
||||
"Server startup waits for a responsive console before reporting success",
|
||||
"Restore the existing Manager window when launching it again"
|
||||
],
|
||||
"commit": "642da8fdc1a0165aea74fbd1ab1b46933fc7e589",
|
||||
"compare": "https://github.com/Corfirean/coa-server-manager/compare/v0.9.4...v0.9.5"
|
||||
},
|
||||
{
|
||||
"tag": "v0.9.7",
|
||||
"version": "0.9.7",
|
||||
"date": "2026-10-30",
|
||||
"url": "https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.7",
|
||||
"notes": [
|
||||
"Show available update notes even when release history is cached"
|
||||
],
|
||||
"commit": "ba5816e3aea471d5b870e5f0db0b03920c071ed3",
|
||||
"compare": "https://github.com/Corfirean/coa-server-manager/compare/v0.9.5...v0.9.7"
|
||||
},
|
||||
{
|
||||
"tag": "v0.9.8",
|
||||
"version": "0.9.8",
|
||||
"date": "2026-11-01",
|
||||
"url": "https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.8",
|
||||
"notes": [
|
||||
"Dungeon Clear can be enabled when SQUID bots are active",
|
||||
"Diagnostic exports include launcher stages and lock owner records",
|
||||
"Choose normal logs, errors only or no server logs in maintenance settings",
|
||||
"Update checks temporarily suspend bot population and restore your configuration",
|
||||
"Update validation keeps MySQL running between compatible checks"
|
||||
],
|
||||
"commit": "076fba185c4d96d74f7258d6ca0cae6a4ae4a613",
|
||||
"compare": "https://github.com/Corfirean/coa-server-manager/compare/v0.9.7...v0.9.8"
|
||||
},
|
||||
{
|
||||
"tag": "v0.9.9",
|
||||
"version": "0.9.9",
|
||||
"date": "2026-11-04",
|
||||
"url": "https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.9",
|
||||
"notes": [
|
||||
"Update and recovery checks use the temporary login port even with a Windows override"
|
||||
],
|
||||
"commit": "173248efbe24da9b4c1b5ca12fa7580fcd1e8ea7",
|
||||
"compare": "https://github.com/Corfirean/coa-server-manager/compare/v0.9.8...v0.9.9"
|
||||
},
|
||||
{
|
||||
"tag": "v0.9.10",
|
||||
"version": "0.9.10",
|
||||
"date": "2026-11-08",
|
||||
"url": "https://github.com/Corfirean/coa-server-manager/releases/tag/v0.9.10",
|
||||
"notes": [
|
||||
"Custom Races patch installation recovers from interrupted downloads"
|
||||
],
|
||||
"commit": "711f378ae82f75d3fc64368c042889c773315c54",
|
||||
"compare": "https://github.com/Corfirean/coa-server-manager/compare/v0.9.9...v0.9.10"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
use coa_core::{
|
||||
db::{Account, Db},
|
||||
driver::{self, Verb},
|
||||
ra::Ra,
|
||||
Result,
|
||||
};
|
||||
use std::path::PathBuf;
|
||||
fn main() -> Result<()> {
|
||||
let root = PathBuf::from(std::env::args().nth(1).expect("disposable fixture"));
|
||||
assert!(root
|
||||
.file_name()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.starts_with("coa-update-recovery-fixture-"));
|
||||
assert!(root.join("recovery-e2e-started").is_file());
|
||||
let result = std::panic::catch_unwind(|| -> Result<()> {
|
||||
let started = driver::run(&root, Verb::StartAll)?;
|
||||
assert!(started.ok, "{}", started.output);
|
||||
assert!(root.join("Core/Crashes").is_dir());
|
||||
let db = Db::from_repack(&root, Account::Admin)?;
|
||||
println!("Account acceptance: server started, connecting to RA");
|
||||
let mut ra = Ra::connect(&root)?;
|
||||
println!("Account acceptance: RA authenticated");
|
||||
let name = "STABILITYACCT2";
|
||||
assert_eq!(
|
||||
db.query("SELECT COUNT(*) FROM acore_auth.account WHERE username='STABILITYACCT2';")?
|
||||
.trim(),
|
||||
"0"
|
||||
);
|
||||
println!("Account acceptance: sending create command");
|
||||
coa_core::accounts::create(&root, name, "PrivateTest773", true)?;
|
||||
println!("Account acceptance: created");
|
||||
assert_eq!(db.query("SELECT COUNT(*) FROM acore_auth.account WHERE username='STABILITYACCT2' AND LENGTH(salt)=32 AND LENGTH(verifier)=32;")?.trim(), "1");
|
||||
assert!(ra
|
||||
.create_account(name, "PrivateTest773")
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.contains("already taken"));
|
||||
ra.set_account_password(name, "PrivateTest774")?;
|
||||
ra.set_account_access(name, 3)?;
|
||||
assert_eq!(db.query("SELECT gmlevel FROM acore_auth.account_access WHERE id=(SELECT id FROM acore_auth.account WHERE username='STABILITYACCT2');")?.trim(), "3");
|
||||
ra.delete_account(name)?;
|
||||
assert_eq!(
|
||||
db.query("SELECT COUNT(*) FROM acore_auth.account WHERE username='STABILITYACCT2';")?
|
||||
.trim(),
|
||||
"0"
|
||||
);
|
||||
lost_reply(&root, &db)?;
|
||||
println!("PASS: native RA account create, SRP salt/verifier, duplicate refusal, password change, administrator access and deletion");
|
||||
Ok(())
|
||||
});
|
||||
let stopped = driver::run(&root, Verb::StopAll)?;
|
||||
assert!(stopped.ok, "{}", stopped.output);
|
||||
result.map_err(|_| {
|
||||
coa_core::Error::Invalid("Native account acceptance failed; fixture stopped".into())
|
||||
})?
|
||||
}
|
||||
|
||||
fn lost_reply(root: &std::path::Path, db: &Db) -> Result<()> {
|
||||
use std::io::{Read, Write};
|
||||
use std::net::{TcpListener, TcpStream};
|
||||
let path = root.join("Settings/repack.json");
|
||||
let original = std::fs::read(&path)?;
|
||||
struct Restore(std::path::PathBuf, Vec<u8>);
|
||||
impl Drop for Restore {
|
||||
fn drop(&mut self) {
|
||||
std::fs::write(&self.0, &self.1).expect("restore disposable fixture settings");
|
||||
}
|
||||
}
|
||||
let restore = Restore(path.clone(), original.clone());
|
||||
let actual = coa_core::layout::read_ports(root).ra;
|
||||
for (name, forward, ready) in [
|
||||
("STABLOSTREPLY", true, true),
|
||||
("STABNOTCREATED", false, true),
|
||||
("STABNOTREADY", false, false),
|
||||
] {
|
||||
assert_eq!(
|
||||
db.query(&format!(
|
||||
"SELECT COUNT(*) FROM acore_auth.account WHERE username='{name}';"
|
||||
))?
|
||||
.trim(),
|
||||
"0"
|
||||
);
|
||||
let listener = TcpListener::bind(("127.0.0.1", 0))?;
|
||||
let mut config: serde_json::Value = serde_json::from_slice(&original)?;
|
||||
config["raPort"] = listener.local_addr()?.port().into();
|
||||
coa_core::fsx::atomic_write_json(&path, &config)?;
|
||||
let proxy = std::thread::spawn(move || {
|
||||
fn until(s: &mut TcpStream, marker: &[u8]) -> Vec<u8> {
|
||||
s.set_read_timeout(Some(std::time::Duration::from_secs(30)))
|
||||
.unwrap();
|
||||
let mut bytes = Vec::new();
|
||||
let mut byte = [0];
|
||||
while !bytes.ends_with(marker) {
|
||||
s.read_exact(&mut byte).unwrap();
|
||||
bytes.push(byte[0]);
|
||||
}
|
||||
bytes
|
||||
}
|
||||
let (mut client, _) = listener.accept().unwrap();
|
||||
let mut server = TcpStream::connect(("127.0.0.1", actual)).unwrap();
|
||||
for marker in [b"Username: ".as_slice(), b"Password: ".as_slice()] {
|
||||
client.write_all(&until(&mut server, marker)).unwrap();
|
||||
server.write_all(&until(&mut client, b"\r\n")).unwrap();
|
||||
}
|
||||
client.write_all(&until(&mut server, b"AC>")).unwrap();
|
||||
let readiness = until(&mut client, b"\r\n");
|
||||
assert_eq!(readiness, b"server info\r\n");
|
||||
if !ready {
|
||||
return;
|
||||
}
|
||||
server.write_all(&readiness).unwrap();
|
||||
client.write_all(&until(&mut server, b"AC>")).unwrap();
|
||||
let command = until(&mut client, b"\r\n");
|
||||
if forward {
|
||||
server.write_all(&command).unwrap();
|
||||
let _ = until(&mut server, b"AC>");
|
||||
}
|
||||
});
|
||||
let outcome = coa_core::accounts::create(root, name, "PrivateTest773", false);
|
||||
proxy.join().unwrap();
|
||||
std::fs::write(&path, &original)?;
|
||||
if forward {
|
||||
outcome?;
|
||||
assert_eq!(
|
||||
db.query(&format!(
|
||||
"SELECT COUNT(*) FROM acore_auth.account WHERE username='{name}';"
|
||||
))?
|
||||
.trim(),
|
||||
"1"
|
||||
);
|
||||
assert!(coa_core::accounts::create(root, name, "DifferentPass77", false).is_err());
|
||||
Ra::connect(root)?.delete_account(name)?;
|
||||
} else {
|
||||
assert!(outcome.is_err());
|
||||
if !ready {
|
||||
assert!(outcome
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.contains("No create command was sent"));
|
||||
}
|
||||
assert_eq!(
|
||||
db.query(&format!(
|
||||
"SELECT COUNT(*) FROM acore_auth.account WHERE username='{name}';"
|
||||
))?
|
||||
.trim(),
|
||||
"0"
|
||||
);
|
||||
}
|
||||
}
|
||||
drop(restore);
|
||||
println!("PASS: a lost native console reply is reconciled by exact SRP credentials; a command that was never executed is rejected");
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
use coa_core::{crashes, Result};
|
||||
fn main()->Result<()> {
|
||||
let root=std::path::PathBuf::from(std::env::args().nth(1).expect("marked native fixture"));
|
||||
assert!(root.join("recovery-e2e-started").is_file());
|
||||
let reports=crashes::list(&root,30)?;
|
||||
let matching:Vec<_>=reports.iter().filter(|r|r.full_log.contains("AllowableRaces")).collect();
|
||||
assert!(!matching.is_empty());
|
||||
assert!(matching.iter().all(|r|r.exception_code.as_deref()==Some("C0000420")));
|
||||
println!("PASS: Manager discovered {} actual worldserver SQL assertion reports from Core/Crashes, including Windows ANSI text",matching.len());
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
use coa_core::{
|
||||
db::{Account, Db},
|
||||
driver::{self, Verb},
|
||||
ra::Ra,
|
||||
Result,
|
||||
};
|
||||
use std::{
|
||||
path::PathBuf,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
fn main() -> Result<()> {
|
||||
let root = PathBuf::from(
|
||||
std::env::args()
|
||||
.nth(1)
|
||||
.expect("disposable recovery fixture"),
|
||||
);
|
||||
assert!(root
|
||||
.file_name()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.starts_with("coa-update-recovery-fixture-"));
|
||||
assert!(root.join("recovery-e2e-started").is_file());
|
||||
let result = std::panic::catch_unwind(|| -> Result<()> {
|
||||
let start = driver::run(&root, Verb::StartAll)?;
|
||||
assert!(start.ok, "{}", start.output);
|
||||
let db = Db::from_repack(&root, Account::Admin)?;
|
||||
coa_core::companions::ensure_templates(&db)?;
|
||||
let mut ra = Ra::connect(&root)?;
|
||||
let before = coa_core::population::query(&root)?;
|
||||
assert_eq!(before.bots_online, 0);
|
||||
let rejected = db.query("SELECT name, at_login FROM acore_characters.characters WHERE guid=3030 AND account IN (SELECT id FROM acore_auth.account WHERE username LIKE 'COABOTHOST%');")?;
|
||||
assert!(rejected.contains("Christian Shadowheart"));
|
||||
assert_eq!(rejected.split_whitespace().last(), Some("1"));
|
||||
println!("Repair reply: {}", ra.run("botcmd spawnbot 3030")?);
|
||||
let repair_deadline = Instant::now() + Duration::from_secs(60);
|
||||
loop {
|
||||
let row = db.query(
|
||||
"SELECT name, at_login, online FROM acore_characters.characters WHERE guid=3030;",
|
||||
)?;
|
||||
if row.trim().ends_with("0\t1") {
|
||||
assert!(!row.contains("Christian Shadowheart"));
|
||||
println!("PASS: the exact previously rejected companion was renamed by server validation and logged in");
|
||||
break;
|
||||
}
|
||||
assert!(
|
||||
Instant::now() < repair_deadline,
|
||||
"previously rejected companion logged in"
|
||||
);
|
||||
std::thread::sleep(Duration::from_secs(1));
|
||||
}
|
||||
let _ = ra.despawn_all()?;
|
||||
let clear_deadline = Instant::now() + Duration::from_secs(30);
|
||||
while coa_core::population::query(&root)?.bots_online > 0 {
|
||||
assert!(Instant::now() < clear_deadline);
|
||||
std::thread::sleep(Duration::from_secs(1));
|
||||
}
|
||||
println!("Spawn reply: {}", ra.spawn_bots(21)?);
|
||||
let deadline = Instant::now() + Duration::from_secs(180);
|
||||
loop {
|
||||
let pop = coa_core::population::query(&root)?;
|
||||
if pop.bots_online >= 21 {
|
||||
println!(
|
||||
"PASS: {} companions logged in; real players={}",
|
||||
pop.bots_online, pop.players_online
|
||||
);
|
||||
break;
|
||||
}
|
||||
if Instant::now() > deadline {
|
||||
return Err(coa_core::Error::Invalid(format!(
|
||||
"Only {} of 21 companion logins completed",
|
||||
pop.bots_online
|
||||
)));
|
||||
}
|
||||
std::thread::sleep(Duration::from_secs(2));
|
||||
}
|
||||
let _ = ra.cancel_spawning()?;
|
||||
let _ = ra.despawn_all()?;
|
||||
let deadline = Instant::now() + Duration::from_secs(30);
|
||||
while coa_core::population::query(&root)?.bots_online > 0 {
|
||||
assert!(Instant::now() < deadline, "companions despawned");
|
||||
std::thread::sleep(Duration::from_secs(1));
|
||||
}
|
||||
println!("PASS: companion despawn completed");
|
||||
Ok(())
|
||||
});
|
||||
let stopped = driver::run(&root, Verb::StopAll)?;
|
||||
assert!(stopped.ok, "{}", stopped.output);
|
||||
result.map_err(|_| {
|
||||
coa_core::Error::Invalid("Companion native acceptance panicked; fixture stopped".into())
|
||||
})?
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
use coa_core::{crashes, Result};
|
||||
fn main() -> Result<()> {
|
||||
let root = std::path::PathBuf::from(std::env::args().nth(1).expect("native crash evidence"));
|
||||
assert!(root.join(".crash-report-evidence").is_file());
|
||||
let reports = crashes::list(&root, 10)?;
|
||||
assert_eq!(reports.len(), 1);
|
||||
assert_eq!(reports[0].exception_code.as_deref(), Some("C0000005"));
|
||||
assert_eq!(reports[0].category, "access_violation");
|
||||
assert!(!reports[0].full_log.is_empty());
|
||||
println!("PASS: Manager crash history discovers and classifies the actual native handler report from Core/Crashes");
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
use coa_core::{driver, fsx, process, Result};
|
||||
#[cfg(windows)]
|
||||
use std::os::windows::process::CommandExt;
|
||||
use std::{
|
||||
path::Path,
|
||||
process::{Child, Command, Stdio},
|
||||
};
|
||||
|
||||
struct OwnedChild(Child);
|
||||
impl Drop for OwnedChild {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.0.kill();
|
||||
let _ = self.0.wait();
|
||||
}
|
||||
}
|
||||
fn copy_tree(source: &Path, target: &Path) -> Result<()> {
|
||||
std::fs::create_dir_all(target)?;
|
||||
for entry in std::fs::read_dir(source)? {
|
||||
let entry = entry?;
|
||||
let destination = target.join(entry.file_name());
|
||||
if entry.file_type()?.is_dir() {
|
||||
copy_tree(&entry.path(), &destination)?;
|
||||
} else {
|
||||
std::fs::copy(entry.path(), destination)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
fn spawn(path: &Path) -> OwnedChild {
|
||||
let mut cmd = Command::new(path);
|
||||
cmd.args(["-t", "127.0.0.1"])
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null());
|
||||
#[cfg(windows)]
|
||||
cmd.creation_flags(0x0800_0000);
|
||||
OwnedChild(cmd.spawn().unwrap())
|
||||
}
|
||||
fn main() -> Result<()> {
|
||||
assert!(cfg!(windows));
|
||||
let source = std::path::PathBuf::from(
|
||||
std::env::args()
|
||||
.nth(1)
|
||||
.expect("marked disposable runtime source"),
|
||||
);
|
||||
assert_eq!(
|
||||
std::fs::read(source.join(".release-schema-fixture"))?,
|
||||
b"disposable release-schema fixture"
|
||||
);
|
||||
let temp = tempfile::tempdir()?;
|
||||
let root = temp.path();
|
||||
copy_tree(&source.join("Runtime"), &root.join("Runtime"))?;
|
||||
std::fs::create_dir_all(root.join("Core"))?;
|
||||
std::fs::create_dir_all(root.join("Scripts"))?;
|
||||
let system =
|
||||
std::path::PathBuf::from(std::env::var_os("SystemRoot").unwrap()).join("System32/ping.exe");
|
||||
std::fs::copy(&system, root.join("Core/worldserver.exe"))?;
|
||||
std::fs::copy(&system, root.join("foreign.exe"))?;
|
||||
let mut ports = Vec::new();
|
||||
let mut listeners = Vec::new();
|
||||
for _ in 0..4 {
|
||||
let listener = std::net::TcpListener::bind("127.0.0.1:0")?;
|
||||
ports.push(listener.local_addr()?.port());
|
||||
listeners.push(listener);
|
||||
}
|
||||
let config = serde_json::json!({"mysqlPort":ports[0],"authPort":ports[1],"worldPort":ports[2],"raPort":ports[3],"raUsername":"fixture","raPassword":"fixture"});
|
||||
fsx::atomic_write_json(&root.join("Settings/repack.json"), &config)?;
|
||||
drop(listeners);
|
||||
let mut launcher = std::fs::read_to_string(source.join("Scripts/manage.py"))?;
|
||||
launcher.push_str("\nfrom contextlib import nullcontext\ndef control_lock(): return nullcontext()\ndef stop_all(config):\n assert not process('world'), 'world must stop before database'\n (ROOT/'database-stage').write_text('safe')\n");
|
||||
fsx::atomic_write(&root.join("Scripts/manage.py"), launcher.as_bytes())?;
|
||||
let mut foreign = spawn(&root.join("foreign.exe"));
|
||||
let foreign_identity = process::identity(foreign.0.id()).unwrap();
|
||||
fsx::atomic_write_json(&root.join(".state/world.json"), &foreign_identity)?;
|
||||
let rejected = driver::force_stop(root)?;
|
||||
assert!(!rejected.ok, "a foreign world record must be rejected");
|
||||
assert!(!root.join("database-stage").exists());
|
||||
assert!(foreign.0.try_wait()?.is_none());
|
||||
let mut owned = spawn(&root.join("Core/worldserver.exe"));
|
||||
let stopped = driver::force_stop(root)?;
|
||||
assert!(stopped.ok, "{}", stopped.output);
|
||||
assert!(owned.0.try_wait()?.is_some());
|
||||
assert!(
|
||||
foreign.0.try_wait()?.is_none(),
|
||||
"foreign process was untouched"
|
||||
);
|
||||
assert_eq!(std::fs::read(root.join("database-stage"))?, b"safe");
|
||||
println!("PASS: native Windows forced-stop rejects foreign records, recovers the exact owned world identity, stops it before the database stage, and leaves the foreign process alive");
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
use base64::{engine::general_purpose::STANDARD, Engine};
|
||||
use coa_core::{
|
||||
backup,
|
||||
db::Db,
|
||||
driver::{self, Verb},
|
||||
fsx,
|
||||
manifest::{Kind, Migration},
|
||||
package::{self, BuildOptions},
|
||||
pkgsource::Source,
|
||||
registry::MetaDir,
|
||||
update::{self, RepackEnv},
|
||||
Result,
|
||||
};
|
||||
use ed25519_dalek::{Signer, SigningKey};
|
||||
use std::{collections::BTreeMap, path::PathBuf};
|
||||
fn main() -> Result<()> {
|
||||
let root = PathBuf::from(
|
||||
std::env::args()
|
||||
.nth(1)
|
||||
.expect("qualified disposable fixture"),
|
||||
);
|
||||
let sql = std::fs::read(std::env::args().nth(2).expect("corrective SQL"))?;
|
||||
assert_eq!(
|
||||
root.file_name().unwrap(),
|
||||
"coa-schema-fixture-stability-upgrade-76-85-20261030"
|
||||
);
|
||||
assert!(root.join(".release-schema-fixture").is_file());
|
||||
assert!(!root.join("legacy-start-data-e2e-started").exists());
|
||||
fsx::atomic_write(
|
||||
&root.join("legacy-start-data-e2e-started"),
|
||||
b"disposable regression test",
|
||||
)?;
|
||||
let result = std::panic::catch_unwind(|| -> Result<()> {
|
||||
let meta = coa_core::registry::metadata_dir_for(&root)?;
|
||||
let mut identities = String::new();
|
||||
let mut custom = String::new();
|
||||
backup::with_database(&root, |db| {
|
||||
assert_eq!(
|
||||
db.query(
|
||||
"SELECT COUNT(*) FROM acore_world.playercreateinfo WHERE race IN (33,45);"
|
||||
)?
|
||||
.trim(),
|
||||
"0"
|
||||
);
|
||||
let base: u32 = db
|
||||
.query("SELECT MAX(guid)+100 FROM acore_characters.characters;")?
|
||||
.trim()
|
||||
.parse()
|
||||
.unwrap();
|
||||
clone_character(db, base, 33, 12, "Thinprobe")?;
|
||||
clone_character(db, base + 1, 45, 30, "Leperprobe")?;
|
||||
identities = db.query(&format!(
|
||||
"SELECT * FROM acore_characters.characters WHERE guid IN ({base},{});",
|
||||
base + 1
|
||||
))?;
|
||||
let missing = coa_core::character_start_check::missing(db)?;
|
||||
assert!(missing
|
||||
.iter()
|
||||
.any(|c| c.guid == base && c.race == 33 && c.class == 12));
|
||||
assert!(missing
|
||||
.iter()
|
||||
.any(|c| c.guid == base + 1 && c.race == 45 && c.class == 30));
|
||||
db.query("INSERT INTO acore_world.playercreateinfo SELECT 33,class,map,zone,position_x+0.125,position_y,position_z,orientation FROM acore_world.playercreateinfo WHERE race=1 AND class=32;")?;
|
||||
custom =
|
||||
db.query("SELECT * FROM acore_world.playercreateinfo WHERE race=33 AND class=32;")?;
|
||||
fsx::atomic_write(
|
||||
&root.join("legacy-probe-guids.json"),
|
||||
serde_json::to_string(&[base, base + 1])?.as_bytes(),
|
||||
)?;
|
||||
println!("PASS: reproduced missing starting data for existing race 33/class 12 and race 45/class 30 characters");
|
||||
Ok(())
|
||||
})?;
|
||||
let source = root.join("legacy-start-data-source");
|
||||
let pkg = root.join("legacy-start-data-package");
|
||||
fsx::atomic_write(
|
||||
&source.join("Core/legacy-start-data-proof.txt"),
|
||||
b"corrective migration acceptance",
|
||||
)?;
|
||||
fsx::atomic_write(
|
||||
&source.join("_migrations/world/stabilization_legacy_starts.sql"),
|
||||
&sql,
|
||||
)?;
|
||||
let manifest = package::build(
|
||||
&source,
|
||||
&pkg,
|
||||
&BuildOptions {
|
||||
kind: Kind::Update,
|
||||
version: "2.0.0".into(),
|
||||
core_commit: None,
|
||||
bots_commit: None,
|
||||
built_at: "private regression acceptance".into(),
|
||||
part_size: 1 << 20,
|
||||
migrations: vec![Migration {
|
||||
id: "stabilization_legacy_starts".into(),
|
||||
db: "world".into(),
|
||||
sha256: fsx::sha256_bytes(&sql),
|
||||
compatible_sha256: vec![],
|
||||
destructive: false,
|
||||
}],
|
||||
},
|
||||
&|_| {},
|
||||
)?;
|
||||
let key = SigningKey::generate(&mut rand_core::OsRng);
|
||||
fsx::atomic_write(
|
||||
&pkg.join("manifest.json.sig"),
|
||||
STANDARD
|
||||
.encode(
|
||||
key.sign(&std::fs::read(pkg.join("manifest.json"))?)
|
||||
.to_bytes(),
|
||||
)
|
||||
.as_bytes(),
|
||||
)?;
|
||||
let trusted = STANDARD.encode(key.verifying_key().to_bytes());
|
||||
let env = RepackEnv {
|
||||
root: &root,
|
||||
meta_dir: &meta,
|
||||
};
|
||||
let out = update::apply(
|
||||
&update::Params {
|
||||
root: &root,
|
||||
meta_dir: &meta,
|
||||
source: Source::Dir(pkg),
|
||||
trusted_key: &trusted,
|
||||
cancel: Default::default(),
|
||||
resolutions: BTreeMap::new(),
|
||||
env: &env,
|
||||
fail_after_ops: None,
|
||||
},
|
||||
&|step, pct| println!("{pct}% {step}"),
|
||||
)?;
|
||||
assert_eq!(out.txn.state, update::State::Committed);
|
||||
assert_eq!(
|
||||
MetaDir::open(&meta)?.1.core.version.as_deref(),
|
||||
Some("2.0.0")
|
||||
);
|
||||
backup::with_database(&root, |db| {
|
||||
let guids: Vec<u32> =
|
||||
serde_json::from_slice(&std::fs::read(root.join("legacy-probe-guids.json"))?)?;
|
||||
assert_eq!(
|
||||
db.query(&format!(
|
||||
"SELECT * FROM acore_characters.characters WHERE guid IN ({},{});",
|
||||
guids[0], guids[1]
|
||||
))?,
|
||||
identities
|
||||
);
|
||||
assert!(coa_core::character_start_check::missing(db)?
|
||||
.iter()
|
||||
.all(|c| !guids.contains(&c.guid)));
|
||||
assert_eq!(
|
||||
db.query("SELECT * FROM acore_world.playercreateinfo WHERE race=33 AND class=32;")?,
|
||||
custom
|
||||
);
|
||||
assert!(coa_core::migrations::status(db, &manifest.migrations)?
|
||||
.iter()
|
||||
.all(|m| m.status == coa_core::migrations::Status::Applied));
|
||||
let before = counts(db)?;
|
||||
db.query(&format!(
|
||||
"USE acore_world; {}",
|
||||
String::from_utf8_lossy(&sql)
|
||||
))?;
|
||||
assert_eq!(counts(db)?, before);
|
||||
assert_eq!(
|
||||
db.query("SELECT * FROM acore_world.playercreateinfo WHERE race=33 AND class=32;")?,
|
||||
custom
|
||||
);
|
||||
println!("PASS: signed Manager update restored legacy starts, preserved complete character rows and custom starts, and remained idempotent on a second SQL execution");
|
||||
Ok(())
|
||||
})?;
|
||||
Ok(())
|
||||
});
|
||||
let stopped = driver::run(&root, Verb::StopAll)?;
|
||||
assert!(stopped.ok, "{}", stopped.output);
|
||||
result.map_err(|_| {
|
||||
coa_core::Error::Invalid("Legacy start regression failed; fixture stopped".into())
|
||||
})?
|
||||
}
|
||||
fn counts(db: &Db) -> Result<String> {
|
||||
db.query("SELECT COUNT(*) FROM acore_world.playercreateinfo WHERE race IN (33,45); SELECT COUNT(*) FROM acore_world.playercreateinfo_item WHERE race IN (33,45); SELECT COUNT(*) FROM acore_world.playercreateinfo_action WHERE race IN (33,45); SELECT COUNT(*) FROM acore_world.player_race_stats WHERE Race IN (33,45); SELECT COUNT(*) FROM acore_world.ascension_custom_class_race WHERE race IN (33,45);")
|
||||
}
|
||||
fn clone_character(db: &Db, guid: u32, race: u32, class: u32, name: &str) -> Result<()> {
|
||||
let columns = db.query("SHOW COLUMNS FROM acore_characters.characters;")?;
|
||||
let names: Vec<_> = columns
|
||||
.lines()
|
||||
.map(|l| l.split('\t').next().unwrap())
|
||||
.collect();
|
||||
let values: Vec<String> = names
|
||||
.iter()
|
||||
.map(|c| match *c {
|
||||
"guid" => guid.to_string(),
|
||||
"name" => format!("'{name}'"),
|
||||
"race" => race.to_string(),
|
||||
"class" => class.to_string(),
|
||||
"online" | "at_login" => "0".into(),
|
||||
_ => format!("`{c}`"),
|
||||
})
|
||||
.collect();
|
||||
db.query(&format!("INSERT INTO acore_characters.characters ({}) SELECT {} FROM acore_characters.characters WHERE class={class} LIMIT 1;",names.iter().map(|c|format!("`{c}`")).collect::<Vec<_>>().join(","),values.join(",")))?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
use coa_core::{backup, schema_check, Result};
|
||||
fn main()->Result<()> {
|
||||
let root=std::path::PathBuf::from(std::env::args().nth(1).unwrap());
|
||||
let contract=std::path::PathBuf::from(std::env::args().nth(2).unwrap());
|
||||
assert!(root.join("recovery-e2e-started").is_file());
|
||||
assert!(contract.join(".release-schema-fixture").is_file());
|
||||
backup::with_database(&root,|db| {for p in schema_check::check(db,&contract)? {println!("{}.{}.{}: {}",p.database,p.table,p.column,p.detail);} Ok(())})
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
use base64::{engine::general_purpose::STANDARD, Engine};
|
||||
use coa_core::{
|
||||
backup,
|
||||
driver::{self, Verb},
|
||||
fsx,
|
||||
manifest::{Kind, Migration},
|
||||
package::{self, BuildOptions},
|
||||
pkgsource::Source,
|
||||
update::{self, RepackEnv},
|
||||
Result,
|
||||
};
|
||||
use ed25519_dalek::{Signer, SigningKey};
|
||||
use std::{collections::BTreeMap, path::PathBuf};
|
||||
fn main() -> Result<()> {
|
||||
let root = PathBuf::from(std::env::args().nth(1).unwrap());
|
||||
let core = PathBuf::from(std::env::args().nth(2).unwrap());
|
||||
let release = PathBuf::from(std::env::args().nth(3).unwrap());
|
||||
assert!(root.join("recovery-e2e-started").is_file());
|
||||
let result = std::panic::catch_unwind(|| -> Result<()> {
|
||||
let meta = coa_core::registry::metadata_dir_for(&root)?;
|
||||
let source = root.join("schema-sync-source-v2");
|
||||
let pkg = root.join("schema-sync-package-v2");
|
||||
assert!(!pkg.exists());
|
||||
fsx::atomic_write(
|
||||
&source.join("Core/schema-sync-proof.txt"),
|
||||
b"official schema migration acceptance",
|
||||
)?;
|
||||
let published =
|
||||
coa_core::manifest::Manifest::parse(&std::fs::read(release.join("manifest.json"))?)?;
|
||||
let contract_path = PathBuf::from("C:/games/source/coa-schema-fixture-stability-upgrade-76-85-20261030/Scripts/database-schema.json");
|
||||
let contract = std::fs::read(contract_path)?;
|
||||
let expected = published
|
||||
.files
|
||||
.iter()
|
||||
.find(|f| f.path == "Scripts/database-schema.json")
|
||||
.unwrap();
|
||||
assert_eq!(fsx::sha256_bytes(&contract), expected.sha256);
|
||||
fsx::atomic_write(&source.join("Scripts/database-schema.json"), &contract)?;
|
||||
let mut migrations: Vec<Migration> = Vec::new();
|
||||
for id in [
|
||||
"rev_1793212891571528600",
|
||||
"rev_20261027_18_coa_strange_piece_of_scrap_faction_diamond",
|
||||
] {
|
||||
let m = published
|
||||
.migrations
|
||||
.iter()
|
||||
.find(|m| m.id == id)
|
||||
.unwrap()
|
||||
.clone();
|
||||
let sql = std::fs::read(
|
||||
core.join(format!("data/sql/updates/pending_db_{}/{}.sql", m.db, m.id)),
|
||||
)?;
|
||||
assert_eq!(fsx::sha256_bytes(&sql), m.sha256);
|
||||
fsx::atomic_write(
|
||||
&source.join(format!("_migrations/{}/{}.sql", m.db, m.id)),
|
||||
&sql,
|
||||
)?;
|
||||
migrations.push(m);
|
||||
}
|
||||
package::build(
|
||||
&source,
|
||||
&pkg,
|
||||
&BuildOptions {
|
||||
kind: Kind::Update,
|
||||
version: "3.0.0".into(),
|
||||
core_commit: None,
|
||||
bots_commit: None,
|
||||
built_at: "private native fixture schema sync".into(),
|
||||
part_size: 1 << 20,
|
||||
migrations,
|
||||
},
|
||||
&|_| {},
|
||||
)?;
|
||||
let key = SigningKey::generate(&mut rand_core::OsRng);
|
||||
fsx::atomic_write(
|
||||
&pkg.join("manifest.json.sig"),
|
||||
STANDARD
|
||||
.encode(
|
||||
key.sign(&std::fs::read(pkg.join("manifest.json"))?)
|
||||
.to_bytes(),
|
||||
)
|
||||
.as_bytes(),
|
||||
)?;
|
||||
let trusted = STANDARD.encode(key.verifying_key().to_bytes());
|
||||
let env = RepackEnv {
|
||||
root: &root,
|
||||
meta_dir: &meta,
|
||||
};
|
||||
let out = update::apply(
|
||||
&update::Params {
|
||||
root: &root,
|
||||
meta_dir: &meta,
|
||||
source: Source::Dir(pkg),
|
||||
trusted_key: &trusted,
|
||||
cancel: Default::default(),
|
||||
resolutions: BTreeMap::from([(
|
||||
"Scripts/database-schema.json".into(),
|
||||
update::Resolution::Replace,
|
||||
)]),
|
||||
env: &env,
|
||||
fail_after_ops: None,
|
||||
},
|
||||
&|step, pct| println!("{pct}% {step}"),
|
||||
)?;
|
||||
assert_eq!(out.txn.state, update::State::Committed);
|
||||
backup::with_database(&root, |db| {
|
||||
assert_eq!(
|
||||
db.query("SELECT name,at_login FROM acore_characters.characters WHERE guid=3030;")?
|
||||
.trim(),
|
||||
"Christian Shadowheart\t1"
|
||||
);
|
||||
assert_eq!(
|
||||
db.query("SELECT id FROM acore_characters.manager_recovery_probe;")?
|
||||
.trim(),
|
||||
"42"
|
||||
);
|
||||
assert_eq!(
|
||||
db.query("SELECT id FROM acore_world.manager_recovery_probe;")?
|
||||
.trim(),
|
||||
"44"
|
||||
);
|
||||
Ok(())
|
||||
})?;
|
||||
println!("PASS: the exact two published migrations brought the old fixture schema forward through the Manager updater while preserving the rejected companion and recovery probes");
|
||||
Ok(())
|
||||
});
|
||||
let stop = driver::run(&root, Verb::StopAll)?;
|
||||
assert!(stop.ok, "{}", stop.output);
|
||||
result.map_err(|_| {
|
||||
coa_core::Error::Invalid("Schema sync acceptance failed; fixture stopped".into())
|
||||
})?
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
use base64::{engine::general_purpose::STANDARD, Engine};
|
||||
use coa_core::{
|
||||
backup, driver, fsx,
|
||||
manifest::{Kind, Migration},
|
||||
package::{self, BuildOptions},
|
||||
pkgsource::Source,
|
||||
registry::MetaDir,
|
||||
update::{self, RepackEnv},
|
||||
Result,
|
||||
};
|
||||
use ed25519_dalek::{Signer, SigningKey};
|
||||
use std::{collections::BTreeMap, path::PathBuf};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let root = PathBuf::from(
|
||||
std::env::args()
|
||||
.nth(1)
|
||||
.expect("disposable recovery fixture"),
|
||||
);
|
||||
assert!(root
|
||||
.file_name()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.starts_with("coa-update-recovery-fixture-"));
|
||||
assert!(root.join("recovery-e2e-started").is_file());
|
||||
let cycles_only = std::env::args().nth(2).as_deref() == Some("--cycles-only");
|
||||
if !cycles_only {
|
||||
assert!(!root.join("success-e2e-started").exists());
|
||||
fsx::atomic_write(
|
||||
&root.join("success-e2e-started"),
|
||||
b"disposable success acceptance",
|
||||
)?;
|
||||
}
|
||||
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
||||
if cycles_only {
|
||||
restart_cycles(&root)
|
||||
} else {
|
||||
exercise(&root)
|
||||
}
|
||||
}));
|
||||
assert!(
|
||||
driver::run(&root, driver::Verb::StopAll)?.ok,
|
||||
"fixture shutdown"
|
||||
);
|
||||
result.map_err(|_| {
|
||||
coa_core::Error::Invalid(
|
||||
"Success acceptance assertion failed; fixture services stopped".into(),
|
||||
)
|
||||
})?
|
||||
}
|
||||
|
||||
fn exercise(root: &std::path::Path) -> Result<()> {
|
||||
let meta = coa_core::registry::metadata_dir_for(root)?;
|
||||
assert!(update::unfinished(&meta).is_none());
|
||||
assert!(driver::run(root, driver::Verb::StopAll)?.ok);
|
||||
let source = root.join("success-source");
|
||||
let pkg = root.join("success-package");
|
||||
fsx::atomic_write(
|
||||
&source.join("Core/stabilization-success.txt"),
|
||||
b"verified update",
|
||||
)?;
|
||||
let sql = b"UPDATE manager_recovery_probe SET id=44 WHERE id=43;";
|
||||
fsx::atomic_write(
|
||||
&source.join("_migrations/world/stabilization_success.sql"),
|
||||
sql,
|
||||
)?;
|
||||
let manifest = package::build(
|
||||
&source,
|
||||
&pkg,
|
||||
&BuildOptions {
|
||||
kind: Kind::Update,
|
||||
version: "2.0.0".into(),
|
||||
core_commit: None,
|
||||
bots_commit: None,
|
||||
built_at: "disposable acceptance".into(),
|
||||
part_size: 1 << 20,
|
||||
migrations: vec![Migration {
|
||||
id: "stabilization_success".into(),
|
||||
db: "world".into(),
|
||||
sha256: fsx::sha256_bytes(sql),
|
||||
compatible_sha256: vec![],
|
||||
destructive: false,
|
||||
}],
|
||||
},
|
||||
&|_| {},
|
||||
)?;
|
||||
let key = SigningKey::generate(&mut rand_core::OsRng);
|
||||
fsx::atomic_write(
|
||||
&pkg.join("manifest.json.sig"),
|
||||
STANDARD
|
||||
.encode(
|
||||
key.sign(&std::fs::read(pkg.join("manifest.json"))?)
|
||||
.to_bytes(),
|
||||
)
|
||||
.as_bytes(),
|
||||
)?;
|
||||
let trusted = STANDARD.encode(key.verifying_key().to_bytes());
|
||||
let env = RepackEnv {
|
||||
root,
|
||||
meta_dir: &meta,
|
||||
};
|
||||
let outcome = update::apply(
|
||||
&update::Params {
|
||||
root,
|
||||
meta_dir: &meta,
|
||||
source: Source::Dir(pkg),
|
||||
trusted_key: &trusted,
|
||||
cancel: Default::default(),
|
||||
resolutions: BTreeMap::new(),
|
||||
env: &env,
|
||||
fail_after_ops: None,
|
||||
},
|
||||
&|step, pct| println!("{pct}% {step}"),
|
||||
)?;
|
||||
assert_eq!(outcome.txn.state, update::State::Committed);
|
||||
assert_eq!(
|
||||
MetaDir::open(&meta)?.1.core.version.as_deref(),
|
||||
Some("2.0.0")
|
||||
);
|
||||
assert!(update::unfinished(&meta).is_none());
|
||||
assert_eq!(
|
||||
std::fs::read(root.join("Core/stabilization-success.txt"))?,
|
||||
b"verified update"
|
||||
);
|
||||
backup::with_database(root, |db| {
|
||||
assert_eq!(
|
||||
db.query("SELECT id FROM acore_characters.manager_recovery_probe;")?,
|
||||
"42"
|
||||
);
|
||||
assert_eq!(
|
||||
db.query("SELECT id FROM acore_characters.manager_recovery_view;")?,
|
||||
"42"
|
||||
);
|
||||
assert_eq!(
|
||||
db.query("SELECT id FROM acore_world.manager_recovery_probe;")?,
|
||||
"44"
|
||||
);
|
||||
assert!(coa_core::migrations::status(db, &manifest.migrations)?
|
||||
.iter()
|
||||
.all(|m| m.status == coa_core::migrations::Status::Applied));
|
||||
Ok(())
|
||||
})?;
|
||||
restart_cycles(root)?;
|
||||
println!("PASS: signed update committed after failed rehearsal and recovery; SQL, files, metadata and player data verified; two native restart cycles passed");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn restart_cycles(root: &std::path::Path) -> Result<()> {
|
||||
for cycle in 0..2 {
|
||||
let stopped = driver::run(root, driver::Verb::StopAll)?;
|
||||
assert!(
|
||||
stopped.ok,
|
||||
"Stop cycle {cycle}: {}",
|
||||
coa_core::diag::redact(&stopped.output)
|
||||
);
|
||||
let started = driver::run(root, driver::Verb::StartAll)?;
|
||||
assert!(started.ok, "{}", started.output);
|
||||
let pop = coa_core::population::query(root)?;
|
||||
println!(
|
||||
"Restart cycle {cycle}: world ready, players={}, bots={}",
|
||||
pop.players_online, pop.bots_online
|
||||
);
|
||||
}
|
||||
println!("PASS: two native restart cycles finished");
|
||||
Ok(())
|
||||
}
|
||||
@@ -30,15 +30,27 @@ fn main() -> Result<()> {
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.starts_with("coa-update-recovery-fixture-"));
|
||||
assert!(
|
||||
!root.join("recovery-e2e-started").exists(),
|
||||
"Use a new fixture; never reuse an owned server"
|
||||
);
|
||||
fsx::atomic_write(&root.join("recovery-e2e-started"), b"disposable fixture")?;
|
||||
let result = exercise(&root);
|
||||
let stopped = driver::run(&root, Verb::StopAll)?;
|
||||
assert!(stopped.ok);
|
||||
result
|
||||
let resume = std::env::args().nth(2).as_deref() == Some("--verify-recovered");
|
||||
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
||||
if resume {
|
||||
assert!(root.join("recovery-e2e-started").is_file());
|
||||
let manifest = coa_core::manifest::Manifest::parse(&std::fs::read(
|
||||
root.join("fixture-package/manifest.json"),
|
||||
)?)?;
|
||||
verify_recovered(&root, &manifest)
|
||||
} else {
|
||||
assert!(
|
||||
!root.join("recovery-e2e-started").exists(),
|
||||
"Use a new fixture"
|
||||
);
|
||||
fsx::atomic_write(&root.join("recovery-e2e-started"), b"disposable fixture")?;
|
||||
exercise(&root)
|
||||
}
|
||||
}));
|
||||
assert!(driver::run(&root, Verb::StopAll)?.ok);
|
||||
result.map_err(|_| {
|
||||
Error::Invalid("Recovery acceptance assertion failed; owned services were stopped".into())
|
||||
})?
|
||||
}
|
||||
|
||||
fn exercise(root: &Path) -> Result<()> {
|
||||
@@ -122,9 +134,18 @@ fn exercise(root: &Path) -> Result<()> {
|
||||
assert!(
|
||||
error
|
||||
.to_string()
|
||||
.contains("private update rehearsal failed"),
|
||||
.contains("files and databases were restored to the recovery point"),
|
||||
"{error}"
|
||||
);
|
||||
verify_recovered(root, &manifest)
|
||||
}
|
||||
|
||||
fn verify_recovered(root: &Path, manifest: &coa_core::manifest::Manifest) -> Result<()> {
|
||||
let meta = coa_core::registry::metadata_dir_for(root)?;
|
||||
let env = RepackEnv {
|
||||
root,
|
||||
meta_dir: &meta,
|
||||
};
|
||||
assert!(!root.join("Core/recovery-probe.txt").exists());
|
||||
assert!(update::unfinished(&meta).is_none());
|
||||
assert_eq!(
|
||||
@@ -168,6 +189,6 @@ fn exercise(root: &Path) -> Result<()> {
|
||||
Db::from_repack(root, Account::Admin)?.realm(),
|
||||
coa_core::realms::Mode::Coa
|
||||
);
|
||||
println!("PASS: private rehearsal caught failed SQL before changing the installed world, characters, ledger, objects, files or version; complete recovery succeeded");
|
||||
println!("PASS: failed SQL was rolled back; characters, world, ledger, views, triggers, routines, files and version were verified; the saved recovery point was restored again");
|
||||
Ok(())
|
||||
}
|
||||
@@ -80,6 +80,60 @@ fn upper(name: &str) -> Result<String> {
|
||||
Ok(name.to_ascii_uppercase())
|
||||
}
|
||||
|
||||
pub fn create(root: &Path, name: &str, password: &str, administrator: bool) -> Result<()> {
|
||||
validate_account(name, password)?;
|
||||
let name = name.to_ascii_uppercase();
|
||||
let db = Db::from_repack(root, Account::Admin)?;
|
||||
if db
|
||||
.query(&format!(
|
||||
"SELECT COUNT(*) FROM acore_auth.account WHERE username='{name}';"
|
||||
))?
|
||||
.trim()
|
||||
!= "0"
|
||||
{
|
||||
return Err(Error::Invalid("That account name is already taken.".into()));
|
||||
}
|
||||
let mut ra = Ra::connect(root)?;
|
||||
ra.performance().map_err(|error| Error::Invalid(format!("The server console is not ready for account creation. No create command was sent. {error}")))?;
|
||||
let confirmed = ra.create_account(&name, password);
|
||||
if let Err(error) = confirmed {
|
||||
let stored = db.query(&format!(
|
||||
"SELECT HEX(salt), HEX(verifier) FROM acore_auth.account WHERE username='{name}';"
|
||||
))?;
|
||||
if !matches_credentials(&stored, &name, password) {
|
||||
return Err(Error::Invalid(format!("Account creation was not confirmed. Refresh the account list before retrying. {error}")));
|
||||
}
|
||||
if administrator {
|
||||
ra = Ra::connect(root).map_err(|error| Error::Invalid(format!("The account was created, but administrator access was not confirmed. Refresh the account list and check its access level. {error}")))?;
|
||||
}
|
||||
}
|
||||
if administrator {
|
||||
if let Err(error) = ra.make_administrator(&name) {
|
||||
let access = db.query(&format!("SELECT COUNT(*) FROM acore_auth.account_access WHERE id=(SELECT id FROM acore_auth.account WHERE username='{name}') AND gmlevel=3 AND RealmID=-1;"))?;
|
||||
if access.trim() != "1" {
|
||||
return Err(Error::Invalid(format!("The account was created, but administrator access was not confirmed. Refresh the account list and check its access level. {error}")));
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn matches_credentials(stored: &str, name: &str, password: &str) -> bool {
|
||||
let Some((salt, verifier)) = stored.trim().split_once('\t') else {
|
||||
return false;
|
||||
};
|
||||
let Ok(salt) = hex::decode(salt) else {
|
||||
return false;
|
||||
};
|
||||
let Ok(salt): std::result::Result<[u8; 32], _> = salt.try_into() else {
|
||||
return false;
|
||||
};
|
||||
let Ok(verifier) = hex::decode(verifier) else {
|
||||
return false;
|
||||
};
|
||||
verifier.as_slice() == crate::srp6::verifier(name, password, &salt)
|
||||
}
|
||||
|
||||
/// Give the account a new name. Needs the world console (the new password is what makes the login work again) and an
|
||||
/// account that is not logged in. The old name is put back if anything goes wrong.
|
||||
pub fn rename(root: &Path, ra: &mut Ra, old: &str, new: &str, password: &str) -> Result<()> {
|
||||
@@ -165,6 +219,19 @@ pub fn delete(root: &Path, ra: &mut Ra, name: &str) -> Result<()> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn lost_reply_requires_the_exact_requested_credentials() {
|
||||
let salt = [42; 32];
|
||||
let verifier = crate::srp6::verifier("NewPlayer", "Password77", &salt);
|
||||
let stored = format!("{}\t{}\n", hex::encode(salt), hex::encode(verifier));
|
||||
assert!(matches_credentials(&stored, "NEWPLAYER", "password77"));
|
||||
assert!(!matches_credentials(&stored, "NEWPLAYER", "wrongpass"));
|
||||
assert!(!matches_credentials(&stored, "OTHERPLAYER", "Password77"));
|
||||
for value in ["", "NULL\tNULL", "00\t00", "malformed"] {
|
||||
assert!(!matches_credentials(value, "NewPlayer", "Password77"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rows_from_the_client_become_accounts() {
|
||||
let out = "2\tALICE\t3\t0\t2026-09-30 21:04:11\t4\n5\tBOB\t0\t1\t\t0\n7\tBROKEN\n";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Every setting of the world server's configuration, for people who want more than the curated list: the documented
|
||||
//! settings come from `worldserver.conf.dist` (the file that ships with the server and explains each one), the current
|
||||
//! settings come from `worldserver.conf.dist` and `modules/coa.conf.dist`, the current
|
||||
//! values from the configuration the next start will use. Anything that holds a password, a port, an address, a folder or
|
||||
//! the database connection is left out; the Manager owns those.
|
||||
|
||||
@@ -10,7 +10,7 @@ use std::path::Path;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::parser::ConfFile;
|
||||
use crate::config::{take_snapshot, targets, Scope};
|
||||
use crate::config::{take_snapshot, targets, Scope, Targets};
|
||||
use crate::error::{Error, Result};
|
||||
use crate::fsx;
|
||||
|
||||
@@ -39,6 +39,14 @@ fn hidden(key: &str) -> bool {
|
||||
|| k.starts_with("logindatabase.")
|
||||
|| k.starts_with("worlddatabase.")
|
||||
|| k.starts_with("characterdatabase.")
|
||||
|| [
|
||||
"coa.classmodel",
|
||||
"coa.realmtype",
|
||||
"coa.gamemodemask",
|
||||
"coa.mapclass10towarrior",
|
||||
"coa.clientbooleanconfigs",
|
||||
]
|
||||
.contains(&k.as_str())
|
||||
|| [
|
||||
"bindip",
|
||||
"realmid",
|
||||
@@ -121,52 +129,85 @@ fn dist_path(root: &Path) -> std::path::PathBuf {
|
||||
root.join("Core/configs/worldserver.conf.dist")
|
||||
}
|
||||
|
||||
fn sources(root: &Path) -> Result<Vec<(std::path::PathBuf, Targets)>> {
|
||||
let mut result = vec![(dist_path(root), targets(root, Scope::Server)?)];
|
||||
let dist = root.join("Core/configs/modules/coa.conf.dist");
|
||||
if dist.is_file() {
|
||||
let active = root.join("Core/configs/modules/coa.conf");
|
||||
result.push((
|
||||
dist,
|
||||
Targets {
|
||||
read: active.clone(),
|
||||
writes: vec![active],
|
||||
generated: None,
|
||||
},
|
||||
));
|
||||
}
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
pub fn list(root: &Path) -> Result<Vec<Item>> {
|
||||
let dist = fs::read_to_string(dist_path(root)).map_err(|_| {
|
||||
Error::Invalid(
|
||||
"The documented settings file (worldserver.conf.dist) was not found on this server."
|
||||
.into(),
|
||||
)
|
||||
})?;
|
||||
let t = targets(root, Scope::Server)?;
|
||||
let active = ConfFile::parse_bytes(&fs::read(&t.read)?)?;
|
||||
Ok(parse_dist(&dist)
|
||||
.into_iter()
|
||||
.filter(|(k, _, _)| !hidden(k))
|
||||
.map(|(key, default, doc)| {
|
||||
let value = active
|
||||
.get(&key)
|
||||
.map(|v| v.trim().to_string())
|
||||
.unwrap_or_else(|| default.clone());
|
||||
let changed = value != default;
|
||||
Item {
|
||||
key,
|
||||
value,
|
||||
default,
|
||||
doc,
|
||||
changed,
|
||||
}
|
||||
})
|
||||
.collect())
|
||||
let mut items = Vec::new();
|
||||
for (dist_path, t) in sources(root)? {
|
||||
let dist = fs::read_to_string(&dist_path)?;
|
||||
let active = ConfFile::parse_bytes(&if t.read.exists() {
|
||||
fs::read(&t.read)?
|
||||
} else {
|
||||
dist.as_bytes().to_vec()
|
||||
})?;
|
||||
items.extend(
|
||||
parse_dist(&dist)
|
||||
.into_iter()
|
||||
.filter(|(k, _, _)| !hidden(k))
|
||||
.map(|(key, default, doc)| {
|
||||
let value = active
|
||||
.get(&key)
|
||||
.map(|v| v.trim().to_string())
|
||||
.unwrap_or_else(|| default.clone());
|
||||
let changed = value != default;
|
||||
Item {
|
||||
key,
|
||||
value,
|
||||
default,
|
||||
doc,
|
||||
changed,
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
);
|
||||
}
|
||||
Ok(items)
|
||||
}
|
||||
|
||||
/// Change settings that exist in the documented file. A value is one line of at most 500 characters. Returns the keys
|
||||
/// that actually changed; the previous files are snapshotted first (and can be restored from Settings).
|
||||
pub fn save(root: &Path, meta: &Path, changes: &BTreeMap<String, String>) -> Result<Vec<String>> {
|
||||
let known: BTreeMap<String, String> =
|
||||
parse_dist(&fs::read_to_string(dist_path(root)).map_err(|_| {
|
||||
Error::Invalid("worldserver.conf.dist was not found on this server.".into())
|
||||
})?)
|
||||
.into_iter()
|
||||
.map(|(k, d, _)| (k, d))
|
||||
.collect();
|
||||
let t = targets(root, Scope::Server)?;
|
||||
let _lock = crate::update::operation_lock(meta)?;
|
||||
crate::update::ensure_recovered(meta)?;
|
||||
let sources = sources(root)?;
|
||||
let mut known = BTreeMap::new();
|
||||
let mut originals: Vec<(std::path::PathBuf, Vec<u8>)> = Vec::new();
|
||||
let mut confs: Vec<ConfFile> = Vec::new();
|
||||
for p in &t.writes {
|
||||
let bytes = fs::read(p)?;
|
||||
confs.push(ConfFile::parse_bytes(&bytes)?);
|
||||
originals.push((p.clone(), bytes));
|
||||
let mut owners = Vec::new();
|
||||
for (index, (dist, t)) in sources.iter().enumerate() {
|
||||
let defaults = fs::read(dist)?;
|
||||
for (key, default, _) in parse_dist(&String::from_utf8_lossy(&defaults)) {
|
||||
if known.insert(key.clone(), (default, index)).is_some() {
|
||||
return Err(Error::Invalid(format!(
|
||||
"{key} is documented in more than one configuration file."
|
||||
)));
|
||||
}
|
||||
}
|
||||
for p in &t.writes {
|
||||
let bytes = if p.exists() {
|
||||
fs::read(p)?
|
||||
} else {
|
||||
defaults.clone()
|
||||
};
|
||||
confs.push(ConfFile::parse_bytes(&bytes)?);
|
||||
originals.push((p.clone(), bytes));
|
||||
owners.push(index);
|
||||
}
|
||||
}
|
||||
let mut changed = Vec::new();
|
||||
for (key, value) in changes {
|
||||
@@ -181,10 +222,22 @@ pub fn save(root: &Path, meta: &Path, changes: &BTreeMap<String, String>) -> Res
|
||||
"The value of {key} must be one line of text."
|
||||
)));
|
||||
}
|
||||
let same = confs.iter().all(|c| match c.get(key) {
|
||||
Some(v) => v.trim() == value,
|
||||
None => known[key] == value,
|
||||
});
|
||||
let (default, owner) = &known[key];
|
||||
if default.parse::<f64>().is_ok() && !value.parse::<f64>().is_ok_and(f64::is_finite)
|
||||
|| key == "CoA.LegacyMountFlight" && !matches!(value, "0" | "1")
|
||||
{
|
||||
return Err(Error::Invalid(format!(
|
||||
"The value of {key} must be a number matching its documented default."
|
||||
)));
|
||||
}
|
||||
let same = confs
|
||||
.iter()
|
||||
.zip(&owners)
|
||||
.filter(|(_, index)| *index == owner)
|
||||
.all(|(c, _)| match c.get(key) {
|
||||
Some(v) => v.trim() == value,
|
||||
None => default == value,
|
||||
});
|
||||
if !same {
|
||||
changed.push((key.clone(), value.to_string()));
|
||||
}
|
||||
@@ -192,20 +245,31 @@ pub fn save(root: &Path, meta: &Path, changes: &BTreeMap<String, String>) -> Res
|
||||
if changed.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
for c in &mut confs {
|
||||
for (c, owner) in confs.iter_mut().zip(&owners) {
|
||||
for (k, v) in &changed {
|
||||
c.set(k, v, &["Added by CoA Server Manager"]);
|
||||
if known[k].1 == *owner {
|
||||
c.set(k, v, &["Added by CoA Server Manager"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
let texts: Vec<String> = confs.iter().map(ConfFile::to_text).collect();
|
||||
for text in &texts {
|
||||
for (text, owner) in texts.iter().zip(&owners) {
|
||||
let reread = ConfFile::parse(text);
|
||||
for (k, v) in &changed {
|
||||
if reread.get(k).map(str::trim) != Some(v.as_str()) {
|
||||
if known[k].1 == *owner && reread.get(k).map(str::trim) != Some(v.as_str()) {
|
||||
return Err(Error::Invalid(format!("internal check failed for {k}")));
|
||||
}
|
||||
}
|
||||
}
|
||||
let affected: std::collections::BTreeSet<_> =
|
||||
changed.iter().map(|(key, _)| known[key].1).collect();
|
||||
let (originals, texts): (Vec<_>, Vec<_>) = originals
|
||||
.into_iter()
|
||||
.zip(texts)
|
||||
.zip(owners)
|
||||
.filter(|(_, owner)| affected.contains(owner))
|
||||
.map(|(pair, _)| pair)
|
||||
.unzip();
|
||||
take_snapshot(
|
||||
meta,
|
||||
Scope::Server,
|
||||
@@ -232,6 +296,114 @@ pub fn save(root: &Path, meta: &Path, changes: &BTreeMap<String, String>) -> Res
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn unrelated_saves_do_not_create_coa_files_and_existing_realm_values_are_preserved() {
|
||||
let d = tempfile::tempdir().unwrap();
|
||||
let (root, meta) = server(d.path());
|
||||
let module = root.join("Core/configs/modules");
|
||||
fs::create_dir_all(&module).unwrap();
|
||||
fs::write(
|
||||
module.join("coa.conf.dist"),
|
||||
"CoA.LegacyMountFlight = 0\nCoA.ClassModel = \"coa\"\n",
|
||||
)
|
||||
.unwrap();
|
||||
save(
|
||||
&root,
|
||||
&meta,
|
||||
&BTreeMap::from([("Rate.Drop.Item.Rare".into(), "1.5".into())]),
|
||||
)
|
||||
.unwrap();
|
||||
assert!(!module.join("coa.conf").exists());
|
||||
fs::write(
|
||||
module.join("coa.conf"),
|
||||
"# Reborn realm\nCoA.ClassModel = \"wcr\"\nCustom.Preserved = 42\n",
|
||||
)
|
||||
.unwrap();
|
||||
assert!(save(
|
||||
&root,
|
||||
&meta,
|
||||
&BTreeMap::from([("CoA.ClassModel".into(), "\"coa\"".into())])
|
||||
)
|
||||
.is_err());
|
||||
save(
|
||||
&root,
|
||||
&meta,
|
||||
&BTreeMap::from([("CoA.LegacyMountFlight".into(), "1".into())]),
|
||||
)
|
||||
.unwrap();
|
||||
let actual = fs::read_to_string(module.join("coa.conf")).unwrap();
|
||||
assert!(
|
||||
actual.contains("CoA.ClassModel = \"wcr\"") && actual.contains("Custom.Preserved = 42")
|
||||
);
|
||||
assert!(actual.contains("# Reborn realm"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn coa_settings_are_found_saved_to_the_module_and_snapshotted_without_profile_overrides() {
|
||||
let d = tempfile::tempdir().unwrap();
|
||||
let (root, meta) = server(d.path());
|
||||
let module = root.join("Core/configs/modules");
|
||||
fs::create_dir_all(&module).unwrap();
|
||||
let defaults = "[worldserver]\n# Mount flight rules\nCoA.LegacyMountFlight = 0\nCoA.ClassModel = \"coa\"\nCoA.RealmType = \"live\"\n";
|
||||
fs::write(module.join("coa.conf.dist"), defaults).unwrap();
|
||||
let original_world = fs::read(root.join("Core/configs/worldserver.conf")).unwrap();
|
||||
let items = list(&root).unwrap();
|
||||
assert!(items
|
||||
.iter()
|
||||
.any(|i| i.key == "CoA.LegacyMountFlight" && i.value == "0"));
|
||||
assert!(!items
|
||||
.iter()
|
||||
.any(|i| i.key == "CoA.ClassModel" || i.key == "CoA.RealmType"));
|
||||
for value in ["2", "invalid", "1\nInjected = 1"] {
|
||||
assert!(save(
|
||||
&root,
|
||||
&meta,
|
||||
&BTreeMap::from([("CoA.LegacyMountFlight".into(), value.into())])
|
||||
)
|
||||
.is_err());
|
||||
}
|
||||
assert!(!module.join("coa.conf").exists());
|
||||
save(
|
||||
&root,
|
||||
&meta,
|
||||
&BTreeMap::from([
|
||||
("CoA.LegacyMountFlight".into(), "1".into()),
|
||||
("Rate.Drop.Item.Rare".into(), "1.5".into()),
|
||||
]),
|
||||
)
|
||||
.unwrap();
|
||||
assert!(fs::read_to_string(module.join("coa.conf"))
|
||||
.unwrap()
|
||||
.contains("CoA.LegacyMountFlight = 1"));
|
||||
let world = fs::read_to_string(root.join("Core/configs/worldserver.conf")).unwrap();
|
||||
assert!(!world.contains("CoA.LegacyMountFlight"));
|
||||
assert!(world.contains("Rate.Drop.Item.Rare = 1.5"));
|
||||
assert!(!String::from_utf8(original_world)
|
||||
.unwrap()
|
||||
.contains("CoA.LegacyMountFlight"));
|
||||
assert_eq!(
|
||||
list(&root)
|
||||
.unwrap()
|
||||
.iter()
|
||||
.find(|i| i.key == "CoA.LegacyMountFlight")
|
||||
.unwrap()
|
||||
.value,
|
||||
"1"
|
||||
);
|
||||
assert!(!crate::config::list_snapshots(&meta).is_empty());
|
||||
let saved = crate::config::list_snapshots(&meta).remove(0);
|
||||
crate::config::restore_snapshot(&meta, &saved.id).unwrap();
|
||||
assert_eq!(
|
||||
list(&root)
|
||||
.unwrap()
|
||||
.iter()
|
||||
.find(|i| i.key == "CoA.LegacyMountFlight")
|
||||
.unwrap()
|
||||
.value,
|
||||
"0"
|
||||
);
|
||||
}
|
||||
|
||||
const DIST: &str = "[worldserver]\r\n\r\n###################\r\n# SECTION\r\n###################\r\n\r\n#\r\n# Rate.Drop.Item.Epic\r\n# Rate.Drop.Item.Rare\r\n# Description: Drop rates by quality.\r\n# Default: 1\r\n#\r\n\r\nRate.Drop.Item.Rare = 1\r\nRate.Drop.Item.Epic = 1\r\n\r\n#\r\n# LoginDatabaseInfo\r\n# Description: secret\r\n#\r\n\r\nLoginDatabaseInfo = \"127.0.0.1;3306;a;b;c\"\r\n\r\n#\r\n# Instance.ResetTimeHour\r\n# Description: Hour of the reset.\r\n# Important: Use 0-23.\r\n# Default: 4\r\n#\r\n\r\nInstance.ResetTimeHour = 4\r\n";
|
||||
|
||||
fn server(d: &Path) -> (std::path::PathBuf, std::path::PathBuf) {
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
//! Update-only comparison of existing unsupported character starts. Never repairs or deletes rows.
|
||||
use crate::{db::Db, Error, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
|
||||
pub struct MissingStart {
|
||||
pub guid: u32,
|
||||
pub race: u32,
|
||||
pub class: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Baseline {
|
||||
pub schema: u32,
|
||||
pub realms: BTreeMap<String, BTreeSet<MissingStart>>,
|
||||
}
|
||||
|
||||
pub fn parse_missing(text: &str) -> Result<BTreeSet<MissingStart>> {
|
||||
text.lines()
|
||||
.map(|line| {
|
||||
let values = line
|
||||
.split('\t')
|
||||
.map(str::parse::<u32>)
|
||||
.collect::<std::result::Result<Vec<_>, _>>()
|
||||
.map_err(|_| {
|
||||
Error::Invalid("Cannot read existing character start identities.".into())
|
||||
})?;
|
||||
if values.len() != 3 {
|
||||
return Err(Error::Invalid(
|
||||
"Incomplete character start identity.".into(),
|
||||
));
|
||||
}
|
||||
Ok(MissingStart {
|
||||
guid: values[0],
|
||||
race: values[1],
|
||||
class: values[2],
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn missing(db: &Db) -> Result<BTreeSet<MissingStart>> {
|
||||
parse_missing(&db.query("SELECT c.guid,c.race,c.class FROM acore_characters.characters c LEFT JOIN acore_world.playercreateinfo p ON p.race=c.race AND p.class=c.class WHERE p.race IS NULL;")?)
|
||||
}
|
||||
|
||||
pub fn capture(db: &Db, root: &Path) -> Result<Baseline> {
|
||||
let mut realms = BTreeMap::new();
|
||||
for mode in crate::realms::state(root)?.modes() {
|
||||
realms.insert(
|
||||
mode.name().to_owned(),
|
||||
missing(&db.clone().for_realm(mode))?,
|
||||
);
|
||||
}
|
||||
Ok(Baseline { schema: 1, realms })
|
||||
}
|
||||
|
||||
/// Match identity and race/class, never just totals: one new failure cannot replace an old one.
|
||||
pub fn introduced(
|
||||
current: &BTreeSet<MissingStart>,
|
||||
before: &BTreeSet<MissingStart>,
|
||||
) -> BTreeSet<MissingStart> {
|
||||
current.difference(before).copied().collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn old_gaps_are_not_new_character_loss() {
|
||||
let before = parse_missing("1\t44\t14\n2\t44\t14\n3\t44\t14").unwrap();
|
||||
assert!(introduced(&before, &before).is_empty());
|
||||
assert!(introduced(&BTreeSet::new(), &before).is_empty());
|
||||
let replaced = parse_missing("1\t44\t14\n2\t44\t14\n4\t44\t14").unwrap();
|
||||
assert_eq!(
|
||||
introduced(&replaced, &before),
|
||||
parse_missing("4\t44\t14").unwrap()
|
||||
);
|
||||
let changed = parse_missing("1\t44\t15").unwrap();
|
||||
assert_eq!(introduced(&changed, &before), changed);
|
||||
assert_eq!(introduced(&before, &BTreeSet::new()), before);
|
||||
}
|
||||
#[test]
|
||||
fn malformed_identity_is_not_silently_ignored() {
|
||||
for text in ["1\t44", "bad\t44\t14", "1\t44\t14\t0", "1\t44\t-1"] {
|
||||
assert!(parse_missing(text).is_err());
|
||||
}
|
||||
assert!(parse_missing("").unwrap().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reported_174_old_records_cannot_mask_one_newly_hidden_character() {
|
||||
// Reproduce the report's scale without shipping another person's diagnostics or identities.
|
||||
let before: BTreeSet<_> = (1..=174)
|
||||
.map(|guid| MissingStart {
|
||||
guid,
|
||||
race: 44,
|
||||
class: 14,
|
||||
})
|
||||
.collect();
|
||||
assert!(introduced(&before, &before).is_empty());
|
||||
let mut after = before.clone();
|
||||
after.remove(&MissingStart {
|
||||
guid: 1,
|
||||
race: 44,
|
||||
class: 14,
|
||||
});
|
||||
after.insert(MissingStart {
|
||||
guid: 175,
|
||||
race: 44,
|
||||
class: 14,
|
||||
});
|
||||
assert_eq!(after.len(), before.len());
|
||||
assert_eq!(
|
||||
introduced(&after, &before),
|
||||
BTreeSet::from([MissingStart {
|
||||
guid: 175,
|
||||
race: 44,
|
||||
class: 14
|
||||
}])
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
use crate::{fsx, Error, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{fs, path::Path};
|
||||
|
||||
#[derive(Default, Serialize, Deserialize)]
|
||||
pub struct Graphics {
|
||||
pub dxvk_disabled: bool,
|
||||
pub enhancements_disabled: bool,
|
||||
}
|
||||
|
||||
fn preferences(client: &Path) -> Result<Option<Graphics>> {
|
||||
match fs::read(client.join(".coa-manager/graphics.json")) {
|
||||
Ok(bytes) => Ok(Some(serde_json::from_slice(&bytes)?)),
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(None),
|
||||
Err(e) => Err(e.into()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn status(client: &Path) -> Result<Graphics> {
|
||||
let saved = preferences(client)?.unwrap_or_default();
|
||||
let actual = |name: &str, remembered: bool| -> Result<bool> {
|
||||
let active = client.join(name).is_file();
|
||||
let inactive = client.join(format!("{name}.DISABLED")).is_file();
|
||||
if active && inactive {
|
||||
return Err(Error::Invalid(
|
||||
"Both enabled and disabled renderer files exist.".into(),
|
||||
));
|
||||
}
|
||||
Ok(inactive || (!active && remembered))
|
||||
};
|
||||
Ok(Graphics {
|
||||
dxvk_disabled: actual("d3d9.dll", saved.dxvk_disabled)?,
|
||||
enhancements_disabled: actual("dxgi.dll", saved.enhancements_disabled)?,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn disabled(client: &Path, path: &str) -> Result<bool> {
|
||||
let name = path.to_ascii_lowercase();
|
||||
if !matches!(name.as_str(), "d3d9.dll" | "dxgi.dll") {
|
||||
return Ok(false);
|
||||
}
|
||||
let state = status(client)?;
|
||||
Ok(if name == "d3d9.dll" {
|
||||
state.dxvk_disabled
|
||||
} else {
|
||||
state.enhancements_disabled
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set(client: &Path, name: &str, disabled: bool) -> Result<Graphics> {
|
||||
if !matches!(name, "d3d9.dll" | "dxgi.dll") {
|
||||
return Err(Error::Invalid("Unknown graphics setting.".into()));
|
||||
}
|
||||
if crate::client::is_running(client) {
|
||||
return Err(Error::Invalid(
|
||||
"Close the game before changing graphics settings.".into(),
|
||||
));
|
||||
}
|
||||
let active = fsx::safe_join(client, name)?;
|
||||
let inactive = fsx::safe_join(client, &format!("{name}.DISABLED"))?;
|
||||
if active.exists() && inactive.exists() {
|
||||
return Err(Error::Invalid("Both enabled and disabled renderer files exist. Resolve the conflict before changing graphics settings.".into()));
|
||||
}
|
||||
let mut state = status(client)?;
|
||||
if name == "d3d9.dll" {
|
||||
state.dxvk_disabled = disabled;
|
||||
} else {
|
||||
state.enhancements_disabled = disabled;
|
||||
}
|
||||
let (source, target) = if disabled {
|
||||
(&active, &inactive)
|
||||
} else {
|
||||
(&inactive, &active)
|
||||
};
|
||||
// The no-clobber link also preserves an existing destination if another app changes the setting.
|
||||
if source.is_file() {
|
||||
if let Err(error) = fs::hard_link(source, target) {
|
||||
if error.kind() == std::io::ErrorKind::AlreadyExists {
|
||||
return Err(error.into());
|
||||
}
|
||||
let mut output = fs::OpenOptions::new()
|
||||
.write(true)
|
||||
.create_new(true)
|
||||
.open(target)?;
|
||||
let copied = std::fs::File::open(source)
|
||||
.and_then(|mut input| std::io::copy(&mut input, &mut output))
|
||||
.and_then(|_| output.sync_all());
|
||||
drop(output);
|
||||
if let Err(error) = copied {
|
||||
let _ = fs::remove_file(target);
|
||||
return Err(error.into());
|
||||
}
|
||||
}
|
||||
if let Err(error) = fs::remove_file(source) {
|
||||
let _ = fs::remove_file(target);
|
||||
return Err(error.into());
|
||||
}
|
||||
}
|
||||
fsx::atomic_write_json(&client.join(".coa-manager/graphics.json"), &state)?;
|
||||
Ok(state)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn toggles_preserve_bytes_and_refuse_conflicts() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
fs::write(root.join("d3d9.dll"), b"custom renderer").unwrap();
|
||||
assert!(set(root, "d3d9.dll", true).unwrap().dxvk_disabled);
|
||||
assert!(!root.join("d3d9.dll").exists());
|
||||
assert_eq!(
|
||||
fs::read(root.join("d3d9.dll.DISABLED")).unwrap(),
|
||||
b"custom renderer"
|
||||
);
|
||||
assert!(!set(root, "d3d9.dll", false).unwrap().dxvk_disabled);
|
||||
fs::write(root.join("d3d9.dll.DISABLED"), b"other").unwrap();
|
||||
assert!(set(root, "d3d9.dll", false).is_err());
|
||||
assert_eq!(fs::read(root.join("d3d9.dll")).unwrap(), b"custom renderer");
|
||||
assert_eq!(fs::read(root.join("d3d9.dll.DISABLED")).unwrap(), b"other");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remembers_missing_wrapper_and_imports_launcher_marker() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
assert!(set(root, "d3d9.dll", true).unwrap().dxvk_disabled);
|
||||
assert!(disabled(root, "d3d9.dll").unwrap());
|
||||
fs::write(root.join("dxgi.dll.DISABLED"), b"launcher disabled").unwrap();
|
||||
assert!(disabled(root, "dxgi.dll").unwrap());
|
||||
assert!(!disabled(root, "Data/d3d9.dll").unwrap());
|
||||
}
|
||||
}
|
||||
@@ -299,6 +299,11 @@ pub fn plan(
|
||||
bytes_per_sec: 0,
|
||||
file: Some(f.path.clone()),
|
||||
});
|
||||
if crate::client_graphics::disabled(client, &f.path)? {
|
||||
kept += 1;
|
||||
done += f.size;
|
||||
continue;
|
||||
}
|
||||
let path = fsx::safe_join(client, &f.path)?;
|
||||
let meta = match fs::metadata(&path) {
|
||||
Ok(meta) if meta.is_file() => meta,
|
||||
@@ -440,6 +445,9 @@ pub fn apply(a: &Apply, on_step: &dyn Fn(Step)) -> Result<()> {
|
||||
|
||||
let mut todo = Vec::new();
|
||||
for item in &a.plan.items {
|
||||
if crate::client_graphics::disabled(a.client, &item.path)? {
|
||||
continue;
|
||||
}
|
||||
if item.kind == Kind::Modified && a.keep_modified {
|
||||
let path = fsx::safe_join(a.client, &item.path)?;
|
||||
let meta = fs::metadata(&path)?;
|
||||
@@ -777,6 +785,52 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn disabled_launcher_renderers_are_never_restored_even_with_a_stale_plan() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let files: Vec<(&str, &[u8])> = vec![("d3d9.dll", b"dxvk"), ("dxgi.dll", b"enhancements")];
|
||||
let manifest = manifest("v1", &files);
|
||||
let cancel = Cancel::default();
|
||||
let old_plan = plan(dir.path(), &manifest, &State::default(), &cancel, &|_| {}).unwrap();
|
||||
fs::write(dir.path().join("d3d9.dll.DISABLED"), b"custom disabled").unwrap();
|
||||
crate::client_graphics::set(dir.path(), "dxgi.dll", true).unwrap();
|
||||
let server = Server::new(&files);
|
||||
apply(
|
||||
&Apply {
|
||||
client: dir.path(),
|
||||
manifest: &manifest,
|
||||
plan: &old_plan,
|
||||
keep_modified: false,
|
||||
transport: &server,
|
||||
objects_url: "https://x.invalid/objects",
|
||||
cancel: &cancel,
|
||||
},
|
||||
&|_| {},
|
||||
)
|
||||
.unwrap();
|
||||
assert!(server.requested.lock().unwrap().is_empty());
|
||||
assert!(!dir.path().join("d3d9.dll").exists());
|
||||
assert!(!dir.path().join("dxgi.dll").exists());
|
||||
assert_eq!(
|
||||
fs::read(dir.path().join("d3d9.dll.DISABLED")).unwrap(),
|
||||
b"custom disabled"
|
||||
);
|
||||
let after = plan(
|
||||
dir.path(),
|
||||
&manifest,
|
||||
&load_state(dir.path()).unwrap(),
|
||||
&cancel,
|
||||
&|_| {},
|
||||
)
|
||||
.unwrap();
|
||||
assert!(after.items.is_empty());
|
||||
crate::client_graphics::set(dir.path(), "d3d9.dll", false).unwrap();
|
||||
assert_eq!(
|
||||
fs::read(dir.path().join("d3d9.dll")).unwrap(),
|
||||
b"custom disabled"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn renderer_files_configs_and_everything_not_in_the_manifest_survive_an_update_untouched() {
|
||||
let d = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -1034,6 +1034,31 @@ Spellbook.New = 5
|
||||
assert!(v.drift_keys.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn skill_controls_persist_and_reject_invalid_gains() {
|
||||
let (_d, root, meta) = fixture();
|
||||
let changes = BTreeMap::from([
|
||||
("SkillChance.Prospecting".into(), json!(true)),
|
||||
("SkillChance.Milling".into(), json!(true)),
|
||||
("SkillGain.Crafting".into(), json!(3)),
|
||||
("SkillGain.Defense".into(), json!(4)),
|
||||
("SkillGain.Gathering".into(), json!(5)),
|
||||
]);
|
||||
let report = save(&root, &meta, Scope::Server, &changes).unwrap();
|
||||
assert_eq!(report.changed.len(), 5);
|
||||
assert_eq!(report.restart, Some(Restart::World));
|
||||
for path in ["Settings/worldserver.conf.template", "Core/configs/worldserver.conf"] {
|
||||
let conf = load_conf(&root.join(path)).unwrap();
|
||||
for (key, expected) in [("SkillChance.Prospecting", "1"), ("SkillChance.Milling", "1"), ("SkillGain.Crafting", "3"), ("SkillGain.Defense", "4"), ("SkillGain.Gathering", "5")] {
|
||||
assert_eq!(conf.get(key), Some(expected));
|
||||
}
|
||||
assert_eq!(conf.get("Unknown.Custom"), Some("\"keep me\""));
|
||||
}
|
||||
for value in [json!(-1), json!(1.5), json!(451)] {
|
||||
assert!(save(&root, &meta, Scope::Server, &BTreeMap::from([("SkillGain.Crafting".into(), value)])).is_err());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn creature_rates_save_independently_in_template_and_active_config() {
|
||||
let (_d, root, meta) = fixture();
|
||||
|
||||
@@ -214,11 +214,13 @@ fn run(
|
||||
struct StreamWorker {
|
||||
tx: Sender<TunnelMsg>,
|
||||
reset_on_drop: bool,
|
||||
shutdown: Arc<TcpStream>,
|
||||
}
|
||||
|
||||
impl Drop for StreamWorker {
|
||||
fn drop(&mut self) {
|
||||
if self.reset_on_drop {
|
||||
let _ = self.shutdown.shutdown(std::net::Shutdown::Both);
|
||||
let _ = self.tx.send(TunnelMsg::Reset { stream_id: 0 });
|
||||
}
|
||||
}
|
||||
@@ -388,6 +390,8 @@ fn session(
|
||||
};
|
||||
match TcpStream::connect(("127.0.0.1", local_port)) {
|
||||
Ok(tcp) => {
|
||||
let tcp = Arc::new(tcp);
|
||||
let shutdown = tcp.clone();
|
||||
let (stream_tx, stream_rx) = channel::<TunnelMsg>();
|
||||
let ws_tx = ws_out_tx.clone();
|
||||
|
||||
@@ -398,6 +402,7 @@ fn session(
|
||||
StreamWorker {
|
||||
tx: stream_tx,
|
||||
reset_on_drop: true,
|
||||
shutdown,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -456,19 +461,20 @@ fn session(
|
||||
|
||||
fn spawn_local_tcp_bridge(
|
||||
stream_id: u32,
|
||||
mut tcp: TcpStream,
|
||||
tcp: Arc<TcpStream>,
|
||||
from_tunnel: Receiver<TunnelMsg>,
|
||||
to_tunnel: Sender<TunnelMsg>,
|
||||
) {
|
||||
let _ = tcp.set_nonblocking(false);
|
||||
let _ = tcp.set_nodelay(true);
|
||||
let mut tcp_read = tcp.try_clone().expect("tcp clone");
|
||||
let tcp_read = tcp.clone();
|
||||
let to_tunnel_read = to_tunnel.clone();
|
||||
|
||||
// Local TCP read -> to tunnel
|
||||
std::thread::Builder::new()
|
||||
.name(format!("relay-stream-{stream_id}-read"))
|
||||
.spawn(move || {
|
||||
let mut tcp_read = tcp_read.as_ref();
|
||||
let mut buf = [0u8; 16384];
|
||||
loop {
|
||||
match tcp_read.read(&mut buf) {
|
||||
@@ -498,11 +504,12 @@ fn spawn_local_tcp_bridge(
|
||||
std::thread::Builder::new()
|
||||
.name(format!("relay-stream-{stream_id}-write"))
|
||||
.spawn(move || {
|
||||
let mut tcp_write = tcp.as_ref();
|
||||
while let Ok(msg) = from_tunnel.recv() {
|
||||
match msg {
|
||||
TunnelMsg::Data { chunk, .. } => {
|
||||
if let Ok(data) = base64::engine::general_purpose::STANDARD.decode(&chunk) {
|
||||
if tcp.write_all(&data).is_err() {
|
||||
if tcp_write.write_all(&data).is_err() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -608,22 +615,71 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dropping_a_tunnel_closes_its_local_tcp_stream() {
|
||||
fn local_tunnel_exchanges_data_in_both_directions_before_reset() {
|
||||
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||
let tcp = TcpStream::connect(listener.local_addr().unwrap()).unwrap();
|
||||
let tcp = Arc::new(TcpStream::connect(listener.local_addr().unwrap()).unwrap());
|
||||
let shutdown = tcp.clone();
|
||||
let (mut peer, _) = listener.accept().unwrap();
|
||||
peer.set_read_timeout(Some(Duration::from_secs(3))).unwrap();
|
||||
let (tx, rx) = channel();
|
||||
let (out, _) = channel();
|
||||
spawn_local_tcp_bridge(7, tcp, rx, out);
|
||||
drop(StreamWorker {
|
||||
let (out, replies) = channel();
|
||||
spawn_local_tcp_bridge(8, tcp, rx, out);
|
||||
let worker = StreamWorker {
|
||||
tx,
|
||||
reset_on_drop: true,
|
||||
});
|
||||
match peer.read(&mut [0u8; 1]) {
|
||||
Ok(0) => {},
|
||||
Err(error) if matches!(error.kind(), std::io::ErrorKind::ConnectionReset | std::io::ErrorKind::ConnectionAborted) => {},
|
||||
other => panic!("The abandoned relay stream must close, got {other:?}"),
|
||||
shutdown,
|
||||
};
|
||||
worker
|
||||
.tx
|
||||
.send(TunnelMsg::Data {
|
||||
stream_id: 8,
|
||||
chunk: base64::engine::general_purpose::STANDARD.encode(b"request"),
|
||||
})
|
||||
.unwrap();
|
||||
let mut request = [0; 7];
|
||||
peer.read_exact(&mut request).unwrap();
|
||||
assert_eq!(&request, b"request");
|
||||
peer.write_all(b"response").unwrap();
|
||||
let mut response = Vec::new();
|
||||
while response.len() < 8 {
|
||||
match replies.recv_timeout(Duration::from_secs(3)).unwrap() {
|
||||
TunnelMsg::Data { chunk, .. } => response.extend(
|
||||
base64::engine::general_purpose::STANDARD
|
||||
.decode(chunk)
|
||||
.unwrap(),
|
||||
),
|
||||
other => panic!("Expected the local reply, got {other:?}"),
|
||||
}
|
||||
}
|
||||
assert_eq!(response, b"response");
|
||||
drop(worker);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dropping_a_tunnel_closes_its_local_tcp_stream() {
|
||||
for _ in 0..32 {
|
||||
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||
let tcp = Arc::new(TcpStream::connect(listener.local_addr().unwrap()).unwrap());
|
||||
let shutdown = tcp.clone();
|
||||
let (mut peer, _) = listener.accept().unwrap();
|
||||
peer.set_read_timeout(Some(Duration::from_secs(3))).unwrap();
|
||||
let (tx, rx) = channel();
|
||||
let (out, _) = channel();
|
||||
spawn_local_tcp_bridge(7, tcp, rx, out);
|
||||
drop(StreamWorker {
|
||||
tx,
|
||||
reset_on_drop: true,
|
||||
shutdown,
|
||||
});
|
||||
match peer.read(&mut [0u8; 1]) {
|
||||
Ok(0) => {}
|
||||
Err(error)
|
||||
if matches!(
|
||||
error.kind(),
|
||||
std::io::ErrorKind::ConnectionReset | std::io::ErrorKind::ConnectionAborted
|
||||
) => {}
|
||||
other => panic!("The abandoned relay stream must close, got {other:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,17 +24,25 @@ pub struct CrashItem {
|
||||
|
||||
/// Lists recent crash reports from `Core/Crashes`, sorted newest first.
|
||||
pub fn list(root: &Path, limit: usize) -> Result<Vec<CrashItem>> {
|
||||
let dir = root.join("Core/Crashes");
|
||||
let mut roots = vec![root.to_path_buf()];
|
||||
roots.extend(crate::multiworld::Tree::ALL.map(|tree| crate::multiworld::tree_root(root, tree)));
|
||||
let mut files: Vec<(PathBuf, SystemTime)> = Vec::new();
|
||||
if let Ok(entries) = fs::read_dir(&dir) {
|
||||
for entry in entries.flatten() {
|
||||
let path = entry.path();
|
||||
if path.is_file() && path.extension().and_then(|e| e.to_str()) == Some("txt") {
|
||||
let mtime = entry
|
||||
.metadata()
|
||||
.and_then(|m| m.modified())
|
||||
.unwrap_or(SystemTime::UNIX_EPOCH);
|
||||
files.push((path, mtime));
|
||||
for world_root in roots {
|
||||
let entries = match fs::read_dir(world_root.join("Core/Crashes")) {
|
||||
Ok(entries) => Some(entries),
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => None,
|
||||
Err(e) => return Err(e.into()),
|
||||
};
|
||||
if let Some(entries) = entries {
|
||||
for entry in entries.flatten() {
|
||||
let path = entry.path();
|
||||
if path.is_file() && path.extension().and_then(|e| e.to_str()) == Some("txt") {
|
||||
let mtime = entry
|
||||
.metadata()
|
||||
.and_then(|m| m.modified())
|
||||
.unwrap_or(SystemTime::UNIX_EPOCH);
|
||||
files.push((path, mtime));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,8 +51,12 @@ pub fn list(root: &Path, limit: usize) -> Result<Vec<CrashItem>> {
|
||||
|
||||
let mut items = Vec::new();
|
||||
for (path, mtime) in files {
|
||||
if let Ok(content) = fs::read_to_string(&path) {
|
||||
let item = parse_crash_content(&path, mtime, &content);
|
||||
if let Ok(bytes) = fs::read(&path) {
|
||||
let content = String::from_utf8_lossy(&bytes);
|
||||
let mut item = parse_crash_content(&path, mtime, &content);
|
||||
if let Ok(relative) = path.strip_prefix(root) {
|
||||
item.id = relative.to_string_lossy().replace('\\', "/");
|
||||
}
|
||||
items.push(item);
|
||||
}
|
||||
}
|
||||
@@ -237,6 +249,49 @@ fn explain(
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn discovers_native_ansi_reports_and_ignores_dump_files() {
|
||||
let root = tempfile::tempdir().unwrap();
|
||||
assert!(list(root.path(), 10).unwrap().is_empty());
|
||||
fs::create_dir_all(root.path().join("Core/Crashes")).unwrap();
|
||||
fs::write(
|
||||
root.path().join("Core/Crashes/report.txt"),
|
||||
b"Exception code: C0000005 \xff\r\n",
|
||||
)
|
||||
.unwrap();
|
||||
fs::write(root.path().join("Core/Crashes/report.dmp"), b"binary").unwrap();
|
||||
let reports = list(root.path(), 10).unwrap();
|
||||
assert_eq!(reports.len(), 1);
|
||||
assert_eq!(reports[0].exception_code.as_deref(), Some("C0000005"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn discovers_reports_from_all_worlds_without_filename_collisions() {
|
||||
let root = tempfile::tempdir().unwrap();
|
||||
for relative in [
|
||||
"Core/Crashes",
|
||||
".realms/secondary/Core/Crashes",
|
||||
".realms/reborn/Core/Crashes",
|
||||
] {
|
||||
fs::create_dir_all(root.path().join(relative)).unwrap();
|
||||
fs::write(
|
||||
root.path().join(relative).join("same.txt"),
|
||||
b"Exception code: C0000005",
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
let reports = list(root.path(), 10).unwrap();
|
||||
assert_eq!(reports.len(), 3);
|
||||
assert_eq!(
|
||||
reports
|
||||
.iter()
|
||||
.map(|r| &r.id)
|
||||
.collect::<std::collections::HashSet<_>>()
|
||||
.len(),
|
||||
3
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_assertion_report() {
|
||||
let report = r#"Revision: AzerothCore rev. df5bcdf26092 2026-10-02 22:08:42 +0500 (coa-bots branch) (Win64, RelWithDebInfo, Static)
|
||||
|
||||
+337
-124
@@ -5,7 +5,7 @@
|
||||
//! into the player's WoW client directory.
|
||||
|
||||
use std::fs::{self, File};
|
||||
use std::io::{self, Read, Write};
|
||||
use std::io::{self, Read};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -111,6 +111,13 @@ pub fn playerbots_conf_paths(root: &Path) -> Vec<PathBuf> {
|
||||
/// Checks whether playerbots are configured to allow custom races.
|
||||
/// Returns true if AiPlayerbot.ExcludedBotRaces exists and does not exclude general custom races.
|
||||
pub fn is_bot_custom_races_allowed(root: &Path) -> Option<bool> {
|
||||
if let Ok(bytes) = fs::read(root.join("Core/configs/modules/coa_custom_races.conf")) {
|
||||
if let Ok(conf) = crate::config::parser::ConfFile::parse_bytes(&bytes) {
|
||||
if let Some(value) = conf.get("CoACustomRaces.BotsEnable") {
|
||||
return Some(matches!(value.trim().trim_matches('"'), "1" | "true"));
|
||||
}
|
||||
}
|
||||
}
|
||||
for path in playerbots_conf_paths(root) {
|
||||
if let Ok(bytes) = fs::read(&path) {
|
||||
if let Ok(conf) = crate::config::parser::ConfFile::parse_bytes(&bytes) {
|
||||
@@ -142,6 +149,18 @@ pub fn sync_bot_races_config(root: &Path, allow_custom_races: bool) -> Result<()
|
||||
for path in playerbots_conf_paths(root) {
|
||||
if let Ok(bytes) = fs::read(&path) {
|
||||
if let Ok(mut conf) = crate::config::parser::ConfFile::parse_bytes(&bytes) {
|
||||
if let Some(value) = conf.get("AiPlayerbot.ExcludedBotRaces") {
|
||||
let clean = value.trim().trim_matches(['"', '\'']);
|
||||
let owned = String::from_utf8_lossy(&bytes)
|
||||
.contains("CoA Custom: races new random bots never get")
|
||||
&& matches!(
|
||||
clean,
|
||||
EXCLUDED_BOT_RACES_RECOMMENDED | EXCLUDED_BOT_RACES_EXPERIMENTAL
|
||||
);
|
||||
if !owned {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
conf.set(
|
||||
"AiPlayerbot.ExcludedBotRaces",
|
||||
&format!("\"{excluded}\""),
|
||||
@@ -646,134 +665,147 @@ fn stage_root_asset(staging: &Path, relative: &str, reader: &mut impl Read) -> R
|
||||
Ok(relative.to_string())
|
||||
}
|
||||
|
||||
fn verify_archive(path: &Path, filename: &str) -> Result<()> {
|
||||
let expected = match filename {
|
||||
"CoA-Custom-1.9.2-Client-1.zip" => {
|
||||
"a9dd51ed2d90fb048d549602f40f5429d56e2df0df5606a38781b358fa369568"
|
||||
}
|
||||
"CoA-Custom-1.9.2-Client-2.zip" => {
|
||||
"ab084a55509ccbcc2977a06dd0c01fa879973a1892baaacaeb3ff52f3dfc750e"
|
||||
}
|
||||
"CoA-Custom-1.9.2-Client-3.zip" => {
|
||||
"907e267f0ee7038807e626c3c1eca5e12db6c88b747137a23c5fb52eaa1a358e"
|
||||
}
|
||||
"CoA-Custom-1.9.2-Client-4.zip" => {
|
||||
"e0bd87172af989fa50a8e2b08ba4321c72b6265047482f051a1db3b80d55bcaa"
|
||||
}
|
||||
"CoA-Custom-1.9.2-Client-5.zip" => {
|
||||
"73364ad1b58c6342641a848a3b20a835472834f600416606be1470386774ca78"
|
||||
}
|
||||
fn archive_job(filename: &str, url: &str, cache: &Path) -> Result<crate::download::Job> {
|
||||
let (size, sha256) = match filename {
|
||||
"CoA-Custom-1.9.2-Client-1.zip" => (
|
||||
1_513_021_586,
|
||||
"a9dd51ed2d90fb048d549602f40f5429d56e2df0df5606a38781b358fa369568",
|
||||
),
|
||||
"CoA-Custom-1.9.2-Client-2.zip" => (
|
||||
1_198_283_005,
|
||||
"ab084a55509ccbcc2977a06dd0c01fa879973a1892baaacaeb3ff52f3dfc750e",
|
||||
),
|
||||
"CoA-Custom-1.9.2-Client-3.zip" => (
|
||||
1_678_829_573,
|
||||
"907e267f0ee7038807e626c3c1eca5e12db6c88b747137a23c5fb52eaa1a358e",
|
||||
),
|
||||
"CoA-Custom-1.9.2-Client-4.zip" => (
|
||||
502_385_128,
|
||||
"e0bd87172af989fa50a8e2b08ba4321c72b6265047482f051a1db3b80d55bcaa",
|
||||
),
|
||||
"CoA-Custom-1.9.2-Client-5.zip" => (
|
||||
168_079_711,
|
||||
"73364ad1b58c6342641a848a3b20a835472834f600416606be1470386774ca78",
|
||||
),
|
||||
_ => return Err(Error::Invalid("Unknown custom races archive.".into())),
|
||||
};
|
||||
if fsx::sha256_file(path)? != expected {
|
||||
Ok(crate::download::Job {
|
||||
url: url.into(),
|
||||
dest: cache.join(filename),
|
||||
sha256: sha256.into(),
|
||||
size,
|
||||
})
|
||||
}
|
||||
|
||||
fn archive_matches(path: &Path, job: &crate::download::Job) -> bool {
|
||||
path.metadata()
|
||||
.is_ok_and(|m| m.is_file() && m.len() == job.size)
|
||||
&& fsx::sha256_file(path).is_ok_and(|hash| hash.eq_ignore_ascii_case(&job.sha256))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn verify_archive(path: &Path, filename: &str) -> Result<()> {
|
||||
let job = archive_job(filename, "", Path::new(""))?;
|
||||
if !archive_matches(path, &job) {
|
||||
return Err(Error::Invalid(format!(
|
||||
"Custom races archive {filename} failed verification. Remove it and try again."
|
||||
"Custom races archive {filename} failed verification."
|
||||
)));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Locate an archive locally in Downloads or cache, or download it from GitHub.
|
||||
/// User-owned Downloads files are read-only candidates. Only the Manager's cache is repaired.
|
||||
fn resolve_archive_with(
|
||||
transport: &dyn crate::download::Transport,
|
||||
job: &crate::download::Job,
|
||||
downloads: Option<&Path>,
|
||||
cancel: &Cancel,
|
||||
progress: &dyn Fn(crate::download::Progress),
|
||||
) -> Result<PathBuf> {
|
||||
if cancel.is_set() {
|
||||
return Err(Error::Invalid("Download cancelled.".into()));
|
||||
}
|
||||
if let Some(downloads) = downloads {
|
||||
let candidate = downloads.join(job.dest.file_name().unwrap_or_default());
|
||||
if archive_matches(&candidate, job) {
|
||||
tracing::info!(path = %candidate.display(), "using verified archive in Downloads");
|
||||
progress(crate::download::Progress {
|
||||
downloaded: job.size,
|
||||
total: job.size,
|
||||
bytes_per_sec: 0,
|
||||
});
|
||||
return Ok(candidate);
|
||||
}
|
||||
if candidate.exists() {
|
||||
tracing::warn!(path = %candidate.display(), "ignoring incomplete or unverified archive in Downloads");
|
||||
}
|
||||
}
|
||||
|
||||
let cache = job
|
||||
.dest
|
||||
.parent()
|
||||
.ok_or_else(|| Error::Invalid("Missing archive cache directory.".into()))?;
|
||||
fs::create_dir_all(cache)?;
|
||||
// Different installations share this cache; never append to or replace another active download.
|
||||
use fs4::fs_std::FileExt;
|
||||
let lock = fs::OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create(true)
|
||||
.truncate(false)
|
||||
.open(suffix(&job.dest, "lock"))?;
|
||||
if !lock.try_lock_exclusive()? {
|
||||
return Err(Error::Invalid("Another custom races download is using this archive. Wait for it to finish, then retry.".into()));
|
||||
}
|
||||
if job.dest.is_file() {
|
||||
if archive_matches(&job.dest, job) {
|
||||
progress(crate::download::Progress {
|
||||
downloaded: job.size,
|
||||
total: job.size,
|
||||
bytes_per_sec: 0,
|
||||
});
|
||||
return Ok(job.dest.clone());
|
||||
}
|
||||
tracing::warn!(path = %job.dest.display(), "removing unverified Manager archive cache; downloading again");
|
||||
fs::remove_file(&job.dest)?;
|
||||
}
|
||||
// The shared downloader resumes .part files and verifies the complete archive before promotion.
|
||||
// A stale/corrupt prefix may only be detectable after resume: retry once from scratch in that case.
|
||||
match crate::download::fetch_with(transport, job, cancel, progress) {
|
||||
Err(Error::HashMismatch { .. }) if !cancel.is_set() => {
|
||||
tracing::warn!(path = %job.dest.display(), "archive verification failed; retrying a clean download");
|
||||
crate::download::fetch_with(transport, job, cancel, progress)?;
|
||||
}
|
||||
result => result?,
|
||||
}
|
||||
Ok(job.dest.clone())
|
||||
}
|
||||
|
||||
/// Locate a verified archive or resume downloading it into the Manager's cache.
|
||||
fn resolve_or_download_archive(
|
||||
filename: &str,
|
||||
url: &str,
|
||||
client: &reqwest::blocking::Client,
|
||||
transport: &dyn crate::download::Transport,
|
||||
cancel: &Cancel,
|
||||
report: &dyn Fn(&str, f32),
|
||||
base_percent: f32,
|
||||
percent_slice: f32,
|
||||
) -> Result<PathBuf> {
|
||||
// 1. Check user Downloads folder
|
||||
if let Some(userprofile) = std::env::var_os("USERPROFILE") {
|
||||
let downloads = PathBuf::from(userprofile).join("Downloads");
|
||||
let candidate = downloads.join(filename);
|
||||
if candidate.is_file() {
|
||||
if let Ok(meta) = candidate.metadata() {
|
||||
if meta.len() > 1000 {
|
||||
tracing::info!(path = %candidate.display(), "using existing archive in Downloads");
|
||||
verify_archive(&candidate, filename)?;
|
||||
return Ok(candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Check temp / cache directory
|
||||
let cache_dir = std::env::temp_dir().join("coa-client-races");
|
||||
fs::create_dir_all(&cache_dir)?;
|
||||
let target = cache_dir.join(filename);
|
||||
if target.is_file() {
|
||||
if let Ok(meta) = target.metadata() {
|
||||
if meta.len() > 1000 {
|
||||
verify_archive(&target, filename)?;
|
||||
return Ok(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Download from GitHub Releases
|
||||
report(&format!("Downloading {filename}..."), base_percent);
|
||||
let part_path = cache_dir.join(format!("{filename}.part"));
|
||||
|
||||
let resp = client
|
||||
.get(url)
|
||||
.send()
|
||||
.map_err(|e| Error::NetworkUnreachable(format!("Could not reach download server: {e}")))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(Error::NetworkUnreachable(format!(
|
||||
"Download failed with status {} for {url}",
|
||||
resp.status()
|
||||
)));
|
||||
}
|
||||
|
||||
let total_bytes = resp.content_length().unwrap_or(0);
|
||||
let mut downloaded = 0u64;
|
||||
let mut src = resp;
|
||||
let mut dst = File::create(&part_path)?;
|
||||
|
||||
let mut buf = [0u8; 64 * 1024];
|
||||
let mut last_report = std::time::Instant::now();
|
||||
|
||||
loop {
|
||||
if cancel.is_set() {
|
||||
let _ = fs::remove_file(&part_path);
|
||||
return Err(Error::Invalid("Operation cancelled.".into()));
|
||||
}
|
||||
|
||||
let n = src
|
||||
.read(&mut buf)
|
||||
.map_err(|e| Error::NetworkUnreachable(format!("Download interrupted: {e}")))?;
|
||||
if n == 0 {
|
||||
break;
|
||||
}
|
||||
|
||||
dst.write_all(&buf[..n])?;
|
||||
downloaded += n as u64;
|
||||
|
||||
if last_report.elapsed() > std::time::Duration::from_millis(200) {
|
||||
let ratio = if total_bytes > 0 {
|
||||
(downloaded as f32 / total_bytes as f32).clamp(0.0, 1.0)
|
||||
} else {
|
||||
0.5
|
||||
};
|
||||
report(
|
||||
&format!(
|
||||
"Downloading {filename} ({:.1} MB)...",
|
||||
downloaded as f64 / 1_048_576.0
|
||||
),
|
||||
base_percent + ratio * percent_slice,
|
||||
);
|
||||
last_report = std::time::Instant::now();
|
||||
}
|
||||
}
|
||||
|
||||
dst.flush()?;
|
||||
drop(dst);
|
||||
|
||||
verify_archive(&part_path, filename)?;
|
||||
fs::rename(&part_path, &target)?;
|
||||
Ok(target)
|
||||
// Report before hashing existing files: otherwise checking a large archive looks like no operation.
|
||||
report(&format!("Checking {filename}..."), base_percent);
|
||||
let cache = std::env::temp_dir().join("coa-client-races");
|
||||
let downloads = std::env::var_os("USERPROFILE").map(|p| PathBuf::from(p).join("Downloads"));
|
||||
let job = archive_job(filename, url, &cache)?;
|
||||
resolve_archive_with(transport, &job, downloads.as_deref(), cancel, &|p| {
|
||||
let ratio = p.downloaded as f32 / p.total.max(1) as f32;
|
||||
report(
|
||||
&format!(
|
||||
"Downloading {filename} ({:.1} MB)...",
|
||||
p.downloaded as f64 / 1_048_576.0
|
||||
),
|
||||
base_percent + ratio.clamp(0.0, 1.0) * percent_slice,
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
/// Download (if needed) and extract custom races client assets into the target WoW client.
|
||||
@@ -802,11 +834,7 @@ pub fn install_client_patches(
|
||||
fs::create_dir_all(&data_dir)?;
|
||||
|
||||
// 2. Resolve/download archives (0.05 .. 0.50)
|
||||
let http = reqwest::blocking::Client::builder()
|
||||
.user_agent(concat!("CoA-Server-Manager/", env!("CARGO_PKG_VERSION")))
|
||||
.timeout(std::time::Duration::from_secs(600))
|
||||
.build()
|
||||
.map_err(|e| Error::Invalid(format!("Cannot prepare downloader: {e}")))?;
|
||||
let http = crate::download::HttpTransport::with_total_timeout(600)?;
|
||||
|
||||
let mut resolved_archives = Vec::new();
|
||||
let n_archives = ARCHIVES.len() as f32;
|
||||
@@ -1097,7 +1125,9 @@ mod tests {
|
||||
serde_json::from_str(include_str!("custom_races_hashes_1_9_1.json")).unwrap();
|
||||
let files = patch_files(temp.path()).unwrap();
|
||||
assert_eq!(files.len(), old.len());
|
||||
assert!(files.iter().all(|file| old.get(&file.path) == Some(&file.sha256)));
|
||||
assert!(files
|
||||
.iter()
|
||||
.all(|file| old.get(&file.path) == Some(&file.sha256)));
|
||||
assert!(!files.iter().any(|file| file.path.contains("CoAQuestSafe")));
|
||||
}
|
||||
|
||||
@@ -1555,11 +1585,179 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
struct ArchiveTransport {
|
||||
body: Vec<u8>,
|
||||
ranges: std::sync::Mutex<Vec<u64>>,
|
||||
}
|
||||
|
||||
impl crate::download::Transport for ArchiveTransport {
|
||||
fn get(&self, _: &str, from: u64) -> std::result::Result<crate::download::Reply, String> {
|
||||
self.ranges.lock().unwrap().push(from);
|
||||
Ok(crate::download::Reply {
|
||||
status: if from == 0 { 200 } else { 206 },
|
||||
content_range: (from > 0)
|
||||
.then(|| format!("bytes {from}-{}/{}", self.body.len() - 1, self.body.len())),
|
||||
body: Box::new(io::Cursor::new(self.body[from as usize..].to_vec())),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn archive_fixture(root: &Path) -> (crate::download::Job, ArchiveTransport) {
|
||||
use sha2::{Digest, Sha256};
|
||||
let body = b"verified archive bytes for recovery tests".to_vec();
|
||||
let job = crate::download::Job {
|
||||
url: "https://example.invalid/patch.zip".into(),
|
||||
dest: root.join("cache/patch.zip"),
|
||||
sha256: hex::encode(Sha256::digest(&body)),
|
||||
size: body.len() as u64,
|
||||
};
|
||||
fs::create_dir_all(job.dest.parent().unwrap()).unwrap();
|
||||
(
|
||||
job,
|
||||
ArchiveTransport {
|
||||
body,
|
||||
ranges: Default::default(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn corrupt_downloads_are_rejected() {
|
||||
let temp = tempfile::NamedTempFile::new().unwrap();
|
||||
fs::write(temp.path(), b"corrupt archive").unwrap();
|
||||
assert!(verify_archive(temp.path(), ARCHIVES[0].0).is_err());
|
||||
fn download_uses_verified_user_archive_without_network() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let (job, transport) = archive_fixture(temp.path());
|
||||
let downloads = temp.path().join("Downloads");
|
||||
fs::create_dir(&downloads).unwrap();
|
||||
let archive = downloads.join("patch.zip");
|
||||
fs::write(&archive, &transport.body).unwrap();
|
||||
let path = resolve_archive_with(
|
||||
&transport,
|
||||
&job,
|
||||
Some(&downloads),
|
||||
&Cancel::default(),
|
||||
&|_| {},
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(path, archive);
|
||||
assert!(transport.ranges.lock().unwrap().is_empty());
|
||||
assert!(!job.dest.exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn download_skips_bad_user_archive_and_repairs_bad_cache() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let (job, transport) = archive_fixture(temp.path());
|
||||
let downloads = temp.path().join("Downloads");
|
||||
fs::create_dir(&downloads).unwrap();
|
||||
let bad = vec![b'x'; transport.body.len()];
|
||||
fs::write(downloads.join("patch.zip"), &bad).unwrap();
|
||||
fs::write(downloads.join("patch.zip.part"), b"user browser download").unwrap();
|
||||
fs::write(&job.dest, &bad).unwrap();
|
||||
let path = resolve_archive_with(
|
||||
&transport,
|
||||
&job,
|
||||
Some(&downloads),
|
||||
&Cancel::default(),
|
||||
&|_| {},
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(path, job.dest);
|
||||
assert_eq!(fs::read(&path).unwrap(), transport.body);
|
||||
assert_eq!(fs::read(downloads.join("patch.zip")).unwrap(), bad);
|
||||
assert_eq!(
|
||||
fs::read(downloads.join("patch.zip.part")).unwrap(),
|
||||
b"user browser download"
|
||||
);
|
||||
assert_eq!(*transport.ranges.lock().unwrap(), vec![0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn download_resumes_leftover_part_and_verifies_complete_archive() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let (job, transport) = archive_fixture(temp.path());
|
||||
let part = suffix(&job.dest, "part");
|
||||
fs::write(&part, &transport.body[..9]).unwrap();
|
||||
resolve_archive_with(&transport, &job, None, &Cancel::default(), &|_| {}).unwrap();
|
||||
assert_eq!(*transport.ranges.lock().unwrap(), vec![9]);
|
||||
assert_eq!(fs::read(&job.dest).unwrap(), transport.body);
|
||||
assert!(!part.exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn download_reuses_good_cache_even_when_user_archive_is_incomplete() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let (job, transport) = archive_fixture(temp.path());
|
||||
let downloads = temp.path().join("Downloads");
|
||||
fs::create_dir(&downloads).unwrap();
|
||||
fs::write(downloads.join("patch.zip"), b"incomplete").unwrap();
|
||||
fs::write(&job.dest, &transport.body).unwrap();
|
||||
let path = resolve_archive_with(
|
||||
&transport,
|
||||
&job,
|
||||
Some(&downloads),
|
||||
&Cancel::default(),
|
||||
&|_| {},
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(path, job.dest);
|
||||
assert!(transport.ranges.lock().unwrap().is_empty());
|
||||
assert_eq!(
|
||||
fs::read(downloads.join("patch.zip")).unwrap(),
|
||||
b"incomplete"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn download_restarts_once_when_resumed_prefix_is_corrupt() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let (job, transport) = archive_fixture(temp.path());
|
||||
fs::write(suffix(&job.dest, "part"), b"bad").unwrap();
|
||||
resolve_archive_with(&transport, &job, None, &Cancel::default(), &|_| {}).unwrap();
|
||||
assert_eq!(*transport.ranges.lock().unwrap(), vec![3, 0]);
|
||||
assert_eq!(fs::read(&job.dest).unwrap(), transport.body);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn download_promotes_completed_part_without_redownloading() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let (job, transport) = archive_fixture(temp.path());
|
||||
fs::write(suffix(&job.dest, "part"), &transport.body).unwrap();
|
||||
resolve_archive_with(&transport, &job, None, &Cancel::default(), &|_| {}).unwrap();
|
||||
assert!(transport.ranges.lock().unwrap().is_empty());
|
||||
assert_eq!(fs::read(&job.dest).unwrap(), transport.body);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn download_stops_after_one_clean_retry_if_server_bytes_are_invalid() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let (job, mut transport) = archive_fixture(temp.path());
|
||||
transport.body.fill(b'x');
|
||||
let result = resolve_archive_with(&transport, &job, None, &Cancel::default(), &|_| {});
|
||||
assert!(matches!(result, Err(Error::HashMismatch { .. })));
|
||||
assert_eq!(*transport.ranges.lock().unwrap(), vec![0, 0]);
|
||||
assert!(!job.dest.exists());
|
||||
assert!(!suffix(&job.dest, "part").exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn download_does_not_modify_an_archive_owned_by_another_download() {
|
||||
use fs4::fs_std::FileExt;
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let (job, transport) = archive_fixture(temp.path());
|
||||
let lock = fs::OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create(true)
|
||||
.truncate(false)
|
||||
.open(suffix(&job.dest, "lock"))
|
||||
.unwrap();
|
||||
lock.try_lock_exclusive().unwrap();
|
||||
fs::write(suffix(&job.dest, "part"), b"active download").unwrap();
|
||||
assert!(resolve_archive_with(&transport, &job, None, &Cancel::default(), &|_| {}).is_err());
|
||||
assert_eq!(
|
||||
fs::read(suffix(&job.dest, "part")).unwrap(),
|
||||
b"active download"
|
||||
);
|
||||
assert!(transport.ranges.lock().unwrap().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1621,7 +1819,7 @@ mod tests {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let conf = temp.path().join("Core/configs/modules/playerbots.conf");
|
||||
fs::create_dir_all(conf.parent().unwrap()).unwrap();
|
||||
fs::write(&conf, "AiPlayerbot.ExcludedBotRaces = \"\"\n").unwrap();
|
||||
fs::write(&conf, "AiPlayerbot.Enabled = 1\n").unwrap();
|
||||
sync_bot_races_config(temp.path(), false).unwrap();
|
||||
assert_eq!(is_bot_custom_races_allowed(temp.path()), Some(false));
|
||||
let parsed =
|
||||
@@ -1639,4 +1837,19 @@ mod tests {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bot_race_sync_preserves_user_and_crashing_exclusions() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let conf = temp.path().join("Core/configs/modules/playerbots.conf");
|
||||
fs::create_dir_all(conf.parent().unwrap()).unwrap();
|
||||
for value in ["", "1,82,97", EXCLUDED_BOT_RACES_RECOMMENDED] {
|
||||
let original = format!("AiPlayerbot.ExcludedBotRaces = \"{value}\"\nAiPlayerbot.CrashingBotRaces = \"72,77,97\"\n");
|
||||
fs::write(&conf, &original).unwrap();
|
||||
sync_bot_races_config(temp.path(), true).unwrap();
|
||||
assert_eq!(fs::read_to_string(&conf).unwrap(), original);
|
||||
sync_bot_races_config(temp.path(), false).unwrap();
|
||||
assert_eq!(fs::read_to_string(&conf).unwrap(), original);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,6 +96,9 @@ pub fn run(root: &Path, meta: &InstallMeta) -> Report {
|
||||
if let Some(second) = &o.secondary_world {
|
||||
services.push(("Second world", second));
|
||||
}
|
||||
if let Some(reborn) = &o.reborn_world {
|
||||
services.push(("Warcraft Reborn world", reborn));
|
||||
}
|
||||
for (title, s) in services {
|
||||
let (lvl, text) = match (s.state, &s.conflict) {
|
||||
(ServiceState::Running, _) => (Level::Ok, "Running".to_string()),
|
||||
@@ -639,6 +642,7 @@ fn processes_report(root: &Path, ports: &layout::Ports) -> String {
|
||||
Some(&o.auth),
|
||||
Some(&o.world),
|
||||
o.secondary_world.as_ref(),
|
||||
o.reborn_world.as_ref(),
|
||||
]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
@@ -714,6 +718,24 @@ pub fn export_package(
|
||||
"maintenance.json",
|
||||
serde_json::to_string_pretty(&maintenance)?.as_bytes(),
|
||||
)?;
|
||||
for (realm, prefix) in [("primary", ""), ("secondary", ".realms/secondary/"), ("reborn", ".realms/reborn/")] {
|
||||
let state = root.join(format!("{prefix}.state"));
|
||||
if let Ok(owner) = fs::read_to_string(state.join("control-owner.json")) {
|
||||
add(&format!("launcher/{realm}/control-owner.json"), redact_json(&owner).as_bytes())?;
|
||||
}
|
||||
for (path, _, _) in newest_files(&state.join("diagnostics"), "jsonl", 20)
|
||||
.into_iter()
|
||||
.filter(|(path, _, _)| path.file_name().is_some_and(|name| name.to_string_lossy().starts_with("manage-")))
|
||||
.take(5)
|
||||
{
|
||||
let bytes = tail(&path, 512 * 1024);
|
||||
let entries: Vec<serde_json::Value> = String::from_utf8_lossy(&bytes).lines().map(|line| {
|
||||
serde_json::from_str(&redact_json(line)).unwrap_or_else(|_| serde_json::Value::String(redact(line)))
|
||||
}).collect();
|
||||
add(&format!("launcher/{realm}/{}.json", path.file_stem().unwrap_or_default().to_string_lossy()),
|
||||
serde_json::to_string_pretty(&entries)?.as_bytes())?;
|
||||
}
|
||||
}
|
||||
|
||||
// Logs. The newest update logs of the repack's own updater are added under their own names.
|
||||
let mut logs: Vec<(String, PathBuf)> = vec![
|
||||
@@ -1253,6 +1275,12 @@ real error
|
||||
fs::create_dir_all(meta_dir.join("diagnostics")).unwrap();
|
||||
fs::write(meta_dir.join("diagnostics/schema-validation-CoA-test.json"), r#"{"problems":[{"table":"creature_display_preset","column":"display_id","detail":"default mismatch"}],"password":"schema-secret"}"#).unwrap();
|
||||
fs::write(meta_dir.join("diagnostics/database-recovery-test.json"), r#"{"objects":[{"database":"acore_characters","kind":"TRIGGER","name":"user_character_trigger"}],"password":"recovery-secret"}"#).unwrap();
|
||||
for prefix in ["", ".realms/secondary/", ".realms/reborn/"] {
|
||||
let state = root.join(format!("{prefix}.state"));
|
||||
fs::create_dir_all(state.join("diagnostics")).unwrap();
|
||||
fs::write(state.join("control-owner.json"), r#"{"pid":42,"action":"start-all","password":"launcher-owner-secret"}"#).unwrap();
|
||||
fs::write(state.join("diagnostics/manage-test.jsonl"), "{\"event\":\"launcher-stage-test\",\"password\":\"launcher-stage-secret\"}\n{\"event\":\"wait_ready.error\",\"port\":3307}\n").unwrap();
|
||||
}
|
||||
let meta = InstallMeta::new(InstallKind::Imported, &root);
|
||||
let report = run(&root, &meta);
|
||||
let zip_path = d.path().join("diag.zip");
|
||||
@@ -1285,6 +1313,9 @@ real error
|
||||
assert!(all.contains("checking updates") && all.contains("1234"));
|
||||
assert!(all.contains("lockFilePresent") && all.contains("does not establish"));
|
||||
assert!(!all.contains("owner-secret"));
|
||||
assert!(all.contains("launcher-stage-test"));
|
||||
assert!(all.contains("wait_ready.error"));
|
||||
assert!(!all.contains("launcher-stage-secret"));
|
||||
assert_eq!(fs::read(meta_dir.join("update.lock")).unwrap(), b"");
|
||||
assert!(
|
||||
!all.contains("hunter2")
|
||||
|
||||
@@ -758,6 +758,7 @@ pub fn observe_with(d: &dyn Docker, root: &Path, ports: &Ports) -> Observed {
|
||||
auth: unknown("auth", ports.auth),
|
||||
world: unknown("world", ports.world),
|
||||
secondary_world: None,
|
||||
reborn_world: None,
|
||||
};
|
||||
};
|
||||
let n = cfg.names();
|
||||
@@ -767,6 +768,7 @@ pub fn observe_with(d: &dyn Docker, root: &Path, ports: &Ports) -> Observed {
|
||||
auth: unknown("auth", ports.auth),
|
||||
world: unknown("world", ports.world),
|
||||
secondary_world: None,
|
||||
reborn_world: None,
|
||||
};
|
||||
};
|
||||
let ip = connect_ip(&cfg);
|
||||
@@ -795,6 +797,7 @@ pub fn observe_with(d: &dyn Docker, root: &Path, ports: &Ports) -> Observed {
|
||||
listening(state.get(&n.world), ports.world),
|
||||
),
|
||||
secondary_world: None,
|
||||
reborn_world: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,36 +31,17 @@ impl Verb {
|
||||
}
|
||||
}
|
||||
|
||||
fn timeout(self, root: &Path) -> Duration {
|
||||
fn timeout(self, _root: &Path) -> Duration {
|
||||
match self {
|
||||
Verb::StartAll | Verb::StartWorld if squid_enabled(root) => Duration::from_secs(2700),
|
||||
Verb::StartAll | Verb::StartWorld => Duration::from_secs(420),
|
||||
Verb::StartMysql => Duration::from_secs(120),
|
||||
// Includes database startup, optional bot provisioning and the shared 25-minute
|
||||
// world/console wait in launcher_bridge.py, even for older installed scripts.
|
||||
Verb::StartAll | Verb::StartWorld => Duration::from_secs(3600),
|
||||
Verb::StartMysql => Duration::from_secs(360),
|
||||
Verb::StopAll => Duration::from_secs(240),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn squid_enabled(root: &Path) -> bool {
|
||||
let active = root.join("Core/configs/modules/playerbots.conf");
|
||||
let path = if active.exists() {
|
||||
active
|
||||
} else {
|
||||
root.join("Core/configs/modules/playerbots.conf.dist")
|
||||
};
|
||||
std::fs::read(path)
|
||||
.ok()
|
||||
.and_then(|bytes| crate::config::parser::ConfFile::parse_bytes(&bytes).ok())
|
||||
.is_some_and(|config| {
|
||||
config.get("AiPlayerbot.Enabled").is_none_or(|value| {
|
||||
!matches!(
|
||||
value.trim().trim_matches('"').to_ascii_lowercase().as_str(),
|
||||
"0" | "false" | "no" | "off"
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct DriverOutcome {
|
||||
pub ok: bool,
|
||||
@@ -122,7 +103,69 @@ pub(crate) fn validate_update(root: &Path) -> Result<DriverOutcome> {
|
||||
run_inner(root, Verb::StartAll, true)
|
||||
}
|
||||
|
||||
pub fn force_stop(root: &Path) -> Result<DriverOutcome> {
|
||||
if crate::docker::is_docker(root) {
|
||||
return Err(Error::Invalid(
|
||||
"Forced shutdown is only available for Windows repacks.".into(),
|
||||
));
|
||||
}
|
||||
for tree in crate::multiworld::Tree::ALL {
|
||||
let path = crate::multiworld::tree_root(root, tree);
|
||||
if crate::multiworld::tree_running(root, tree)
|
||||
|| !crate::process::find_by_exe(&path.join("Core/worldserver.exe")).is_empty()
|
||||
{
|
||||
let child = fsx::ensure_within(root, &path)?;
|
||||
let out = run_inner_mode(&child, Verb::StopAll, false, true)?;
|
||||
if !out.ok || crate::multiworld::tree_running(root, tree) {
|
||||
return Err(Error::Invalid(format!(
|
||||
"An extra world could not stop; the shared database was left running. {}",
|
||||
out.output
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
run_inner_mode(root, Verb::StopAll, false, true)
|
||||
}
|
||||
|
||||
fn recover_world_for_forced_stop(root: &Path) -> Result<()> {
|
||||
let worlds = crate::process::find_by_exe(&root.join("Core/worldserver.exe"));
|
||||
if worlds.len() > 1 {
|
||||
return Err(Error::Invalid(
|
||||
"More than one world process belongs to this folder; its database was left running."
|
||||
.into(),
|
||||
));
|
||||
}
|
||||
if let Some(world) = worlds.first() {
|
||||
if !crate::process::is_alive(world) {
|
||||
return Err(Error::Invalid(
|
||||
"The world process identity changed; retry the stop.".into(),
|
||||
));
|
||||
}
|
||||
if crate::process::read_state_record(root, "world")
|
||||
.is_none_or(|saved| !saved.same_as(world))
|
||||
{
|
||||
let record = root.join(".state/world.json");
|
||||
let previous = root.join(".state/world-before-forced-stop-recovery.json");
|
||||
if record.is_file() && !previous.exists() {
|
||||
fsx::atomic_write(&previous, &std::fs::read(&record)?)?;
|
||||
}
|
||||
fsx::atomic_write_json(&record, world)?;
|
||||
tracing::warn!(pid = world.pid, root = %root.display(), "Recovered owned world identity before an explicitly requested forced stop");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_inner(root: &Path, verb: Verb, validating_update: bool) -> Result<DriverOutcome> {
|
||||
run_inner_mode(root, verb, validating_update, false)
|
||||
}
|
||||
|
||||
fn run_inner_mode(
|
||||
root: &Path,
|
||||
verb: Verb,
|
||||
validating_update: bool,
|
||||
force: bool,
|
||||
) -> Result<DriverOutcome> {
|
||||
let root = fsx::canonicalize_lenient(root)?;
|
||||
let _update_lock = if !validating_update && matches!(verb, Verb::StartAll | Verb::StartWorld) {
|
||||
Some(crate::update::operation_lock_for(
|
||||
@@ -143,7 +186,7 @@ fn run_inner(root: &Path, verb: Verb, validating_update: bool) -> Result<DriverO
|
||||
prepare_headless_world(&root, verb)?;
|
||||
return crate::docker::run(&root, verb);
|
||||
}
|
||||
if verb == Verb::StopAll {
|
||||
if verb == Verb::StopAll && !force {
|
||||
crate::multiworld::stop(&root)?;
|
||||
}
|
||||
if verb == Verb::StartAll {
|
||||
@@ -186,12 +229,19 @@ fn run_inner(root: &Path, verb: Verb, validating_update: bool) -> Result<DriverO
|
||||
if matches!(verb, Verb::StopAll | Verb::StartMysql | Verb::StartAll) {
|
||||
recover_mysql_launcher_state(&root, verb != Verb::StopAll)?;
|
||||
}
|
||||
if force {
|
||||
recover_world_for_forced_stop(&root)?;
|
||||
}
|
||||
let mut cmd = Command::new(&python);
|
||||
if validating_update {
|
||||
// Isolated startup must use the port from its temporary auth config.
|
||||
cmd.env_remove("AC_REALM_SERVER_PORT");
|
||||
}
|
||||
cmd.arg("-B")
|
||||
.arg("-c")
|
||||
.arg(LAUNCH_SCRIPT)
|
||||
.arg(&script)
|
||||
.arg(verb.arg())
|
||||
.arg(if force { "force-stop-all" } else { verb.arg() })
|
||||
.current_dir(&root)
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::piped())
|
||||
@@ -230,6 +280,13 @@ fn run_inner(root: &Path, verb: Verb, validating_update: bool) -> Result<DriverO
|
||||
let mut output = out_t.join().unwrap_or_default();
|
||||
output.push_str(&err_t.join().unwrap_or_default());
|
||||
let mut output = output.trim().to_string();
|
||||
if status.is_none() {
|
||||
output.push_str(&format!(
|
||||
"\nLauncher {} exceeded its {} second deadline; check the server logs.",
|
||||
verb.arg(),
|
||||
verb.timeout(&root).as_secs()
|
||||
));
|
||||
}
|
||||
let (ok, exit_code) = match status {
|
||||
Some(st) => (st.success(), st.code()),
|
||||
None => (false, None),
|
||||
@@ -254,7 +311,7 @@ fn run_inner(root: &Path, verb: Verb, validating_update: bool) -> Result<DriverO
|
||||
let observed = crate::process::observe(&root, &crate::layout::read_ports(&root));
|
||||
for service in [&observed.mysql, &observed.auth, &observed.world]
|
||||
.into_iter()
|
||||
.chain(observed.secondary_world.iter())
|
||||
.chain(observed.extra_worlds())
|
||||
{
|
||||
if let Some(conflict) = &service.conflict {
|
||||
output.push_str(&format!(
|
||||
@@ -290,6 +347,9 @@ fn prepare_headless_world(root: &Path, verb: Verb) -> Result<()> {
|
||||
if !matches!(verb, Verb::StartAll | Verb::StartWorld) {
|
||||
return Ok(());
|
||||
}
|
||||
std::fs::create_dir_all(root.join("Core/Crashes"))?;
|
||||
let probe = tempfile::NamedTempFile::new_in(root.join("Core/Crashes"))?;
|
||||
probe.close()?;
|
||||
for relative in [
|
||||
"Settings/worldserver.conf.template",
|
||||
"Core/configs/worldserver.conf",
|
||||
@@ -393,7 +453,7 @@ fn recover_mysql_launcher_state(root: &Path, prefer_listener: bool) -> Result<()
|
||||
Ok(())
|
||||
}
|
||||
|
||||
const LAUNCH_SCRIPT: &str = "import runpy,sys\nfrom pathlib import Path\nscript=sys.argv[1]\nsys.path.insert(0,str(Path(script).resolve().parent))\nsys.argv=sys.argv[1:]\nif sys.argv[1]=='stop-all':\n launcher=runpy.run_path(script,run_name='coa_manager_shutdown')\n config=launcher['settings']()\n with launcher['control_lock']():\n launcher['stop_all'](config)\nelse:\n runpy.run_path(script,run_name='__main__')";
|
||||
const LAUNCH_SCRIPT: &str = include_str!("launcher_bridge.py");
|
||||
|
||||
pub(crate) fn patch_launcher_imports(text: &str) -> Result<String> {
|
||||
let line = "sys.path.insert(0, str(Path(__file__).resolve().parent))";
|
||||
@@ -587,6 +647,7 @@ mod tests {
|
||||
let folder = tempfile::tempdir().unwrap();
|
||||
let root = folder.path();
|
||||
prepare_headless_world(root, Verb::StartAll).unwrap();
|
||||
assert!(root.join("Core/Crashes").is_dir());
|
||||
std::fs::create_dir_all(root.join("Core/configs")).unwrap();
|
||||
let path = root.join("Core/configs/worldserver.conf");
|
||||
for original in [
|
||||
@@ -604,7 +665,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn large_squid_provisioning_has_time_to_finish_without_extending_shutdown() {
|
||||
fn slow_world_startup_has_time_with_either_bot_system_without_extending_shutdown() {
|
||||
let folder = tempfile::tempdir().unwrap();
|
||||
let modules = folder.path().join("Core/configs/modules");
|
||||
std::fs::create_dir_all(&modules).unwrap();
|
||||
@@ -615,7 +676,7 @@ mod tests {
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
Verb::StartAll.timeout(folder.path()),
|
||||
Duration::from_secs(2700)
|
||||
Duration::from_secs(3600)
|
||||
);
|
||||
assert_eq!(
|
||||
Verb::StopAll.timeout(folder.path()),
|
||||
@@ -624,7 +685,11 @@ mod tests {
|
||||
std::fs::write(modules.join("playerbots.conf"), "AiPlayerbot.Enabled = 0\n").unwrap();
|
||||
assert_eq!(
|
||||
Verb::StartWorld.timeout(folder.path()),
|
||||
Duration::from_secs(420)
|
||||
Duration::from_secs(3600)
|
||||
);
|
||||
assert_eq!(
|
||||
Verb::StartMysql.timeout(folder.path()),
|
||||
Duration::from_secs(360)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,23 +88,27 @@ fn run_elevated(commands: &[String]) -> Result<()> {
|
||||
|
||||
/// Make sure both rules exist (adds only the missing ones) and confirm afterwards.
|
||||
pub fn ensure_rules(ports: &Ports) -> Result<Status> {
|
||||
ensure_rules_with_secondary(ports, None)
|
||||
ensure_rules_with_extra(ports, &[])
|
||||
}
|
||||
|
||||
pub fn ensure_rules_with_secondary(ports: &Ports, secondary: Option<u16>) -> Result<Status> {
|
||||
/// As `ensure_rules`, plus one rule for the world port of each extra realm that runs next to the main one.
|
||||
pub fn ensure_rules_with_extra(ports: &Ports, extra: &[u16]) -> Result<Status> {
|
||||
let have = status();
|
||||
let mut cmds = plan(ports, &have);
|
||||
let second_name = secondary.map(|port| format!("CoA Server Manager - Second World {port}"));
|
||||
if let (Some(port), Some(name)) = (secondary, &second_name) {
|
||||
let extra_names: Vec<String> = extra
|
||||
.iter()
|
||||
.map(|port| format!("CoA Server Manager - Second World {port}"))
|
||||
.collect();
|
||||
for (port, name) in extra.iter().zip(&extra_names) {
|
||||
if !rule_exists(name) {
|
||||
cmds.push(add_cmd(name, port));
|
||||
cmds.push(add_cmd(name, *port));
|
||||
}
|
||||
}
|
||||
if !cmds.is_empty() {
|
||||
run_elevated(&cmds)?;
|
||||
}
|
||||
let now = status();
|
||||
if now.auth && now.world && second_name.as_ref().is_none_or(|name| rule_exists(name)) {
|
||||
if now.auth && now.world && extra_names.iter().all(|name| rule_exists(name)) {
|
||||
Ok(now)
|
||||
} else {
|
||||
Err(Error::Invalid(
|
||||
|
||||
@@ -163,20 +163,64 @@ pub fn set_open(root: &Path, meta: &Path, open: bool) -> Result<bool> {
|
||||
|
||||
/// Make the realm list advertise `host` to remote clients (the launcher resets it to 127.0.0.1 at every start, so this
|
||||
/// runs after each start).
|
||||
pub fn apply_realm_address(root: &Path, host: &str) -> Result<()> {
|
||||
fn realm_address_sql(
|
||||
host: &str,
|
||||
local: Option<(std::net::Ipv4Addr, std::net::Ipv4Addr)>,
|
||||
where_realms: &str,
|
||||
) -> Result<String> {
|
||||
if !host_ok(host) {
|
||||
return Err(Error::Invalid("That address is not valid.".into()));
|
||||
}
|
||||
let db = Db::from_repack(root, Account::Admin)?;
|
||||
let realm = crate::realms::state(root)?.active.realm_id();
|
||||
let where_realms = if crate::realms::state(root)?.simultaneous {
|
||||
"id IN (1,2)".into()
|
||||
} else {
|
||||
format!("id={realm}")
|
||||
let local = local
|
||||
.map(|(address, mask)| format!(",localAddress='{address}',localSubnetMask='{mask}'"))
|
||||
.unwrap_or_default();
|
||||
Ok(format!(
|
||||
"UPDATE acore_auth.realmlist SET address='{host}'{local} WHERE {where_realms};"
|
||||
))
|
||||
}
|
||||
|
||||
pub fn apply_realm_address(root: &Path, settings: &Settings) -> Result<()> {
|
||||
let host = settings.host.as_deref().unwrap_or("127.0.0.1");
|
||||
let local = match settings.mode {
|
||||
Mode::Direct | Mode::Lan => {
|
||||
let address = if settings.mode == Mode::Lan {
|
||||
host.to_owned()
|
||||
} else {
|
||||
crate::net::resolve_lan_host(
|
||||
settings.lan_address_override.as_deref(),
|
||||
crate::net::lan_ip(),
|
||||
)?
|
||||
};
|
||||
let address = crate::net::validate_lan_address(&address)?;
|
||||
let mask = if_addrs::get_if_addrs()?
|
||||
.into_iter()
|
||||
.find_map(|interface| match interface.addr {
|
||||
if_addrs::IfAddr::V4(v4) if v4.ip == address => Some(v4.netmask),
|
||||
_ => None,
|
||||
})
|
||||
.ok_or_else(|| {
|
||||
Error::Invalid("The selected local network address is not connected.".into())
|
||||
})?;
|
||||
Some((address, mask))
|
||||
}
|
||||
Mode::Local => Some((
|
||||
std::net::Ipv4Addr::LOCALHOST,
|
||||
std::net::Ipv4Addr::new(255, 0, 0, 0),
|
||||
)),
|
||||
Mode::Private => None,
|
||||
};
|
||||
db.query(&format!(
|
||||
"UPDATE acore_auth.realmlist SET address='{host}' WHERE {where_realms};"
|
||||
))?;
|
||||
let db = Db::from_repack(root, Account::Admin)?;
|
||||
let state = crate::realms::state(root)?;
|
||||
let mut ids = vec![state.active];
|
||||
ids.extend(state.extra_modes());
|
||||
let where_realms = format!(
|
||||
"id IN ({})",
|
||||
ids.iter()
|
||||
.map(|m| m.realm_id().to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(",")
|
||||
);
|
||||
db.query(&realm_address_sql(host, local, &where_realms)?)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -194,9 +238,9 @@ pub fn ensure_bind(root: &Path, meta: &Path) -> Result<bool> {
|
||||
/// After every server start: put the chosen address back into the realm list (the launcher resets it to 127.0.0.1).
|
||||
pub fn reapply(root: &Path, meta: &Path) -> Result<()> {
|
||||
let s = load(meta);
|
||||
match (s.mode, s.host) {
|
||||
match (s.mode, &s.host) {
|
||||
(Mode::Local, _) | (_, None) => Ok(()),
|
||||
(_, Some(host)) => apply_realm_address(root, &host),
|
||||
(_, Some(_)) => apply_realm_address(root, &s),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,6 +434,25 @@ CoA.AllowRemoteClients = 0
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn realm_addresses_restore_lan_without_replacing_public_host() {
|
||||
let sql = realm_address_sql(
|
||||
"203.0.113.9",
|
||||
Some((
|
||||
"192.168.50.7".parse().unwrap(),
|
||||
"255.255.254.0".parse().unwrap(),
|
||||
)),
|
||||
"id IN (1,2)",
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(sql, "UPDATE acore_auth.realmlist SET address='203.0.113.9',localAddress='192.168.50.7',localSubnetMask='255.255.254.0' WHERE id IN (1,2);");
|
||||
assert_eq!(
|
||||
realm_address_sql("100.64.1.2", None, "id=1").unwrap(),
|
||||
"UPDATE acore_auth.realmlist SET address='100.64.1.2' WHERE id=1;"
|
||||
);
|
||||
assert!(realm_address_sql("bad'host", None, "id=1").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn old_settings_load_without_migrating_effective_host_to_override() {
|
||||
let s: Settings = serde_json::from_str(r#"{"mode":"lan","host":"192.168.1.50"}"#).unwrap();
|
||||
|
||||
@@ -239,14 +239,14 @@ fn bootstrap_database_inner(root: &Path) -> Result<()> {
|
||||
}
|
||||
fs::copy(&boot, &target)?; // launcher needs database.json to render its files at first start
|
||||
|
||||
let started = driver::run(root, Verb::StartMysql)?;
|
||||
if !started.ok {
|
||||
return Err(Error::Invalid(format!(
|
||||
"The database could not be started. {}",
|
||||
driver::startup_failure(root, &started)
|
||||
)));
|
||||
}
|
||||
let result = (|| -> Result<()> {
|
||||
let started = driver::run(root, Verb::StartMysql)?;
|
||||
if !started.ok {
|
||||
return Err(Error::Invalid(format!(
|
||||
"The database could not be started. {}",
|
||||
driver::startup_failure(root, &started)
|
||||
)));
|
||||
}
|
||||
let db = Db::from_repack(root, Account::Admin)?;
|
||||
let (root_pw, app_pw) = (random_hex(48), random_hex(48));
|
||||
let accounts = db.query(
|
||||
@@ -362,6 +362,7 @@ pub fn install_base(p: &Params, report: &dyn Fn(Step)) -> Result<Installed> {
|
||||
// 3. Extract into our own staging folder.
|
||||
if staging_root.exists() {
|
||||
if staging_root.join(MARKER).is_file() {
|
||||
stop_installation(&staging_root)?;
|
||||
fs::remove_dir_all(&staging_root)?; // leftover of an earlier failed attempt that we created
|
||||
} else {
|
||||
return Err(Error::Invalid(format!("{} is left over from an earlier installation that did not finish, and the Manager cannot tell whether it may be deleted. Delete that folder yourself, then try again.", staging_root.display())));
|
||||
@@ -426,24 +427,60 @@ pub fn install_base(p: &Params, report: &dyn Fn(Step)) -> Result<Installed> {
|
||||
})();
|
||||
|
||||
if result.is_err() {
|
||||
if staging_root.join(MARKER).exists() {
|
||||
// Unfinished work of ours; the destination was never touched.
|
||||
let _ = driver::run(&staging_root, Verb::StopAll);
|
||||
let _ = fs::remove_dir_all(&staging_root);
|
||||
let unfinished = if staging_root.join(MARKER).is_file() {
|
||||
Some(&staging_root)
|
||||
} else if dest.join(MARKER).is_file() {
|
||||
// Failed after the folder was moved into place. The destination was empty or absent before (preflight),
|
||||
// so what carries our marker is only our unfinished install.
|
||||
let _ = driver::run(&dest, Verb::StopAll);
|
||||
let _ = fs::remove_dir_all(&dest);
|
||||
Some(&dest)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
if let Some(unfinished) = unfinished {
|
||||
if let Err(cleanup) = stop_installation(unfinished) {
|
||||
return Err(Error::Invalid(format!(
|
||||
"{} {cleanup}",
|
||||
result.as_ref().unwrap_err()
|
||||
)));
|
||||
}
|
||||
let _ = fs::remove_dir_all(unfinished);
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
fn stop_installation(root: &Path) -> Result<()> {
|
||||
if !root.join("Scripts/manage.py").is_file() {
|
||||
return Ok(());
|
||||
}
|
||||
let stopped = driver::run(root, Verb::StopAll)?;
|
||||
if !stopped.ok {
|
||||
return Err(Error::Invalid(format!(
|
||||
"The unfinished installation could not be stopped; its files were kept. {}",
|
||||
driver::startup_failure(root, &stopped)
|
||||
)));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn an_unstoppable_partial_installation_keeps_its_files_for_recovery() {
|
||||
let folder = tempfile::tempdir().unwrap();
|
||||
let root = folder.path();
|
||||
fs::create_dir_all(root.join("Scripts")).unwrap();
|
||||
fs::write(root.join("Scripts/manage.py"), "# incomplete launcher").unwrap();
|
||||
fs::write(root.join(MARKER), "").unwrap();
|
||||
fs::write(root.join("database-preserved"), "unchanged").unwrap();
|
||||
assert!(stop_installation(root).is_err());
|
||||
assert_eq!(
|
||||
fs::read_to_string(root.join("database-preserved")).unwrap(),
|
||||
"unchanged"
|
||||
);
|
||||
assert!(root.join(MARKER).is_file());
|
||||
}
|
||||
|
||||
fn reg(d: &Path) -> Registry {
|
||||
Registry::at(d.join("reg/installs.json"))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
import runpy
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
script = sys.argv[1]
|
||||
sys.path.insert(0, str(Path(script).resolve().parent))
|
||||
sys.argv = sys.argv[1:]
|
||||
launcher = runpy.run_path(script, run_name="coa_manager_launcher")
|
||||
original_wait = launcher["wait_ready"]
|
||||
world_deadline = None
|
||||
|
||||
|
||||
def wait_ready(name, port, seconds=180):
|
||||
global world_deadline
|
||||
if name == "mysql":
|
||||
seconds = max(seconds, 300)
|
||||
elif name == "world":
|
||||
# Both game and console listeners belong to one startup, including on old repacks.
|
||||
# Ordinary CoA worlds can load slowly too; this must not depend on SQUID.
|
||||
if world_deadline is None:
|
||||
world_deadline = time.monotonic() + max(seconds, 1500)
|
||||
seconds = max(0, world_deadline - time.monotonic())
|
||||
return original_wait(name, port, seconds)
|
||||
|
||||
|
||||
launcher["start_mysql"].__globals__["wait_ready"] = wait_ready
|
||||
if sys.argv[1] in ("stop-all", "force-stop-all"):
|
||||
shutdown = launcher["stop_all"].__globals__
|
||||
class UnsafeShutdown(Exception):
|
||||
pass
|
||||
|
||||
def stop_owned_world(world):
|
||||
expected = Path(script).resolve().parents[1] / "Core" / "worldserver.exe"
|
||||
if Path(world.get("exe", "")) != expected or not shutdown["same_process"](world):
|
||||
raise UnsafeShutdown("World process ownership could not be verified; the database was left running.")
|
||||
try:
|
||||
shutdown["terminate"](world)
|
||||
except (OSError, RuntimeError) as error:
|
||||
raise UnsafeShutdown("Worldserver could not be stopped safely; its database was left running.") from error
|
||||
if not shutdown["wait_stopped"](world, 90):
|
||||
raise UnsafeShutdown("Worldserver is still stopping; its database was left running.")
|
||||
|
||||
if "ra" in shutdown:
|
||||
original_ra = shutdown["ra"]
|
||||
|
||||
def shutdown_command(command, config):
|
||||
try:
|
||||
return original_ra(command, config)
|
||||
except (OSError, RuntimeError):
|
||||
if not command.startswith("server shutdown "):
|
||||
raise
|
||||
world = shutdown["process"]("world")
|
||||
if not world:
|
||||
return "Worldserver has already stopped."
|
||||
stop_owned_world(world)
|
||||
return "Stopped this server's recorded world process without its unavailable console."
|
||||
|
||||
shutdown["ra"] = shutdown_command
|
||||
config = launcher["settings"]()
|
||||
with launcher["control_lock"]():
|
||||
if sys.argv[1] == "force-stop-all":
|
||||
world = shutdown["process"]("world")
|
||||
if world:
|
||||
stop_owned_world(world)
|
||||
print("Force-stopped this server's verified world process; unsaved progress may be lost.", flush=True)
|
||||
launcher["stop_all"](config)
|
||||
else:
|
||||
launcher["main"]()
|
||||
if sys.argv[1] in ("start-all", "start-world"):
|
||||
config = launcher["settings"]()
|
||||
deadline = world_deadline if world_deadline is not None else time.monotonic() + 1500
|
||||
last_error = None
|
||||
while time.monotonic() < deadline:
|
||||
if not launcher["process"]("world"):
|
||||
raise RuntimeError("World startup failed: worldserver stopped before its console accepted commands.")
|
||||
try:
|
||||
launcher["ra"]("server info", config)
|
||||
print("World console is accepting commands.", flush=True)
|
||||
break
|
||||
except (OSError, RuntimeError) as error:
|
||||
last_error = error
|
||||
time.sleep(0.5)
|
||||
else:
|
||||
raise RuntimeError(f"World startup failed: its console is still starting. {last_error}")
|
||||
@@ -11,8 +11,10 @@ pub mod accounts;
|
||||
pub mod allsettings;
|
||||
pub mod backup;
|
||||
pub mod channels;
|
||||
pub mod character_start_check;
|
||||
pub mod cleanbase;
|
||||
pub mod client;
|
||||
pub mod client_graphics;
|
||||
pub mod clientdl;
|
||||
pub mod companions;
|
||||
pub mod config;
|
||||
@@ -35,6 +37,7 @@ pub mod health;
|
||||
pub mod install;
|
||||
pub mod layout;
|
||||
pub mod logging;
|
||||
pub mod server_logging;
|
||||
pub mod manifest;
|
||||
pub mod migrations;
|
||||
pub mod modules;
|
||||
@@ -48,11 +51,13 @@ pub mod population;
|
||||
pub mod portable;
|
||||
pub mod process;
|
||||
pub mod ra;
|
||||
pub mod race_availability;
|
||||
pub mod realm_registry;
|
||||
pub mod realmlist;
|
||||
pub mod realms;
|
||||
pub mod registry;
|
||||
pub mod release;
|
||||
pub mod release_history;
|
||||
pub mod release_schema;
|
||||
pub mod remote_client;
|
||||
pub mod repair;
|
||||
|
||||
@@ -307,6 +307,51 @@ pub struct Item {
|
||||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Audit {
|
||||
pub total: usize,
|
||||
pub applied: usize,
|
||||
pub checksum_verified: usize,
|
||||
pub legacy_unknown: usize,
|
||||
}
|
||||
|
||||
pub fn inventory_sha256(list: &[Migration]) -> Result<String> {
|
||||
let inventory: Vec<_> = list
|
||||
.iter()
|
||||
.map(|m| (&m.db, &m.id, &m.sha256, &m.compatible_sha256, m.destructive))
|
||||
.collect();
|
||||
Ok(fsx::sha256_bytes(&serde_json::to_vec(&inventory)?))
|
||||
}
|
||||
|
||||
pub fn audit_applied(store: &dyn Store, list: &[Migration]) -> Result<Audit> {
|
||||
let rows = store.load_readonly()?;
|
||||
check_history(&rows, list)?;
|
||||
let mut audit = Audit {
|
||||
total: list.len(),
|
||||
applied: 0,
|
||||
checksum_verified: 0,
|
||||
legacy_unknown: 0,
|
||||
};
|
||||
for migration in list {
|
||||
let row = recorded(&rows, migration)
|
||||
.filter(|r| r.status == Status::Applied)
|
||||
.ok_or_else(|| {
|
||||
Error::Invalid(format!(
|
||||
"Release migration {} ({}) is not recorded as applied.",
|
||||
migration.id, migration.db
|
||||
))
|
||||
})?;
|
||||
audit.applied += 1;
|
||||
if row.sha256 == "0".repeat(64) {
|
||||
audit.legacy_unknown += 1;
|
||||
} else {
|
||||
audit.checksum_verified += 1;
|
||||
}
|
||||
}
|
||||
Ok(audit)
|
||||
}
|
||||
|
||||
pub fn status(store: &dyn Store, list: &[Migration]) -> Result<Vec<Item>> {
|
||||
let rows = store.load()?;
|
||||
Ok(list
|
||||
@@ -358,7 +403,7 @@ fn preserve_auth_history(store: &dyn Store, rows: &[LedgerRow], list: &[Migratio
|
||||
}
|
||||
|
||||
/// Migrations that were published with different bytes but have the same effect, so a server that applied either
|
||||
/// version accepts the other. The Wildcard table repair went out as `c1d8…` (0.261005.0, 0.261006.1) and as `9e4a…`
|
||||
/// version accepts the other. The Wildcard table repair went out as `c1d8…` (0.261005.0, 0.261006.1) and as `9e4a…`
|
||||
/// (0.261005.22, 0.261007.24); the packages carry no list of compatible versions, so the Manager knows this pair.
|
||||
const SAME_EFFECT: &[(&str, &[&str])] = &[(
|
||||
"manager_repair__20261005_missing_wildcard_tables",
|
||||
@@ -667,6 +712,61 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn qualification_inventory_digest_matches_release_pipeline_encoding() {
|
||||
let list = vec![Migration {
|
||||
id: "one".into(),
|
||||
db: "world".into(),
|
||||
sha256: "a".repeat(64),
|
||||
compatible_sha256: vec![],
|
||||
destructive: false,
|
||||
}];
|
||||
assert_eq!(
|
||||
inventory_sha256(&list).unwrap(),
|
||||
"b35e45f666304500e69ff352f83103910075ace998afb7915b548765b8c30703"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn qualification_rejects_missing_interrupted_failed_and_changed_history() {
|
||||
let (_dir, list) = setup(&[("world", "qualification_probe", "SELECT 1;")]);
|
||||
let store = Mem::default();
|
||||
assert!(audit_applied(&store, &list).is_err());
|
||||
for status in [Status::Running, Status::Failed, Status::Pending] {
|
||||
store
|
||||
.put(&LedgerRow {
|
||||
db: "world".into(),
|
||||
id: list[0].id.clone(),
|
||||
sha256: list[0].sha256.clone(),
|
||||
status,
|
||||
error: None,
|
||||
baseline: false,
|
||||
})
|
||||
.unwrap();
|
||||
assert!(audit_applied(&store, &list).is_err());
|
||||
}
|
||||
store
|
||||
.put(&LedgerRow {
|
||||
db: "world".into(),
|
||||
id: list[0].id.clone(),
|
||||
sha256: "a".repeat(64),
|
||||
status: Status::Applied,
|
||||
error: None,
|
||||
baseline: false,
|
||||
})
|
||||
.unwrap();
|
||||
assert!(audit_applied(&store, &list).is_err());
|
||||
store.rows.borrow_mut()[0].sha256 = list[0].sha256.clone();
|
||||
assert_eq!(audit_applied(&store, &list).unwrap().checksum_verified, 1);
|
||||
store.rows.borrow_mut()[0].sha256 = "0".repeat(64);
|
||||
let audit = audit_applied(&store, &list).unwrap();
|
||||
assert_eq!(
|
||||
(audit.applied, audit.checksum_verified, audit.legacy_unknown),
|
||||
(1, 0, 1)
|
||||
);
|
||||
assert!(store.ran.borrow().is_empty());
|
||||
}
|
||||
|
||||
fn setup(files: &[(&str, &str, &str)]) -> (tempfile::TempDir, Vec<Migration>) {
|
||||
let d = tempfile::tempdir().unwrap();
|
||||
let mut list = Vec::new();
|
||||
|
||||
@@ -197,7 +197,13 @@ fn list_in(cat: &[Entry], root: &Path) -> Vec<ModuleView> {
|
||||
.and_then(|c| c.get(&e.enable_key).map(truthy))
|
||||
.unwrap_or(e.default_on)
|
||||
};
|
||||
let blocked = wildcard && matches!(e.id.as_str(), "companions" | "playerbots");
|
||||
let dependency_missing = e.id == "dungeon-clear"
|
||||
&& entry_in(cat, "playerbots")
|
||||
.and_then(|entry| bot_enabled(root, &entry))
|
||||
.map(|enabled| !enabled)
|
||||
.unwrap_or(true);
|
||||
let blocked = dependency_missing
|
||||
|| (wildcard && matches!(e.id.as_str(), "companions" | "playerbots" | "dungeon-clear"));
|
||||
let version = if e.id == "playerbots" {
|
||||
crate::squid::release(root).map(|release| {
|
||||
[
|
||||
@@ -228,7 +234,9 @@ fn list_in(cat: &[Entry], root: &Path) -> Vec<ModuleView> {
|
||||
};
|
||||
ModuleView {
|
||||
version,
|
||||
compatibility: if blocked {
|
||||
compatibility: if dependency_missing {
|
||||
"requires-squid"
|
||||
} else if blocked {
|
||||
"unsupported"
|
||||
} else if wildcard && e.id != "client-compat" {
|
||||
"experimental"
|
||||
@@ -296,7 +304,7 @@ fn require_bot_server_stopped(root: &Path) -> Result<()> {
|
||||
pub fn set_enabled(root: &Path, meta: &Path, id: &str, on: bool) -> Result<()> {
|
||||
let _update_lock = crate::update::operation_lock(meta)?;
|
||||
crate::update::ensure_recovered(meta)?;
|
||||
let _lock = if matches!(id, "companions" | "playerbots") {
|
||||
let _lock = if matches!(id, "companions" | "playerbots" | "dungeon-clear") {
|
||||
require_bot_server_stopped(root)?;
|
||||
fs::create_dir_all(root.join(".state"))?;
|
||||
let lock = fs::OpenOptions::new()
|
||||
@@ -317,6 +325,9 @@ pub fn set_enabled(root: &Path, meta: &Path, id: &str, on: bool) -> Result<()> {
|
||||
};
|
||||
if on {
|
||||
crate::realms::guard_module(root, id)?;
|
||||
if id == "dungeon-clear" {
|
||||
crate::realms::guard_module(root, "playerbots")?;
|
||||
}
|
||||
}
|
||||
if id == "custom-races" {
|
||||
if let Ok(meta_content) = fs::read_to_string(meta.join("install.json")) {
|
||||
@@ -379,6 +390,9 @@ pub fn ensure_bot_exclusivity(root: &Path) -> Result<()> {
|
||||
|
||||
fn set_enabled_in(cat: &[Entry], root: &Path, meta: &Path, id: &str, on: bool) -> Result<()> {
|
||||
let e = entry_in(cat, id)?;
|
||||
if on && id == "dungeon-clear" && !bot_enabled(root, &entry_in(cat, "playerbots")?)? {
|
||||
return Err(Error::Invalid("Enable SQUID bots before enabling Dungeon Clear.".into()));
|
||||
}
|
||||
if !e.switchable || e.enable_key.is_empty() {
|
||||
return Err(Error::Invalid("This part cannot be switched off.".into()));
|
||||
}
|
||||
@@ -394,6 +408,15 @@ fn set_enabled_in(cat: &[Entry], root: &Path, meta: &Path, id: &str, on: bool) -
|
||||
}
|
||||
}
|
||||
}
|
||||
if (id == "playerbots" && !on) || (id == "companions" && on) {
|
||||
if let Some(dependency) = cat.iter().find(|entry| entry.id == "dungeon-clear") {
|
||||
if dir(root).join(&dependency.conf).exists()
|
||||
|| dir(root).join(format!("{}.dist", dependency.conf)).exists()
|
||||
{
|
||||
set_enabled_in(cat, root, meta, "dungeon-clear", false)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
let conf = active_file(root, &e)?;
|
||||
let mut file = ConfFile::parse_bytes(&fs::read(&conf)?)?;
|
||||
if file.get(&e.enable_key).map(truthy).unwrap_or(e.default_on) == on
|
||||
@@ -516,6 +539,20 @@ fn save_settings_in(
|
||||
let mut changed = Vec::new();
|
||||
for (key, value) in changes {
|
||||
let value = value.trim();
|
||||
if id == "custom-races" && key == crate::race_availability::KEY {
|
||||
require_bot_server_stopped(root)?;
|
||||
let catalog = crate::race_availability::status(root)?;
|
||||
if !catalog.server_config_supported {
|
||||
return Err(Error::Invalid("Update the server before configuring individual race restrictions.".into()));
|
||||
}
|
||||
crate::race_availability::parse_disabled(value, &catalog.races)?;
|
||||
}
|
||||
if id == "custom-races" && key == crate::race_availability::CATALOG_KEY {
|
||||
let hash = value.trim_matches('"');
|
||||
if !hash.is_empty() && (hash.len() != 64 || !hash.bytes().all(|byte| byte.is_ascii_hexdigit())) {
|
||||
return Err(Error::Invalid("Invalid race catalog fingerprint.".into()));
|
||||
}
|
||||
}
|
||||
if let Some(field) = fields.get(key) {
|
||||
crate::squid::validate(field, value)?;
|
||||
}
|
||||
@@ -804,6 +841,27 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dungeon_clear_requires_squid_and_stays_off_after_squid_is_reenabled() {
|
||||
let d = tempfile::tempdir().unwrap();
|
||||
let root = d.path();
|
||||
fs::create_dir_all(dir(root)).unwrap();
|
||||
fs::write(dir(root).join("playerbots.conf"), "AiPlayerbot.Enabled = 0\n").unwrap();
|
||||
fs::write(dir(root).join("mod_coa_playerbots.conf"), "CoaBots.Enable = 0\n").unwrap();
|
||||
let dungeon = dir(root).join("mod_dungeon_clear.conf");
|
||||
fs::write(&dungeon, "DungeonClear.Enable = 0\n").unwrap();
|
||||
let cat = catalog();
|
||||
assert!(set_enabled_in(&cat, root, root, "dungeon-clear", true).is_err());
|
||||
assert!(!list_in(&cat, root).iter().find(|entry| entry.id == "dungeon-clear").unwrap().switchable);
|
||||
set_enabled_in(&cat, root, root, "playerbots", true).unwrap();
|
||||
set_enabled_in(&cat, root, root, "dungeon-clear", true).unwrap();
|
||||
assert!(read(&dungeon).unwrap().get("DungeonClear.Enable").map(truthy).unwrap());
|
||||
set_enabled_in(&cat, root, root, "playerbots", false).unwrap();
|
||||
assert!(!read(&dungeon).unwrap().get("DungeonClear.Enable").map(truthy).unwrap());
|
||||
set_enabled_in(&cat, root, root, "playerbots", true).unwrap();
|
||||
assert!(!read(&dungeon).unwrap().get("DungeonClear.Enable").map(truthy).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bot_systems_are_mutually_exclusive_in_both_directions_and_manual_configs() {
|
||||
let d = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -12,12 +12,66 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
pub fn root(main: &Path) -> PathBuf {
|
||||
main.join(".realms/secondary")
|
||||
/// A world that runs next to the primary one. Each has its own folder, configs, logs and ports; auth and MySQL stay shared.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Tree {
|
||||
/// Wildcard next to Conquest of Azeroth (or Conquest of Azeroth next to Wildcard when Wildcard is the primary).
|
||||
Second,
|
||||
/// Warcraft Reborn next to Conquest of Azeroth.
|
||||
Reborn,
|
||||
}
|
||||
|
||||
pub fn is_running(main: &Path) -> bool {
|
||||
let second = root(main);
|
||||
impl Tree {
|
||||
pub const ALL: [Tree; 2] = [Tree::Second, Tree::Reborn];
|
||||
|
||||
fn dir(self) -> &'static str {
|
||||
match self {
|
||||
Tree::Second => ".realms/secondary",
|
||||
Tree::Reborn => ".realms/reborn",
|
||||
}
|
||||
}
|
||||
|
||||
fn label(self) -> &'static str {
|
||||
match self {
|
||||
Tree::Second => "second realm",
|
||||
Tree::Reborn => "Warcraft Reborn realm",
|
||||
}
|
||||
}
|
||||
|
||||
fn mode(self, active: Mode) -> Mode {
|
||||
match self {
|
||||
Tree::Second if active == Mode::Coa => Mode::Wildcard,
|
||||
Tree::Second => Mode::Coa,
|
||||
Tree::Reborn => Mode::Reborn,
|
||||
}
|
||||
}
|
||||
|
||||
fn enabled(self, s: &RealmState) -> bool {
|
||||
match self {
|
||||
Tree::Second => s.simultaneous,
|
||||
Tree::Reborn => s.with_reborn,
|
||||
}
|
||||
}
|
||||
|
||||
fn ports(self, s: &RealmState) -> (Option<u16>, Option<u16>) {
|
||||
match self {
|
||||
Tree::Second => (s.secondary_world_port, s.secondary_ra_port),
|
||||
Tree::Reborn => (s.reborn_world_port, s.reborn_ra_port),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tree_root(main: &Path, tree: Tree) -> PathBuf {
|
||||
main.join(tree.dir())
|
||||
}
|
||||
|
||||
/// The folder of the second realm (Wildcard next to Conquest of Azeroth).
|
||||
pub fn root(main: &Path) -> PathBuf {
|
||||
tree_root(main, Tree::Second)
|
||||
}
|
||||
|
||||
pub fn tree_running(main: &Path, tree: Tree) -> bool {
|
||||
let second = tree_root(main, tree);
|
||||
if !second.exists() {
|
||||
return false;
|
||||
}
|
||||
@@ -28,6 +82,26 @@ pub fn is_running(main: &Path) -> bool {
|
||||
.any(|n| process::read_state_record(&second, n).is_some_and(|p| process::is_alive(&p)))
|
||||
}
|
||||
|
||||
/// The folder whose world server runs `mode`: the main folder, or the folder of the extra world that runs that realm.
|
||||
/// Its settings hold the console port that belongs to that world.
|
||||
pub fn world_root(main: &Path, mode: Mode) -> PathBuf {
|
||||
let Ok(s) = realms::state(main) else {
|
||||
return main.to_path_buf();
|
||||
};
|
||||
if mode == s.active {
|
||||
return main.to_path_buf();
|
||||
}
|
||||
Tree::ALL
|
||||
.into_iter()
|
||||
.find(|t| t.enabled(&s) && t.mode(s.active) == mode)
|
||||
.map_or_else(|| main.to_path_buf(), |t| tree_root(main, t))
|
||||
}
|
||||
|
||||
/// Any of the extra worlds is running or still stopping.
|
||||
pub fn is_running(main: &Path) -> bool {
|
||||
Tree::ALL.into_iter().any(|t| tree_running(main, t))
|
||||
}
|
||||
|
||||
fn copy_tree(from: &Path, to: &Path) -> Result<()> {
|
||||
fs::create_dir_all(to)?;
|
||||
for entry in fs::read_dir(from)? {
|
||||
@@ -55,23 +129,52 @@ fn copy_tree(from: &Path, to: &Path) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Start Wildcard together with Conquest of Azeroth.
|
||||
pub fn set_enabled(main: &Path, enabled: bool) -> Result<realms::View> {
|
||||
set_tree(main, Tree::Second, enabled)
|
||||
}
|
||||
|
||||
/// Start Warcraft Reborn together with Conquest of Azeroth.
|
||||
pub fn set_reborn_enabled(main: &Path, enabled: bool) -> Result<realms::View> {
|
||||
set_tree(main, Tree::Reborn, enabled)
|
||||
}
|
||||
|
||||
fn set_tree(main: &Path, tree: Tree, enabled: bool) -> Result<realms::View> {
|
||||
if enabled && !cfg!(windows) {
|
||||
return Err(Error::Invalid(
|
||||
"Simultaneous realms currently require Windows.".into(),
|
||||
));
|
||||
}
|
||||
if enabled {
|
||||
if realms::state(main)?.active == Mode::Reborn {
|
||||
return Err(Error::Invalid(
|
||||
"Simultaneous startup supports CoA and Wildcard. Select one of these realms first."
|
||||
.into(),
|
||||
));
|
||||
}
|
||||
if !realms::view(main)?.supported {
|
||||
return Err(Error::Invalid(
|
||||
"Update the server to a build with Wildcard support first.".into(),
|
||||
));
|
||||
let active = realms::state(main)?.active;
|
||||
let view = realms::view(main)?;
|
||||
match tree {
|
||||
Tree::Second => {
|
||||
if active == Mode::Reborn {
|
||||
return Err(Error::Invalid(
|
||||
"Wildcard starts together with Conquest of Azeroth. Select Conquest of Azeroth first."
|
||||
.into(),
|
||||
));
|
||||
}
|
||||
if !view.supported {
|
||||
return Err(Error::Invalid(
|
||||
"Update the server to a build with Wildcard support first.".into(),
|
||||
));
|
||||
}
|
||||
}
|
||||
Tree::Reborn => {
|
||||
if active != Mode::Coa {
|
||||
return Err(Error::Invalid(
|
||||
"Warcraft Reborn starts together with Conquest of Azeroth. Select Conquest of Azeroth first."
|
||||
.into(),
|
||||
));
|
||||
}
|
||||
if !view.reborn_supported {
|
||||
return Err(Error::Invalid(
|
||||
"Update the server to a build with Warcraft Reborn support first.".into(),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
secondary_launcher(&fs::read_to_string(main.join("Scripts/manage.py"))?)?;
|
||||
}
|
||||
@@ -81,20 +184,21 @@ pub fn set_enabled(main: &Path, enabled: bool) -> Result<realms::View> {
|
||||
|| is_running(main)
|
||||
{
|
||||
return Err(Error::Invalid(
|
||||
"Stop both realms before changing simultaneous startup.".into(),
|
||||
"Stop all realms before changing which realms start together.".into(),
|
||||
));
|
||||
}
|
||||
let original = realms::state(main)?.active;
|
||||
if enabled && !realms::state(main)?.wildcard_created {
|
||||
realms::select(main, Mode::Wildcard)?;
|
||||
if original != Mode::Wildcard {
|
||||
realms::select(main, original)?;
|
||||
}
|
||||
if enabled {
|
||||
realms::ensure_created(main, tree.mode(realms::state(main)?.active))?;
|
||||
}
|
||||
let mut s = realms::state(main)?;
|
||||
if enabled {
|
||||
let p = crate::layout::read_ports(main);
|
||||
let mut reserved = vec![p.mysql, p.auth, p.world, p.ra];
|
||||
// Ports already saved for any other extra world stay reserved, so two worlds never get the same one.
|
||||
for other in Tree::ALL.into_iter().filter(|t| *t != tree) {
|
||||
let (world, ra) = other.ports(&s);
|
||||
reserved.extend(world.into_iter().chain(ra));
|
||||
}
|
||||
let mut choose = |saved: Option<u16>, near: u16| -> Result<u16> {
|
||||
if let Some(port) = saved.filter(|p| *p > 0 && !reserved.contains(p)) {
|
||||
reserved.push(port);
|
||||
@@ -104,31 +208,41 @@ pub fn set_enabled(main: &Path, enabled: bool) -> Result<realms::View> {
|
||||
.find(|p| {
|
||||
!reserved.contains(p) && std::net::TcpListener::bind(("127.0.0.1", *p)).is_ok()
|
||||
})
|
||||
.ok_or_else(|| Error::Invalid("No free port for the second realm.".into()))?;
|
||||
.ok_or_else(|| Error::Invalid(format!("No free port for the {}.", tree.label())))?;
|
||||
reserved.push(port);
|
||||
Ok(port)
|
||||
};
|
||||
s.secondary_world_port = Some(choose(s.secondary_world_port, p.world)?);
|
||||
s.secondary_ra_port = Some(choose(s.secondary_ra_port, p.ra)?);
|
||||
let (world, ra) = tree.ports(&s);
|
||||
let (world, ra) = (choose(world, p.world)?, choose(ra, p.ra)?);
|
||||
match tree {
|
||||
Tree::Second => {
|
||||
s.secondary_world_port = Some(world);
|
||||
s.secondary_ra_port = Some(ra);
|
||||
}
|
||||
Tree::Reborn => {
|
||||
s.reborn_world_port = Some(world);
|
||||
s.reborn_ra_port = Some(ra);
|
||||
}
|
||||
}
|
||||
}
|
||||
match tree {
|
||||
Tree::Second => s.simultaneous = enabled,
|
||||
Tree::Reborn => s.with_reborn = enabled,
|
||||
}
|
||||
s.simultaneous = enabled;
|
||||
fsx::atomic_write_json(&main.join("Settings/realm-profile.json"), &s)?;
|
||||
realms::view(main)
|
||||
}
|
||||
|
||||
fn prepare(main: &Path) -> Result<PathBuf> {
|
||||
if is_running(main) {
|
||||
return Err(Error::Invalid(
|
||||
"The second realm is still running; stop it before preparing its files.".into(),
|
||||
));
|
||||
fn prepare(main: &Path, tree: Tree) -> Result<PathBuf> {
|
||||
if tree_running(main, tree) {
|
||||
return Err(Error::Invalid(format!(
|
||||
"The {} is still running; stop it before preparing its files.",
|
||||
tree.label()
|
||||
)));
|
||||
}
|
||||
let s = realms::state(main)?;
|
||||
let mode = if s.active == Mode::Coa {
|
||||
Mode::Wildcard
|
||||
} else {
|
||||
Mode::Coa
|
||||
};
|
||||
let second = fsx::ensure_within(main, &root(main))?;
|
||||
let mode = tree.mode(s.active);
|
||||
let second = fsx::ensure_within(main, &tree_root(main, tree))?;
|
||||
for folder in ["Runtime", "BugReport", "mysql/bin"] {
|
||||
copy_tree(
|
||||
&main.join(folder),
|
||||
@@ -214,13 +328,12 @@ fn prepare(main: &Path) -> Result<PathBuf> {
|
||||
)?;
|
||||
}
|
||||
let mut cfg: serde_json::Value = fsx::read_json(&main.join("Settings/repack.json"))?;
|
||||
cfg["worldPort"] = s
|
||||
.secondary_world_port
|
||||
.ok_or_else(|| Error::Invalid("Second realm world port is missing.".into()))?
|
||||
let (world_port, ra_port) = tree.ports(&s);
|
||||
cfg["worldPort"] = world_port
|
||||
.ok_or_else(|| Error::Invalid(format!("The {} world port is missing.", tree.label())))?
|
||||
.into();
|
||||
cfg["raPort"] = s
|
||||
.secondary_ra_port
|
||||
.ok_or_else(|| Error::Invalid("Second realm console port is missing.".into()))?
|
||||
cfg["raPort"] = ra_port
|
||||
.ok_or_else(|| Error::Invalid(format!("The {} console port is missing.", tree.label())))?
|
||||
.into();
|
||||
fsx::atomic_write_json(&second.join("Settings/repack.json"), &cfg)?;
|
||||
fsx::atomic_write(
|
||||
@@ -232,6 +345,7 @@ fn prepare(main: &Path) -> Result<PathBuf> {
|
||||
&RealmState {
|
||||
active: mode,
|
||||
wildcard_created: true,
|
||||
reborn_created: true,
|
||||
..Default::default()
|
||||
},
|
||||
)?;
|
||||
@@ -256,12 +370,9 @@ fn secondary_launcher(source: &str) -> Result<String> {
|
||||
))
|
||||
}
|
||||
|
||||
pub fn start(main: &Path) -> Result<()> {
|
||||
if !realms::state(main)?.simultaneous {
|
||||
return Ok(());
|
||||
}
|
||||
if is_running(main) {
|
||||
let second = root(main);
|
||||
fn start_tree(main: &Path, tree: Tree) -> Result<()> {
|
||||
if tree_running(main, tree) {
|
||||
let second = tree_root(main, tree);
|
||||
if process::observe(&second, &crate::layout::read_ports(&second))
|
||||
.world
|
||||
.state
|
||||
@@ -269,35 +380,50 @@ pub fn start(main: &Path) -> Result<()> {
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
return Err(Error::Invalid(
|
||||
"The second realm is still starting or stopping.".into(),
|
||||
));
|
||||
return Err(Error::Invalid(format!(
|
||||
"The {} is still starting or stopping.",
|
||||
tree.label()
|
||||
)));
|
||||
}
|
||||
let second = prepare(main)?;
|
||||
let second = prepare(main, tree)?;
|
||||
let out = driver::run(&second, Verb::StartWorld)?;
|
||||
if !out.ok {
|
||||
return Err(Error::Invalid(format!(
|
||||
"The second realm did not start: {}",
|
||||
"The {} did not start: {}",
|
||||
tree.label(),
|
||||
out.output
|
||||
)));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn stop(main: &Path) -> Result<()> {
|
||||
let second = root(main);
|
||||
/// Start every extra world that is switched on.
|
||||
pub fn start(main: &Path) -> Result<()> {
|
||||
let s = realms::state(main)?;
|
||||
for tree in Tree::ALL.into_iter().filter(|t| t.enabled(&s)) {
|
||||
start_tree(main, tree)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn stop_tree(main: &Path, tree: Tree) -> Result<()> {
|
||||
let second = tree_root(main, tree);
|
||||
if !second.join("Scripts/manage.py").exists() {
|
||||
if is_running(main) {
|
||||
return Err(Error::Invalid("The running second realm's launcher is missing. The shared database was left running.".into()));
|
||||
if tree_running(main, tree) {
|
||||
return Err(Error::Invalid(format!(
|
||||
"The running {}'s launcher is missing. The shared database was left running.",
|
||||
tree.label()
|
||||
)));
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
// Its state has no auth/MySQL records: the shared database remains up until the primary world stops.
|
||||
if is_running(main) {
|
||||
if tree_running(main, tree) {
|
||||
let out = driver::run(&second, Verb::StopAll)?;
|
||||
if !out.ok || is_running(main) {
|
||||
if !out.ok || tree_running(main, tree) {
|
||||
return Err(Error::Invalid(format!(
|
||||
"The second realm could not stop; the database was left running: {}",
|
||||
"The {} could not stop; the database was left running: {}",
|
||||
tree.label(),
|
||||
out.output
|
||||
)));
|
||||
}
|
||||
@@ -305,9 +431,81 @@ pub fn stop(main: &Path) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Stop every extra world; one that fails does not keep the others running.
|
||||
pub fn stop(main: &Path) -> Result<()> {
|
||||
let mut first = None;
|
||||
for tree in Tree::ALL {
|
||||
if let Err(e) = stop_tree(main, tree) {
|
||||
first.get_or_insert(e);
|
||||
}
|
||||
}
|
||||
first.map_or(Ok(()), Err)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn every_extra_world_has_its_own_folder_realm_and_ports() {
|
||||
let mut s = RealmState::default();
|
||||
assert_eq!(Tree::Second.mode(Mode::Coa), Mode::Wildcard);
|
||||
assert_eq!(Tree::Second.mode(Mode::Wildcard), Mode::Coa);
|
||||
assert_eq!(Tree::Reborn.mode(Mode::Coa), Mode::Reborn);
|
||||
assert_ne!(Tree::Second.dir(), Tree::Reborn.dir());
|
||||
s.secondary_world_port = Some(8086);
|
||||
s.reborn_world_port = Some(8087);
|
||||
assert_eq!(Tree::Second.ports(&s).0, Some(8086));
|
||||
assert_eq!(Tree::Reborn.ports(&s).0, Some(8087));
|
||||
assert!(!Tree::Second.enabled(&s) && !Tree::Reborn.enabled(&s));
|
||||
s.with_reborn = true;
|
||||
assert!(!Tree::Second.enabled(&s) && Tree::Reborn.enabled(&s));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_realm_is_reached_through_the_folder_of_its_own_world() {
|
||||
let t = tempfile::tempdir().unwrap();
|
||||
let main = t.path();
|
||||
fsx::atomic_write(
|
||||
&main.join("Settings/realm-profile.json"),
|
||||
br#"{"active":"coa","wildcard_created":true,"reborn_created":true,"simultaneous":true,"with_reborn":true}"#,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(world_root(main, Mode::Coa), main);
|
||||
assert_eq!(world_root(main, Mode::Wildcard), main.join(".realms/secondary"));
|
||||
assert_eq!(world_root(main, Mode::Reborn), main.join(".realms/reborn"));
|
||||
// A realm that is not switched on has no world of its own: the main folder answers.
|
||||
fsx::atomic_write(
|
||||
&main.join("Settings/realm-profile.json"),
|
||||
br#"{"active":"coa","wildcard_created":true,"reborn_created":true,"with_reborn":true}"#,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(world_root(main, Mode::Wildcard), main);
|
||||
assert_eq!(world_root(main, Mode::Reborn), main.join(".realms/reborn"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reborn_starts_together_with_conquest_of_azeroth_only() {
|
||||
let t = tempfile::tempdir().unwrap();
|
||||
fsx::atomic_write(
|
||||
&t.path().join("Core/worldserver.exe"),
|
||||
b"Warcraft Reborn class spells are unavailable",
|
||||
)
|
||||
.unwrap();
|
||||
fsx::atomic_write(
|
||||
&t.path().join("Settings/realm-profile.json"),
|
||||
br#"{"active":"wildcard","wildcard_created":true}"#,
|
||||
)
|
||||
.unwrap();
|
||||
let err = set_reborn_enabled(t.path(), true).unwrap_err().to_string();
|
||||
let expected = if cfg!(windows) {
|
||||
"Select Conquest of Azeroth first"
|
||||
} else {
|
||||
"Simultaneous realms currently require Windows"
|
||||
};
|
||||
assert!(err.contains(expected), "{err}");
|
||||
assert!(!realms::state(t.path()).unwrap().with_reborn);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn secondary_never_starts_the_shared_database() {
|
||||
let patched = secondary_launcher("def start_world(config, offset):\r\n start_mysql(config)\r\n wait_ready('world', 8086)\r\n").unwrap();
|
||||
|
||||
@@ -284,7 +284,7 @@ fn stop_failure(
|
||||
)];
|
||||
for service in [&status.mysql, &status.auth, &status.world]
|
||||
.into_iter()
|
||||
.chain(status.secondary_world.iter())
|
||||
.chain(status.extra_worlds())
|
||||
{
|
||||
if service.state != crate::process::ServiceState::Stopped {
|
||||
details.push(format!(
|
||||
@@ -506,6 +506,7 @@ mod tests {
|
||||
auth: stopped("auth"),
|
||||
world: stopped("world"),
|
||||
secondary_world: None,
|
||||
reborn_world: None,
|
||||
};
|
||||
let outcome = crate::driver::DriverOutcome {
|
||||
ok: false,
|
||||
@@ -1003,6 +1004,89 @@ mod tests {
|
||||
};
|
||||
let mut server = start();
|
||||
db.query("CREATE DATABASE acore_characters; CREATE DATABASE acore_world; CREATE DATABASE acore_auth; CREATE TABLE acore_characters.probe(id INT PRIMARY KEY, note VARCHAR(40)); CREATE TABLE acore_world.probe(id INT NOT NULL DEFAULT 0); INSERT INTO acore_world.probe VALUES(43); CREATE TABLE acore_auth.probe(id INT); INSERT INTO acore_auth.probe VALUES(44); CREATE USER 'fixture_user'@'localhost' IDENTIFIED BY 'fixture'; CREATE TRIGGER acore_characters.probe_insert BEFORE INSERT ON acore_characters.probe FOR EACH ROW SET NEW.note='triggered'; INSERT INTO acore_characters.probe VALUES(42,'original'); CREATE VIEW acore_characters.probe_view AS SELECT c.id,w.id AS world_id FROM acore_characters.probe c CROSS JOIN acore_world.probe w; CREATE PROCEDURE acore_characters.probe_proc() SELECT id FROM acore_characters.probe; CREATE FUNCTION acore_characters.probe_func() RETURNS INT DETERMINISTIC RETURN 73;").unwrap();
|
||||
// Regression: an upgrade must distinguish pre-existing unsupported character starts
|
||||
// from a newly lost start, without weakening any structural schema check.
|
||||
db.query("CREATE TABLE acore_characters.characters(guid INT UNSIGNED PRIMARY KEY,race INT UNSIGNED NOT NULL,class INT UNSIGNED NOT NULL); CREATE TABLE acore_world.playercreateinfo(race INT UNSIGNED,class INT UNSIGNED,PRIMARY KEY(race,class)); INSERT INTO acore_characters.characters VALUES(100,44,14),(101,44,14),(102,7,14);").unwrap();
|
||||
let starts = [1, 2, 3, 4, 5, 6, 7, 8, 10, 11]
|
||||
.into_iter()
|
||||
.flat_map(|race| (12..=32).map(move |class| format!("({race},{class})")))
|
||||
.collect::<Vec<_>>()
|
||||
.join(",");
|
||||
db.query(&format!(
|
||||
"INSERT INTO acore_world.playercreateinfo VALUES {starts};"
|
||||
))
|
||||
.unwrap();
|
||||
crate::schema_check::capture(&db, &root).unwrap();
|
||||
let baseline = crate::character_start_check::capture(&db, &root).unwrap();
|
||||
assert_eq!(baseline.realms[crate::realms::Mode::Coa.name()].len(), 2);
|
||||
assert!(
|
||||
!crate::schema_check::check(&db, &root).unwrap().is_empty(),
|
||||
"ordinary diagnostics stay strict"
|
||||
);
|
||||
assert!(
|
||||
crate::schema_check::check_update_with_report(&db, &root, Some(&baseline))
|
||||
.unwrap()
|
||||
.is_empty(),
|
||||
"unchanged old gaps must not block an unrelated upgrade"
|
||||
);
|
||||
assert_eq!(
|
||||
db.query("SELECT COUNT(*) FROM acore_characters.characters;")
|
||||
.unwrap()
|
||||
.trim(),
|
||||
"3"
|
||||
);
|
||||
let report_dir = crate::registry::metadata_dir_for(&root)
|
||||
.unwrap()
|
||||
.join("diagnostics");
|
||||
let report_path = fs::read_dir(report_dir)
|
||||
.unwrap()
|
||||
.flatten()
|
||||
.map(|e| e.path())
|
||||
.find(|p| {
|
||||
p.file_name()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.starts_with("schema-validation-")
|
||||
})
|
||||
.unwrap();
|
||||
let report: serde_json::Value = fsx::read_json(&report_path).unwrap();
|
||||
assert_eq!(report["preexistingUnsupportedCharacters"], 2);
|
||||
assert_eq!(
|
||||
report["preexistingCharacterStarts"],
|
||||
serde_json::json!([{"race":44,"class":14,"count":2}])
|
||||
);
|
||||
assert_eq!(report["problems"], serde_json::json!([]));
|
||||
// Same count and race/class but a different GUID must still block.
|
||||
db.query("UPDATE acore_characters.characters SET guid=103 WHERE guid=101;")
|
||||
.unwrap();
|
||||
assert!(
|
||||
!crate::schema_check::check_update_with_report(&db, &root, Some(&baseline))
|
||||
.unwrap()
|
||||
.is_empty()
|
||||
);
|
||||
db.query("UPDATE acore_characters.characters SET guid=101 WHERE guid=103;")
|
||||
.unwrap();
|
||||
// Loss of a formerly valid start is never grandfathered.
|
||||
db.query("DELETE FROM acore_world.playercreateinfo WHERE race=7 AND class=14;")
|
||||
.unwrap();
|
||||
assert!(
|
||||
!crate::schema_check::check_update_with_report(&db, &root, Some(&baseline))
|
||||
.unwrap()
|
||||
.is_empty()
|
||||
);
|
||||
db.query("INSERT INTO acore_world.playercreateinfo VALUES(7,14);")
|
||||
.unwrap();
|
||||
db.query("ALTER TABLE acore_world.probe MODIFY id VARCHAR(30) NOT NULL DEFAULT '0';")
|
||||
.unwrap();
|
||||
assert!(
|
||||
!crate::schema_check::check_update_with_report(&db, &root, Some(&baseline))
|
||||
.unwrap()
|
||||
.is_empty(),
|
||||
"existing character warnings cannot hide a structural failure"
|
||||
);
|
||||
db.query("ALTER TABLE acore_world.probe MODIFY id INT NOT NULL DEFAULT 0; DROP TABLE acore_characters.characters; DROP TABLE acore_world.playercreateinfo;").unwrap();
|
||||
fs::remove_file(root.join(crate::schema_check::CONTRACT)).unwrap();
|
||||
|
||||
// Shared auth must not run again when the active realm changes.
|
||||
use crate::migrations::Store;
|
||||
db.query("CREATE DATABASE acore_world_wildcard;").unwrap();
|
||||
|
||||
@@ -248,9 +248,15 @@ impl RealmAccess {
|
||||
}
|
||||
}
|
||||
|
||||
/// The folder of the world server this realm runs in: an extra world next to the main one has its own console port.
|
||||
fn world_folder(&self, root: &Path) -> PathBuf {
|
||||
self.mode
|
||||
.map_or_else(|| root.to_path_buf(), |m| crate::multiworld::world_root(root, m))
|
||||
}
|
||||
|
||||
pub fn ra(&self) -> Result<Ra> {
|
||||
match &self.source {
|
||||
Source::Install { root } => Ra::connect(root),
|
||||
Source::Install { root } => Ra::connect(&self.world_folder(root)),
|
||||
Source::Descriptor(d) => Ra::connect_to(d.ra_port, &d.ra_user, d.ra_password.expose()),
|
||||
}
|
||||
}
|
||||
@@ -261,7 +267,7 @@ impl RealmAccess {
|
||||
|
||||
pub fn ports(&self) -> (Option<u16>, u16) {
|
||||
match &self.source {
|
||||
Source::Install { root } => (None, read_ports(root).ra),
|
||||
Source::Install { root } => (None, read_ports(&self.world_folder(root)).ra),
|
||||
Source::Descriptor(d) => (Some(d.db_port), d.ra_port),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,16 @@ pub struct Observed {
|
||||
pub auth: ServiceStatus,
|
||||
pub world: ServiceStatus,
|
||||
pub secondary_world: Option<ServiceStatus>,
|
||||
/// The Warcraft Reborn world that starts together with Conquest of Azeroth.
|
||||
#[serde(default)]
|
||||
pub reborn_world: Option<ServiceStatus>,
|
||||
}
|
||||
|
||||
impl Observed {
|
||||
/// The worlds that run next to the primary one.
|
||||
pub fn extra_worlds(&self) -> impl Iterator<Item = &ServiceStatus> {
|
||||
self.secondary_world.iter().chain(self.reborn_world.iter())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_state_record(root: &Path, name: &str) -> Option<ProcessIdentity> {
|
||||
@@ -392,20 +402,30 @@ pub fn observe(root: &Path, ports: &Ports) -> Observed {
|
||||
}
|
||||
let listen = listeners();
|
||||
let (world, auth, mysql) = crate::layout::executables(root);
|
||||
let secondary = crate::multiworld::root(root);
|
||||
let secondary_world = if crate::realms::state(root).is_ok_and(|s| s.simultaneous)
|
||||
|| crate::multiworld::is_running(root)
|
||||
{
|
||||
Some(service(
|
||||
&secondary,
|
||||
"world-secondary",
|
||||
secondary.join("Core/worldserver.exe"),
|
||||
crate::layout::read_ports(&secondary).world,
|
||||
&listen,
|
||||
))
|
||||
} else {
|
||||
None
|
||||
use crate::multiworld::Tree;
|
||||
let realm_state = crate::realms::state(root).ok();
|
||||
let extra_world = |tree: Tree, name: &'static str, enabled: bool| {
|
||||
let folder = crate::multiworld::tree_root(root, tree);
|
||||
(enabled || crate::multiworld::tree_running(root, tree)).then(|| {
|
||||
service(
|
||||
&folder,
|
||||
name,
|
||||
folder.join("Core/worldserver.exe"),
|
||||
crate::layout::read_ports(&folder).world,
|
||||
&listen,
|
||||
)
|
||||
})
|
||||
};
|
||||
let secondary_world = extra_world(
|
||||
Tree::Second,
|
||||
"world-secondary",
|
||||
realm_state.as_ref().is_some_and(|s| s.simultaneous),
|
||||
);
|
||||
let reborn_world = extra_world(
|
||||
Tree::Reborn,
|
||||
"world-reborn",
|
||||
realm_state.as_ref().is_some_and(|s| s.with_reborn),
|
||||
);
|
||||
Observed {
|
||||
mysql: service(root, "mysql", mysql, ports.mysql, &listen),
|
||||
auth: service(root, "auth", auth, ports.auth, &listen),
|
||||
@@ -418,6 +438,7 @@ pub fn observe(root: &Path, ports: &Ports) -> Observed {
|
||||
&listen,
|
||||
),
|
||||
secondary_world,
|
||||
reborn_world,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,515 @@
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use serde::Serialize;
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
use crate::config::parser::ConfFile;
|
||||
use crate::error::{Error, Result};
|
||||
|
||||
pub const KEY: &str = "CoACustomRaces.DisabledRaceIds";
|
||||
pub const CATALOG_KEY: &str = "CoACustomRaces.DisabledRaceCatalogSha256";
|
||||
const CONF: &str = "Core/configs/modules/coa_custom_races.conf";
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Race {
|
||||
pub id: u32,
|
||||
pub name: String,
|
||||
pub faction: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Availability {
|
||||
pub realm: crate::realms::Mode,
|
||||
pub races: Vec<Race>,
|
||||
pub disabled_race_ids: BTreeSet<u32>,
|
||||
pub catalog_sha256: String,
|
||||
pub server_config_supported: bool,
|
||||
pub catalog_needs_review: bool,
|
||||
pub unrecognized_race_ids: BTreeSet<u32>,
|
||||
}
|
||||
|
||||
fn invalid(message: &str) -> Error {
|
||||
Error::Invalid(message.into())
|
||||
}
|
||||
|
||||
fn stock(id: u32) -> bool {
|
||||
(1..=11).contains(&id) && id != 9
|
||||
}
|
||||
|
||||
pub fn catalog(bytes: &[u8]) -> Result<Vec<Race>> {
|
||||
let word = |offset: usize| -> Result<u32> {
|
||||
let data = bytes
|
||||
.get(offset..offset + 4)
|
||||
.ok_or_else(|| invalid("Truncated race catalog."))?;
|
||||
Ok(u32::from_le_bytes(data.try_into().unwrap()))
|
||||
};
|
||||
if bytes.get(..4) != Some(b"WDBC") || word(8)? != 69 || word(12)? != 276 {
|
||||
return Err(invalid("Unsupported race catalog format."));
|
||||
}
|
||||
let count = word(4)? as usize;
|
||||
let string_size = word(16)? as usize;
|
||||
if count == 0 || count > 255 {
|
||||
return Err(invalid("Invalid race catalog record count."));
|
||||
}
|
||||
let strings_start = 20 + count * 276;
|
||||
if strings_start.checked_add(string_size) != Some(bytes.len()) || string_size == 0 {
|
||||
return Err(invalid("Invalid race catalog bounds."));
|
||||
}
|
||||
let strings = &bytes[strings_start..];
|
||||
if strings.last() != Some(&0) {
|
||||
return Err(invalid("Invalid race catalog strings."));
|
||||
}
|
||||
let mut ids = BTreeSet::new();
|
||||
let mut races = Vec::new();
|
||||
for row in 0..count {
|
||||
let offset = 20 + row * 276;
|
||||
let id = word(offset)?;
|
||||
if id == 0 || id > 255 || !ids.insert(id) {
|
||||
return Err(invalid("Invalid or duplicate RaceID in the catalog."));
|
||||
}
|
||||
let mut name = String::new();
|
||||
for field in 14..30 {
|
||||
let index = word(offset + field * 4)? as usize;
|
||||
let remaining = strings
|
||||
.get(index..)
|
||||
.ok_or_else(|| invalid("Invalid race name offset."))?;
|
||||
let end = remaining
|
||||
.iter()
|
||||
.position(|byte| *byte == 0)
|
||||
.ok_or_else(|| invalid("Unterminated race name."))?;
|
||||
let value = std::str::from_utf8(&remaining[..end])
|
||||
.map_err(|_| invalid("Invalid race name encoding."))?;
|
||||
if name.is_empty() && !value.is_empty() {
|
||||
name = value.into();
|
||||
}
|
||||
}
|
||||
if stock(id) || word(offset + 4)? & 1 != 0 {
|
||||
continue;
|
||||
}
|
||||
if name.trim().is_empty() {
|
||||
return Err(invalid("A playable custom race has no name."));
|
||||
}
|
||||
let faction = match word(offset + 13 * 4)? {
|
||||
0 => Some("alliance".into()),
|
||||
1 => Some("horde".into()),
|
||||
_ => None,
|
||||
};
|
||||
races.push(Race { id, name, faction });
|
||||
}
|
||||
races.sort_by_key(|race| race.id);
|
||||
Ok(races)
|
||||
}
|
||||
|
||||
fn parse_ids(value: &str) -> Result<BTreeSet<u32>> {
|
||||
let value = value.trim();
|
||||
let value = if value.starts_with('"') && value.ends_with('"') && value.len() >= 2 {
|
||||
&value[1..value.len() - 1]
|
||||
} else {
|
||||
value
|
||||
};
|
||||
if value.trim().is_empty() {
|
||||
return Ok(BTreeSet::new());
|
||||
}
|
||||
let mut disabled = BTreeSet::new();
|
||||
for token in value.split(',') {
|
||||
let token = token.trim();
|
||||
if token.is_empty() || !token.bytes().all(|byte| byte.is_ascii_digit()) {
|
||||
return Err(invalid(
|
||||
"Disabled RaceIDs must be a comma-separated list of whole numbers.",
|
||||
));
|
||||
}
|
||||
let id = token
|
||||
.parse::<u32>()
|
||||
.map_err(|_| invalid("Invalid disabled RaceID."))?;
|
||||
if id == 0 || id > 255 || stock(id) || !disabled.insert(id) {
|
||||
return Err(invalid(
|
||||
"Disabled RaceIDs contain a stock, unknown or duplicate race.",
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(disabled)
|
||||
}
|
||||
|
||||
pub fn parse_disabled(value: &str, races: &[Race]) -> Result<BTreeSet<u32>> {
|
||||
let disabled = parse_ids(value)?;
|
||||
let known: BTreeSet<u32> = races.iter().map(|race| race.id).collect();
|
||||
if !disabled.is_subset(&known) {
|
||||
return Err(invalid("Disabled RaceIDs contain an unknown race."));
|
||||
}
|
||||
Ok(disabled)
|
||||
}
|
||||
|
||||
fn dbc_path(root: &Path) -> Result<PathBuf> {
|
||||
let config_path = root.join("Core/configs/worldserver.conf");
|
||||
if config_path.is_file() {
|
||||
let conf = ConfFile::parse_bytes(&fs::read(config_path)?)?;
|
||||
let value = conf.get("DataDir").unwrap_or(".");
|
||||
let data = PathBuf::from(value.trim().trim_matches('"'));
|
||||
return Ok(if data.is_absolute() {
|
||||
data
|
||||
} else {
|
||||
root.join("Core").join(data)
|
||||
}
|
||||
.join("dbc_races/ChrRaces.dbc"));
|
||||
}
|
||||
Ok(root.join("Data/dbc_races/ChrRaces.dbc"))
|
||||
}
|
||||
|
||||
pub fn status(root: &Path) -> Result<Availability> {
|
||||
let bytes = fs::read(dbc_path(root)?)?;
|
||||
let races = catalog(&bytes)?;
|
||||
let conf = ConfFile::parse_bytes(&fs::read(root.join(CONF))?)?;
|
||||
let configured = parse_ids(conf.get(KEY).unwrap_or(""))?;
|
||||
let known: BTreeSet<u32> = races.iter().map(|race| race.id).collect();
|
||||
let unrecognized_race_ids: BTreeSet<u32> = configured.difference(&known).copied().collect();
|
||||
let disabled_race_ids = configured.intersection(&known).copied().collect();
|
||||
let dist = fs::read(root.join(format!("{CONF}.dist")))
|
||||
.ok()
|
||||
.map(|bytes| ConfFile::parse_bytes(&bytes))
|
||||
.transpose()?;
|
||||
let catalog_sha256 = hex::encode(Sha256::digest(&bytes));
|
||||
let saved_hash = conf
|
||||
.get(CATALOG_KEY)
|
||||
.unwrap_or("")
|
||||
.trim()
|
||||
.trim_matches('"')
|
||||
.to_ascii_lowercase();
|
||||
let catalog_needs_review = !configured.is_empty()
|
||||
&& (saved_hash != catalog_sha256 || !unrecognized_race_ids.is_empty());
|
||||
Ok(Availability {
|
||||
realm: crate::realms::state(root)?.active,
|
||||
races,
|
||||
disabled_race_ids,
|
||||
catalog_sha256,
|
||||
catalog_needs_review,
|
||||
unrecognized_race_ids,
|
||||
server_config_supported: dist
|
||||
.is_some_and(|file| file.get(KEY).is_some() && file.get(CATALOG_KEY).is_some())
|
||||
&& fs::read(crate::layout::executables(root).0).is_ok_and(|binary| {
|
||||
[KEY, CATALOG_KEY]
|
||||
.iter()
|
||||
.all(|key| binary.windows(key.len()).any(|part| part == key.as_bytes()))
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn save(
|
||||
root: &Path,
|
||||
meta: &Path,
|
||||
expected_catalog: &str,
|
||||
expected_realm: crate::realms::Mode,
|
||||
disabled: &[u32],
|
||||
) -> Result<Availability> {
|
||||
crate::update::ensure_recovered(meta)?;
|
||||
fs::create_dir_all(root.join(".state"))?;
|
||||
let lock = fs::OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create(true)
|
||||
.truncate(false)
|
||||
.open(root.join(".state/control.lock"))?;
|
||||
if !fs4::fs_std::FileExt::try_lock_exclusive(&lock)? {
|
||||
return Err(invalid("Another server operation is in progress."));
|
||||
}
|
||||
let observed = crate::process::observe(root, &crate::layout::read_ports(root));
|
||||
if observed.world.state != crate::process::ServiceState::Stopped
|
||||
|| crate::multiworld::is_running(root)
|
||||
{
|
||||
return Err(invalid(
|
||||
"Stop the server before changing race availability.",
|
||||
));
|
||||
}
|
||||
let current = status(root)?;
|
||||
if current.realm != expected_realm {
|
||||
return Err(invalid(
|
||||
"The selected realm changed. Reload race availability before saving.",
|
||||
));
|
||||
}
|
||||
if !current.server_config_supported {
|
||||
return Err(invalid(
|
||||
"Update the server to a build supporting individual race restrictions first.",
|
||||
));
|
||||
}
|
||||
if current.catalog_sha256 != expected_catalog {
|
||||
return Err(invalid(
|
||||
"The race catalog changed. Reload the race list before saving.",
|
||||
));
|
||||
}
|
||||
let value = disabled
|
||||
.iter()
|
||||
.map(u32::to_string)
|
||||
.collect::<Vec<_>>()
|
||||
.join(",");
|
||||
let normalized = parse_disabled(&value, ¤t.races)?;
|
||||
let value = normalized
|
||||
.iter()
|
||||
.map(u32::to_string)
|
||||
.collect::<Vec<_>>()
|
||||
.join(",");
|
||||
crate::modules::save_settings(
|
||||
root,
|
||||
meta,
|
||||
"custom-races",
|
||||
&BTreeMap::from([
|
||||
(KEY.into(), format!("\"{value}\"")),
|
||||
(
|
||||
CATALOG_KEY.into(),
|
||||
format!(
|
||||
"\"{}\"",
|
||||
if normalized.is_empty() {
|
||||
""
|
||||
} else {
|
||||
¤t.catalog_sha256
|
||||
}
|
||||
),
|
||||
),
|
||||
]),
|
||||
)?;
|
||||
status(root)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn dbc() -> Vec<u8> {
|
||||
let mut bytes = b"WDBC".to_vec();
|
||||
for value in [4u32, 69, 276, 11] {
|
||||
bytes.extend(value.to_le_bytes());
|
||||
}
|
||||
for id in [1u32, 82, 83, 97] {
|
||||
let mut row = vec![0; 276];
|
||||
row[..4].copy_from_slice(&id.to_le_bytes());
|
||||
row[4..8].copy_from_slice(&12u32.to_le_bytes());
|
||||
row[56..60].copy_from_slice(&1u32.to_le_bytes());
|
||||
bytes.extend(row);
|
||||
}
|
||||
bytes.extend(b"\0Synthetic\0");
|
||||
bytes
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn catalog_preserves_ids_and_excludes_stock_and_nonplayable() {
|
||||
let mut bytes = dbc();
|
||||
bytes[20 + 276 + 4] |= 1;
|
||||
let races = catalog(&bytes).unwrap();
|
||||
assert_eq!(
|
||||
races.iter().map(|race| race.id).collect::<Vec<_>>(),
|
||||
[83, 97]
|
||||
);
|
||||
assert_eq!(races[0].name, "Synthetic");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_corrupt_layout_bounds_ids_and_names() {
|
||||
for (offset, value) in [
|
||||
(4, 0),
|
||||
(8, 68),
|
||||
(12, 272),
|
||||
(16, 100),
|
||||
(20, 0),
|
||||
(20 + 276, 1),
|
||||
(20 + 56, 999),
|
||||
] {
|
||||
let mut bytes = dbc();
|
||||
bytes[offset..offset + 4].copy_from_slice(&(value as u32).to_le_bytes());
|
||||
assert!(catalog(&bytes).is_err(), "offset {offset}");
|
||||
}
|
||||
assert!(catalog(&dbc()[..19]).is_err());
|
||||
assert!(catalog(&dbc()[..100]).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn disabled_set_is_strict_and_atomic() {
|
||||
let races = catalog(&dbc()).unwrap();
|
||||
assert_eq!(
|
||||
parse_disabled("\"97,82\"", &races).unwrap(),
|
||||
BTreeSet::from([82, 97])
|
||||
);
|
||||
assert!(parse_disabled("\"\"", &races).unwrap().is_empty());
|
||||
for value in [
|
||||
"82,1", "82,82", "82,250", "82,", "-82", "+82", "82,1-97", "82x", "0",
|
||||
] {
|
||||
assert!(parse_disabled(value, &races).is_err(), "{value}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn status_uses_current_config_and_requires_server_capability() {
|
||||
let temporary = tempfile::tempdir().unwrap();
|
||||
let root = temporary.path();
|
||||
fs::create_dir_all(root.join("Data/dbc_races")).unwrap();
|
||||
fs::create_dir_all(root.join("Core/configs/modules")).unwrap();
|
||||
fs::write(root.join("Data/dbc_races/ChrRaces.dbc"), dbc()).unwrap();
|
||||
fs::write(root.join(CONF), format!("{KEY} = \"82\"\n")).unwrap();
|
||||
let before = status(root).unwrap();
|
||||
assert!(!before.server_config_supported);
|
||||
assert_eq!(before.disabled_race_ids, BTreeSet::from([82]));
|
||||
fs::write(
|
||||
root.join(format!("{CONF}.dist")),
|
||||
format!("{KEY} = \"\"\n{CATALOG_KEY} = \"\"\n"),
|
||||
)
|
||||
.unwrap();
|
||||
assert!(!status(root).unwrap().server_config_supported);
|
||||
fs::write(
|
||||
root.join("Core/worldserver.exe"),
|
||||
format!("{KEY} {CATALOG_KEY}"),
|
||||
)
|
||||
.unwrap();
|
||||
let after = status(root).unwrap();
|
||||
assert!(after.server_config_supported);
|
||||
assert_eq!(before.catalog_sha256, after.catalog_sha256);
|
||||
}
|
||||
|
||||
fn server(root: &Path) {
|
||||
fs::create_dir_all(root.join("Data/dbc_races")).unwrap();
|
||||
fs::create_dir_all(root.join("Core/configs/modules")).unwrap();
|
||||
fs::write(
|
||||
root.join("Core/worldserver.exe"),
|
||||
format!("{KEY} {CATALOG_KEY}"),
|
||||
)
|
||||
.unwrap();
|
||||
fs::create_dir_all(root.join("Settings")).unwrap();
|
||||
fs::write(
|
||||
root.join("Settings/repack.json"),
|
||||
r#"{"worldPort":0,"authPort":0,"mysqlPort":0,"raPort":0}"#,
|
||||
)
|
||||
.unwrap();
|
||||
fs::write(root.join("Data/dbc_races/ChrRaces.dbc"), dbc()).unwrap();
|
||||
fs::write(
|
||||
root.join(CONF),
|
||||
format!("CoACustomRaces.Enable = 1\n{KEY} = \"82\"\nUser.Custom = 42\n"),
|
||||
)
|
||||
.unwrap();
|
||||
fs::write(
|
||||
root.join(format!("{CONF}.dist")),
|
||||
format!("CoACustomRaces.Enable = 0\n{KEY} = \"\"\n{CATALOG_KEY} = \"\"\n"),
|
||||
)
|
||||
.unwrap();
|
||||
fs::write(
|
||||
root.join("Core/configs/modules/playerbots.conf"),
|
||||
"AiPlayerbot.ExcludedBotRaces = \"1,83\"\nAiPlayerbot.CrashingBotRaces = \"97\"\n",
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn saving_and_allow_all_preserve_user_settings_and_bot_exclusions() {
|
||||
let temporary = tempfile::tempdir().unwrap();
|
||||
let root = temporary.path().join("server");
|
||||
let meta = temporary.path().join("metadata");
|
||||
server(&root);
|
||||
let hash = status(&root).unwrap().catalog_sha256;
|
||||
let bot_path = root.join("Core/configs/modules/playerbots.conf");
|
||||
let bot_before = fs::read(&bot_path).unwrap();
|
||||
let saved = save(&root, &meta, &hash, crate::realms::Mode::Coa, &[97, 83]).unwrap();
|
||||
assert_eq!(saved.disabled_race_ids, BTreeSet::from([83, 97]));
|
||||
assert!(!saved.catalog_needs_review);
|
||||
assert!(fs::read_to_string(root.join(CONF)).unwrap().contains(&hash));
|
||||
assert!(fs::read_to_string(root.join(CONF))
|
||||
.unwrap()
|
||||
.contains("User.Custom = 42"));
|
||||
assert_eq!(fs::read(&bot_path).unwrap(), bot_before);
|
||||
assert!(save(&root, &meta, &hash, crate::realms::Mode::Coa, &[])
|
||||
.unwrap()
|
||||
.disabled_race_ids
|
||||
.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stale_catalog_and_invalid_lists_cannot_change_configuration() {
|
||||
let temporary = tempfile::tempdir().unwrap();
|
||||
let root = temporary.path().join("server");
|
||||
let meta = temporary.path().join("metadata");
|
||||
server(&root);
|
||||
let hash = status(&root).unwrap().catalog_sha256;
|
||||
let before = fs::read(root.join(CONF)).unwrap();
|
||||
assert!(save(&root, &meta, "stale", crate::realms::Mode::Coa, &[83]).is_err());
|
||||
for ids in [&[82, 1][..], &[82, 82][..], &[250][..]] {
|
||||
assert!(save(&root, &meta, &hash, crate::realms::Mode::Coa, ids).is_err());
|
||||
assert_eq!(fs::read(root.join(CONF)).unwrap(), before);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn switching_realms_cannot_apply_a_draft_from_another_profile() {
|
||||
let temporary = tempfile::tempdir().unwrap();
|
||||
let root = temporary.path().join("server");
|
||||
let meta = temporary.path().join("metadata");
|
||||
server(&root);
|
||||
let loaded = status(&root).unwrap();
|
||||
let before = fs::read(root.join(CONF)).unwrap();
|
||||
let realm = crate::realms::RealmState {
|
||||
active: crate::realms::Mode::Wildcard,
|
||||
..Default::default()
|
||||
};
|
||||
fs::write(
|
||||
root.join("Settings/realm-profile.json"),
|
||||
serde_json::to_vec(&realm).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
assert!(save(&root, &meta, &loaded.catalog_sha256, loaded.realm, &[83]).is_err());
|
||||
assert_eq!(fs::read(root.join(CONF)).unwrap(), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn concurrent_server_operations_cannot_change_policy() {
|
||||
let temporary = tempfile::tempdir().unwrap();
|
||||
let root = temporary.path().join("server");
|
||||
let meta = temporary.path().join("metadata");
|
||||
server(&root);
|
||||
fs::create_dir_all(root.join(".state")).unwrap();
|
||||
let lock = fs::OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create(true)
|
||||
.truncate(false)
|
||||
.open(root.join(".state/control.lock"))
|
||||
.unwrap();
|
||||
assert!(fs4::fs_std::FileExt::try_lock_exclusive(&lock).unwrap());
|
||||
let loaded = status(&root).unwrap();
|
||||
let before = fs::read(root.join(CONF)).unwrap();
|
||||
assert!(save(&root, &meta, &loaded.catalog_sha256, loaded.realm, &[83]).is_err());
|
||||
assert_eq!(fs::read(root.join(CONF)).unwrap(), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn relative_data_dir_uses_the_worldserver_working_directory() {
|
||||
let temporary = tempfile::tempdir().unwrap();
|
||||
let root = temporary.path().join("server");
|
||||
server(&root);
|
||||
fs::write(
|
||||
root.join("Core/configs/worldserver.conf"),
|
||||
"DataDir = \"../Data\"\n",
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(status(&root).unwrap().races.len(), 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn changed_catalog_requires_explicit_review_and_unknown_ids_are_not_valid_races() {
|
||||
let temporary = tempfile::tempdir().unwrap();
|
||||
let root = temporary.path().join("server");
|
||||
let meta = temporary.path().join("metadata");
|
||||
server(&root);
|
||||
let loaded = status(&root).unwrap();
|
||||
assert!(loaded.catalog_needs_review);
|
||||
save(&root, &meta, &loaded.catalog_sha256, loaded.realm, &[82]).unwrap();
|
||||
assert!(!status(&root).unwrap().catalog_needs_review);
|
||||
let mut changed = dbc();
|
||||
changed[20 + 276..24 + 276].copy_from_slice(&84u32.to_le_bytes());
|
||||
fs::write(root.join("Data/dbc_races/ChrRaces.dbc"), changed).unwrap();
|
||||
let updated = status(&root).unwrap();
|
||||
assert!(updated.catalog_needs_review);
|
||||
assert_eq!(updated.unrecognized_race_ids, BTreeSet::from([82]));
|
||||
assert!(!updated.races.iter().any(|race| race.id == 82));
|
||||
assert!(updated.disabled_race_ids.is_empty());
|
||||
let reviewed = save(&root, &meta, &updated.catalog_sha256, updated.realm, &[]).unwrap();
|
||||
assert!(!reviewed.catalog_needs_review);
|
||||
assert!(reviewed.unrecognized_race_ids.is_empty());
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,10 @@ pub fn find_access(
|
||||
st.active == crate::realms::Mode::Wildcard
|
||||
|| (st.simultaneous && st.wildcard_created)
|
||||
}
|
||||
crate::realms::Mode::Reborn => st.active == crate::realms::Mode::Reborn,
|
||||
crate::realms::Mode::Reborn => {
|
||||
st.active == crate::realms::Mode::Reborn
|
||||
|| (st.with_reborn && st.reborn_created)
|
||||
}
|
||||
};
|
||||
if !supported {
|
||||
return None;
|
||||
|
||||
+300
-50
@@ -63,15 +63,50 @@ pub struct RealmState {
|
||||
pub wildcard_created: bool,
|
||||
#[serde(default)]
|
||||
pub reborn_created: bool,
|
||||
/// Wildcard starts together with Conquest of Azeroth (the second of the two when Wildcard is the primary realm).
|
||||
#[serde(default)]
|
||||
pub simultaneous: bool,
|
||||
#[serde(default)]
|
||||
pub secondary_world_port: Option<u16>,
|
||||
#[serde(default)]
|
||||
pub secondary_ra_port: Option<u16>,
|
||||
/// Warcraft Reborn starts together with Conquest of Azeroth, which is then the primary realm.
|
||||
#[serde(default)]
|
||||
pub with_reborn: bool,
|
||||
#[serde(default)]
|
||||
pub reborn_world_port: Option<u16>,
|
||||
#[serde(default)]
|
||||
pub reborn_ra_port: Option<u16>,
|
||||
}
|
||||
|
||||
impl RealmState {
|
||||
/// World ports of the realms that run next to the primary one (the ones that are switched on).
|
||||
pub fn extra_world_ports(&self) -> Vec<u16> {
|
||||
[
|
||||
self.secondary_world_port.filter(|_| self.simultaneous),
|
||||
self.reborn_world_port.filter(|_| self.with_reborn),
|
||||
]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Realms that run as a world of their own next to the primary one.
|
||||
pub fn extra_modes(&self) -> Vec<Mode> {
|
||||
let mut modes = Vec::new();
|
||||
if self.simultaneous {
|
||||
modes.push(if self.active == Mode::Coa {
|
||||
Mode::Wildcard
|
||||
} else {
|
||||
Mode::Coa
|
||||
});
|
||||
}
|
||||
if self.with_reborn {
|
||||
modes.push(Mode::Reborn);
|
||||
}
|
||||
modes
|
||||
}
|
||||
|
||||
pub fn created(&self, mode: Mode) -> bool {
|
||||
match mode {
|
||||
Mode::Coa => true,
|
||||
@@ -101,6 +136,9 @@ pub struct View {
|
||||
pub simultaneous: bool,
|
||||
pub secondary_world_port: Option<u16>,
|
||||
pub secondary_running: bool,
|
||||
pub with_reborn: bool,
|
||||
pub reborn_world_port: Option<u16>,
|
||||
pub reborn_running: bool,
|
||||
}
|
||||
|
||||
pub fn state(root: &Path) -> Result<RealmState> {
|
||||
@@ -139,7 +177,10 @@ pub fn view(root: &Path) -> Result<View> {
|
||||
recovery_pending: root.join(JOURNAL).exists(),
|
||||
simultaneous: s.simultaneous,
|
||||
secondary_world_port: s.secondary_world_port,
|
||||
secondary_running: crate::multiworld::is_running(root),
|
||||
secondary_running: crate::multiworld::tree_running(root, crate::multiworld::Tree::Second),
|
||||
with_reborn: s.with_reborn,
|
||||
reborn_world_port: s.reborn_world_port,
|
||||
reborn_running: crate::multiworld::tree_running(root, crate::multiworld::Tree::Reborn),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -447,6 +488,58 @@ fn create_databases(root: &Path, mode: Mode) -> Result<()> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Create the saved settings and the databases of a realm that was never set up. `before` is the current
|
||||
/// configuration, the base of a new realm while Conquest of Azeroth is the active one.
|
||||
fn create_realm(root: &Path, s: &mut RealmState, mode: Mode, before: &Files) -> Result<()> {
|
||||
if s.created(mode) {
|
||||
return Ok(());
|
||||
}
|
||||
let base = if s.active == Mode::Coa {
|
||||
before.clone()
|
||||
} else {
|
||||
fsx::read_json(&snapshot(root, Mode::Coa))?
|
||||
};
|
||||
let files = match mode {
|
||||
Mode::Wildcard => wildcard_configs(base)?,
|
||||
Mode::Reborn => reborn_configs(base)?,
|
||||
Mode::Coa => unreachable!(),
|
||||
};
|
||||
fsx::atomic_write_json(&snapshot(root, mode), &files)?;
|
||||
create_databases(root, mode)?;
|
||||
match mode {
|
||||
Mode::Wildcard => s.wildcard_created = true,
|
||||
Mode::Reborn => s.reborn_created = true,
|
||||
Mode::Coa => {}
|
||||
}
|
||||
fsx::atomic_write_json(&root.join(STATE), s)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set a realm up without making it the active one, so it can start next to the active realm.
|
||||
pub fn ensure_created(root: &Path, mode: Mode) -> Result<()> {
|
||||
let meta = crate::registry::metadata_dir_for(root)?;
|
||||
let _update_lock = crate::update::operation_lock(&meta)?;
|
||||
crate::update::ensure_recovered(&meta)?;
|
||||
require_world_stopped(root)?;
|
||||
recover(root)?;
|
||||
let mut s = state(root)?;
|
||||
let supported = view(root)?;
|
||||
if mode == Mode::Wildcard && !supported.supported {
|
||||
return Err(Error::Invalid(
|
||||
"Update the server to a build with Wildcard support first.".into(),
|
||||
));
|
||||
}
|
||||
if mode == Mode::Reborn && !supported.reborn_supported {
|
||||
return Err(Error::Invalid(
|
||||
"Update the server to a build with Warcraft Reborn support first.".into(),
|
||||
));
|
||||
}
|
||||
// Verify launcher support before creating databases, as selecting a realm does.
|
||||
prepare_launcher(root)?;
|
||||
let before = configs(root)?;
|
||||
create_realm(root, &mut s, mode, &before)
|
||||
}
|
||||
|
||||
pub fn select(root: &Path, mode: Mode) -> Result<View> {
|
||||
let meta = crate::registry::metadata_dir_for(root)?;
|
||||
let _update_lock = crate::update::operation_lock(&meta)?;
|
||||
@@ -467,35 +560,16 @@ pub fn select(root: &Path, mode: Mode) -> Result<View> {
|
||||
"Update the server to a build with Warcraft Reborn support first.".into(),
|
||||
));
|
||||
}
|
||||
if s.simultaneous && mode != s.active {
|
||||
if (s.simultaneous || s.with_reborn) && mode != s.active {
|
||||
return Err(Error::Invalid(
|
||||
"Disable simultaneous startup before switching realms.".into(),
|
||||
"Disable the realms that start together before switching realms.".into(),
|
||||
));
|
||||
}
|
||||
// Verify launcher support before creating databases or changing the selected realm.
|
||||
prepare_launcher(root)?;
|
||||
let before = configs(root)?;
|
||||
fsx::atomic_write_json(&snapshot(root, s.active), &before)?;
|
||||
if !s.created(mode) {
|
||||
let base = if s.active == Mode::Coa {
|
||||
before.clone()
|
||||
} else {
|
||||
fsx::read_json(&snapshot(root, Mode::Coa))?
|
||||
};
|
||||
let files = match mode {
|
||||
Mode::Wildcard => wildcard_configs(base)?,
|
||||
Mode::Reborn => reborn_configs(base)?,
|
||||
Mode::Coa => unreachable!(),
|
||||
};
|
||||
fsx::atomic_write_json(&snapshot(root, mode), &files)?;
|
||||
create_databases(root, mode)?;
|
||||
match mode {
|
||||
Mode::Wildcard => s.wildcard_created = true,
|
||||
Mode::Reborn => s.reborn_created = true,
|
||||
Mode::Coa => {}
|
||||
}
|
||||
fsx::atomic_write_json(&root.join(STATE), &s)?;
|
||||
}
|
||||
create_realm(root, &mut s, mode, &before)?;
|
||||
let target: Files = fsx::read_json(&snapshot(root, mode))?;
|
||||
// The launcher and batch files share this lock; recheck after the potentially long database copy.
|
||||
fs::create_dir_all(root.join(".state"))?;
|
||||
@@ -653,9 +727,46 @@ pub(crate) fn unpatch_launcher(source: &str) -> Option<String> {
|
||||
(check == source).then_some(original)
|
||||
}
|
||||
|
||||
/// The character-creation model the world server advertises for a realm. Every realm has its own database and its own
|
||||
/// entry on Overview, so it advertises exactly one model: a list such as `"coa wcr"` would let players create
|
||||
/// Warcraft Reborn characters in the Conquest of Azeroth realm.
|
||||
fn class_model_for(mode: Mode) -> &'static str {
|
||||
match mode {
|
||||
Mode::Coa => "coa",
|
||||
Mode::Wildcard => "hero",
|
||||
Mode::Reborn => "wcr",
|
||||
}
|
||||
}
|
||||
|
||||
/// The client builds its character-creation screen from `CoA.ClassModel`, so a realm whose setting lacks its own
|
||||
/// model would show the wrong screen (a Conquest of Azeroth realm set to `"hero"` has no classes). The realm chosen in
|
||||
/// the Manager wins: any other setting is replaced by the realm's own model.
|
||||
/// A missing key means the server default, `"coa"`; a missing file is left to the server.
|
||||
fn align_class_model(root: &Path, mode: Mode) -> Result<()> {
|
||||
let path = root.join("Core/configs/modules/coa.conf");
|
||||
let Ok(bytes) = fs::read(&path) else {
|
||||
return Ok(());
|
||||
};
|
||||
let mut conf = ConfFile::parse_bytes(&bytes)?;
|
||||
let current = conf
|
||||
.get("CoA.ClassModel")
|
||||
.map(crate::config::parser::unquote)
|
||||
.unwrap_or("coa")
|
||||
.to_string();
|
||||
let wanted = class_model_for(mode);
|
||||
if current.split_whitespace().eq([wanted]) {
|
||||
return Ok(());
|
||||
}
|
||||
conf.set("CoA.ClassModel", &format!("\"{wanted}\""), &[]);
|
||||
fsx::atomic_write(&path, conf.to_text().as_bytes())?;
|
||||
tracing::warn!(realm = mode.name(), from = %current, to = wanted, "CoA.ClassModel did not fit the selected realm and was corrected");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn before_start(root: &Path) -> Result<()> {
|
||||
recover(root)?;
|
||||
let s = state(root)?;
|
||||
align_class_model(root, s.active)?;
|
||||
if !root.join(STATE).exists() {
|
||||
return Ok(());
|
||||
}
|
||||
@@ -665,12 +776,22 @@ pub fn before_start(root: &Path) -> Result<()> {
|
||||
"The installed server build does not support simultaneous Wildcard startup.".into(),
|
||||
));
|
||||
}
|
||||
if s.simultaneous && s.active == Mode::Reborn {
|
||||
if (s.simultaneous || s.with_reborn) && s.active == Mode::Reborn {
|
||||
return Err(Error::Invalid(
|
||||
"Simultaneous startup supports CoA and Wildcard only.".into(),
|
||||
"Realms that start together need Conquest of Azeroth or Wildcard as the main realm.".into(),
|
||||
));
|
||||
}
|
||||
if s.simultaneous {
|
||||
if s.with_reborn && s.active != Mode::Coa {
|
||||
return Err(Error::Invalid(
|
||||
"Warcraft Reborn can start together with Conquest of Azeroth only. Select Conquest of Azeroth first.".into(),
|
||||
));
|
||||
}
|
||||
if s.with_reborn && !view(root)?.reborn_supported {
|
||||
return Err(Error::Invalid(
|
||||
"The installed server build does not support Warcraft Reborn.".into(),
|
||||
));
|
||||
}
|
||||
if s.simultaneous || s.with_reborn {
|
||||
fsx::atomic_write_json(&snapshot(root, s.active), &configs(root)?)?;
|
||||
}
|
||||
if s.active == Mode::Reborn && !view(root)?.reborn_supported {
|
||||
@@ -734,37 +855,38 @@ pub fn setup_realmlist(root: &Path) -> Result<()> {
|
||||
};
|
||||
db.query(&format!("UPDATE acore_auth.realmlist SET port=CASE id WHEN 1 THEN {coa} ELSE {wildcard} END,flag=0 WHERE id IN (1,2);"))?;
|
||||
}
|
||||
if s.with_reborn {
|
||||
let reborn = s
|
||||
.reborn_world_port
|
||||
.ok_or_else(|| Error::Invalid("Warcraft Reborn realm port is missing.".into()))?;
|
||||
db.query(&format!(
|
||||
"UPDATE acore_auth.realmlist SET port={reborn},flag=0 WHERE id={};",
|
||||
Mode::Reborn.realm_id()
|
||||
))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn world_port_for_mode(root: &Path, mode: Mode) -> Result<u16> {
|
||||
let ports = crate::layout::read_ports(root);
|
||||
let s = state(root)?;
|
||||
if s.simultaneous {
|
||||
let second = s
|
||||
.secondary_world_port
|
||||
.ok_or_else(|| Error::Invalid("Second realm port is missing.".into()))?;
|
||||
let port = match (s.active, mode) {
|
||||
(Mode::Coa, Mode::Coa) => ports.world,
|
||||
(Mode::Coa, Mode::Wildcard) => second,
|
||||
(Mode::Wildcard, Mode::Wildcard) => ports.world,
|
||||
(Mode::Wildcard, Mode::Coa) => second,
|
||||
_ => {
|
||||
return Err(Error::Invalid(format!(
|
||||
"Unsupported mode {mode:?} for simultaneous hosting (active: {:?})",
|
||||
s.active
|
||||
)))
|
||||
}
|
||||
};
|
||||
Ok(port)
|
||||
} else if mode == s.active {
|
||||
Ok(ports.world)
|
||||
} else {
|
||||
Err(Error::Invalid(format!(
|
||||
"Realm mode {mode:?} is not active (active: {:?}) and simultaneous mode is disabled.",
|
||||
s.active
|
||||
)))
|
||||
if mode == s.active {
|
||||
return Ok(ports.world);
|
||||
}
|
||||
if mode == Mode::Reborn && s.with_reborn && s.active == Mode::Coa {
|
||||
return s
|
||||
.reborn_world_port
|
||||
.ok_or_else(|| Error::Invalid("Warcraft Reborn realm port is missing.".into()));
|
||||
}
|
||||
if s.simultaneous && matches!((s.active, mode), (Mode::Coa, Mode::Wildcard) | (Mode::Wildcard, Mode::Coa)) {
|
||||
return s
|
||||
.secondary_world_port
|
||||
.ok_or_else(|| Error::Invalid("Second realm port is missing.".into()));
|
||||
}
|
||||
Err(Error::Invalid(format!(
|
||||
"Realm mode {mode:?} is not active (active: {:?}) and simultaneous mode is disabled.",
|
||||
s.active
|
||||
)))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -838,6 +960,134 @@ mod tests {
|
||||
assert!(guard_module(t.path(), "content-scaling").is_ok());
|
||||
}
|
||||
|
||||
fn write_class_model(root: &Path, text: &str) {
|
||||
fsx::atomic_write(&root.join("Core/configs/modules/coa.conf"), text.as_bytes()).unwrap();
|
||||
}
|
||||
|
||||
fn class_model(root: &Path) -> String {
|
||||
let bytes = fs::read(root.join("Core/configs/modules/coa.conf")).unwrap();
|
||||
ConfFile::parse_bytes(&bytes)
|
||||
.unwrap()
|
||||
.get("CoA.ClassModel")
|
||||
.unwrap_or_default()
|
||||
.to_string()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_class_model_that_does_not_fit_the_realm_is_replaced_by_the_realms_own() {
|
||||
let t = tempfile::tempdir().unwrap();
|
||||
// No file: left to the server. No key: the server default "coa" applies, which fits Conquest of Azeroth.
|
||||
align_class_model(t.path(), Mode::Coa).unwrap();
|
||||
assert!(!t.path().join("Core/configs/modules/coa.conf").exists());
|
||||
write_class_model(t.path(), "[worldserver]
|
||||
# CoA.ClassModel = \"hero\"
|
||||
");
|
||||
align_class_model(t.path(), Mode::Coa).unwrap();
|
||||
assert_eq!(class_model(t.path()), "");
|
||||
|
||||
write_class_model(t.path(), "# note
|
||||
CoA.ClassModel = \"hero\"
|
||||
CoA.GameModeMask = 0
|
||||
");
|
||||
align_class_model(t.path(), Mode::Coa).unwrap();
|
||||
assert_eq!(
|
||||
fs::read_to_string(t.path().join("Core/configs/modules/coa.conf")).unwrap(),
|
||||
"# note
|
||||
CoA.ClassModel = \"coa\"
|
||||
CoA.GameModeMask = 0
|
||||
"
|
||||
);
|
||||
align_class_model(t.path(), Mode::Wildcard).unwrap();
|
||||
assert_eq!(class_model(t.path()), "\"hero\"");
|
||||
align_class_model(t.path(), Mode::Reborn).unwrap();
|
||||
assert_eq!(class_model(t.path()), "\"wcr\"");
|
||||
|
||||
// A missing key does not fit a realm other than Conquest of Azeroth.
|
||||
write_class_model(t.path(), "[worldserver]
|
||||
");
|
||||
align_class_model(t.path(), Mode::Wildcard).unwrap();
|
||||
assert_eq!(class_model(t.path()), "\"hero\"");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_class_model_list_is_narrowed_to_the_realms_own_model() {
|
||||
let t = tempfile::tempdir().unwrap();
|
||||
// The shipped default serves two models; the realm chosen in the Manager keeps only its own.
|
||||
for (mode, want) in [(Mode::Coa, "\"coa\""), (Mode::Reborn, "\"wcr\"")] {
|
||||
write_class_model(t.path(), "CoA.ClassModel = \"coa wcr\"
|
||||
");
|
||||
align_class_model(t.path(), mode).unwrap();
|
||||
assert_eq!(class_model(t.path()), want);
|
||||
}
|
||||
// A setting that is already exactly right is not rewritten, quoted or not.
|
||||
for (text, mode) in [
|
||||
("CoA.ClassModel = \"coa\"
|
||||
", Mode::Coa),
|
||||
("CoA.ClassModel = hero
|
||||
", Mode::Wildcard),
|
||||
] {
|
||||
write_class_model(t.path(), text);
|
||||
align_class_model(t.path(), mode).unwrap();
|
||||
assert_eq!(
|
||||
fs::read_to_string(t.path().join("Core/configs/modules/coa.conf")).unwrap(),
|
||||
text
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn before_start_aligns_the_class_model_with_the_active_realm() {
|
||||
let t = tempfile::tempdir().unwrap();
|
||||
write_class_model(t.path(), "CoA.ClassModel = \"hero\"
|
||||
");
|
||||
before_start(t.path()).unwrap();
|
||||
assert_eq!(class_model(t.path()), "\"coa\"");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extra_realms_follow_the_two_switches_and_old_states_still_load() {
|
||||
let old: RealmState = serde_json::from_str(
|
||||
r#"{"active":"coa","wildcard_created":true,"simultaneous":true,"secondary_world_port":8086}"#,
|
||||
)
|
||||
.unwrap();
|
||||
assert!(!old.with_reborn && old.reborn_world_port.is_none());
|
||||
assert_eq!(old.extra_modes(), [Mode::Wildcard]);
|
||||
let mut s = RealmState::default();
|
||||
assert!(s.extra_modes().is_empty());
|
||||
s.with_reborn = true;
|
||||
assert_eq!(s.extra_modes(), [Mode::Reborn]);
|
||||
s.simultaneous = true;
|
||||
assert_eq!(s.extra_modes(), [Mode::Wildcard, Mode::Reborn]);
|
||||
s.secondary_world_port = Some(8086);
|
||||
s.reborn_world_port = Some(8087);
|
||||
assert_eq!(s.extra_world_ports(), [8086, 8087]);
|
||||
s.with_reborn = false;
|
||||
assert_eq!(s.extra_world_ports(), [8086]);
|
||||
s.with_reborn = true;
|
||||
// Wildcard as the main realm still pairs with Conquest of Azeroth.
|
||||
s.active = Mode::Wildcard;
|
||||
s.with_reborn = false;
|
||||
assert_eq!(s.extra_modes(), [Mode::Coa]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn each_running_realm_has_its_own_world_port() {
|
||||
let t = tempfile::tempdir().unwrap();
|
||||
fsx::atomic_write(&t.path().join("Settings/repack.json"), br#"{"worldPort": 8085}"#).unwrap();
|
||||
let write = |json: &str| fsx::atomic_write(&t.path().join(STATE), json.as_bytes()).unwrap();
|
||||
write(r#"{"active":"coa","wildcard_created":true,"reborn_created":true,"simultaneous":true,"secondary_world_port":8086,"with_reborn":true,"reborn_world_port":8087}"#);
|
||||
assert_eq!(world_port_for_mode(t.path(), Mode::Coa).unwrap(), 8085);
|
||||
assert_eq!(world_port_for_mode(t.path(), Mode::Wildcard).unwrap(), 8086);
|
||||
assert_eq!(world_port_for_mode(t.path(), Mode::Reborn).unwrap(), 8087);
|
||||
// Only Reborn next to Conquest of Azeroth: Wildcard is not running anywhere.
|
||||
write(r#"{"active":"coa","wildcard_created":true,"reborn_created":true,"with_reborn":true,"reborn_world_port":8087}"#);
|
||||
assert_eq!(world_port_for_mode(t.path(), Mode::Reborn).unwrap(), 8087);
|
||||
assert!(world_port_for_mode(t.path(), Mode::Wildcard).is_err());
|
||||
// Reborn only pairs with Conquest of Azeroth as the main realm.
|
||||
write(r#"{"active":"wildcard","wildcard_created":true,"reborn_created":true,"with_reborn":true,"reborn_world_port":8087}"#);
|
||||
assert!(world_port_for_mode(t.path(), Mode::Reborn).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reborn_support_requires_the_new_code_in_the_installed_binary() {
|
||||
let t = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -21,22 +21,33 @@ pub struct SqlFile {
|
||||
pub sha256: String,
|
||||
}
|
||||
|
||||
fn sql_in(dir: &Path) -> Vec<PathBuf> {
|
||||
let mut v: Vec<PathBuf> = fs::read_dir(dir)
|
||||
.map(|rd| {
|
||||
rd.flatten()
|
||||
.map(|e| e.path())
|
||||
.filter(|p| p.extension().map(|e| e == "sql").unwrap_or(false))
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default();
|
||||
v.sort();
|
||||
v
|
||||
fn entries(dir: &Path) -> Result<Vec<fs::DirEntry>> {
|
||||
match fs::read_dir(dir) {
|
||||
Ok(rd) => Ok(rd.collect::<std::io::Result<Vec<_>>>()?),
|
||||
Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(vec![]),
|
||||
Err(error) => Err(error.into()),
|
||||
}
|
||||
}
|
||||
|
||||
fn sql_in(dir: &Path) -> Result<Vec<PathBuf>> {
|
||||
let mut paths: Vec<_> = entries(dir)?
|
||||
.into_iter()
|
||||
.map(|entry| entry.path())
|
||||
.filter(|path| path.extension().is_some_and(|ext| ext == "sql"))
|
||||
.collect();
|
||||
paths.sort();
|
||||
Ok(paths)
|
||||
}
|
||||
|
||||
/// The order in which files were first added to the repository (a pending script may rely on a table a module
|
||||
/// created earlier). Files git does not know come last, in name order.
|
||||
fn introduction_rank(repo: &Path, pathspecs: &[&str]) -> std::collections::HashMap<String, usize> {
|
||||
fn introduction_rank(
|
||||
repo: &Path,
|
||||
pathspecs: &[&str],
|
||||
) -> Result<std::collections::HashMap<String, usize>> {
|
||||
if !repo.join(".git").exists() {
|
||||
return Ok(Default::default());
|
||||
}
|
||||
let mut args = vec![
|
||||
"log",
|
||||
"--full-history",
|
||||
@@ -48,18 +59,22 @@ fn introduction_rank(repo: &Path, pathspecs: &[&str]) -> std::collections::HashM
|
||||
"--",
|
||||
];
|
||||
args.extend_from_slice(pathspecs);
|
||||
let out = Command::new("git").current_dir(repo).args(&args).output();
|
||||
let mut rank = std::collections::HashMap::new();
|
||||
if let Ok(o) = out {
|
||||
for (i, line) in String::from_utf8_lossy(&o.stdout)
|
||||
.lines()
|
||||
.filter(|l| l.ends_with(".sql"))
|
||||
.enumerate()
|
||||
{
|
||||
rank.entry(line.to_string()).or_insert(i);
|
||||
}
|
||||
let out = Command::new("git").current_dir(repo).args(&args).output()?;
|
||||
if !out.status.success() {
|
||||
return Err(Error::Invalid(format!(
|
||||
"Cannot establish SQL migration order: {}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
)));
|
||||
}
|
||||
rank
|
||||
let mut rank = std::collections::HashMap::new();
|
||||
for (i, line) in String::from_utf8_lossy(&out.stdout)
|
||||
.lines()
|
||||
.filter(|line| line.ends_with(".sql"))
|
||||
.enumerate()
|
||||
{
|
||||
rank.entry(line.to_string()).or_insert(i);
|
||||
}
|
||||
Ok(rank)
|
||||
}
|
||||
|
||||
/// Incremental SQL of a core checkout. Installation-only module bases must never be replayed on a live database.
|
||||
@@ -91,7 +106,7 @@ fn collect_core_sql_mode(core: &Path, include_base: bool) -> Result<Vec<SqlFile>
|
||||
("world", ["db_world", "pending_db_world"]),
|
||||
] {
|
||||
for d in dirs {
|
||||
for f in sql_in(&core.join("data/sql/updates").join(d)) {
|
||||
for f in sql_in(&core.join("data/sql/updates").join(d))? {
|
||||
let stem = f.file_stem().unwrap().to_string_lossy().into_owned();
|
||||
let rel = format!(
|
||||
"data/sql/updates/{d}/{}",
|
||||
@@ -101,8 +116,8 @@ fn collect_core_sql_mode(core: &Path, include_base: bool) -> Result<Vec<SqlFile>
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Ok(rd) = fs::read_dir(core.join("modules")) {
|
||||
let mut mods: Vec<_> = rd.flatten().collect();
|
||||
{
|
||||
let mut mods = entries(&core.join("modules"))?;
|
||||
mods.sort_by_key(|e| e.file_name());
|
||||
for m in mods {
|
||||
let name = m.file_name().to_string_lossy().into_owned();
|
||||
@@ -110,7 +125,7 @@ fn collect_core_sql_mode(core: &Path, include_base: bool) -> Result<Vec<SqlFile>
|
||||
for kind in ["auth", "characters", "world"] {
|
||||
let base = m.path().join(format!("data/sql/db-{kind}"));
|
||||
for f in if include_base {
|
||||
sql_in(&base.join("base"))
|
||||
sql_in(&base.join("base"))?
|
||||
} else {
|
||||
vec![]
|
||||
} {
|
||||
@@ -121,7 +136,7 @@ fn collect_core_sql_mode(core: &Path, include_base: bool) -> Result<Vec<SqlFile>
|
||||
);
|
||||
push(kind, format!("mod_{mname}__base__{stem}"), f, rel)?;
|
||||
}
|
||||
for f in sql_in(&base) {
|
||||
for f in sql_in(&base)? {
|
||||
let stem = f.file_stem().unwrap().to_string_lossy().into_owned();
|
||||
let rel = format!(
|
||||
"modules/{name}/data/sql/db-{kind}/{}",
|
||||
@@ -132,7 +147,7 @@ fn collect_core_sql_mode(core: &Path, include_base: bool) -> Result<Vec<SqlFile>
|
||||
}
|
||||
}
|
||||
}
|
||||
let rank = introduction_rank(core, &["data/sql/updates", "modules"]);
|
||||
let rank = introduction_rank(core, &["data/sql/updates", "modules"])?;
|
||||
out.sort_by_key(|f| rank.get(&f.origin).copied().unwrap_or(usize::MAX));
|
||||
Ok(out)
|
||||
}
|
||||
@@ -155,7 +170,7 @@ pub fn export_baseline(server: &Path, out: &Path) -> Result<Vec<(String, u64)>>
|
||||
/// SQL a bots module checkout ships for the characters database (its `dist/sql`).
|
||||
pub fn collect_bots_sql(bots: &Path) -> Result<Vec<SqlFile>> {
|
||||
let mut out = Vec::new();
|
||||
for f in sql_in(&bots.join("dist/sql")) {
|
||||
for f in sql_in(&bots.join("dist/sql"))? {
|
||||
let stem = f.file_stem().unwrap().to_string_lossy().into_owned();
|
||||
out.push(SqlFile {
|
||||
db: "characters".into(),
|
||||
@@ -364,6 +379,30 @@ mod tests {
|
||||
fs::write(p, c).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sql_collection_rejects_broken_history_in_a_git_checkout() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
write(dir.path(), ".git", "gitdir: missing-history");
|
||||
write(dir.path(), "data/sql/updates/db_world/one.sql", "SELECT 1;");
|
||||
assert!(collect_core_sql(dir.path())
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.contains("migration order"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sql_collection_rejects_unreadable_directories_instead_of_omitting_migrations() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
write(dir.path(), "data/sql/updates/db_world", "not a directory");
|
||||
assert!(collect_core_sql(dir.path()).is_err());
|
||||
let bots = tempfile::tempdir().unwrap();
|
||||
write(bots.path(), "dist/sql", "not a directory");
|
||||
assert!(collect_bots_sql(bots.path()).is_err());
|
||||
let modules = tempfile::tempdir().unwrap();
|
||||
write(modules.path(), "modules", "not a directory");
|
||||
assert!(collect_core_sql(modules.path()).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn collects_core_and_module_sql_with_module_base_first_and_stable_ids() {
|
||||
let d = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
//! Read-only, bounded canonical histories. Offline fallback is also bundled in the UI.
|
||||
use serde_json::Value;
|
||||
use std::{io::Read, path::Path, time::Duration};
|
||||
|
||||
const LIMIT: u64 = 2 * 1024 * 1024;
|
||||
|
||||
fn repository(component: &str) -> Result<(&'static str, &'static str), String> {
|
||||
match component {
|
||||
"server" => Ok(("Corfirean/coa-server-build", "main")),
|
||||
"manager" => Ok(("Corfirean/coa-server-manager", "master")),
|
||||
_ => Err("Unknown release component".into()),
|
||||
}
|
||||
}
|
||||
|
||||
fn validate(bytes: &[u8], component: &str) -> Result<Value, String> {
|
||||
let (repo, _) = repository(component)?;
|
||||
if bytes.len() as u64 > LIMIT {
|
||||
return Err("Release history is too large".into());
|
||||
}
|
||||
let value: Value = serde_json::from_slice(bytes).map_err(|e| e.to_string())?;
|
||||
if value["schema"] != 1 || value["component"] != component || value["repository"] != repo {
|
||||
return Err("Release history identity mismatch".into());
|
||||
}
|
||||
let releases = value["releases"].as_array().ok_or("Missing releases")?;
|
||||
if releases.len() > 2000 {
|
||||
return Err("Too many releases".into());
|
||||
}
|
||||
for release in releases {
|
||||
if release.get("prerelease").is_some_and(|v| !v.is_boolean())
|
||||
|| release.get("experimentalFeatures").is_some_and(|v| {
|
||||
v.as_array()
|
||||
.is_none_or(|items| items.iter().any(|item| !item.is_string()))
|
||||
})
|
||||
{
|
||||
return Err("Invalid release flags".into());
|
||||
}
|
||||
for field in ["tag", "date"] {
|
||||
if release[field]
|
||||
.as_str()
|
||||
.is_none_or(|s| s.is_empty() || s.len() > 100)
|
||||
{
|
||||
return Err("Invalid release metadata".into());
|
||||
}
|
||||
}
|
||||
let version = release["version"].as_str().ok_or("Missing version")?;
|
||||
if version.len() > 80
|
||||
|| !version
|
||||
.bytes()
|
||||
.all(|b| b.is_ascii_alphanumeric() || b".-+".contains(&b))
|
||||
{
|
||||
return Err("Invalid version".into());
|
||||
}
|
||||
let notes = release["notes"].as_array().ok_or("Missing notes")?;
|
||||
if notes.len() > 500
|
||||
|| notes
|
||||
.iter()
|
||||
.any(|n| n.as_str().is_none_or(|s| s.len() > 10000))
|
||||
{
|
||||
return Err("Invalid release notes".into());
|
||||
}
|
||||
}
|
||||
Ok(value)
|
||||
}
|
||||
|
||||
pub fn load(component: &str, cache_dir: &Path) -> Result<Value, String> {
|
||||
load_for_target(component, cache_dir, None)
|
||||
}
|
||||
|
||||
pub fn load_for_target(
|
||||
component: &str,
|
||||
cache_dir: &Path,
|
||||
target: Option<&str>,
|
||||
) -> Result<Value, String> {
|
||||
let (repo, branch) = repository(component)?;
|
||||
load_with_remote(component, cache_dir, target, || {
|
||||
let client = reqwest::blocking::Client::builder()
|
||||
.timeout(Duration::from_secs(8))
|
||||
.redirect(reqwest::redirect::Policy::none())
|
||||
.build()
|
||||
.map_err(|e| e.to_string())?;
|
||||
let response = client
|
||||
.get(format!(
|
||||
"https://raw.githubusercontent.com/{repo}/{branch}/changelog/history.json"
|
||||
))
|
||||
.query(&[("target", target.unwrap_or(""))])
|
||||
.header(reqwest::header::CACHE_CONTROL, "no-cache")
|
||||
.send()
|
||||
.and_then(|r| r.error_for_status())
|
||||
.map_err(|e| e.to_string())?;
|
||||
let mut bytes = Vec::new();
|
||||
response
|
||||
.take(LIMIT + 1)
|
||||
.read_to_end(&mut bytes)
|
||||
.map_err(|e| e.to_string())?;
|
||||
Ok(bytes)
|
||||
})
|
||||
}
|
||||
|
||||
fn load_with_remote(
|
||||
component: &str,
|
||||
cache_dir: &Path,
|
||||
target: Option<&str>,
|
||||
remote: impl FnOnce() -> Result<Vec<u8>, String>,
|
||||
) -> Result<Value, String> {
|
||||
repository(component)?;
|
||||
let cache = cache_dir.join(format!("{component}.json"));
|
||||
let cached = || {
|
||||
let mut bytes = Vec::new();
|
||||
std::fs::File::open(&cache)
|
||||
.ok()?
|
||||
.take(LIMIT + 1)
|
||||
.read_to_end(&mut bytes)
|
||||
.ok()?;
|
||||
validate(&bytes, component).ok()
|
||||
};
|
||||
if cache
|
||||
.metadata()
|
||||
.and_then(|m| m.modified())
|
||||
.ok()
|
||||
.and_then(|t| t.elapsed().ok())
|
||||
.is_some_and(|age| age < Duration::from_secs(3600))
|
||||
{
|
||||
if let Some(mut value) = cached() {
|
||||
if target.is_none_or(|target| {
|
||||
value["releases"].as_array().is_some_and(|releases| {
|
||||
releases
|
||||
.iter()
|
||||
.any(|release| release["version"].as_str() == Some(target))
|
||||
})
|
||||
}) {
|
||||
value["source"] = "cache".into();
|
||||
return Ok(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
let fetched = (|| {
|
||||
let bytes = remote()?;
|
||||
let mut value = validate(&bytes, component)?;
|
||||
if std::fs::create_dir_all(cache_dir).is_ok() {
|
||||
let _ = crate::fsx::atomic_write(&cache, &bytes);
|
||||
}
|
||||
value["source"] = "remote".into();
|
||||
Ok(value)
|
||||
})();
|
||||
fetched.or_else(|error| {
|
||||
cached()
|
||||
.map(|mut value| {
|
||||
value["source"] = "cache".into();
|
||||
value
|
||||
})
|
||||
.ok_or(error)
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn accepts_both_complete_bundled_canonical_histories() {
|
||||
assert!(validate(include_bytes!("../../../changelog/history.json"), "manager").is_ok());
|
||||
assert!(validate(
|
||||
include_bytes!("../../../src/data/server-history.json"),
|
||||
"server"
|
||||
)
|
||||
.is_ok());
|
||||
}
|
||||
#[test]
|
||||
fn rejects_cross_component_and_untrusted_components() {
|
||||
let bytes = br#"{"schema":1,"component":"manager","repository":"Corfirean/coa-server-manager","releases":[]}"#;
|
||||
assert!(validate(bytes, "manager").is_ok());
|
||||
assert!(validate(bytes, "server").is_err());
|
||||
assert!(repository("../../other").is_err());
|
||||
assert!(validate(&vec![b' '; LIMIT as usize + 1], "manager").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_malformed_records_before_the_ui_can_use_them() {
|
||||
let mut value = serde_json::json!({"schema": 1, "component": "server",
|
||||
"repository": "Corfirean/coa-server-build", "releases": [{
|
||||
"version": "0.261028.83", "tag": "0.261028.83", "date": "2026-10-28",
|
||||
"notes": ["Reviewed note"]
|
||||
}]});
|
||||
assert!(validate(&serde_json::to_vec(&value).unwrap(), "server").is_ok());
|
||||
value["releases"][0]["date"] = Value::Null;
|
||||
assert!(validate(&serde_json::to_vec(&value).unwrap(), "server").is_err());
|
||||
value["releases"][0]["date"] = "2026-10-28".into();
|
||||
value["releases"][0]["notes"] = serde_json::json!([{"html": "not a text note"}]);
|
||||
assert!(validate(&serde_json::to_vec(&value).unwrap(), "server").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn available_update_bypasses_fresh_cache_missing_the_target_and_keeps_offline_fallback() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let feed = |version: &str| {
|
||||
serde_json::to_vec(&serde_json::json!({
|
||||
"schema":1,"component":"manager","repository":"Corfirean/coa-server-manager",
|
||||
"releases":[{"version":version,"tag":format!("v{version}"),"date":"2026-10-30",
|
||||
"notes":["Visible update notes"]}]
|
||||
}))
|
||||
.unwrap()
|
||||
};
|
||||
std::fs::write(dir.path().join("manager.json"), feed("0.9.4")).unwrap();
|
||||
let value =
|
||||
load_with_remote("manager", dir.path(), Some("0.9.5"), || Ok(feed("0.9.5"))).unwrap();
|
||||
assert_eq!(value["source"], "remote");
|
||||
assert_eq!(value["releases"][0]["version"], "0.9.5");
|
||||
let cached = load_with_remote("manager", dir.path(), Some("0.9.5"), || {
|
||||
panic!("fresh target is cached")
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(cached["source"], "cache");
|
||||
let offline = load_with_remote("manager", dir.path(), Some("0.9.6"), || {
|
||||
Err("offline".into())
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(offline["releases"][0]["version"], "0.9.5");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fresh_valid_cache_is_available_without_network() {
|
||||
let dir = std::env::temp_dir().join(format!("coa-history-{}", uuid::Uuid::new_v4()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
std::fs::write(dir.join("manager.json"), br#"{"schema":1,"component":"manager","repository":"Corfirean/coa-server-manager","releases":[]}"#).unwrap();
|
||||
let result = load("manager", &dir).unwrap();
|
||||
assert_eq!(result["source"], "cache");
|
||||
std::fs::remove_file(dir.join("manager.json")).unwrap();
|
||||
std::fs::remove_dir(dir).unwrap();
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ pub fn qualify_upgrade(
|
||||
pkgsource::fetch_manifest(&pkgsource::Source::Dir(base.into()), trusted_key)?;
|
||||
let (source_manifest, source_bytes) =
|
||||
pkgsource::fetch_manifest(&pkgsource::Source::Dir(source.into()), trusted_key)?;
|
||||
let (candidate_manifest, _) =
|
||||
let (candidate_manifest, candidate_bytes) =
|
||||
pkgsource::fetch_manifest(&pkgsource::Source::Dir(candidate.into()), trusted_key)?;
|
||||
if candidate_manifest.kind != Kind::Update
|
||||
|| !matches!(source_manifest.kind, Kind::Base | Kind::Update)
|
||||
@@ -149,6 +149,7 @@ pub fn qualify_upgrade(
|
||||
}
|
||||
env.ensure_stopped()
|
||||
};
|
||||
let mut migration_audit = None;
|
||||
install::with_scratch_ports(fixture, || {
|
||||
if source_manifest.kind == Kind::Update {
|
||||
apply(source)?;
|
||||
@@ -157,6 +158,7 @@ pub fn qualify_upgrade(
|
||||
let user_bytes = b"Qualification.UserSetting = 7391\r\n";
|
||||
fsx::atomic_write(&user_file, user_bytes)?;
|
||||
apply(candidate)?;
|
||||
migration_audit = Some(audit_migrations(fixture, &candidate_manifest.migrations)?);
|
||||
if std::fs::read(&user_file)?.as_slice() != user_bytes {
|
||||
return Err(Error::Invalid(
|
||||
"The update changed a user configuration file.".into(),
|
||||
@@ -175,9 +177,10 @@ pub fn qualify_upgrade(
|
||||
})?;
|
||||
Ok(serde_json::json!({
|
||||
"schema": 1, "result": "passed", "fromVersion": source_manifest.version,
|
||||
"toVersion": candidate_manifest.version, "fromManifestSha256": fsx::sha256_bytes(&source_bytes),
|
||||
"toVersion": candidate_manifest.version, "toManifestSha256": fsx::sha256_bytes(&candidate_bytes),
|
||||
"migrationInventorySha256": migrations::inventory_sha256(&candidate_manifest.migrations)?, "migrations": migration_audit, "fromManifestSha256": fsx::sha256_bytes(&source_bytes),
|
||||
"fromSchemaSha256": source_manifest.files.iter().find(|file| file.path == schema_check::CONTRACT).map(|file| &file.sha256),
|
||||
"checks": ["manager-transaction", "recovery-backed-database-update", "database-schema", "private-auth-world-startup", "existing-identities", "user-file-preservation"],
|
||||
"checks": ["legacy-race-start-data", "migration-ledger", "manager-transaction", "recovery-backed-database-update", "database-schema", "private-auth-world-startup", "existing-identities", "user-file-preservation"],
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -238,6 +241,15 @@ pub fn qualify_install(
|
||||
package: &Path,
|
||||
fixture: &Path,
|
||||
trusted_key: &str,
|
||||
) -> Result<serde_json::Value> {
|
||||
qualify_install_against(package, None, fixture, trusted_key)
|
||||
}
|
||||
|
||||
pub fn qualify_install_against(
|
||||
package: &Path,
|
||||
update: Option<&Path>,
|
||||
fixture: &Path,
|
||||
trusted_key: &str,
|
||||
) -> Result<serde_json::Value> {
|
||||
use crate::update::Env;
|
||||
if !cfg!(windows)
|
||||
@@ -254,6 +266,21 @@ pub fn qualify_install(
|
||||
let package = fsx::canonicalize_lenient(package)?;
|
||||
let (manifest, bytes) =
|
||||
pkgsource::fetch_manifest(&pkgsource::Source::Dir(package.clone()), trusted_key)?;
|
||||
let expected_update = update
|
||||
.map(|path| pkgsource::fetch_manifest(&pkgsource::Source::Dir(path.into()), trusted_key))
|
||||
.transpose()?;
|
||||
if let Some((expected, _)) = &expected_update {
|
||||
if expected.kind != Kind::Update
|
||||
|| expected.version != manifest.version
|
||||
|| expected.core.commit != manifest.core.commit
|
||||
|| expected.bots.as_ref().and_then(|b| b.commit.as_ref())
|
||||
!= manifest.bots.as_ref().and_then(|b| b.commit.as_ref())
|
||||
{
|
||||
return Err(Error::Invalid(
|
||||
"Clean installation image does not match the selected release.".into(),
|
||||
));
|
||||
}
|
||||
}
|
||||
let registry_dir = tempfile::tempdir()?;
|
||||
let registry = crate::registry::Registry::at(registry_dir.path().join("registry.json"));
|
||||
let installed = install::install_base(
|
||||
@@ -280,13 +307,84 @@ pub fn qualify_install(
|
||||
"Clean installation did not finish at the packaged release.".into(),
|
||||
));
|
||||
}
|
||||
let migration_audit = expected_update
|
||||
.as_ref()
|
||||
.map(|(expected, _)| audit_migrations(&fixture, &expected.migrations))
|
||||
.transpose()?;
|
||||
env.ensure_stopped()?;
|
||||
crate::mysql_snapshot::stop(&fixture)?;
|
||||
let inventory = expected_update
|
||||
.as_ref()
|
||||
.map(|(expected, _)| migrations::inventory_sha256(&expected.migrations))
|
||||
.transpose()?;
|
||||
let mut checks = vec![
|
||||
"clean-install",
|
||||
"signed-full-package",
|
||||
"credential-rotation",
|
||||
"schema-contract",
|
||||
"private-auth-world-startup",
|
||||
];
|
||||
if expected_update.is_some() {
|
||||
checks.push("migration-ledger");
|
||||
checks.push("legacy-race-start-data");
|
||||
}
|
||||
Ok(
|
||||
serde_json::json!({ "schema": 1, "result": "passed", "version": installed.version,
|
||||
"manifestSha256": fsx::sha256_bytes(&bytes),
|
||||
"checks": ["clean-install", "signed-full-package", "credential-rotation", "schema-contract", "private-auth-world-startup"] }),
|
||||
"checks": checks, "migrationInventorySha256": inventory, "migrations": migration_audit }),
|
||||
)
|
||||
}
|
||||
|
||||
fn audit_migrations(
|
||||
root: &Path,
|
||||
list: &[Migration],
|
||||
) -> Result<std::collections::BTreeMap<String, migrations::Audit>> {
|
||||
install::with_scratch_ports(root, || {
|
||||
backup::with_database(root, |db| {
|
||||
crate::realms::state(root)?
|
||||
.modes()
|
||||
.into_iter()
|
||||
.map(|mode| {
|
||||
if mode == crate::realms::Mode::Coa {
|
||||
let rows = db
|
||||
.clone()
|
||||
.for_realm(mode)
|
||||
.query("SELECT race,class FROM acore_world.playercreateinfo;")?;
|
||||
let missing = missing_legacy_starts(&rows);
|
||||
if !missing.is_empty() {
|
||||
return Err(Error::Invalid(format!(
|
||||
"Release is missing legacy race starting data: {}",
|
||||
missing.join(", ")
|
||||
)));
|
||||
}
|
||||
}
|
||||
Ok((
|
||||
mode.name().to_string(),
|
||||
migrations::audit_applied(&db.clone().for_realm(mode), list)?,
|
||||
))
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fn missing_legacy_starts(rows: &str) -> Vec<String> {
|
||||
let pairs: std::collections::BTreeSet<(u32, u32)> = rows
|
||||
.lines()
|
||||
.filter_map(|line| line.split_once('\t'))
|
||||
.filter_map(|(race, class)| Some((race.parse().ok()?, class.parse().ok()?)))
|
||||
.collect();
|
||||
let mut missing = Vec::new();
|
||||
for (race, parent) in [(33, 1), (45, 8)] {
|
||||
for &(source, class) in &pairs {
|
||||
if source == parent && !pairs.contains(&(race, class)) {
|
||||
missing.push(format!("race {race} / class {class}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
missing
|
||||
}
|
||||
|
||||
pub fn collect(core: &Path, bots: Option<&Path>, repairs: Option<&Path>) -> Result<Vec<SqlFile>> {
|
||||
let mut files = release::collect_core_sql(core)?;
|
||||
if let Some(bots) = bots {
|
||||
@@ -617,6 +715,56 @@ mod tests {
|
||||
use base64::{engine::general_purpose::STANDARD, Engine};
|
||||
use ed25519_dalek::{Signer, SigningKey};
|
||||
|
||||
#[test]
|
||||
#[ignore = "Requires the disposable current-release installation audit fixture"]
|
||||
fn real_current_image_is_blocked_until_legacy_start_data_is_restored() {
|
||||
let root = std::path::PathBuf::from(std::env::var_os("COA_RELEASE_AUDIT_FIXTURE").unwrap());
|
||||
assert_eq!(
|
||||
root.file_name().unwrap(),
|
||||
"coa-schema-fixture-latest-install-audit-20261030"
|
||||
);
|
||||
assert!(root.join(".release-schema-fixture").is_file());
|
||||
assert!(!root.join("legacy-release-gate-probe-started").exists());
|
||||
fsx::atomic_write(
|
||||
&root.join("legacy-release-gate-probe-started"),
|
||||
b"disposable regression test",
|
||||
)
|
||||
.unwrap();
|
||||
let candidate =
|
||||
std::path::PathBuf::from(std::env::var_os("COA_RELEASE_AUDIT_PACKAGE").unwrap());
|
||||
let (manifest, _) = pkgsource::fetch_manifest(
|
||||
&pkgsource::Source::Dir(candidate),
|
||||
crate::signing::EMBEDDED_PUBLIC_KEY,
|
||||
)
|
||||
.unwrap();
|
||||
let failure = audit_migrations(&root, &manifest.migrations).unwrap_err();
|
||||
assert!(failure.to_string().contains("race 33 / class 12"));
|
||||
assert!(failure.to_string().contains("race 45 / class 30"));
|
||||
println!("PASS: signed current image is blocked for missing legacy starts despite a complete migration ledger");
|
||||
let sql =
|
||||
fs::read_to_string(std::env::var_os("COA_RELEASE_AUDIT_CORRECTION").unwrap()).unwrap();
|
||||
install::with_scratch_ports(&root, || backup::with_database(&root, |db| {
|
||||
let before = db.query("SELECT * FROM acore_characters.characters ORDER BY guid;")?;
|
||||
db.query(&format!("USE acore_world;\n{sql}"))?;
|
||||
let once = db.query("SELECT * FROM acore_world.playercreateinfo WHERE race IN (33,45) ORDER BY race,class;")?;
|
||||
db.query(&format!("USE acore_world;\n{sql}"))?;
|
||||
assert_eq!(once, db.query("SELECT * FROM acore_world.playercreateinfo WHERE race IN (33,45) ORDER BY race,class;")?);
|
||||
assert_eq!(before, db.query("SELECT * FROM acore_characters.characters ORDER BY guid;")?);
|
||||
Ok(())
|
||||
})).unwrap();
|
||||
let audits = audit_migrations(&root, &manifest.migrations).unwrap();
|
||||
println!("PASS: corrected data passes the release gate; characters unchanged; correction idempotent; audit={}", serde_json::to_string(&audits).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn release_rejects_missing_legacy_starts_even_without_existing_characters() {
|
||||
assert_eq!(
|
||||
missing_legacy_starts("1\t12\n8\t30\n"),
|
||||
["race 33 / class 12", "race 45 / class 30"]
|
||||
);
|
||||
assert!(missing_legacy_starts("1\t12\n8\t30\n33\t12\n45\t30\n").is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "Requires a composed disposable installation image"]
|
||||
fn real_full_package_installs_the_current_version_without_an_update_transaction() {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! Where a problem report goes. A report about the bots goes to the repository of the bot system in question, anything
|
||||
//! else to the Manager's own. The repositories come from the module catalog, so there is one list to keep right.
|
||||
//! Problem-report destinations for the Manager, bot systems and upstream custom races.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
@@ -36,14 +35,14 @@ fn catalog_repo(id: &str) -> Option<String> {
|
||||
.and_then(|e| repo_of(&e.repo))
|
||||
}
|
||||
|
||||
/// The three places, in the order the page lists them. A bot system whose repository is unknown falls back to the Manager's.
|
||||
/// Report destinations in display order. Custom-race reports go to the upstream asset maintainer.
|
||||
pub fn targets() -> Vec<Target> {
|
||||
let mut v = vec![Target {
|
||||
id: "manager",
|
||||
repo: MANAGER_REPO.into(),
|
||||
ours: true,
|
||||
}];
|
||||
for (id, module) in [("companions", "companions"), ("squid", "playerbots")] {
|
||||
for (id, module) in [("companions", "companions"), ("squid", "playerbots"), ("content-scaling", "content-scaling")] {
|
||||
if let Some(repo) = catalog_repo(module) {
|
||||
v.push(Target {
|
||||
id,
|
||||
@@ -52,6 +51,11 @@ pub fn targets() -> Vec<Target> {
|
||||
});
|
||||
}
|
||||
}
|
||||
v.push(Target {
|
||||
id: "custom-races",
|
||||
repo: "ilusixn/azerothcore-wotlk-coa".into(),
|
||||
ours: false,
|
||||
});
|
||||
v
|
||||
}
|
||||
|
||||
@@ -103,7 +107,7 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn the_three_targets_come_from_the_catalog() {
|
||||
fn report_targets_route_to_their_maintainers() {
|
||||
let t = targets();
|
||||
let repo = |id: &str| t.iter().find(|x| x.id == id).map(|x| x.repo.clone());
|
||||
assert_eq!(
|
||||
@@ -116,6 +120,10 @@ mod tests {
|
||||
);
|
||||
assert_eq!(repo("squid").as_deref(), Some("Zyth45/mod-playerbots"));
|
||||
assert!(t.iter().find(|x| x.id == "squid").is_some_and(|x| !x.ours));
|
||||
assert_eq!(repo("custom-races").as_deref(), Some("ilusixn/azerothcore-wotlk-coa"));
|
||||
assert!(t.iter().find(|x| x.id == "custom-races").is_some_and(|x| !x.ours));
|
||||
assert_eq!(repo("content-scaling").as_deref(), Some("Corfirean/mod-coa-content-scaling"));
|
||||
assert!(t.iter().find(|x| x.id == "content-scaling").is_some_and(|x| x.ours));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -135,6 +143,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn only_the_new_issue_pages_of_the_targets_are_allowed() {
|
||||
assert!(is_new_issue_url("https://github.com/Corfirean/mod-coa-content-scaling/issues/new?title=a&body=b"));
|
||||
assert!(is_new_issue_url("https://github.com/ilusixn/azerothcore-wotlk-coa/issues/new?title=a&body=b"));
|
||||
assert!(!is_new_issue_url("https://github.com/ilusixn/azerothcore-wotlk-coa/issues/newer"));
|
||||
assert!(is_new_issue_url(
|
||||
"https://github.com/Zyth45/mod-playerbots/issues/new"
|
||||
));
|
||||
|
||||
@@ -95,13 +95,42 @@ pub struct Problem {
|
||||
|
||||
/// Keep all differences for support; never change a database to match a contract automatically.
|
||||
pub fn check_with_report(db: &Db, root: &Path) -> Result<Vec<Problem>> {
|
||||
let problems = check(db, root)?;
|
||||
if problems.is_empty() {
|
||||
check_update_with_report(db, root, None)
|
||||
}
|
||||
|
||||
/// Only a hash-verified pre-update baseline may downgrade unchanged missing starts to warnings.
|
||||
pub fn check_update_with_report(
|
||||
db: &Db,
|
||||
root: &Path,
|
||||
baseline: Option<&crate::character_start_check::Baseline>,
|
||||
) -> Result<Vec<Problem>> {
|
||||
let mut preexisting = BTreeMap::new();
|
||||
let before = match baseline {
|
||||
Some(b) if b.schema == 1 => Some(b.realms.get(db.realm().name()).ok_or_else(|| {
|
||||
crate::Error::Invalid("The character baseline does not contain this realm.".into())
|
||||
})?),
|
||||
Some(_) => {
|
||||
return Err(crate::Error::Invalid(
|
||||
"Unsupported character start baseline.".into(),
|
||||
))
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
let problems = check_inner(db, root, before, &mut preexisting)?;
|
||||
let existing: usize = preexisting.values().sum();
|
||||
let preexisting_details: Vec<_> = preexisting.into_iter().map(|((race, class), count)| serde_json::json!({"race": race, "class": class, "count": count})).collect();
|
||||
if existing > 0 {
|
||||
tracing::warn!(realm = db.realm().name(), characters = existing, "Unchanged pre-update characters with missing starting data retained; no character records were repaired or deleted");
|
||||
}
|
||||
if problems.is_empty() && existing == 0 {
|
||||
return Ok(problems);
|
||||
}
|
||||
let report = serde_json::json!({
|
||||
"schema": 1, "checkedAt": chrono::Utc::now().to_rfc3339(),
|
||||
"realm": db.realm().name(), "problems": problems,
|
||||
"preexistingUnsupportedCharacters": existing,
|
||||
"preexistingCharacterStarts": preexisting_details,
|
||||
"note": "Unchanged pre-update missing starts are reported separately. New missing character starts and all schema errors still block the update.",
|
||||
});
|
||||
let path = crate::registry::metadata_dir_for(root)?
|
||||
.join("diagnostics")
|
||||
@@ -245,6 +274,15 @@ pub(crate) fn repair_missing_defaults(
|
||||
}
|
||||
|
||||
pub fn check(db: &Db, root: &Path) -> Result<Vec<Problem>> {
|
||||
check_inner(db, root, None, &mut BTreeMap::new())
|
||||
}
|
||||
|
||||
fn check_inner(
|
||||
db: &Db,
|
||||
root: &Path,
|
||||
before: Option<&BTreeSet<crate::character_start_check::MissingStart>>,
|
||||
existing: &mut BTreeMap<(u32, u32), usize>,
|
||||
) -> Result<Vec<Problem>> {
|
||||
let contract = if root.join(CONTRACT).is_file() {
|
||||
let contract: Contract = fsx::read_json(&root.join(CONTRACT))?;
|
||||
if contract.schema != 1 {
|
||||
@@ -367,12 +405,24 @@ pub fn check(db: &Db, root: &Path) -> Result<Vec<Problem>> {
|
||||
}
|
||||
// Check owned characters too, including legacy classes and Wildcard characters. Their rows
|
||||
// must not silently disappear from character selection after an otherwise healthy update.
|
||||
let missing = db.query("SELECT c.race,c.class,COUNT(*) FROM acore_characters.characters c LEFT JOIN acore_world.playercreateinfo p ON p.race=c.race AND p.class=c.class WHERE p.race IS NULL GROUP BY c.race,c.class;")?;
|
||||
for row in missing.lines() {
|
||||
let fields: Vec<_> = row.split('\t').collect();
|
||||
if fields.len() == 3 {
|
||||
problems.push(Problem { database: "world".into(), table: "playercreateinfo".into(), column: String::new(), detail: format!("{} existing characters have no starting data for race {} / class {} and would be hidden from character selection", fields[2], fields[0], fields[1]) });
|
||||
let current = crate::character_start_check::missing(db)?;
|
||||
let blocking = if let Some(before) = before {
|
||||
let introduced = crate::character_start_check::introduced(¤t, before);
|
||||
for character in current.intersection(before) {
|
||||
*existing
|
||||
.entry((character.race, character.class))
|
||||
.or_default() += 1;
|
||||
}
|
||||
introduced
|
||||
} else {
|
||||
current
|
||||
};
|
||||
let mut counts = BTreeMap::<(u32, u32), usize>::new();
|
||||
for character in blocking {
|
||||
*counts.entry((character.race, character.class)).or_default() += 1;
|
||||
}
|
||||
for ((race, class), count) in counts {
|
||||
problems.push(Problem { database: "world".into(), table: "playercreateinfo".into(), column: String::new(), detail: format!("{count} existing characters have no starting data for race {race} / class {class} and would be hidden from character selection") });
|
||||
}
|
||||
Ok(problems)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
use std::{fs, path::Path};
|
||||
|
||||
use crate::{
|
||||
config::{parser::ConfFile, Scope},
|
||||
error::{Error, Result},
|
||||
fsx,
|
||||
};
|
||||
|
||||
fn transform(bytes: &[u8], preset: &str) -> Result<String> {
|
||||
let level = match preset {
|
||||
"normal" => 4,
|
||||
"errors" => 2,
|
||||
"off" => 0,
|
||||
_ => return Err(Error::Invalid("Unknown server logging preset.".into())),
|
||||
};
|
||||
let mut conf = ConfFile::parse_bytes(bytes)?;
|
||||
let entries: Vec<_> = conf
|
||||
.entries()
|
||||
.map(|(key, value)| (key.to_string(), value.to_string()))
|
||||
.collect();
|
||||
for (key, value) in entries {
|
||||
if key.starts_with("Logger.") {
|
||||
let Some((_, appenders)) = value.split_once(',') else {
|
||||
continue;
|
||||
};
|
||||
let value = if preset == "normal"
|
||||
&& matches!(
|
||||
key.as_str(),
|
||||
"Logger.network" | "Logger.sql.sql" | "Logger.entities.player"
|
||||
) {
|
||||
2
|
||||
} else {
|
||||
level
|
||||
};
|
||||
conf.set(&key, &format!("{value},{appenders}"), &[]);
|
||||
} else if key.starts_with("Appender.") {
|
||||
let mut fields: Vec<_> = value.split(',').map(str::to_string).collect();
|
||||
if fields.len() >= 3 {
|
||||
fields[1] = if key == "Appender.Errors" && preset == "normal" {
|
||||
"2".into()
|
||||
} else {
|
||||
level.to_string()
|
||||
};
|
||||
conf.set(&key, &fields.join(","), &[]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(conf.to_text())
|
||||
}
|
||||
|
||||
pub fn apply(root: &Path, meta: &Path, preset: &str) -> Result<()> {
|
||||
let _operation = crate::update::operation_lock(meta)?;
|
||||
crate::update::ensure_recovered(meta)?;
|
||||
fs::create_dir_all(root.join(".state"))?;
|
||||
let lock = fs::OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create(true)
|
||||
.truncate(false)
|
||||
.open(root.join(".state/control.lock"))?;
|
||||
if !fs4::fs_std::FileExt::try_lock_exclusive(&lock)? {
|
||||
return Err(Error::Invalid(
|
||||
"Another start/stop action is in progress.".into(),
|
||||
));
|
||||
}
|
||||
let mut originals = Vec::new();
|
||||
let mut texts = Vec::new();
|
||||
for prefix in ["", ".realms/secondary/", ".realms/reborn/"] {
|
||||
for name in [
|
||||
"Settings/worldserver.conf.template",
|
||||
"Settings/authserver.conf.template",
|
||||
"Core/configs/worldserver.conf",
|
||||
"Core/configs/authserver.conf",
|
||||
] {
|
||||
let path = fsx::ensure_within(root, &root.join(format!("{prefix}{name}")))?;
|
||||
if path.is_file() {
|
||||
let bytes = fs::read(&path)?;
|
||||
texts.push(transform(&bytes, preset)?);
|
||||
originals.push((path, bytes));
|
||||
}
|
||||
}
|
||||
let marker = root.join(format!("{prefix}.state/debug-logs.json"));
|
||||
if marker.is_file() {
|
||||
originals.push((marker.clone(), fs::read(marker)?));
|
||||
texts.push("{\"enabled\":false}\n".into());
|
||||
}
|
||||
}
|
||||
if originals.is_empty() {
|
||||
return Err(Error::Invalid(
|
||||
"Server configuration files were not found.".into(),
|
||||
));
|
||||
}
|
||||
crate::config::take_snapshot(
|
||||
meta,
|
||||
Scope::Server,
|
||||
"before changing server logging",
|
||||
&originals,
|
||||
)?;
|
||||
for (index, (path, _)) in originals.iter().enumerate() {
|
||||
if let Err(error) = fsx::atomic_write(path, texts[index].as_bytes()) {
|
||||
for (path, bytes) in originals.iter().take(index) {
|
||||
let _ = fsx::atomic_write(path, bytes);
|
||||
}
|
||||
return Err(error);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn changes_auth_world_and_templates_in_all_realms_with_restorable_snapshots() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let root = temp.path().join("server");
|
||||
let meta = temp.path().join("meta");
|
||||
fs::create_dir_all(&root).unwrap();
|
||||
let mut files = Vec::new();
|
||||
for prefix in ["", ".realms/secondary/", ".realms/reborn/"] {
|
||||
for name in [
|
||||
"Settings/worldserver.conf.template",
|
||||
"Settings/authserver.conf.template",
|
||||
"Core/configs/worldserver.conf",
|
||||
"Core/configs/authserver.conf",
|
||||
] {
|
||||
let path = root.join(format!("{prefix}{name}"));
|
||||
fs::create_dir_all(path.parent().unwrap()).unwrap();
|
||||
let bytes =
|
||||
b"Logger.root=6,Console\r\nAppender.Console=1,6,0\r\nKeep = unchanged\r\n"
|
||||
.to_vec();
|
||||
fs::write(&path, &bytes).unwrap();
|
||||
files.push((path, bytes));
|
||||
}
|
||||
}
|
||||
apply(&root, &meta, "errors").unwrap();
|
||||
for (path, _) in &files {
|
||||
assert!(fs::read_to_string(path)
|
||||
.unwrap()
|
||||
.contains("Logger.root=2,Console\r\n"));
|
||||
}
|
||||
let snapshots = crate::config::list_snapshots(&meta);
|
||||
assert_eq!(snapshots.len(), 1);
|
||||
crate::config::restore_snapshot(&meta, &snapshots[0].id).unwrap();
|
||||
for (path, bytes) in files {
|
||||
assert_eq!(fs::read(path).unwrap(), bytes);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn presets_control_dispatch_and_appenders_and_can_restore_useful_logs() {
|
||||
let original = b"Logger.root=6,Console Server\r\nLogger.sql.sql=6,Console Server\r\nAppender.Console=1,6,0,\"1 9 3 6 5 8\"\r\nAppender.Errors=2,2,0,Errors.log,w\r\nOther = keep\r\n";
|
||||
let off = transform(original, "off").unwrap();
|
||||
assert!(off.contains("Logger.root=0,Console Server\r\n"));
|
||||
assert!(off.contains("Appender.Errors=2,0,0,Errors.log,w\r\n"));
|
||||
let normal = transform(off.as_bytes(), "normal").unwrap();
|
||||
assert!(normal.contains("Logger.root=4,Console Server\r\n"));
|
||||
assert!(normal.contains("Logger.sql.sql=2,Console Server\r\n"));
|
||||
assert!(normal.contains("Appender.Errors=2,2,0,Errors.log,w\r\n"));
|
||||
assert!(normal.contains("Other = keep\r\n"));
|
||||
assert_eq!(transform(normal.as_bytes(), "normal").unwrap(), normal);
|
||||
assert!(transform(original, "unsupported").is_err());
|
||||
}
|
||||
}
|
||||
+252
-18
@@ -22,6 +22,8 @@ use crate::pkgsource::{fetch_manifest, fetch_parts, Source};
|
||||
use crate::registry::{InstallMeta, MetaDir};
|
||||
|
||||
const STAGED_PREFIX: &str = "_migrations/";
|
||||
const CHARACTER_BASELINE: &str = "character-start-baseline.json";
|
||||
const CHARACTER_BASELINE_HASH: &str = "@character-starts";
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
@@ -106,6 +108,9 @@ pub trait Env {
|
||||
fn verify_snapshot(&self, _id: &str) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
fn character_start_baseline(&self) -> Result<Option<crate::character_start_check::Baseline>> {
|
||||
Ok(None)
|
||||
}
|
||||
fn snapshot(&self) -> Result<String>;
|
||||
fn restore_snapshot(&self, id: &str) -> Result<()>;
|
||||
fn migrate(&self, manifest: &Manifest, staged_migrations: &Path) -> Result<ApplyReport>;
|
||||
@@ -223,11 +228,12 @@ fn read_journal(path: &Path) -> Result<Txn> {
|
||||
"Update journal contains invalid recovery hashes.".into(),
|
||||
));
|
||||
}
|
||||
for key in txn
|
||||
.recovery_hashes
|
||||
.keys()
|
||||
.filter(|key| !matches!(key.as_str(), "@install" | "@point"))
|
||||
{
|
||||
for key in txn.recovery_hashes.keys().filter(|key| {
|
||||
!matches!(
|
||||
key.as_str(),
|
||||
"@install" | "@point" | CHARACTER_BASELINE_HASH
|
||||
)
|
||||
}) {
|
||||
fsx::safe_join(path.parent().unwrap(), key)?;
|
||||
}
|
||||
if completed_legacy_repair {
|
||||
@@ -684,6 +690,7 @@ pub struct Params<'a> {
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct Outcome {
|
||||
pub txn: Txn,
|
||||
pub preexisting_character_count: usize,
|
||||
pub migrations: Option<ApplyReport>,
|
||||
}
|
||||
|
||||
@@ -816,6 +823,26 @@ pub fn apply(p: &Params, report: &dyn Fn(&str, u8)) -> Result<Outcome> {
|
||||
.insert("@point".into(), fsx::sha256_file(&point_meta)?);
|
||||
}
|
||||
save(meta_dir, &txn)?;
|
||||
// Capture before any new files or SQL are applied; retry must reuse these exact bytes.
|
||||
let baseline = match p.env.character_start_baseline() {
|
||||
Ok(baseline) => baseline,
|
||||
Err(error) => {
|
||||
txn.state = State::Failed;
|
||||
txn.message = Some(format!("The update was not applied because the character baseline could not be captured: {error}"));
|
||||
save(meta_dir, &txn)?;
|
||||
return Err(error);
|
||||
}
|
||||
};
|
||||
let preexisting_character_count = baseline
|
||||
.as_ref()
|
||||
.map_or(0, |b| b.realms.values().map(|r| r.len()).sum());
|
||||
if let Some(baseline) = &baseline {
|
||||
let path = tdir.join(CHARACTER_BASELINE);
|
||||
fsx::atomic_write_json(&path, baseline)?;
|
||||
txn.recovery_hashes
|
||||
.insert(CHARACTER_BASELINE_HASH.into(), fsx::sha256_file(&path)?);
|
||||
save(meta_dir, &txn)?;
|
||||
}
|
||||
txn.ops = items
|
||||
.iter()
|
||||
.filter(|i| i.action != Action::Skip)
|
||||
@@ -909,6 +936,7 @@ pub fn apply(p: &Params, report: &dyn Fn(&str, u8)) -> Result<Outcome> {
|
||||
save(meta_dir, &txn)?;
|
||||
return Ok(Outcome {
|
||||
txn,
|
||||
preexisting_character_count,
|
||||
migrations: migrated,
|
||||
});
|
||||
}
|
||||
@@ -919,6 +947,7 @@ pub fn apply(p: &Params, report: &dyn Fn(&str, u8)) -> Result<Outcome> {
|
||||
let _ = archive;
|
||||
Ok(Outcome {
|
||||
txn,
|
||||
preexisting_character_count,
|
||||
migrations: migrated,
|
||||
})
|
||||
}
|
||||
@@ -1039,6 +1068,7 @@ pub fn retry_validation(
|
||||
)));
|
||||
}
|
||||
}
|
||||
read_character_baseline(meta_dir, &txn)?;
|
||||
env.ensure_stopped()?;
|
||||
if let Err(error) = env.validate() {
|
||||
txn.message = Some(format!(
|
||||
@@ -1115,7 +1145,13 @@ fn restore_transaction(
|
||||
txn: &mut Txn,
|
||||
env: &dyn Env,
|
||||
) -> Result<()> {
|
||||
for (rel, expected) in &txn.recovery_hashes {
|
||||
// This baseline is a validation input, not a recovery copy: corruption must block
|
||||
// retry/commit, but must never prevent restoration of the verified safety backup.
|
||||
for (rel, expected) in txn
|
||||
.recovery_hashes
|
||||
.iter()
|
||||
.filter(|(key, _)| key.as_str() != CHARACTER_BASELINE_HASH)
|
||||
{
|
||||
let saved = match rel.as_str() {
|
||||
"@install" => before.join("manager-install.json"),
|
||||
"@point" => crate::backup::point_json(
|
||||
@@ -1504,6 +1540,33 @@ fn prune(meta_dir: &Path, keep: usize) {
|
||||
}
|
||||
}
|
||||
|
||||
fn read_character_baseline(
|
||||
meta: &Path,
|
||||
txn: &Txn,
|
||||
) -> Result<Option<crate::character_start_check::Baseline>> {
|
||||
let path = txn_dir(meta, &txn.id)?.join(CHARACTER_BASELINE);
|
||||
let Some(expected) = txn.recovery_hashes.get(CHARACTER_BASELINE_HASH) else {
|
||||
if path.exists() {
|
||||
return Err(Error::Invalid(
|
||||
"An unverified character start baseline was found.".into(),
|
||||
));
|
||||
}
|
||||
return Ok(None); // Older transactions remain strict; never learn a baseline after applying SQL.
|
||||
};
|
||||
if fsx::sha256_file(&path)? != *expected {
|
||||
return Err(Error::Invalid(
|
||||
"The saved character start baseline failed verification.".into(),
|
||||
));
|
||||
}
|
||||
let baseline: crate::character_start_check::Baseline = fsx::read_json(&path)?;
|
||||
if baseline.schema != 1 {
|
||||
return Err(Error::Invalid(
|
||||
"Unsupported character start baseline.".into(),
|
||||
));
|
||||
}
|
||||
Ok(Some(baseline))
|
||||
}
|
||||
|
||||
/// The real environment: a repack-shaped installation driven through its launcher.
|
||||
pub struct RepackEnv<'a> {
|
||||
pub root: &'a Path,
|
||||
@@ -1511,6 +1574,12 @@ pub struct RepackEnv<'a> {
|
||||
}
|
||||
|
||||
impl RepackEnv<'_> {
|
||||
fn saved_character_baseline(&self) -> Result<Option<crate::character_start_check::Baseline>> {
|
||||
match unfinished(self.meta_dir) {
|
||||
Some(txn) => read_character_baseline(self.meta_dir, &txn),
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
pub fn pending_migrations(&self, manifest: &Manifest) -> Result<usize> {
|
||||
Ok(self
|
||||
.pending_migrations_with(manifest, DatabaseAccess::Start)?
|
||||
@@ -1527,9 +1596,9 @@ impl RepackEnv<'_> {
|
||||
return Ok(Some(0));
|
||||
}
|
||||
let count = |db: &crate::db::Db| -> Result<usize> {
|
||||
let db = db.clone().with_read_deadline(
|
||||
std::time::Instant::now() + std::time::Duration::from_secs(15),
|
||||
);
|
||||
let db = db
|
||||
.clone()
|
||||
.with_read_deadline(std::time::Instant::now() + std::time::Duration::from_secs(15));
|
||||
let realms = crate::realms::state(self.root)?;
|
||||
let modes = realms.modes();
|
||||
let mut count = 0;
|
||||
@@ -1772,12 +1841,25 @@ impl Env for RepackEnv<'_> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn character_start_baseline(&self) -> Result<Option<crate::character_start_check::Baseline>> {
|
||||
crate::backup::with_database(self.root, |db| {
|
||||
crate::character_start_check::capture(db, self.root)
|
||||
})
|
||||
.map(Some)
|
||||
}
|
||||
|
||||
fn migrate(&self, manifest: &Manifest, staged: &Path) -> Result<ApplyReport> {
|
||||
crate::backup::with_database(self.root, |db| {
|
||||
let identities = database_identities(db)?;
|
||||
let result = migrate_databases(db, self.root, manifest, staged, &|| {
|
||||
self.migration_snapshot()
|
||||
})?;
|
||||
let baseline = self.saved_character_baseline()?;
|
||||
let result = migrate_databases(
|
||||
db,
|
||||
self.root,
|
||||
manifest,
|
||||
staged,
|
||||
&|| self.migration_snapshot(),
|
||||
baseline.as_ref(),
|
||||
)?;
|
||||
if result.failed.is_none() {
|
||||
verify_database_identities(db, &identities)?;
|
||||
}
|
||||
@@ -1799,16 +1881,26 @@ impl RepackEnv<'_> {
|
||||
crate::mysql_snapshot::stop(self.root)?;
|
||||
self.ensure_stopped()?;
|
||||
self.recover_validation()?;
|
||||
let baseline = if check_schema {
|
||||
self.saved_character_baseline()?
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let result = (|| -> Result<()> {
|
||||
crate::update_isolation::begin(self.root, self.meta_dir)?;
|
||||
let database = crate::driver::run(self.root, crate::driver::Verb::StartMysql)?;
|
||||
if !database.ok {
|
||||
return Err(Error::Invalid(crate::driver::startup_failure(self.root, &database)));
|
||||
}
|
||||
use crate::process::{observe, ServiceState};
|
||||
let identities = crate::backup::with_database(self.root, |db| {
|
||||
if check_schema {
|
||||
let modes = crate::realms::state(self.root)?.modes();
|
||||
for mode in modes {
|
||||
if let Some(p) = crate::schema_check::check_with_report(
|
||||
if let Some(p) = crate::schema_check::check_update_with_report(
|
||||
&db.clone().for_realm(mode),
|
||||
self.root,
|
||||
baseline.as_ref(),
|
||||
)?
|
||||
.first()
|
||||
{
|
||||
@@ -1851,9 +1943,7 @@ impl RepackEnv<'_> {
|
||||
if o.mysql.state == ServiceState::Running
|
||||
&& o.auth.state == ServiceState::Running
|
||||
&& o.world.state == ServiceState::Running
|
||||
&& o.secondary_world
|
||||
.as_ref()
|
||||
.is_none_or(|s| s.state == ServiceState::Running)
|
||||
&& o.extra_worlds().all(|s| s.state == ServiceState::Running)
|
||||
{
|
||||
let since = ready_since.get_or_insert_with(std::time::Instant::now);
|
||||
if since.elapsed() >= std::time::Duration::from_secs(10) {
|
||||
@@ -1870,7 +1960,26 @@ impl RepackEnv<'_> {
|
||||
};
|
||||
if healthy {
|
||||
crate::backup::with_database(self.root, |db| {
|
||||
verify_database_identities(db, &identities)
|
||||
verify_database_identities(db, &identities)?;
|
||||
if check_schema {
|
||||
for mode in crate::realms::state(self.root)?.modes() {
|
||||
if let Some(problem) = crate::schema_check::check_update_with_report(
|
||||
&db.clone().for_realm(mode),
|
||||
self.root,
|
||||
baseline.as_ref(),
|
||||
)?
|
||||
.first()
|
||||
{
|
||||
return Err(Error::Invalid(format!(
|
||||
"Database validation failed after startup on {}: {}: {}",
|
||||
mode.name(),
|
||||
problem.table,
|
||||
problem.detail
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
})?;
|
||||
return Ok(());
|
||||
}
|
||||
@@ -1893,6 +2002,7 @@ fn migrate_databases(
|
||||
manifest: &Manifest,
|
||||
staged: &Path,
|
||||
snapshot: &dyn Fn() -> Result<String>,
|
||||
baseline: Option<&crate::character_start_check::Baseline>,
|
||||
) -> Result<ApplyReport> {
|
||||
let realms = crate::realms::state(root)?;
|
||||
let modes = realms.modes();
|
||||
@@ -1944,7 +2054,8 @@ fn migrate_databases(
|
||||
return Ok(result);
|
||||
}
|
||||
crate::schema_check::repair_missing_defaults(&db, root, contract)?;
|
||||
if let Some(p) = crate::schema_check::check_with_report(&db, root)?.first() {
|
||||
if let Some(p) = crate::schema_check::check_update_with_report(&db, root, baseline)?.first()
|
||||
{
|
||||
return Err(Error::Invalid(format!(
|
||||
"Database validation failed on {}: {}.{}: {}",
|
||||
mode.name(),
|
||||
@@ -2011,6 +2122,8 @@ mod tests {
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
||||
struct Fake {
|
||||
character_baseline: RefCell<Option<crate::character_start_check::Baseline>>,
|
||||
baseline_failed: Cell<bool>,
|
||||
activation_expected: RefCell<Option<(PathBuf, String)>>,
|
||||
activation_failed: Cell<bool>,
|
||||
activated: Cell<bool>,
|
||||
@@ -2028,6 +2141,8 @@ mod tests {
|
||||
impl Fake {
|
||||
fn ok() -> Fake {
|
||||
Fake {
|
||||
character_baseline: RefCell::new(None),
|
||||
baseline_failed: Cell::new(false),
|
||||
activation_expected: RefCell::new(None),
|
||||
activation_failed: Cell::new(false),
|
||||
activated: Cell::new(false),
|
||||
@@ -2045,6 +2160,14 @@ mod tests {
|
||||
}
|
||||
|
||||
impl Env for Fake {
|
||||
fn character_start_baseline(
|
||||
&self,
|
||||
) -> Result<Option<crate::character_start_check::Baseline>> {
|
||||
if self.baseline_failed.get() {
|
||||
return Err(Error::Invalid("fixture baseline unavailable".into()));
|
||||
}
|
||||
Ok(self.character_baseline.borrow().clone())
|
||||
}
|
||||
fn activate(&self) -> Result<()> {
|
||||
if let Some((meta, version)) = self.activation_expected.borrow().as_ref() {
|
||||
ensure_recovered(meta)?;
|
||||
@@ -3486,4 +3609,115 @@ mod tests {
|
||||
.iter()
|
||||
.any(|i| i.path == "Core/newfile.dll" && i.action == Action::Create));
|
||||
}
|
||||
fn baseline_fixture() -> crate::character_start_check::Baseline {
|
||||
crate::character_start_check::Baseline {
|
||||
schema: 1,
|
||||
realms: BTreeMap::from([(
|
||||
"coa".into(),
|
||||
crate::character_start_check::parse_missing("1\t44\t14\n2\t44\t14\n3\t44\t14")
|
||||
.unwrap(),
|
||||
)]),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn character_baseline_is_captured_once_persisted_and_verified_for_retry() {
|
||||
let w = world(&[], true);
|
||||
let env = Fake::ok();
|
||||
*env.character_baseline.borrow_mut() = Some(baseline_fixture());
|
||||
env.healthy.set(false);
|
||||
let out = run(&w, &env, BTreeMap::new(), None).unwrap();
|
||||
assert_eq!(out.txn.state, State::NeedsDecision);
|
||||
assert_eq!(out.preexisting_character_count, 3);
|
||||
let baseline_path = txn_dir(&w.meta, &out.txn.id)
|
||||
.unwrap()
|
||||
.join(CHARACTER_BASELINE);
|
||||
let original = fs::read(&baseline_path).unwrap();
|
||||
assert_eq!(
|
||||
read_character_baseline(&w.meta, &out.txn)
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.realms["coa"]
|
||||
.len(),
|
||||
3
|
||||
);
|
||||
// A retry may not learn new gaps from an already modified database.
|
||||
*env.character_baseline.borrow_mut() = None;
|
||||
env.healthy.set(true);
|
||||
fs::write(&baseline_path, b"{}").unwrap();
|
||||
assert!(retry_validation(
|
||||
&w.root,
|
||||
&w.meta,
|
||||
&out.txn.id,
|
||||
&Source::Dir(w.pkg.clone()),
|
||||
&w.key,
|
||||
&env
|
||||
)
|
||||
.is_err());
|
||||
fs::write(&baseline_path, original).unwrap();
|
||||
let done = retry_validation(
|
||||
&w.root,
|
||||
&w.meta,
|
||||
&out.txn.id,
|
||||
&Source::Dir(w.pkg.clone()),
|
||||
&w.key,
|
||||
&env,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(done.state, State::Committed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn corrupt_character_baseline_does_not_prevent_safe_rollback() {
|
||||
let w = world(&[], true);
|
||||
let env = Fake::ok();
|
||||
*env.character_baseline.borrow_mut() = Some(baseline_fixture());
|
||||
env.healthy.set(false);
|
||||
let out = run(&w, &env, BTreeMap::new(), None).unwrap();
|
||||
fs::write(
|
||||
txn_dir(&w.meta, &out.txn.id)
|
||||
.unwrap()
|
||||
.join(CHARACTER_BASELINE),
|
||||
b"bad",
|
||||
)
|
||||
.unwrap();
|
||||
let restored = rollback(&w.root, &w.meta, &out.txn.id, &env).unwrap();
|
||||
assert_eq!(restored.state, State::RolledBack);
|
||||
assert_eq!(read(&w, "Core/worldserver.exe"), b"world-v1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_or_unverified_character_baselines_fail_closed() {
|
||||
let w = world(&[], true);
|
||||
let env = Fake::ok();
|
||||
env.healthy.set(false);
|
||||
let out = run(&w, &env, BTreeMap::new(), None).unwrap();
|
||||
assert!(read_character_baseline(&w.meta, &out.txn)
|
||||
.unwrap()
|
||||
.is_none());
|
||||
let path = txn_dir(&w.meta, &out.txn.id)
|
||||
.unwrap()
|
||||
.join(CHARACTER_BASELINE);
|
||||
fsx::atomic_write_json(&path, &baseline_fixture()).unwrap();
|
||||
assert!(read_character_baseline(&w.meta, &out.txn).is_err());
|
||||
let mut txn = out.txn;
|
||||
txn.recovery_hashes.insert(
|
||||
CHARACTER_BASELINE_HASH.into(),
|
||||
fsx::sha256_file(&path).unwrap(),
|
||||
);
|
||||
fs::remove_file(path).unwrap();
|
||||
assert!(read_character_baseline(&w.meta, &txn).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn baseline_capture_failure_precedes_file_and_database_changes() {
|
||||
let w = world(&[], true);
|
||||
let env = Fake::ok();
|
||||
env.baseline_failed.set(true);
|
||||
assert!(run(&w, &env, BTreeMap::new(), None).is_err());
|
||||
assert_eq!(read(&w, "Core/worldserver.exe"), b"world-v1");
|
||||
assert!(!env.calls.borrow().contains(&"migrate"));
|
||||
assert!(!env.calls.borrow().contains(&"validate"));
|
||||
assert!(unfinished(&w.meta).is_none());
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,20 @@ const FILES: &[&str] = &[
|
||||
".realms/secondary/Core/configs/worldserver.conf",
|
||||
".realms/secondary/Core/configs/authserver.conf",
|
||||
"Settings/realm-profiles/reborn.json",
|
||||
".realms/reborn/Settings/repack.json",
|
||||
".realms/reborn/Settings/realm-profile.json",
|
||||
".realms/reborn/Settings/worldserver.conf.template",
|
||||
".realms/reborn/Settings/authserver.conf.template",
|
||||
".realms/reborn/Core/configs/worldserver.conf",
|
||||
".realms/reborn/Core/configs/authserver.conf",
|
||||
];
|
||||
|
||||
/// Ports of the extra worlds kept in the realm profile.
|
||||
const REALM_PORT_KEYS: [&str; 4] = [
|
||||
"secondary_world_port",
|
||||
"secondary_ra_port",
|
||||
"reborn_world_port",
|
||||
"reborn_ra_port",
|
||||
];
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
@@ -27,6 +41,24 @@ struct Saved {
|
||||
sha256: Option<String>,
|
||||
}
|
||||
|
||||
fn bot_files() -> Vec<String> {
|
||||
["", ".realms/secondary/", ".realms/reborn/"]
|
||||
.into_iter()
|
||||
.flat_map(|prefix| {
|
||||
[
|
||||
"mod_coa_playerbots.conf",
|
||||
"mod_coa_playerbots.conf.dist",
|
||||
"playerbots.conf",
|
||||
"playerbots.conf.dist",
|
||||
"mod_playerbots.conf",
|
||||
"mod_playerbots.conf.dist",
|
||||
]
|
||||
.into_iter()
|
||||
.map(move |name| format!("{prefix}Core/configs/modules/{name}"))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub(crate) fn pending(meta: &Path) -> bool {
|
||||
meta.join("validation-configs.json").exists()
|
||||
}
|
||||
@@ -38,15 +70,20 @@ pub(crate) fn begin(root: &Path, meta: &Path) -> Result<()> {
|
||||
));
|
||||
}
|
||||
let mut saved = BTreeMap::new();
|
||||
for rel in FILES {
|
||||
let path = fsx::ensure_within(root, &fsx::safe_join(root, rel)?)?;
|
||||
let modules = bot_files();
|
||||
for rel in FILES
|
||||
.iter()
|
||||
.map(|rel| rel.to_string())
|
||||
.chain(modules.iter().cloned())
|
||||
{
|
||||
let path = fsx::ensure_within(root, &fsx::safe_join(root, &rel)?)?;
|
||||
let bytes = if path.exists() {
|
||||
Some(fs::read(path)?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let sha256 = bytes.as_ref().map(|b| fsx::sha256_bytes(b));
|
||||
saved.insert(*rel, Saved { bytes, sha256 });
|
||||
saved.insert(rel, Saved { bytes, sha256 });
|
||||
}
|
||||
let mut settings: serde_json::Value = fsx::read_json(&root.join("Settings/repack.json"))?;
|
||||
let mut realm: Option<serde_json::Value> = if root.join("Settings/realm-profile.json").exists()
|
||||
@@ -62,7 +99,7 @@ pub(crate) fn begin(root: &Path, meta: &Path) -> Result<()> {
|
||||
.collect();
|
||||
if let Some(state) = &realm {
|
||||
excluded.extend(
|
||||
["secondary_world_port", "secondary_ra_port"]
|
||||
REALM_PORT_KEYS
|
||||
.iter()
|
||||
.filter_map(|key| state[*key].as_u64()),
|
||||
);
|
||||
@@ -82,19 +119,19 @@ pub(crate) fn begin(root: &Path, meta: &Path) -> Result<()> {
|
||||
settings[key] = reserve()?.into();
|
||||
}
|
||||
if let Some(state) = &mut realm {
|
||||
for key in ["secondary_world_port", "secondary_ra_port"] {
|
||||
for key in REALM_PORT_KEYS {
|
||||
state[key] = reserve()?.into();
|
||||
}
|
||||
}
|
||||
let mut configs = Vec::new();
|
||||
for rel in [
|
||||
"Settings/worldserver.conf.template",
|
||||
"Settings/authserver.conf.template",
|
||||
"Core/configs/worldserver.conf",
|
||||
"Core/configs/authserver.conf",
|
||||
] {
|
||||
for rel in FILES.iter().copied().filter(|rel| {
|
||||
rel.ends_with("worldserver.conf.template")
|
||||
|| rel.ends_with("authserver.conf.template")
|
||||
|| rel.ends_with("worldserver.conf")
|
||||
|| rel.ends_with("authserver.conf")
|
||||
}) {
|
||||
let path = root.join(rel);
|
||||
if !path.exists() && rel.ends_with(".template") {
|
||||
if !path.exists() && rel.ends_with(".template") && !rel.starts_with(".realms/") {
|
||||
return Err(Error::Invalid(format!(
|
||||
"Cannot isolate validation without {rel}."
|
||||
)));
|
||||
@@ -104,10 +141,34 @@ pub(crate) fn begin(root: &Path, meta: &Path) -> Result<()> {
|
||||
conf.set("BindIP", "\"127.0.0.1\"", &[]);
|
||||
if rel.contains("worldserver") {
|
||||
conf.set("Ra.IP", "\"127.0.0.1\"", &[]);
|
||||
conf.set("CoA.ValidationMode", "1", &[]);
|
||||
}
|
||||
configs.push((path, conf.to_text()));
|
||||
}
|
||||
}
|
||||
for rel in modules {
|
||||
let path = fsx::ensure_within(root, &fsx::safe_join(root, &rel)?)?;
|
||||
if !path.exists() {
|
||||
continue;
|
||||
}
|
||||
let mut conf = ConfFile::parse_bytes(&fs::read(&path)?)?;
|
||||
let keys: &[&str] = if rel.contains("mod_coa_playerbots.") {
|
||||
&[
|
||||
"CoaBots.AutoLoginOnStartup",
|
||||
"CoaBots.RandomSpawn.AutoLogin",
|
||||
]
|
||||
} else {
|
||||
&[
|
||||
"AiPlayerbot.RandomBotAutologin",
|
||||
"AiPlayerbot.BotAutologin",
|
||||
"AiPlayerbot.DeleteRandomBotAccounts",
|
||||
]
|
||||
};
|
||||
for key in keys {
|
||||
conf.set(key, "0", &[]);
|
||||
}
|
||||
configs.push((path, conf.to_text()));
|
||||
}
|
||||
fsx::atomic_write_json(&meta.join("validation-configs.json"), &saved)?;
|
||||
fsx::atomic_write_json(&root.join("Settings/repack.json"), &settings)?;
|
||||
if let Some(state) = realm {
|
||||
@@ -125,16 +186,20 @@ pub(crate) fn restore(root: &Path, meta: &Path) -> Result<()> {
|
||||
}
|
||||
let journal = meta.join("validation-configs.json");
|
||||
let saved: BTreeMap<String, Saved> = fsx::read_json(&journal)?;
|
||||
// Previous managers could journal only the first two profiles. Recover those
|
||||
// journals too, while continuing to reject missing or unknown legacy entries.
|
||||
let legacy = saved.len() == FILES.len() - 1
|
||||
let modules = bot_files();
|
||||
let complete_core = FILES.iter().all(|rel| saved.contains_key(*rel));
|
||||
let legacy_core = FILES
|
||||
.iter()
|
||||
.filter(|rel| **rel != "Settings/realm-profiles/reborn.json")
|
||||
.all(|rel| saved.contains_key(*rel));
|
||||
let current = complete_core
|
||||
&& saved.len() == FILES.len() + modules.len()
|
||||
&& modules.iter().all(|rel| saved.contains_key(rel));
|
||||
let previous = complete_core && saved.len() == FILES.len();
|
||||
let legacy = legacy_core
|
||||
&& saved.len() == FILES.len() - 1
|
||||
&& !saved.contains_key("Settings/realm-profiles/reborn.json");
|
||||
let required = if legacy {
|
||||
&FILES[..FILES.len() - 1]
|
||||
} else {
|
||||
FILES
|
||||
};
|
||||
if saved.len() != required.len() || required.iter().any(|rel| !saved.contains_key(*rel)) {
|
||||
if !(current || previous || legacy) {
|
||||
return Err(Error::Invalid(
|
||||
"Isolated validation configuration journal is incomplete.".into(),
|
||||
));
|
||||
@@ -249,4 +314,92 @@ mod tests {
|
||||
assert!(!pending(&meta));
|
||||
assert_eq!(fs::read(root.join(FILES[0])).unwrap(), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bot_population_is_suppressed_in_all_realms_and_restored_exactly() {
|
||||
let (_dir, root, meta) = fixture();
|
||||
let companion = b"[worldserver]\r\n# owner settings\r\nCoaBots.Enable = 1\r\nCoaBots.AutoLoginOnStartup = 1\r\nCoaBots.RandomSpawn.AutoLogin = 1\r\nCoaBots.AutoLogin.MaxCount = 2000\r\n";
|
||||
let squid = b"[worldserver]\nAiPlayerbot.Enabled = 1\nAiPlayerbot.RandomBotAutologin = 1\nAiPlayerbot.BotAutologin = 1\nAiPlayerbot.DeleteRandomBotAccounts = 1\n";
|
||||
for rel in bot_files() {
|
||||
fsx::atomic_write(
|
||||
&root.join(&rel),
|
||||
if rel.contains("mod_coa_playerbots.") {
|
||||
companion
|
||||
} else {
|
||||
squid
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
begin(&root, &meta).unwrap();
|
||||
for rel in bot_files() {
|
||||
let conf = ConfFile::parse_bytes(&fs::read(root.join(&rel)).unwrap()).unwrap();
|
||||
if rel.contains("mod_coa_playerbots.") {
|
||||
assert_eq!(conf.get("CoaBots.Enable"), Some("1"));
|
||||
assert_eq!(conf.get("CoaBots.AutoLoginOnStartup"), Some("0"));
|
||||
assert_eq!(conf.get("CoaBots.RandomSpawn.AutoLogin"), Some("0"));
|
||||
assert_eq!(conf.get("CoaBots.AutoLogin.MaxCount"), Some("2000"));
|
||||
} else {
|
||||
assert_eq!(conf.get("AiPlayerbot.Enabled"), Some("1"));
|
||||
assert_eq!(conf.get("AiPlayerbot.RandomBotAutologin"), Some("0"));
|
||||
assert_eq!(conf.get("AiPlayerbot.BotAutologin"), Some("0"));
|
||||
assert_eq!(conf.get("AiPlayerbot.DeleteRandomBotAccounts"), Some("0"));
|
||||
}
|
||||
}
|
||||
restore(&root, &meta).unwrap();
|
||||
for rel in bot_files() {
|
||||
assert_eq!(
|
||||
fs::read(root.join(&rel)).unwrap(),
|
||||
if rel.contains("mod_coa_playerbots.") {
|
||||
companion.as_slice()
|
||||
} else {
|
||||
squid.as_slice()
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn validation_removes_only_module_configs_created_during_the_check() {
|
||||
let (_dir, root, meta) = fixture();
|
||||
let dist = root.join("Core/configs/modules/mod_coa_playerbots.conf.dist");
|
||||
let active = root.join("Core/configs/modules/mod_coa_playerbots.conf");
|
||||
let original = b"CoaBots.AutoLoginOnStartup = 1\n";
|
||||
fsx::atomic_write(&dist, original).unwrap();
|
||||
begin(&root, &meta).unwrap();
|
||||
fs::copy(&dist, &active).unwrap();
|
||||
restore(&root, &meta).unwrap();
|
||||
assert!(!active.exists());
|
||||
assert_eq!(fs::read(dist).unwrap(), original);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn previous_manager_journals_remain_recoverable() {
|
||||
for without_reborn in [false, true] {
|
||||
let (_dir, root, meta) = fixture();
|
||||
begin(&root, &meta).unwrap();
|
||||
let journal = meta.join("validation-configs.json");
|
||||
let mut saved: BTreeMap<String, Saved> = fsx::read_json(&journal).unwrap();
|
||||
saved.retain(|key, _| FILES.contains(&key.as_str()));
|
||||
if without_reborn {
|
||||
saved.remove("Settings/realm-profiles/reborn.json");
|
||||
}
|
||||
fsx::atomic_write_json(&journal, &saved).unwrap();
|
||||
restore(&root, &meta).unwrap();
|
||||
assert!(!pending(&meta));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn incomplete_bot_journal_blocks_restoration_before_writing() {
|
||||
let (_dir, root, meta) = fixture();
|
||||
begin(&root, &meta).unwrap();
|
||||
let journal = meta.join("validation-configs.json");
|
||||
let mut saved: BTreeMap<String, Saved> = fsx::read_json(&journal).unwrap();
|
||||
saved.remove(&bot_files()[0]);
|
||||
fsx::atomic_write_json(&journal, &saved).unwrap();
|
||||
let before = fs::read(root.join(FILES[2])).unwrap();
|
||||
assert!(restore(&root, &meta).is_err());
|
||||
assert_eq!(fs::read(root.join(FILES[2])).unwrap(), before);
|
||||
}
|
||||
}
|
||||
@@ -94,8 +94,9 @@ fn run() -> Result<(), String> {
|
||||
.map_err(e)?;
|
||||
}
|
||||
"qualify-install" => {
|
||||
let report = coa_core::release_schema::qualify_install(
|
||||
let report = coa_core::release_schema::qualify_install_against(
|
||||
&PathBuf::from(need(&a, "package")?),
|
||||
Some(&PathBuf::from(need(&a, "update")?)),
|
||||
&PathBuf::from(need(&a, "fixture")?),
|
||||
coa_core::signing::EMBEDDED_PUBLIC_KEY,
|
||||
)
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
# Existing Hide Races filter: internal research
|
||||
|
||||
Inspected 2026-10-27. No installed game files were changed. No game, server, database or desktop
|
||||
automation was used for this investigation.
|
||||
|
||||
## Evidence
|
||||
|
||||
The owner supplied screenshots of the creation screen and Hide Races panel. The previously
|
||||
extracted `Interface/GlueXML/CharacterCreate.lua` from `patch-ZZZF.MPQ` contains this implementation.
|
||||
SHA-256 of the extracted Lua: `8816ef9b6839652db60da6de7d2a6d09ceed1f80323ca5c8e55271a4d5aacac3`.
|
||||
This identifies the inspected file, not proven runtime archive precedence.
|
||||
|
||||
Line numbers below refer to the original LF-delimited file, ignoring carriage-return bytes.
|
||||
The game source remains outside Git at `C:/games/source/per-race-evidence/`.
|
||||
|
||||
| Function / lines | Confirmed behavior |
|
||||
| --- | --- |
|
||||
| `CharacterCreate_LayoutRaceButtons`, 138–185 | Reads hidden entries by `#<button index>`, displayed name or lowercase name; hides and relays out buttons by faction |
|
||||
| Same function, 173–180 | If no button remains visible, shows every button and clears its hidden marker |
|
||||
| `CharacterCreateEnumerateRaces`, 1864–1899 | Uses native name/English-name/enabled triples; button indices follow enumeration order |
|
||||
| `CharacterCreate_Finish`, 2184–2212 | Delegates to `CoACharacterNames.CreateCharacter`; no filter-policy check is present in this function |
|
||||
| `CHAR_CREATE_RACE_IDS` and `SetRace` wrapper, 3404–3459 | Maps English display names and repeated occurrence order to a `bonusRaceID` originally used for racial text |
|
||||
| Filter persistence, 4603–4701 | Registers `coaHiddenRaces` and `coaHiddenRaces2`; writes with `SetCVar` and optional C_Config setters/save, all protected by `pcall` |
|
||||
| `RaceEntries`, 4703 onward | Displayed RaceID comes from `bonusRaceID`, first name-map ID, or finally button index |
|
||||
| Row click, 4844–4856 | Saves the displayed name and `#<button index>`; the displayed RaceID is not the saved key |
|
||||
| `SetAllChecked`, 4977–4985 | Builds the same name/index set; does not apply a server policy |
|
||||
| Save handler, 4988–4995 | Stores draft and relays out buttons; does not explicitly choose a permitted replacement race |
|
||||
| Row refresh, 5018–5041 | Stores `info.id` (button index) in `row.raceId`, while the label displays `info.raceID` |
|
||||
| Click wrapper, 5056–5069 | Redirects a click on a hidden button to the first visible one |
|
||||
|
||||
The name-to-ID table is hardcoded and extended repeatedly later in the Lua. Examples of paired
|
||||
names: Pandaren `{29,20}`, Murloc `{30,31}`, Earthen `{68,69}`, Haranir `{71,70}`,
|
||||
Centaur `{75,102}` and Drakonid `{100,98}`. Name localization and enumeration-order changes
|
||||
need validation; this table is not a universal verified RaceID API.
|
||||
|
||||
## Offline reproduction
|
||||
|
||||
An isolated harness executed the actual extracted layout, persistence and click-wrapper functions
|
||||
using the already installed `lupa.lua51` runtime. Buttons, CVar storage, faction lookup and filter
|
||||
button creation were mocked. No render, native race API, packet send, account or database was used.
|
||||
|
||||
Harness: `C:/games/source/per-race-evidence/probe_existing_filter.py`.
|
||||
Machine-readable results: `C:/games/source/per-race-evidence/existing-filter-probe.json`.
|
||||
|
||||
All nine assertions were confirmed:
|
||||
|
||||
1. Saving one Pandaren by name hides both same-named Pandaren buttons.
|
||||
2. A saved index plus saved name can hide two different races after reordering.
|
||||
3. Hiding all buttons makes the layout show all buttons again.
|
||||
4. Saving 128 synthetic index entries persists at most 480 characters; a fresh runtime recovered
|
||||
only 115 of those indices. The exact losses depend on the input and sort order.
|
||||
5. Saving/hiding the currently selected button leaves the harness's selection unchanged.
|
||||
6. Clicking a hidden button redirects to the first visible one.
|
||||
7. The same preference values apply across independent Glue runtimes; no realm identifier is read.
|
||||
8. Saving `#82` does not hide Sethrak at button index 2, even when the button's `bonusRaceID`
|
||||
is 82. Current serialization cannot simply be given real IDs instead of indices.
|
||||
9. If persistent setters fail, saving still updates the in-memory list and reports no failure;
|
||||
a fresh runtime loses that list. Protected calls suppress the errors.
|
||||
|
||||
The initial harness run lacked a stub for filter-button creation and failed six checks before
|
||||
their assertions; adding that UI stub allowed the original assertions to run and pass. The later
|
||||
expanded run passed all nine assertions. This correction
|
||||
did not modify the inspected game Lua. These results are offline behavior checks, not live acceptance.
|
||||
|
||||
## Persistence and identity cross-check
|
||||
|
||||
Read-only searches of both the primary client and isolated copy found no `coaHiddenRaces` or
|
||||
`coaHiddenRaces2` entries in their `WTF/Config.wtf` or `WTF/Custom/GlueConfig.json`, or in the
|
||||
searched text configuration files. There is therefore no observed on-disk value establishing
|
||||
where this installation persists the list. The presence of `SetCVar` calls alone does not prove
|
||||
that an arbitrary registered CVar is archived. C_Config setters/save are optional and their
|
||||
failures are suppressed. Physical persistence must be verified later by a controlled save/exit
|
||||
and file comparison, when the owner allows game testing. The earlier Config.wtf suggestion
|
||||
remains a hypothesis, not an established path.
|
||||
|
||||
Listfile-guided scanning of Lua members in patch-B, patch-T and patch-ZZZF found the filter's
|
||||
setter calls but no implementation of these C_Config persistence methods. This does not establish
|
||||
their absence at runtime: native code or another archive may provide them. No native client code
|
||||
was executed or patched to investigate this.
|
||||
|
||||
The final `CHAR_CREATE_RACE_IDS` map was reconstructed by executing its literal declarations and
|
||||
subsequent assignments in Lua 5.1. All 73 inspected ChrRaces rows whose NOT_PLAYABLE bit is clear
|
||||
are represented by their English name and actual ID in that map. The comparison includes final
|
||||
overrides, rather than only the initial table. Result:
|
||||
`C:/games/source/per-race-evidence/race-filter-id-map-audit.json`.
|
||||
|
||||
This is good evidence that the map can support this version's UI integration. It is not proof
|
||||
that each runtime button is assigned the right ID: repeated names depend on occurrence order,
|
||||
the engine may enumerate a different set/order, and localized labels may not match the English
|
||||
keys. `bonusRaceID` remains a candidate identity, not an authoritative native lookup.
|
||||
|
||||
## Suitability for CSM
|
||||
|
||||
The existing layout and UI are useful foundations. Directly replacing `coaHiddenRaces` with owner
|
||||
restrictions is unsuitable: the player can clear the list, names can collide, indices can shift,
|
||||
serialization truncates and the preferences are not realm-scoped. It would also overwrite the
|
||||
player's own display choices. A local filter cannot enforce server creation policy.
|
||||
|
||||
Recommended integration to investigate next:
|
||||
|
||||
- Keep personal Hide Races preferences independent from the server-managed disabled RaceID set.
|
||||
- Resolve actual RaceID per button from validated version-specific client data and faction/identity.
|
||||
Never use a button-index fallback as an authoritative RaceID. Ambiguous mapping is unsupported,
|
||||
not permission to hide another race with the same name.
|
||||
- Compute visibility from personal preference OR the server restriction. Check All may clear
|
||||
personal preferences but must not remove the server restriction.
|
||||
- Preserve stock-race behavior and the existing layout, class-selection and Esteria wrappers.
|
||||
The empty-layout fallback must not reveal a server-prohibited race.
|
||||
- Validate selected race before advancing/creating, including after save, randomization, sex
|
||||
changes and native selection resets. Do not renumber native race indices.
|
||||
- Reconcile the selected local realm before PLAY with the client closed. Do not guess public-server
|
||||
policy or mutate the player's saved preference when switching realms.
|
||||
- Independently enforce creation on the server and in new-bot factories, preserving existing
|
||||
character login/import and existing-bot admission.
|
||||
|
||||
One possible delivery is a small GlueXML extension in the single managed overlay, reusing existing
|
||||
layout entry points while supplying a separately generated policy table. This is a proposal, not
|
||||
an existing API or a selected filename. It still requires proven loading order and live validation.
|
||||
An alternative CVar-based channel needs its own persistence and truncation checks and must not
|
||||
reuse the personal hidden-list keys.
|
||||
|
||||
## Decision
|
||||
|
||||
Prioritize investigation of the existing GlueXML mechanism as the client integration candidate.
|
||||
Do not yet commit to a DBC-only overlay, and do not declare the DBC hypothesis failed: it has not
|
||||
been live-tested. No gameplay/client support claim follows from these screenshots or mock tests.
|
||||
|
||||
The next live acceptance must establish correct real RaceID mapping, one disabled race, independent
|
||||
faction variants, selected-race replacement, Check All resistance to owner-policy removal, ordinary
|
||||
race creation, existing-character login and profile switching. Interactive/database tests remain
|
||||
deferred at the owner's request.
|
||||
|
||||
## User-operated visibility experiment and disabled-row prototype
|
||||
|
||||
The owner subsequently authorized a temporary patch in the isolated client. The first probe added
|
||||
only a real-ID predicate for Sethrak 82, Gnoll 83 and Saberon 97 to the existing layout. A single
|
||||
`Data/patch-ZZZZZ.MPQ` contained the modified CharacterCreate.lua; original archives and DBCs
|
||||
were unchanged. The owner reported the races disappeared and supplied screenshots consistent
|
||||
with that result. This is evidence that this particular Lua overlay affects this installation's
|
||||
creation screen, not proof of universal MPQ precedence or completed creation/login tests.
|
||||
|
||||
The owner then selected the UI behavior: hide owner-prohibited races on the creation screen;
|
||||
show them grey, unchecked and disabled in Hide Races, with a server-disabled label. Personal
|
||||
preferences remain independent, including when the owner later re-enables the race.
|
||||
|
||||
`tools/race_visibility_lua_poc.py` now generates a version-pinned second laboratory probe. It
|
||||
accepts only the exact inspected Lua fingerprint and the three previously tested RaceIDs.
|
||||
Unknown identity is not interpreted as a button index. It guards disabled row clicks, restores
|
||||
enabled state when a scroll row is reused, and prevents the empty-layout fallback from revealing
|
||||
an owner-prohibited race. The disabled label has EN/RU/DE/FR/ES/ZH translations.
|
||||
|
||||
Eleven tests passed under Lua 5.1, covering syntax, disabled row state, personal preference,
|
||||
scroll-row reuse, ambiguous identity, Check All, direct disabled-row click, six translations,
|
||||
unsupported input rejection, empty-layout fallback and lifting restrictions.
|
||||
|
||||
Probe v2 was MPQ-roundtrip verified and installed only after observing that the isolated client
|
||||
was closed. The previous owned probe's SHA-256 was checked before replacement, the existing
|
||||
client patch lock was held, and the prior bytes were preserved outside the client. Its evidence
|
||||
is `C:/games/source/per-race-evidence/lua-visibility-probe-v2/report.json`.
|
||||
The primary client, all databases and all server processes were untouched.
|
||||
|
||||
This prototype still contains a fixed laboratory restriction set, not the future server-driven
|
||||
policy. The owner confirmed grey, unchecked rows for the three probe races in game and supplied
|
||||
screenshots. Selected-race validation, realm policy
|
||||
reconciliation, source update handling, server enforcement and new-bot integration remain work.
|
||||
@@ -0,0 +1,145 @@
|
||||
# Per-race toggles: internal design and implementation status
|
||||
|
||||
This is an internal specification and work-in-progress record, not a released user guide.
|
||||
Current verdict: **PARTIAL**. Client hiding and disabled rows were confirmed by the owner;
|
||||
server policy, new-bot integration and Manager controls are now implemented in feature branches.
|
||||
Native build qualification and server gameplay acceptance are still pending.
|
||||
|
||||
See [audit](../PER_RACE_TOGGLES_AUDIT.md) and [verification record](PER_RACE_TOGGLES_TESTS.md).
|
||||
|
||||
## Verified data and outstanding client decision
|
||||
|
||||
The local manifest identifies CoA Custom 1.9.2. The candidate source archive is `patch-ZZZF.MPQ`.
|
||||
Its ChrRaces has WDBC layout 95/69/276/2428 (records/fields/record bytes/string bytes).
|
||||
Its DBC SHA-256 is `b78635b08bf0bd63d2898fce97c1fb162c8a9c41632703172eefa88bae79061f`.
|
||||
Observed IDs include Sethrak 82, Gnoll 83 and Saberon 97, all initially Flags 12.
|
||||
|
||||
The experiment sets `originalFlags | 0x01` only for selected IDs. Empty selection preserves
|
||||
every original byte. Each run reads the explicitly selected source MPQ anew; it never consumes
|
||||
the previous generated DBC. Re-enabling must restore the original record, including an original
|
||||
NOT_PLAYABLE bit if present; it must not make an originally nonplayable race playable.
|
||||
|
||||
These observations do not qualify a client version. Actual archive precedence, menu behavior,
|
||||
other-race creation and existing-character login are untested. No managed overlay filename has
|
||||
been chosen. The tool does not infer precedence from filename sorting.
|
||||
|
||||
## Intended integration
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
P[Existing realm configuration snapshot] --> S[Server creation policy]
|
||||
P --> G[Availability generation, after client qualification]
|
||||
O[Original effective client DBC] --> G
|
||||
G --> V[Validate bytes and MPQ roundtrip]
|
||||
V --> T[Existing client lock and transaction journal]
|
||||
T --> M[One managed overlay]
|
||||
S --> H[Normal account creation hook]
|
||||
S --> C[Companions new-character creation]
|
||||
S --> Q[SQUID new-character creation]
|
||||
```
|
||||
|
||||
The new server key is `CoACustomRaces.DisabledRaceIds` in the existing module config.
|
||||
It requires a newly built server; no installed server binary has been replaced. Empty or missing
|
||||
key retains the previous master-switch behavior.
|
||||
Validate the entire set before applying it; reject malformed, unknown and stock IDs without a
|
||||
partial policy. Validate identity against effective server/client data, not numeric ranges alone.
|
||||
|
||||
Creation policy is independent of login and import. It must not modify existing characters,
|
||||
appearance, items, spells, progress or Portable Characters identity. Bot creation additionally
|
||||
obeys master switches, module switches, user exclusions and crashing-race restrictions. Existing
|
||||
bot admission must not inherit a new-character restriction accidentally.
|
||||
|
||||
Use current module configuration, additive `.dist` merge and `Settings/realm-profiles/` snapshots.
|
||||
Do not introduce another authoritative policy store. The future client record is provenance and
|
||||
ownership metadata, not a replacement for the realm configuration.
|
||||
|
||||
Local PLAY must reconcile the selected profile before launch while the client is closed, using
|
||||
the same `.coa-races.lock` as package operations. Shared clients have one currently installed
|
||||
overlay; remote policies cannot be guessed. Unknown formats or conflicting ownership must fail
|
||||
with a truthful status. Client and server application status must be separate in the UI.
|
||||
|
||||
Client repair/update must invalidate the previous overlay when the original effective DBC
|
||||
changes and regenerate from the new original only after compatibility checks. Empty restrictions
|
||||
must remove only the verified CSM-owned overlay. Actual install/recovery/update behavior is
|
||||
not implemented by the offline tool.
|
||||
|
||||
## Offline tool
|
||||
|
||||
`tools/race_availability_poc.py` extracts with an explicitly supplied, existing Unicode StormLib
|
||||
DLL. That DLL is a laboratory dependency only; no Manager/user dependency has been selected.
|
||||
The tool writes `original.dbc`, `generated.dbc`, `experiment.MPQ` and `report.json` to a new output
|
||||
directory after successful verification. It never installs an overlay, edits an input MPQ or
|
||||
launches a process. The archive contains one game payload plus StormLib's internal listfile.
|
||||
|
||||
The fingerprint includes original DBC hash, sorted unique disabled IDs, algorithm version and
|
||||
recorded client profile. It supports reproducibility checks; runtime caching is not implemented.
|
||||
An empty selection still produces an offline test artifact so byte equality can be checked;
|
||||
production empty-set removal is a separate, unimplemented requirement.
|
||||
|
||||
No game files or DLLs are checked into Git. Tests generate synthetic DBC/MPQ fixtures locally.
|
||||
No export/distribution feature, release-channel change or publication is included.
|
||||
|
||||
## Remaining acceptance gate
|
||||
|
||||
The owner subsequently confirmed the Lua visibility and disabled-row probes through screenshots.
|
||||
The selected client approach reuses the existing GlueXML filter rather than changing DBC flags.
|
||||
This does not establish whether the earlier DBC-bit hypothesis works.
|
||||
|
||||
The owner deferred database/server testing while another server runs bot tests.
|
||||
Do not launch the game, servers or MySQL or capture/control the screen without renewed authorization.
|
||||
Use the owner-confirmed GlueXML approach for the next client integration stage. It preserves
|
||||
the original DBC. The DBC-bit approach has not been declared incompatible; it was not live-tested.
|
||||
|
||||
## Server controls implemented in the feature branches
|
||||
|
||||
### Maintenance when new races are added
|
||||
|
||||
Whenever upstream adds races, include every new playable custom RaceID in the availability
|
||||
list and verify its name and Horde/Alliance grouping. The Manager reads this list from the
|
||||
installed server catalog automatically; update the server catalog rather than maintaining a
|
||||
second hardcoded UI list. Review and explicitly save existing restrictions after the catalog
|
||||
changes, preserving the owner's choices for unchanged IDs.
|
||||
|
||||
Also update and verify the client Lua RaceID mapping and filtering for the new races. A race
|
||||
appearing in the Manager does not by itself establish client support. Check creation restrictions
|
||||
and new-bot generation in both CoA Companions and SQUID, retaining user and crashing-race exclusions.
|
||||
|
||||
### Current implementation
|
||||
|
||||
Manager exposes a versioned catalog read from the server's `DataDir/dbc_races/ChrRaces.dbc`, with
|
||||
strict WDBC layout/ID/name validation and stock/nonplayable rows excluded. The UI supports search,
|
||||
counts, per-race allow checkboxes, Allow all, explicit Save/Discard and navigation guards. New
|
||||
strings exist in all six Manager languages.
|
||||
|
||||
Saving requires a stopped server, no unfinished update, the existing control lock, an unchanged
|
||||
catalog SHA-256 and the same selected realm as the loaded draft.
|
||||
It uses the normal module backup/config writer. Servers whose distributed configuration does
|
||||
not declare the new key cannot be configured through this control. The executable is also checked
|
||||
for the key, following existing realm capability detection. The UI reports saved settings
|
||||
and restart requirements, not a verified running-server Applied status. Template detection does
|
||||
not independently attest the identity of a manually modified server executable.
|
||||
|
||||
Saved restrictions include the source catalog SHA-256. A changed catalog or orphaned IDs requires
|
||||
explicit review and save; simply opening the panel does not migrate settings. Core and the offline
|
||||
bot factory reject a mismatched bound catalog before creating characters. Empty hashes remain
|
||||
supported for manually authored legacy configurations.
|
||||
|
||||
The core module stages a whole policy, validates configured IDs against loaded server race data,
|
||||
and applies it atomically on startup/reload. Invalid input retains the previous policy; on an
|
||||
initial invalid configuration, new custom creation remains disabled. Stock creation remains
|
||||
available. The normal account hook remains in place and import/login paths are unchanged.
|
||||
|
||||
CoA Companions' common clone entry calls the account creation hook before inserting a new bot;
|
||||
its selection also preserves explicit crashing exclusions. SQUID's random factory calls the
|
||||
same hook while constructing candidate races, without adding owner restrictions to existing-bot
|
||||
admission lists. The offline Companions factory reads configuration and filters prohibited
|
||||
templates before creating accounts or generating insert SQL. No SQL was executed for verification.
|
||||
|
||||
The old Manager synchronization now preserves explicit user race exclusions. It only replaces
|
||||
lists carrying its old ownership comment with an exact known generated value. Crashing-race
|
||||
settings are never rewritten. BotsEnable is read directly from the Custom Races configuration
|
||||
when available rather than inferred from unrelated exclusion choices.
|
||||
|
||||
Automatic production client synchronization and client update invalidation remain unimplemented.
|
||||
Server-side catalog binding is implemented. The fixed three-race test overlay is not automatically changed
|
||||
by these new server controls. This limitation is explicitly visible in the Manager UI.
|
||||
@@ -0,0 +1,92 @@
|
||||
# Per-race toggles: internal verification record
|
||||
|
||||
Date: 2026-10-27. Verdict: **PARTIAL**. Scope: source implementation, native builds and offline verification; live acceptance remains pending.
|
||||
|
||||
Latest source implementation checks additionally include:
|
||||
|
||||
- Manager catalog/configuration tests: 10 passed, including catalog binding, unknown-ID review, stale/invalid input rejection,
|
||||
Allow all, preserving unknown configuration keys and leaving bot exclusions unchanged.
|
||||
- Focused Manager race regression selection: 34 passed, 3 ignored because they require release
|
||||
archives or another writable volume. The three ignored tests are not counted as passes.
|
||||
- Frontend TypeScript/Vite build: passed after correcting the new component's error rendering.
|
||||
- Existing i18n and module-settings checks: passed; new keys exist in all six languages.
|
||||
- Core production-module harness: passed with synthetic Config/DBC stubs through verify_all.
|
||||
- Companions production selector harness and five offline-factory policy tests: passed without
|
||||
running a MySQL client or server.
|
||||
- Complete native core build with staged Companions and SQUID: passed in the dedicated
|
||||
`build-utf8` directory. Final source/build/harness verification passed in
|
||||
`C:/games/source/per-race-core/.cache/verify-all/20261027-112640/report.json`.
|
||||
Unit and gameplay stages were skipped. No installed binaries or services were changed.
|
||||
- Rust Clippy with warnings denied: passed for coa-core.
|
||||
- Final Tauri debug application build: passed after the catalog-review changes. Artifact:
|
||||
`C:/games/source/per-race-manager/target/debug/coa-server-manager.exe`.
|
||||
Frontend bundle-size and localized linker-output warnings were emitted; neither failed the build.
|
||||
|
||||
The first native configure lacked an OpenSSL root. A subsequent build was deliberately stopped
|
||||
when its MSVC dependency prefix was found misencoded. The replacement uses the existing dynamic
|
||||
OpenSSL/MySQL development libraries and a fresh UTF-8 environment. These earlier verify_all runs
|
||||
ended FAILED and are not successful build evidence.
|
||||
|
||||
## Executed automated checks
|
||||
|
||||
Run from the Manager feature checkout:
|
||||
|
||||
```powershell
|
||||
$env:COA_TEST_STORMLIB = '<absolute path to an existing Unicode StormLib DLL>'
|
||||
python -B -m unittest discover -s tools -p 'test_race_availability_*.py' -v
|
||||
```
|
||||
|
||||
The recorded run used the bundled repack Python at
|
||||
`C:/games/CoA Server 2/Runtime/python/python.exe` and the existing DLL at
|
||||
`C:/Users/Dion/AppData/Local/Programs/Python/Python311/Lib/site-packages/pympq/StormLib.dll`.
|
||||
No database or game process is used. Without the explicit DLL environment variable, MPQ tests
|
||||
are skipped; that is not equivalent to the recorded full pass.
|
||||
|
||||
| Group | Result | Actual scope |
|
||||
| --- | --- | --- |
|
||||
| DBC and fingerprint | PASS, 17 tests | Exact changed bytes; 1/5/50 IDs; other bits; original restoration; duplicate normalization; stock/unknown IDs; duplicate/invalid table IDs; corrupt/truncated/unknown layouts; localized name bounds and UTF-8; source/profile/set fingerprint inputs |
|
||||
| Synthetic MPQ | PASS, 8 tests | 1/50 IDs produce one archive; one game payload; extraction equality; identical regenerated DBC/fingerprint; source unchanged; existing output preserved; packaging/readback/read/input errors publish no result; empty set preserves bytes |
|
||||
| Total | PASS, 25 tests, zero skipped | Offline files only |
|
||||
| Real three-race DBC/MPQ | PASS | Sethrak 82, Gnoll 83, Saberon 97; only Flags 12 → 13; one MPQ; re-extracted DBC equals expected; original MPQ hash unchanged |
|
||||
| Existing filter behavior | CONFIRMED, 9 offline assertions | Original extracted Lua functions under Lua 5.1 with UI/CVar mocks; see existing-filter research |
|
||||
| English name/ID map vs original DBC | PASS, 73 rows with NOT_PLAYABLE clear | Every inspected ID appears in the final literal Lua name map; runtime button identity remains unverified |
|
||||
| Managed disabled-row Lua probe | PASS, 11 tests | Lua 5.1 syntax; grey/unchecked/disabled rows; personal choices; scroll reuse; unknown identity; Check All; click guard; six languages; input rejection; layout fallback; lifting restrictions |
|
||||
| First Lua visibility probe | USER-OBSERVED | Owner reported Sethrak/Gnoll/Saberon absent and supplied screenshots; creation, login and grey rows not tested |
|
||||
|
||||
An initial new MPQ assertion expected one block-table entry and failed for both cardinalities.
|
||||
Inspection showed StormLib also writes `(listfile)`. The corrected check requires two entries
|
||||
and verifies the listfile names exactly one game file. All 25 tests then passed. This was a test
|
||||
assumption correction, not a change to the functional requirement of one overlay.
|
||||
|
||||
Local evidence for real game files stays outside Git:
|
||||
`C:/games/source/per-race-evidence/multiple-races-offline/report.json`.
|
||||
Original DBC hash: `b78635b08bf0bd63d2898fce97c1fb162c8a9c41632703172eefa88bae79061f`.
|
||||
Generated three-race DBC hash: `243fb36837b76ebd6943da574cc095be548b4530be7f06487debea6703db10d3`.
|
||||
|
||||
## Unexecuted checks
|
||||
|
||||
| Scope | Status | Reason |
|
||||
| --- | --- | --- |
|
||||
| Effective running-client DBC and general MPQ load order | NOT RUN | First Lua probe visibly affected this one installation, but effective DBC/general precedence remain unverified |
|
||||
| LIVE-01 one disabled race | NOT RUN | Requires client and isolated server |
|
||||
| LIVE-02 multiple disabled races and re-enable | NOT RUN | Requires client and isolated server |
|
||||
| LIVE-03 existing character data/login | NOT RUN | No database/login testing performed |
|
||||
| LIVE-04 bot generation, both systems separately | NOT RUN | Other bot tests are in progress; MySQL must remain untouched |
|
||||
| LIVE-05 Portable Characters | NOT RUN | Requires disposable realm/database setup |
|
||||
| LIVE-06 client repair/update | NOT RUN | Runtime overlay integration not implemented |
|
||||
| LIVE-07 shared client | NOT RUN | Runtime profile reconciliation not implemented |
|
||||
| Server config/parser/hook tests | PASS, offline | Actual module compiled with Config/DBC/crypto stubs; native build also passed |
|
||||
| Client transaction crash/recovery matrix | NOT RUN | Offline result staging is not client install/recovery |
|
||||
| Manager visual interaction | NOT RUN | Owner requested no screen capture/control; translation checks and frontend build passed |
|
||||
| Full Rust workspace tests | NOT RUN | Focused race tests and native Manager build used instead |
|
||||
| C++ build and verify_all | PASS, source/build/harness | No server/database process started; gameplay excluded |
|
||||
| Release packaging and upgrades | NOT RUN | No release or runtime implementation prepared |
|
||||
|
||||
The copied client initially displayed a missing-critical-files message and crashed on exit.
|
||||
The fault address maps to AMD's AMDXN32.DLL; root cause is unresolved. No experimental overlay
|
||||
was installed at the time of that crash. Later Lua probes were installed only in the isolated copy,
|
||||
and the owner confirmed hidden races and disabled grey rows. Creation could not be checked.
|
||||
Neither observation is an availability live-test pass.
|
||||
|
||||
Existing character data and original game archives were not changed. No SQL was executed.
|
||||
The feature must not be declared READY on these results.
|
||||
@@ -1,6 +1,24 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"modules": [
|
||||
{
|
||||
"id": "dungeon-clear",
|
||||
"name": "Dungeon Clear",
|
||||
"description": {
|
||||
"en": "Dungeon tactics for SQUID bots. Requires SQUID bots to be enabled.",
|
||||
"ru": "Тактика подземелий для SQUID bots. Работает только при включённых SQUID bots.",
|
||||
"de": "Dungeon-Taktiken für SQUID-Bots. Erfordert aktivierte SQUID-Bots.",
|
||||
"fr": "Tactiques de donjon pour les bots SQUID. Nécessite les bots SQUID activés.",
|
||||
"es": "Tácticas de mazmorra para bots SQUID. Requiere activar los bots SQUID.",
|
||||
"zh": "为 SQUID 机器人提供地下城战术。需要启用 SQUID 机器人。"
|
||||
},
|
||||
"repo": "https://github.com/Zyth45/mod-dungeon-clear",
|
||||
"conf": "mod_dungeon_clear.conf",
|
||||
"enable_key": "DungeonClear.Enable",
|
||||
"default_on": false,
|
||||
"status": "early",
|
||||
"icon": "bot"
|
||||
},
|
||||
{
|
||||
"id": "companions",
|
||||
"name": "CoA Companions",
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "coa-server-manager",
|
||||
"version": "0.8.2",
|
||||
"version": "0.9.12",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "coa-server-manager",
|
||||
"version": "0.8.2",
|
||||
"version": "0.9.12",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.12.0",
|
||||
"@tauri-apps/plugin-dialog": "^2.8.0",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "coa-server-manager",
|
||||
"private": true,
|
||||
"version": "0.8.2",
|
||||
"version": "0.9.12",
|
||||
"license": "AGPL-3.0-only",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -422,6 +422,128 @@
|
||||
"max": 40,
|
||||
"unit": "yards"
|
||||
},
|
||||
{
|
||||
"key": "CoaBots.Scaling.Enable",
|
||||
"type": "bool",
|
||||
"category": "combat",
|
||||
"title": "Bot strength help in dungeons and raids",
|
||||
"description": "Master switch for the multipliers below. They are all 1 (no change) until you raise them.",
|
||||
"default": true,
|
||||
"advanced": false,
|
||||
"restartRequired": "world",
|
||||
"dangerous": false
|
||||
},
|
||||
{
|
||||
"key": "CoaBots.Scaling.Dungeons",
|
||||
"type": "bool",
|
||||
"category": "combat",
|
||||
"title": "Help in 5-player dungeons",
|
||||
"description": "Apply the multipliers while a bot is in a 5-player dungeon.",
|
||||
"default": true,
|
||||
"advanced": false,
|
||||
"restartRequired": "world",
|
||||
"dangerous": false
|
||||
},
|
||||
{
|
||||
"key": "CoaBots.Scaling.Raids",
|
||||
"type": "bool",
|
||||
"category": "combat",
|
||||
"title": "Help in raids",
|
||||
"description": "Apply the multipliers while a bot is in a raid.",
|
||||
"default": true,
|
||||
"advanced": false,
|
||||
"restartRequired": "world",
|
||||
"dangerous": false
|
||||
},
|
||||
{
|
||||
"key": "CoaBots.Scaling.Battlegrounds",
|
||||
"type": "bool",
|
||||
"category": "combat",
|
||||
"title": "Help in battlegrounds and arenas",
|
||||
"description": "Apply the multipliers in battlegrounds and arenas.",
|
||||
"default": false,
|
||||
"advanced": true,
|
||||
"restartRequired": "world",
|
||||
"dangerous": false
|
||||
},
|
||||
{
|
||||
"key": "CoaBots.Scaling.World",
|
||||
"type": "bool",
|
||||
"category": "combat",
|
||||
"title": "Help in the open world",
|
||||
"description": "Apply the multipliers outside dungeons and raids. Usually not wanted.",
|
||||
"default": false,
|
||||
"advanced": true,
|
||||
"restartRequired": "world",
|
||||
"dangerous": false
|
||||
},
|
||||
{
|
||||
"key": "CoaBots.Scaling.DamageDone",
|
||||
"type": "float",
|
||||
"category": "combat",
|
||||
"title": "Bot damage",
|
||||
"description": "Multiplies the damage bots and their pets deal to creatures. 1 is no change; higher makes content easier.",
|
||||
"default": 1.0,
|
||||
"advanced": false,
|
||||
"restartRequired": "world",
|
||||
"dangerous": false,
|
||||
"min": 0.1,
|
||||
"max": 10,
|
||||
"unit": "x"
|
||||
},
|
||||
{
|
||||
"key": "CoaBots.Scaling.HealingDone",
|
||||
"type": "float",
|
||||
"category": "combat",
|
||||
"title": "Bot healing",
|
||||
"description": "Multiplies the healing bots cast. 1 is no change.",
|
||||
"default": 1.0,
|
||||
"advanced": false,
|
||||
"restartRequired": "world",
|
||||
"dangerous": false,
|
||||
"min": 0.1,
|
||||
"max": 10,
|
||||
"unit": "x"
|
||||
},
|
||||
{
|
||||
"key": "CoaBots.Scaling.DamageTaken",
|
||||
"type": "float",
|
||||
"category": "combat",
|
||||
"title": "Damage taken by bots",
|
||||
"description": "Multiplies the damage creatures deal to bots. Below 1 bots take less; 1 is no change.",
|
||||
"default": 1.0,
|
||||
"advanced": false,
|
||||
"restartRequired": "world",
|
||||
"dangerous": false,
|
||||
"min": 0.1,
|
||||
"max": 10,
|
||||
"unit": "x"
|
||||
},
|
||||
{
|
||||
"key": "CoaBots.Scaling.TankThreat",
|
||||
"type": "float",
|
||||
"category": "combat",
|
||||
"title": "Tank threat",
|
||||
"description": "Extra threat generated by bot tanks so they hold the enemy's attention. 1 is no change.",
|
||||
"default": 1.0,
|
||||
"advanced": false,
|
||||
"restartRequired": "world",
|
||||
"dangerous": false,
|
||||
"min": 1,
|
||||
"max": 10,
|
||||
"unit": "x"
|
||||
},
|
||||
{
|
||||
"key": "CoaBots.Scaling.BossTuning",
|
||||
"type": "bool",
|
||||
"category": "combat",
|
||||
"title": "Extra help against four bosses",
|
||||
"description": "Adds stronger multipliers for Loken, the Drakkari Elemental, the Drakkari Colossus and Gal'darah, whom level 60 bots could not beat otherwise. For testing; off by default.",
|
||||
"default": false,
|
||||
"advanced": true,
|
||||
"restartRequired": "world",
|
||||
"dangerous": false
|
||||
},
|
||||
{
|
||||
"key": "CoaBots.WorldBrain.MountDistanceMin",
|
||||
"type": "int",
|
||||
|
||||
Loaded 100 of 177 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user