minor changes to mulitiplayer

This commit is contained in:
Dave White 2003-10-05 08:55:03 +00:00
parent 265e902ed5
commit bc2a1705ba

View file

@ -68,7 +68,40 @@ int connection_acceptor::do_action()
} }
config cfg; config cfg;
try {
sock = network::receive_data(cfg); sock = network::receive_data(cfg);
} catch(network::error& e) {
sock = 0;
//if the problem isn't related to any specific connection
if(!e.socket) {
throw e;
}
bool changes = false;
//a socket has disconnected. Remove its positions.
for(positions_map::iterator i = positions_.begin();
i != positions_.end(); ) {
if(i->second == e.socket) {
changes = true;
i->second = 0;
i->first.values.erase("taken");
}
}
//now disconnect the socket
e.disconnect();
//if there have been changes to the positions taken,
//then notify other players
if(changes) {
network::send_data(players_);
}
}
if(sock) { if(sock) {
const int side_taken = atoi(cfg.values["side"].c_str())-1; const int side_taken = atoi(cfg.values["side"].c_str())-1;
if(side_taken >= 0 && side_taken < int(sides_.size())) { if(side_taken >= 0 && side_taken < int(sides_.size())) {