mirror of https://github.com/OpenTTD/OpenTTD
(svn r189) -Fix: [1024750] Fix: network.c - timeout error. When one client timed out, all clients were disconnected (sign_de)
parent
5ecaebcc6c
commit
216abe4e93
10
network.c
10
network.c
|
@ -1096,6 +1096,7 @@ void NetworkSend()
|
||||||
SyncPacket sp;
|
SyncPacket sp;
|
||||||
uint new_max;
|
uint new_max;
|
||||||
|
|
||||||
|
_network_ahead_frames = _network_sync_freq + 1;
|
||||||
|
|
||||||
ready_all=false;
|
ready_all=false;
|
||||||
|
|
||||||
|
@ -1106,7 +1107,7 @@ void NetworkSend()
|
||||||
for(cs=_clients;cs->socket != INVALID_SOCKET; cs++) {
|
for(cs=_clients;cs->socket != INVALID_SOCKET; cs++) {
|
||||||
count++;
|
count++;
|
||||||
ready_all = ready_all && (cs->ready || cs->inactive || (cs->xmitpos>0));
|
ready_all = ready_all && (cs->ready || cs->inactive || (cs->xmitpos>0));
|
||||||
cs->timeout-=5;
|
if (!cs->ready) cs->timeout-=5;
|
||||||
if (cs->timeout == 0) {
|
if (cs->timeout == 0) {
|
||||||
SET_DPARAM16(0,count);
|
SET_DPARAM16(0,count);
|
||||||
ShowErrorMessage(-1,STR_NETWORK_ERR_TIMEOUT,0,0);
|
ShowErrorMessage(-1,STR_NETWORK_ERR_TIMEOUT,0,0);
|
||||||
|
@ -1122,7 +1123,9 @@ void NetworkSend()
|
||||||
_not_packet = 0;
|
_not_packet = 0;
|
||||||
|
|
||||||
new_max = max(_frame_counter + (int)_network_ahead_frames, _frame_counter_max);
|
new_max = max(_frame_counter + (int)_network_ahead_frames, _frame_counter_max);
|
||||||
|
|
||||||
|
DEBUG(net,3) ("net: serv: sync max=%i, seed1=%i, seed2=%i",new_max,_sync_seed_1,_sync_seed_2);
|
||||||
|
|
||||||
sp.packet_length = sizeof(sp);
|
sp.packet_length = sizeof(sp);
|
||||||
sp.packet_type = 1;
|
sp.packet_type = 1;
|
||||||
sp.frames = new_max - _frame_counter_max;
|
sp.frames = new_max - _frame_counter_max;
|
||||||
|
@ -1511,6 +1514,7 @@ if (_network_available) {
|
||||||
IConsoleCmdRegister("connect",NetworkConsoleCmdConnect);
|
IConsoleCmdRegister("connect",NetworkConsoleCmdConnect);
|
||||||
IConsoleVarRegister("net_client_timeout",&_network_client_timeout,ICONSOLE_VAR_UINT16);
|
IConsoleVarRegister("net_client_timeout",&_network_client_timeout,ICONSOLE_VAR_UINT16);
|
||||||
IConsoleVarRegister("net_ready_ahead",&_network_ready_ahead,ICONSOLE_VAR_UINT16);
|
IConsoleVarRegister("net_ready_ahead",&_network_ready_ahead,ICONSOLE_VAR_UINT16);
|
||||||
|
IConsoleVarRegister("net_sync_freq",&_network_sync_freq,ICONSOLE_VAR_UINT16);
|
||||||
} else {
|
} else {
|
||||||
DEBUG(net, 3) ("[NET][Core] FAILED: multiplayer not available");
|
DEBUG(net, 3) ("[NET][Core] FAILED: multiplayer not available");
|
||||||
}
|
}
|
||||||
|
@ -1636,7 +1640,7 @@ if (incomming) {
|
||||||
|
|
||||||
if ((_networking) && (!_networking_server) && (_frame_counter+_network_ready_ahead >= _frame_counter_max)) {
|
if ((_networking) && (!_networking_server) && (_frame_counter+_network_ready_ahead >= _frame_counter_max)) {
|
||||||
// send the "i" am ready message to the server
|
// send the "i" am ready message to the server
|
||||||
// [_network_ready_ahead] frame before "i" reach the frame-limit
|
// [_network_ready_ahead] frames before "i" reach the frame-limit
|
||||||
NetworkSendReadyPacket();
|
NetworkSendReadyPacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -762,8 +762,8 @@ static const SettingDesc misc_settings[] = {
|
||||||
static const SettingDesc network_settings[] = {
|
static const SettingDesc network_settings[] = {
|
||||||
{"port", SDT_UINT | SDT_NOSAVE, (void*)3978, &_network_client_port, NULL},
|
{"port", SDT_UINT | SDT_NOSAVE, (void*)3978, &_network_client_port, NULL},
|
||||||
{"server_port", SDT_UINT | SDT_NOSAVE, (void*)3979, &_network_server_port, NULL},
|
{"server_port", SDT_UINT | SDT_NOSAVE, (void*)3979, &_network_server_port, NULL},
|
||||||
{"sync_freq", SDT_UINT | SDT_NOSAVE, (void*)4, &_network_sync_freq, NULL},
|
{"sync_freq", SDT_UINT16 | SDT_NOSAVE, (void*)4, &_network_sync_freq, NULL},
|
||||||
{"ahead_frames", SDT_UINT | SDT_NOSAVE, (void*)5, &_network_ahead_frames, NULL},
|
{"ahead_frames", SDT_UINT16 | SDT_NOSAVE, (void*)5, &_network_ahead_frames, NULL},
|
||||||
{NULL, 0, NULL, NULL, NULL}
|
{NULL, 0, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -227,8 +227,8 @@ VARDEF uint16 _network_game_count;
|
||||||
VARDEF uint _network_client_port;
|
VARDEF uint _network_client_port;
|
||||||
VARDEF uint _network_server_port;
|
VARDEF uint _network_server_port;
|
||||||
|
|
||||||
VARDEF uint _network_sync_freq;
|
VARDEF uint16 _network_sync_freq;
|
||||||
VARDEF uint _network_ahead_frames;
|
VARDEF uint16 _network_ahead_frames;
|
||||||
|
|
||||||
VARDEF uint32 _sync_seed_1, _sync_seed_2;
|
VARDEF uint32 _sync_seed_1, _sync_seed_2;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue