mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-19 03:25:56 +00:00
Merge integrate/manager-0.9.14 into preview: characters kept out while custom races are off
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # src/screens/ModulesPage.tsx
This commit is contained in:
commit
59132216f7
13 files changed
+121
No files matched your search
@@ -0,0 +1,7 @@
|
||||
---
|
||||
area: manager
|
||||
type: added
|
||||
audience: admins
|
||||
title: The Custom Races card tells which characters stay out while races are off
|
||||
---
|
||||
With custom races off, the card shows how many player characters and bots of custom races cannot enter the world, and offers to delete the companion bots of those races.
|
||||
@@ -515,6 +515,46 @@ fn is_switched(client: &Path, file: &PatchFile) -> bool {
|
||||
entry_point || suffix(&client.join(&file.path), "original").is_file()
|
||||
}
|
||||
|
||||
/// Characters of custom races (RaceID above 11) on the active realm: a game client without the client patch
|
||||
/// crashes when one of them comes into view, so the server keeps them out of the world while custom races are
|
||||
/// off. `None` when the database is not running.
|
||||
#[derive(Debug, Clone, Copy, Serialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CustomRaceCharacters {
|
||||
pub players: u32,
|
||||
pub companion_bots: u32,
|
||||
pub squid_bots: u32,
|
||||
}
|
||||
|
||||
pub fn custom_race_characters(root: &Path) -> Result<Option<CustomRaceCharacters>> {
|
||||
let squid = crate::accounts::squid_bot_prefix(root);
|
||||
let characters = crate::realms::state(root)
|
||||
.map(|s| s.active)
|
||||
.unwrap_or_default()
|
||||
.schema("characters")?;
|
||||
crate::backup::with_running_database(root, |db| {
|
||||
let out = db.query(&format!(
|
||||
"SELECT \
|
||||
IFNULL(SUM(a.username NOT LIKE 'COABOTHOST%' AND a.username NOT LIKE '{squid}%'), 0), \
|
||||
IFNULL(SUM(a.username LIKE 'COABOTHOST%'), 0), \
|
||||
IFNULL(SUM(a.username LIKE '{squid}%'), 0) \
|
||||
FROM {characters}.characters c JOIN acore_auth.account a ON a.id = c.account WHERE c.race > 11;"
|
||||
))?;
|
||||
let numbers: Vec<u32> = out
|
||||
.lines()
|
||||
.last()
|
||||
.unwrap_or("")
|
||||
.split('\t')
|
||||
.map(|n| n.trim().parse().unwrap_or(0))
|
||||
.collect();
|
||||
Ok(CustomRaceCharacters {
|
||||
players: numbers.first().copied().unwrap_or(0),
|
||||
companion_bots: numbers.get(1).copied().unwrap_or(0),
|
||||
squid_bots: numbers.get(2).copied().unwrap_or(0),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Only complete, verified payloads are reported as enabled or disabled.
|
||||
pub fn client_patch_status(client_path: &Path) -> ClientPatchStatus {
|
||||
let data = client_path.join("Data");
|
||||
|
||||
@@ -258,6 +258,11 @@ impl Ra {
|
||||
Ok(out.lines().last().unwrap_or("").to_string())
|
||||
}
|
||||
|
||||
/// Delete the companion bots of custom races (RaceID above 11), every other bot stays. Returns how many.
|
||||
pub fn purge_custom_race_bots(&mut self) -> Result<u32> {
|
||||
Ok(first_number(&self.bot_command("botcmd purgecustomraces")?))
|
||||
}
|
||||
|
||||
/// Ask the bot module to create `count` leveling bots (throttled by the module itself). Only a number is sent.
|
||||
pub fn spawn_bots(&mut self, count: u32) -> Result<String> {
|
||||
if !(1..=2000).contains(&count) {
|
||||
|
||||
@@ -1665,6 +1665,33 @@ async fn custom_races_install(
|
||||
result
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn custom_race_characters(
|
||||
state: State<'_, AppState>,
|
||||
id: String,
|
||||
) -> std::result::Result<Option<coa_core::custom_races::CustomRaceCharacters>, UiError> {
|
||||
let root = path_of(&state, &id)?;
|
||||
blocking(move || coa_core::custom_races::custom_race_characters(&root)).await
|
||||
}
|
||||
|
||||
/// Delete the companion bots of custom races through the running world's console. Returns how many.
|
||||
#[tauri::command]
|
||||
async fn purge_custom_race_bots(
|
||||
state: State<'_, AppState>,
|
||||
id: String,
|
||||
) -> std::result::Result<u32, UiError> {
|
||||
let root = path_of(&state, &id)?;
|
||||
let _guard = BusyGuard::acquire(&state, &id)?;
|
||||
blocking(move || {
|
||||
let o = coa_core::process::observe(&root, &layout::read_ports(&root));
|
||||
if o.world.state != coa_core::process::ServiceState::Running {
|
||||
return Err(Error::Invalid("Start the server to delete bots.".into()));
|
||||
}
|
||||
Ra::connect(&root)?.purge_custom_race_bots()
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn addons_list(
|
||||
state: State<'_, AppState>,
|
||||
@@ -3761,6 +3788,8 @@ pub fn run() {
|
||||
restart_schedule_save,
|
||||
clear_game_cache_on_play,
|
||||
set_clear_game_cache_on_play,
|
||||
custom_race_characters,
|
||||
purge_custom_race_bots,
|
||||
addons_list,
|
||||
addons_install,
|
||||
addons_remove,
|
||||
|
||||
@@ -43,6 +43,8 @@ export {};
|
||||
if(cmd==="plugin:app|version") return "0.8.2";
|
||||
if(cmd==="release_history") throw new Error("Offline demo: using bundled notes");
|
||||
if(cmd==="addons_list"||cmd==="addons_install"||cmd==="addons_remove"){const w=window as any;w.__addons=w.__addons??{dragonui:"old"};if(cmd==="addons_install"){await new Promise(r=>setTimeout(r,700));w.__addons[args.addon]="new";}if(cmd==="addons_remove")delete w.__addons[args.addon];return addonCatalog.addons.map((a:any)=>({id:a.id,name:a.name,description:a.description,author:a.author,license:a.license,needs:a.needs??null,repo:a.repo,size:a.files.reduce((s:number,f:any)=>s+f.size,0),installed:a.id in w.__addons,updateAvailable:w.__addons[a.id]==="old",foreignFolders:a.id==="coacombat"&&!(a.id in w.__addons)?["CoACombat"]:[],bundled:null as string|null})).concat([{id:"coa-dev-menu",name:"CoA Dev Menu",description:{en:"The in-game /dev editor for game masters.",ru:"Внутриигровой редактор /dev для гейм-мастеров. Ставится вместе с клиентским патчем Custom Races V2 и включается вместе с ним."},author:"ilusixn",license:"see repository",needs:null,repo:"https://github.com/ilusixn/ilusixn-dev-menu",size:0,installed:true,updateAvailable:false,foreignFolders:[],bundled:"custom-races"}]);}
|
||||
if(cmd==="custom_race_characters") return {players:2,companionBots:14,squidBots:0};
|
||||
if(cmd==="purge_custom_race_bots"){await new Promise(r=>setTimeout(r,500));return 14;}
|
||||
if(cmd==="restart_schedule"||cmd==="restart_schedule_save"){const w=window as any;w.__sched=w.__sched??{enabled:false,time:"05:00",warningMinutes:5};if(cmd==="restart_schedule_save"){const s=args.schedule;if(s.enabled&&!/^([01]\d|2[0-3]):[0-5]\d$/.test(s.time))throw new Error("The restart time must be HH:MM, for example 05:00.");w.__sched={...s};}return {schedule:w.__sched,supported:true};}
|
||||
if(cmd==="mysql_custom"||cmd==="mysql_custom_save"){const w=window as any;if(cmd==="mysql_custom_save")w.__my=args.text;const text:string=w.__my??"";const applied=text.split("\n").map((l:string)=>l.trim()).filter((l:string)=>l&&!l.startsWith("#")&&!/^(port|datadir|basedir|bind[-_]address)\b/i.test(l)).map((l:string)=>l+"\n").join("");return {text,applied};}
|
||||
if(cmd==="realm_names"||cmd==="realm_rename"){const w=window as any;w.__rn=w.__rn??{};const defs:[number,string][]=[[1,"Conquest of Azeroth"],[2,"Wildcard"]];if(cmd==="realm_rename"){await new Promise(r=>setTimeout(r,300));const n=(args.name??"").trim();if(n.length>32||n.includes('"'))throw new Error("The realm name can have at most 32 characters.");if(n)w.__rn[args.realmId]=n;else delete w.__rn[args.realmId];}return defs.map(([id,d])=>({id,name:w.__rn[id]??d,defaultName:d,custom:id in w.__rn}));}
|
||||
|
||||
@@ -803,6 +803,9 @@ const de: Partial<Record<keyof typeof en, string>> = {
|
||||
"addons.doInstall": "Installieren",
|
||||
"addons.doUpdate": "Aktualisieren",
|
||||
"addons.doRemove": "Entfernen",
|
||||
"races.offCharacters": "Eigene Völker sind aus: {players} Spielerfigur(en) und {bots} Bot(s) eigener Völker bleiben der Welt fern, bis sie wieder an sind (ein Client ohne Patch würde bei ihnen abstürzen).",
|
||||
"races.purgeBots": "{n} Begleiter-Bot(s) eigener Völker löschen",
|
||||
"races.purged": "{n} Bot(s) eigener Völker gelöscht.",
|
||||
"realm.namesTitle": "Realmnamen",
|
||||
"realm.namesHint": "So heißt der Realm in der Realmliste der Spieler. Ein laufender Server zeigt den Namen sofort, und er bleibt nach Updates erhalten.",
|
||||
"realm.nameSave": "Speichern",
|
||||
|
||||
@@ -87,6 +87,9 @@ const en = {
|
||||
"addons.doInstall": "Install",
|
||||
"addons.doUpdate": "Update",
|
||||
"addons.doRemove": "Remove",
|
||||
"races.offCharacters": "Custom races are off: {players} player character(s) and {bots} bot(s) of custom races stay out of the world until they are on again (a game client without the patch would crash on them).",
|
||||
"races.purgeBots": "Delete the {n} companion bot(s) of custom races",
|
||||
"races.purged": "Deleted {n} bot(s) of custom races.",
|
||||
"realm.namesTitle": "Realm names",
|
||||
"realm.namesHint": "The name players see in the realm list. A running server shows it at once, and it stays after updates.",
|
||||
"realm.nameSave": "Save",
|
||||
|
||||
@@ -803,6 +803,9 @@ const es: Partial<Record<keyof typeof en, string>> = {
|
||||
"addons.doInstall": "Instalar",
|
||||
"addons.doUpdate": "Actualizar",
|
||||
"addons.doRemove": "Quitar",
|
||||
"races.offCharacters": "Las razas personalizadas están desactivadas: {players} personaje(s) de jugadores y {bots} bot(s) de esas razas quedan fuera del mundo hasta reactivarlas (un cliente sin el parche se cerraría al verlos).",
|
||||
"races.purgeBots": "Borrar los {n} bot(s) acompañantes de razas personalizadas",
|
||||
"races.purged": "Borrados {n} bot(s) de razas personalizadas.",
|
||||
"realm.namesTitle": "Nombres de los reinos",
|
||||
"realm.namesHint": "El nombre que ven los jugadores en la lista de reinos. Un servidor en marcha lo muestra al instante y se mantiene tras las actualizaciones.",
|
||||
"realm.nameSave": "Guardar",
|
||||
|
||||
@@ -803,6 +803,9 @@ const fr: Partial<Record<keyof typeof en, string>> = {
|
||||
"addons.doInstall": "Installer",
|
||||
"addons.doUpdate": "Mettre à jour",
|
||||
"addons.doRemove": "Supprimer",
|
||||
"races.offCharacters": "Les races personnalisées sont désactivées : {players} personnage(s) de joueurs et {bots} bot(s) de ces races restent hors du monde jusqu'à leur réactivation (un client sans le patch planterait en les voyant).",
|
||||
"races.purgeBots": "Supprimer les {n} bot(s) compagnons de races personnalisées",
|
||||
"races.purged": "{n} bot(s) de races personnalisées supprimé(s).",
|
||||
"realm.namesTitle": "Noms des royaumes",
|
||||
"realm.namesHint": "Le nom que les joueurs voient dans la liste des royaumes. Un serveur en marche l'affiche aussitôt, et il reste après les mises à jour.",
|
||||
"realm.nameSave": "Enregistrer",
|
||||
|
||||
@@ -90,6 +90,9 @@ const ru: Partial<Record<keyof typeof en, string>> = {
|
||||
"addons.doInstall": "Установить",
|
||||
"addons.doUpdate": "Обновить",
|
||||
"addons.doRemove": "Удалить",
|
||||
"races.offCharacters": "Кастомные расы выключены: {players} персонаж(ей) игроков и {bots} бот(ов) кастомных рас не входят в мир, пока расы снова не включены (клиент без патча падал бы при виде их).",
|
||||
"races.purgeBots": "Удалить ботов-компаньонов кастомных рас: {n}",
|
||||
"races.purged": "Удалено ботов кастомных рас: {n}.",
|
||||
"realm.namesTitle": "Названия реалмов",
|
||||
"realm.namesHint": "Так реалм называется в списке реалмов у игроков. Работающий сервер показывает новое название сразу, и оно сохраняется после обновлений.",
|
||||
"realm.nameSave": "Сохранить",
|
||||
|
||||
@@ -88,6 +88,9 @@ const zh = {
|
||||
"addons.doInstall": "安装",
|
||||
"addons.doUpdate": "更新",
|
||||
"addons.doRemove": "移除",
|
||||
"races.offCharacters": "自定义种族已关闭:{players} 个玩家角色和 {bots} 个自定义种族机器人在重新开启前不会进入世界(没有补丁的游戏客户端看到它们会崩溃)。",
|
||||
"races.purgeBots": "删除 {n} 个自定义种族的伙伴机器人",
|
||||
"races.purged": "已删除 {n} 个自定义种族机器人。",
|
||||
"realm.namesTitle": "服务器名称",
|
||||
"realm.namesHint": "玩家在服务器列表中看到的名称。运行中的服务器会立即显示新名称,更新后也会保留。",
|
||||
"realm.nameSave": "保存",
|
||||
|
||||
@@ -64,6 +64,7 @@ export interface StatusView {
|
||||
}
|
||||
|
||||
export type RealmMode = "coa" | "wildcard" | "reborn";
|
||||
export interface CustomRaceCharacters { players: number; companionBots: number; squidBots: number }
|
||||
export interface AddonView { id: string; name: string; description: Record<string, string>; author: string; license: string; needs: string | null; repo: string; size: number; installed: boolean; updateAvailable: boolean; foreignFolders: string[]; bundled?: string | null }
|
||||
export interface RestartSchedule { enabled: boolean; time: string; warningMinutes: number }
|
||||
export interface RestartScheduleView { schedule: RestartSchedule; supported: boolean }
|
||||
@@ -737,6 +738,8 @@ export const api = {
|
||||
realmProfiles: (id: string) => invoke<RealmProfiles>("realm_profiles", { id }),
|
||||
realmSelect: (id: string, mode: RealmMode, restart: boolean) => invoke<RealmProfiles>("realm_select", { id, mode, restart }),
|
||||
realmSimultaneous: (id: string, enabled: boolean) => invoke<RealmProfiles>("realm_simultaneous", { id, enabled }),
|
||||
customRaceCharacters: (id: string) => invoke<CustomRaceCharacters | null>("custom_race_characters", { id }),
|
||||
purgeCustomRaceBots: (id: string) => invoke<number>("purge_custom_race_bots", { id }),
|
||||
addonsList: (id: string) => invoke<AddonView[]>("addons_list", { id }),
|
||||
addonsInstall: (id: string, addon: string) => invoke<AddonView[]>("addons_install", { id, addon }),
|
||||
addonsRemove: (id: string, addon: string) => invoke<AddonView[]>("addons_remove", { id, addon }),
|
||||
|
||||
@@ -41,6 +41,7 @@ import {
|
||||
type CoaCompatibilityStatus,
|
||||
type CompatibilityReport,
|
||||
type CustomRacesClientStatus,
|
||||
type CustomRaceCharacters,
|
||||
type CustomRacesProgress,
|
||||
type InstalledPreviewPlugin,
|
||||
type ModuleSetting,
|
||||
@@ -633,6 +634,9 @@ export function ModulesPage({
|
||||
const [toggling, setToggling] = useState<string | null>(null);
|
||||
const [changed, setChanged] = useState(false);
|
||||
const [racesPatchStatus, setRacesPatchStatus] = useState<CustomRacesClientStatus | null>(null);
|
||||
const [raceChars, setRaceChars] = useState<CustomRaceCharacters | null>(null);
|
||||
const [purging, setPurging] = useState(false);
|
||||
const [purged, setPurged] = useState<number | null>(null);
|
||||
const [racesInstalling, setRacesInstalling] = useState(false);
|
||||
const [racesProgress, setRacesProgress] = useState<CustomRacesProgress | null>(null);
|
||||
const [guard, setGuard] = useState<UnsavedChangesGuard | null>(null);
|
||||
@@ -768,6 +772,7 @@ export function ModulesPage({
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
setRaceChars(await api.customRaceCharacters(serverId).catch(() => null));
|
||||
}, [serverId]);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
@@ -1792,6 +1797,18 @@ export function ModulesPage({
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{modules?.find((x) => x.id === "custom-races")?.enabled === false && raceChars && raceChars.players + raceChars.companionBots + raceChars.squidBots > 0 && (
|
||||
<div className="mb-2 rounded-md border border-warn/40 bg-warn/5 p-2 text-xs" role="status">
|
||||
<p>{t("races.offCharacters", { players: raceChars.players, bots: raceChars.companionBots + raceChars.squidBots })}</p>
|
||||
{raceChars.companionBots > 0 && <Button size="sm" variant="ghost" className="mt-1 h-auto whitespace-normal py-1 text-left" disabled={purging} onClick={() => void (async () => {
|
||||
setPurging(true); setError(null);
|
||||
try { setPurged(await api.purgeCustomRaceBots(serverId)); await loadRacesStatus(); }
|
||||
catch (e) { setError(asUiError(e)); }
|
||||
finally { setPurging(false); }
|
||||
})()}>{purging && <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />}{t("races.purgeBots", { n: raceChars.companionBots })}</Button>}
|
||||
</div>
|
||||
)}
|
||||
{purged !== null && <p className="mb-2 text-xs text-ok" role="status">{t("races.purged", { n: purged })}</p>}
|
||||
{racesInstalling && racesProgress ? (
|
||||
<div className="rounded-lg border border-gold/30 bg-gold/5 p-3">
|
||||
<div className="flex items-center justify-between gap-3 text-xs">
|
||||
|
||||
Reference in new issue
Block a user