aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Dußin2021-02-04 15:13:39 +0100
committerArne Dußin2021-02-04 15:13:39 +0100
commitc53af0485f38a1f5bd843154eb27357a5c0aed11 (patch)
tree1d1fb377dba8e481cd7fa02c6a1e51931ba1a3f2
parentc0f8c067f6226981dc657a5a13fe0c0c5b0734d9 (diff)
downloadgraf_karto-c53af0485f38a1f5bd843154eb27357a5c0aed11.tar.gz
graf_karto-c53af0485f38a1f5bd843154eb27357a5c0aed11.zip
Add matrix transform capabilities back
-rw-r--r--src/client/editor.rs6
-rw-r--r--src/server/mod.rs12
2 files changed, 14 insertions, 4 deletions
diff --git a/src/client/editor.rs b/src/client/editor.rs
index e030558..14f25ef 100644
--- a/src/client/editor.rs
+++ b/src/client/editor.rs
@@ -192,8 +192,10 @@ impl Editor {
}
Cargo::AddMapData(_) => unimplemented!(),
Cargo::UpdateMapData(_) => unimplemented!(),
- Cargo::ApplyMatrix(_) => unimplemented!(),
- Cargo::AddIcon(_) | Cargo::AddRoom(_) | Cargo::AddWall(_) => {
+ Cargo::AddIcon(_)
+ | Cargo::AddRoom(_)
+ | Cargo::AddWall(_)
+ | Cargo::ApplyMatrix(_) => {
error!("Packet is only valid in Client -> Server direction")
}
}
diff --git a/src/server/mod.rs b/src/server/mod.rs
index 4f95378..d25b799 100644
--- a/src/server/mod.rs
+++ b/src/server/mod.rs
@@ -2,7 +2,7 @@
use crate::net::server::ConnectionManager;
use crate::net::Cargo;
-use crate::world::World;
+use crate::world::{Component, World};
use std::io;
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr};
use std::sync::atomic::{AtomicBool, Ordering};
@@ -105,7 +105,15 @@ fn start(conn_man: ConnectionManager<Cargo>) -> (JoinHandle<()>, Arc<AtomicBool>
error!("Unable to remove item. No item with id `{}` found.", id);
}
}
- Cargo::ApplyMatrix((_id, _matrix)) => unimplemented!(),
+ Cargo::ApplyMatrix((id, matrix)) => {
+ if let Some(room) = world.get_room_mut(id) {
+ room.as_non_rigid_mut().unwrap().apply_matrix(&matrix);
+ conn_man.broadcast(Cargo::SetRoom((id, room.clone())));
+ } else if let Some(wall) = world.get_wall_mut(id) {
+ wall.as_non_rigid_mut().unwrap().apply_matrix(&matrix);
+ conn_man.broadcast(Cargo::SetWall((id, wall.clone())));
+ }
+ }
Cargo::AddMapData(_) | Cargo::UpdateMapData(_) => {
error!("This packet is not allowed in the client -> server direction");
}