Delete closed connections when starting a new game or leaving SuperMelee.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2576 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
meep-eep
2006-12-07 03:45:05 +00:00
parent 48af246772
commit e69613241f
4 changed files with 19 additions and 4 deletions
+1
View File
@@ -1838,6 +1838,7 @@ DoConfirmSettings (PMELEE_STATE pMS)
return FALSE; return FALSE;
return TRUE; return TRUE;
#else #else
closeDisconnectedConnections ();
netInput (); netInput ();
SleepThread (ONE_SECOND / 120); SleepThread (ONE_SECOND / 120);
+3 -2
View File
@@ -165,7 +165,7 @@ closeCallback(NetDescriptor *nd) {
NetConnection_doClose(conn); NetConnection_doClose(conn);
} }
// Close and release a NetDescriptor. // Close and release a NetConnection.
void void
NetConnection_close(NetConnection *conn) { NetConnection_close(NetConnection *conn) {
if (conn->nd != NULL) { if (conn->nd != NULL) {
@@ -176,7 +176,8 @@ NetConnection_close(NetConnection *conn) {
// This would queue the close callback. // This would queue the close callback.
conn->nd = NULL; conn->nd = NULL;
} }
NetConnection_doClose(conn); if (!conn->stateFlags.disconnected)
NetConnection_doClose(conn);
NetConnection_delete(conn); NetConnection_delete(conn);
} }
+14 -1
View File
@@ -69,7 +69,20 @@ closeAllConnections(void) {
{ {
NetConnection *conn = netConnections[player]; NetConnection *conn = netConnections[player];
if (conn != NULL && NetConnection_isConnected(conn)) if (conn != NULL)
closePlayerNetworkConnection(player);
}
}
void
closeDisconnectedConnections(void) {
COUNT player;
for (player = 0; player < NUM_PLAYERS; player++)
{
NetConnection *conn = netConnections[player];
if (conn != NULL && !NetConnection_isConnected(conn))
closePlayerNetworkConnection(player); closePlayerNetworkConnection(player);
} }
} }
+1 -1
View File
@@ -34,7 +34,7 @@ extern struct NetConnection *netConnections[];
void addNetConnection(NetConnection *conn, int playerNr); void addNetConnection(NetConnection *conn, int playerNr);
void removeNetConnection(int playerNr); void removeNetConnection(int playerNr);
void closeAllConnections(void); void closeAllConnections(void);
void closeAllConnections(void); void closeDisconnectedConnections(void);
size_t getNumNetConnections(void); size_t getNumNetConnections(void);
struct melee_state *NetMelee_getMeleeState(NetConnection *conn); struct melee_state *NetMelee_getMeleeState(NetConnection *conn);