Ejemplo n.º 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;
}
Ejemplo n.º 2
0
void mods_init()
{
	//if(!data) /* only load once */
		//data = load_data_from_memory(internal_data);
		
	for(int i = 0; i < NUM_NETOBJTYPES; i++)
		snap_set_staticsize(i, netobj_get_size(i));

	layers_init();
	col_init();
	game.controller = new GAMECONTROLLER_BALL;
	MAPITEM_LAYER_TILEMAP *tmap = layers_game_layer();
	TILE *tiles = (TILE *)map_get_data(tmap->data);
	
	for(int y = 0; y < tmap->height; y++)
	{
		for(int x = 0; x < tmap->width; x++)
		{
			int index = tiles[y*tmap->width+x].index;
			
			if(index >= ENTITY_OFFSET)
			{
				vec2 pos(x*32.0f+16.0f, y*32.0f+16.0f);
				game.controller->on_entity(index-ENTITY_OFFSET, pos);
			}
		}
	}

	//game.world.insert_entity(game.controller);

#ifdef CONF_DEBUG
	if(config.dbg_dummies)
	{
		for(int i = 0; i < config.dbg_dummies ; i++)
		{
			mods_connected(MAX_CLIENTS-i-1);
			mods_client_enter(MAX_CLIENTS-i-1);
			if(game.controller->is_teamplay())
				game.players[MAX_CLIENTS-i-1]->team = i&1;
		}
	}
#endif
}
Ejemplo n.º 3
0
void mods_init()
{
	//if(!data) /* only load once */
		//data = load_data_from_memory(internal_data);
		
	for(int i = 0; i < NUM_NETOBJTYPES; i++)
		snap_set_staticsize(i, netobj_get_size(i));

	layers_init();
	col_init();

	// reset everything here
	//world = new GAMEWORLD;
	//players = new PLAYER[MAX_CLIENTS];

	// select gametype
	if(strcmp(config.sv_gametype, "mod") == 0)
		game.controller = new GAMECONTROLLER_MOD;
	else if(strcmp(config.sv_gametype, "ctf") == 0)
		game.controller = new GAMECONTROLLER_CTF;
	else if(strcmp(config.sv_gametype, "tdm") == 0)
		game.controller = new GAMECONTROLLER_TDM;
	else if(strcmp(config.sv_gametype, "race") == 0)
		game.controller = new GAMECONTROLLER_RACE;
	else
		game.controller = new GAMECONTROLLER_DM;

	// setup core world
	//for(int i = 0; i < MAX_CLIENTS; i++)
	//	game.players[i].core.world = &game.world.core;

	// create all entities from the game layer
	MAPITEM_LAYER_TILEMAP *tmap = layers_game_layer();
	TILE *tiles = (TILE *)map_get_data(tmap->data);
	
	/*
	num_spawn_points[0] = 0;
	num_spawn_points[1] = 0;
	num_spawn_points[2] = 0;
	*/
	
	for(int y = 0; y < tmap->height; y++)
	{
		for(int x = 0; x < tmap->width; x++)
		{
			int index = tiles[y*tmap->width+x].index;
			
			if(index >= ENTITY_OFFSET)
			{
				game.controller->on_entity(index-ENTITY_OFFSET, x, y);
			}
		}
	}

	//game.world.insert_entity(game.controller);

#ifdef CONF_DEBUG
	if(config.dbg_dummies)
	{
		for(int i = 0; i < config.dbg_dummies ; i++)
		{
			mods_connected(MAX_CLIENTS-i-1);
			mods_client_enter(MAX_CLIENTS-i-1);
			if(game.controller->is_teamplay())
				game.players[MAX_CLIENTS-i-1]->team = i&1;
		}
	}
#endif
}
Ejemplo n.º 4
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);
}