gameServer2/src/server/handlers/inroom.rs
changeset 13427 6f6a866c86a2
parent 13426 f091f69d59e4
child 13428 c8425fbcf1d9
--- a/gameServer2/src/server/handlers/inroom.rs	Wed Jun 27 17:58:33 2018 +0300
+++ b/gameServer2/src/server/handlers/inroom.rs	Wed Jun 27 23:26:29 2018 +0300
@@ -239,18 +239,25 @@
                     let decoding = decode(&em[..]).unwrap();
                     let messages = by_msg(&decoding);
                     let valid = messages.clone().filter(|m| is_msg_valid(m, &c.team_indices));
-                    let _non_empty = messages.filter(|m| !is_msg_empty(m));
-                    let _last_valid_timed_msg = valid.clone().scan(None, |res, msg| match msg {
+                    let non_empty = messages.filter(|m| !is_msg_empty(m));
+                    let last_msg = valid.clone().scan(None, |res, msg| match msg {
                         [_, b'+', ..] => Some(msg),
                         [_, typ, ..] if NON_TIMED_MESSAGES.contains(typ) => *res,
                         _ => None
-                    }).next();
+                    }).next().map(|s| encode(s));
 
                     let em_response = encode(&valid.flat_map(|msg| msg).cloned().collect::<Vec<_>>());
                     if !em_response.is_empty() {
                         actions.push(ForwardEngineMessage(em_response)
                             .send_all().in_room(r.id).but_self().action());
                     }
+                    let em_log = encode(&non_empty.flat_map(|msg| msg).cloned().collect::<Vec<_>>());
+                    if let Some(ref mut info) = r.game_info {
+                        info.msg_log.push_str(&em_log);
+                        if last_msg.is_some() {
+                            info.last_msg = last_msg;
+                        }
+                    }
                 }
             }
             server.react(client_id, actions)