gameServer2/src/server/handlers/inroom.rs
changeset 13427 5fb27f94fc3b
parent 13424 81e0ed105f5d
child 13428 87a6cad20c90
--- a/gameServer2/src/server/handlers/inroom.rs	Sun Jun 24 12:09:31 2018 -0400
+++ b/gameServer2/src/server/handlers/inroom.rs	Tue Jun 26 23:22:38 2018 +0300
@@ -40,7 +40,7 @@
                     vec![Warn("A room with the same name already exists.".to_string())]
                 } else {
                     let mut old_name = new_name.clone();
-                    if let (c, Some(r)) = server.client_and_room(client_id) {
+                    if let (_, Some(r)) = server.client_and_room(client_id) {
                         swap(&mut r.name, &mut old_name);
                         vec![SendRoomUpdate(Some(old_name))]
                     } else {
@@ -66,7 +66,7 @@
             };
             server.react(client_id, actions);
         }
-        AddTeam(mut info) => {
+        AddTeam(info) => {
             let mut actions = Vec::new();
             if let (c, Some(r)) = server.client_and_room(client_id) {
                 let room_id = r.id;
@@ -163,6 +163,20 @@
             }
 
             server.react(client_id, actions);
+        },
+        Cfg(cfg) => {
+            let actions = if let (c, Some(r)) = server.client_and_room(client_id) {
+                if !c.is_master {
+                    vec![ProtocolError("You're not the room master!".to_string())]
+                } else {
+                    r.set_config(cfg.clone());
+                    vec![cfg.into_server_msg()
+                        .send_all().in_room(r.id).but_self().action()]
+                }
+            } else {
+                Vec::new()
+            };
+            server.react(client_id, actions);
         }
         _ => warn!("Unimplemented!")
     }