diff options
| author | metamuffin <metamuffin@disroot.org> | 2024-06-20 01:20:51 +0200 | 
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2024-06-23 19:21:49 +0200 | 
| commit | 6f7b995dd9fa3bea95be8c24e2452f015b410839 (patch) | |
| tree | 2c1d2d03a759ee4597a07d5998dae8480bd73a67 /server/src/data.rs | |
| parent | 67ccafad4d7d481bdf60be750f96a086ae452e27 (diff) | |
| download | hurrycurry-6f7b995dd9fa3bea95be8c24e2452f015b410839.tar hurrycurry-6f7b995dd9fa3bea95be8c24e2452f015b410839.tar.bz2 hurrycurry-6f7b995dd9fa3bea95be8c24e2452f015b410839.tar.zst | |
change the protocol yet again
Diffstat (limited to 'server/src/data.rs')
| -rw-r--r-- | server/src/data.rs | 21 | 
1 files changed, 18 insertions, 3 deletions
| diff --git a/server/src/data.rs b/server/src/data.rs index 3526d786..e467fefa 100644 --- a/server/src/data.rs +++ b/server/src/data.rs @@ -31,22 +31,34 @@ pub struct InitialMap {      tiles: HashMap<String, String>,  } +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct DemandDecl { +    from: String, +    to: String, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Demand { +    pub from: usize, +    pub to: usize, +} +  #[derive(Debug, Clone, Serialize, Deserialize, Default)]  pub struct Gamedata {      pub recipes: Vec<Recipe>, +    pub demands: Vec<Demand>,      pub item_names: Vec<String>,      pub tile_names: Vec<String>,      #[serde(skip)]      pub initial_map: HashMap<IVec2, TileIndex>,      pub chef_spawn: Vec2,      pub customer_spawn: Vec2, -    pub demands: Vec<usize>,  }  pub fn build_gamedata(      recipes_in: Vec<RecipeDecl>,      map_in: InitialMap, -    demands_in: Vec<String>, +    demands_in: Vec<DemandDecl>,  ) -> Gamedata {      let item_names = RwLock::new(Vec::new());      let tile_names = RwLock::new(Vec::new()); @@ -85,7 +97,10 @@ pub fn build_gamedata(      }      for d in demands_in { -        demands.push(register(&item_names, d)) +        demands.push(Demand { +            from: register(&item_names, d.from), +            to: register(&item_names, d.to), +        })      }      let mut chef_spawn = Vec2::new(0., 0.); | 
