(svn r15640) -Fix [FS#2712]: game crashes when network pools are empty, so always allocate at least one pool block

This commit is contained in:
smatz 2009-03-07 22:40:47 +00:00
parent 3f73152b7f
commit 642dc1ea5e
1 changed files with 11 additions and 9 deletions

View File

@ -591,12 +591,18 @@ static bool NetworkListen()
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
static void NetworkClose()
{
/* The pool is already empty, so we already closed the connections */
if (GetNetworkClientSocketPoolSize() == 0) return;
NetworkClientSocket *cs;
FOR_ALL_CLIENT_SOCKETS(cs) {
@ -625,17 +631,13 @@ static void NetworkClose()
free(_network_company_states);
_network_company_states = NULL;
_NetworkClientSocket_pool.CleanPool();
_NetworkClientInfo_pool.CleanPool();
InitializeNetworkPools();
}
// Inits the network (cleans sockets and stuff)
static void NetworkInitialize()
{
_NetworkClientSocket_pool.CleanPool();
_NetworkClientSocket_pool.AddBlockToPool();
_NetworkClientInfo_pool.CleanPool();
_NetworkClientInfo_pool.AddBlockToPool();
InitializeNetworkPools();
_sync_frame = 0;
_network_first_time = true;