diff options
Diffstat (limited to 'server/src/data.rs')
-rw-r--r-- | server/src/data.rs | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/server/src/data.rs b/server/src/data.rs index 2d190f3b..7f5ed9a6 100644 --- a/server/src/data.rs +++ b/server/src/data.rs @@ -98,20 +98,21 @@ pub struct Demand { pub points: i64, } -#[derive(Debug, Clone, Serialize, Deserialize, Default)] +#[derive(Debug, Clone, Default)] #[rustfmt::skip] pub struct Gamedata { pub spec: String, + pub map_name: String, pub item_names: Vec<String>, pub tile_names: Vec<String>, pub tile_collide: Vec<bool>, pub tile_interact: Vec<bool>, pub map: HashMap<String, MapMetadata>, - #[serde(skip)] pub recipes: Vec<Recipe>, - #[serde(skip)] pub initial_map: HashMap<IVec2, (TileIndex, Option<ItemIndex>)>, - #[serde(skip)] pub chef_spawn: Vec2, - #[serde(skip)] pub customer_spawn: Vec2, - #[serde(skip)] pub entities: Vec<Entity>, + pub recipes: Vec<Recipe>, + pub initial_map: HashMap<IVec2, (TileIndex, Option<ItemIndex>)>, + pub chef_spawn: Vec2, + pub customer_spawn: Vec2, + pub entities: Vec<Entity>, } #[derive(Debug, Deserialize, Default)] @@ -164,14 +165,19 @@ impl DataIndex { let map_in = serde_yml::from_str(&self.read_map(map).await?)?; let recipes_in = serde_yml::from_str(&self.read_recipes(recipes).await?)?; - let mut gd = Gamedata::build(spec, map_in, recipes_in)?; + let mut gd = Gamedata::build(spec.clone(), map.to_string(), map_in, recipes_in)?; gd.map = self.maps.clone(); Ok(gd) } } impl Gamedata { - pub fn build(spec: String, map_in: InitialMap, recipes_in: Vec<RecipeDecl>) -> Result<Self> { + pub fn build( + spec: String, + map_name: String, + map_in: InitialMap, + recipes_in: Vec<RecipeDecl>, + ) -> Result<Self> { let reg = ItemTileRegistry::default(); let mut recipes = Vec::new(); let mut entities = Vec::new(); @@ -313,6 +319,7 @@ impl Gamedata { Ok(Gamedata { spec, tile_collide, + map_name, tile_interact, recipes, map: HashMap::new(), |