Esempio n. 1
0
void unwear_item_from_actor(int actor_id,Uint8 which_part)
{
	int i;

	for(i=0;i<max_actors;i++)
		{
			if(actors_list[i])
				if(actors_list[i]->actor_id==actor_id)
					{
						if(which_part==KIND_OF_WEAPON)
							{
								if(actors_list[i]->cur_weapon == GLOVE_FUR || actors_list[i]->cur_weapon == GLOVE_LEATHER){
									my_strcp(actors_list[i]->body_parts->hands_tex, actors_list[i]->body_parts->hands_tex_save);
									glDeleteTextures(1,&actors_list[i]->texture_id);
									actors_list[i]->texture_id=load_bmp8_enhanced_actor(actors_list[i]->body_parts, 255);
								}
								actors_list[i]->body_parts->weapon=0;
								actors_list[i]->body_parts->weapon_fn[0]=0;
								actors_list[i]->body_parts->weapon_tex[0]=0;
								return;
							}

						if(which_part==KIND_OF_SHIELD)
							{
								actors_list[i]->body_parts->shield=0;
								actors_list[i]->body_parts->shield_fn[0]=0;
								actors_list[i]->body_parts->shield_tex[0]=0;
								return;
							}

						if(which_part==KIND_OF_CAPE)
							{
								actors_list[i]->body_parts->cape=0;
								actors_list[i]->body_parts->cape_fn[0]=0;
								actors_list[i]->body_parts->cape_tex[0]=0;
								return;
							}

						if(which_part==KIND_OF_HELMET)
							{
								actors_list[i]->body_parts->helmet=0;
								actors_list[i]->body_parts->helmet_fn[0]=0;
								actors_list[i]->body_parts->helmet_tex[0]=0;
								return;
							}

						return;
					}
		}

}
Esempio n. 2
0
void set_new_video_mode(int fs,int mode)
{
	int i;
#ifndef	NEW_TEXTURES
	int alpha;
#endif	/* NEW_TEXTURES */
	
	full_screen=fs;
	video_mode=mode;

	//now, clear all the textures...
#ifdef	NEW_TEXTURES
	unload_texture_cache();
#else	/* NEW_TEXTURES */
	for(i = 0; i < TEXTURE_CACHE_MAX; i++)
	{
		if(texture_cache[i].file_name[0])
		{
			glDeleteTextures(1,(GLuint*)&texture_cache[i].texture_id);
			texture_cache[i].texture_id=0;//force a reload
			CHECK_GL_ERRORS();
		}
	}

#ifndef MAP_EDITOR2
	//do the same for the actors textures...
	for(i=0;i<max_actors;i++)
		{
			if(actors_list[i])
				{
					if(actors_list[i]->remapped_colors || actors_list[i]->is_enhanced_model)//if it is not remapable, then it is already in the cache
						{
							glDeleteTextures(1,&actors_list[i]->texture_id);
							actors_list[i]->texture_id=0;
							CHECK_GL_ERRORS();
						}
				}
		}
#endif
#endif	/* NEW_TEXTURES */

	if (use_vertex_buffers)
	{
		e3d_object * obj;

#ifdef FASTER_MAP_LOAD
		for (i = 0; i < cache_e3d->num_items; i++)
#else
		for (i = 0; i < cache_e3d->max_item; i++)
#endif
		{
			if (!cache_e3d->cached_items[i]) continue;
			obj= cache_e3d->cached_items[i]->cache_item;
			free_e3d_va(obj);
		}
		CHECK_GL_ERRORS();
	}

#ifndef	NEW_TEXTURES
	ec_clear_textures();
#endif	/* NEW_TEXTURES */

	//destroy the current context

	init_video();
#ifndef WINDOWS
	// Re-enable window manager events, since the killing of the video 
	// subsystem turns them off.
	SDL_EventState (SDL_SYSWMEVENT, SDL_ENABLE);
#endif	
	resize_root_window();
	init_lights();
	disable_local_lights();
	reset_material();

	//reload the cursors
	load_cursors();
	build_cursors();
	change_cursor(current_cursor);

	ec_load_textures();

	//now, reload the textures
#ifndef	NEW_TEXTURES
	for(i = 0; i < TEXTURE_CACHE_MAX; i++)
	{
		if (texture_cache[i].file_name[0] && !texture_cache[i].load_err)
		{
			alpha=texture_cache[i].alpha;
			//our texture was freed, we have to reload it
			if(alpha<=0)
				texture_cache[i].texture_id = load_bmp8_color_key (&(texture_cache[i]), alpha);
	            	else
				texture_cache[i].texture_id = load_bmp8_fixed_alpha (&(texture_cache[i]), alpha);
		}
	}
	reload_fonts();

#ifndef MAP_EDITOR2
	//do the same for the actors textures...
	for(i=0;i<max_actors;i++)
		{
			if(actors_list[i])
				{
					if(actors_list[i]->remapped_colors)//if it is not remapable, then it is already in the cache
						{
							//reload the skin
							//actors_list[i]->texture_id=load_bmp8_remapped_skin(actors_list[i]->skin_name,
							//												   150,actors_list[i]->skin,actors_list[i]->hair,actors_list[i]->shirt,
							//												   actors_list[i]->pants,actors_list[i]->boots);
						}
					if(actors_list[i]->is_enhanced_model)
						{
							actors_list[i]->texture_id=load_bmp8_enhanced_actor(actors_list[i]->body_parts, 255);
						}
				}
		}
#endif
#endif	/* NEW_TEXTURES */
	
	//it is dependent on the window height...
	init_hud_interface (HUD_INTERFACE_LAST);
	new_minute();

	set_all_intersect_update_needed(main_bbox_tree);
	skybox_init_gl();

	// resize the EL root windows
	resize_all_root_windows (window_width, window_height);
	check_options();
	reload_tab_map = 1;
#ifdef NEW_CURSOR
	if (!sdl_cursors)
	{
		SDL_ShowCursor(0);
		SDL_WM_GrabInput(SDL_GRAB_OFF);
	}
#endif // NEW_CURSOR
}
Esempio n. 3
0
void actor_wear_item(int actor_id,Uint8 which_part, Uint8 which_id)
{
	int i;

	for(i=0;i<max_actors;i++)
		{
			if(actors_list[i])
				if(actors_list[i]->actor_id==actor_id)
					{
						if(which_part==KIND_OF_WEAPON)
							{
								if(which_id == GLOVE_FUR || which_id == GLOVE_LEATHER){
									my_strcp(actors_list[i]->body_parts->hands_tex, actors_defs[actors_list[i]->actor_type].weapon[which_id].skin_name);
								}
								my_strcp(actors_list[i]->body_parts->weapon_tex,actors_defs[actors_list[i]->actor_type].weapon[which_id].skin_name);
								my_strcp(actors_list[i]->body_parts->weapon_fn,actors_defs[actors_list[i]->actor_type].weapon[which_id].model_name);
								no_bounding_box=1;
								actors_list[i]->body_parts->weapon=(md2*)load_md2_cache(actors_list[i]->body_parts->weapon_fn);
								no_bounding_box=0;
								glDeleteTextures(1,&actors_list[i]->texture_id);
								actors_list[i]->texture_id=load_bmp8_enhanced_actor(actors_list[i]->body_parts, 255);
								actors_list[i]->cur_weapon=which_id;

								actors_list[i]->body_parts->weapon_glow=actors_defs[actors_list[i]->actor_type].weapon[which_id].glow;

								return;
							}

						if(which_part==KIND_OF_SHIELD)
							{
								my_strcp(actors_list[i]->body_parts->shield_tex,actors_defs[actors_list[i]->actor_type].shield[which_id].skin_name);
								my_strcp(actors_list[i]->body_parts->shield_fn,actors_defs[actors_list[i]->actor_type].shield[which_id].model_name);
								no_bounding_box=1;
								actors_list[i]->body_parts->shield=(md2*)load_md2_cache(actors_list[i]->body_parts->shield_fn);
								no_bounding_box=0;
								glDeleteTextures(1,&actors_list[i]->texture_id);
								actors_list[i]->texture_id=load_bmp8_enhanced_actor(actors_list[i]->body_parts, 255);
								return;
							}

						if(which_part==KIND_OF_CAPE)
							{
								my_strcp(actors_list[i]->body_parts->cape_tex,actors_defs[actors_list[i]->actor_type].cape[which_id].skin_name);
								my_strcp(actors_list[i]->body_parts->cape_fn,actors_defs[actors_list[i]->actor_type].cape[which_id].model_name);
								no_bounding_box=1;
								actors_list[i]->body_parts->cape=(md2*)load_md2_cache(actors_list[i]->body_parts->cape_fn);
								no_bounding_box=0;
								glDeleteTextures(1,&actors_list[i]->texture_id);
								actors_list[i]->texture_id=load_bmp8_enhanced_actor(actors_list[i]->body_parts, 255);
								return;
							}

						if(which_part==KIND_OF_HELMET)
							{
								my_strcp(actors_list[i]->body_parts->helmet_tex,actors_defs[actors_list[i]->actor_type].helmet[which_id].skin_name);
								my_strcp(actors_list[i]->body_parts->helmet_fn,actors_defs[actors_list[i]->actor_type].helmet[which_id].model_name);
								no_bounding_box=1;
								actors_list[i]->body_parts->helmet=(md2*)load_md2_cache(actors_list[i]->body_parts->helmet_fn);
								no_bounding_box=0;
								glDeleteTextures(1,&actors_list[i]->texture_id);
								actors_list[i]->texture_id=load_bmp8_enhanced_actor(actors_list[i]->body_parts, 255);
								return;
							}

						if(which_part==KIND_OF_BODY_ARMOR)
							{
								my_strcp(actors_list[i]->body_parts->arms_tex,actors_defs[actors_list[i]->actor_type].shirt[which_id].arms_name);
								my_strcp(actors_list[i]->body_parts->torso_tex,actors_defs[actors_list[i]->actor_type].shirt[which_id].torso_name);
								my_strcp(actors_list[i]->body_parts->torso_fn,actors_defs[actors_list[i]->actor_type].shirt[which_id].model_name);
								no_bounding_box=1;
								actors_list[i]->body_parts->torso=(md2*)load_md2_cache(actors_list[i]->body_parts->torso_fn);
								no_bounding_box=0;
								glDeleteTextures(1,&actors_list[i]->texture_id);
								actors_list[i]->texture_id=load_bmp8_enhanced_actor(actors_list[i]->body_parts, 255);
								return;
							}
						if(which_part==KIND_OF_LEG_ARMOR)
							{
								my_strcp(actors_list[i]->body_parts->pants_tex,actors_defs[actors_list[i]->actor_type].legs[which_id].legs_name);
								my_strcp(actors_list[i]->body_parts->legs_fn,actors_defs[actors_list[i]->actor_type].legs[which_id].model_name);
								no_bounding_box=1;
								actors_list[i]->body_parts->legs=(md2*)load_md2_cache(actors_list[i]->body_parts->legs_fn);
								no_bounding_box=0;
								glDeleteTextures(1,&actors_list[i]->texture_id);
								actors_list[i]->texture_id=load_bmp8_enhanced_actor(actors_list[i]->body_parts, 255);
								return;
							}

						if(which_part==KIND_OF_BOOT_ARMOR)
							{
								my_strcp(actors_list[i]->body_parts->boots_tex,actors_defs[actors_list[i]->actor_type].boots[which_id].boots_name);
								actors_list[i]->texture_id=load_bmp8_enhanced_actor(actors_list[i]->body_parts, 255);
								return;
							}
						return;
					}
		}

}
Esempio n. 4
0
//return the ID (number in the actors_list[]) of the new allocated actor
int add_enhanced_actor(enhanced_actor *this_actor,char * frame_name,float x_pos, float y_pos,
					   float z_pos, float z_rot, int actor_id)
{
	int texture_id;
	int i;
	int k;
	actor *our_actor;
	no_bounding_box=1;

	//ok, load the legs
	if(this_actor->legs_fn[0])
		{
			this_actor->legs=(md2*)load_md2_cache(this_actor->legs_fn);
			if(!this_actor->legs)
				{
    		        char str[120];
    		        sprintf(str,"%s: %s: %s\n",reg_error_str,error_body_part,this_actor->legs_fn);
    		        log_error(str);
    		        this_actor->legs=0;
				}
		}
	else this_actor->legs=0;

	//ok, load the head
	if(this_actor->head_fn[0])
		{
			this_actor->head=(md2*)load_md2_cache(this_actor->head_fn);
			if(!this_actor->head)
				{
    		        char str[120];
    		        sprintf(str,"%s: %s (%s): %s\n",reg_error_str,error_body_part,error_head,this_actor->head_fn);
    		        log_error(str);
    		        this_actor->head=0;
				}
		}
	else this_actor->head=0;

	//ok, load the torso
	if(this_actor->torso_fn[0])
		{
			this_actor->torso=(md2*)load_md2_cache(this_actor->torso_fn);
			if(!this_actor->torso)
				{
    		        char str[120];
    		        sprintf(str,"%s: %s (%s): %s\n",reg_error_str,error_body_part,error_torso,this_actor->torso_fn);
    		        log_error(str);
    		        this_actor->torso=0;
				}
		}
	else this_actor->torso=0;

	//ok, load the weapon
	if(this_actor->weapon_fn[0])
		{
			this_actor->weapon=(md2*)load_md2_cache(this_actor->weapon_fn);
			if(!this_actor->weapon)
				{
    		        char str[120];
    		        sprintf(str,"%s: %s (%s): %s\n",reg_error_str,error_body_part,error_weapon,this_actor->weapon_fn);
    		        log_error(str);
    		        this_actor->weapon=0;
				}
		}
	else this_actor->weapon=0;

	//ok, load the shield
	if(this_actor->shield_fn[0])
		{
			this_actor->shield=(md2*)load_md2_cache(this_actor->shield_fn);
			if(!this_actor->shield)
				{
    		        char str[120];
    		        sprintf(str,"%s: %s (%s): %s\n",reg_error_str,error_body_part,error_weapon,this_actor->shield_fn);
    		        log_error(str);
    		        this_actor->shield=0;
				}
		}
	else this_actor->shield=0;

	//ok, load the helmet
	if(this_actor->helmet_fn[0])
		{
			this_actor->helmet=(md2*)load_md2_cache(this_actor->helmet_fn);
			if(!this_actor->helmet)
				{
    		        char str[120];
    		        sprintf(str,"%s: %s (%s): %s\n",reg_error_str,error_body_part,error_helmet,this_actor->helmet_fn);
    		        log_error(str);
    		        this_actor->helmet=0;
				}
		}
	else this_actor->helmet=0;


	//ok, load the cape
	if(this_actor->cape_fn[0])
		{
			this_actor->cape=(md2*)load_md2_cache(this_actor->cape_fn);
			if(!this_actor->cape)
				{
    		        char str[120];
    		        sprintf(str,"%s: %s (%s): %s\n",reg_error_str,error_body_part,error_cape,this_actor->cape_fn);
    		        log_error(str);
    		        this_actor->cape=0;
				}
		}
	else this_actor->cape=0;

	//get the skin
	texture_id= load_bmp8_enhanced_actor(this_actor, 255);

	our_actor = calloc(1, sizeof(actor));

	memset(our_actor->current_displayed_text, 0, max_current_displayed_text_len);
	our_actor->current_displayed_text_time_left =  0;

	our_actor->texture_id=texture_id;
	our_actor->is_enhanced_model=1;
	our_actor->actor_id=actor_id;
	our_actor->x_pos=x_pos;
	our_actor->y_pos=y_pos;
	our_actor->z_pos=z_pos;

	our_actor->x_speed=0;
	our_actor->y_speed=0;
	our_actor->z_speed=0;

	our_actor->x_rot=0;
	our_actor->y_rot=0;
	our_actor->z_rot=z_rot;

	//reset the script related things
    our_actor->move_x_speed=0;
	our_actor->move_y_speed=0;
	our_actor->move_z_speed=0;
    our_actor->rotate_x_speed=0;
	our_actor->rotate_y_speed=0;
	our_actor->rotate_z_speed=0;
	our_actor->movement_frames_left=0;
	our_actor->moving=0;
	our_actor->rotating=0;
	our_actor->busy=0;
	our_actor->last_command=nothing;
	//clear the que
	for(k=0;k<10;k++)our_actor->que[k]=nothing;



	our_actor->model_data=0;
	my_strcp(our_actor->cur_frame,frame_name);
	our_actor->stand_idle=0;
	our_actor->sit_idle=0;
	our_actor->body_parts=this_actor;

	//find a free spot, in the actors_list
	lock_actors_lists();	//lock it to avoid timing issues
	for(i=0;i<max_actors;i++)
		{
			if(!actors_list[i])break;
		}

	actors_list[i]=our_actor;
	if(i>=max_actors)max_actors=i+1;
	no_bounding_box=0;
	//We're unlocking it later
	return i;
}