From 69c9938aba2479e60bbae1ad547e2f01840d131c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Fri, 6 Nov 2026 19:33:41 +0500 Subject: [PATCH] feat(manager): enable multi-realm playerbots support across CoA, Wildcard, and Reborn --- crates/coa-core/src/multiworld.rs | 6 +++ crates/coa-core/src/realms.rs | 63 ++++++++++--------------------- src/screens/CompanionsCard.tsx | 14 ++++++- 3 files changed, 39 insertions(+), 44 deletions(-) diff --git a/crates/coa-core/src/multiworld.rs b/crates/coa-core/src/multiworld.rs index 96df9bb..f7bb17c 100644 --- a/crates/coa-core/src/multiworld.rs +++ b/crates/coa-core/src/multiworld.rs @@ -261,6 +261,12 @@ fn prepare(main: &Path, tree: Tree) -> Result { &fsx::ensure_within(&second, &second.join("Core/reference"))?, )?; } + if main.join("Core/plugins").is_dir() { + copy_tree( + &main.join("Core/plugins"), + &fsx::ensure_within(&second, &second.join("Core/plugins"))?, + )?; + } for entry in fs::read_dir(main.join("Core"))? { let entry = entry?; if entry.file_type()?.is_file() diff --git a/crates/coa-core/src/realms.rs b/crates/coa-core/src/realms.rs index 96532d3..ab4c156 100644 --- a/crates/coa-core/src/realms.rs +++ b/crates/coa-core/src/realms.rs @@ -185,9 +185,8 @@ pub fn view(root: &Path) -> Result { } pub fn guard_module(root: &Path, id: &str) -> Result<()> { - if state(root)?.active != Mode::Coa && matches!(id, "companions" | "playerbots") { - return Err(Error::Invalid("Bot class mechanics have not been validated for this realm. This module is unavailable on this realm.".into())); - } + // Multi-realm Playerbots 1.0 supports all realms (CoA, Wildcard, Reborn). + let _ = (root, id); Ok(()) } @@ -296,14 +295,12 @@ fn wildcard_configs(mut files: Files) -> Result { } } } - for (key, value) in [("CoaBots.Enable", "0"), ("CoaBots.AutoLoginOnStartup", "0")] { - set( - &mut files, - "Core/configs/modules/mod_coa_playerbots.conf", - key, - value, - )?; - } + set( + &mut files, + "Core/configs/modules/mod_coa_playerbots.conf", + "CoaBots.Enable", + "1", + )?; set( &mut files, "Core/configs/modules/playerbots.conf", @@ -337,14 +334,12 @@ fn reborn_configs(mut files: Files) -> Result { set(&mut files, path, "RealmID", "3")?; } } - for (key, value) in [("CoaBots.Enable", "0"), ("CoaBots.AutoLoginOnStartup", "0")] { - set( - &mut files, - "Core/configs/modules/mod_coa_playerbots.conf", - key, - value, - )?; - } + set( + &mut files, + "Core/configs/modules/mod_coa_playerbots.conf", + "CoaBots.Enable", + "1", + )?; set( &mut files, "Core/configs/modules/playerbots.conf", @@ -681,19 +676,7 @@ pub fn before_start(root: &Path) -> Result<()> { "The installed server build does not support Wildcard.".into(), )); } - let path = root.join("Core/configs/modules/mod_coa_playerbots.conf"); - let mut conf = ConfFile::parse_bytes(&fs::read(&path)?)?; - conf.set("CoaBots.Enable", "0", &[]); - fsx::atomic_write(&path, conf.to_text().as_bytes())?; - let path = root.join("Core/configs/modules/playerbots.conf"); - let bytes = if path.exists() { - fs::read(&path)? - } else { - b"[worldserver]\n".to_vec() - }; - let mut conf = ConfFile::parse_bytes(&bytes)?; - conf.set("AiPlayerbot.Enabled", "0", &[]); - fsx::atomic_write(&path, conf.to_text().as_bytes())?; + // Multi-realm Playerbots 1.0: bots are supported and enabled on all realms } Ok(()) } @@ -831,8 +814,8 @@ mod tests { }, ) .unwrap(); - assert!(guard_module(t.path(), "companions").is_err()); - assert!(guard_module(t.path(), "playerbots").is_err()); + assert!(guard_module(t.path(), "companions").is_ok()); + assert!(guard_module(t.path(), "playerbots").is_ok()); assert!(guard_module(t.path(), "content-scaling").is_ok()); } @@ -1030,7 +1013,7 @@ CoA.GameModeMask = 0 f["Core/configs/modules/mod-coa-content-scaling.conf"] ); let c = ConfFile::parse_bytes(&w["Core/configs/modules/mod_coa_playerbots.conf"]).unwrap(); - assert_eq!(c.get("CoaBots.Enable"), Some("0")); + assert_eq!(c.get("CoaBots.Enable"), Some("1")); assert_eq!( ConfFile::parse_bytes(&w["Settings/worldserver.conf.template"]) .unwrap() @@ -1102,14 +1085,8 @@ CoA.GameModeMask = 0 }, ) .unwrap(); - assert!(crate::modules::set_enabled(t.path(), t.path(), "companions", true).is_err()); - assert!(crate::config::save( - t.path(), - t.path(), - crate::config::Scope::Bots, - &BTreeMap::new() - ) - .is_err()); + assert!(guard_module(t.path(), "companions").is_ok()); + assert!(guard_module(t.path(), "playerbots").is_ok()); assert!(guard_module(t.path(), "content-scaling").is_ok()); } } diff --git a/src/screens/CompanionsCard.tsx b/src/screens/CompanionsCard.tsx index 09870c9..a3f9307 100644 --- a/src/screens/CompanionsCard.tsx +++ b/src/screens/CompanionsCard.tsx @@ -9,6 +9,7 @@ export function CompanionsCard({ serverId }: { serverId: string }) { const t = useT(); const human = useHuman(); const [sizes, setSizes] = useState(null); + const [realmMode, setRealmMode] = useState(null); const [pop, setPop] = useState(null); const [running, setRunning] = useState(false); const [choice, setChoice] = useState("small"); @@ -25,6 +26,10 @@ export function CompanionsCard({ serverId }: { serverId: string }) { const [startBusy, setStartBusy] = useState(false); const [despawnN, setDespawnN] = useState("10"); + useEffect(() => { + void api.realmProfiles(serverId).then((r) => setRealmMode(r.active)).catch(() => {}); + }, [serverId]); + useEffect(() => { void api .settings(serverId, "bots") @@ -156,7 +161,14 @@ export function CompanionsCard({ serverId }: { serverId: string }) { return ( -

{t("comp.title")}

+
+

{t("comp.title")}

+ {realmMode && ( + + {realmMode === "coa" ? "Conquest of Azeroth" : realmMode === "wildcard" ? "Wildcard" : "Warcraft Reborn"} + + )} +

{pop ? t("comp.population", { online: pop.bots_online, total: pop.bots_total })