rust/hedgewars-server/src/server/handlers/inroom.rs
changeset 14708 5122c584804e
parent 14707 9f98086de1b6
child 14709 4569d8d50286
equal deleted inserted replaced
14707:9f98086de1b6 14708:5122c584804e
     4 use crate::{
     4 use crate::{
     5     protocol::messages::{server_chat, HWProtocolMessage, HWServerMessage::*},
     5     protocol::messages::{server_chat, HWProtocolMessage, HWServerMessage::*},
     6     server::{
     6     server::{
     7         actions::{Action, Action::*},
     7         actions::{Action, Action::*},
     8         core::HWServer,
     8         core::HWServer,
       
     9         coretypes,
     9         coretypes::{ClientId, GameCfg, RoomId, VoteType, Voting, MAX_HEDGEHOGS_PER_TEAM},
    10         coretypes::{ClientId, GameCfg, RoomId, VoteType, Voting, MAX_HEDGEHOGS_PER_TEAM},
    10         room::{HWRoom, RoomFlags},
    11         room::{HWRoom, RoomFlags},
    11     },
    12     },
    12     utils::is_name_illegal,
    13     utils::is_name_illegal,
    13 };
    14 };
   457                     let msg = voting_description(&kind);
   458                     let msg = voting_description(&kind);
   458                     let voting = Voting::new(kind, server.room_clients(client_id));
   459                     let voting = Voting::new(kind, server.room_clients(client_id));
   459                     let room = &mut server.rooms[room_id];
   460                     let room = &mut server.rooms[room_id];
   460                     room.voting = Some(voting);
   461                     room.voting = Some(voting);
   461                     response.add(server_chat(msg).send_all().in_room(room_id));
   462                     response.add(server_chat(msg).send_all().in_room(room_id));
   462                     super::common::add_vote(room, response, true, false);
   463                     super::common::submit_vote(
       
   464                         server,
       
   465                         coretypes::Vote {
       
   466                             is_pro: true,
       
   467                             is_forced: false,
       
   468                         },
       
   469                         response,
       
   470                     );
   463                 }
   471                 }
   464                 Some(msg) => {
   472                 Some(msg) => {
   465                     response.add(server_chat(msg).send_self());
   473                     response.add(server_chat(msg).send_self());
   466                 }
   474                 }
   467             }
   475             }
   468         }
   476         }
   469         Vote(vote) => {
   477         Vote(vote) => {
   470             super::common::add_vote(&mut server.rooms[room_id], response, vote, false);
   478             super::common::submit_vote(
       
   479                 server,
       
   480                 coretypes::Vote {
       
   481                     is_pro: vote,
       
   482                     is_forced: false,
       
   483                 },
       
   484                 response,
       
   485             );
   471         }
   486         }
   472         ForceVote(vote) => {
   487         ForceVote(vote) => {
   473             let is_forced = server.clients[client_id].is_admin();
   488             let is_forced = server.clients[client_id].is_admin();
   474             super::common::add_vote(&mut server.rooms[room_id], response, vote, false);
   489             super::common::submit_vote(
       
   490                 server,
       
   491                 coretypes::Vote {
       
   492                     is_pro: vote,
       
   493                     is_forced,
       
   494                 },
       
   495                 response,
       
   496             );
   475         }
   497         }
   476         ToggleRestrictJoin | ToggleRestrictTeams | ToggleRegisteredOnly => {
   498         ToggleRestrictJoin | ToggleRestrictTeams | ToggleRegisteredOnly => {
   477             let client = &server.clients[client_id];
   499             let client = &server.clients[client_id];
   478             let room = &mut server.rooms[room_id];
   500             let room = &mut server.rooms[room_id];
   479             if client.is_master() {
   501             if client.is_master() {