mirror of https://github.com/OpenTTD/OpenTTD
(svn r15640) -Fix [FS#2712]: game crashes when network pools are empty, so always allocate at least one pool block
parent
3f73152b7f
commit
642dc1ea5e
|
@ -591,12 +591,18 @@ static bool NetworkListen()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Resets both pools used for network clients */
|
||||||
|
static void InitializeNetworkPools()
|
||||||
|
{
|
||||||
|
_NetworkClientSocket_pool.CleanPool();
|
||||||
|
_NetworkClientSocket_pool.AddBlockToPool();
|
||||||
|
_NetworkClientInfo_pool.CleanPool();
|
||||||
|
_NetworkClientInfo_pool.AddBlockToPool();
|
||||||
|
}
|
||||||
|
|
||||||
// Close all current connections
|
// Close all current connections
|
||||||
static void NetworkClose()
|
static void NetworkClose()
|
||||||
{
|
{
|
||||||
/* The pool is already empty, so we already closed the connections */
|
|
||||||
if (GetNetworkClientSocketPoolSize() == 0) return;
|
|
||||||
|
|
||||||
NetworkClientSocket *cs;
|
NetworkClientSocket *cs;
|
||||||
|
|
||||||
FOR_ALL_CLIENT_SOCKETS(cs) {
|
FOR_ALL_CLIENT_SOCKETS(cs) {
|
||||||
|
@ -625,17 +631,13 @@ static void NetworkClose()
|
||||||
free(_network_company_states);
|
free(_network_company_states);
|
||||||
_network_company_states = NULL;
|
_network_company_states = NULL;
|
||||||
|
|
||||||
_NetworkClientSocket_pool.CleanPool();
|
InitializeNetworkPools();
|
||||||
_NetworkClientInfo_pool.CleanPool();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inits the network (cleans sockets and stuff)
|
// Inits the network (cleans sockets and stuff)
|
||||||
static void NetworkInitialize()
|
static void NetworkInitialize()
|
||||||
{
|
{
|
||||||
_NetworkClientSocket_pool.CleanPool();
|
InitializeNetworkPools();
|
||||||
_NetworkClientSocket_pool.AddBlockToPool();
|
|
||||||
_NetworkClientInfo_pool.CleanPool();
|
|
||||||
_NetworkClientInfo_pool.AddBlockToPool();
|
|
||||||
|
|
||||||
_sync_frame = 0;
|
_sync_frame = 0;
|
||||||
_network_first_time = true;
|
_network_first_time = true;
|
||||||
|
|
Loading…
Reference in New Issue