mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-26 03:25:56 +00:00
feat(manager): enable multi-realm playerbots support across CoA, Wildcard, and Reborn
This commit is contained in:
1 parent
2fd42f2acd
commit
69c9938aba
3 files changed
+39
-44
No files matched your search
@@ -261,6 +261,12 @@ fn prepare(main: &Path, tree: Tree) -> Result<PathBuf> {
|
|||||||
&fsx::ensure_within(&second, &second.join("Core/reference"))?,
|
&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"))? {
|
for entry in fs::read_dir(main.join("Core"))? {
|
||||||
let entry = entry?;
|
let entry = entry?;
|
||||||
if entry.file_type()?.is_file()
|
if entry.file_type()?.is_file()
|
||||||
|
|||||||
@@ -185,9 +185,8 @@ pub fn view(root: &Path) -> Result<View> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn guard_module(root: &Path, id: &str) -> Result<()> {
|
pub fn guard_module(root: &Path, id: &str) -> Result<()> {
|
||||||
if state(root)?.active != Mode::Coa && matches!(id, "companions" | "playerbots") {
|
// Multi-realm Playerbots 1.0 supports all realms (CoA, Wildcard, Reborn).
|
||||||
return Err(Error::Invalid("Bot class mechanics have not been validated for this realm. This module is unavailable on this realm.".into()));
|
let _ = (root, id);
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,14 +295,12 @@ fn wildcard_configs(mut files: Files) -> Result<Files> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (key, value) in [("CoaBots.Enable", "0"), ("CoaBots.AutoLoginOnStartup", "0")] {
|
set(
|
||||||
set(
|
&mut files,
|
||||||
&mut files,
|
"Core/configs/modules/mod_coa_playerbots.conf",
|
||||||
"Core/configs/modules/mod_coa_playerbots.conf",
|
"CoaBots.Enable",
|
||||||
key,
|
"1",
|
||||||
value,
|
)?;
|
||||||
)?;
|
|
||||||
}
|
|
||||||
set(
|
set(
|
||||||
&mut files,
|
&mut files,
|
||||||
"Core/configs/modules/playerbots.conf",
|
"Core/configs/modules/playerbots.conf",
|
||||||
@@ -337,14 +334,12 @@ fn reborn_configs(mut files: Files) -> Result<Files> {
|
|||||||
set(&mut files, path, "RealmID", "3")?;
|
set(&mut files, path, "RealmID", "3")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (key, value) in [("CoaBots.Enable", "0"), ("CoaBots.AutoLoginOnStartup", "0")] {
|
set(
|
||||||
set(
|
&mut files,
|
||||||
&mut files,
|
"Core/configs/modules/mod_coa_playerbots.conf",
|
||||||
"Core/configs/modules/mod_coa_playerbots.conf",
|
"CoaBots.Enable",
|
||||||
key,
|
"1",
|
||||||
value,
|
)?;
|
||||||
)?;
|
|
||||||
}
|
|
||||||
set(
|
set(
|
||||||
&mut files,
|
&mut files,
|
||||||
"Core/configs/modules/playerbots.conf",
|
"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(),
|
"The installed server build does not support Wildcard.".into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let path = root.join("Core/configs/modules/mod_coa_playerbots.conf");
|
// Multi-realm Playerbots 1.0: bots are supported and enabled on all realms
|
||||||
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())?;
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -831,8 +814,8 @@ mod tests {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(guard_module(t.path(), "companions").is_err());
|
assert!(guard_module(t.path(), "companions").is_ok());
|
||||||
assert!(guard_module(t.path(), "playerbots").is_err());
|
assert!(guard_module(t.path(), "playerbots").is_ok());
|
||||||
assert!(guard_module(t.path(), "content-scaling").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"]
|
f["Core/configs/modules/mod-coa-content-scaling.conf"]
|
||||||
);
|
);
|
||||||
let c = ConfFile::parse_bytes(&w["Core/configs/modules/mod_coa_playerbots.conf"]).unwrap();
|
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!(
|
assert_eq!(
|
||||||
ConfFile::parse_bytes(&w["Settings/worldserver.conf.template"])
|
ConfFile::parse_bytes(&w["Settings/worldserver.conf.template"])
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@@ -1102,14 +1085,8 @@ CoA.GameModeMask = 0
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(crate::modules::set_enabled(t.path(), t.path(), "companions", true).is_err());
|
assert!(guard_module(t.path(), "companions").is_ok());
|
||||||
assert!(crate::config::save(
|
assert!(guard_module(t.path(), "playerbots").is_ok());
|
||||||
t.path(),
|
|
||||||
t.path(),
|
|
||||||
crate::config::Scope::Bots,
|
|
||||||
&BTreeMap::new()
|
|
||||||
)
|
|
||||||
.is_err());
|
|
||||||
assert!(guard_module(t.path(), "content-scaling").is_ok());
|
assert!(guard_module(t.path(), "content-scaling").is_ok());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ export function CompanionsCard({ serverId }: { serverId: string }) {
|
|||||||
const t = useT();
|
const t = useT();
|
||||||
const human = useHuman();
|
const human = useHuman();
|
||||||
const [sizes, setSizes] = useState<CompanionSizes | null>(null);
|
const [sizes, setSizes] = useState<CompanionSizes | null>(null);
|
||||||
|
const [realmMode, setRealmMode] = useState<string | null>(null);
|
||||||
const [pop, setPop] = useState<Population | null>(null);
|
const [pop, setPop] = useState<Population | null>(null);
|
||||||
const [running, setRunning] = useState(false);
|
const [running, setRunning] = useState(false);
|
||||||
const [choice, setChoice] = useState<string>("small");
|
const [choice, setChoice] = useState<string>("small");
|
||||||
@@ -25,6 +26,10 @@ export function CompanionsCard({ serverId }: { serverId: string }) {
|
|||||||
const [startBusy, setStartBusy] = useState(false);
|
const [startBusy, setStartBusy] = useState(false);
|
||||||
const [despawnN, setDespawnN] = useState("10");
|
const [despawnN, setDespawnN] = useState("10");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
void api.realmProfiles(serverId).then((r) => setRealmMode(r.active)).catch(() => {});
|
||||||
|
}, [serverId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void api
|
void api
|
||||||
.settings(serverId, "bots")
|
.settings(serverId, "bots")
|
||||||
@@ -156,7 +161,14 @@ export function CompanionsCard({ serverId }: { serverId: string }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="mt-6 p-6">
|
<Card className="mt-6 p-6">
|
||||||
<h2 className="font-semibold">{t("comp.title")}</h2>
|
<div className="flex items-center justify-between">
|
||||||
|
<h2 className="font-semibold">{t("comp.title")}</h2>
|
||||||
|
{realmMode && (
|
||||||
|
<span className="rounded bg-gold/15 px-2 py-0.5 text-xs font-medium text-gold uppercase tracking-wider">
|
||||||
|
{realmMode === "coa" ? "Conquest of Azeroth" : realmMode === "wildcard" ? "Wildcard" : "Warcraft Reborn"}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<p className="mt-1 text-sm text-muted">
|
<p className="mt-1 text-sm text-muted">
|
||||||
{pop
|
{pop
|
||||||
? t("comp.population", { online: pop.bots_online, total: pop.bots_total })
|
? t("comp.population", { online: pop.bots_online, total: pop.bots_total })
|
||||||
|
|||||||
Reference in new issue
Block a user