diff options
| author | Arne Dußin | 2021-02-03 10:51:08 +0100 |
|---|---|---|
| committer | Arne Dußin | 2021-02-03 10:51:08 +0100 |
| commit | d4c1c7ecb5688ef64f45425d9ac8e7ddeb8e8602 (patch) | |
| tree | 6788d2efc22373d735947ba46d3a3ea3b3b3733c /src/client/cli/cmd/read.rs | |
| parent | f92e9f6f07b1e3834c2ca58ce3510734819d08e4 (diff) | |
| download | graf_karto-d4c1c7ecb5688ef64f45425d9ac8e7ddeb8e8602.tar.gz graf_karto-d4c1c7ecb5688ef64f45425d9ac8e7ddeb8e8602.zip | |
Fix commands
Commands now operate on the local file system, but on the remote world
Diffstat (limited to 'src/client/cli/cmd/read.rs')
| -rw-r--r-- | src/client/cli/cmd/read.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/client/cli/cmd/read.rs b/src/client/cli/cmd/read.rs index 313530a..3b20308 100644 --- a/src/client/cli/cmd/read.rs +++ b/src/client/cli/cmd/read.rs @@ -3,7 +3,8 @@ use super::Command; use super::{CmdParseError, FromArgs}; use crate::client::Editor; -use crate::map::MapData; +use crate::net::Cargo; +use crate::world::World; use std::path::PathBuf; /// Command to read a file from the system @@ -25,7 +26,7 @@ impl FromArgs for Read { impl Command for Read { fn process(&self, editor: &mut Editor) -> Result<String, String> { - let data = match MapData::load_from_file(&self.file) { + let world = match World::load_from_file(&self.file) { Ok(data) => data, Err(err) => { return Err(format!( @@ -35,7 +36,17 @@ impl Command for Read { } }; - editor.map_mut().add_data(data); + // Send all components of the file to the server. + for (_, icon) in world.icons().iter() { + editor.server().send(Cargo::AddIcon(icon.clone())); + } + for (_, room) in world.rooms().iter() { + editor.server().send(Cargo::AddRoom(room.clone())); + } + for (_, wall) in world.walls().iter() { + editor.server().send(Cargo::AddWall(wall.clone())); + } + Ok(format!( "Map data from {:?} read and added to the current buffer.", &self.file |
