diff --git a/crates/coa-core/src/portable/realm/collections.rs b/crates/coa-core/src/portable/realm/collections.rs index 516c251..fb7191e 100644 --- a/crates/coa-core/src/portable/realm/collections.rs +++ b/crates/coa-core/src/portable/realm/collections.rs @@ -35,7 +35,7 @@ fn realm_error(e: crate::Error) -> PortableError { } fn coa_only(db: &Db) -> Result<()> { - if ruleset_of(db) != Ruleset::Coa { + if ruleset_of(db)? != Ruleset::Coa { return Err(PortableError::Invalid( "collections are carried for CoA realms only (Wildcard transfer is disabled)".into(), )); diff --git a/crates/coa-core/src/portable/realm/import.rs b/crates/coa-core/src/portable/realm/import.rs index f6dc2f9..71a3863 100644 --- a/crates/coa-core/src/portable/realm/import.rs +++ b/crates/coa-core/src/portable/realm/import.rs @@ -200,7 +200,7 @@ pub fn preflight( opts: &ImportOptions, ) -> Result { let mut report = PreflightReport::default(); - let realm_ruleset = ruleset_of(db); + let realm_ruleset = ruleset_of(db)?; if model.ruleset != realm_ruleset { report.problems.push(ImportProblem::WrongRuleset { character: model.ruleset, @@ -452,7 +452,7 @@ pub fn import_character_in_session( let plan = match build_plan( &model, &PlanContext { - ruleset: ruleset_of(db), + ruleset: ruleset_of(db)?, account, revision: record.revision, nonce: ticket.nonce, diff --git a/crates/coa-core/src/portable/realm/mod.rs b/crates/coa-core/src/portable/realm/mod.rs index b0f2ed0..888c0fe 100644 --- a/crates/coa-core/src/portable/realm/mod.rs +++ b/crates/coa-core/src/portable/realm/mod.rs @@ -51,10 +51,11 @@ pub use reconcile::{ pub use script::SchemaProbe; /// The ruleset a database belongs to is decided by which realm profile it is (`realms::Mode`), never by the caller. -pub fn ruleset_of(db: &Db) -> Ruleset { +pub fn ruleset_of(db: &Db) -> Result { match db.realm() { - Mode::Coa => Ruleset::Coa, - Mode::Wildcard => Ruleset::Wildcard, + Mode::Coa => Ok(Ruleset::Coa), + Mode::Wildcard => Ok(Ruleset::Wildcard), + Mode::Reborn => Err(PortableError::Invalid("Portable characters are not supported on Warcraft Reborn realms yet.".into())), } } @@ -216,7 +217,7 @@ pub fn export_character_with_pets( export::build( &raw, &ExportRequest { - ruleset: ruleset_of(db), + ruleset: ruleset_of(db)?, local_guid, character_id, prior_items, @@ -240,7 +241,7 @@ pub fn read_session_character( export::build( &raw, &ExportRequest { - ruleset: ruleset_of(db), + ruleset: ruleset_of(db)?, local_guid, character_id: Some(character_id), prior_items, diff --git a/crates/coa-core/src/portable/realm/profile.rs b/crates/coa-core/src/portable/realm/profile.rs index 332a889..bad7386 100644 --- a/crates/coa-core/src/portable/realm/profile.rs +++ b/crates/coa-core/src/portable/realm/profile.rs @@ -92,7 +92,7 @@ pub fn assemble( let mut extension_realm = NoRealm { probe }; let extensions = registry.supported_on(&mut extension_realm); let content = ContentProfile { - ruleset: ruleset_of(db), + ruleset: ruleset_of(db)?, character_formats: ContentProfile::manager_formats(), online_import_job_formats: core .map(|c| c.portable.job_formats.clone()) diff --git a/crates/coa-core/src/portable/realm/reconcile.rs b/crates/coa-core/src/portable/realm/reconcile.rs index 413eabd..78d912a 100644 --- a/crates/coa-core/src/portable/realm/reconcile.rs +++ b/crates/coa-core/src/portable/realm/reconcile.rs @@ -738,8 +738,9 @@ fn update_inner( merged }; let schema = probe(db)?; + let ruleset = ruleset_of(db)?; let context = |nonce| UpdateContext { - ruleset: ruleset_of(db), + ruleset, local_guid: guid, revision: record.revision, nonce, diff --git a/crates/coa-core/src/portable/realm/tests.rs b/crates/coa-core/src/portable/realm/tests.rs index 8b63645..66581a3 100644 --- a/crates/coa-core/src/portable/realm/tests.rs +++ b/crates/coa-core/src/portable/realm/tests.rs @@ -728,8 +728,10 @@ fn the_wildcard_ruleset_uses_its_own_namespace_and_quarantines_wildcard_state() // the realm profile of a database decides the ruleset, not the caller let wc_db = Db::with_tools(std::path::PathBuf::new(), 1, "root", "x", Mode::Wildcard); let coa_db = Db::with_tools(std::path::PathBuf::new(), 1, "root", "x", Mode::Coa); + let reborn_db = Db::with_tools(std::path::PathBuf::new(), 1, "root", "x", Mode::Reborn); + assert!(ruleset_of(&reborn_db).is_err()); assert_eq!( - (ruleset_of(&wc_db), ruleset_of(&coa_db)), + (ruleset_of(&wc_db).unwrap(), ruleset_of(&coa_db).unwrap()), (Ruleset::Wildcard, Ruleset::Coa) ); assert_eq!( diff --git a/crates/coa-core/src/portable/service/engine.rs b/crates/coa-core/src/portable/service/engine.rs index 7f00b19..fd23e80 100644 --- a/crates/coa-core/src/portable/service/engine.rs +++ b/crates/coa-core/src/portable/service/engine.rs @@ -1438,7 +1438,7 @@ impl PortableService { let model = self.host.load_current(character_id)?; let encoded = super::super::snapshot::encode(&model)?; let mut collections = BTreeMap::new(); - if realm::ruleset_of(&db) == super::super::model::Ruleset::Coa { + if realm::ruleset_of(&db)? == super::super::model::Ruleset::Coa { if let Some(account) = realm::collections::account_of(&db, local_guid)? { for kind in ["coa:appearance", "coa:vanity"] { if let Ok(set) = realm::collections::read_set(&db, account, kind) {