diff --git a/src/simulator/crates/mc-core/src/lib.rs b/src/simulator/crates/mc-core/src/lib.rs index 1607595b..d0ad09bb 100644 --- a/src/simulator/crates/mc-core/src/lib.rs +++ b/src/simulator/crates/mc-core/src/lib.rs @@ -74,9 +74,11 @@ pub use expertise::{ExpertiseTier, ParseExpertiseTierError, ALL as EXPERTISE_TIE /// Static RwLock so it is populated once at boot and read-only after. /// Names are the logical keys (e.g. "promotions", "treaty_rules"). use std::collections::HashMap; -use std::sync::RwLock; +use std::sync::{LazyLock, RwLock}; -static CONTENT_REGISTRY: RwLock>> = RwLock::new(HashMap::new()); +/// Static via LazyLock (the `new` for HashMap/RwLock is not const in static context). +static CONTENT_REGISTRY: LazyLock>>> = + LazyLock::new(|| RwLock::new(HashMap::new())); /// Load content bytes under `name`. Overwrites if re-called. pub fn load_content(name: &str, bytes: Vec) { diff --git a/src/simulator/crates/mc-player-api/src/lib.rs b/src/simulator/crates/mc-player-api/src/lib.rs index 93acfaf9..d46d4ea3 100644 --- a/src/simulator/crates/mc-player-api/src/lib.rs +++ b/src/simulator/crates/mc-player-api/src/lib.rs @@ -63,46 +63,46 @@ pub fn load_default_content() { // Promotions (used by mc-combat for XP/heal and registry). mc_core::load_content_static( "promotions", - include_bytes!("../../../../../../public/resources/promotions/promotions.json"), + include_bytes!("../../../../../public/resources/promotions/promotions.json"), ); // Treaty rules (mc-trade). mc_core::load_content_static( "treaty_rules", - include_bytes!("../../../../../../public/resources/diplomacy/treaty_rules.json"), + include_bytes!("../../../../../public/resources/diplomacy/treaty_rules.json"), ); // Freepeople (mc-trade). mc_core::load_content_static( "freepeople", - include_bytes!("../../../../../../public/resources/ai/freepeople/freepeople.json"), + include_bytes!("../../../../../public/resources/ai/freepeople/freepeople.json"), ); // Awards (mc-replay tests, but useful). mc_core::load_content_static( "awards", - include_bytes!("../../../../../../public/games/age-of-dwarves/data/awards.json"), + include_bytes!("../../../../../public/games/age-of-dwarves/data/awards.json"), ); // Score config. mc_core::load_content_static( "score", - include_bytes!("../../../../../../public/games/age-of-dwarves/data/score.json"), + include_bytes!("../../../../../public/games/age-of-dwarves/data/score.json"), ); // Resources. mc_core::load_content_static( "resources", - include_bytes!("../../../../../../public/resources/resources.json"), + include_bytes!("../../../../../public/resources/resources.json"), ); // Combat balance (already has its path, but for registry). mc_core::load_content_static( "combat_balance", - include_bytes!("../../../../../../public/games/age-of-dwarves/data/combat_balance.json"), + include_bytes!("../../../../../public/games/age-of-dwarves/data/combat_balance.json"), ); // Ecology traits. mc_core::load_content_static( "biome_trait_weights", - include_bytes!("../../../../../../public/resources/ecology/traits/biome_trait_weights.json"), + include_bytes!("../../../../../public/resources/ecology/traits/biome_trait_weights.json"), ); mc_core::load_content_static( "flavor", - include_bytes!("../../../../../../public/resources/ecology/traits/flavor.json"), + include_bytes!("../../../../../public/resources/ecology/traits/flavor.json"), ); }