Exemplo n.º 1
0
void sv_Destroy()
{
	NMUInt32 refCount;
	NMErr err = kNMNoError;
	NSpProtocolReference pRef;

	if(!gNetworkInitialised)
		return;
	m_ConsPrint("Network UnInitialization\n");

	if( _gameReference )
	{
		err = NSpGame_Dispose( _gameReference, kNSpGameFlag_ForceTerminateGame );
	}

	if( _protocolListRef )
	{
		refCount = NSpProtocolList_GetCount( _protocolListRef );	/* get number of protocols */

		while( refCount-- && !err )
		{
			pRef = NSpProtocolList_GetIndexedRef( _protocolListRef, refCount );	/* get currect reference */
			err = NSpProtocolList_RemoveIndexed( _protocolListRef, refCount );	/* then remove it from the list */

			/* now, we can dispose of the reference safely */
			NSpProtocol_Dispose( pRef );	/* this should have an NMErr return, but has a void return... */
		}

		/* once all of the protocols are disposed, we can dispose of the containing reference list */
		NSpProtocolList_Dispose( _protocolListRef );
	}
	gNetworkInitialised = false;
}
Exemplo n.º 2
0
NMErr NetworkShutdown( void )
{
	NMUInt32 refCount;
	NMErr err = kNMNoError;

	/* if we have a game object (we should!) dispose if it now */

	if( _gameReference )
		err = NSpGame_Dispose( _gameReference, kNSpGameFlag_ForceTerminateGame );

	/* dispose of our protocol references & the list containing them */

	if( _protocolListRef )
	{
		NSpProtocolReference pRef;

		refCount = NSpProtocolList_GetCount( _protocolListRef );	/* get number of protocols */

		while( refCount-- && !err )
		{
			pRef = NSpProtocolList_GetIndexedRef( _protocolListRef, refCount );	/* get currect reference */

			err = NSpProtocolList_RemoveIndexed( _protocolListRef, refCount );	/* then remove it from the list */

			/* now, we can dispose of the reference safely */
			NSpProtocol_Dispose( pRef );	/* this should have an NMErr return, but has a void return... */
		}

		/* once all of the protocols are disposed, we can dispose of the containing reference list */
		NSpProtocolList_Dispose( _protocolListRef );
	}


	/* Make sure we can't use old values */

	_protocolListRef = NULL;
	_gameReference = NULL;
	
	return( err );
}