Example #1
0
//================
// MM_FreeMatch
// Free match memory and remove it from list
//================
void MM_FreeMatch( mm_match_t *match, qboolean freeconns )
{
	int i;
	mm_server_t *server;
	mm_match_t *current, *prev = NULL;

	// find the match in the list
	for( current = mms.matches ; current ; current = current->next )
	{
		if( current == match )
			break;

		prev = current;
	}

	if( !current )
		return;

	// free clients
	for( i = 0; i < match->maxclients; i++ )
	{
		if( !match->clients[i] )
			continue;

		MM_FreeClient( match->clients[i], freeconns );
	}

	// remove from the list
	if( prev )
		prev->next = match->next;
	else
		mms.matches = match->next;

	// free any servers possibly attached to this match
	for( server = mms.gameservers ; server ; server = server->next )
	{
		if( server->match == match )
			server->match = NULL;
	}

	MM_Free( match->clients );
	MM_Free( match->gametype );
	MM_Free( match );
}
Example #2
0
static void cl_mm_StringCopy( const char *in, char **pout )
{
	char *out;
	size_t in_size;

	out = *pout;
	if( out ) {
		MM_Free( out );
		*pout = NULL;
	}

	if( !in ) {
		return;
	}

	in_size = strlen( in ) + 1;
	out = MM_Alloc( in_size );
	strcpy( out, in );
	*pout = out;
}
Example #3
0
/*
* CL_MM_ErrorMessage
* Stores error message in local buffer and optionally prints it to console
*/
static void CL_MM_ErrorMessage( qboolean printToConsole, const char *format, ... )
{
	va_list	argptr;
	char string[2048];
	size_t string_len;

	va_start( argptr, format );
	string_len = Q_vsnprintfz( string, sizeof( string ), format, argptr );
	va_end( argptr );

	if( string_len >= cl_mm_errmsg_size ) {
		if( cl_mm_errmsg ) {
			MM_Free( cl_mm_errmsg );
		}
		cl_mm_errmsg_size = string_len + 1;
		cl_mm_errmsg = MM_Alloc( cl_mm_errmsg_size );
	}

	strcpy( cl_mm_errmsg, string );

	if( printToConsole ) {
		Com_Printf( "%s\n", cl_mm_errmsg );
	}
}