mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-20 03:25:56 +00:00
Merge integrate/manager-0.9.14 into preview: Custom Races V2, fast races switch, ports, realm names, V2 switches, MySQL options, scheduled restart
Versions stay the preview's. schemas/bots.json keeps the preview's own bot scaling settings (master brought the released ones a second time, as duplicate keys). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
fc8b18ef97
57 files changed
+11926
-255
No files matched your search
@@ -308,7 +308,9 @@ pub fn with_database<T>(root: &Path, f: impl FnOnce(&Db) -> Result<T>) -> Result
|
||||
let db = Db::from_repack(root, Account::Admin)?;
|
||||
let observed = process::observe(root, &read_ports(root));
|
||||
let mysql_was_up = observed.mysql.state == ServiceState::Running && db.ping();
|
||||
if !mysql_was_up {
|
||||
let db = if mysql_was_up {
|
||||
db
|
||||
} else {
|
||||
let out = driver::run(root, Verb::StartMysql)?;
|
||||
if !out.ok {
|
||||
// Keep the launcher's own last lines: the title alone ("Something went wrong") hides the cause.
|
||||
@@ -317,7 +319,9 @@ pub fn with_database<T>(root: &Path, f: impl FnOnce(&Db) -> Result<T>) -> Result
|
||||
driver::startup_failure(root, &out)
|
||||
)));
|
||||
}
|
||||
}
|
||||
// The start may have moved the database to another port (a reserved or taken one).
|
||||
Db::from_repack(root, Account::Admin)?
|
||||
};
|
||||
let result = f(&db);
|
||||
if !mysql_was_up {
|
||||
let now = process::observe(root, &read_ports(root));
|
||||
|
||||
@@ -15,7 +15,8 @@ use crate::fsx;
|
||||
pub use crate::glue_config;
|
||||
|
||||
pub const ADDON_NAME: &str = "CoABotUI";
|
||||
const EXECUTABLES: [&str; 3] = ["Ascension.exe", "Wow.exe", "WoW.exe"];
|
||||
// CoA Custom Races V2 ships its own client (CoACustomRace.exe) next to Ascension.exe and must be started instead.
|
||||
const EXECUTABLES: [&str; 4] = ["CoACustomRace.exe", "Ascension.exe", "Wow.exe", "WoW.exe"];
|
||||
|
||||
pub fn is_running(client: &Path) -> bool {
|
||||
if crate::platform::flavor() == crate::platform::Flavor::Docker {
|
||||
@@ -71,13 +72,23 @@ fn realm_config(old: &[u8], realm: &str) -> Vec<u8> {
|
||||
}
|
||||
|
||||
pub fn sync_realm(client: &Path, meta: &Path, mode: crate::realms::Mode) -> Result<bool> {
|
||||
sync_realm_when_closed(client, meta, mode, is_running(client))
|
||||
let realm = match mode {
|
||||
crate::realms::Mode::Coa => "Conquest of Azeroth",
|
||||
crate::realms::Mode::Wildcard => "Wildcard",
|
||||
crate::realms::Mode::Reborn => "Warcraft Reborn",
|
||||
};
|
||||
sync_realm_when_closed(client, meta, realm, is_running(client))
|
||||
}
|
||||
|
||||
/// [`sync_realm`] with the realm's name as the server shows it (the owner may have renamed it).
|
||||
pub fn sync_realm_named(client: &Path, meta: &Path, realm: &str) -> Result<bool> {
|
||||
sync_realm_when_closed(client, meta, realm, is_running(client))
|
||||
}
|
||||
|
||||
fn sync_realm_when_closed(
|
||||
client: &Path,
|
||||
meta: &Path,
|
||||
mode: crate::realms::Mode,
|
||||
realm: &str,
|
||||
running: bool,
|
||||
) -> Result<bool> {
|
||||
if running {
|
||||
@@ -89,11 +100,6 @@ fn sync_realm_when_closed(
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => Vec::new(),
|
||||
Err(e) => return Err(e.into()),
|
||||
};
|
||||
let realm = match mode {
|
||||
crate::realms::Mode::Coa => "Conquest of Azeroth",
|
||||
crate::realms::Mode::Wildcard => "Wildcard",
|
||||
crate::realms::Mode::Reborn => "Warcraft Reborn",
|
||||
};
|
||||
let new = realm_config(&old, realm);
|
||||
if new == old {
|
||||
return Ok(true);
|
||||
@@ -677,10 +683,10 @@ mod tests {
|
||||
let meta = d.path().join("meta");
|
||||
let original = b"SET realmName \"Wildcard\"\n";
|
||||
fs::write(c.join("WTF/Config.wtf"), original).unwrap();
|
||||
assert!(!sync_realm_when_closed(&c, &meta, crate::realms::Mode::Coa, true).unwrap());
|
||||
assert!(!sync_realm_when_closed(&c, &meta, "Conquest of Azeroth", true).unwrap());
|
||||
assert_eq!(fs::read(c.join("WTF/Config.wtf")).unwrap(), original);
|
||||
assert!(!backup_dir(&meta).exists());
|
||||
assert!(sync_realm_when_closed(&c, &meta, crate::realms::Mode::Coa, false).unwrap());
|
||||
assert!(sync_realm_when_closed(&c, &meta, "Conquest of Azeroth", false).unwrap());
|
||||
assert_eq!(
|
||||
fs::read(c.join("WTF/Config.wtf")).unwrap(),
|
||||
b"SET realmName \"Conquest of Azeroth\"\n"
|
||||
|
||||
@@ -14,14 +14,24 @@ use crate::download::Cancel;
|
||||
use crate::error::{Error, Result};
|
||||
use crate::fsx;
|
||||
|
||||
pub const CLIENT_VERSION: &str = "1.9.2";
|
||||
pub const CLIENT_VERSION: &str = "2.0";
|
||||
pub const MANIFEST_FILENAME: &str = "custom_races_patch_manifest.txt";
|
||||
/// Files earlier releases installed that the current release no longer ships (removed on update).
|
||||
#[cfg(test)]
|
||||
const RETIRED_FILES: &[&str] = &["Ascension.exe"];
|
||||
/// The client archives of the coa-custom-2.0 release. The server archive is read only for its client
|
||||
/// addons (files/addons: subclass interface, dev menu, teleports, spell activation overlay).
|
||||
pub const ARCHIVES: &[(&str, &str)] = &[
|
||||
("CoA-Custom-1.9.2-Client-1.zip", "https://github.com/ilusixn/azerothcore-wotlk-coa/releases/download/coa-custom-1.9.2/CoA-Custom-1.9.2-Client-1.zip"),
|
||||
("CoA-Custom-1.9.2-Client-2.zip", "https://github.com/ilusixn/azerothcore-wotlk-coa/releases/download/coa-custom-1.9.2/CoA-Custom-1.9.2-Client-2.zip"),
|
||||
("CoA-Custom-1.9.2-Client-3.zip", "https://github.com/ilusixn/azerothcore-wotlk-coa/releases/download/coa-custom-1.9.2/CoA-Custom-1.9.2-Client-3.zip"),
|
||||
("CoA-Custom-1.9.2-Client-4.zip", "https://github.com/ilusixn/azerothcore-wotlk-coa/releases/download/coa-custom-1.9.2/CoA-Custom-1.9.2-Client-4.zip"),
|
||||
("CoA-Custom-1.9.2-Client-5.zip", "https://github.com/ilusixn/azerothcore-wotlk-coa/releases/download/coa-custom-1.9.2/CoA-Custom-1.9.2-Client-5.zip"),
|
||||
("CoA-Custom-V2-Client-1.zip", "https://github.com/ilusixn/CustomRacesCoa/releases/download/coa-custom-2.0/CoA-Custom-V2-Client-1.zip"),
|
||||
("CoA-Custom-V2-Client-2.zip", "https://github.com/ilusixn/CustomRacesCoa/releases/download/coa-custom-2.0/CoA-Custom-V2-Client-2.zip"),
|
||||
("CoA-Custom-V2-Client-3.zip", "https://github.com/ilusixn/CustomRacesCoa/releases/download/coa-custom-2.0/CoA-Custom-V2-Client-3.zip"),
|
||||
("CoA-Custom-V2-Client-4.zip", "https://github.com/ilusixn/CustomRacesCoa/releases/download/coa-custom-2.0/CoA-Custom-V2-Client-4.zip"),
|
||||
("CoA-Custom-V2-Client-5.zip", "https://github.com/ilusixn/CustomRacesCoa/releases/download/coa-custom-2.0/CoA-Custom-V2-Client-5.zip"),
|
||||
("CoA-Custom-V2-Client-6.zip", "https://github.com/ilusixn/CustomRacesCoa/releases/download/coa-custom-2.0/CoA-Custom-V2-Client-6.zip"),
|
||||
("CoA-Custom-V2-Client-7.zip", "https://github.com/ilusixn/CustomRacesCoa/releases/download/coa-custom-2.0/CoA-Custom-V2-Client-7.zip"),
|
||||
("CoA-Custom-V2-Client-8.zip", "https://github.com/ilusixn/CustomRacesCoa/releases/download/coa-custom-2.0/CoA-Custom-V2-Client-8.zip"),
|
||||
("CoA-Custom-V2-Client-9.zip", "https://github.com/ilusixn/CustomRacesCoa/releases/download/coa-custom-2.0/CoA-Custom-V2-Client-9.zip"),
|
||||
("CoA-Custom-V2-Server.zip", "https://github.com/ilusixn/CustomRacesCoa/releases/download/coa-custom-2.0/CoA-Custom-V2-Server.zip"),
|
||||
];
|
||||
|
||||
pub const RACE_MPQS: &[&str] = &[
|
||||
@@ -35,14 +45,29 @@ pub const RACE_MPQS: &[&str] = &[
|
||||
"patch-ZE8.MPQ",
|
||||
"patch-ZE9.MPQ",
|
||||
"patch-ZEA.MPQ",
|
||||
"patch-ZES.MPQ",
|
||||
"patch-ZEZV.MPQ",
|
||||
"patch-ZEZW.MPQ",
|
||||
"patch-ZEZX.MPQ",
|
||||
"patch-ZEZY.MPQ",
|
||||
"patch-ZEZZ.MPQ",
|
||||
"patch-ZEZZA.MPQ",
|
||||
"patch-ZEZZB.MPQ",
|
||||
"patch-ZEZZC.MPQ",
|
||||
"patch-ZEZZD.MPQ",
|
||||
"patch-ZEZZE.MPQ",
|
||||
"patch-ZEZZF.MPQ",
|
||||
"patch-ZEZZG.MPQ",
|
||||
"patch-ZEZZH.MPQ",
|
||||
"patch-ZEZZI.MPQ",
|
||||
"patch-ZG.MPQ",
|
||||
"patch-ZH.MPQ",
|
||||
"patch-ZHA.MPQ",
|
||||
"patch-ZHM.MPQ",
|
||||
"patch-ZJ.MPQ",
|
||||
"patch-ZK.MPQ",
|
||||
"patch-ZM.MPQ",
|
||||
"patch-ZVU.MPQ",
|
||||
"patch-ZES.MPQ",
|
||||
"patch-ZJ.MPQ",
|
||||
"patch-ZZE.MPQ",
|
||||
"patch-ZZR.MPQ",
|
||||
"patch-ZZS.MPQ",
|
||||
@@ -50,26 +75,187 @@ pub const RACE_MPQS: &[&str] = &[
|
||||
"patch-ZZU.MPQ",
|
||||
"patch-ZZV.MPQ",
|
||||
"patch-ZZW.MPQ",
|
||||
"patch-ZZZ.MPQ",
|
||||
"patch-ZK.MPQ",
|
||||
"patch-ZZX.MPQ",
|
||||
"patch-ZZZ.MPQ",
|
||||
"patch-ZZZA.MPQ",
|
||||
"patch-ZZZC.MPQ",
|
||||
"patch-ZZZD.MPQ",
|
||||
"patch-ZZZA.MPQ",
|
||||
"patch-ZZZE.MPQ",
|
||||
"patch-ZZZF.MPQ",
|
||||
"patch-ZZZG.MPQ",
|
||||
"patch-ZZZZ.MPQ",
|
||||
"patch-ZZZZA.MPQ",
|
||||
"patch-ZZZZB.MPQ",
|
||||
"patch-ZZZZC.MPQ",
|
||||
"patch-ZZZZD.MPQ",
|
||||
"patch-ZZZZE.MPQ",
|
||||
"patch-ZZZZS.MPQ",
|
||||
"patch-ZZZZT.MPQ",
|
||||
"patch-ZZZZW.MPQ",
|
||||
"patch-ZZZZX.MPQ",
|
||||
"patch-ZZZZY.MPQ",
|
||||
"patch-ZZZZZ.MPQ",
|
||||
"patch-ZZZZZA.MPQ",
|
||||
"patch-ZZZZZB.MPQ",
|
||||
"patch-ZZZZZC.MPQ",
|
||||
"patch-ZZZZZM.MPQ",
|
||||
"patch-ZZZZZN.MPQ",
|
||||
"patch-ZZZZZO.MPQ",
|
||||
"patch-ZZZZZP.MPQ",
|
||||
"patch-ZZZZZQ.MPQ",
|
||||
"patch-ZZZZZR.MPQ",
|
||||
"patch-ZZZZZS.MPQ",
|
||||
"patch-ZZZZZT.MPQ",
|
||||
"patch-ZZZZZU.MPQ",
|
||||
"patch-ZZZZZV.MPQ",
|
||||
"patch-ZZZZZW.MPQ",
|
||||
"patch-ZZZZZX.MPQ",
|
||||
"patch-ZZZZZY.MPQ",
|
||||
];
|
||||
|
||||
pub const RACE_ADDONS: &[&str] = &[
|
||||
"Ascension_Subclass/Ascension_Subclass.lua",
|
||||
"Ascension_Subclass/Ascension_Subclass.toc",
|
||||
"Ascension_Subclass/Bindings.xml",
|
||||
"Ascension_Subclass/SubclassBar.lua",
|
||||
"Ascension_Subclass/SubclassCastBar.lua",
|
||||
"Ascension_Subclass/SubclassChoices.lua",
|
||||
"Ascension_Subclass/SubclassGlow.lua",
|
||||
"Ascension_Subclass/SubclassNodes.lua",
|
||||
"Ascension_Subclass/SubclassOrbs.lua",
|
||||
"Ascension_Subclass/SubclassPowerBar.lua",
|
||||
"Ascension_Subclass/SubclassRaceBackground.lua",
|
||||
"CoAHideArmor/CoAHideArmor.lua",
|
||||
"CoAHideArmor/CoAHideArmor.toc",
|
||||
"CoAQuestSafe/CoAQuestSafe.lua",
|
||||
"CoAQuestSafe/CoAQuestSafe.toc",
|
||||
"CoAWC2Cursor/CoAWC2Cursor.lua",
|
||||
"CoAWC2Cursor/CoAWC2Cursor.toc",
|
||||
"CoAHideArmor/CoAHideArmor.lua",
|
||||
"CoAHideArmor/CoAHideArmor.toc",
|
||||
"CoA_DevMenu/CoA_DevMenu.lua",
|
||||
"CoA_DevMenu/CoA_DevMenu.lua.before_v2",
|
||||
"CoA_DevMenu/CoA_DevMenu.lua.before_v3",
|
||||
"CoA_DevMenu/CoA_DevMenu.toc",
|
||||
"CoA_DevMenu/CoA_DevMenu_CoA.lua",
|
||||
"CoA_DevMenu/CoA_DevMenu_Combat.lua",
|
||||
"CoA_DevMenu/CoA_DevMenu_Create.lua",
|
||||
"CoA_DevMenu/CoA_DevMenu_Create.lua.before_v4",
|
||||
"CoA_DevMenu/CoA_DevMenu_Create.lua.before_v5",
|
||||
"CoA_DevMenu/CoA_DevMenu_Ext.lua",
|
||||
"CoA_DevMenu/CoA_DevMenu_Ext.lua.before_v3",
|
||||
"CoA_DevMenu/CoA_DevMenu_Ext.lua.before_v4",
|
||||
"CoA_DevMenu/CoA_DevMenu_Help.lua",
|
||||
"CoA_DevMenu/CoA_DevMenu_Items.lua",
|
||||
"CoA_DevMenu/CoA_DevMenu_Me.lua",
|
||||
"CoA_DevMenu/CoA_DevMenu_Server.lua",
|
||||
"CoA_DevMenu/CoA_DevMenu_Share.lua",
|
||||
"CoA_DevMenu/EmoteData.lua",
|
||||
"CoA_TalentReset/CoA_TalentReset.lua",
|
||||
"CoA_TalentReset/CoA_TalentReset.toc",
|
||||
"CoA_Teleports/CoA_Teleports.lua",
|
||||
"CoA_Teleports/CoA_Teleports.toc",
|
||||
"CoA_Teleports/TeleportData.lua",
|
||||
"SpellActivationOverlay-for-CoA/LICENSE",
|
||||
"SpellActivationOverlay-for-CoA/SpellActivationOverlay-for-CoA.toc",
|
||||
"SpellActivationOverlay-for-CoA/SpellActivationOverlay.lua",
|
||||
"SpellActivationOverlay-for-CoA/SpellActivationOverlay.xml",
|
||||
"SpellActivationOverlay-for-CoA/changelog.md",
|
||||
"SpellActivationOverlay-for-CoA/classes/barbarian.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/bloodmage.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/chronomancer.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/common.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/cultist.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/deathknight.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/druid.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/felsworn.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/guardian.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/hunter.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/knightofxoroth.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/mage.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/monk.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/necromancer.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/paladin.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/priest.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/primalist.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/pyromancer.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/ranger.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/reaper.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/rogue.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/runemaster.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/shaman.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/starcaller.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/stormbringer.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/suncleric.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/templar.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/tinker.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/venomancer.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/warlock.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/warrior.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/witchdoctor.lua",
|
||||
"SpellActivationOverlay-for-CoA/classes/witchhunter.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/aura.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/bucket.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/display.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/effect.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/events.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/external.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/glow.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/hash.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/item.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/overlay.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/project.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/rune.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/shutdown.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/sound.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/spell.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/targetspells.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/targetwatch.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/tr.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/trigger.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/util.lua",
|
||||
"SpellActivationOverlay-for-CoA/components/variable.lua",
|
||||
"SpellActivationOverlay-for-CoA/libs/LibActionButton-1.0/LibActionButton-1.0.lua",
|
||||
"SpellActivationOverlay-for-CoA/libs/LibActionButton-1.0/LibActionButton-1.0.toc",
|
||||
"SpellActivationOverlay-for-CoA/libs/LibButtonGlow-1.0/LibButtonGlow-1.0.lua",
|
||||
"SpellActivationOverlay-for-CoA/libs/LibButtonGlow-1.0/LibButtonGlow-1.0.toc",
|
||||
"SpellActivationOverlay-for-CoA/libs/LibStub/LibStub.lua",
|
||||
"SpellActivationOverlay-for-CoA/libs/LibStub/LibStub.toc",
|
||||
"SpellActivationOverlay-for-CoA/options/InterfaceOptionsPanels.lua",
|
||||
"SpellActivationOverlay-for-CoA/options/InterfaceOptionsPanels.xml",
|
||||
"SpellActivationOverlay-for-CoA/options/classoptions.lua",
|
||||
"SpellActivationOverlay-for-CoA/options/db.lua",
|
||||
"SpellActivationOverlay-for-CoA/options/defaults.lua",
|
||||
"SpellActivationOverlay-for-CoA/options/glowoptions.lua",
|
||||
"SpellActivationOverlay-for-CoA/options/overlayoptions.lua",
|
||||
"SpellActivationOverlay-for-CoA/options/questions.lua",
|
||||
"SpellActivationOverlay-for-CoA/options/variables.lua",
|
||||
"SpellActivationOverlay-for-CoA/options/variants.lua",
|
||||
"SpellActivationOverlay-for-CoA/textures/bandits_guile.blp",
|
||||
"SpellActivationOverlay-for-CoA/textures/eclipse_moon.blp",
|
||||
"SpellActivationOverlay-for-CoA/textures/eclipse_sun.blp",
|
||||
"SpellActivationOverlay-for-CoA/textures/fury_of_stormrage_yellow.blp",
|
||||
"SpellActivationOverlay-for-CoA/textures/high_tide.blp",
|
||||
"SpellActivationOverlay-for-CoA/textures/icon64.blp",
|
||||
"SpellActivationOverlay-for-CoA/textures/maelstrom_weapon_1.blp",
|
||||
"SpellActivationOverlay-for-CoA/textures/maelstrom_weapon_2.blp",
|
||||
"SpellActivationOverlay-for-CoA/textures/maelstrom_weapon_3.blp",
|
||||
"SpellActivationOverlay-for-CoA/textures/maelstrom_weapon_4.blp",
|
||||
"SpellActivationOverlay-for-CoA/textures/mask.blp",
|
||||
"SpellActivationOverlay-for-CoA/textures/maskzero.blp",
|
||||
"SpellActivationOverlay-for-CoA/textures/rkm128.blp",
|
||||
"SpellActivationOverlay-for-CoA/textures/texname.lua",
|
||||
"SpellActivationOverlay-for-CoA/textures/thrill_of_the_hunt_1.blp",
|
||||
"SpellActivationOverlay-for-CoA/textures/thrill_of_the_hunt_2.blp",
|
||||
"SpellActivationOverlay-for-CoA/textures/thrill_of_the_hunt_3.blp",
|
||||
"SpellActivationOverlay-for-CoA/variables/actionusable.lua",
|
||||
"SpellActivationOverlay-for-CoA/variables/aurastacks.lua",
|
||||
"SpellActivationOverlay-for-CoA/variables/custom.lua",
|
||||
"SpellActivationOverlay-for-CoA/variables/execute.lua",
|
||||
"SpellActivationOverlay-for-CoA/variables/holypower.lua",
|
||||
"SpellActivationOverlay-for-CoA/variables/itemset.lua",
|
||||
"SpellActivationOverlay-for-CoA/variables/nativesao.lua",
|
||||
"SpellActivationOverlay-for-CoA/variables/stance.lua",
|
||||
"SpellActivationOverlay-for-CoA/variables/talent.lua",
|
||||
"UnBot/OnlineFrame.xml",
|
||||
];
|
||||
|
||||
pub const EXCLUDED_BOT_RACES_RECOMMENDED: &str =
|
||||
@@ -217,6 +403,8 @@ fn patch_files(client: &Path) -> Result<Vec<PatchFile>> {
|
||||
include_str!("custom_races_hashes_1_8_3.json")
|
||||
} else if manifest.lines().any(|line| line == "# CoA Custom 1.9.1") {
|
||||
include_str!("custom_races_hashes_1_9_1.json")
|
||||
} else if manifest.lines().any(|line| line == "# CoA Custom 1.9.2") {
|
||||
include_str!("custom_races_hashes_1_9_2.json")
|
||||
} else {
|
||||
include_str!("custom_races_hashes.json")
|
||||
};
|
||||
@@ -275,8 +463,56 @@ fn suffix(path: &Path, extension: &str) -> PathBuf {
|
||||
))
|
||||
}
|
||||
|
||||
/// SHA-256 of a payload file, remembered for this run of the Manager. V2 is 8.7 GB, and every status check and
|
||||
/// switch verifies all of it; a rename keeps size, creation and write time, while a replaced file changes them.
|
||||
fn cached_sha256(path: &Path) -> Option<String> {
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Mutex, OnceLock};
|
||||
use std::time::UNIX_EPOCH;
|
||||
static HASHES: OnceLock<Mutex<HashMap<(String, u64, u128, u128), String>>> = OnceLock::new();
|
||||
let meta = fs::metadata(path).ok()?;
|
||||
let nanos = |time: io::Result<std::time::SystemTime>| {
|
||||
time.ok()
|
||||
.and_then(|t| t.duration_since(UNIX_EPOCH).ok())
|
||||
.map(|d| d.as_nanos())
|
||||
};
|
||||
// The name without `.disabled`: switching renames only that suffix.
|
||||
let name = path.file_name()?.to_string_lossy().to_ascii_lowercase();
|
||||
let name = name.strip_suffix(".disabled").unwrap_or(&name).to_string();
|
||||
let key = match (nanos(meta.modified()), nanos(meta.created())) {
|
||||
(Some(modified), Some(created)) => Some((name, meta.len(), modified, created)),
|
||||
_ => None,
|
||||
};
|
||||
let hashes = HASHES.get_or_init(Mutex::default);
|
||||
if let Some(hash) = key.as_ref().and_then(|key| hashes.lock().ok()?.get(key).cloned()) {
|
||||
return Some(hash);
|
||||
}
|
||||
let hash = fsx::sha256_file(path).ok()?;
|
||||
if let (Some(key), Ok(mut hashes)) = (key, hashes.lock()) {
|
||||
hashes.insert(key, hash.clone());
|
||||
}
|
||||
Some(hash)
|
||||
}
|
||||
|
||||
fn matches_patch(path: &Path, file: &PatchFile) -> bool {
|
||||
path.is_file() && fsx::sha256_file(path).is_ok_and(|hash| hash == file.sha256)
|
||||
path.is_file() && cached_sha256(path).is_some_and(|hash| hash == file.sha256)
|
||||
}
|
||||
|
||||
/// Whether disabling the patch must hide this file. The stock client loads only the MPQs in Data,
|
||||
/// dinput8.dll and the addons; the rest (Data/Retail, VulkanShaders, the Esteria data files) is read by the
|
||||
/// custom races executable and its libraries alone, so it stays in place: thousands of renames bought nothing.
|
||||
/// A file that replaced one of the player's own (an `.original` exists) is always switched.
|
||||
fn is_switched(client: &Path, file: &PatchFile) -> bool {
|
||||
let lower = file.path.to_ascii_lowercase();
|
||||
let entry_point = lower.starts_with("interface/addons/")
|
||||
|| lower
|
||||
.strip_prefix("data/")
|
||||
.is_some_and(|name| !name.contains('/') && name.ends_with(".mpq"))
|
||||
|| (!lower.contains('/')
|
||||
&& [".dll", ".exe", ".bat"]
|
||||
.iter()
|
||||
.any(|extension| lower.ends_with(extension)));
|
||||
entry_point || suffix(&client.join(&file.path), "original").is_file()
|
||||
}
|
||||
|
||||
/// Only complete, verified payloads are reported as enabled or disabled.
|
||||
@@ -307,9 +543,11 @@ pub fn client_patch_status(client_path: &Path) -> ClientPatchStatus {
|
||||
ClientPatchState::Enabled
|
||||
}
|
||||
Ok(files)
|
||||
if files
|
||||
.iter()
|
||||
.all(|f| matches_patch(&suffix(&client_path.join(&f.path), "disabled"), f)) =>
|
||||
if files.iter().all(|f| {
|
||||
let active = client_path.join(&f.path);
|
||||
matches_patch(&suffix(&active, "disabled"), f)
|
||||
|| (!is_switched(client_path, f) && matches_patch(&active, f))
|
||||
}) =>
|
||||
{
|
||||
ClientPatchState::Disabled
|
||||
}
|
||||
@@ -351,9 +589,24 @@ struct SavedFile {
|
||||
moved_to: Option<String>,
|
||||
}
|
||||
|
||||
/// One line of the append-only journal. A payload has thousands of files, so the journal is never rewritten:
|
||||
/// each step adds one synced line, and recovery replays the lines in order.
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
enum JournalRecord {
|
||||
Saved { path: String, existed: bool },
|
||||
Moved { index: usize, to: String },
|
||||
Returned { index: usize },
|
||||
}
|
||||
|
||||
const LEGACY_JOURNAL: &str = "journal.json";
|
||||
const JOURNAL: &str = "journal.jsonl";
|
||||
|
||||
struct PatchTransaction<'a> {
|
||||
root: &'a Path,
|
||||
entries: Vec<SavedFile>,
|
||||
index: std::collections::HashMap<String, usize>,
|
||||
journal: Option<File>,
|
||||
finished: bool,
|
||||
}
|
||||
|
||||
@@ -376,37 +629,102 @@ fn move_patch_file(source: &Path, target: &Path) -> io::Result<()> {
|
||||
fs::remove_file(source)
|
||||
}
|
||||
|
||||
fn append_record(journal: &mut File, record: &JournalRecord) -> Result<()> {
|
||||
use std::io::Write;
|
||||
let mut line = serde_json::to_vec(record)?;
|
||||
line.push(b'\n');
|
||||
journal.write_all(&line)?;
|
||||
journal.sync_data()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Replays a journal. A line cut short by a crash is the last one and was never followed by its file
|
||||
/// operation (each line is synced before the operation it describes), so reading stops there.
|
||||
fn read_journal(directory: &Path) -> Result<Vec<SavedFile>> {
|
||||
let legacy = directory.join(LEGACY_JOURNAL);
|
||||
if legacy.is_file() {
|
||||
return fsx::read_json(&legacy);
|
||||
}
|
||||
let bytes = match fs::read(directory.join(JOURNAL)) {
|
||||
Ok(bytes) => bytes,
|
||||
Err(error) if error.kind() == io::ErrorKind::NotFound => return Ok(Vec::new()),
|
||||
Err(error) => return Err(error.into()),
|
||||
};
|
||||
let mut entries: Vec<SavedFile> = Vec::new();
|
||||
for line in bytes.split(|byte| *byte == b'\n') {
|
||||
let Ok(record) = serde_json::from_slice::<JournalRecord>(line) else {
|
||||
break;
|
||||
};
|
||||
match record {
|
||||
JournalRecord::Saved { path, existed } => entries.push(SavedFile {
|
||||
path,
|
||||
existed,
|
||||
moved_to: None,
|
||||
}),
|
||||
JournalRecord::Moved { index, to } => {
|
||||
let entry = entries
|
||||
.get_mut(index)
|
||||
.ok_or_else(|| Error::Invalid("Invalid custom races journal.".into()))?;
|
||||
entry.moved_to = Some(to);
|
||||
}
|
||||
JournalRecord::Returned { index } => {
|
||||
let entry = entries
|
||||
.get_mut(index)
|
||||
.ok_or_else(|| Error::Invalid("Invalid custom races journal.".into()))?;
|
||||
entry.moved_to = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(entries)
|
||||
}
|
||||
|
||||
impl<'a> PatchTransaction<'a> {
|
||||
fn new(root: &'a Path) -> Result<Self> {
|
||||
recover_patch_transaction(root)?;
|
||||
fs::create_dir(root.join(".coa-races-transaction"))?;
|
||||
let directory = root.join(".coa-races-transaction");
|
||||
fs::create_dir(&directory)?;
|
||||
let journal = fs::OpenOptions::new()
|
||||
.create_new(true)
|
||||
.append(true)
|
||||
.open(directory.join(JOURNAL))?;
|
||||
Ok(Self {
|
||||
root,
|
||||
entries: Vec::new(),
|
||||
index: std::collections::HashMap::new(),
|
||||
journal: Some(journal),
|
||||
finished: false,
|
||||
})
|
||||
}
|
||||
fn save(&mut self, path: &Path) -> Result<()> {
|
||||
fn relative(&self, path: &Path) -> Result<String> {
|
||||
let relative = path
|
||||
.strip_prefix(self.root)
|
||||
.map_err(|_| Error::Invalid("Patch path escaped the client directory.".into()))?
|
||||
.to_string_lossy()
|
||||
.replace('\\', "/");
|
||||
fsx::safe_join(self.root, &relative)?;
|
||||
if self.entries.iter().any(|entry| entry.path == relative) {
|
||||
Ok(relative)
|
||||
}
|
||||
fn save(&mut self, path: &Path) -> Result<()> {
|
||||
let relative = self.relative(path)?;
|
||||
if self.index.contains_key(&relative) {
|
||||
return Ok(());
|
||||
}
|
||||
let index = self.entries.len();
|
||||
let existed = path.is_file();
|
||||
append_record(
|
||||
self.journal.as_mut().expect("open journal"),
|
||||
&JournalRecord::Saved {
|
||||
path: relative.clone(),
|
||||
existed,
|
||||
},
|
||||
)?;
|
||||
self.index.insert(relative.clone(), index);
|
||||
self.entries.push(SavedFile {
|
||||
path: relative,
|
||||
existed: path.is_file(),
|
||||
existed,
|
||||
moved_to: None,
|
||||
});
|
||||
fsx::atomic_write_json(
|
||||
&self.root.join(".coa-races-transaction/journal.json"),
|
||||
&self.entries,
|
||||
)?;
|
||||
if path.is_file() {
|
||||
if existed {
|
||||
move_patch_file(
|
||||
path,
|
||||
&self
|
||||
@@ -431,21 +749,16 @@ impl<'a> PatchTransaction<'a> {
|
||||
// Save the destination first so recovery restores the moved source before it.
|
||||
self.save(target)?;
|
||||
self.save(source)?;
|
||||
let index = self
|
||||
.entries
|
||||
.iter()
|
||||
.position(|entry| self.root.join(&entry.path) == source)
|
||||
.unwrap();
|
||||
let relative = target
|
||||
.strip_prefix(self.root)
|
||||
.map_err(|_| Error::Invalid("Patch path escaped the client directory.".into()))?
|
||||
.to_string_lossy()
|
||||
.replace('\\', "/");
|
||||
self.entries[index].moved_to = Some(relative);
|
||||
fsx::atomic_write_json(
|
||||
&self.root.join(".coa-races-transaction/journal.json"),
|
||||
&self.entries,
|
||||
let index = self.index[&self.relative(source)?];
|
||||
let relative = self.relative(target)?;
|
||||
append_record(
|
||||
self.journal.as_mut().expect("open journal"),
|
||||
&JournalRecord::Moved {
|
||||
index,
|
||||
to: relative.clone(),
|
||||
},
|
||||
)?;
|
||||
self.entries[index].moved_to = Some(relative);
|
||||
fs::create_dir_all(target.parent().unwrap())?;
|
||||
move_patch_file(
|
||||
&self
|
||||
@@ -463,6 +776,8 @@ impl<'a> PatchTransaction<'a> {
|
||||
b"committed",
|
||||
)?;
|
||||
self.finished = true;
|
||||
// Windows cannot remove a directory while a file in it is open.
|
||||
self.journal = None;
|
||||
fs::remove_dir_all(self.root.join(".coa-races-transaction"))?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -470,6 +785,7 @@ impl<'a> PatchTransaction<'a> {
|
||||
impl Drop for PatchTransaction<'_> {
|
||||
fn drop(&mut self) {
|
||||
if !self.finished {
|
||||
self.journal = None;
|
||||
let _ = recover_patch_transaction(self.root);
|
||||
}
|
||||
}
|
||||
@@ -480,8 +796,19 @@ fn recover_patch_transaction(root: &Path) -> Result<()> {
|
||||
if !directory.is_dir() {
|
||||
return Ok(());
|
||||
}
|
||||
if !directory.join("committed").exists() && directory.join("journal.json").exists() {
|
||||
let mut entries: Vec<SavedFile> = fsx::read_json(&directory.join("journal.json"))?;
|
||||
if !directory.join("committed").exists() {
|
||||
let legacy = directory.join(LEGACY_JOURNAL).is_file();
|
||||
let mut entries = read_journal(&directory)?;
|
||||
let mut journal = if legacy {
|
||||
None
|
||||
} else {
|
||||
Some(
|
||||
fs::OpenOptions::new()
|
||||
.create(true)
|
||||
.append(true)
|
||||
.open(directory.join(JOURNAL))?,
|
||||
)
|
||||
};
|
||||
for index in (0..entries.len()).rev() {
|
||||
let entry = &entries[index];
|
||||
let path = fsx::safe_join(root, &entry.path)?;
|
||||
@@ -493,7 +820,10 @@ fn recover_patch_transaction(root: &Path) -> Result<()> {
|
||||
}
|
||||
// Persist recovery progress before restoring the source, making retries safe.
|
||||
entries[index].moved_to = None;
|
||||
fsx::atomic_write_json(&directory.join("journal.json"), &entries)?;
|
||||
match journal.as_mut() {
|
||||
Some(journal) => append_record(journal, &JournalRecord::Returned { index })?,
|
||||
None => fsx::atomic_write_json(&directory.join(LEGACY_JOURNAL), &entries)?,
|
||||
}
|
||||
}
|
||||
let entry = &entries[index];
|
||||
if saved.is_file() {
|
||||
@@ -505,6 +835,7 @@ fn recover_patch_transaction(root: &Path) -> Result<()> {
|
||||
fs::remove_file(path)?;
|
||||
}
|
||||
}
|
||||
drop(journal);
|
||||
}
|
||||
fs::remove_dir_all(directory)?;
|
||||
Ok(())
|
||||
@@ -541,6 +872,31 @@ fn preserve_original(tx: &mut PatchTransaction<'_>, active: &Path) -> Result<()>
|
||||
tx.copy(active, &original)
|
||||
}
|
||||
|
||||
/// A file the previous release installed and the new one no longer ships (1.9.2's Ascension.exe, which V2
|
||||
/// replaced with its own CoACustomRace.exe) is removed if it is still ours, and the player's original comes back.
|
||||
fn retire_dropped_files(
|
||||
tx: &mut PatchTransaction<'_>,
|
||||
client: &Path,
|
||||
previous: &[PatchFile],
|
||||
payload: &std::collections::BTreeSet<String>,
|
||||
) -> Result<()> {
|
||||
for old in previous.iter().filter(|old| !payload.contains(&old.path)) {
|
||||
let active = fsx::safe_join(client, &old.path)?;
|
||||
if matches_patch(&active, old) {
|
||||
tx.save(&active)?;
|
||||
let original = suffix(&active, "original");
|
||||
if original.is_file() {
|
||||
tx.copy(&original, &active)?;
|
||||
}
|
||||
}
|
||||
let disabled = suffix(&active, "disabled");
|
||||
if matches_patch(&disabled, old) {
|
||||
tx.save(&disabled)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Preserve launcher replacements, and switch every file owned by the package.
|
||||
pub fn set_client_patch_enabled(client: &Path, enabled: bool) -> Result<()> {
|
||||
if !client.is_dir() {
|
||||
@@ -570,7 +926,8 @@ pub fn set_client_patch_enabled(client: &Path, enabled: bool) -> Result<()> {
|
||||
let active = client.join(&file.path);
|
||||
let disabled = suffix(&active, "disabled");
|
||||
let original = suffix(&active, "original");
|
||||
if enabled {
|
||||
// Data the stock client never reads stays active, and an older Manager's disabled copy comes back.
|
||||
if enabled || !is_switched(client, &file) {
|
||||
if active.is_file() && !matches_patch(&active, &file) {
|
||||
preserve_original(&mut tx, &active)?;
|
||||
}
|
||||
@@ -667,26 +1024,46 @@ fn stage_root_asset(staging: &Path, relative: &str, reader: &mut impl Read) -> R
|
||||
|
||||
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" => (
|
||||
"CoA-Custom-V2-Client-1.zip" => (
|
||||
1_513_021_586,
|
||||
"a9dd51ed2d90fb048d549602f40f5429d56e2df0df5606a38781b358fa369568",
|
||||
),
|
||||
"CoA-Custom-1.9.2-Client-2.zip" => (
|
||||
"CoA-Custom-V2-Client-2.zip" => (
|
||||
1_198_283_005,
|
||||
"ab084a55509ccbcc2977a06dd0c01fa879973a1892baaacaeb3ff52f3dfc750e",
|
||||
),
|
||||
"CoA-Custom-1.9.2-Client-3.zip" => (
|
||||
1_678_829_573,
|
||||
"907e267f0ee7038807e626c3c1eca5e12db6c88b747137a23c5fb52eaa1a358e",
|
||||
"CoA-Custom-V2-Client-3.zip" => (
|
||||
1_671_130_705,
|
||||
"0af34199f0739ce086adb0371d3de7c1a0f5ca9c62ecde6b0efe9286e33874a8",
|
||||
),
|
||||
"CoA-Custom-1.9.2-Client-4.zip" => (
|
||||
"CoA-Custom-V2-Client-4.zip" => (
|
||||
502_385_128,
|
||||
"e0bd87172af989fa50a8e2b08ba4321c72b6265047482f051a1db3b80d55bcaa",
|
||||
),
|
||||
"CoA-Custom-1.9.2-Client-5.zip" => (
|
||||
"CoA-Custom-V2-Client-5.zip" => (
|
||||
168_079_711,
|
||||
"73364ad1b58c6342641a848a3b20a835472834f600416606be1470386774ca78",
|
||||
),
|
||||
"CoA-Custom-V2-Client-6.zip" => (
|
||||
1_881_526_537,
|
||||
"91db79b7b451856fa9e45daea52e0fe1c04676653dd8a88e6627f04ee7b47759",
|
||||
),
|
||||
"CoA-Custom-V2-Client-7.zip" => (
|
||||
734_725_114,
|
||||
"4c5532d775d206a3b913a6111040bb96b95c683b74c08a6131ed9f38db8e2b39",
|
||||
),
|
||||
"CoA-Custom-V2-Client-8.zip" => (
|
||||
734_216_670,
|
||||
"bdaa1d047e8767bd5715f1e8465d116220597d9c135a43e2dda02e12ce2e5526",
|
||||
),
|
||||
"CoA-Custom-V2-Client-9.zip" => (
|
||||
195_235_400,
|
||||
"0764893543084a12d15578fe734f66ba4519740794a6b3b3a38a08594c38c640",
|
||||
),
|
||||
"CoA-Custom-V2-Server.zip" => (
|
||||
63_983_587,
|
||||
"8970d61eea40f53cea4c27481edd85d2b2647cd32eb88932e0077da3b4a77d23",
|
||||
),
|
||||
_ => return Err(Error::Invalid("Unknown custom races archive.".into())),
|
||||
};
|
||||
Ok(crate::download::Job {
|
||||
@@ -781,6 +1158,17 @@ fn resolve_archive_with(
|
||||
Ok(job.dest.clone())
|
||||
}
|
||||
|
||||
/// The 1.9.2 file name of a V2 archive with the same bytes (same size and SHA-256 in both releases).
|
||||
fn earlier_name(filename: &str) -> Option<&'static str> {
|
||||
match filename {
|
||||
"CoA-Custom-V2-Client-1.zip" => Some("CoA-Custom-1.9.2-Client-1.zip"),
|
||||
"CoA-Custom-V2-Client-2.zip" => Some("CoA-Custom-1.9.2-Client-2.zip"),
|
||||
"CoA-Custom-V2-Client-4.zip" => Some("CoA-Custom-1.9.2-Client-4.zip"),
|
||||
"CoA-Custom-V2-Client-5.zip" => Some("CoA-Custom-1.9.2-Client-5.zip"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Locate a verified archive or resume downloading it into the Manager's cache.
|
||||
fn resolve_or_download_archive(
|
||||
filename: &str,
|
||||
@@ -796,6 +1184,16 @@ fn resolve_or_download_archive(
|
||||
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)?;
|
||||
// V2 republished four 1.9.2 archives byte for byte under new names: reuse a verified 1.9.2 copy.
|
||||
if let Some(previous) = earlier_name(filename) {
|
||||
for folder in [Some(cache.as_path()), downloads.as_deref()].into_iter().flatten() {
|
||||
let candidate = folder.join(previous);
|
||||
if archive_matches(&candidate, &job) {
|
||||
tracing::info!(path = %candidate.display(), "using the identical 1.9.2 archive");
|
||||
return Ok(candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
resolve_archive_with(transport, &job, downloads.as_deref(), cancel, &|p| {
|
||||
let ratio = p.downloaded as f32 / p.total.max(1) as f32;
|
||||
report(
|
||||
@@ -985,6 +1383,8 @@ pub fn install_client_patches(
|
||||
"Custom races archives are missing required runtime files.".into(),
|
||||
));
|
||||
}
|
||||
let payload_paths: std::collections::BTreeSet<String> =
|
||||
payload.iter().map(|file| file.path.clone()).collect();
|
||||
let previous = patch_files(client_path)?;
|
||||
let mut tx = PatchTransaction::new(client_path)?;
|
||||
for file in payload {
|
||||
@@ -1017,6 +1417,7 @@ pub fn install_client_patches(
|
||||
}
|
||||
}
|
||||
}
|
||||
retire_dropped_files(&mut tx, client_path, &previous, &payload_paths)?;
|
||||
tx.save(&manifest_path)?;
|
||||
fsx::atomic_write(&manifest_path, manifest_body.as_bytes())?;
|
||||
tx.finish()?;
|
||||
@@ -1165,6 +1566,7 @@ mod tests {
|
||||
("ADDON", base)
|
||||
} else {
|
||||
name.strip_prefix("Data/")
|
||||
.filter(|base| !base.contains('/'))
|
||||
.map_or(("ROOT", *name), |base| ("MPQ", base))
|
||||
};
|
||||
manifest.push_str(&format!(
|
||||
@@ -1175,6 +1577,165 @@ mod tests {
|
||||
fs::write(root.join(MANIFEST_FILENAME), manifest).unwrap();
|
||||
}
|
||||
|
||||
const SWITCHED: &[&str] = &[
|
||||
"Data/patch-ZE1.MPQ",
|
||||
"dinput8.dll",
|
||||
"CoACustomRace.exe",
|
||||
"Start-CoACustomRace.bat",
|
||||
"Interface/AddOns/CoAHideArmor/CoAHideArmor.lua",
|
||||
];
|
||||
const INERT: &[&str] = &[
|
||||
"Data/Retail/Cache/Retail/wow/decoded/2/strict/id-1.bin",
|
||||
"Data/Retail/RetailCasc.ini",
|
||||
"VulkanShaders/a.spv",
|
||||
"Vulkan/d3d9.dll",
|
||||
"forever_data/hd_forever_fog.txt",
|
||||
"EsteriaAppearance.bin",
|
||||
];
|
||||
|
||||
fn client_with(root: &Path, names: &[&str]) {
|
||||
for name in names {
|
||||
let path = root.join(name);
|
||||
fs::create_dir_all(path.parent().unwrap()).unwrap();
|
||||
fs::write(&path, format!("custom {name}")).unwrap();
|
||||
}
|
||||
record_files(root, names);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn disabling_hides_only_what_the_stock_client_loads() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let root = temp.path();
|
||||
let all: Vec<&str> = SWITCHED.iter().chain(INERT).copied().collect();
|
||||
client_with(root, &all);
|
||||
set_client_patch_enabled(root, false).unwrap();
|
||||
for name in SWITCHED {
|
||||
assert!(!root.join(name).exists(), "{name} stays active");
|
||||
assert!(suffix(&root.join(name), "disabled").is_file(), "{name}");
|
||||
}
|
||||
for name in INERT {
|
||||
assert!(root.join(name).is_file(), "{name} was moved");
|
||||
assert!(!suffix(&root.join(name), "disabled").exists(), "{name}");
|
||||
}
|
||||
assert_eq!(client_patch_status(root).state, ClientPatchState::Disabled);
|
||||
set_client_patch_enabled(root, true).unwrap();
|
||||
assert_eq!(client_patch_status(root).state, ClientPatchState::Enabled);
|
||||
for name in &all {
|
||||
assert!(root.join(name).is_file(), "{name}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_file_that_replaced_the_players_own_is_still_switched() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let root = temp.path();
|
||||
let name = "Data/Retail/RetailCasc.ini";
|
||||
client_with(root, &[name]);
|
||||
fs::write(suffix(&root.join(name), "original"), b"player").unwrap();
|
||||
set_client_patch_enabled(root, false).unwrap();
|
||||
assert_eq!(fs::read(root.join(name)).unwrap(), b"player");
|
||||
assert!(suffix(&root.join(name), "disabled").is_file());
|
||||
assert_eq!(client_patch_status(root).state, ClientPatchState::Disabled);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_client_disabled_by_an_older_manager_is_disabled_and_enables() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let root = temp.path();
|
||||
let all: Vec<&str> = SWITCHED.iter().chain(INERT).copied().collect();
|
||||
client_with(root, &all);
|
||||
// 0.9.13 renamed every file of the payload.
|
||||
for name in &all {
|
||||
fs::rename(root.join(name), suffix(&root.join(name), "disabled")).unwrap();
|
||||
}
|
||||
assert_eq!(client_patch_status(root).state, ClientPatchState::Disabled);
|
||||
set_client_patch_enabled(root, false).unwrap();
|
||||
for name in INERT {
|
||||
assert!(root.join(name).is_file(), "{name} not restored");
|
||||
}
|
||||
assert_eq!(client_patch_status(root).state, ClientPatchState::Disabled);
|
||||
set_client_patch_enabled(root, true).unwrap();
|
||||
assert_eq!(client_patch_status(root).state, ClientPatchState::Enabled);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_transaction_left_by_an_older_manager_is_recovered() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let root = temp.path();
|
||||
let directory = root.join(".coa-races-transaction");
|
||||
fs::create_dir(&directory).unwrap();
|
||||
// The source was moved into the journal and then on to its destination when the old Manager stopped.
|
||||
fs::write(root.join("patch.MPQ.disabled"), b"patch bytes").unwrap();
|
||||
fs::write(
|
||||
directory.join(LEGACY_JOURNAL),
|
||||
r#"[{"path":"patch.MPQ.disabled","existed":false},{"path":"patch.MPQ","existed":true,"moved_to":"patch.MPQ.disabled"}]"#,
|
||||
)
|
||||
.unwrap();
|
||||
recover_patch_transaction(root).unwrap();
|
||||
assert_eq!(fs::read(root.join("patch.MPQ")).unwrap(), b"patch bytes");
|
||||
assert!(!root.join("patch.MPQ.disabled").exists());
|
||||
assert!(!directory.exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_journal_line_cut_short_by_a_crash_is_ignored() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let root = temp.path();
|
||||
let file = root.join("dinput8.dll");
|
||||
fs::write(&file, b"previous").unwrap();
|
||||
let mut tx = PatchTransaction::new(root).unwrap();
|
||||
tx.save(&file).unwrap();
|
||||
fs::write(&file, b"replacement").unwrap();
|
||||
drop(tx.journal.take());
|
||||
std::mem::forget(tx);
|
||||
let journal = root.join(".coa-races-transaction").join(JOURNAL);
|
||||
let mut bytes = fs::read(&journal).unwrap();
|
||||
bytes.extend_from_slice(br#"{"saved":{"path":"other.dll","exi"#);
|
||||
fs::write(&journal, bytes).unwrap();
|
||||
recover_patch_transaction(root).unwrap();
|
||||
assert_eq!(fs::read(&file).unwrap(), b"previous");
|
||||
assert!(!root.join(".coa-races-transaction").exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn switching_a_release_sized_payload_takes_seconds() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let root = temp.path();
|
||||
let mut names: Vec<String> = (0..7000)
|
||||
.map(|i| format!("VulkanShaders/shader-{i}.spv"))
|
||||
.collect();
|
||||
names.extend((0..80).map(|i| format!("Data/patch-Z{i}.MPQ")));
|
||||
names.extend((0..140).map(|i| format!("Interface/AddOns/Addon{}/file{i}.lua", i % 9)));
|
||||
let names: Vec<&str> = names.iter().map(String::as_str).collect();
|
||||
client_with(root, &names);
|
||||
let started = std::time::Instant::now();
|
||||
set_client_patch_enabled(root, false).unwrap();
|
||||
set_client_patch_enabled(root, true).unwrap();
|
||||
let elapsed = started.elapsed();
|
||||
assert_eq!(client_patch_status(root).state, ClientPatchState::Enabled);
|
||||
// 0.9.13 needed minutes here: it moved every file and rewrote the whole journal after each one.
|
||||
assert!(elapsed < std::time::Duration::from_secs(60), "{elapsed:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_update_retires_files_the_new_release_no_longer_ships() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let root = temp.path();
|
||||
fs::write(root.join("Ascension.exe"), b"1.9.2 client").unwrap();
|
||||
fs::write(root.join("Ascension.exe.original"), b"player's own client").unwrap();
|
||||
fs::write(root.join("Wow.exe"), b"changed by the player").unwrap();
|
||||
let ours = |path: &str, bytes: &[u8]| PatchFile {
|
||||
path: path.into(),
|
||||
sha256: hex::encode(<sha2::Sha256 as sha2::Digest>::digest(bytes)),
|
||||
};
|
||||
let previous = vec![ours("Ascension.exe", b"1.9.2 client"), ours("Wow.exe", b"old package bytes")];
|
||||
let mut tx = PatchTransaction::new(root).unwrap();
|
||||
retire_dropped_files(&mut tx, root, &previous, &Default::default()).unwrap();
|
||||
tx.finish().unwrap();
|
||||
assert_eq!(fs::read(root.join("Ascension.exe")).unwrap(), b"player's own client");
|
||||
assert_eq!(fs::read(root.join("Wow.exe")).unwrap(), b"changed by the player");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "Requires the downloaded release archives"]
|
||||
fn bundled_hashes_match_verified_release_archives() {
|
||||
@@ -1226,6 +1787,28 @@ mod tests {
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "Requires COA_UPGRADE_CLIENT: a disposable client with 1.9.2 installed by Manager 0.9.12"]
|
||||
fn an_installed_1_9_2_client_updates_to_v2_and_gets_its_own_executable_back() {
|
||||
let root = PathBuf::from(std::env::var_os("COA_UPGRADE_CLIENT").expect("COA_UPGRADE_CLIENT"));
|
||||
assert_eq!(client_patch_status(&root).version.as_deref(), Some("1.9.2"));
|
||||
let patched = fs::read(root.join("Ascension.exe")).unwrap();
|
||||
let original = fs::read(root.join("Ascension.exe.original")).unwrap();
|
||||
assert_ne!(patched, original);
|
||||
install_client_patches(&root, &Cancel::default(), &|_, _| {}).unwrap();
|
||||
let status = client_patch_status(&root);
|
||||
assert_eq!(status.version.as_deref(), Some(CLIENT_VERSION));
|
||||
assert_eq!(status.state, ClientPatchState::Enabled);
|
||||
assert!(root.join("CoACustomRace.exe").is_file());
|
||||
assert!(root.join("Data/patch-ZZZZZY.MPQ").is_file());
|
||||
// 1.9.2's patched Ascension.exe is retired and the player's own executable is back.
|
||||
assert_eq!(fs::read(root.join("Ascension.exe")).unwrap(), original);
|
||||
uninstall_client_patches(&root).unwrap();
|
||||
assert_eq!(client_patch_status(&root).state, ClientPatchState::NotInstalled);
|
||||
assert_eq!(fs::read(root.join("Ascension.exe")).unwrap(), original);
|
||||
assert!(!root.join("CoACustomRace.exe").exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "Requires the downloaded release archives in the normal download cache"]
|
||||
fn release_archives_install_toggle_and_uninstall_in_a_disposable_client() {
|
||||
@@ -1243,8 +1826,30 @@ mod tests {
|
||||
assert!(root
|
||||
.join("Interface/AddOns/CoAHideArmor/CoAHideArmor.lua")
|
||||
.is_file());
|
||||
// V2: its own client next to the untouched game executable, and the server package's addons.
|
||||
assert!(root.join("CoACustomRace.exe").is_file());
|
||||
assert!(root.join("Vulkan/d3d9.dll").is_file());
|
||||
assert_eq!(fs::read(root.join("Ascension.exe")).unwrap(), b"original game executable");
|
||||
assert!(root
|
||||
.join("Interface/AddOns/Ascension_Subclass")
|
||||
.is_dir());
|
||||
let started = std::time::Instant::now();
|
||||
set_client_patch_enabled(root, false).unwrap();
|
||||
eprintln!("disable took {:?}", started.elapsed());
|
||||
assert_eq!(client_patch_status(root).state, ClientPatchState::Disabled);
|
||||
// Only what the stock client loads is hidden; the data its executable alone reads stays put.
|
||||
assert!(!root.join("CoACustomRace.exe").exists());
|
||||
assert!(!root.join("dinput8.dll").exists());
|
||||
assert!(!root.join("Data/patch-ZZZD.MPQ").exists());
|
||||
assert!(!root.join("Interface/AddOns/CoAHideArmor/CoAHideArmor.lua").exists());
|
||||
assert!(root.join("Vulkan/d3d9.dll").is_file());
|
||||
assert!(root.join("Data/Retail/RetailCasc.ini").is_file());
|
||||
let hidden = patch_files(root)
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|file| suffix(&root.join(&file.path), "disabled").is_file())
|
||||
.count();
|
||||
eprintln!("hidden {hidden} of {}", patch_files(root).unwrap().len());
|
||||
assert_eq!(
|
||||
fs::read(root.join("Ascension.exe")).unwrap(),
|
||||
b"original game executable"
|
||||
@@ -1253,7 +1858,9 @@ mod tests {
|
||||
fs::read(root.join("Data/patch-T.MPQ")).unwrap(),
|
||||
b"original game patch"
|
||||
);
|
||||
let started = std::time::Instant::now();
|
||||
set_client_patch_enabled(root, true).unwrap();
|
||||
eprintln!("enable took {:?}", started.elapsed());
|
||||
assert_eq!(client_patch_status(root).state, ClientPatchState::Enabled);
|
||||
uninstall_client_patches(root).unwrap();
|
||||
assert_eq!(
|
||||
@@ -1273,6 +1880,7 @@ mod tests {
|
||||
b"unrelated user patch"
|
||||
);
|
||||
assert!(!root.join("Data/patch-ZZZD.MPQ").exists());
|
||||
assert!(!root.join("CoACustomRace.exe").exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1317,7 +1925,10 @@ mod tests {
|
||||
);
|
||||
assert_ne!(legacy["Data/patch-T.MPQ"], current["Data/patch-T.MPQ"]);
|
||||
assert!(!files.iter().any(|file| file.path == "Data/patch-ZZW.MPQ"));
|
||||
assert!(legacy.keys().all(|key| current.contains_key(key)));
|
||||
assert!(legacy
|
||||
.keys()
|
||||
.filter(|key| !RETIRED_FILES.contains(&key.as_str()))
|
||||
.all(|key| current.contains_key(key)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1333,7 +1944,10 @@ mod tests {
|
||||
for file in files {
|
||||
assert_eq!(file.sha256, legacy[&file.path]);
|
||||
}
|
||||
assert!(legacy.keys().all(|path| current.contains_key(path)));
|
||||
assert!(legacy
|
||||
.keys()
|
||||
.filter(|key| !RETIRED_FILES.contains(&key.as_str()))
|
||||
.all(|key| current.contains_key(key)));
|
||||
assert!(!legacy.contains_key("Data/patch-ZZZD.MPQ"));
|
||||
assert!(current.contains_key("Data/patch-ZZZD.MPQ"));
|
||||
let status = client_patch_status(temp.path());
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,116 @@
|
||||
{
|
||||
"Ascension.exe": "e2c347019d554a59639e5978fd68e50e906973ab313c6573cc56ca82e8e3c547",
|
||||
"Data/Retail/Assets/EquipmentFitting/1068-1.bin": "332d2c38b037a118f262bbb3096a01ebfb33c5347e96bbfb64157437b300281b",
|
||||
"Data/Retail/Assets/EquipmentFitting/60-0.bin": "ffbf6efc9ea09b0c442f048c5bc7b4c5975258045cfddedd9a77a93363312b5e",
|
||||
"Data/Retail/Assets/EquipmentFitting/60-1.bin": "36ceed2a55756f3322e018938809acea5124351161405058ef27d100173778da",
|
||||
"Data/Retail/Assets/EquipmentFitting/61-0.bin": "3b302a4055d1e795c451b02e38dfe8007527ee1bc5f926ebcd6ef17f433cd232",
|
||||
"Data/Retail/Assets/EquipmentFitting/61-1.bin": "c42df399ed99be3c7ce1b5fdb95a873711011713a4cd867bc226a14b1ce0e8ca",
|
||||
"Data/Retail/Assets/EquipmentFitting/65-0.bin": "8ce3f884ae197d14dff0f955c2cf05abb716742c8aff79f7af1cec5cf7225f04",
|
||||
"Data/Retail/Assets/EquipmentFitting/68-0.bin": "f1d878f0f943cbdb8025af8daac4a38c1d1e159bd961d9d76f225931c11648ac",
|
||||
"Data/Retail/Assets/EquipmentFitting/68-1.bin": "2ccbae634384200340c0cc3dca36a7a014a8ddad110598e4470ff1b266576465",
|
||||
"Data/Retail/Assets/EquipmentFitting/73-0.bin": "5530882678f677ad47987ce906e851338a35f7d9737e3f9d829938027b8af67f",
|
||||
"Data/Retail/Assets/EquipmentFitting/74-0.bin": "53a7be86b3bfdd6995406c706df3ca091484206d8141cebb39113c714500384a",
|
||||
"Data/Retail/Assets/EquipmentFitting/74-1.bin": "e688c55a355231978d42480a003c26d379460f5931c2469c119ecb073ea153e1",
|
||||
"Data/Retail/Assets/EquipmentFitting/75-0.bin": "289abc71c6df0e031a64d62a40e658eaefd37e45373a062ca52f08fbe803500c",
|
||||
"Data/Retail/Assets/EquipmentFitting/76-0.bin": "63a493e70b91f59ff49f1942d959df986062bd267fe2ba589f344963df771021",
|
||||
"Data/Retail/Assets/EquipmentFitting/77-0.bin": "b1366ce0dc4f31cb8c8c9705be2da565df4b905224af04b6b88f8c8e9c87e3c9",
|
||||
"Data/Retail/Assets/EquipmentFitting/78-0.bin": "7b0031fb12ab19020005bdccacca2dd3991349c36949a58b035992585b4134db",
|
||||
"Data/patch-T.MPQ": "fe597138ab7f56881b5f4f27d6dc9d81bb278b483ca0d91b7207ffd4a5ae7bfd",
|
||||
"Data/patch-ZE1.MPQ": "69d79dbbea54ec0312c37770debc79c7bc9ce2e21eedef99c03cd8d911955283",
|
||||
"Data/patch-ZE2.MPQ": "1a41cae77ad730e9cf69e8d63fd12ae3a579418bb550d351fff469573a97ac3c",
|
||||
"Data/patch-ZE3.MPQ": "b587202c21b6f580682b601b7c2e905fbfa766276e74733db55c1bddbffb7f87",
|
||||
"Data/patch-ZE5.MPQ": "476b5a1fcf69f64fdb281e3b445362b936d016066ccd12f897acfcf200d6c0cf",
|
||||
"Data/patch-ZE6.MPQ": "762592c9ed950b4a7b6c7d85d45050b30fa3f35d53e348ee1e1516fdbb7e5484",
|
||||
"Data/patch-ZE7.MPQ": "de54b0189d242763d2872223419a259b6b8a4b380c24b50a2ef9c6fa44466248",
|
||||
"Data/patch-ZE8.MPQ": "1bc5691fb84a84f3e7a0a70baaa9192a97b4ec5906ee37c85838ffe08adef934",
|
||||
"Data/patch-ZE9.MPQ": "d49c94463e9548e76378ce2c0454d8f204f0745c8c0de32b6dce7f0b0fd67c4a",
|
||||
"Data/patch-ZEA.MPQ": "78fd10ec5262ae2417eba9700d2172553bbc1e5cfb0b597aada8f1753ca46d9d",
|
||||
"Data/patch-ZES.MPQ": "a2d9348f917f745c7aa25b2eed96efa312f7b2d2f62cb86a4f2eaabc2dfa895f",
|
||||
"Data/patch-ZG.MPQ": "48979e1fda775f8deb47bffa48e0a468595d4c71286fee518f51dc5801c5ca39",
|
||||
"Data/patch-ZH.MPQ": "5e1d2fe287053abba703d7af381e10096c6525ba477ffed3971c2fc4f93e919c",
|
||||
"Data/patch-ZHA.MPQ": "0fc6ebeafe1d14192dc64bafc90bde3c49230df1297f98bf65900a3bcf953617",
|
||||
"Data/patch-ZHM.MPQ": "317d3ae00f0bd674b358af07544976acb7804aa6d8b19d1788ad96030e8c9bf0",
|
||||
"Data/patch-ZJ.MPQ": "f821e99add86ef68d108c5ec466328c97677d3ed52f7944e200f3fe38c13b4de",
|
||||
"Data/patch-ZK.MPQ": "444d0ecb72c1e990509d53e3cfa5b7634c816733533e8a97e5d7f5653ee32cce",
|
||||
"Data/patch-ZM.MPQ": "424ab1978986e854551633983a94bd15beba6328aabea8c02f98eaa32f6f0b61",
|
||||
"Data/patch-ZVU.MPQ": "c679b85a2e97344395756b54d2cf6abefe4e80e74944cb55b6e573ad17b7d020",
|
||||
"Data/patch-ZZE.MPQ": "4b1e289e12c82644cb78f50170e6b5fd53918eb2de834f9e0cebddd81873a8bb",
|
||||
"Data/patch-ZZR.MPQ": "5a7575e592dc0c8a6913e0d946bbe06fa0ca2e4d817ef1f8548d3d13142bcbd3",
|
||||
"Data/patch-ZZS.MPQ": "533fd69d5784d83e872a5a28d27301dc9ab5d0cb925f8b2116926854e4a0a5b8",
|
||||
"Data/patch-ZZT.MPQ": "e60dab63fe5650fdf5f0846ea6d4136219293bcfdad46d9b796697faeff9ab4c",
|
||||
"Data/patch-ZZU.MPQ": "0311de8f034eae7dec1bd2c92b1fe6c741cbaf53da62c7609cd12b6c37908e47",
|
||||
"Data/patch-ZZV.MPQ": "3b04008905e7185d165827d68f7ca228dda8272816364f7d71874ecc83b64f0e",
|
||||
"Data/patch-ZZW.MPQ": "3bbbc72901fd2d662113036485c380701e693f5a39ba9479af306bf2fa2030bd",
|
||||
"Data/patch-ZZX.MPQ": "4c12608089cfe356f7c8882d66db90239ed3ec8ddd980d91d7a3a488680f3c88",
|
||||
"Data/patch-ZZZ.MPQ": "566aaadf501af42e29a828b1bc2edbd36d436288fb309fe423bd74b9619bf593",
|
||||
"Data/patch-ZZZA.MPQ": "57ccbdc0a66000767554ffd194088df6d602ddd8341a141bca8201e7d5435889",
|
||||
"Data/patch-ZZZC.MPQ": "691a53f6325c2615a64ced0802f18bc4d96e99c62aaa606fc930f9406ee74cdf",
|
||||
"Data/patch-ZZZD.MPQ": "ca893cf8129f6fd442a63f0697a8ddea88546e3ce71bde713be2cc832b892bc9",
|
||||
"Data/patch-ZZZE.MPQ": "2e245ee0fe3b913087eed399062fda5843d98b04afac38024f7c64ac3bf43e18",
|
||||
"Data/patch-ZZZF.MPQ": "40eac695cfcafb598b8376f3b9a61ecc037e4d445b87279cfe387a91edad32c3",
|
||||
"Data/patch-ZZZZ.MPQ": "860c990db3b4185fdc36e1a001d3ca3507a68253a4506793a115f86eb0892a15",
|
||||
"EsteriaAppearance.bin": "90d9cfaeaf6de10f014f1d1610ea10453ec9b240255759aea99513cac488a3ec",
|
||||
"EsteriaAppearance.dll": "88e268d3be9eca3b0644f543d823f4bdcc04a9700a6e8ed73fd2a1260ad191af",
|
||||
"EsteriaAppearanceGeometry.bin": "19de5b4b4f79778ea5316659efc2f66c6edb6b5149c46efa47c46bfa4ec6904c",
|
||||
"EsteriaAppearanceMaterials.bin": "f72f027f54a55c05aa0f76b457b97b484fe0e1aedc0e068cc0e0ca53e1878cba",
|
||||
"EsteriaBanshee.bin": "d3fe66caa6a0ecba96bddb07ac1cbdb915694e87fc1608da0fdabecdf9ffea4d",
|
||||
"EsteriaBansheeTextures.bin": "837774377ca055e6a5c79c1a4cfd8151e7c1f7ce2c16990b00fd445281137433",
|
||||
"EsteriaCentaur.bin": "d63f0b7d21cee67d234d134e832fe6d55c398f2b63f9f6c191dcfa9671637185",
|
||||
"EsteriaCentaurTextures.bin": "837774377ca055e6a5c79c1a4cfd8151e7c1f7ce2c16990b00fd445281137433",
|
||||
"EsteriaCosmeticWings.bin": "57352c28459d073a29b3014d33b70f3b3756afa37fa9583ef6b30d503422ac3f",
|
||||
"EsteriaDrakonid.bin": "95440ee9c065ef20bb7fed6158d20623d68745291cedc2726fc746ff54601f95",
|
||||
"EsteriaDrakonidCoverage.bin": "9cdc227f08329e1245d2b864a996e7a772c96ecdbe5d81925f4d60cdbe4fa11e",
|
||||
"EsteriaDrakonidTextures.bin": "1ba9133a75dad291d98a068b2dcde01f31a897a1764cd7f3e2c316c288a8f605",
|
||||
"EsteriaEarthen.bin": "8a0db93ba2d5c756b44ed84f2f7bc7c15eef13be6a7d87baf1383c6c0c624e02",
|
||||
"EsteriaEthereal.bin": "ada3b7588511a847dd5154d91e3041e9f7f193998b06bfede5e0afc32570b48c",
|
||||
"EsteriaEtherealTextures.bin": "837774377ca055e6a5c79c1a4cfd8151e7c1f7ce2c16990b00fd445281137433",
|
||||
"EsteriaFaceless.bin": "1c5a1d7a6b1db6984a8e41bc4804e9f7c50d65dcdbb8c0a9d1a9e8af8c91bd8f",
|
||||
"EsteriaFacelessTextures.bin": "837774377ca055e6a5c79c1a4cfd8151e7c1f7ce2c16990b00fd445281137433",
|
||||
"EsteriaGnoll.bin": "cfacc8e681bb8e54a4f01ee9c12a91bf0bd23a23527bb548d4dc21ec1b33eea2",
|
||||
"EsteriaGnollTextures.bin": "1ba9133a75dad291d98a068b2dcde01f31a897a1764cd7f3e2c316c288a8f605",
|
||||
"EsteriaHaranir.bin": "59f31d00e372fd2646e1cf0d9d3d5d671b31edd60ff7b862f8d1ce7e53ba1f2f",
|
||||
"EsteriaHaranirTextures.bin": "99948ca570be2d376f0c67e3b8088739b6fa9f9d2c73985e19f68df77689a229",
|
||||
"EsteriaHighmountain.bin": "e83349252ad2687ac23fcfc5623db7401cf32e5faf47a5a7be20c2f94b014938",
|
||||
"EsteriaHozen.bin": "739bc3775388976f5c09bcbf3a98b62d804dff78d545e25a41d07dd99b5fddc5",
|
||||
"EsteriaHozenTextures.bin": "837774377ca055e6a5c79c1a4cfd8151e7c1f7ce2c16990b00fd445281137433",
|
||||
"EsteriaKvItems.bin": "fc5f9d86114234b38dbb0e14a6a5ec16249eaa92a73411a7fc371a950549dcce",
|
||||
"EsteriaKvSkins.bin": "60b2b899f5f83137368514928f92f3b04c0fae058f534c487ddbe913ee4bec18",
|
||||
"EsteriaKyrian.bin": "9329147f08805ff4003f9e062fea7c6ea8fdd8c4d6a40de63a6d228ebe1b7c9a",
|
||||
"EsteriaKyrianTextures.bin": "837774377ca055e6a5c79c1a4cfd8151e7c1f7ce2c16990b00fd445281137433",
|
||||
"EsteriaMantid.bin": "71536dee6c2abd0b0e13f33bc73cad7e6fb1b0fc1f6912a95c55d57bc7ee1787",
|
||||
"EsteriaMantidTextures.bin": "837774377ca055e6a5c79c1a4cfd8151e7c1f7ce2c16990b00fd445281137433",
|
||||
"EsteriaNaga.bin": "e87547cff5d09500c294f8b06935d134cdd0bbb962e294a72de09404505bd8b3",
|
||||
"EsteriaNagaTextures.bin": "57ec560f99c1d48ac1e8f6a797c156513b99e7d349e3071afe405f812d159ae3",
|
||||
"EsteriaSaberon.bin": "7735c9325c807c5125760d87f323d6b7d4162fb542c1d8b5f435ea2d6b9a4daa",
|
||||
"EsteriaSaberonCoverage.bin": "9cdc227f08329e1245d2b864a996e7a772c96ecdbe5d81925f4d60cdbe4fa11e",
|
||||
"EsteriaSaberonTextures.bin": "1ba9133a75dad291d98a068b2dcde01f31a897a1764cd7f3e2c316c288a8f605",
|
||||
"EsteriaSethrak.bin": "bd14857a8c11fdf8027128763293701586b2102f9a6539d33a727014789fd606",
|
||||
"EsteriaSethrakTextures.bin": "d2b2cf58087a391f00198008fe871edd400ddf28d54a3a05674df74c5198528a",
|
||||
"EsteriaSlime.bin": "491e942ceb6abda83c0249afebae7c9c43af3897b35e45fa33d6f9177ecbc177",
|
||||
"EsteriaSlimeTextures.bin": "837774377ca055e6a5c79c1a4cfd8151e7c1f7ce2c16990b00fd445281137433",
|
||||
"EsteriaTarasek.bin": "f718444d5ec36f7aff018883486ae1981151fe6e01f5b7781d68d74e9fadfa47",
|
||||
"EsteriaTarasekTextures.bin": "1ba9133a75dad291d98a068b2dcde01f31a897a1764cd7f3e2c316c288a8f605",
|
||||
"EsteriaThinHuman.bin": "bc12e5ca2c087ca0a8642ff6cd8e78fe2e1f85928518b12c19b4245a8320585d",
|
||||
"EsteriaThinHumanTextures.bin": "27488a7494fa9733b53118d1d0f4acef50a9e19004f81f9c8a614b10f4c3fd5e",
|
||||
"EsteriaTuskarr.bin": "ecbe7ef490ba67eca029a57639192db61238522618491549766fe38529914387",
|
||||
"EsteriaTuskarrTextures.bin": "e2116c2c83adea079126fd5da765d20da24f044d4f161c4124e4368cb3d6bc71",
|
||||
"EsteriaVenthyr.bin": "5bcf7804363e59b3c922830d06de17bbd348b9967307f39b7d72bc09f58814eb",
|
||||
"EsteriaVenthyrTextures.bin": "837774377ca055e6a5c79c1a4cfd8151e7c1f7ce2c16990b00fd445281137433",
|
||||
"EsteriaVorkai.bin": "d6d2088c7e867b5db437e9afc2d323c22d830c6f84a3598415eedcaa27e2461f",
|
||||
"EsteriaVorkaiTextures.bin": "837774377ca055e6a5c79c1a4cfd8151e7c1f7ce2c16990b00fd445281137433",
|
||||
"EsteriaVrykul.bin": "39e2b7b4c67997dbbd34bae840bd606a59290f7f2fc82565a0ba00090335415c",
|
||||
"EsteriaVrykulTextures.bin": "46098750a0e235724c6e9cc8d9d4e26550aa47bef95fd5f0f82efe5e945bf296",
|
||||
"EsteriaVulpera.bin": "c5434993b9af4a17d881965e4735cd2ac379e39c7142aac9844adff9528562d4",
|
||||
"EsteriaVulperaTextures.bin": "1ab844e74684aced2b069f1b91cd563aade45e05bd5e23f866a6c0c301cb098e",
|
||||
"Interface/AddOns/CoAHideArmor/CoAHideArmor.lua": "8c1c7403524fc9bd56c0809b4101b141da700ba163701209bf1420f2ef106aa7",
|
||||
"Interface/AddOns/CoAHideArmor/CoAHideArmor.toc": "123580d92fd5ceee258e96296f42c359b7e83cdff151af49c50c6c4e2059677c",
|
||||
"Interface/AddOns/CoAQuestSafe/CoAQuestSafe.lua": "062de55c91228971553f482fd2c8753f4752993b4e8e49d4ded04fa18b98bde7",
|
||||
"Interface/AddOns/CoAQuestSafe/CoAQuestSafe.toc": "890bb9d1087e236f4823603f5df3ab0e316dbb65c28feebbda08fb0ab53a408f",
|
||||
"Interface/AddOns/CoAWC2Cursor/CoAWC2Cursor.lua": "1cf9537ff5f10b77250fea4407aea1008da690afe102ed6ed2dac21f79638cfa",
|
||||
"Interface/AddOns/CoAWC2Cursor/CoAWC2Cursor.toc": "48ce695dce712b3643ebe13a77e318d623c964acc69479b8fc8cc675099801bf",
|
||||
"Interface/AddOns/CoA_TalentReset/CoA_TalentReset.lua": "827d756d5948ef918fafaf8b869290b3a1faa4e4cc21b19b512a00d4509f3d41",
|
||||
"Interface/AddOns/CoA_TalentReset/CoA_TalentReset.toc": "16298c04af68e68d6445e7a11f42aee525dd4145f85d2771ff434fb7c6e95a85",
|
||||
"dinput8.dll": "f8de78606c241fb3911dce22faf68f5b9f9885b142b183c1e2c09ddc8f7e380c",
|
||||
"wc2_human.cur": "f609736e29596bb386ef1597b157d211e01a86d32c2a929e256c581c37d71791",
|
||||
"wc2_orc.cur": "baa512c9b9045762ba35b6e0d35b8f79c54b7649f35cc9c0e0cc8c168a1e5a97"
|
||||
}
|
||||
@@ -144,6 +144,10 @@ fn run_inner_mode(
|
||||
}
|
||||
if matches!(verb, Verb::StartAll | Verb::StartWorld) {
|
||||
crate::modules::ensure_bot_exclusivity(&root)?;
|
||||
// A server update that only added races keeps the owner's race restriction (and custom races on).
|
||||
if let Err(error) = crate::race_availability::rebind_unchanged(&root) {
|
||||
tracing::warn!(%error, "the race restriction could not be checked against the race catalog");
|
||||
}
|
||||
}
|
||||
if crate::docker::is_docker(&root) {
|
||||
prepare_headless_world(&root, verb)?;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
pub mod ops;
|
||||
pub mod relay;
|
||||
pub mod render;
|
||||
pub mod schedule;
|
||||
pub mod services;
|
||||
pub mod settings;
|
||||
pub mod spawn;
|
||||
|
||||
@@ -63,6 +63,21 @@ pub fn run(root: &Path, cfg: &Settings, offset: i32, action: Action, supervisor:
|
||||
if matches!(action, Action::StartAll | Action::StartWorld) {
|
||||
squid::validate_bots(root)?;
|
||||
}
|
||||
let relocated;
|
||||
let cfg = match action {
|
||||
Action::StartAll | Action::StartMysql | Action::StartAuth | Action::StartWorld => {
|
||||
match services::relocate_database_port(root, cfg, offset, progress)? {
|
||||
Some(_) => {
|
||||
let mut moved = Settings::load(root, offset)?;
|
||||
moved.env_remove = cfg.env_remove.clone();
|
||||
relocated = moved;
|
||||
&relocated
|
||||
}
|
||||
None => cfg,
|
||||
}
|
||||
}
|
||||
_ => cfg,
|
||||
};
|
||||
render::prepare(root, cfg)?;
|
||||
if action == Action::Prepare {
|
||||
return Ok(());
|
||||
|
||||
@@ -140,6 +140,7 @@ pub fn prepare(root: &Path, config: &Settings) -> Result<Vec<PathBuf>> {
|
||||
std::fs::write(root.join(target), text.as_bytes())?;
|
||||
written.push(root.join(target));
|
||||
}
|
||||
let custom = custom_mysql_options(root);
|
||||
let files: [(&str, String); 3] = [
|
||||
(
|
||||
"Core/configs/modules/coa_bugreport.conf",
|
||||
@@ -150,7 +151,7 @@ pub fn prepare(root: &Path, config: &Settings) -> Result<Vec<PathBuf>> {
|
||||
(
|
||||
"mysql/my.ini",
|
||||
format!(
|
||||
"[mysqld]\nbasedir=\"{base}/mysql\"\ndatadir=\"{base}/mysql/data\"\nport={mysql_port}\nbind-address=127.0.0.1\nmysqlx=0\ncharacter-set-server=utf8mb4\ncollation-server=utf8mb4_unicode_ci\nmax_allowed_packet=128M\ninnodb_buffer_pool_size=256M\nskip-log-bin\nlog-error=\"{base}/mysql/logs/mysql-error.log\"\npid-file=\"{base}/mysql/mysql.pid\"\n"
|
||||
"[mysqld]\nbasedir=\"{base}/mysql\"\ndatadir=\"{base}/mysql/data\"\nport={mysql_port}\nbind-address=127.0.0.1\nmysqlx=0\ncharacter-set-server=utf8mb4\ncollation-server=utf8mb4_unicode_ci\nmax_allowed_packet=128M\ninnodb_buffer_pool_size=256M\nskip-log-bin\nlog-error=\"{base}/mysql/logs/mysql-error.log\"\npid-file=\"{base}/mysql/mysql.pid\"\n{custom}"
|
||||
),
|
||||
),
|
||||
(
|
||||
@@ -168,6 +169,85 @@ pub fn prepare(root: &Path, config: &Settings) -> Result<Vec<PathBuf>> {
|
||||
Ok(written)
|
||||
}
|
||||
|
||||
/// The owner's file of extra MySQL options; the launcher rewrites `mysql/my.ini` at every start.
|
||||
pub const CUSTOM_MYSQL: &str = "Settings/mysql-custom.ini";
|
||||
|
||||
/// The owner's MySQL options as written, and the lines a start will add to `[mysqld]`.
|
||||
#[derive(Debug, serde::Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CustomMysql {
|
||||
pub text: String,
|
||||
pub applied: String,
|
||||
}
|
||||
|
||||
pub fn read_custom_mysql(root: &Path) -> CustomMysql {
|
||||
let text = std::fs::read(root.join(CUSTOM_MYSQL))
|
||||
.map(|b| String::from_utf8_lossy(&b).into_owned())
|
||||
.unwrap_or_default();
|
||||
CustomMysql { text, applied: custom_mysql_options(root) }
|
||||
}
|
||||
|
||||
/// Save the owner's MySQL options; they apply at the next start of the database.
|
||||
pub fn write_custom_mysql(root: &Path, text: &str) -> Result<CustomMysql> {
|
||||
if text.len() > 16 * 1024 || text.contains(char::from(0)) {
|
||||
return Err(Error::Invalid("The MySQL options must be plain text of at most 16 KB.".into()));
|
||||
}
|
||||
crate::fsx::atomic_write(&root.join(CUSTOM_MYSQL), text.replace("\r\n", "\n").as_bytes())?;
|
||||
Ok(read_custom_mysql(root))
|
||||
}
|
||||
|
||||
/// Options the server cannot run without, which only the launcher sets.
|
||||
const MANAGED_MYSQL_OPTIONS: [&str; 10] = [
|
||||
"basedir",
|
||||
"datadir",
|
||||
"port",
|
||||
"bind-address",
|
||||
"mysqlx",
|
||||
"log-error",
|
||||
"pid-file",
|
||||
"socket",
|
||||
"skip-networking",
|
||||
"defaults-file",
|
||||
];
|
||||
|
||||
/// `name = value` lines of the owner's file (outside any section or in `[mysqld]`), as lines for `[mysqld]`.
|
||||
/// Comments, other sections, `!include` and the options the launcher manages are left out.
|
||||
pub fn custom_mysql_options(root: &Path) -> String {
|
||||
let Ok(bytes) = std::fs::read(root.join(CUSTOM_MYSQL)) else {
|
||||
return String::new();
|
||||
};
|
||||
let text = String::from_utf8_lossy(&bytes);
|
||||
let mut in_mysqld = true;
|
||||
let mut out = String::new();
|
||||
for line in text.trim_start_matches('\u{feff}').lines() {
|
||||
let line = line.trim();
|
||||
if line.is_empty() || line.starts_with('#') || line.starts_with(';') {
|
||||
continue;
|
||||
}
|
||||
if line.starts_with('[') {
|
||||
in_mysqld = line.eq_ignore_ascii_case("[mysqld]");
|
||||
continue;
|
||||
}
|
||||
if !in_mysqld || line.starts_with('!') {
|
||||
continue;
|
||||
}
|
||||
let name = line
|
||||
.split('=')
|
||||
.next()
|
||||
.unwrap_or("")
|
||||
.trim()
|
||||
.to_ascii_lowercase()
|
||||
.replace('_', "-");
|
||||
let name = name.strip_prefix("loose-").unwrap_or(&name);
|
||||
if name.is_empty() || MANAGED_MYSQL_OPTIONS.contains(&name) {
|
||||
continue;
|
||||
}
|
||||
out.push_str(line);
|
||||
out.push('\n');
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
mod sys {
|
||||
use std::os::windows::ffi::OsStrExt;
|
||||
@@ -206,6 +286,22 @@ mod tests {
|
||||
w("Settings/mod_ascension_compat.conf.template", b"Ascension.DbcDir = \"@ASCENSION_DBC@\"\rOld.Mac = 1\r");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_owners_mysql_options_are_kept_except_the_managed_ones() {
|
||||
let d = tempfile::tempdir().unwrap();
|
||||
std::fs::create_dir_all(d.path().join("Settings")).unwrap();
|
||||
std::fs::write(
|
||||
d.path().join(CUSTOM_MYSQL),
|
||||
"\u{feff}# tuning\ninnodb_buffer_pool_size = 2G\nport=3999\nloose_bind_address=0.0.0.0\n!include C:/x.ini\n[client]\nuser=evil\n[mysqld]\nmax_connections=500\nDATADIR=D:/elsewhere\n",
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
custom_mysql_options(d.path()),
|
||||
"innodb_buffer_pool_size = 2G\nmax_connections=500\n"
|
||||
);
|
||||
assert_eq!(custom_mysql_options(&d.path().join("missing")), "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn placeholders_left_outside_comments_are_refused() {
|
||||
let d = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
//! Restarts on a schedule (#202): once a day at the owner's local time, the world supervisor asks the world to
|
||||
//! restart with an in-game countdown, waits for it to exit with AzerothCore's restart code and starts it again.
|
||||
//! The database and the auth server keep running.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Duration;
|
||||
|
||||
use chrono::{Local, NaiveDateTime, NaiveTime, Timelike};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::error::{Error, Result};
|
||||
|
||||
const FILE: &str = "Settings/restart-schedule.json";
|
||||
/// Present while a scheduled restart is under way, so a world that is briefly down is not taken for a crash.
|
||||
const UNDER_WAY: &str = ".state/scheduled-restart";
|
||||
/// The exit code of `server restart` (AzerothCore's `RESTART_EXIT_CODE`).
|
||||
pub const RESTART_EXIT_CODE: i32 = 2;
|
||||
/// A restart missed by more than this (the computer slept, the world started late) waits for the next day.
|
||||
const LATE: Duration = Duration::from_secs(15 * 60);
|
||||
/// A world that has not come back within this time no longer counts as restarting.
|
||||
const UNDER_WAY_LIMIT: Duration = Duration::from_secs(45 * 60);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RestartSchedule {
|
||||
pub enabled: bool,
|
||||
/// Local time, `HH:MM`.
|
||||
pub time: String,
|
||||
/// The in-game countdown before the restart, in minutes (1-60).
|
||||
pub warning_minutes: u32,
|
||||
}
|
||||
|
||||
impl Default for RestartSchedule {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
enabled: false,
|
||||
time: "05:00".into(),
|
||||
warning_minutes: 5,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RestartSchedule {
|
||||
fn at(&self) -> Option<NaiveTime> {
|
||||
NaiveTime::parse_from_str(self.time.trim(), "%H:%M").ok()
|
||||
}
|
||||
|
||||
fn validate(&self) -> Result<()> {
|
||||
if self.at().is_none() {
|
||||
return Err(Error::Invalid("The restart time must be HH:MM, for example 05:00.".into()));
|
||||
}
|
||||
if !(1..=60).contains(&self.warning_minutes) {
|
||||
return Err(Error::Invalid("The restart warning must be 1 to 60 minutes.".into()));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The scheduled moment of `now`'s day, when a restart is due at `now` for a world started at `started`:
|
||||
/// the moment has passed by less than [`LATE`] and the world was already running before it.
|
||||
pub fn due(&self, now: NaiveDateTime, started: NaiveDateTime) -> Option<NaiveDateTime> {
|
||||
if !self.enabled {
|
||||
return None;
|
||||
}
|
||||
let moment = now.date().and_time(self.at()?);
|
||||
let late = now.signed_duration_since(moment).to_std().ok()?;
|
||||
(late <= LATE && started < moment).then_some(moment)
|
||||
}
|
||||
}
|
||||
|
||||
/// The folder whose schedule a world follows: an extra world (`<server>/.realms/<name>`) follows its server's.
|
||||
fn owner(root: &Path) -> PathBuf {
|
||||
if crate::launcher::settings::is_extra_world(root) {
|
||||
if let Some(main) = root.parent().and_then(Path::parent) {
|
||||
return main.to_path_buf();
|
||||
}
|
||||
}
|
||||
root.to_path_buf()
|
||||
}
|
||||
|
||||
pub fn load(root: &Path) -> RestartSchedule {
|
||||
crate::fsx::read_json(&owner(root).join(FILE)).unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn save(root: &Path, schedule: &RestartSchedule) -> Result<RestartSchedule> {
|
||||
let mut schedule = schedule.clone();
|
||||
schedule.time = schedule.time.trim().to_string();
|
||||
if schedule.enabled {
|
||||
schedule.validate()?;
|
||||
} else if schedule.at().is_none() {
|
||||
schedule.time = RestartSchedule::default().time;
|
||||
}
|
||||
crate::fsx::atomic_write_json(&owner(root).join(FILE), &schedule)?;
|
||||
Ok(schedule)
|
||||
}
|
||||
|
||||
pub fn now() -> NaiveDateTime {
|
||||
Local::now().naive_local().with_nanosecond(0).unwrap_or_else(|| Local::now().naive_local())
|
||||
}
|
||||
|
||||
pub fn mark_under_way(root: &Path) -> Result<()> {
|
||||
let path = root.join(UNDER_WAY);
|
||||
if let Some(parent) = path.parent() {
|
||||
std::fs::create_dir_all(parent)?;
|
||||
}
|
||||
std::fs::write(path, b"")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn clear_under_way(root: &Path) {
|
||||
let _ = std::fs::remove_file(root.join(UNDER_WAY));
|
||||
}
|
||||
|
||||
/// A scheduled restart of this world is under way (its world may be down for a few minutes).
|
||||
pub fn under_way(root: &Path) -> bool {
|
||||
std::fs::metadata(root.join(UNDER_WAY))
|
||||
.and_then(|m| m.modified())
|
||||
.is_ok_and(|t| t.elapsed().is_ok_and(|age| age < UNDER_WAY_LIMIT))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn at(text: &str) -> NaiveDateTime {
|
||||
NaiveDateTime::parse_from_str(text, "%Y-%m-%d %H:%M").unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_restart_is_due_once_after_its_time_for_a_world_that_ran_before_it() {
|
||||
let s = RestartSchedule { enabled: true, time: "05:00".into(), warning_minutes: 5 };
|
||||
let started = at("2026-11-14 20:00");
|
||||
assert_eq!(s.due(at("2026-11-15 04:59"), started), None);
|
||||
assert_eq!(s.due(at("2026-11-15 05:00"), started), Some(at("2026-11-15 05:00")));
|
||||
assert_eq!(s.due(at("2026-11-15 05:14"), started), Some(at("2026-11-15 05:00")));
|
||||
assert_eq!(s.due(at("2026-11-15 05:16"), started), None, "missed by too much");
|
||||
// The world that came back at 05:06 is not restarted again that day.
|
||||
assert_eq!(s.due(at("2026-11-15 05:10"), at("2026-11-15 05:06")), None);
|
||||
assert_eq!(s.due(at("2026-11-16 05:01"), at("2026-11-15 05:06")), Some(at("2026-11-16 05:00")));
|
||||
let off = RestartSchedule { enabled: false, ..s };
|
||||
assert_eq!(off.due(at("2026-11-15 05:00"), started), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn schedules_are_validated_and_extra_worlds_follow_their_server() {
|
||||
let d = tempfile::tempdir().unwrap();
|
||||
assert_eq!(load(d.path()), RestartSchedule::default());
|
||||
let bad = RestartSchedule { enabled: true, time: "25:00".into(), warning_minutes: 5 };
|
||||
assert!(save(d.path(), &bad).is_err());
|
||||
let quiet = RestartSchedule { enabled: true, time: "05:00".into(), warning_minutes: 0 };
|
||||
assert!(save(d.path(), &quiet).is_err());
|
||||
let good = RestartSchedule { enabled: true, time: " 04:30 ".into(), warning_minutes: 10 };
|
||||
assert_eq!(save(d.path(), &good).unwrap().time, "04:30");
|
||||
let extra = d.path().join(".realms/secondary");
|
||||
std::fs::create_dir_all(&extra).unwrap();
|
||||
assert!(load(&extra).enabled);
|
||||
assert!(!under_way(d.path()));
|
||||
mark_under_way(d.path()).unwrap();
|
||||
assert!(under_way(d.path()));
|
||||
clear_under_way(d.path());
|
||||
assert!(!under_way(d.path()));
|
||||
}
|
||||
}
|
||||
@@ -35,12 +35,24 @@ pub fn spawn(root: &Path, name: &str, exe: &Path, args: &[&str], cwd: &Path, log
|
||||
// Ports
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Wait (up to 30 s) until `port` can be bound by a new server. A port with a listening owner is refused at
|
||||
/// once; a port Windows still holds for a stopped process (a PID-zero row) is waited for. The test bind is
|
||||
/// exclusive (`SO_EXCLUSIVEADDRUSE`), never a shared one.
|
||||
pub fn ensure_free(port: u16, progress: Progress) -> Result<()> {
|
||||
let deadline = Instant::now() + Duration::from_secs(30);
|
||||
/// What keeps a new server off a port.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum PortBlock {
|
||||
/// Processes listen on it.
|
||||
Owned(Vec<u32>),
|
||||
/// Windows keeps it in an excluded range (Hyper-V, WSL and Docker reserve such ranges); waiting never helps.
|
||||
Reserved(u16, u16),
|
||||
/// Windows still refuses it after the wait (a stopped process' socket, or an owner the table does not show).
|
||||
Unavailable(i32),
|
||||
}
|
||||
|
||||
/// Wait (up to `wait`) until `port` can be bound by a new server. A port with a listening owner or inside a
|
||||
/// Windows excluded range is reported at once; a port Windows still holds for a stopped process (a PID-zero row)
|
||||
/// is waited for. The test bind is exclusive (`SO_EXCLUSIVEADDRUSE`), never a shared one.
|
||||
pub fn port_block(port: u16, wait: Duration, progress: Progress) -> std::result::Result<(), PortBlock> {
|
||||
let deadline = Instant::now() + wait;
|
||||
let mut announced = false;
|
||||
let mut reserved: Option<Vec<(u16, u16)>> = None;
|
||||
loop {
|
||||
let mut owners: Vec<u32> = sys::tcp_rows_v4()
|
||||
.into_iter()
|
||||
@@ -50,19 +62,17 @@ pub fn ensure_free(port: u16, progress: Progress) -> Result<()> {
|
||||
owners.sort_unstable();
|
||||
owners.dedup();
|
||||
if owners.iter().any(|p| *p != 0) {
|
||||
let list: Vec<String> = owners.iter().map(u32::to_string).collect();
|
||||
return Err(Error::Service(
|
||||
ErrorCode::PortInUse,
|
||||
format!("Port {port} is already used (PID {}). Stop the other server or change Settings/repack.json.", list.join(", ")),
|
||||
));
|
||||
return Err(PortBlock::Owned(owners));
|
||||
}
|
||||
match sys::exclusive_bind(port) {
|
||||
Ok(()) => return Ok(()),
|
||||
Err(code) if code == 10013 || code == 10048 => {
|
||||
let ranges = reserved.get_or_insert_with(sys::excluded_ranges);
|
||||
if let Some((start, end)) = ranges.iter().copied().find(|(s, e)| (*s..=*e).contains(&port)) {
|
||||
return Err(PortBlock::Reserved(start, end));
|
||||
}
|
||||
if Instant::now() >= deadline {
|
||||
return Err(Error::Invalid(format!(
|
||||
"Port {port} remains unavailable after 30 seconds (Windows bind error {code}). No process was stopped. Retry after the previous database shutdown has finished, or check the Windows port reservation."
|
||||
)));
|
||||
return Err(PortBlock::Unavailable(code));
|
||||
}
|
||||
if !announced {
|
||||
progress(&format!("Waiting for Windows to release port {port}..."));
|
||||
@@ -70,11 +80,119 @@ pub fn ensure_free(port: u16, progress: Progress) -> Result<()> {
|
||||
}
|
||||
std::thread::sleep(Duration::from_millis(250));
|
||||
}
|
||||
Err(code) => return Err(Error::Invalid(format!("Port {port} cannot be checked (Windows error {code})."))),
|
||||
Err(code) => return Err(PortBlock::Unavailable(code)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn port_error(port: u16, block: PortBlock) -> Error {
|
||||
match block {
|
||||
PortBlock::Owned(owners) => {
|
||||
let list: Vec<String> = owners.iter().map(u32::to_string).collect();
|
||||
Error::Service(
|
||||
ErrorCode::PortInUse,
|
||||
format!("Port {port} is already used (PID {}). Stop the other server or change Settings/repack.json.", list.join(", ")),
|
||||
)
|
||||
}
|
||||
PortBlock::Reserved(start, end) => Error::Service(
|
||||
ErrorCode::PortInUse,
|
||||
format!(
|
||||
"Port {port} is reserved by Windows (excluded range {start}-{end}; Hyper-V, WSL and Docker reserve such ranges). Choose another port in Settings/repack.json, or restart the Windows NAT service as administrator (net stop winnat, then net start winnat)."
|
||||
),
|
||||
),
|
||||
PortBlock::Unavailable(code) if code == 10013 || code == 10048 => Error::Invalid(format!(
|
||||
"Port {port} remains unavailable after 30 seconds (Windows bind error {code}). No process was stopped. Retry after the previous database shutdown has finished, or check the Windows port reservation."
|
||||
)),
|
||||
PortBlock::Unavailable(code) => Error::Invalid(format!("Port {port} cannot be checked (Windows error {code}).")),
|
||||
}
|
||||
}
|
||||
|
||||
/// [`port_block`] with up to 30 s of waiting, as an error a person can act on.
|
||||
pub fn ensure_free(port: u16, progress: Progress) -> Result<()> {
|
||||
port_block(port, Duration::from_secs(30), progress).map_err(|block| port_error(port, block))
|
||||
}
|
||||
|
||||
/// The ports of this server's other services and extra worlds, which the database must not take.
|
||||
fn ports_in_use_by_server(root: &Path, cfg: &Settings) -> Vec<u16> {
|
||||
let mut ports = vec![cfg.auth_port, cfg.world_port, cfg.ra_port];
|
||||
for tree in crate::multiworld::Tree::ALL {
|
||||
let other = crate::multiworld::tree_root(root, tree);
|
||||
if let Ok(other) = Settings::load(&other, 0) {
|
||||
ports.extend([other.world_port, other.ra_port, other.auth_port]);
|
||||
}
|
||||
}
|
||||
ports
|
||||
}
|
||||
|
||||
/// Before the database starts: when its port is reserved by Windows or held by a program that is not this
|
||||
/// server's MySQL, move the database to a free port and record it in `Settings/repack.json`. Only this server's
|
||||
/// own services connect to MySQL (players never do), and every start renders their configs from that file, so
|
||||
/// the move needs nothing else. Returns the new port, or `None` when the configured one is usable.
|
||||
pub fn relocate_database_port(root: &Path, cfg: &Settings, offset: i32, progress: Progress) -> Result<Option<u16>> {
|
||||
if cfg.shared_database || offset != 0 || state::running(root, "mysql").is_some() {
|
||||
return Ok(None);
|
||||
}
|
||||
let block = match port_block(cfg.mysql_port, Duration::from_secs(30), progress) {
|
||||
Ok(()) => return Ok(None),
|
||||
Err(block) => block,
|
||||
};
|
||||
let ours = root.join("mysql/bin/mysqld.exe");
|
||||
if let PortBlock::Owned(owners) = &block {
|
||||
// This server's own database without a record: never start a second one on the same data.
|
||||
let same = |pid: &u32| {
|
||||
crate::process::identity(*pid).is_some_and(|p| same_file(Path::new(&p.exe), &ours))
|
||||
};
|
||||
if owners.iter().any(same) {
|
||||
return Err(port_error(cfg.mysql_port, block));
|
||||
}
|
||||
}
|
||||
let taken = ports_in_use_by_server(root, cfg);
|
||||
let reserved = sys::excluded_ranges();
|
||||
let candidate = (cfg.mysql_port.saturating_add(1)..=cfg.mysql_port.saturating_add(400))
|
||||
.chain(33070..=33470)
|
||||
.filter(|p| *p > 1024)
|
||||
.find(|p| {
|
||||
!taken.contains(p)
|
||||
&& !reserved.iter().any(|(s, e)| (*s..=*e).contains(p))
|
||||
&& port_block(*p, Duration::ZERO, &|_| {}).is_ok()
|
||||
});
|
||||
let Some(port) = candidate else {
|
||||
return Err(port_error(cfg.mysql_port, block));
|
||||
};
|
||||
let reason = match &block {
|
||||
PortBlock::Owned(_) => "used by another program",
|
||||
PortBlock::Reserved(..) => "reserved by Windows",
|
||||
PortBlock::Unavailable(_) => "unavailable",
|
||||
};
|
||||
let path = root.join("Settings/repack.json");
|
||||
let mut raw = cfg.raw.clone();
|
||||
raw.insert("mysqlPort".into(), port.into());
|
||||
crate::fsx::atomic_write_json(&path, &serde_json::Value::Object(raw))?;
|
||||
tracing::warn!(old = cfg.mysql_port, new = port, reason, "database moved to a free port");
|
||||
progress(&format!("Port {} is {reason}; the database now uses port {port}.", cfg.mysql_port));
|
||||
Ok(Some(port))
|
||||
}
|
||||
|
||||
fn same_file(a: &Path, b: &Path) -> bool {
|
||||
match (std::fs::canonicalize(a), std::fs::canonicalize(b)) {
|
||||
(Ok(a), Ok(b)) => a.to_string_lossy().eq_ignore_ascii_case(&b.to_string_lossy()),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// The ranges of `netsh interface ipv4 show excludedportrange protocol=tcp`: every line that starts with two
|
||||
/// port numbers (the headers are translated, the numbers are not).
|
||||
pub(crate) fn parse_excluded_ranges(text: &str) -> Vec<(u16, u16)> {
|
||||
text.lines()
|
||||
.filter_map(|line| {
|
||||
let mut parts = line.split_whitespace();
|
||||
let start = parts.next()?.parse::<u16>().ok()?;
|
||||
let end = parts.next()?.parse::<u16>().ok()?;
|
||||
(start <= end).then_some((start, end))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Is the recorded process of `name` serving `port`? Its listener row is the evidence; when a system does not
|
||||
/// show the owner of a listener, the server side of a fresh loopback connection is (never for MySQL, whose
|
||||
/// listener has always been visible and which should not get stray connections).
|
||||
@@ -217,8 +335,8 @@ pub fn start_mysql(root: &Path, cfg: &Settings, progress: Progress) -> Result<()
|
||||
mysql(
|
||||
root,
|
||||
Some(&format!(
|
||||
"UPDATE acore_auth.realmlist SET name='{}',address='127.0.0.1',localAddress='127.0.0.1',port={} WHERE id={};",
|
||||
cfg.realm.name, cfg.world_port, cfg.realm.id
|
||||
"UPDATE acore_auth.realmlist SET name={},address='127.0.0.1',localAddress='127.0.0.1',port={} WHERE id={};",
|
||||
crate::realm_names::sql_literal(&cfg.realm.name), cfg.world_port, cfg.realm.id
|
||||
)),
|
||||
None,
|
||||
)?;
|
||||
@@ -473,6 +591,29 @@ mod sys {
|
||||
}
|
||||
|
||||
/// Bind 0.0.0.0:port exclusively and release it. Err carries the Windows socket error.
|
||||
/// Windows' excluded TCP port ranges, read with the system's own netsh (never one from PATH or the server).
|
||||
pub fn excluded_ranges() -> Vec<(u16, u16)> {
|
||||
use std::os::windows::process::CommandExt;
|
||||
let mut directory = vec![0u16; 32768];
|
||||
let length = unsafe {
|
||||
windows_sys::Win32::System::SystemInformation::GetSystemDirectoryW(directory.as_mut_ptr(), directory.len() as u32)
|
||||
} as usize;
|
||||
if length == 0 || length >= directory.len() {
|
||||
return Vec::new();
|
||||
}
|
||||
let netsh = std::path::PathBuf::from(String::from_utf16_lossy(&directory[..length])).join("netsh.exe");
|
||||
let output = std::process::Command::new(netsh)
|
||||
.args(["interface", "ipv4", "show", "excludedportrange", "protocol=tcp"])
|
||||
.stdin(std::process::Stdio::null())
|
||||
.stderr(std::process::Stdio::null())
|
||||
.creation_flags(super::CREATE_NO_WINDOW)
|
||||
.output();
|
||||
match output {
|
||||
Ok(out) if out.status.success() => super::parse_excluded_ranges(&String::from_utf8_lossy(&out.stdout)),
|
||||
_ => Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn exclusive_bind(port: u16) -> std::result::Result<(), i32> {
|
||||
use socket2::{Domain, Socket, Type};
|
||||
use std::os::windows::io::AsRawSocket;
|
||||
@@ -527,6 +668,9 @@ mod sys {
|
||||
pub fn exclusive_bind(_: u16) -> std::result::Result<(), i32> {
|
||||
Ok(())
|
||||
}
|
||||
pub fn excluded_ranges() -> Vec<(u16, u16)> {
|
||||
Vec::new()
|
||||
}
|
||||
pub fn terminate(_: &ProcessIdentity) -> Result<()> {
|
||||
Err(Error::Invalid("not supported".into()))
|
||||
}
|
||||
@@ -536,6 +680,57 @@ mod sys {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn excluded_ranges_are_read_from_translated_netsh_output() {
|
||||
let english = "\r\nProtocol tcp Port Exclusion Ranges\r\n\r\nStart Port End Port\r\n---------- --------\r\n 3250 3349\r\n 50000 50059 *\r\n\r\n* - Administered port exclusions.\r\n";
|
||||
assert_eq!(parse_excluded_ranges(english), vec![(3250, 3349), (50000, 50059)]);
|
||||
let russian = "\r\nПротокол tcp Диапазоны исключения портов\r\n\r\nНачальный порт Конечный порт\r\n---------- --------\r\n 50000 50059 *\r\n\r\n* — управляемые исключения портов.\r\n";
|
||||
assert_eq!(parse_excluded_ranges(russian), vec![(50000, 50059)]);
|
||||
assert!(parse_excluded_ranges("").is_empty());
|
||||
}
|
||||
|
||||
fn repack(dir: &Path, mysql: u16) {
|
||||
std::fs::create_dir_all(dir.join("Settings")).unwrap();
|
||||
std::fs::write(
|
||||
dir.join("Settings/repack.json"),
|
||||
format!(r#"{{"mysqlPort":{mysql},"authPort":3724,"worldPort":8085,"raPort":3443,"raUsername":"U","raPassword":"P"}}"#),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_taken_database_port_moves_to_a_free_one_and_is_recorded() {
|
||||
let d = tempfile::tempdir().unwrap();
|
||||
let held = std::net::TcpListener::bind("0.0.0.0:0").unwrap();
|
||||
let port = held.local_addr().unwrap().port();
|
||||
repack(d.path(), port);
|
||||
let cfg = Settings::load(d.path(), 0).unwrap();
|
||||
let said = std::cell::RefCell::new(Vec::new());
|
||||
let moved = relocate_database_port(d.path(), &cfg, 0, &|line| said.borrow_mut().push(line.to_string()))
|
||||
.unwrap()
|
||||
.expect("moved");
|
||||
assert_ne!(moved, port);
|
||||
let again = Settings::load(d.path(), 0).unwrap();
|
||||
assert_eq!(again.mysql_port, moved);
|
||||
assert_eq!((again.auth_port, again.ra_username.as_str()), (3724, "U"), "other keys are kept");
|
||||
assert!(said.borrow().iter().any(|l| l.contains("used by another program")), "{said:?}");
|
||||
// The new port is usable: nothing moves on the next start.
|
||||
assert_eq!(relocate_database_port(d.path(), &again, 0, &|_| {}).unwrap(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extra_worlds_and_shifted_test_ports_never_move_the_database() {
|
||||
let d = tempfile::tempdir().unwrap();
|
||||
let held = std::net::TcpListener::bind("0.0.0.0:0").unwrap();
|
||||
let port = held.local_addr().unwrap().port();
|
||||
repack(d.path(), port);
|
||||
let cfg = Settings::load(d.path(), 0).unwrap();
|
||||
let shared = Settings { shared_database: true, ..cfg.clone() };
|
||||
assert_eq!(relocate_database_port(d.path(), &shared, 0, &|_| {}).unwrap(), None);
|
||||
assert_eq!(relocate_database_port(d.path(), &cfg, 5, &|_| {}).unwrap(), None);
|
||||
assert_eq!(Settings::load(d.path(), 0).unwrap().mysql_port, port);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_port_with_a_listener_is_refused_and_a_free_one_passes() {
|
||||
let held = std::net::TcpListener::bind("0.0.0.0:0").unwrap();
|
||||
@@ -554,9 +749,11 @@ mod tests {
|
||||
assert!(!ready(d.path(), "auth", port), "no record yet");
|
||||
state::record(d.path(), "auth", std::process::id()).unwrap();
|
||||
assert!(ready(d.path(), "auth", port));
|
||||
// A port nobody listens on now (port + 1 may belong to a test running in parallel in this process).
|
||||
let other = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
|
||||
let free = other.local_addr().unwrap().port();
|
||||
drop(other);
|
||||
assert!(!ready(d.path(), "auth", port + 1) || port + 1 == 0);
|
||||
assert!(!ready(d.path(), "auth", free));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -14,7 +14,7 @@ pub const PORT_KEYS: [&str; 4] = ["mysqlPort", "authPort", "worldPort", "raPort"
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Realm {
|
||||
pub id: u32,
|
||||
pub name: &'static str,
|
||||
pub name: String,
|
||||
pub world_db: &'static str,
|
||||
pub characters_db: &'static str,
|
||||
}
|
||||
@@ -22,15 +22,19 @@ pub struct Realm {
|
||||
impl Realm {
|
||||
pub fn load(root: &Path) -> Result<Realm> {
|
||||
let path = root.join("Settings/realm-profile.json");
|
||||
if !path.exists() {
|
||||
return Ok(Realm { id: 1, name: "AzerothCore", world_db: "acore_world", characters_db: "acore_characters" });
|
||||
}
|
||||
let v: serde_json::Value = crate::fsx::read_json(&path)?;
|
||||
Ok(match v.get("active").and_then(|a| a.as_str()).unwrap_or("coa") {
|
||||
"wildcard" => Realm { id: 2, name: "Wildcard", world_db: "acore_world_wildcard", characters_db: "acore_characters_wildcard" },
|
||||
"reborn" => Realm { id: 3, name: "Warcraft Reborn", world_db: "acore_world_reborn", characters_db: "acore_characters_reborn" },
|
||||
_ => Realm { id: 1, name: "Conquest of Azeroth", world_db: "acore_world", characters_db: "acore_characters" },
|
||||
})
|
||||
let (id, name, world_db, characters_db) = if !path.exists() {
|
||||
(1, "AzerothCore", "acore_world", "acore_characters")
|
||||
} else {
|
||||
let v: serde_json::Value = crate::fsx::read_json(&path)?;
|
||||
match v.get("active").and_then(|a| a.as_str()).unwrap_or("coa") {
|
||||
"wildcard" => (2, "Wildcard", "acore_world_wildcard", "acore_characters_wildcard"),
|
||||
"reborn" => (3, "Warcraft Reborn", "acore_world_reborn", "acore_characters_reborn"),
|
||||
_ => (1, "Conquest of Azeroth", "acore_world", "acore_characters"),
|
||||
}
|
||||
};
|
||||
// The owner's own name for this realm, when one was chosen in the Manager.
|
||||
let name = crate::realm_names::name_or(root, id, name);
|
||||
Ok(Realm { id, name, world_db, characters_db })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ use std::time::{Duration, Instant};
|
||||
use crate::error::{Error, ErrorCode, Result};
|
||||
use crate::launcher::services::{self, ensure_free, mysql, spawn, start_mysql, wait_ready, Progress};
|
||||
use crate::launcher::spawn::Proc;
|
||||
use crate::launcher::{settings::Settings, squid, state};
|
||||
use crate::launcher::{schedule, settings::Settings, squid, state};
|
||||
|
||||
fn stop_relay_flag(root: &Path) -> std::path::PathBuf {
|
||||
state::dir(root).join("stop-relay")
|
||||
@@ -169,24 +169,70 @@ fn spawn_relay(root: &Path, launcher: Option<&Path>) -> Result<Proc> {
|
||||
}
|
||||
|
||||
/// The supervisor (`watch-world`): run the world, keep the relay alive while it runs, stop the relay after it.
|
||||
/// `launcher` is the launcher executable that runs the relay (`None`: the Python relay).
|
||||
pub fn watch_world(root: &Path, launcher: Option<&Path>, log: Progress) -> Result<()> {
|
||||
/// `launcher` is the launcher executable that runs the relay (`None`: the Python relay). At the owner's scheduled
|
||||
/// time it asks the world to restart with an in-game countdown and starts it again when it exits for that.
|
||||
pub fn watch_world(root: &Path, launcher: Option<&Path>, offset: i32, log: Progress) -> Result<()> {
|
||||
squid::validate_bots(root)?;
|
||||
let world = spawn_child(root, "world", &root.join("Core/worldserver.exe"), &["-c", "configs/worldserver.conf"], &root.join("Core"), &root.join("Core/Logs/world-console.log"))?;
|
||||
let mut relay: Option<Proc> = None;
|
||||
while world.try_wait().is_none() {
|
||||
let dead = relay.as_ref().is_none_or(|r| r.try_wait().is_some());
|
||||
if dead {
|
||||
match spawn_relay(root, launcher) {
|
||||
Ok(r) => relay = Some(r),
|
||||
Err(e) => {
|
||||
log(&format!("Report relay could not start ({e}); retrying."));
|
||||
std::thread::sleep(Duration::from_secs(5));
|
||||
continue;
|
||||
loop {
|
||||
let world = spawn_child(root, "world", &root.join("Core/worldserver.exe"), &["-c", "configs/worldserver.conf"], &root.join("Core"), &root.join("Core/Logs/world-console.log"))?;
|
||||
let started = schedule::now();
|
||||
let mut requested = false;
|
||||
let mut last_check: Option<Instant> = None;
|
||||
let code = loop {
|
||||
if let Some(code) = world.try_wait() {
|
||||
break code;
|
||||
}
|
||||
let dead = relay.as_ref().is_none_or(|r| r.try_wait().is_some());
|
||||
if dead {
|
||||
match spawn_relay(root, launcher) {
|
||||
Ok(r) => relay = Some(r),
|
||||
Err(e) => {
|
||||
log(&format!("Report relay could not start ({e}); retrying."));
|
||||
std::thread::sleep(Duration::from_secs(5));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if last_check.is_none_or(|t| t.elapsed() >= Duration::from_secs(30)) {
|
||||
last_check = Some(Instant::now());
|
||||
if schedule::under_way(root) && !requested {
|
||||
// The world that a scheduled restart started again is back once it accepts connections.
|
||||
if Settings::load(root, offset).is_ok_and(|cfg| services::ready(root, "world", cfg.world_port)) {
|
||||
schedule::clear_under_way(root);
|
||||
}
|
||||
}
|
||||
if !requested {
|
||||
let plan = schedule::load(root);
|
||||
if plan.due(schedule::now(), started).is_some() {
|
||||
let seconds = plan.warning_minutes * 60;
|
||||
let asked = Settings::load(root, offset).and_then(|cfg| {
|
||||
crate::ra::Ra::connect_to(cfg.ra_port, &cfg.ra_username, &cfg.ra_password)
|
||||
.and_then(|mut ra| ra.run(&format!("server restart {seconds}")))
|
||||
});
|
||||
match asked {
|
||||
Ok(_) => {
|
||||
schedule::mark_under_way(root)?;
|
||||
requested = true;
|
||||
log(&format!("Scheduled restart: the world restarts in {} minutes.", plan.warning_minutes));
|
||||
}
|
||||
Err(e) => log(&format!("Scheduled restart could not be requested ({e}); retrying.")),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
std::thread::sleep(Duration::from_secs(2));
|
||||
};
|
||||
if requested && code == schedule::RESTART_EXIT_CODE as u32 {
|
||||
log("Scheduled restart: starting the world again.");
|
||||
if let Err(e) = squid::validate_bots(root) {
|
||||
schedule::clear_under_way(root);
|
||||
return Err(e);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
std::thread::sleep(Duration::from_secs(2));
|
||||
schedule::clear_under_way(root);
|
||||
break;
|
||||
}
|
||||
std::fs::write(stop_relay_flag(root), b"")?;
|
||||
if let Some(r) = relay {
|
||||
|
||||
@@ -66,6 +66,7 @@ pub mod ra;
|
||||
pub mod race_availability;
|
||||
pub mod realm_registry;
|
||||
pub mod realmlist;
|
||||
pub mod realm_names;
|
||||
pub mod realms;
|
||||
pub mod rebuild;
|
||||
pub mod registry;
|
||||
|
||||
@@ -269,9 +269,95 @@ pub fn save(
|
||||
),
|
||||
]),
|
||||
)?;
|
||||
write_snapshot(root, ¤t.catalog_sha256, ¤t.races)?;
|
||||
status(root)
|
||||
}
|
||||
|
||||
/// Every race catalog (`ChrRaces.dbc` of the custom races overlay) a server build has shipped, by SHA-256:
|
||||
/// RaceID -> name. Generated from the core repository's history of the overlay.
|
||||
const SHIPPED_CATALOGS: &str = include_str!("race_catalogs.json");
|
||||
/// The names of the catalog a restriction was saved against, written by every save.
|
||||
const SNAPSHOT: &str = "Settings/race-catalog.json";
|
||||
|
||||
#[derive(serde::Deserialize, Serialize)]
|
||||
struct Snapshot {
|
||||
sha256: String,
|
||||
races: BTreeMap<u32, String>,
|
||||
}
|
||||
|
||||
/// RaceID -> name of the catalog with `hash`: this server's own snapshot, or a catalog a build shipped.
|
||||
fn names_of(root: &Path, hash: &str) -> Option<BTreeMap<u32, String>> {
|
||||
if let Ok(snapshot) = crate::fsx::read_json::<Snapshot>(&root.join(SNAPSHOT)) {
|
||||
if snapshot.sha256.eq_ignore_ascii_case(hash) {
|
||||
return Some(snapshot.races);
|
||||
}
|
||||
}
|
||||
#[derive(serde::Deserialize)]
|
||||
struct Shipped {
|
||||
catalogs: BTreeMap<String, BTreeMap<u32, String>>,
|
||||
}
|
||||
let shipped: Shipped = serde_json::from_str(SHIPPED_CATALOGS).ok()?;
|
||||
shipped.catalogs.get(&hash.to_ascii_lowercase()).cloned()
|
||||
}
|
||||
|
||||
fn write_snapshot(root: &Path, hash: &str, races: &[Race]) -> Result<()> {
|
||||
crate::fsx::atomic_write_json(
|
||||
&root.join(SNAPSHOT),
|
||||
&Snapshot {
|
||||
sha256: hash.to_string(),
|
||||
races: races.iter().map(|race| (race.id, race.name.clone())).collect(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/// A server update that only adds races keeps the owner's restriction. The worldserver ignores a restriction
|
||||
/// saved against another catalog (and with it the whole custom races switch), so before a start: when every
|
||||
/// disabled race still has its RaceID and name in the new catalog, the restriction is bound to the new catalog.
|
||||
/// Anything else (an unknown old catalog, a renamed or missing race) is left for the owner to review. Returns
|
||||
/// whether the restriction was bound again.
|
||||
pub fn rebind_unchanged(root: &Path) -> Result<bool> {
|
||||
let conf_path = root.join(CONF);
|
||||
let Ok(conf_bytes) = fs::read(&conf_path) else {
|
||||
return Ok(false);
|
||||
};
|
||||
let mut conf = ConfFile::parse_bytes(&conf_bytes)?;
|
||||
let configured = parse_ids(conf.get(KEY).unwrap_or(""))?;
|
||||
let saved = conf
|
||||
.get(CATALOG_KEY)
|
||||
.unwrap_or("")
|
||||
.trim()
|
||||
.trim_matches('"')
|
||||
.to_ascii_lowercase();
|
||||
if configured.is_empty() || saved.is_empty() {
|
||||
return Ok(false);
|
||||
}
|
||||
let Ok(bytes) = fs::read(dbc_path(root)?) else {
|
||||
return Ok(false);
|
||||
};
|
||||
let current = hex::encode(Sha256::digest(&bytes));
|
||||
if saved == current {
|
||||
return Ok(false);
|
||||
}
|
||||
let races = catalog(&bytes)?;
|
||||
let Some(before) = names_of(root, &saved) else {
|
||||
tracing::warn!("race restriction saved against an unknown catalog; it needs the owner's review");
|
||||
return Ok(false);
|
||||
};
|
||||
let now: BTreeMap<u32, &str> = races.iter().map(|race| (race.id, race.name.as_str())).collect();
|
||||
let unchanged = configured
|
||||
.iter()
|
||||
.all(|id| before.get(id).is_some_and(|name| now.get(id) == Some(&name.as_str())));
|
||||
if !unchanged {
|
||||
tracing::warn!("a restricted race changed in the new catalog; the restriction needs the owner's review");
|
||||
return Ok(false);
|
||||
}
|
||||
conf.set(CATALOG_KEY, &format!("\"{current}\""), &[]);
|
||||
crate::fsx::atomic_write(&conf_path, conf.to_text().as_bytes())?;
|
||||
write_snapshot(root, ¤t, &races)?;
|
||||
tracing::info!(races = configured.len(), "race restriction kept for the updated race catalog");
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -292,6 +378,91 @@ mod tests {
|
||||
bytes
|
||||
}
|
||||
|
||||
fn catalog_of(rows: &[(u32, &str)]) -> Vec<u8> {
|
||||
let mut strings = vec![0u8];
|
||||
let mut offsets = Vec::new();
|
||||
for (_, name) in rows {
|
||||
offsets.push(strings.len() as u32);
|
||||
strings.extend(name.as_bytes());
|
||||
strings.push(0);
|
||||
}
|
||||
let mut bytes = b"WDBC".to_vec();
|
||||
for value in [rows.len() as u32, 69, 276, strings.len() as u32] {
|
||||
bytes.extend(value.to_le_bytes());
|
||||
}
|
||||
for ((id, _), offset) in rows.iter().zip(offsets) {
|
||||
let mut row = vec![0; 276];
|
||||
row[..4].copy_from_slice(&id.to_le_bytes());
|
||||
row[56..60].copy_from_slice(&offset.to_le_bytes());
|
||||
bytes.extend(row);
|
||||
}
|
||||
bytes.extend(strings);
|
||||
bytes
|
||||
}
|
||||
|
||||
fn restricted_server(catalog: &[u8], disabled: &str, saved_hash: &str) -> tempfile::TempDir {
|
||||
let d = tempfile::tempdir().unwrap();
|
||||
fs::create_dir_all(d.path().join("Data/dbc_races")).unwrap();
|
||||
fs::create_dir_all(d.path().join("Core/configs/modules")).unwrap();
|
||||
fs::write(d.path().join("Data/dbc_races/ChrRaces.dbc"), catalog).unwrap();
|
||||
fs::write(
|
||||
d.path().join(CONF),
|
||||
format!("CoACustomRaces.Enable = 1\nCoACustomRaces.DisabledRaceIds = \"{disabled}\"\nCoACustomRaces.DisabledRaceCatalogSha256 = \"{saved_hash}\"\n"),
|
||||
)
|
||||
.unwrap();
|
||||
d
|
||||
}
|
||||
|
||||
fn sha(bytes: &[u8]) -> String {
|
||||
hex::encode(Sha256::digest(bytes))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_catalog_that_only_adds_races_keeps_the_restriction() {
|
||||
let old = catalog_of(&[(83, "Vulpera"), (97, "Gnoll")]);
|
||||
let new = catalog_of(&[(83, "Vulpera"), (97, "Gnoll"), (120, "Nerubian")]);
|
||||
let d = restricted_server(&new, "83", &sha(&old));
|
||||
write_snapshot(d.path(), &sha(&old), &catalog(&old).unwrap()).unwrap();
|
||||
assert!(rebind_unchanged(d.path()).unwrap());
|
||||
let conf = ConfFile::parse_bytes(&fs::read(d.path().join(CONF)).unwrap()).unwrap();
|
||||
assert_eq!(conf.get(KEY), Some("\"83\""));
|
||||
assert_eq!(
|
||||
conf.get(CATALOG_KEY).map(|h| h.trim_matches('"').to_string()),
|
||||
Some(sha(&new))
|
||||
);
|
||||
assert_eq!(conf.get("CoACustomRaces.Enable"), Some("1"));
|
||||
assert!(!rebind_unchanged(d.path()).unwrap(), "already bound");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_renamed_race_or_unknown_catalog_waits_for_review() {
|
||||
let old = catalog_of(&[(83, "Thin Human"), (97, "Gnoll")]);
|
||||
let renamed = catalog_of(&[(83, "Forgotten"), (97, "Gnoll")]);
|
||||
let d = restricted_server(&renamed, "83", &sha(&old));
|
||||
write_snapshot(d.path(), &sha(&old), &catalog(&old).unwrap()).unwrap();
|
||||
assert!(!rebind_unchanged(d.path()).unwrap());
|
||||
let unknown = restricted_server(&renamed, "97", &"ab".repeat(32));
|
||||
assert!(!rebind_unchanged(unknown.path()).unwrap());
|
||||
// Nothing is restricted: nothing to bind.
|
||||
let empty = restricted_server(&renamed, "", &sha(&old));
|
||||
assert!(!rebind_unchanged(empty.path()).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_shipped_catalogs_include_1_9_2_and_v2_with_stable_ids() {
|
||||
let shipped: serde_json::Value = serde_json::from_str(SHIPPED_CATALOGS).unwrap();
|
||||
let catalogs = shipped["catalogs"].as_object().unwrap();
|
||||
let size = |c: &serde_json::Value| c.as_object().unwrap().len();
|
||||
assert!(catalogs.values().any(|c| size(c) == 95), "1.9.2 has 95 races");
|
||||
let v2: Vec<_> = catalogs.values().filter(|c| size(c) == 112).collect();
|
||||
assert_eq!(v2.len(), 1, "V2 has 112 races");
|
||||
for old in catalogs.values().filter(|c| size(c) == 95) {
|
||||
for (id, name) in old.as_object().unwrap() {
|
||||
assert_eq!(&v2[0][id], name, "race {id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn catalog_preserves_ids_and_excludes_stock_and_nonplayable() {
|
||||
let mut bytes = dbc();
|
||||
|
||||
@@ -0,0 +1,639 @@
|
||||
{
|
||||
"catalogs": {
|
||||
"0f9e05112d56609a87f0b1900be88f8130a8fcb24ee4acae585f1fd8d9144bf0": {
|
||||
"1": "Human",
|
||||
"10": "Blood Elf",
|
||||
"100": "Drakonid",
|
||||
"103": "Grummle",
|
||||
"11": "Draenei",
|
||||
"12": "Zandalari Troll",
|
||||
"13": "Worgen",
|
||||
"14": "High Elf",
|
||||
"15": "Tuskarr",
|
||||
"16": "Kul Tiran",
|
||||
"17": "Taunka",
|
||||
"18": "Vrykul",
|
||||
"19": "Vulpera",
|
||||
"2": "Orc",
|
||||
"20": "Pandaren",
|
||||
"21": "Naga",
|
||||
"22": "Broken",
|
||||
"23": "Fel Orc",
|
||||
"24": "Forest Troll",
|
||||
"25": "Ice Troll",
|
||||
"26": "Skeleton",
|
||||
"27": "Earthen",
|
||||
"28": "Drakkari Troll",
|
||||
"29": "Pandaren",
|
||||
"3": "Dwarf",
|
||||
"30": "Murloc",
|
||||
"31": "Murloc",
|
||||
"32": "Thin Human",
|
||||
"33": "Thin Human",
|
||||
"34": "Fel Orc",
|
||||
"35": "Naga",
|
||||
"36": "Broken",
|
||||
"37": "Skeleton",
|
||||
"38": "Vrykul",
|
||||
"39": "Tuskarr",
|
||||
"4": "Night Elf",
|
||||
"40": "Forest Troll",
|
||||
"41": "Taunka",
|
||||
"42": "Northrend Skeleton",
|
||||
"43": "Ice Troll",
|
||||
"44": "Drakkari Troll",
|
||||
"45": "Leper Troll",
|
||||
"46": "Troglodyte",
|
||||
"47": "Alpha Worgen",
|
||||
"48": "Dark Iron Dwarf",
|
||||
"49": "Mag'har Orc",
|
||||
"5": "Undead",
|
||||
"50": "Furbolg",
|
||||
"51": "Undead Gnome",
|
||||
"52": "Orc",
|
||||
"53": "Ogre",
|
||||
"54": "Dracthyr",
|
||||
"55": "Eredar",
|
||||
"56": "Harpy",
|
||||
"57": "Alpha Goblin",
|
||||
"58": "Dracthyr",
|
||||
"59": "Void Elf",
|
||||
"6": "Tauren",
|
||||
"60": "Illidari Blood Elf",
|
||||
"61": "Illidari Night Elf",
|
||||
"62": "Lightforged Draenei",
|
||||
"63": "Nightborne",
|
||||
"65": "Test Race",
|
||||
"66": "Highmountain Tauren",
|
||||
"67": "Mechagnome",
|
||||
"68": "Earthen",
|
||||
"69": "Earthen",
|
||||
"7": "Gnome",
|
||||
"70": "Haranir",
|
||||
"71": "Haranir",
|
||||
"72": "Windshaper Skyborne",
|
||||
"74": "Vulpera",
|
||||
"77": "High Order Skyborne",
|
||||
"78": "Jinyu",
|
||||
"79": "Arakkoa",
|
||||
"8": "Troll",
|
||||
"80": "Darkfallen",
|
||||
"81": "Darkfallen",
|
||||
"82": "Sethrak",
|
||||
"83": "Gnoll",
|
||||
"9": "Goblin",
|
||||
"97": "Saberon",
|
||||
"98": "Drakonid",
|
||||
"99": "Drakkin"
|
||||
},
|
||||
"358503359af5b05d16a76f61bab77b5c6221c792bcb0e11793eba8e279689ff7": {
|
||||
"1": "Human",
|
||||
"10": "Blood Elf",
|
||||
"11": "Draenei",
|
||||
"12": "Zandalari Troll",
|
||||
"13": "Worgen",
|
||||
"14": "High Elf",
|
||||
"15": "Tuskarr",
|
||||
"16": "Kul Tiran",
|
||||
"17": "Taunka",
|
||||
"18": "Vrykul",
|
||||
"19": "Vulpera",
|
||||
"2": "Orc",
|
||||
"20": "Pandaren",
|
||||
"21": "Naga",
|
||||
"22": "Broken",
|
||||
"23": "Fel Orc",
|
||||
"24": "Forest Troll",
|
||||
"25": "Ice Troll",
|
||||
"26": "Skeleton",
|
||||
"27": "Earthen",
|
||||
"28": "Drakkari Troll",
|
||||
"29": "Pandaren",
|
||||
"3": "Dwarf",
|
||||
"30": "Murloc",
|
||||
"31": "Murloc",
|
||||
"32": "Thin Human",
|
||||
"33": "Thin Human",
|
||||
"34": "Fel Orc",
|
||||
"35": "Naga",
|
||||
"36": "Broken",
|
||||
"37": "Skeleton",
|
||||
"38": "Vrykul",
|
||||
"39": "Tuskarr",
|
||||
"4": "Night Elf",
|
||||
"40": "Forest Troll",
|
||||
"41": "Taunka",
|
||||
"42": "Northrend Skeleton",
|
||||
"43": "Ice Troll",
|
||||
"44": "Drakkari Troll",
|
||||
"45": "Leper Troll",
|
||||
"46": "Troglodyte",
|
||||
"47": "Alpha Worgen",
|
||||
"48": "Dark Iron Dwarf",
|
||||
"49": "Mag'har Orc",
|
||||
"5": "Undead",
|
||||
"50": "Furbolg",
|
||||
"51": "Undead Gnome",
|
||||
"52": "Orc",
|
||||
"53": "Ogre",
|
||||
"54": "Dracthyr",
|
||||
"55": "Eredar",
|
||||
"56": "Harpy",
|
||||
"57": "Alpha Goblin",
|
||||
"58": "Dracthyr",
|
||||
"59": "Void Elf",
|
||||
"6": "Tauren",
|
||||
"60": "Illidari Blood Elf",
|
||||
"61": "Illidari Night Elf",
|
||||
"62": "Lightforged Draenei",
|
||||
"63": "Nightborne",
|
||||
"65": "Test Race",
|
||||
"66": "Highmountain Tauren",
|
||||
"67": "Mechagnome",
|
||||
"68": "Earthen",
|
||||
"69": "Earthen",
|
||||
"7": "Gnome",
|
||||
"70": "Haranir",
|
||||
"71": "Haranir",
|
||||
"72": "Windshaper Skyborne",
|
||||
"74": "Vulpera",
|
||||
"77": "High Order Skyborne",
|
||||
"78": "Jinyu",
|
||||
"8": "Troll",
|
||||
"80": "Darkfallen",
|
||||
"81": "Darkfallen",
|
||||
"82": "Sethrak",
|
||||
"83": "Gnoll",
|
||||
"9": "Goblin",
|
||||
"97": "Saberon"
|
||||
},
|
||||
"6ad3ac1ad6ef7f32ed347e979cd1667bb5393d7a0967a859e5ba3cfa2a5d04c7": {
|
||||
"1": "Human",
|
||||
"10": "Blood Elf",
|
||||
"100": "Drakonid",
|
||||
"101": "Venthyr",
|
||||
"102": "Centaur",
|
||||
"103": "Grummle",
|
||||
"104": "Slime Giant",
|
||||
"106": "Mantid",
|
||||
"107": "Kyrian",
|
||||
"109": "Ethereal",
|
||||
"11": "Draenei",
|
||||
"110": "Sylvari",
|
||||
"112": "Hozen",
|
||||
"12": "Zandalari Troll",
|
||||
"13": "Worgen",
|
||||
"14": "High Elf",
|
||||
"15": "Tuskarr",
|
||||
"16": "Kul Tiran",
|
||||
"17": "Taunka",
|
||||
"18": "Vrykul",
|
||||
"19": "Vulpera",
|
||||
"2": "Orc",
|
||||
"20": "Pandaren",
|
||||
"21": "Naga",
|
||||
"22": "Broken",
|
||||
"23": "Fel Orc",
|
||||
"24": "Forest Troll",
|
||||
"25": "Ice Troll",
|
||||
"26": "Skeleton",
|
||||
"27": "Earthen",
|
||||
"28": "Drakkari Troll",
|
||||
"29": "Pandaren",
|
||||
"3": "Dwarf",
|
||||
"30": "Murloc",
|
||||
"31": "Murloc",
|
||||
"32": "Forgotten",
|
||||
"33": "Forgotten",
|
||||
"34": "Fel Orc",
|
||||
"35": "Naga",
|
||||
"36": "Broken",
|
||||
"37": "Skeleton",
|
||||
"38": "Vrykul",
|
||||
"39": "Tuskarr",
|
||||
"4": "Night Elf",
|
||||
"40": "Forest Troll",
|
||||
"41": "Taunka",
|
||||
"42": "Northrend Skeleton",
|
||||
"43": "Ice Troll",
|
||||
"44": "Drakkari Troll",
|
||||
"45": "Leper Troll",
|
||||
"46": "Troglodyte",
|
||||
"47": "Alpha Worgen",
|
||||
"48": "Dark Iron Dwarf",
|
||||
"49": "Mag'har Orc",
|
||||
"5": "Undead",
|
||||
"50": "Furbolg",
|
||||
"51": "Undead Gnome",
|
||||
"52": "Orc",
|
||||
"53": "Ogre",
|
||||
"54": "Dracthyr",
|
||||
"55": "Eredar",
|
||||
"56": "Harpy",
|
||||
"57": "Alpha Goblin",
|
||||
"58": "Dracthyr",
|
||||
"59": "Void Elf",
|
||||
"6": "Tauren",
|
||||
"60": "Illidari Blood Elf",
|
||||
"61": "Illidari Night Elf",
|
||||
"62": "Lightforged Draenei",
|
||||
"63": "Nightborne",
|
||||
"65": "Test Race",
|
||||
"66": "Highmountain Tauren",
|
||||
"67": "Mechagnome",
|
||||
"68": "Earthen",
|
||||
"69": "Earthen",
|
||||
"7": "Gnome",
|
||||
"70": "Haranir",
|
||||
"71": "Haranir",
|
||||
"72": "Windshaper Skyborne",
|
||||
"74": "Vulpera",
|
||||
"75": "Centaur",
|
||||
"77": "High Order Skyborne",
|
||||
"78": "Jinyu",
|
||||
"79": "Arakkoa",
|
||||
"8": "Troll",
|
||||
"80": "Darkfallen",
|
||||
"81": "Darkfallen",
|
||||
"82": "Sethrak",
|
||||
"83": "Gnoll",
|
||||
"87": "Faceless One",
|
||||
"9": "Goblin",
|
||||
"90": "Banshee",
|
||||
"97": "Saberon",
|
||||
"98": "Drakonid",
|
||||
"99": "Drakkin"
|
||||
},
|
||||
"833e18c0f0550d400e78ee5db00bd65bf86d051861fe6b795c0539e3fd9f125d": {
|
||||
"1": "Human",
|
||||
"10": "Blood Elf",
|
||||
"11": "Draenei",
|
||||
"12": "Zandalari Troll",
|
||||
"13": "Worgen",
|
||||
"14": "High Elf",
|
||||
"15": "Tuskarr",
|
||||
"16": "Kul Tiran",
|
||||
"17": "Taunka",
|
||||
"18": "Vrykul",
|
||||
"19": "Vulpera",
|
||||
"2": "Orc",
|
||||
"20": "Pandaren",
|
||||
"21": "Naga",
|
||||
"22": "Broken",
|
||||
"23": "Fel Orc",
|
||||
"24": "Forest Troll",
|
||||
"25": "Ice Troll",
|
||||
"26": "Skeleton",
|
||||
"27": "Earthen",
|
||||
"28": "Drakkari Troll",
|
||||
"29": "Pandaren",
|
||||
"3": "Dwarf",
|
||||
"30": "Murloc",
|
||||
"31": "Murloc",
|
||||
"32": "Thin Human",
|
||||
"33": "Thin Human",
|
||||
"34": "Fel Orc",
|
||||
"35": "Naga",
|
||||
"36": "Broken",
|
||||
"37": "Skeleton",
|
||||
"38": "Vrykul",
|
||||
"39": "Tuskarr",
|
||||
"4": "Night Elf",
|
||||
"40": "Forest Troll",
|
||||
"41": "Taunka",
|
||||
"42": "Northrend Skeleton",
|
||||
"43": "Ice Troll",
|
||||
"44": "Drakkari Troll",
|
||||
"45": "Leper Troll",
|
||||
"46": "Troglodyte",
|
||||
"47": "Alpha Worgen",
|
||||
"48": "Dark Iron Dwarf",
|
||||
"49": "Mag'har Orc",
|
||||
"5": "Undead",
|
||||
"50": "Furbolg",
|
||||
"51": "Undead Gnome",
|
||||
"52": "Orc",
|
||||
"53": "Ogre",
|
||||
"54": "Dracthyr",
|
||||
"55": "Eredar",
|
||||
"56": "Harpy",
|
||||
"57": "Alpha Goblin",
|
||||
"58": "Dracthyr",
|
||||
"59": "Void Elf",
|
||||
"6": "Tauren",
|
||||
"60": "Illidari Blood Elf",
|
||||
"61": "Illidari Night Elf",
|
||||
"62": "Lightforged Draenei",
|
||||
"63": "Nightborne",
|
||||
"65": "Test Race",
|
||||
"66": "Highmountain Tauren",
|
||||
"67": "Mechagnome",
|
||||
"68": "Earthen",
|
||||
"69": "Earthen",
|
||||
"7": "Gnome",
|
||||
"70": "Haranir",
|
||||
"71": "Haranir",
|
||||
"72": "Windshaper Skyborne",
|
||||
"74": "Vulpera",
|
||||
"77": "High Order Skyborne",
|
||||
"8": "Troll",
|
||||
"9": "Goblin"
|
||||
},
|
||||
"9a49163b9a330d844f0add5a2023f538b828bd5c57d6ecbb3cd5b4196930c5da": {
|
||||
"1": "Human",
|
||||
"10": "Blood Elf",
|
||||
"103": "Grummle",
|
||||
"11": "Draenei",
|
||||
"12": "Zandalari Troll",
|
||||
"13": "Worgen",
|
||||
"14": "High Elf",
|
||||
"15": "Tuskarr",
|
||||
"16": "Kul Tiran",
|
||||
"17": "Taunka",
|
||||
"18": "Vrykul",
|
||||
"19": "Vulpera",
|
||||
"2": "Orc",
|
||||
"20": "Pandaren",
|
||||
"21": "Naga",
|
||||
"22": "Broken",
|
||||
"23": "Fel Orc",
|
||||
"24": "Forest Troll",
|
||||
"25": "Ice Troll",
|
||||
"26": "Skeleton",
|
||||
"27": "Earthen",
|
||||
"28": "Drakkari Troll",
|
||||
"29": "Pandaren",
|
||||
"3": "Dwarf",
|
||||
"30": "Murloc",
|
||||
"31": "Murloc",
|
||||
"32": "Thin Human",
|
||||
"33": "Thin Human",
|
||||
"34": "Fel Orc",
|
||||
"35": "Naga",
|
||||
"36": "Broken",
|
||||
"37": "Skeleton",
|
||||
"38": "Vrykul",
|
||||
"39": "Tuskarr",
|
||||
"4": "Night Elf",
|
||||
"40": "Forest Troll",
|
||||
"41": "Taunka",
|
||||
"42": "Northrend Skeleton",
|
||||
"43": "Ice Troll",
|
||||
"44": "Drakkari Troll",
|
||||
"45": "Leper Troll",
|
||||
"46": "Troglodyte",
|
||||
"47": "Alpha Worgen",
|
||||
"48": "Dark Iron Dwarf",
|
||||
"49": "Mag'har Orc",
|
||||
"5": "Undead",
|
||||
"50": "Furbolg",
|
||||
"51": "Undead Gnome",
|
||||
"52": "Orc",
|
||||
"53": "Ogre",
|
||||
"54": "Dracthyr",
|
||||
"55": "Eredar",
|
||||
"56": "Harpy",
|
||||
"57": "Alpha Goblin",
|
||||
"58": "Dracthyr",
|
||||
"59": "Void Elf",
|
||||
"6": "Tauren",
|
||||
"60": "Illidari Blood Elf",
|
||||
"61": "Illidari Night Elf",
|
||||
"62": "Lightforged Draenei",
|
||||
"63": "Nightborne",
|
||||
"65": "Test Race",
|
||||
"66": "Highmountain Tauren",
|
||||
"67": "Mechagnome",
|
||||
"68": "Earthen",
|
||||
"69": "Earthen",
|
||||
"7": "Gnome",
|
||||
"70": "Haranir",
|
||||
"71": "Haranir",
|
||||
"72": "Windshaper Skyborne",
|
||||
"74": "Vulpera",
|
||||
"77": "High Order Skyborne",
|
||||
"78": "Jinyu",
|
||||
"79": "Arakkoa",
|
||||
"8": "Troll",
|
||||
"80": "Darkfallen",
|
||||
"81": "Darkfallen",
|
||||
"82": "Sethrak",
|
||||
"83": "Gnoll",
|
||||
"9": "Goblin",
|
||||
"97": "Saberon"
|
||||
},
|
||||
"b78635b08bf0bd63d2898fce97c1fb162c8a9c41632703172eefa88bae79061f": {
|
||||
"1": "Human",
|
||||
"10": "Blood Elf",
|
||||
"100": "Drakonid",
|
||||
"101": "Venthyr",
|
||||
"102": "Centaur",
|
||||
"103": "Grummle",
|
||||
"104": "Slime Giant",
|
||||
"106": "Mantid",
|
||||
"107": "Kyrian",
|
||||
"109": "Ethereal",
|
||||
"11": "Draenei",
|
||||
"110": "Sylvari",
|
||||
"112": "Hozen",
|
||||
"12": "Zandalari Troll",
|
||||
"13": "Worgen",
|
||||
"14": "High Elf",
|
||||
"15": "Tuskarr",
|
||||
"16": "Kul Tiran",
|
||||
"17": "Taunka",
|
||||
"18": "Vrykul",
|
||||
"19": "Vulpera",
|
||||
"2": "Orc",
|
||||
"20": "Pandaren",
|
||||
"21": "Naga",
|
||||
"22": "Broken",
|
||||
"23": "Fel Orc",
|
||||
"24": "Forest Troll",
|
||||
"25": "Ice Troll",
|
||||
"26": "Skeleton",
|
||||
"27": "Earthen",
|
||||
"28": "Drakkari Troll",
|
||||
"29": "Pandaren",
|
||||
"3": "Dwarf",
|
||||
"30": "Murloc",
|
||||
"31": "Murloc",
|
||||
"32": "Forgotten",
|
||||
"33": "Forgotten",
|
||||
"34": "Fel Orc",
|
||||
"35": "Naga",
|
||||
"36": "Broken",
|
||||
"37": "Skeleton",
|
||||
"38": "Vrykul",
|
||||
"39": "Tuskarr",
|
||||
"4": "Night Elf",
|
||||
"40": "Forest Troll",
|
||||
"41": "Taunka",
|
||||
"42": "Northrend Skeleton",
|
||||
"43": "Ice Troll",
|
||||
"44": "Drakkari Troll",
|
||||
"45": "Leper Troll",
|
||||
"46": "Troglodyte",
|
||||
"47": "Alpha Worgen",
|
||||
"48": "Dark Iron Dwarf",
|
||||
"49": "Mag'har Orc",
|
||||
"5": "Undead",
|
||||
"50": "Furbolg",
|
||||
"51": "Undead Gnome",
|
||||
"52": "Orc",
|
||||
"53": "Ogre",
|
||||
"54": "Dracthyr",
|
||||
"55": "Eredar",
|
||||
"56": "Harpy",
|
||||
"57": "Alpha Goblin",
|
||||
"58": "Dracthyr",
|
||||
"59": "Void Elf",
|
||||
"6": "Tauren",
|
||||
"60": "Illidari Blood Elf",
|
||||
"61": "Illidari Night Elf",
|
||||
"62": "Lightforged Draenei",
|
||||
"63": "Nightborne",
|
||||
"65": "Test Race",
|
||||
"66": "Highmountain Tauren",
|
||||
"67": "Mechagnome",
|
||||
"68": "Earthen",
|
||||
"69": "Earthen",
|
||||
"7": "Gnome",
|
||||
"70": "Haranir",
|
||||
"71": "Haranir",
|
||||
"72": "Windshaper Skyborne",
|
||||
"74": "Vulpera",
|
||||
"75": "Centaur",
|
||||
"77": "High Order Skyborne",
|
||||
"78": "Jinyu",
|
||||
"79": "Arakkoa",
|
||||
"8": "Troll",
|
||||
"80": "Darkfallen",
|
||||
"81": "Darkfallen",
|
||||
"82": "Sethrak",
|
||||
"83": "Gnoll",
|
||||
"87": "Faceless One",
|
||||
"9": "Goblin",
|
||||
"90": "Banshee",
|
||||
"97": "Saberon",
|
||||
"98": "Drakonid",
|
||||
"99": "Drakkin"
|
||||
},
|
||||
"bff09e612ba44567a5c7d928562d6261755504dc8948daa334e675bf49b54938": {
|
||||
"1": "Human",
|
||||
"10": "Blood Elf",
|
||||
"100": "Drakonid",
|
||||
"101": "Venthyr",
|
||||
"102": "Centaur",
|
||||
"103": "Grummle",
|
||||
"104": "Slime Giant",
|
||||
"105": "Gilgoblin",
|
||||
"106": "Mantid",
|
||||
"107": "Kyrian",
|
||||
"109": "Ethereal",
|
||||
"11": "Draenei",
|
||||
"110": "Sylvari",
|
||||
"111": "Sporeling",
|
||||
"112": "Hozen",
|
||||
"114": "Stormforged",
|
||||
"118": "Elune's Chosen",
|
||||
"119": "Mo'arg",
|
||||
"12": "Zandalari Troll",
|
||||
"120": "Nerubian",
|
||||
"122": "Lich",
|
||||
"123": "Mogu",
|
||||
"125": "Lost One",
|
||||
"13": "Worgen",
|
||||
"14": "High Elf",
|
||||
"15": "Tuskarr",
|
||||
"16": "Kul Tiran",
|
||||
"17": "Taunka",
|
||||
"18": "Vrykul",
|
||||
"19": "Vulpera",
|
||||
"2": "Orc",
|
||||
"20": "Pandaren",
|
||||
"21": "Naga",
|
||||
"22": "Broken",
|
||||
"23": "Fel Orc",
|
||||
"24": "Forest Troll",
|
||||
"25": "Ice Troll",
|
||||
"26": "Skeleton",
|
||||
"27": "Earthen",
|
||||
"28": "Drakkari Troll",
|
||||
"29": "Pandaren",
|
||||
"3": "Dwarf",
|
||||
"30": "Murloc",
|
||||
"31": "Murloc",
|
||||
"32": "Forgotten",
|
||||
"33": "Forgotten",
|
||||
"34": "Fel Orc",
|
||||
"35": "Naga",
|
||||
"36": "Broken",
|
||||
"37": "Skeleton",
|
||||
"38": "Vrykul",
|
||||
"39": "Tuskarr",
|
||||
"4": "Night Elf",
|
||||
"40": "Forest Troll",
|
||||
"41": "Taunka",
|
||||
"42": "Northrend Skeleton",
|
||||
"43": "Ice Troll",
|
||||
"44": "Drakkari Troll",
|
||||
"45": "Leper Troll",
|
||||
"46": "Troglodyte",
|
||||
"47": "Alpha Worgen",
|
||||
"48": "Dark Iron Dwarf",
|
||||
"49": "Mag'har Orc",
|
||||
"5": "Undead",
|
||||
"50": "Furbolg",
|
||||
"51": "Undead Gnome",
|
||||
"52": "Orc",
|
||||
"53": "Ogre",
|
||||
"54": "Dracthyr",
|
||||
"55": "Eredar",
|
||||
"56": "Harpy",
|
||||
"57": "Alpha Goblin",
|
||||
"58": "Dracthyr",
|
||||
"59": "Void Elf",
|
||||
"6": "Tauren",
|
||||
"60": "Illidari Blood Elf",
|
||||
"61": "Illidari Night Elf",
|
||||
"62": "Lightforged Draenei",
|
||||
"63": "Nightborne",
|
||||
"65": "Test Race",
|
||||
"66": "Highmountain Tauren",
|
||||
"67": "Mechagnome",
|
||||
"68": "Earthen",
|
||||
"69": "Earthen",
|
||||
"7": "Gnome",
|
||||
"70": "Haranir",
|
||||
"71": "Haranir",
|
||||
"72": "Windshaper Skyborne",
|
||||
"74": "Vulpera",
|
||||
"75": "Centaur",
|
||||
"77": "High Order Skyborne",
|
||||
"78": "Jinyu",
|
||||
"79": "Arakkoa",
|
||||
"8": "Troll",
|
||||
"80": "Darkfallen",
|
||||
"81": "Darkfallen",
|
||||
"82": "Sethrak",
|
||||
"83": "Gnoll",
|
||||
"85": "Two-Headed Ogre",
|
||||
"86": "Sureki",
|
||||
"87": "Faceless One",
|
||||
"88": "Qiraji",
|
||||
"89": "Dreadlord",
|
||||
"9": "Goblin",
|
||||
"90": "Banshee",
|
||||
"91": "Titan",
|
||||
"92": "Wretched",
|
||||
"93": "Fungarian",
|
||||
"96": "Thin Human",
|
||||
"97": "Saberon",
|
||||
"98": "Drakonid",
|
||||
"99": "Drakkin"
|
||||
}
|
||||
},
|
||||
"schema": 1,
|
||||
"source": "Corfirean/azerothcore-wotlk-coa modules/mod-coa-custom-races/data/dbc/ChrRaces.dbc"
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
//! The names players see in the realm list, chosen by the server owner.
|
||||
//!
|
||||
//! The launcher writes `acore_auth.realmlist.name` at every start, so a name typed into the database (or into
|
||||
//! an old `manage.py`) did not last. The owner's choice lives in `Settings/realm-names.json` of the server's main
|
||||
//! folder, keyed by realm id, and every start and every realm-list setup uses it; extra worlds read their main
|
||||
//! folder's file.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::error::{Error, Result};
|
||||
use crate::fsx;
|
||||
|
||||
const FILE: &str = "Settings/realm-names.json";
|
||||
|
||||
/// `acore_auth.realmlist.name` is `varchar(32)`.
|
||||
pub const MAX_CHARS: usize = 32;
|
||||
|
||||
#[derive(Debug, Default, Serialize, Deserialize)]
|
||||
struct Names {
|
||||
#[serde(default)]
|
||||
names: BTreeMap<u32, String>,
|
||||
}
|
||||
|
||||
/// The folder that owns the names: an extra world (`<server>/.realms/<name>`) belongs to `<server>`.
|
||||
fn main_folder(root: &Path) -> PathBuf {
|
||||
if crate::launcher::settings::is_extra_world(root) {
|
||||
if let Some(main) = root.parent().and_then(Path::parent) {
|
||||
return main.to_path_buf();
|
||||
}
|
||||
}
|
||||
root.to_path_buf()
|
||||
}
|
||||
|
||||
fn read(root: &Path) -> Names {
|
||||
let path = main_folder(root).join(FILE);
|
||||
if !path.is_file() {
|
||||
return Names::default();
|
||||
}
|
||||
match fsx::read_json(&path) {
|
||||
Ok(names) => names,
|
||||
Err(error) => {
|
||||
tracing::warn!(%error, "realm names could not be read; the default names are used");
|
||||
Names::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A trimmed name the realm list can hold: 1 to 32 characters, no control characters.
|
||||
pub fn validate(name: &str) -> Result<String> {
|
||||
let name = name.trim();
|
||||
if name.is_empty() {
|
||||
return Err(Error::Invalid("The realm name cannot be empty.".into()));
|
||||
}
|
||||
if name.chars().count() > MAX_CHARS {
|
||||
return Err(Error::Invalid(format!(
|
||||
"The realm name can have at most {MAX_CHARS} characters."
|
||||
)));
|
||||
}
|
||||
// The game client stores the realm as `SET realmName "<name>"` in Config.wtf.
|
||||
if name.chars().any(|c| c.is_control() || c == '"') {
|
||||
return Err(Error::Invalid(
|
||||
"The realm name cannot contain quotation marks or control characters.".into(),
|
||||
));
|
||||
}
|
||||
Ok(name.to_string())
|
||||
}
|
||||
|
||||
/// The owner's name for realm `id`, if one was chosen.
|
||||
pub fn custom(root: &Path, id: u32) -> Option<String> {
|
||||
read(root)
|
||||
.names
|
||||
.remove(&id)
|
||||
.and_then(|name| validate(&name).ok())
|
||||
}
|
||||
|
||||
/// The name realm `id` shows: the owner's choice, or `default`.
|
||||
pub fn name_or(root: &Path, id: u32, default: &str) -> String {
|
||||
custom(root, id).unwrap_or_else(|| default.to_string())
|
||||
}
|
||||
|
||||
/// The name the realm of `mode` shows.
|
||||
pub fn for_mode(root: &Path, mode: crate::realms::Mode) -> String {
|
||||
name_or(root, mode.realm_id(), mode.label())
|
||||
}
|
||||
|
||||
/// Every chosen name.
|
||||
pub fn all(root: &Path) -> BTreeMap<u32, String> {
|
||||
read(root)
|
||||
.names
|
||||
.into_iter()
|
||||
.filter_map(|(id, name)| validate(&name).ok().map(|name| (id, name)))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Choose a name for realm `id`; `None` (or an empty name) returns it to its default.
|
||||
pub fn set(root: &Path, id: u32, name: Option<&str>) -> Result<Option<String>> {
|
||||
let mut names = read(root);
|
||||
let chosen = match name.map(str::trim).filter(|n| !n.is_empty()) {
|
||||
Some(name) => Some(validate(name)?),
|
||||
None => None,
|
||||
};
|
||||
match &chosen {
|
||||
Some(name) => names.names.insert(id, name.clone()),
|
||||
None => names.names.remove(&id),
|
||||
};
|
||||
fsx::atomic_write_json(&main_folder(root).join(FILE), &names)?;
|
||||
Ok(chosen)
|
||||
}
|
||||
|
||||
/// A realm of this server and the name it shows.
|
||||
#[derive(Debug, Clone, Serialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RealmName {
|
||||
pub id: u32,
|
||||
pub name: String,
|
||||
pub default_name: String,
|
||||
pub custom: bool,
|
||||
}
|
||||
|
||||
/// The realms of a server with their names: Conquest of Azeroth (or the plain repack's "AzerothCore") and the
|
||||
/// Wildcard and Warcraft Reborn realms that were created.
|
||||
pub fn list(root: &Path) -> Result<Vec<RealmName>> {
|
||||
let main = main_folder(root);
|
||||
let mut realms: Vec<(u32, &'static str)> = Vec::new();
|
||||
if main.join("Settings/realm-profile.json").exists() {
|
||||
let state = crate::realms::state(&main)?;
|
||||
realms.extend(state.modes().into_iter().map(|m| (m.realm_id(), m.label())));
|
||||
} else {
|
||||
realms.push((1, "AzerothCore"));
|
||||
}
|
||||
realms.sort_unstable();
|
||||
realms.dedup();
|
||||
Ok(realms
|
||||
.into_iter()
|
||||
.map(|(id, default)| {
|
||||
let custom = custom(&main, id);
|
||||
RealmName {
|
||||
id,
|
||||
name: custom.clone().unwrap_or_else(|| default.to_string()),
|
||||
default_name: default.to_string(),
|
||||
custom: custom.is_some(),
|
||||
}
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
/// Choose a name and, when the database runs, write it to the realm list at once (the auth server shows it
|
||||
/// within its realm refresh interval). Returns the realms with their names.
|
||||
pub fn rename(root: &Path, id: u32, name: Option<&str>) -> Result<Vec<RealmName>> {
|
||||
let main = main_folder(root);
|
||||
let known = list(&main)?;
|
||||
let realm = known
|
||||
.iter()
|
||||
.find(|r| r.id == id)
|
||||
.ok_or_else(|| Error::Invalid(format!("This server has no realm {id}.")))?;
|
||||
let shown = set(&main, id, name)?.unwrap_or_else(|| realm.default_name.clone());
|
||||
crate::backup::with_running_database(&main, |db| {
|
||||
db.query(&format!(
|
||||
"UPDATE acore_auth.realmlist SET name={} WHERE id={id};",
|
||||
sql_literal(&shown)
|
||||
))
|
||||
.map(|_| ())
|
||||
})?;
|
||||
list(&main)
|
||||
}
|
||||
|
||||
/// `text` as a MySQL string literal (quotes and backslashes escaped).
|
||||
pub fn sql_literal(text: &str) -> String {
|
||||
let mut out = String::with_capacity(text.len() + 2);
|
||||
out.push('\'');
|
||||
for c in text.chars() {
|
||||
match c {
|
||||
'\'' => out.push_str("''"),
|
||||
'\\' => out.push_str("\\\\"),
|
||||
c => out.push(c),
|
||||
}
|
||||
}
|
||||
out.push('\'');
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn names_are_validated_trimmed_and_reset() {
|
||||
let d = tempfile::tempdir().unwrap();
|
||||
assert_eq!(name_or(d.path(), 1, "Conquest of Azeroth"), "Conquest of Azeroth");
|
||||
assert_eq!(set(d.path(), 1, Some(" Owner's Realm ")).unwrap().as_deref(), Some("Owner's Realm"));
|
||||
assert_eq!(name_or(d.path(), 1, "x"), "Owner's Realm");
|
||||
assert!(set(d.path(), 2, Some(&"a".repeat(33))).is_err());
|
||||
assert!(set(d.path(), 2, Some("bad\nname")).is_err());
|
||||
assert_eq!(set(d.path(), 2, Some("Царство")).unwrap().as_deref(), Some("Царство"));
|
||||
assert_eq!(all(d.path()).len(), 2);
|
||||
assert_eq!(set(d.path(), 1, Some(" ")).unwrap(), None);
|
||||
assert_eq!(name_or(d.path(), 1, "Conquest of Azeroth"), "Conquest of Azeroth");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_extra_world_reads_its_main_folders_names() {
|
||||
let d = tempfile::tempdir().unwrap();
|
||||
set(d.path(), 2, Some("Wild Side")).unwrap();
|
||||
let extra = d.path().join(".realms/secondary");
|
||||
std::fs::create_dir_all(&extra).unwrap();
|
||||
assert_eq!(custom(&extra, 2).as_deref(), Some("Wild Side"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn names_are_safe_in_sql() {
|
||||
assert_eq!(sql_literal(r"O'Neil \ realm"), r"'O''Neil \\ realm'");
|
||||
}
|
||||
}
|
||||
@@ -707,8 +707,8 @@ pub fn setup_realmlist(root: &Path) -> Result<()> {
|
||||
let port = layout::read_ports(root).world;
|
||||
for mode in s.modes().into_iter().filter(|m| *m != Mode::Coa) {
|
||||
let id = mode.realm_id();
|
||||
let name = mode.label();
|
||||
db.query(&format!("INSERT INTO acore_auth.realmlist (id,name,address,localAddress,localSubnetMask,port,icon,flag,timezone,gamebuild) SELECT {id},'{name}',address,localAddress,localSubnetMask,{port},icon,2,timezone,gamebuild FROM acore_auth.realmlist WHERE id=1 ON DUPLICATE KEY UPDATE port={port};"))?;
|
||||
let name = crate::realm_names::sql_literal(&crate::realm_names::name_or(root, id, mode.label()));
|
||||
db.query(&format!("INSERT INTO acore_auth.realmlist (id,name,address,localAddress,localSubnetMask,port,icon,flag,timezone,gamebuild) SELECT {id},{name},address,localAddress,localSubnetMask,{port},icon,2,timezone,gamebuild FROM acore_auth.realmlist WHERE id=1 ON DUPLICATE KEY UPDATE port={port},name={name};"))?;
|
||||
}
|
||||
let ids = s
|
||||
.modes()
|
||||
|
||||
@@ -100,7 +100,7 @@ fn run(args: Args) -> Result<(), String> {
|
||||
match args.action.as_str() {
|
||||
"watch-world" => {
|
||||
let me = std::env::current_exe().map_err(|x| x.to_string())?;
|
||||
return world::watch_world(root, Some(&me), &|m| say(m)).map_err(e);
|
||||
return world::watch_world(root, Some(&me), args.offset, &|m| say(m)).map_err(e);
|
||||
}
|
||||
"relay-worker" => return coa_core::launcher::relay::worker(root).map_err(e),
|
||||
"debug-logs-status" => {
|
||||
|
||||
Reference in new issue
Block a user