--- a/gameServer2/src/server/handlers/lobby.rs Tue Aug 14 15:25:05 2018 +0200
+++ b/gameServer2/src/server/handlers/lobby.rs Thu Aug 16 19:33:03 2018 +0300
@@ -1,19 +1,21 @@
use mio;
-use server::{
- server::HWServer,
- coretypes::ClientId,
- actions::{Action, Action::*}
+use crate::{
+ server::{
+ server::HWServer,
+ coretypes::ClientId,
+ actions::{Action, Action::*}
+ },
+ protocol::messages::{
+ HWProtocolMessage,
+ HWServerMessage::*
+ },
+ utils::is_name_illegal
};
-use protocol::messages::{
- HWProtocolMessage,
- HWServerMessage::*
-};
-use utils::is_name_illegal;
use super::common::rnd_reply;
pub fn handle(server: &mut HWServer, client_id: ClientId, message: HWProtocolMessage) {
- use protocol::messages::HWProtocolMessage::*;
+ use crate::protocol::messages::HWProtocolMessage::*;
match message {
CreateRoom(name, password) => {
let actions =
@@ -35,32 +37,29 @@
.send_all().in_room(server.lobby_id).but_self().action()];
server.react(client_id, actions);
},
- JoinRoom(name, password) => {
- let actions;
- {
- let room = server.rooms.iter().find(|(_, r)| r.name == name);
- let room_id = room.map(|(_, r)| r.id);
- let nicks = server.clients.iter()
- .filter(|(_, c)| c.room_id == room_id)
- .map(|(_, c)| c.nick.clone())
- .collect();
- let c = &mut server.clients[client_id];
+ JoinRoom(name, _password) => {
+ let room = server.rooms.iter().find(|(_, r)| r.name == name);
+ let room_id = room.map(|(_, r)| r.id);
+ let nicks = server.clients.iter()
+ .filter(|(_, c)| c.room_id == room_id)
+ .map(|(_, c)| c.nick.clone())
+ .collect();
+ let c = &mut server.clients[client_id];
- actions = if let Some((_, r)) = room {
- if c.protocol_number != r.protocol_number {
- vec![Warn("Room version incompatible to your Hedgewars version!".to_string())]
- } else if r.is_join_restricted() {
- vec![Warn("Access denied. This room currently doesn't allow joining.".to_string())]
- } else if r.players_number == u8::max_value() {
- vec![Warn("This room is already full".to_string())]
- } else {
- vec![MoveToRoom(r.id),
- RoomJoined(nicks).send_self().action()]
- }
+ let actions = if let Some((_, r)) = room {
+ if c.protocol_number != r.protocol_number {
+ vec![Warn("Room version incompatible to your Hedgewars version!".to_string())]
+ } else if r.is_join_restricted() {
+ vec![Warn("Access denied. This room currently doesn't allow joining.".to_string())]
+ } else if r.players_number == u8::max_value() {
+ vec![Warn("This room is already full".to_string())]
} else {
- vec![Warn("No such room.".to_string())]
- };
- }
+ vec![MoveToRoom(r.id),
+ RoomJoined(nicks).send_self().action()]
+ }
+ } else {
+ vec![Warn("No such room.".to_string())]
+ };
server.react(client_id, actions);
},
Rnd(v) => {