summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-07-11 13:48:42 +0200
committermetamuffin <metamuffin@disroot.org>2024-07-11 13:48:42 +0200
commitae29ca99dde89f8b975ce7b3a716411ab2028e50 (patch)
tree0ecd0107dda055f9e5f4391d1df545f662a98920 /server/src
parent42900ac1c14712f181a9719a85d9df879e15ef29 (diff)
downloadhurrycurry-ae29ca99dde89f8b975ce7b3a716411ab2028e50.tar
hurrycurry-ae29ca99dde89f8b975ce7b3a716411ab2028e50.tar.bz2
hurrycurry-ae29ca99dde89f8b975ce7b3a716411ab2028e50.tar.zst
send map metadata
Diffstat (limited to 'server/src')
-rw-r--r--server/src/data.rs12
-rw-r--r--server/src/game.rs6
-rw-r--r--server/src/state.rs2
3 files changed, 10 insertions, 10 deletions
diff --git a/server/src/data.rs b/server/src/data.rs
index 5f35a360..c5ed25ad 100644
--- a/server/src/data.rs
+++ b/server/src/data.rs
@@ -23,7 +23,7 @@ use crate::{
use anyhow::{anyhow, bail, Result};
use hurrycurry_protocol::{
glam::{IVec2, Vec2},
- DemandIndex, ItemIndex, RecipeIndex, TileIndex,
+ DemandIndex, ItemIndex, MapMetadata, RecipeIndex, TileIndex,
};
use serde::{Deserialize, Serialize};
use std::{
@@ -105,7 +105,7 @@ pub struct Gamedata {
pub tile_names: Vec<String>,
pub tile_collide: Vec<bool>,
pub tile_interact: Vec<bool>,
- pub map_names: HashSet<String>,
+ pub map: HashMap<String, MapMetadata>,
#[serde(skip)] pub recipes: Vec<Recipe>,
#[serde(skip)] pub demands: Vec<Demand>,
#[serde(skip)] pub initial_map: HashMap<IVec2, (TileIndex, Option<ItemIndex>)>,
@@ -116,7 +116,7 @@ pub struct Gamedata {
#[derive(Debug, Deserialize, Default)]
pub struct DataIndex {
- pub maps: HashSet<String>,
+ pub maps: HashMap<String, MapMetadata>,
pub demands: HashSet<String>,
pub recipes: HashSet<String>,
}
@@ -137,7 +137,7 @@ impl DataIndex {
}
pub async fn read_map(&self, name: &str) -> Result<String> {
- if !self.maps.contains(name) {
+ if !self.maps.contains_key(name) {
bail!("unknown map: {name:?}");
}
let path = data_dir().join(format!("maps/{name}.yaml"));
@@ -167,7 +167,7 @@ impl DataIndex {
let recipes_in = serde_yaml::from_str(&self.read_recipes(recipes).await?)?;
let mut gd = Gamedata::build(spec, map_in, demands_in, recipes_in)?;
- gd.map_names = self.maps.clone();
+ gd.map = self.maps.clone();
Ok(gd)
}
}
@@ -288,7 +288,7 @@ impl Gamedata {
tile_collide,
tile_interact,
recipes,
- map_names: HashSet::new(),
+ map: HashMap::new(),
initial_map,
item_names,
entities,
diff --git a/server/src/game.rs b/server/src/game.rs
index b20dfeb7..f196fd1f 100644
--- a/server/src/game.rs
+++ b/server/src/game.rs
@@ -169,12 +169,12 @@ impl Game {
tile_names: self.data.tile_names.clone(),
tile_collide: self.data.tile_collide.clone(),
tile_interact: self.data.tile_interact.clone(),
- map_names: self
+ maps: self
.data
- .map_names
+ .map
.clone()
.into_iter()
- .filter(|n| n != "lobby")
+ .filter(|(n, _)| n != "lobby")
.collect(),
},
});
diff --git a/server/src/state.rs b/server/src/state.rs
index 2af436a3..e9cb1722 100644
--- a/server/src/state.rs
+++ b/server/src/state.rs
@@ -184,7 +184,7 @@ impl State {
Command::List => {
bail!(
"Maps: {:?}\nDemands: {:?}\nRecipes: {:?}",
- self.index.maps,
+ self.index.maps.keys().collect::<Vec<_>>(),
self.index.demands,
self.index.recipes
)