fixed crash when joining a server when connected to one already

This commit is contained in:
Magnus Auvinen 2007-12-20 00:26:50 +00:00
parent d84e653f6d
commit e06dd7d5d7
2 changed files with 4 additions and 3 deletions

View file

@ -396,6 +396,8 @@ void client_connect(const char *server_address_str)
const char *port_str = 0; const char *port_str = 0;
int k; int k;
int port = 8303; int port = 8303;
client_disconnect();
dbg_msg("client", "connecting to '%s'", server_address_str); dbg_msg("client", "connecting to '%s'", server_address_str);
@ -435,9 +437,7 @@ void client_disconnect_with_reason(const char *reason)
void client_disconnect() void client_disconnect()
{ {
netclient_disconnect(net, 0); client_disconnect_with_reason(0);
client_set_state(CLIENTSTATE_OFFLINE);
map_unload();
} }
static int client_load_data() static int client_load_data()

View file

@ -208,6 +208,7 @@ static void conn_reset(NETCONNECTION *conn)
conn->last_recv_time = 0; conn->last_recv_time = 0;
conn->last_update_time = 0; conn->last_update_time = 0;
conn->token = -1; conn->token = -1;
mem_zero(&conn->peeraddr, sizeof(conn->peeraddr));
rb_clear(&conn->buffer); rb_clear(&conn->buffer);
} }