add REPLAY_START support
authoralfadur
Sat, 11 May 2019 00:41:28 +0300
changeset 14907 c156273b57de
parent 14906 8b5d06749026
child 14908 8d63c6ce4f7e
add REPLAY_START support
rust/hedgewars-server/src/protocol/messages.rs
rust/hedgewars-server/src/server/handlers.rs
rust/hedgewars-server/src/server/network.rs
--- a/rust/hedgewars-server/src/protocol/messages.rs	Fri May 10 23:30:42 2019 +0200
+++ b/rust/hedgewars-server/src/protocol/messages.rs	Sat May 11 00:41:28 2019 +0300
@@ -142,6 +142,7 @@
     RunGame,
     ForwardEngineMessage(Vec<String>),
     RoundFinished,
+    ReplayStart,
 
     Info(Vec<String>),
     ServerMessage(String),
@@ -324,6 +325,7 @@
             StartGame => msg!["START_GAME"],
             EngineMessage(msg) => msg!["EM", msg],
             RoundFinished => msg!["ROUNDFINISHED"],
+            ReplayStart => msg!["REPLAY_START"],
             ToggleRestrictJoin => msg!["TOGGLE_RESTRICT_JOINS"],
             ToggleRestrictTeams => msg!["TOGGLE_RESTRICT_TEAMS"],
             ToggleRegisteredOnly => msg!["TOGGLE_REGISTERED_ONLY"],
--- a/rust/hedgewars-server/src/server/handlers.rs	Fri May 10 23:30:42 2019 +0200
+++ b/rust/hedgewars-server/src/server/handlers.rs	Sat May 11 00:41:28 2019 +0300
@@ -347,12 +347,22 @@
             response.remove_client(client_id);
         }
         IoResult::Replay(Some(replay)) => {
-            response.add(RoomJoined(vec![server.clients[client_id].nick.clone()]).send_self());
+            let protocol = server.clients[client_id].protocol_number;
+            let start_msg = if protocol < 58 {
+                RoomJoined(vec![server.clients[client_id].nick.clone()])
+            } else {
+                ReplayStart
+            };
+            response.add(start_msg.send_self());
+
             common::get_room_config_impl(&replay.config, client_id, response);
             common::get_teams(replay.teams.iter(), client_id, response);
             response.add(RunGame.send_self());
             response.add(ForwardEngineMessage(replay.message_log).send_self());
-            response.add(Kicked.send_self());
+
+            if protocol < 58 {
+                response.add(Kicked.send_self());
+            }
         }
         IoResult::Replay(None) => {
             response.add(Warning("Could't load the replay".to_string()).send_self())
--- a/rust/hedgewars-server/src/server/network.rs	Fri May 10 23:30:42 2019 +0200
+++ b/rust/hedgewars-server/src/server/network.rs	Sat May 11 00:41:28 2019 +0300
@@ -492,8 +492,6 @@
     }
 
     pub fn accept_client(&mut self, poll: &Poll, server_token: mio::Token) -> io::Result<()> {
-
-
         match server_token {
             utils::SERVER_TOKEN => {
                 let (client_socket, addr) = self.listener.accept()?;