Battalion (mode=king): Kill the team when the king died instea of dismissing
DismissTeam causes a lot of problems and is not suited for multiplayer.
The team is not dismissed if the team is still active.
It's hard to properly do a tie.
And, and, and …
extern crate rand;
extern crate mio;
extern crate slab;
extern crate netbuf;
#[macro_use]
extern crate nom;
#[macro_use]
extern crate log;
extern crate env_logger;
//use std::io::*;
//use rand::Rng;
//use std::cmp::Ordering;
use mio::net::*;
use mio::*;
mod utils;
mod server;
mod protocol;
fn main() {
env_logger::init().unwrap();
info!("Hedgewars game server, protocol {}", utils::PROTOCOL_VERSION);
let address = "0.0.0.0:46631".parse().unwrap();
let listener = TcpListener::bind(&address).unwrap();
let mut server = server::server::HWServer::new(listener, 1024, 512);
let poll = Poll::new().unwrap();
server.register(&poll).unwrap();
let mut events = Events::with_capacity(1024);
loop {
poll.poll(&mut events, None).unwrap();
for event in events.iter() {
if event.readiness() & Ready::readable() == Ready::readable() {
match event.token() {
utils::SERVER => server.accept(&poll).unwrap(),
Token(tok) => server.client_readable(&poll, tok).unwrap(),
}
}
if event.readiness() & Ready::writable() == Ready::writable() {
match event.token() {
utils::SERVER => unreachable!(),
Token(tok) => server.client_writable(&poll, tok).unwrap(),
}
}
// if event.kind().is_hup() || event.kind().is_error() {
// match event.token() {
// utils::SERVER => unreachable!(),
// Token(tok) => server.client_error(&poll, tok).unwrap(),
// }
// }
}
}
}