another attempt to fix networking problems
This commit is contained in:
parent
d391af101b
commit
e3fa1a4bc1
4 changed files with 10 additions and 4 deletions
|
@ -496,6 +496,8 @@ int play_game(int argc, char** argv)
|
|||
<< e.message << "\n";
|
||||
return 0;
|
||||
} catch(network::error& e) {
|
||||
std::cerr << "caught network error...\n";
|
||||
e.disconnect();
|
||||
gui::show_dialog(disp,NULL,"",e.message,gui::OK_ONLY);
|
||||
} catch(gamemap::incorrect_format_exception& e) {
|
||||
gui::show_dialog(disp,NULL,"",std::string("The game map could not be loaded: ") + e.msg_,gui::OK_ONLY);
|
||||
|
|
|
@ -96,6 +96,8 @@ int connection_acceptor::do_action()
|
|||
sock = network::receive_data(cfg);
|
||||
} catch(network::error& e) {
|
||||
|
||||
std::cerr << "caught networking error. we are " << (network::is_server() ? "" : "NOT") << " a server\n";
|
||||
|
||||
sock = 0;
|
||||
|
||||
//if the problem isn't related to any specific connection,
|
||||
|
@ -103,7 +105,8 @@ int connection_acceptor::do_action()
|
|||
//likewise if we are not a server, we cannot afford any connection
|
||||
//to go down, so also re-throw the error
|
||||
if(!e.socket || !network::is_server()) {
|
||||
throw e;
|
||||
e.disconnect();
|
||||
throw network::error(e.message);
|
||||
}
|
||||
|
||||
bool changes = false;
|
||||
|
|
|
@ -192,7 +192,9 @@ connection receive_data(config& cfg, connection connection_num, int timeout)
|
|||
char num_buf[4];
|
||||
size_t len = SDLNet_TCP_Recv(*i,num_buf,4);
|
||||
|
||||
if(len != 4) {
|
||||
if(len == 0) {
|
||||
throw error("Remote host disconnected",*i);
|
||||
} else if(len != 4) {
|
||||
std::cerr << "received bad packet length: " << len << "/4\n";
|
||||
throw error(std::string("network error receiving length data: ") + SDLNet_GetError(),*i);
|
||||
}
|
||||
|
@ -238,7 +240,6 @@ connection receive_data(config& cfg, connection connection_num, int timeout)
|
|||
}
|
||||
}
|
||||
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
|
|||
{
|
||||
unit_map::const_iterator u = units.end();
|
||||
|
||||
if(type >= UNIT_REPORTS_BEGIN && type < UNIT_REPORTS_END) {
|
||||
if(int(type) >= int(UNIT_REPORTS_BEGIN) && int(type) < int(UNIT_REPORTS_END)) {
|
||||
u = units.find(mouseover);
|
||||
if(u == units.end()) {
|
||||
u = units.find(loc);
|
||||
|
|
Loading…
Add table
Reference in a new issue