mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-18 19:25:56 +00:00
Companions open on Wildcard and Reborn when the server build plays them
The module list blocked Companions on every realm but Conquest of Azeroth, so the multi-realm bot work could not be switched on. It is allowed (as experimental) when the world server or its bots plugin carries the standard-class bot profiles of the multi-realm bots build; SQUID and Dungeon Clear stay CoA-only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6cbf007d72
commit
e951eb134b
2 files changed
+57
-1
No files matched your search
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: added
|
||||
audience: admins
|
||||
title: Companion bots on Wildcard and Warcraft Reborn
|
||||
---
|
||||
With a server build that supports it, Companions can be switched on for Wildcard and Warcraft Reborn: bots get whole Wildcard archetypes or Reborn abilities by level, and bot creation survives a crash without duplicates.
|
||||
@@ -176,6 +176,32 @@ fn installed_module_commits(root: &Path) -> BTreeMap<String, String> {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
/// The companion bots of this server build play Wildcard and Warcraft Reborn: their bot profiles for the standard
|
||||
/// classes are in the world server or its bots plugin. Older builds only know Conquest of Azeroth characters.
|
||||
pub fn companions_on_other_realms(root: &Path) -> bool {
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Mutex, OnceLock};
|
||||
static SEEN: OnceLock<Mutex<HashMap<(PathBuf, u64, Option<std::time::SystemTime>), bool>>> = OnceLock::new();
|
||||
const MARKER: &[u8] = b"Druid_Guardian_Tank";
|
||||
let mut files = vec![crate::layout::executables(root).0];
|
||||
if let Ok(plugins) = fs::read_dir(root.join("Core/plugins")) {
|
||||
files.extend(plugins.flatten().map(|e| e.path()).filter(|p| p.extension().is_some_and(|x| x.eq_ignore_ascii_case("dll"))));
|
||||
}
|
||||
files.into_iter().any(|file| {
|
||||
let Ok(meta) = fs::metadata(&file) else { return false };
|
||||
let key = (file.clone(), meta.len(), meta.modified().ok());
|
||||
let seen = SEEN.get_or_init(Mutex::default);
|
||||
if let Some(found) = seen.lock().ok().and_then(|s| s.get(&key).copied()) {
|
||||
return found;
|
||||
}
|
||||
let found = fs::read(&file).is_ok_and(|bytes| bytes.windows(MARKER.len()).any(|w| w == MARKER));
|
||||
if let Ok(mut s) = seen.lock() {
|
||||
s.insert(key, found);
|
||||
}
|
||||
found
|
||||
})
|
||||
}
|
||||
|
||||
fn list_in(cat: &[Entry], root: &Path) -> Vec<ModuleView> {
|
||||
let installed_commits = installed_module_commits(root);
|
||||
let wildcard = crate::realms::state(root)
|
||||
@@ -208,7 +234,9 @@ fn list_in(cat: &[Entry], root: &Path) -> Vec<ModuleView> {
|
||||
.map(|enabled| !enabled)
|
||||
.unwrap_or(true);
|
||||
let blocked = dependency_missing
|
||||
|| (wildcard && matches!(e.id.as_str(), "companions" | "playerbots" | "dungeon-clear"));
|
||||
|| (wildcard
|
||||
&& (matches!(e.id.as_str(), "playerbots" | "dungeon-clear")
|
||||
|| (e.id == "companions" && !companions_on_other_realms(root))));
|
||||
let version = if e.id == "playerbots" {
|
||||
crate::squid::release(root).map(|release| {
|
||||
[
|
||||
@@ -722,6 +750,27 @@ mod tests {
|
||||
assert!(meta.join("backups").exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn companions_open_on_other_realms_only_with_a_build_that_plays_them() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let root = temp.path().join("server");
|
||||
fs::create_dir_all(dir(&root)).unwrap();
|
||||
fs::create_dir_all(root.join("Settings")).unwrap();
|
||||
fs::write(root.join("Settings/realm-profile.json"), r#"{"active":"wildcard","wildcard_created":true}"#).unwrap();
|
||||
for e in catalog().iter().filter(|e| matches!(e.id.as_str(), "companions" | "playerbots")) {
|
||||
fs::write(dir(&root).join(format!("{}.dist", e.conf)), format!("{} = 0\n", e.enable_key)).unwrap();
|
||||
}
|
||||
let exe = crate::layout::executables(&root).0;
|
||||
fs::write(&exe, b"an old world server").unwrap();
|
||||
let view = |id: &str| list(&root).into_iter().find(|m| m.id == id).unwrap();
|
||||
assert_eq!(view("companions").compatibility, "unsupported");
|
||||
fs::write(&exe, b"profiles ... Druid_Guardian_Tank ... a new world server").unwrap();
|
||||
assert!(companions_on_other_realms(&root));
|
||||
assert_eq!(view("companions").compatibility, "experimental");
|
||||
assert!(view("companions").switchable);
|
||||
assert_eq!(view("playerbots").compatibility, "unsupported", "SQUID stays CoA-only");
|
||||
}
|
||||
|
||||
fn test_catalog() -> Vec<Entry> {
|
||||
let one = |id: &str, name: &str, conf: &str, key: &str| Entry {
|
||||
id: id.into(),
|
||||
|
||||
Reference in new issue
Block a user