fix(rail-1): LazyLock for ContentRegistry static (fixes E0015); correct 5-up relative include_bytes paths in load_default_content
Unblocks dist:publish / fleet builds for shared magicciv-artifacts Space and p3-29 render proof. Registry (p3-28) now compiles clean on linux workers.
This commit is contained in:
parent
5d9c493553
commit
0d4f59cfae
2 changed files with 13 additions and 11 deletions
|
|
@ -74,9 +74,11 @@ pub use expertise::{ExpertiseTier, ParseExpertiseTierError, ALL as EXPERTISE_TIE
|
||||||
/// Static RwLock<HashMap> so it is populated once at boot and read-only after.
|
/// Static RwLock<HashMap> so it is populated once at boot and read-only after.
|
||||||
/// Names are the logical keys (e.g. "promotions", "treaty_rules").
|
/// Names are the logical keys (e.g. "promotions", "treaty_rules").
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::RwLock;
|
use std::sync::{LazyLock, RwLock};
|
||||||
|
|
||||||
static CONTENT_REGISTRY: RwLock<HashMap<String, Vec<u8>>> = RwLock::new(HashMap::new());
|
/// Static via LazyLock (the `new` for HashMap/RwLock is not const in static context).
|
||||||
|
static CONTENT_REGISTRY: LazyLock<RwLock<HashMap<String, Vec<u8>>>> =
|
||||||
|
LazyLock::new(|| RwLock::new(HashMap::new()));
|
||||||
|
|
||||||
/// Load content bytes under `name`. Overwrites if re-called.
|
/// Load content bytes under `name`. Overwrites if re-called.
|
||||||
pub fn load_content(name: &str, bytes: Vec<u8>) {
|
pub fn load_content(name: &str, bytes: Vec<u8>) {
|
||||||
|
|
|
||||||
|
|
@ -63,46 +63,46 @@ pub fn load_default_content() {
|
||||||
// Promotions (used by mc-combat for XP/heal and registry).
|
// Promotions (used by mc-combat for XP/heal and registry).
|
||||||
mc_core::load_content_static(
|
mc_core::load_content_static(
|
||||||
"promotions",
|
"promotions",
|
||||||
include_bytes!("../../../../../../public/resources/promotions/promotions.json"),
|
include_bytes!("../../../../../public/resources/promotions/promotions.json"),
|
||||||
);
|
);
|
||||||
// Treaty rules (mc-trade).
|
// Treaty rules (mc-trade).
|
||||||
mc_core::load_content_static(
|
mc_core::load_content_static(
|
||||||
"treaty_rules",
|
"treaty_rules",
|
||||||
include_bytes!("../../../../../../public/resources/diplomacy/treaty_rules.json"),
|
include_bytes!("../../../../../public/resources/diplomacy/treaty_rules.json"),
|
||||||
);
|
);
|
||||||
// Freepeople (mc-trade).
|
// Freepeople (mc-trade).
|
||||||
mc_core::load_content_static(
|
mc_core::load_content_static(
|
||||||
"freepeople",
|
"freepeople",
|
||||||
include_bytes!("../../../../../../public/resources/ai/freepeople/freepeople.json"),
|
include_bytes!("../../../../../public/resources/ai/freepeople/freepeople.json"),
|
||||||
);
|
);
|
||||||
// Awards (mc-replay tests, but useful).
|
// Awards (mc-replay tests, but useful).
|
||||||
mc_core::load_content_static(
|
mc_core::load_content_static(
|
||||||
"awards",
|
"awards",
|
||||||
include_bytes!("../../../../../../public/games/age-of-dwarves/data/awards.json"),
|
include_bytes!("../../../../../public/games/age-of-dwarves/data/awards.json"),
|
||||||
);
|
);
|
||||||
// Score config.
|
// Score config.
|
||||||
mc_core::load_content_static(
|
mc_core::load_content_static(
|
||||||
"score",
|
"score",
|
||||||
include_bytes!("../../../../../../public/games/age-of-dwarves/data/score.json"),
|
include_bytes!("../../../../../public/games/age-of-dwarves/data/score.json"),
|
||||||
);
|
);
|
||||||
// Resources.
|
// Resources.
|
||||||
mc_core::load_content_static(
|
mc_core::load_content_static(
|
||||||
"resources",
|
"resources",
|
||||||
include_bytes!("../../../../../../public/resources/resources.json"),
|
include_bytes!("../../../../../public/resources/resources.json"),
|
||||||
);
|
);
|
||||||
// Combat balance (already has its path, but for registry).
|
// Combat balance (already has its path, but for registry).
|
||||||
mc_core::load_content_static(
|
mc_core::load_content_static(
|
||||||
"combat_balance",
|
"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.
|
// Ecology traits.
|
||||||
mc_core::load_content_static(
|
mc_core::load_content_static(
|
||||||
"biome_trait_weights",
|
"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(
|
mc_core::load_content_static(
|
||||||
"flavor",
|
"flavor",
|
||||||
include_bytes!("../../../../../../public/resources/ecology/traits/flavor.json"),
|
include_bytes!("../../../../../public/resources/ecology/traits/flavor.json"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue