# HG changeset patch # User alfadur # Date 1559068112 -10800 # Node ID e935b1ad23f317629765c3a09be348be2ac09d8a # Parent c5a6e85664254169956bb9ca5c304dc773959a43 normalize type names diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/core.rs --- a/rust/hedgewars-server/src/core.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/core.rs Tue May 28 21:28:32 2019 +0300 @@ -1,5 +1,5 @@ -pub mod types; +pub mod client; pub mod indexslab; -pub mod client; pub mod room; -pub mod server; \ No newline at end of file +pub mod server; +pub mod types; diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/core/client.rs --- a/rust/hedgewars-server/src/core/client.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/core/client.rs Tue May 28 21:28:32 2019 +0300 @@ -18,7 +18,7 @@ } } -pub struct HWClient { +pub struct HwClient { pub id: ClientId, pub room_id: Option, pub nick: String, @@ -29,9 +29,9 @@ pub clan: Option, } -impl HWClient { - pub fn new(id: ClientId, protocol_number: u16, nick: String) -> HWClient { - HWClient { +impl HwClient { + pub fn new(id: ClientId, protocol_number: u16, nick: String) -> HwClient { + HwClient { id, nick, protocol_number, diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/core/room.rs --- a/rust/hedgewars-server/src/core/room.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/core/room.rs Tue May 28 21:28:32 2019 +0300 @@ -1,5 +1,5 @@ use super::{ - client::HWClient, + client::HwClient, types::{ ClientId, GameCfg, GameCfg::*, RoomConfig, RoomId, TeamInfo, Voting, MAX_HEDGEHOGS_PER_TEAM, }, @@ -66,7 +66,7 @@ } } -pub struct HWRoom { +pub struct HwRoom { pub id: RoomId, pub master_id: Option, pub name: String, @@ -86,9 +86,9 @@ pub game_info: Option, } -impl HWRoom { - pub fn new(id: RoomId) -> HWRoom { - HWRoom { +impl HwRoom { + pub fn new(id: RoomId) -> HwRoom { + HwRoom { id, master_id: None, name: String::new(), @@ -275,7 +275,7 @@ result } - pub fn info(&self, master: Option<&HWClient>) -> Vec { + pub fn info(&self, master: Option<&HwClient>) -> Vec { let c = &self.config; vec![ self.flags_string(), diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/core/server.rs --- a/rust/hedgewars-server/src/core/server.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/core/server.rs Tue May 28 21:28:32 2019 +0300 @@ -1,13 +1,10 @@ use super::{ - client::HWClient, - types::{ClientId, RoomId}, + client::HwClient, indexslab::IndexSlab, - room::HWRoom, + room::HwRoom, + types::{ClientId, RoomId}, }; -use crate::{ - utils, - protocol::messages::HWProtocolMessage::Greeting -}; +use crate::{protocol::messages::HwProtocolMessage::Greeting, utils}; use bitflags::*; use log::*; @@ -16,25 +13,25 @@ type Slab = slab::Slab; -pub struct HWAnteClient { +pub struct HwAnteClient { pub nick: Option, pub protocol_number: Option, pub server_salt: String, pub is_checker: bool, } -pub struct HWAnteroom { - pub clients: IndexSlab, +pub struct HwAnteroom { + pub clients: IndexSlab, } -impl HWAnteroom { +impl HwAnteroom { pub fn new(clients_limit: usize) -> Self { let clients = IndexSlab::with_capacity(clients_limit); - HWAnteroom { clients } + HwAnteroom { clients } } pub fn add_client(&mut self, client_id: ClientId, salt: String) { - let client = HWAnteClient { + let client = HwAnteClient { nick: None, protocol_number: None, server_salt: salt, @@ -43,7 +40,7 @@ self.clients.insert(client_id, client); } - pub fn remove_client(&mut self, client_id: ClientId) -> Option { + pub fn remove_client(&mut self, client_id: ClientId) -> Option { let mut client = self.clients.remove(client_id); client } @@ -69,32 +66,32 @@ } } -pub struct HWServer { - pub clients: IndexSlab, - pub rooms: Slab, - pub anteroom: HWAnteroom, +pub struct HwServer { + pub clients: IndexSlab, + pub rooms: Slab, + pub anteroom: HwAnteroom, pub latest_protocol: u16, pub flags: ServerFlags, pub greetings: ServerGreetings, } -impl HWServer { +impl HwServer { pub fn new(clients_limit: usize, rooms_limit: usize) -> Self { let rooms = Slab::with_capacity(rooms_limit); let clients = IndexSlab::with_capacity(clients_limit); Self { clients, rooms, - anteroom: HWAnteroom::new(clients_limit), + anteroom: HwAnteroom::new(clients_limit), greetings: ServerGreetings::new(), latest_protocol: 58, flags: ServerFlags::empty(), } } - pub fn add_client(&mut self, client_id: ClientId, data: HWAnteClient) { + pub fn add_client(&mut self, client_id: ClientId, data: HwAnteClient) { if let (Some(protocol), Some(nick)) = (data.protocol_number, data.nick) { - let mut client = HWClient::new(client_id, protocol.get(), nick); + let mut client = HwClient::new(client_id, protocol.get(), nick); client.set_is_checker(data.is_checker); self.clients.insert(client_id, client); } @@ -136,25 +133,25 @@ self.find_room(name).is_some() } - pub fn find_room(&self, name: &str) -> Option<&HWRoom> { + pub fn find_room(&self, name: &str) -> Option<&HwRoom> { self.rooms .iter() .find_map(|(_, r)| Some(r).filter(|r| r.name == name)) } - pub fn find_room_mut(&mut self, name: &str) -> Option<&mut HWRoom> { + pub fn find_room_mut(&mut self, name: &str) -> Option<&mut HwRoom> { self.rooms .iter_mut() .find_map(|(_, r)| Some(r).filter(|r| r.name == name)) } - pub fn find_client(&self, nick: &str) -> Option<&HWClient> { + pub fn find_client(&self, nick: &str) -> Option<&HwClient> { self.clients .iter() .find_map(|(_, c)| Some(c).filter(|c| c.nick == nick)) } - pub fn find_client_mut(&mut self, nick: &str) -> Option<&mut HWClient> { + pub fn find_client_mut(&mut self, nick: &str) -> Option<&mut HwClient> { self.clients .iter_mut() .find_map(|(_, c)| Some(c).filter(|c| c.nick == nick)) @@ -166,28 +163,28 @@ pub fn filter_clients<'a, F>(&'a self, f: F) -> impl Iterator + 'a where - F: Fn(&(usize, &HWClient)) -> bool + 'a, + F: Fn(&(usize, &HwClient)) -> bool + 'a, { self.clients.iter().filter(f).map(|(_, c)| c.id) } pub fn filter_rooms<'a, F>(&'a self, f: F) -> impl Iterator + 'a where - F: Fn(&(usize, &HWRoom)) -> bool + 'a, + F: Fn(&(usize, &HwRoom)) -> bool + 'a, { self.rooms.iter().filter(f).map(|(_, c)| c.id) } pub fn collect_clients(&self, f: F) -> Vec where - F: Fn(&(usize, &HWClient)) -> bool, + F: Fn(&(usize, &HwClient)) -> bool, { self.filter_clients(f).collect() } pub fn collect_nicks(&self, f: F) -> Vec where - F: Fn(&(usize, &HWClient)) -> bool, + F: Fn(&(usize, &HwClient)) -> bool, { self.clients .iter() @@ -226,15 +223,15 @@ } } -fn allocate_room(rooms: &mut Slab) -> &mut HWRoom { +fn allocate_room(rooms: &mut Slab) -> &mut HwRoom { let entry = rooms.vacant_entry(); - let room = HWRoom::new(entry.key()); + let room = HwRoom::new(entry.key()); entry.insert(room) } fn create_room( - client: &mut HWClient, - rooms: &mut Slab, + client: &mut HwClient, + rooms: &mut Slab, name: String, password: Option, ) -> RoomId { @@ -256,7 +253,7 @@ room.id } -fn move_to_room(client: &mut HWClient, room: &mut HWRoom) { +fn move_to_room(client: &mut HwClient, room: &mut HwRoom) { debug_assert!(client.room_id != Some(room.id)); room.players_number += 1; diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/handlers.rs --- a/rust/hedgewars-server/src/handlers.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/handlers.rs Tue May 28 21:28:32 2019 +0300 @@ -3,21 +3,17 @@ use self::{ actions::{Destination, DestinationGroup, PendingMessage}, - inanteroom::LoginResult + inanteroom::LoginResult, }; use crate::{ core::{ - server::HWServer, - types::{ClientId, Replay, RoomId, GameCfg, TeamInfo}, - room::RoomSave + room::RoomSave, + server::HwServer, + types::{ClientId, GameCfg, Replay, RoomId, TeamInfo}, }, protocol::messages::{ - server_chat, - HWProtocolMessage, - HWServerMessage, - HWServerMessage::*, - global_chat, - HWProtocolMessage::EngineMessage + global_chat, server_chat, HwProtocolMessage, HwProtocolMessage::EngineMessage, + HwServerMessage, HwServerMessage::*, }, utils, }; @@ -28,9 +24,9 @@ mod actions; mod checker; mod common; -mod inroom; +mod inanteroom; mod inlobby; -mod inanteroom; +mod inroom; use std::fmt::{Formatter, LowerHex}; @@ -132,8 +128,8 @@ pub fn extract_messages<'a, 'b: 'a>( &'b mut self, - server: &'a HWServer, - ) -> impl Iterator, HWServerMessage)> + 'a { + server: &'a HwServer, + ) -> impl Iterator, HwServerMessage)> + 'a { let client_id = self.client_id; self.messages.drain(..).map(move |m| { let ids = get_recipients(server, client_id, m.destination); @@ -163,7 +159,7 @@ } fn get_recipients( - server: &HWServer, + server: &HwServer, client_id: ClientId, destination: Destination, ) -> Vec { @@ -191,13 +187,13 @@ } pub fn handle( - server: &mut HWServer, + server: &mut HwServer, client_id: ClientId, response: &mut Response, - message: HWProtocolMessage, + message: HwProtocolMessage, ) { match message { - HWProtocolMessage::Ping => response.add(Pong.send_self()), + HwProtocolMessage::Ping => response.add(Pong.send_self()), _ => { if server.anteroom.clients.contains(client_id) { match inanteroom::handle(server, client_id, response, message) { @@ -215,13 +211,13 @@ } } else if server.clients.contains(client_id) { match message { - HWProtocolMessage::Quit(Some(msg)) => { + HwProtocolMessage::Quit(Some(msg)) => { common::remove_client(server, response, "User quit: ".to_string() + &msg); } - HWProtocolMessage::Quit(None) => { + HwProtocolMessage::Quit(None) => { common::remove_client(server, response, "User quit".to_string()); } - HWProtocolMessage::Info(nick) => { + HwProtocolMessage::Info(nick) => { if let Some(client) = server.find_client(&nick) { let admin_sign = if client.is_admin() { "@" } else { "" }; let master_sign = if client.is_master() { "+" } else { "" }; @@ -253,7 +249,7 @@ .add(server_chat("Player is not online.".to_string()).send_self()) } } - HWProtocolMessage::ToggleServerRegisteredOnly => { + HwProtocolMessage::ToggleServerRegisteredOnly => { if !server.clients[client_id].is_admin() { response.add(Warning("Access denied.".to_string()).send_self()); } else { @@ -266,14 +262,14 @@ response.add(server_chat(msg.to_string()).send_all()); } } - HWProtocolMessage::Global(msg) => { + HwProtocolMessage::Global(msg) => { if !server.clients[client_id].is_admin() { response.add(Warning("Access denied.".to_string()).send_self()); } else { response.add(global_chat(msg).send_all()) } } - HWProtocolMessage::SuperPower => { + HwProtocolMessage::SuperPower => { if !server.clients[client_id].is_admin() { response.add(Warning("Access denied.".to_string()).send_self()); } else { @@ -282,7 +278,7 @@ .add(server_chat("Super power activated.".to_string()).send_self()) } } - HWProtocolMessage::Watch(id) => { + HwProtocolMessage::Watch(id) => { #[cfg(feature = "official-server")] { response.request_io(IoTask::GetReplay { id }) @@ -308,23 +304,23 @@ } } -pub fn handle_client_accept(server: &mut HWServer, client_id: ClientId, response: &mut Response) { +pub fn handle_client_accept(server: &mut HwServer, client_id: ClientId, response: &mut Response) { let mut salt = [0u8; 18]; thread_rng().fill_bytes(&mut salt); server.anteroom.add_client(client_id, encode(&salt)); - response.add(HWServerMessage::Connected(utils::SERVER_VERSION).send_self()); + response.add(HwServerMessage::Connected(utils::SERVER_VERSION).send_self()); } -pub fn handle_client_loss(server: &mut HWServer, client_id: ClientId, response: &mut Response) { +pub fn handle_client_loss(server: &mut HwServer, client_id: ClientId, response: &mut Response) { if server.anteroom.remove_client(client_id).is_none() { common::remove_client(server, response, "Connection reset".to_string()); } } pub fn handle_io_result( - server: &mut HWServer, + server: &mut HwServer, client_id: ClientId, response: &mut Response, io_result: IoResult, diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/handlers/actions.rs --- a/rust/hedgewars-server/src/handlers/actions.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/handlers/actions.rs Tue May 28 21:28:32 2019 +0300 @@ -1,12 +1,12 @@ use crate::{ core::{ - client::HWClient, - server::HWServer, + client::HwClient, + room::HwRoom, + room::{GameInfo, RoomFlags}, + server::HwServer, types::{ClientId, GameCfg, RoomId, VoteType}, - room::HWRoom, - room::{GameInfo, RoomFlags} }, - protocol::messages::{server_chat, HWProtocolMessage, HWServerMessage, HWServerMessage::*}, + protocol::messages::{server_chat, HwProtocolMessage, HwServerMessage, HwServerMessage::*}, utils::to_engine_msg, }; use rand::{distributions::Uniform, thread_rng, Rng}; @@ -31,32 +31,32 @@ pub struct PendingMessage { pub destination: Destination, - pub message: HWServerMessage, + pub message: HwServerMessage, } impl PendingMessage { - pub fn send(message: HWServerMessage, client_id: ClientId) -> PendingMessage { + pub fn send(message: HwServerMessage, client_id: ClientId) -> PendingMessage { PendingMessage { destination: Destination::ToId(client_id), message, } } - pub fn send_many(message: HWServerMessage, client_ids: Vec) -> PendingMessage { + pub fn send_many(message: HwServerMessage, client_ids: Vec) -> PendingMessage { PendingMessage { destination: Destination::ToIds(client_ids), message, } } - pub fn send_self(message: HWServerMessage) -> PendingMessage { + pub fn send_self(message: HwServerMessage) -> PendingMessage { PendingMessage { destination: Destination::ToSelf, message, } } - pub fn send_all(message: HWServerMessage) -> PendingMessage { + pub fn send_all(message: HwServerMessage) -> PendingMessage { let destination = Destination::ToAll { group: DestinationGroup::All, skip_self: false, @@ -99,7 +99,7 @@ } } -impl HWServerMessage { +impl HwServerMessage { pub fn send(self, client_id: ClientId) -> PendingMessage { PendingMessage::send(self, client_id) } diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/handlers/checker.rs --- a/rust/hedgewars-server/src/handlers/checker.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/handlers/checker.rs Tue May 28 21:28:32 2019 +0300 @@ -2,11 +2,11 @@ use mio; use crate::{ - protocol::messages::HWProtocolMessage, - core::{server::HWServer, types::ClientId}, + core::{server::HwServer, types::ClientId}, + protocol::messages::HwProtocolMessage, }; -pub fn handle(_server: &mut HWServer, _client_id: ClientId, message: HWProtocolMessage) { +pub fn handle(_server: &mut HwServer, _client_id: ClientId, message: HwProtocolMessage) { match message { _ => warn!("Unknown command"), } diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/handlers/common.rs --- a/rust/hedgewars-server/src/handlers/common.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/handlers/common.rs Tue May 28 21:28:32 2019 +0300 @@ -1,17 +1,16 @@ use crate::{ + core::{ + client::HwClient, + room::HwRoom, + server::HwServer, + types::{ClientId, GameCfg, RoomId, TeamInfo, Vote, VoteType}, + }, protocol::messages::{ - server_chat, - add_flags, remove_flags, - HWProtocolMessage::{self, Rnd}, - HWServerMessage::{self, *}, + add_flags, remove_flags, server_chat, + HwProtocolMessage::{self, Rnd}, + HwServerMessage::{self, *}, ProtocolFlags as Flags, }, - core::{ - client::HWClient, - server::HWServer, - types::{ClientId, GameCfg, RoomId, TeamInfo, Vote, VoteType}, - room::HWRoom, - }, utils::to_engine_msg, }; @@ -21,7 +20,7 @@ use rand::{self, seq::SliceRandom, thread_rng, Rng}; use std::{iter::once, mem::replace}; -pub fn rnd_reply(options: &[String]) -> HWServerMessage { +pub fn rnd_reply(options: &[String]) -> HwServerMessage { let mut rng = thread_rng(); let reply = if options.is_empty() { @@ -36,7 +35,7 @@ } } -pub fn join_lobby(server: &mut HWServer, response: &mut Response) { +pub fn join_lobby(server: &mut HwServer, response: &mut Response) { let client_id = response.client_id(); let client = &server.clients[client_id]; @@ -100,7 +99,7 @@ } pub fn remove_teams( - room: &mut HWRoom, + room: &mut HwRoom, team_names: Vec, is_in_game: bool, response: &mut Response, @@ -144,8 +143,8 @@ } fn remove_client_from_room( - client: &mut HWClient, - room: &mut HWRoom, + client: &mut HwClient, + room: &mut HwRoom, response: &mut Response, msg: &str, ) { @@ -197,7 +196,7 @@ } pub fn change_master( - server: &mut HWServer, + server: &mut HwServer, room_id: RoomId, new_master_id: ClientId, response: &mut Response, @@ -229,7 +228,7 @@ } pub fn enter_room( - server: &mut HWServer, + server: &mut HwServer, client_id: ClientId, room_id: RoomId, response: &mut Response, @@ -271,7 +270,7 @@ } } -pub fn exit_room(server: &mut HWServer, client_id: ClientId, response: &mut Response, msg: &str) { +pub fn exit_room(server: &mut HwServer, client_id: ClientId, response: &mut Response, msg: &str) { let client = &mut server.clients[client_id]; if let Some(room_id) = client.room_id { @@ -309,7 +308,7 @@ } } -pub fn remove_client(server: &mut HWServer, response: &mut Response, msg: String) { +pub fn remove_client(server: &mut HwServer, response: &mut Response, msg: String) { let client_id = response.client_id(); let client = &mut server.clients[client_id]; let nick = client.nick.clone(); @@ -325,8 +324,8 @@ pub fn get_room_update( room_name: Option, - room: &HWRoom, - master: Option<&HWClient>, + room: &HwRoom, + master: Option<&HwClient>, response: &mut Response, ) { let update_msg = RoomUpdated(room_name.unwrap_or(room.name.clone()), room.info(master)); @@ -340,7 +339,7 @@ } } -pub fn get_room_config(room: &HWRoom, to_client: ClientId, response: &mut Response) { +pub fn get_room_config(room: &HwRoom, to_client: ClientId, response: &mut Response) { get_room_config_impl(room.active_config(), to_client, response); } @@ -356,7 +355,7 @@ } pub fn get_room_teams( - server: &HWServer, + server: &HwServer, room_id: RoomId, to_client: ClientId, response: &mut Response, @@ -371,7 +370,7 @@ } pub fn get_room_flags( - server: &HWServer, + server: &HwServer, room_id: RoomId, to_client: ClientId, response: &mut Response, @@ -398,7 +397,7 @@ } pub fn apply_voting_result( - server: &mut HWServer, + server: &mut HwServer, room_id: RoomId, response: &mut Response, kind: VoteType, @@ -470,7 +469,7 @@ } } -fn add_vote(room: &mut HWRoom, response: &mut Response, vote: Vote) -> Option { +fn add_vote(room: &mut HwRoom, response: &mut Response, vote: Vote) -> Option { let client_id = response.client_id; let mut result = None; @@ -498,7 +497,7 @@ result } -pub fn submit_vote(server: &mut HWServer, vote: Vote, response: &mut Response) { +pub fn submit_vote(server: &mut HwServer, vote: Vote, response: &mut Response) { let client_id = response.client_id; let client = &server.clients[client_id]; @@ -519,7 +518,7 @@ } } -pub fn start_game(server: &mut HWServer, room_id: RoomId, response: &mut Response) { +pub fn start_game(server: &mut HwServer, room_id: RoomId, response: &mut Response) { let (room_clients, room_nicks): (Vec<_>, Vec<_>) = server .clients .iter() @@ -558,7 +557,7 @@ } } -pub fn end_game(server: &mut HWServer, room_id: RoomId, response: &mut Response) { +pub fn end_game(server: &mut HwServer, room_id: RoomId, response: &mut Response) { let room = &mut server.rooms[room_id]; room.ready_players_number = 1; let room_master = if let Some(id) = room.master_id { @@ -613,10 +612,10 @@ #[cfg(test)] mod tests { use super::*; - use crate::protocol::messages::HWServerMessage::ChatMsg; + use crate::protocol::messages::HwServerMessage::ChatMsg; use crate::server::actions::PendingMessage; - fn reply2string(r: HWServerMessage) -> String { + fn reply2string(r: HwServerMessage) -> String { match r { ChatMsg { msg: p, .. } => String::from(p), _ => panic!("expected a ChatMsg"), diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/handlers/inanteroom.rs --- a/rust/hedgewars-server/src/handlers/inanteroom.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/handlers/inanteroom.rs Tue May 28 21:28:32 2019 +0300 @@ -1,16 +1,13 @@ use mio; use crate::{ - protocol::messages::{ - HWProtocolMessage::LoadRoom, - HWProtocolMessage, - HWServerMessage::*}, core::{ - client::HWClient, - server::{HWServer, HWAnteClient, HWAnteroom}, - types::ClientId + client::HwClient, + server::{HwAnteClient, HwAnteroom, HwServer}, + types::ClientId, }, - utils::is_name_illegal + protocol::messages::{HwProtocolMessage, HwProtocolMessage::LoadRoom, HwServerMessage::*}, + utils::is_name_illegal, }; use log::*; @@ -29,11 +26,11 @@ fn completion_result<'a, I>( mut other_clients: I, - client: &mut HWAnteClient, + client: &mut HwAnteClient, response: &mut super::Response, ) -> LoginResult where - I: Iterator, + I: Iterator, { let has_nick_clash = other_clients.any(|(_, c)| !c.is_checker() && c.nick == *client.nick.as_ref().unwrap()); @@ -62,17 +59,17 @@ } pub fn handle( - server: &mut HWServer, + server: &mut HwServer, client_id: ClientId, response: &mut super::Response, - message: HWProtocolMessage, + message: HwProtocolMessage, ) -> LoginResult { match message { - HWProtocolMessage::Quit(_) => { + HwProtocolMessage::Quit(_) => { response.add(Bye("User quit".to_string()).send_self()); LoginResult::Exit } - HWProtocolMessage::Nick(nick) => { + HwProtocolMessage::Nick(nick) => { let client = &mut server.anteroom.clients[client_id]; if client.nick.is_some() { @@ -92,7 +89,7 @@ } } } - HWProtocolMessage::Proto(proto) => { + HwProtocolMessage::Proto(proto) => { let client = &mut server.anteroom.clients[client_id]; if client.protocol_number.is_some() { response.add(Error("Protocol already known.".to_string()).send_self()); @@ -112,7 +109,7 @@ } } #[cfg(feature = "official-server")] - HWProtocolMessage::Password(hash, salt) => { + HwProtocolMessage::Password(hash, salt) => { let client = &server.anteroom.clients[client_id]; if let (Some(nick), Some(protocol)) = (client.nick.as_ref(), client.protocol_number) { @@ -128,7 +125,7 @@ LoginResult::Unchanged } #[cfg(feature = "official-server")] - HWProtocolMessage::Checker(protocol, nick, password) => { + HwProtocolMessage::Checker(protocol, nick, password) => { let client = &mut server.anteroom.clients[client_id]; if protocol == 0 { response.add(Error("Bad number.".to_string()).send_self()); diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/handlers/inlobby.rs --- a/rust/hedgewars-server/src/handlers/inlobby.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/handlers/inlobby.rs Tue May 28 21:28:32 2019 +0300 @@ -2,14 +2,14 @@ use super::common::rnd_reply; use crate::{ - protocol::messages::{ - add_flags, remove_flags, server_chat, HWProtocolMessage, HWServerMessage::*, - ProtocolFlags as Flags, + core::{ + client::HwClient, + server::HwServer, + types::{ClientId, ServerVar}, }, - core::{ - client::HWClient, - server::HWServer, - types::{ClientId, ServerVar}, + protocol::messages::{ + add_flags, remove_flags, server_chat, HwProtocolMessage, HwServerMessage::*, + ProtocolFlags as Flags, }, utils::is_name_illegal, }; @@ -17,12 +17,12 @@ use std::{collections::HashSet, convert::identity}; pub fn handle( - server: &mut HWServer, + server: &mut HwServer, client_id: ClientId, response: &mut super::Response, - message: HWProtocolMessage, + message: HwProtocolMessage, ) { - use crate::protocol::messages::HWProtocolMessage::*; + use crate::protocol::messages::HwProtocolMessage::*; match message { CreateRoom(name, password) => { if is_name_illegal(&name) { @@ -94,7 +94,7 @@ } } Follow(nick) => { - if let Some(HWClient { + if let Some(HwClient { room_id: Some(room_id), .. }) = server.find_client(&nick) diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/handlers/inroom.rs --- a/rust/hedgewars-server/src/handlers/inroom.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/handlers/inroom.rs Tue May 28 21:28:32 2019 +0300 @@ -3,15 +3,15 @@ use super::common::rnd_reply; use crate::utils::to_engine_msg; use crate::{ - protocol::messages::{ - add_flags, remove_flags, server_chat, HWProtocolMessage, HWServerMessage::*, - ProtocolFlags as Flags, - }, core::{ - server::HWServer, + room::{HwRoom, RoomFlags, MAX_TEAMS_IN_ROOM}, + server::HwServer, types, types::{ClientId, GameCfg, RoomId, VoteType, Voting, MAX_HEDGEHOGS_PER_TEAM}, - room::{HWRoom, RoomFlags, MAX_TEAMS_IN_ROOM}, + }, + protocol::messages::{ + add_flags, remove_flags, server_chat, HwProtocolMessage, HwServerMessage::*, + ProtocolFlags as Flags, }, utils::is_name_illegal, }; @@ -93,8 +93,8 @@ ) } -fn room_message_flag(msg: &HWProtocolMessage) -> RoomFlags { - use crate::protocol::messages::HWProtocolMessage::*; +fn room_message_flag(msg: &HwProtocolMessage) -> RoomFlags { + use crate::protocol::messages::HwProtocolMessage::*; match msg { ToggleRestrictJoin => RoomFlags::RESTRICTED_JOIN, ToggleRestrictTeams => RoomFlags::RESTRICTED_TEAM_ADD, @@ -104,16 +104,16 @@ } pub fn handle( - server: &mut HWServer, + server: &mut HwServer, client_id: ClientId, response: &mut super::Response, room_id: RoomId, - message: HWProtocolMessage, + message: HwProtocolMessage, ) { let client = &mut server.clients[client_id]; let room = &mut server.rooms[room_id]; - use crate::protocol::messages::HWProtocolMessage::*; + use crate::protocol::messages::HwProtocolMessage::*; match message { Part(msg) => { let msg = match msg { diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/main.rs --- a/rust/hedgewars-server/src/main.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/main.rs Tue May 28 21:28:32 2019 +0300 @@ -7,8 +7,8 @@ use std::{env, str::FromStr as _, time::Duration}; mod core; +mod handlers; mod protocol; -mod handlers; mod server; mod utils; diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/protocol.rs --- a/rust/hedgewars-server/src/protocol.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/protocol.rs Tue May 28 21:28:32 2019 +0300 @@ -44,7 +44,7 @@ Ok(count) } - pub fn extract_messages(&mut self) -> Vec { + pub fn extract_messages(&mut self) -> Vec { let mut messages = vec![]; if !self.is_recovering { loop { diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/protocol/messages.rs --- a/rust/hedgewars-server/src/protocol/messages.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/protocol/messages.rs Tue May 28 21:28:32 2019 +0300 @@ -2,7 +2,7 @@ use std::{convert::From, iter::once, ops}; #[derive(PartialEq, Eq, Clone, Debug)] -pub enum HWProtocolMessage { +pub enum HwProtocolMessage { // common messages Ping, Pong, @@ -108,7 +108,7 @@ } #[derive(Debug)] -pub enum HWServerMessage { +pub enum HwServerMessage { Connected(u32), Redirect(u16), @@ -156,18 +156,18 @@ LegacyReady(bool, Vec), } -fn special_chat(nick: &str, msg: String) -> HWServerMessage { - HWServerMessage::ChatMsg { +fn special_chat(nick: &str, msg: String) -> HwServerMessage { + HwServerMessage::ChatMsg { nick: nick.to_string(), msg, } } -pub fn server_chat(msg: String) -> HWServerMessage { +pub fn server_chat(msg: String) -> HwServerMessage { special_chat("[server]", msg) } -pub fn global_chat(msg: String) -> HWServerMessage { +pub fn global_chat(msg: String) -> HwServerMessage { special_chat("(global notice)", msg) } @@ -206,10 +206,10 @@ } } - pub fn to_server_msg(&self) -> HWServerMessage { - use self::HWServerMessage::ConfigEntry; + pub fn to_server_msg(&self) -> HwServerMessage { + use self::HwServerMessage::ConfigEntry; let (name, args) = self.to_protocol(); - HWServerMessage::ConfigEntry(name, args) + HwServerMessage::ConfigEntry(name, args) } } @@ -251,14 +251,14 @@ [$part: expr, $($other: expr),*] => { once($part).chain(several![$($other),*]) }; } -impl HWProtocolMessage { +impl HwProtocolMessage { /** Converts the message to a raw `String`, which can be sent over the network. * * This is the inverse of the `message` parser. */ #[cfg(test)] pub(crate) fn to_raw_protocol(&self) -> String { - use self::HWProtocolMessage::*; + use self::HwProtocolMessage::*; match self { Ping => msg!["PING"], Pong => msg!["PONG"], @@ -355,9 +355,9 @@ v.join("\n") } -impl HWServerMessage { +impl HwServerMessage { pub fn to_raw_protocol(&self) -> String { - use self::HWServerMessage::*; + use self::HwServerMessage::*; match self { Ping => msg!["PING"], Pong => msg!["PONG"], diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/protocol/parser.rs --- a/rust/hedgewars-server/src/protocol/parser.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/protocol/parser.rs Tue May 28 21:28:32 2019 +0300 @@ -14,58 +14,56 @@ str::{FromStr, Utf8Error}, }; -use super::{ - messages::{HWProtocolMessage, HWProtocolMessage::*}, -}; +use super::messages::{HwProtocolMessage, HwProtocolMessage::*}; use crate::core::types::{ GameCfg, HedgehogInfo, ServerVar, TeamInfo, VoteType, MAX_HEDGEHOGS_PER_TEAM, }; #[derive(Debug, PartialEq)] -pub struct HWProtocolError {} +pub struct HwProtocolError {} -impl HWProtocolError { +impl HwProtocolError { fn new() -> Self { - HWProtocolError {} + HwProtocolError {} } } -impl ParseError for HWProtocolError { +impl ParseError for HwProtocolError { fn from_error_kind(input: I, kind: ErrorKind) -> Self { - HWProtocolError::new() + HwProtocolError::new() } fn append(input: I, kind: ErrorKind, other: Self) -> Self { - HWProtocolError::new() + HwProtocolError::new() } } -impl From for HWProtocolError { +impl From for HwProtocolError { fn from(_: Utf8Error) -> Self { - HWProtocolError::new() + HwProtocolError::new() } } -impl From for HWProtocolError { +impl From for HwProtocolError { fn from(_: ParseIntError) -> Self { - HWProtocolError::new() + HwProtocolError::new() } } -pub type HWResult<'a, O> = IResult<&'a [u8], O, HWProtocolError>; +pub type HwResult<'a, O> = IResult<&'a [u8], O, HwProtocolError>; -fn end_of_message(input: &[u8]) -> HWResult<&[u8]> { +fn end_of_message(input: &[u8]) -> HwResult<&[u8]> { tag("\n\n")(input) } -fn convert_utf8(input: &[u8]) -> HWResult<&str> { +fn convert_utf8(input: &[u8]) -> HwResult<&str> { match str::from_utf8(input) { Ok(str) => Ok((b"", str)), Err(utf_err) => Result::Err(Err::Failure(utf_err.into())), } } -fn convert_from_str(str: &str) -> HWResult +fn convert_from_str(str: &str) -> HwResult where T: FromStr, { @@ -75,72 +73,72 @@ } } -fn str_line(input: &[u8]) -> HWResult<&str> { +fn str_line(input: &[u8]) -> HwResult<&str> { let (i, text) = not_line_ending(input)?; Ok((i, convert_utf8(text)?.1)) } -fn a_line(input: &[u8]) -> HWResult { +fn a_line(input: &[u8]) -> HwResult { let (i, str) = str_line(input)?; Ok((i, str.to_string())) } -fn hw_tag<'a>(tag_str: &'a str) -> impl Fn(&'a [u8]) -> HWResult<'a, ()> { +fn hw_tag<'a>(tag_str: &'a str) -> impl Fn(&'a [u8]) -> HwResult<'a, ()> { move |i| tag(tag_str)(i).map(|(i, _)| (i, ())) } -fn hw_tag_no_case<'a>(tag_str: &'a str) -> impl Fn(&'a [u8]) -> HWResult<'a, ()> { +fn hw_tag_no_case<'a>(tag_str: &'a str) -> impl Fn(&'a [u8]) -> HwResult<'a, ()> { move |i| tag_no_case(tag_str)(i).map(|(i, _)| (i, ())) } -fn cmd_arg(input: &[u8]) -> HWResult { +fn cmd_arg(input: &[u8]) -> HwResult { let delimiters = b" \n"; let (i, str) = take_while(move |c| !delimiters.contains(&c))(input)?; Ok((i, convert_utf8(str)?.1.to_string())) } -fn u8_line(input: &[u8]) -> HWResult { +fn u8_line(input: &[u8]) -> HwResult { let (i, str) = str_line(input)?; Ok((i, convert_from_str(str)?.1)) } -fn u16_line(input: &[u8]) -> HWResult { +fn u16_line(input: &[u8]) -> HwResult { let (i, str) = str_line(input)?; Ok((i, convert_from_str(str)?.1)) } -fn u32_line(input: &[u8]) -> HWResult { +fn u32_line(input: &[u8]) -> HwResult { let (i, str) = str_line(input)?; Ok((i, convert_from_str(str)?.1)) } -fn yes_no_line(input: &[u8]) -> HWResult { +fn yes_no_line(input: &[u8]) -> HwResult { alt(( |i| tag_no_case(b"YES")(i).map(|(i, _)| (i, true)), |i| tag_no_case(b"NO")(i).map(|(i, _)| (i, false)), ))(input) } -fn opt_arg<'a>(input: &'a [u8]) -> HWResult<'a, Option> { +fn opt_arg<'a>(input: &'a [u8]) -> HwResult<'a, Option> { alt(( |i: &'a [u8]| peek!(i, end_of_message).map(|(i, _)| (i, None)), |i| precededc(i, hw_tag("\n"), a_line).map(|(i, v)| (i, Some(v))), ))(input) } -fn spaces(input: &[u8]) -> HWResult<&[u8]> { +fn spaces(input: &[u8]) -> HwResult<&[u8]> { precededc(input, hw_tag(" "), |i| take_while(|c| c == b' ')(i)) } -fn opt_space_arg<'a>(input: &'a [u8]) -> HWResult<'a, Option> { +fn opt_space_arg<'a>(input: &'a [u8]) -> HwResult<'a, Option> { alt(( |i: &'a [u8]| peek!(i, end_of_message).map(|(i, _)| (i, None)), |i| precededc(i, spaces, a_line).map(|(i, v)| (i, Some(v))), ))(input) } -fn hedgehog_array(input: &[u8]) -> HWResult<[HedgehogInfo; 8]> { - fn hedgehog_line(input: &[u8]) -> HWResult { +fn hedgehog_array(input: &[u8]) -> HwResult<[HedgehogInfo; 8]> { + fn hedgehog_line(input: &[u8]) -> HwResult { let (i, name) = terminatedc(input, a_line, eol)?; let (i, hat) = a_line(i)?; Ok((i, HedgehogInfo { name, hat })) @@ -158,7 +156,7 @@ Ok((i, [h1, h2, h3, h4, h5, h6, h7, h8])) } -fn voting(input: &[u8]) -> HWResult { +fn voting(input: &[u8]) -> HwResult { alt(( |i| tag_no_case("PAUSE")(i).map(|(i, _)| (i, VoteType::Pause)), |i| tag_no_case("NEWSEED")(i).map(|(i, _)| (i, VoteType::NewSeed)), @@ -178,12 +176,12 @@ ))(input) } -fn no_arg_message(input: &[u8]) -> HWResult { +fn no_arg_message(input: &[u8]) -> HwResult { fn messagec<'a>( input: &'a [u8], name: &'a str, - msg: HWProtocolMessage, - ) -> HWResult<'a, HWProtocolMessage> { + msg: HwProtocolMessage, + ) -> HwResult<'a, HwProtocolMessage> { tag(name)(input).map(|(i, _)| (i, msg.clone())) } @@ -201,16 +199,16 @@ ))(input) } -fn single_arg_message(input: &[u8]) -> HWResult { +fn single_arg_message(input: &[u8]) -> HwResult { fn messagec<'a, T, F, G>( input: &'a [u8], name: &'a str, parser: F, constructor: G, - ) -> HWResult<'a, HWProtocolMessage> + ) -> HwResult<'a, HwProtocolMessage> where - F: Fn(&[u8]) -> HWResult, - G: Fn(T) -> HWProtocolMessage, + F: Fn(&[u8]) -> HwResult, + G: Fn(T) -> HwProtocolMessage, { precededc(input, hw_tag(name), parser).map(|(i, v)| (i, constructor(v))) } @@ -233,12 +231,12 @@ ))(input) } -fn cmd_message<'a>(input: &'a [u8]) -> HWResult<'a, HWProtocolMessage> { +fn cmd_message<'a>(input: &'a [u8]) -> HwResult<'a, HwProtocolMessage> { fn cmdc_no_arg<'a>( input: &'a [u8], name: &'a str, - msg: HWProtocolMessage, - ) -> HWResult<'a, HWProtocolMessage> { + msg: HwProtocolMessage, + ) -> HwResult<'a, HwProtocolMessage> { tag_no_case(name)(input).map(|(i, _)| (i, msg.clone())) } @@ -247,16 +245,16 @@ name: &'a str, parser: F, constructor: G, - ) -> HWResult<'a, HWProtocolMessage> + ) -> HwResult<'a, HwProtocolMessage> where - F: Fn(&'a [u8]) -> HWResult<'a, T>, - G: Fn(T) -> HWProtocolMessage, + F: Fn(&'a [u8]) -> HwResult<'a, T>, + G: Fn(T) -> HwProtocolMessage, { precededc(input, |i| pairc(i, hw_tag_no_case(name), spaces), parser) .map(|(i, v)| (i, constructor(v))) } - fn cmd_no_arg_message(input: &[u8]) -> HWResult { + fn cmd_no_arg_message(input: &[u8]) -> HwResult { alt(( |i| cmdc_no_arg(i, "STATS", Stats), |i| cmdc_no_arg(i, "FIX", Fix), @@ -266,7 +264,7 @@ ))(input) } - fn cmd_single_arg_message(input: &[u8]) -> HWResult { + fn cmd_single_arg_message(input: &[u8]) -> HwResult { alt(( |i| cmdc_single_arg(i, "RESTART_SERVER", |i| tag("YES")(i), |_| RestartServer), |i| cmdc_single_arg(i, "DELEGATE", a_line, Delegate), @@ -312,15 +310,15 @@ ) } -fn config_message<'a>(input: &'a [u8]) -> HWResult<'a, HWProtocolMessage> { +fn config_message<'a>(input: &'a [u8]) -> HwResult<'a, HwProtocolMessage> { fn cfgc_single_arg<'a, T, F, G>( input: &'a [u8], name: &'a str, parser: F, constructor: G, - ) -> HWResult<'a, GameCfg> + ) -> HwResult<'a, GameCfg> where - F: Fn(&[u8]) -> HWResult, + F: Fn(&[u8]) -> HwResult, G: Fn(T) -> GameCfg, { precededc(input, |i| terminatedc(i, hw_tag(name), eol), parser) @@ -373,7 +371,7 @@ Ok((i, Cfg(cfg))) } -fn server_var_message(input: &[u8]) -> HWResult { +fn server_var_message(input: &[u8]) -> HwResult { precededc( input, hw_tag("SET_SERVER_VAR\n"), @@ -394,7 +392,7 @@ ) } -fn complex_message(input: &[u8]) -> HWResult { +fn complex_message(input: &[u8]) -> HwResult { alt(( |i| { precededc( @@ -533,12 +531,12 @@ ))(input) } -pub fn malformed_message(input: &[u8]) -> HWResult<()> { +pub fn malformed_message(input: &[u8]) -> HwResult<()> { let (i, _) = terminatedc(input, |i| take_until(&b"\n\n"[..])(i), end_of_message)?; Ok((i, ())) } -pub fn message(input: &[u8]) -> HWResult { +pub fn message(input: &[u8]) -> HwResult { precededc( input, |i| take_while(|c| c == b'\n')(i), @@ -559,15 +557,15 @@ ) } -fn extract_messages(input: &[u8]) -> HWResult> { +fn extract_messages(input: &[u8]) -> HwResult> { many0(message)(input) } #[cfg(test)] mod test { use super::{extract_messages, message}; - use crate::protocol::parser::HWProtocolError; - use crate::protocol::{messages::HWProtocolMessage::*, test::gen_proto_msg}; + use crate::protocol::parser::HwProtocolError; + use crate::protocol::{messages::HwProtocolMessage::*, test::gen_proto_msg}; use proptest::{proptest, proptest_helper}; #[cfg(test)] @@ -616,7 +614,7 @@ assert_eq!( message(b"QUIT\n1\n2\n\n"), - Err(nom::Err::Error(HWProtocolError::new())) + Err(nom::Err::Error(HwProtocolError::new())) ); assert_eq!( diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/protocol/test.rs --- a/rust/hedgewars-server/src/protocol/test.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/protocol/test.rs Tue May 28 21:28:32 2019 +0300 @@ -6,7 +6,7 @@ use crate::core::types::{GameCfg, HedgehogInfo, ServerVar, ServerVar::*, TeamInfo}; -use super::messages::{HWProtocolMessage, HWProtocolMessage::*}; +use super::messages::{HwProtocolMessage, HwProtocolMessage::*}; // Due to inability to define From between Options trait Into2: Sized { @@ -166,7 +166,7 @@ type Strategy = BoxedStrategy; } -pub fn gen_proto_msg() -> BoxedStrategy where { +pub fn gen_proto_msg() -> BoxedStrategy where { let res = (0..=55).no_shrink().prop_flat_map(|i| { proto_msg_match!(i, def = Ping, 0 => Ping(), diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/server.rs --- a/rust/hedgewars-server/src/server.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/server.rs Tue May 28 21:28:32 2019 +0300 @@ -2,4 +2,4 @@ mod database; #[cfg(feature = "official-server")] pub mod io; -pub mod network; \ No newline at end of file +pub mod network; diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/server/database.rs --- a/rust/hedgewars-server/src/server/database.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/server/database.rs Tue May 28 21:28:32 2019 +0300 @@ -2,9 +2,7 @@ use mysql::{error::DriverError, error::Error, from_row_opt, params}; use openssl::sha::sha1; -use crate::{ - handlers::{Sha1Digest, AccountInfo} -}; +use crate::handlers::{AccountInfo, Sha1Digest}; const GET_ACCOUNT_QUERY: &str = r"SELECT CASE WHEN users.status = 1 THEN users.pass ELSE '' END, diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/server/io.rs --- a/rust/hedgewars-server/src/server/io.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/server/io.rs Tue May 28 21:28:32 2019 +0300 @@ -6,8 +6,8 @@ }; use crate::{ + handlers::{IoResult, IoTask}, server::database::Database, - handlers::{IoResult, IoTask}, }; use log::*; use mio::{Evented, Poll, PollOpt}; diff -r c5a6e8566425 -r e935b1ad23f3 rust/hedgewars-server/src/server/network.rs --- a/rust/hedgewars-server/src/server/network.rs Tue May 28 19:04:18 2019 +0300 +++ b/rust/hedgewars-server/src/server/network.rs Tue May 28 21:28:32 2019 +0300 @@ -18,10 +18,7 @@ use slab::Slab; use crate::{ - core::{ - server::HWServer, - types::ClientId - }, + core::{server::HwServer, types::ClientId}, handlers, protocol::{messages::*, ProtocolDecoder}, utils, @@ -31,8 +28,8 @@ use super::io::{IOThread, RequestId}; use crate::{ - protocol::messages::HWServerMessage::Redirect, - handlers::{IoResult, IoTask} + handlers::{IoResult, IoTask}, + protocol::messages::HwServerMessage::Redirect, }; #[cfg(feature = "tls-connections")] @@ -142,7 +139,7 @@ source: &mut R, id: ClientId, addr: &SocketAddr, - ) -> NetworkResult> { + ) -> NetworkResult> { let mut bytes_read = 0; let result = loop { match decoder.read_from(source) { @@ -175,7 +172,7 @@ result } - pub fn read(&mut self) -> NetworkResult> { + pub fn read(&mut self) -> NetworkResult> { match self.socket { ClientSocket::Plain(ref mut stream) => { NetworkClient::read_impl(&mut self.decoder, stream, self.id, &self.peer_addr) @@ -309,7 +306,7 @@ pub struct NetworkLayer { listener: TcpListener, - server: HWServer, + server: HwServer, clients: Slab, pending: HashSet<(ClientId, NetworkClientState)>, pending_cache: Vec<(ClientId, NetworkClientState)>, @@ -435,7 +432,7 @@ match event { TimeoutEvent::SendPing { probes_count } => { if let Some(ref mut client) = self.clients.get_mut(client_id) { - client.send_string(&HWServerMessage::Ping.to_raw_protocol()); + client.send_string(&HwServerMessage::Ping.to_raw_protocol()); client.write()?; let timeout = if probes_count != 0 { create_ping_timeout(&mut self.timer, probes_count - 1, client_id) @@ -684,7 +681,7 @@ } pub fn build(self) -> NetworkLayer { - let server = HWServer::new(self.clients_capacity, self.rooms_capacity); + let server = HwServer::new(self.clients_capacity, self.rooms_capacity); let clients = Slab::with_capacity(self.clients_capacity); let pending = HashSet::with_capacity(2 * self.clients_capacity); let pending_cache = Vec::with_capacity(2 * self.clients_capacity);