Exemplo n.º 1
0
//================
// MM_CreateMatch
// Creates a match in memory
//================
mm_match_t *MM_CreateMatch( int matchid, char *gametype, int maxclients, int scorelimit, float timelimit, mm_type_t skilltype, int skilllevel )
{
	mm_match_t *match;

	if( matchid < 0  || !maxclients )
		return NULL;

	if( !gametype || !*gametype )

	if( skilltype == TYPE_DEPENDENT && skilllevel < 0 )
		return NULL;

	match = ( mm_match_t * )MM_Malloc( sizeof( mm_match_t ) );

	match->id = matchid;
	match->clients = ( mm_client_t ** )MM_Malloc( sizeof( mm_client_t * ) * maxclients );
	match->maxclients = maxclients;
	match->gametype = ( char * )MM_Malloc( strlen( gametype ) + 1 );
	strcpy( match->gametype, gametype );
	match->skilltype = skilltype;
	match->skilllevel = skilllevel;
	match->pingtype = TYPE_ANY; // for now
	match->scorelimit = scorelimit;
	match->timelimit = timelimit;

	match->next = mms.matches;
	mms.matches = match;

	return match;
}
Exemplo n.º 2
0
//////////////////////////////////////////////////
// AC_itemPtr AC_I_Create(int op, void * source1, void * source2, void * destination)
// op - operation which is in use
// *source1 - package of data
// *source2 - package of data
// *destination - package of data
////////////////////
// creates package of three address code
//////////////////////////////////////////////////
AC_itemPtr AC_I_Create(int op, void * source1, void * source2, void * destination)
{
#if DEBUG
	printf("Creating address code item for operation %d\n",op);
#endif
	AC_itemPtr item = MM_Malloc(sizeof(struct AC_ItemStruct));
	item->operation = op;
	item->destination = destination;
	item->source1 = source1;
	item->source2 = source2;

	return item;

}	
Exemplo n.º 3
0
hudc_text_t* LA_HUD_CTextInit( int cols, int rows, void (*drawFunc)( const char *, int, int) )
{

	//__chkptr( context );
	hudc_text_t* context;
	TFUNC_ENTER;

	context = ( hudc_text_t* ) MM_Malloc( sizeof( hudc_text_t ) );
	__chkptr( context );
	context->cols = cols;
	context->rows = rows;
	context->firstline = 0;
	context->lastline = 0;
	context->colpointer = -1;
	if( !drawFunc )
		context->drawString = LA_DrawString;
	else
		context->drawString = drawFunc;

	TFUNC_LEAVE;
	return context;
}
Exemplo n.º 4
0
res_gltex_cache_t * Res_CacheInGLTEX_jpg( res_gltex_register_t *reg )
{
	struct jpeg_decompress_struct cinfo;

	ib_file_t	*h;
	unsigned char *buffer;
	int row_stride;
	struct my_error_mgr jerr;
// 	FILE	*b;

	int	pixels;
	unsigned char	*image, *ptr;
	res_gltex_cache_t		*gltex;
	

	h = IB_Open( reg->path );
//	b = fopen( "test.jpg", "rb" );

	if( !h )
	{
		__error( "load of '%s' failed\n", reg->path );
	}

//	memset( &cinfo, 0, sizeof( struct jpeg_decompress_struct ));

	cinfo.err = jpeg_std_error(&jerr.pub);
	jerr.pub.error_exit = jpeg_error_exit;
	
	if (setjmp (jerr.setjmp_buffer))                                              
	{

		jpeg_destroy_decompress (&cinfo);
		if( h )
			IB_Close( h );
		__error( "XJT: JPEG load error\n");
	       
	}



	printf( "%p\n", cinfo.err );


	// step 1

	jpeg_create_decompress(&cinfo);	
//	cinfo.err = jpeg_std_error (&jerr.pub);                                       
//	printf( "%p\n", cinfo.err );

	// step 2
	jpeg_ibase_src(&cinfo, h);
//	jpeg_stdio_src( &cinfo, b );

//	printf( "back\n" );
	
	// step 3
	jpeg_read_header(&cinfo, TRUE);


/*
	if( cinfo.jpeg_color_space != JCS_RGB )
	{
		__error( "colorspace is not RGB\n" );
	}
*/


	jpeg_start_decompress( &cinfo );
//	printf( "jpeg: %d %d %d\n", cinfo.image_width, cinfo.image_height, cinfo.output_components );
	if( cinfo.output_components != 3 )
	{
		__error( "jpeg file '%s' is not RGB\n", reg->path );
	}

	pixels = cinfo.output_width * cinfo.output_height;
	image = (unsigned char *)MM_Malloc( pixels * 3 );
       


	row_stride = cinfo.output_width * 3;

	ptr = image + ( row_stride * (cinfo.output_height - 1) );

	std::vector<unsigned char>buffer_data( row_stride );
	buffer = buffer_data.data();
	//buffer = (unsigned char *)alloca( row_stride );

//	printf( "row_stride: %d\n", row_stride );

       

	while( cinfo.output_scanline < cinfo.output_height )
	{
//		__named_message( "%d\n", cinfo.output_scanline );
		jpeg_read_scanlines( &cinfo, &buffer, 1 ); 
	
		memcpy( ptr, buffer, row_stride );
		
		ptr -= row_stride;

	}

//	memset( image, 0, pixels *3 );

	jpeg_finish_decompress( &cinfo );
	jpeg_destroy_decompress( &cinfo );
	IB_Close( h );

	gltex = NEWTYPE( res_gltex_cache_t );
	gltex->width = cinfo.output_width;
	gltex->height = cinfo.output_height;

	__message( "%s: %d %d\n", reg->path, gltex->width, gltex->height );

	gltex->comp = resGltexComponents_rgb;
	Res_CreateGLTEX_rgb( cinfo.output_width, cinfo.output_height, image );
//	__error( "good\n" );

	return gltex;
}