diff -r 50fcef24003f -r b3adc030104b rust/hedgewars-server/src/server/core.rs --- a/rust/hedgewars-server/src/server/core.rs Wed Apr 10 16:14:33 2019 +0300 +++ b/rust/hedgewars-server/src/server/core.rs Wed Apr 10 18:12:30 2019 +0300 @@ -6,6 +6,7 @@ }; use crate::utils; +use crate::protocol::messages::HWProtocolMessage::Greeting; use log::*; use slab; use std::{borrow::BorrowMut, iter, num::NonZeroU16}; @@ -45,10 +46,26 @@ } } +pub struct ServerGreetings { + pub for_latest_protocol: String, + pub for_old_protocols: String, +} + +impl ServerGreetings { + fn new() -> Self { + Self { + for_latest_protocol: "\u{1f994} is watching".to_string(), + for_old_protocols: "\u{1f994} is watching".to_string(), + } + } +} + pub struct HWServer { pub clients: IndexSlab, pub rooms: Slab, pub anteroom: HWAnteroom, + pub latest_protocol: u16, + pub greetings: ServerGreetings, } impl HWServer { @@ -59,6 +76,8 @@ clients, rooms, anteroom: HWAnteroom::new(clients_limit), + greetings: ServerGreetings::new(), + latest_protocol: 58, } } @@ -74,6 +93,14 @@ self.clients.remove(client_id); } + pub fn get_greetings(&self, client_id: ClientId) -> &str { + if self.clients[client_id].protocol_number < self.latest_protocol { + &self.greetings.for_old_protocols + } else { + &self.greetings.for_latest_protocol + } + } + #[inline] pub fn create_room( &mut self,