Beispiel #1
0
void GAMECLIENT::on_init()
{
	// init all components
	for(int i = 0; i < all.num; i++)
		all.components[i]->on_init();
	
	// setup item sizes
	for(int i = 0; i < NUM_NETOBJTYPES; i++)
		snap_set_staticsize(i, netobj_get_size(i));
	
	// load default font	
	static FONT_SET default_font;
	int64 start = time_get();
	
	int before = gfx_memory_usage();
	font_set_load(&default_font, "fonts/default_font%d.tfnt", "fonts/default_font%d.png", "fonts/default_font%d_b.png", 14, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 36);
	dbg_msg("font", "gfx memory used for font textures: %d", gfx_memory_usage()-before);
	
	gfx_text_set_default_font(&default_font);

	config.cl_threadsoundloading = 0;

	// setup load amount
	load_total = data->num_images;
	load_current = 0;
	if(!config.cl_threadsoundloading)
		load_total += data->num_sounds;
	
	// load textures
	for(int i = 0; i < data->num_images; i++)
	{
		gameclient.menus->render_loading(load_current/load_total);
		data->images[i].id = gfx_load_texture(data->images[i].filename, IMG_AUTO, 0);
		load_current++;
	}

	::skins.init();
	
	if ( config.cl_threadsoundloading )
		thread_create( load_sounds_thread, 0 );
	else
		load_sounds_thread( (void*)1 );

	for(int i = 0; i < all.num; i++)
		all.components[i]->on_reset();
	
	int64 end = time_get();
	dbg_msg("", "%f.2ms", ((end-start)*1000)/(float)time_freq());
	
	servermode = SERVERMODE_PURE;
}
Beispiel #2
0
void GAMECLIENT::on_init()
{
	///--- Added by Tigra	
	average_prediction_offset = -1;
	gameclient.prediction_offset_summ = 0;
	gameclient.prediction_offset_count = 0;
	///---

	// init all components
	for(int i = 0; i < all.num; i++)
		all.components[i]->on_init();
	
	// setup item sizes
	for(int i = 0; i < NUM_NETOBJTYPES; i++)
		snap_set_staticsize(i, netobj_get_size(i));
	
	// load default font	
	static FONT_SET default_font;
	int64 start = time_get();
	
	int before = gfx_memory_usage();
	font_set_load(&default_font, "fonts/default_font%d.tfnt", "fonts/default_font%d.png", "fonts/default_font%d_b.png", 14, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 36);
	dbg_msg("font", "gfx memory used for font textures: %d", gfx_memory_usage()-before);
	
	gfx_text_set_default_font(&default_font);

	config.cl_threadsoundloading = 0;

	// setup load amount
	load_total = data->num_images;
	load_current = 0;
	if(!config.cl_threadsoundloading)
		load_total += data->num_sounds;
	
	// load textures
	for(int i = 0; i < data->num_images; i++)
	{
		gameclient.menus->render_loading(load_current/load_total);
		data->images[i].id = gfx_load_texture(data->images[i].filename, IMG_AUTO, 0);
		load_current++;
	}

	::skins.init();
	
	if(config.cl_threadsoundloading)
		thread_create(load_sounds_thread, 0);
	else
		load_sounds_thread((void*)1);

	for(int i = 0; i < all.num; i++)
		all.components[i]->on_reset();
	
	int64 end = time_get();
	dbg_msg("", "%f.2ms", ((end-start)*1000)/(float)time_freq());
	
	servermode = SERVERMODE_PURE;

	// Teecomp grayscale flags
	gfx_unload_texture(data->images[IMAGE_GAME_GRAY].id); // Already loaded with full color, unload
	data->images[IMAGE_GAME_GRAY].id = -1;

	IMAGE_INFO info;
	if(!gfx_load_png(&info, data->images[IMAGE_GAME_GRAY].filename))
		return;

	unsigned char *d = (unsigned char *)info.data;
	int step = info.format == IMG_RGBA ? 4 : 3;

	for(int i=0; i < info.width*info.height; i++)
	{
		int v = (d[i*step]+d[i*step+1]+d[i*step+2])/3;
		d[i*step] = v;
		d[i*step+1] = v;
		d[i*step+2] = v;
	}

	int freq[256];
	int org_weight;
	int new_weight;
	int flag_x = 384;
	int flag_y = 256;
	int flag_w = 128;
	int flag_h = 256;
	int pitch = info.width*4;

	for(int f=0; f<2; f++)
	{
		org_weight = 0;
		new_weight = 192;
		for(int i=0; i<256; i++)
			freq[i] = 0;

		// find most common frequence
		for(int y=flag_y; y<flag_y+flag_h; y++)
			for(int x=flag_x+flag_w*f; x<flag_x+flag_w*(1+f); x++)
			{
				if(d[y*pitch+x*4+3] > 128)
					freq[d[y*pitch+x*4]]++;
			}
		
		for(int i = 1; i < 256; i++)
		{
			if(freq[org_weight] < freq[i])
				org_weight = i;
		}

		// reorder
		int inv_org_weight = 255-org_weight;
		int inv_new_weight = 255-new_weight;
		for(int y=flag_y; y<flag_y+flag_h; y++)
			for(int x=flag_x+flag_w*f; x<flag_x+flag_w*(1+f); x++)
			{
				int v = d[y*pitch+x*4];
				if(v <= org_weight*1.25f) // modified for contrast
					v = (int)(((v/(float)org_weight) * new_weight));
				else
					v = (int)(((v-org_weight)/(float)inv_org_weight)*inv_new_weight + new_weight);
				d[y*pitch+x*4] = v;
				d[y*pitch+x*4+1] = v;
				d[y*pitch+x*4+2] = v;
			}
	}

	data->images[IMAGE_GAME_GRAY].id = gfx_load_texture_raw(info.width, info.height, info.format, info.data, info.format, 0);
	mem_free(info.data);
}