aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/mod.rs54
1 files changed, 53 insertions, 1 deletions
diff --git a/src/server/mod.rs b/src/server/mod.rs
index fe208ad..7f94453 100644
--- a/src/server/mod.rs
+++ b/src/server/mod.rs
@@ -50,7 +50,59 @@ fn start(conn_man: ConnectionManager<Cargo>) -> JoinHandle<()> {
let room_id = world.push_room(room.clone());
conn_man.broadcast(Cargo::SetRoom((room_id, room)));
}
- other => error!("Unknown packet received from `{}`: {:?}", user, other),
+ Cargo::AddIcon(icon) => {
+ let icon_id = world.push_icon(icon.clone());
+ conn_man.broadcast(Cargo::SetIcon((icon_id, icon)));
+ }
+ Cargo::AddWall(wall) => {
+ let wall_id = world.push_wall(wall.clone());
+ conn_man.broadcast(Cargo::SetWall((wall_id, wall)));
+ }
+ Cargo::SetRoom((id, new)) => {
+ if let Some(old) = world.get_room_mut(id) {
+ *old = new;
+ } else {
+ error!(
+ "Unable to change room. Room with id `{}` does not exist.",
+ id
+ );
+ }
+ }
+ Cargo::SetIcon((id, new)) => {
+ if let Some(old) = world.get_icon_mut(id) {
+ *old = new;
+ } else {
+ error!(
+ "Unable to change icon. Icon with id `{}` does not exist.",
+ id
+ );
+ }
+ }
+ Cargo::SetWall((id, new)) => {
+ if let Some(old) = world.get_wall_mut(id) {
+ *old = new;
+ } else {
+ error!(
+ "Unable to change wall. Wall with id `{}` does not exist.",
+ id
+ );
+ }
+ }
+ Cargo::ClearAll => {
+ world.clear();
+ conn_man.broadcast(Cargo::ClearAll);
+ }
+ Cargo::Remove(id) => {
+ if world.remove(id) {
+ conn_man.broadcast(Cargo::Remove(id));
+ } else {
+ error!("Unable to remove item. No item with id `{}` found.", id);
+ }
+ }
+ Cargo::ApplyMatrix((_id, _matrix)) => unimplemented!(),
+ Cargo::AddMapData(_) | Cargo::UpdateMapData(_) => {
+ error!("This packet is not allowed in the client -> server direction");
+ }
}
}
})