restore engine message handler
authoralfadur <mail@none>
Tue, 24 Dec 2019 21:57:55 +0300
changeset 15527 428a0e7da27b
parent 15526 24f692e791d3
child 15528 17ad5d43e820
restore engine message handler
rust/hedgewars-server/src/core/server.rs
rust/hedgewars-server/src/handlers/inroom.rs
--- a/rust/hedgewars-server/src/core/server.rs	Tue Dec 24 21:45:26 2019 +0300
+++ b/rust/hedgewars-server/src/core/server.rs	Tue Dec 24 21:57:55 2019 +0300
@@ -1032,6 +1032,17 @@
             None
         }
     }
+
+    pub fn log_engine_msg(&mut self, log_msg: String, sync_msg: Option<Option<String>>) {
+        if let Some(ref mut info) = self.room_mut().game_info {
+            if !log_msg.is_empty() {
+                info.msg_log.push(log_msg);
+            }
+            if let Some(msg) = sync_msg {
+                info.sync_msg = msg;
+            }
+        }
+    }
 }
 
 fn allocate_room(rooms: &mut Slab<HwRoom>) -> &mut HwRoom {
--- a/rust/hedgewars-server/src/handlers/inroom.rs	Tue Dec 24 21:45:26 2019 +0300
+++ b/rust/hedgewars-server/src/handlers/inroom.rs	Tue Dec 24 21:57:55 2019 +0300
@@ -414,7 +414,7 @@
             let result = room_control.start_game();
             super::common::get_start_game_data(room_control.server(), room_id, result, response);
         }
-        /*EngineMessage(em) => {
+        EngineMessage(em) => {
             if client.teams_in_game > 0 {
                 let decoding = decode(&em[..]).unwrap();
                 let messages = by_msg(&decoding);
@@ -438,16 +438,10 @@
                     );
                 }
                 let em_log = encode(&non_empty.flat_map(|msg| msg).cloned().collect::<Vec<_>>());
-                if let Some(ref mut info) = room.game_info {
-                    if !em_log.is_empty() {
-                        info.msg_log.push(em_log);
-                    }
-                    if let Some(msg) = sync_msg {
-                        info.sync_msg = msg;
-                    }
-                }
+
+                room_control.log_engine_msg(em_log, sync_msg);
             }
-        }*/
+        }
         RoundFinished => {
             if let Some(team_names) = room_control.leave_game() {
                 let (client, room) = room_control.get();