diff options
Diffstat (limited to 'src/client/editor.rs')
| -rw-r--r-- | src/client/editor.rs | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/client/editor.rs b/src/client/editor.rs index e416339..fb271d4 100644 --- a/src/client/editor.rs +++ b/src/client/editor.rs @@ -168,12 +168,32 @@ impl Editor { fn poll_net(&mut self) { while let Some(cargo) = self.server().next_packet() { match cargo { - Cargo::SetRoom((id, new_room)) => { - if let Some(mark) = self.map.get_room_mut(id) { - mark.set_room(new_room); - } else { + Cargo::SetRoom((id, new_room)) => match self.map.get_room_mut(id) { + Some(mark) => mark.set_room(new_room), + None => { self.map.add_room(id, new_room); } + }, + Cargo::SetIcon((id, new_icon)) => match self.map.get_icon_mut(id) { + Some(mark) => mark.set_icon(new_icon), + None => { + self.map.add_icon(id, new_icon); + } + }, + Cargo::SetWall((id, new_wall)) => match self.map.get_wall_mut(id) { + Some(mark) => mark.set_wall(new_wall), + None => { + self.map.add_wall(id, new_wall); + } + }, + Cargo::ClearAll => self.map.clear(), + Cargo::Remove(id) => { + self.map.remove(id); + } + Cargo::AddMapData(_) => unimplemented!(), + Cargo::UpdateMapData(_) => unimplemented!(), + Cargo::AddIcon(_) | Cargo::AddRoom(_) | Cargo::AddWall(_) => { + error!("Packet is only valid in Client -> Server direction") } other => error!("Unknown packet received: {:?}", other), } |
