Exemple #1
0
void bitmap_texture_read_xml(texture_type *texture,int main_tag,bool read_scale)
{
	int						k,scale_tag,main_image_tag,image_tag,frame_count;

		// settings
		
	texture->animate.on=xml_get_attribute_boolean(main_tag,"animate");
	texture->additive=xml_get_attribute_boolean(main_tag,"additive");
	texture->pixelated=xml_get_attribute_boolean(main_tag,"pixelated");
	texture->compress=xml_get_attribute_boolean(main_tag,"compress");
	texture->flip_normal=xml_get_attribute_boolean_default_true(main_tag,"flip_normal");

	texture->shine_factor=xml_get_attribute_float_default(main_tag,"shine_factor",10.0f);
	texture->rl_alpha_type=xml_get_attribute_list(main_tag,"rl_alpha_type",(char*)rtl_alpha_list_str);
	texture->rl_refract_factor=xml_get_attribute_float_default(main_tag,"rl_refract_factor",0.5f);

	texture->glow.rate=xml_get_attribute_int(main_tag,"glow_rate");
	texture->glow.min=xml_get_attribute_float_default(main_tag,"glow_min",0.25f);
	texture->glow.max=xml_get_attribute_float_default(main_tag,"glow_max",0.75f);

	xml_get_attribute_text(main_tag,"shader",texture->shader_name,name_str_len);
	xml_get_attribute_text(main_tag,"material_name",texture->material_name,name_str_len);
	
		// scale

	if (read_scale) {
		scale_tag=xml_findfirstchild("Scale",main_tag);
		texture->scale.uv_size.x=xml_get_attribute_float_default(scale_tag,"x",0.25f);
		texture->scale.uv_size.y=xml_get_attribute_float_default(scale_tag,"y",0.25f);
		texture->scale.uv_offset.x=xml_get_attribute_float_default(scale_tag,"x_off",0.0f);
		texture->scale.uv_offset.y=xml_get_attribute_float_default(scale_tag,"y_off",0.0f);
	}
	
		// images
		
	main_image_tag=xml_findfirstchild("Images",main_tag);
	if (main_image_tag!=-1) {
	
		texture->animate.current_frame=0;
		texture->animate.total_wait=0;
		
		frame_count=xml_countchildren(main_image_tag);
		image_tag=xml_findfirstchild("Image",main_image_tag);
		
		for (k=0;k!=frame_count;k++) {
			texture->animate.wait[k]=xml_get_attribute_int_default(image_tag,"wait",0);
			texture->animate.end_tick[k]=texture->animate.total_wait=texture->animate.total_wait+texture->animate.wait[k];
			xml_get_attribute_text(image_tag,"bitmap",texture->frames[k].name,file_str_len);

			image_tag=xml_findnextchild(image_tag);
		}
	}
}
Exemple #2
0
void iface_read_settings_singleplayer(iface_type *iface)
{
	int							singleplayer_head_tag,
								settings_tag,options_head_tag,option_tag;
	char						path[1024];
	iface_sp_option_type		*sp_option;

		// get xml file
		
	file_paths_data(&file_path_setup,path,"Settings","Singleplayer","xml");
	if (!xml_open_file(path)) return;
	
	singleplayer_head_tag=xml_findrootchild("Singleplayer");		
    if (singleplayer_head_tag==-1) {
		xml_close_file();
		return;
	}

		// settings
		
    settings_tag=xml_findfirstchild("Settings",singleplayer_head_tag);
    if (settings_tag!=-1) {
		iface->singleplayer.skill=xml_get_attribute_boolean(settings_tag,"skill");
		iface->singleplayer.map_pick=xml_get_attribute_boolean(settings_tag,"map_pick");
		iface->singleplayer.map_pick_ss_reveal_id=xml_get_attribute_int_default(settings_tag,"map_pick_ss_reveal_id",-1);
	}

		// options

	options_head_tag=xml_findfirstchild("Options",singleplayer_head_tag);
	if (options_head_tag!=-1) {
		
		iface->singleplayer.option_list.noption=0;
		
		option_tag=xml_findfirstchild("Option",options_head_tag);
		while (option_tag!=-1) {
			
			sp_option=&iface->singleplayer.option_list.options[iface->singleplayer.option_list.noption];
	
			xml_get_attribute_text(option_tag,"name",sp_option->name,name_str_len);
			xml_get_attribute_text(option_tag,"description",sp_option->descript,64);
			sp_option->ss_reveal_id=xml_get_attribute_int_default(option_tag,"ss_reveal_id",-1);
			
			iface->singleplayer.option_list.noption++;
			if (iface->singleplayer.option_list.noption==max_net_option) break;

			option_tag=xml_findnextchild(option_tag);
		}
	}
	

	xml_close_file();
}
Exemple #3
0
void xml_key_read_float(int setup_tag,char *name,float *value)
{
    int			tag;

    tag=xml_findfirstchild(name,setup_tag);
    if (tag!=-1) *value=xml_get_attribute_float(tag,"value");
}
Exemple #4
0
void xml_key_read_color(int setup_tag,char *name,d3col *value)
{
    int			tag;

    tag=xml_findfirstchild(name,setup_tag);
    if (tag!=-1) xml_get_attribute_color(tag,"value",value);
}
Exemple #5
0
void xml_key_read_boolean(int setup_tag,char *name,bool *value)
{
    int			tag;

    tag=xml_findfirstchild(name,setup_tag);
    if (tag!=-1) *value=xml_get_attribute_boolean(tag,"value");
}
Exemple #6
0
void xml_key_read_text(int setup_tag,char *name,char *value,int value_sz)
{
    int			tag;

    tag=xml_findfirstchild(name,setup_tag);
    if (tag!=-1) xml_get_attribute_text(tag,"value",value,value_sz);
}
Exemple #7
0
void read_settings_action(void)
{
	int					n,actions_head_tag,action_tag,idx;
	char				name[name_str_len],path[1024];
						
		// default actions
		
	for (n=0;n!=ncontrol;n++) {
		strcpy(action_display[n].display_name,control_names_str[n]);
		action_display[n].show=TRUE;
	}
	
		// read in actions from setting files
		
	file_paths_data(&setup.file_path_setup,path,"Settings","Actions","xml");
	if (!xml_open_file(path)) return;
	
		// decode the file
      
    actions_head_tag=xml_findrootchild("Actions");
    if (actions_head_tag!=-1) {
	
		action_tag=xml_findfirstchild("Action",actions_head_tag);
		
		while (action_tag!=-1) {
			xml_get_attribute_text(action_tag,"name",name,name_str_len);
			
			idx=setup_find_control_for_name(name);
			if (idx!=-1) {
				xml_get_attribute_text(action_tag,"display",action_display[idx].display_name,name_str_len);
				action_display[idx].show=xml_get_attribute_boolean(action_tag,"show");
			}
			
			action_tag=xml_findnextchild(action_tag);
		}
	}
	
	xml_close_file();
}
Exemple #8
0
bool read_pose_xml(model_type *model)
{
	int						n,k,t,npose,pose_idx,cnt,
							tag,model_head,bone_tag,poses_tag,pose_tag,constraint_bone_idx;
	char					sub_path[1024],path[1024];
	model_tag				constraint_bone_tag;
    model_bone_move_type	*bone_move;
	model_pose_type			*pose;

        // load the pose xml
        
	sprintf(sub_path,"Models/%s",model->name);
	file_paths_data(&modelutility_settings.file_path_setup,path,sub_path,"pose","xml");

	if (!xml_open_file(path)) return(FALSE);

    model_head=xml_findrootchild("Model");
    if (model_head==-1) return(FALSE);
    
        // poses
        
    poses_tag=xml_findfirstchild("Poses",model_head);

    npose=xml_countchildren(poses_tag);
	pose_tag=xml_findfirstchild("Pose",poses_tag);
    
    for (n=0;n!=npose;n++) {

			// add new pose

		pose_idx=model_pose_add(model);
		if (pose_idx==-1) {
			xml_close_file();
			return(FALSE);
		}

		pose=&model->poses[pose_idx];

			// set pose data

        xml_get_attribute_text(pose_tag,"name",pose->name,64);
        
        bone_move=pose->bone_moves;
        for (k=0;k!=model->nbone;k++) {
            bone_move->rot.x=bone_move->rot.z=bone_move->rot.y=0.0f;
            bone_move->mov.x=bone_move->mov.z=bone_move->mov.y=1.0f;
			bone_move->acceleration=0;
			bone_move->skip_blended=FALSE;
			bone_move->constraint.bone_idx=-1;
			bone_move->constraint.offset.x=bone_move->constraint.offset.y=bone_move->constraint.offset.z=0;
			bone_move++;
        }
            
        bone_tag=xml_findfirstchild("Bones",pose_tag);
        
        cnt=xml_countchildren(bone_tag);
		tag=xml_findfirstchild("Bone",bone_tag);
        
        for (k=0;k!=cnt;k++) {
		
            t=model_find_bone(model,xml_get_attribute_model_tag(tag,"tag"));
            if (t!=-1) {
                bone_move=&pose->bone_moves[t];
                xml_get_attribute_3_coord_float(tag,"rot",&bone_move->rot.x,&bone_move->rot.y,&bone_move->rot.z);
				xml_get_attribute_3_coord_float(tag,"move",&bone_move->mov.x,&bone_move->mov.y,&bone_move->mov.z);
				
				bone_move->acceleration=xml_get_attribute_float(tag,"acceleration");
				bone_move->skip_blended=xml_get_attribute_boolean(tag,"skip_blended");
				
				bone_move->constraint.bone_idx=-1;
				bone_move->constraint.offset.x=bone_move->constraint.offset.y=bone_move->constraint.offset.z=0;
				
				constraint_bone_tag=xml_get_attribute_model_tag(tag,"constraint_bone");
				if (constraint_bone_tag!=model_null_tag) {
					constraint_bone_idx=model_find_bone(model,constraint_bone_tag);
					if (constraint_bone_idx!=-1) {
						bone_move->constraint.bone_idx=constraint_bone_idx;
						xml_get_attribute_3_coord_int(tag,"constraint_offset",&bone_move->constraint.offset.x,&bone_move->constraint.offset.y,&bone_move->constraint.offset.z);
					}
				}
			}
		  
			tag=xml_findnextchild(tag);
        }
    
		pose_tag=xml_findnextchild(pose_tag);
    }

    xml_close_file();
    
    return(TRUE);
}
Exemple #9
0
void iface_read_settings_halo(iface_type *iface)
{
	int					nhalo,halos_head_tag,halo_tag,tag;
	char				path[1024];
	iface_halo_type		*halo;

		// read in interface from setting files
		
	file_paths_data(&file_path_setup,path,"Settings","Halos","xml");
	if (!xml_open_file(path)) return;
	
		// get counts
		
    halos_head_tag=xml_findrootchild("Halos");
    if (halos_head_tag==-1) {
		xml_close_file();
		return;
	}

	nhalo=xml_countchildren(halos_head_tag);

	if (nhalo==0) {
		xml_close_file();
		return;
	}

		// read the halos

	halo_tag=xml_findfirstchild("Halo",halos_head_tag);
	
	while (halo_tag!=-1) {
	
			// create a new halo

		if (iface->halo_list.nhalo>=max_iface_halo) {
			xml_close_file();
			return;
		}
			
		halo=&iface->halo_list.halos[iface->halo_list.nhalo];
		iface->halo_list.nhalo++;
			
			// read settings
			
		xml_get_attribute_text(halo_tag,"name",halo->name,name_str_len);
		
		tag=xml_findfirstchild("Image",halo_tag);
		if (tag!=-1) {
			xml_get_attribute_text(tag,"file",halo->bitmap_name,file_str_len);
		}
		
		halo->min_dist=3000;
		halo->max_dist=50000;
		halo->min_size=500;
		halo->max_size=200;
		halo->min_alpha=0.8f;
		halo->max_alpha=0.05f;
		halo->no_clip_object=FALSE;
		halo->no_clip_self=TRUE;

		tag=xml_findfirstchild("Distance",halo_tag);
		if (tag!=-1) {
			halo->min_dist=xml_get_attribute_int(tag,"min");
			halo->max_dist=xml_get_attribute_int(tag,"max");
		}

		tag=xml_findfirstchild("Size",halo_tag);
		if (tag!=-1) {
			halo->min_size=xml_get_attribute_int(tag,"min");
			halo->max_size=xml_get_attribute_int(tag,"max");
		}

		tag=xml_findfirstchild("Alpha",halo_tag);
		if (tag!=-1) {
			halo->min_alpha=xml_get_attribute_float(tag,"min");
			halo->max_alpha=xml_get_attribute_float(tag,"max");
		}

		tag=xml_findfirstchild("Option",halo_tag);
		if (tag!=-1) {
			halo->no_clip_object=xml_get_attribute_boolean(tag,"no_clip_object");
			halo->no_clip_self=xml_get_attribute_boolean(tag,"no_clip_self");
		}
		
			// move on to next halo
			
		halo_tag=xml_findnextchild(halo_tag);
	}
	
	xml_close_file();
}
Exemple #10
0
void read_settings_ring(void)
{
	int					nring,ring_head_tag,ring_tag,tag;
	char				path[1024];
	ring_type			*ring;

		// no rings yet

	server.rings=NULL;
	server.count.ring=0;

		// read in rings from setting files
		
	file_paths_data(&setup.file_path_setup,path,"Settings","Rings","xml");
	if (!xml_open_file(path)) return;
	
		// get counts
       
    ring_head_tag=xml_findrootchild("Rings");
    if (ring_head_tag==-1) {
		xml_close_file();
		return;
	}

	nring=xml_countchildren(ring_head_tag);

	if (nring==0) {
		xml_close_file();
		return;
	}

	server.rings=(ring_type*)malloc(sizeof(ring_type)*nring);
	if (server.rings==NULL) {
		xml_close_file();
		return;
	}

		// read in the rings

	ring_tag=xml_findfirstchild("Ring",ring_head_tag);
    
	while (ring_tag!=-1) {
	
			// create a new ring
			
		ring=&server.rings[server.count.ring];
		
		xml_get_attribute_text(ring_tag,"name",ring->name,name_str_len);
		
		ring->life_msec=1000;
		ring->blend_add=FALSE;

        tag=xml_findfirstchild("Settings",ring_tag);
        if (tag!=-1) {
            ring->life_msec=xml_get_attribute_int(tag,"time");
            ring->blend_add=xml_get_attribute_boolean(tag,"additive");
        }
		
		ring->animate.image_count=1;
		ring->animate.image_per_row=1;
		ring->animate.msec=200;
		ring->animate.loop=TRUE;
		ring->animate.loop_back=FALSE;
		
        tag=xml_findfirstchild("Image",ring_tag);
        if (tag!=-1) {
            xml_get_attribute_text(tag,"file",ring->bitmap_name,file_str_len);
            ring->animate.image_count=xml_get_attribute_int(tag,"count");
			ring->animate.image_per_row=(int)sqrt((float)ring->animate.image_count);
			ring->animate.msec=xml_get_attribute_int(tag,"time");
            ring->animate.loop=xml_get_attribute_boolean(tag,"loop");
            ring->animate.loop_back=xml_get_attribute_boolean(tag,"loop_back");
		}
		
        tag=xml_findfirstchild("Outer",ring_tag);
        if (tag!=-1) {
            ring->start_outer_size=xml_get_attribute_int(tag,"start");
            ring->end_outer_size=xml_get_attribute_int(tag,"end");
        }

        tag=xml_findfirstchild("Inner",ring_tag);
        if (tag!=-1) {
            ring->start_inner_size=xml_get_attribute_int(tag,"start");
            ring->end_inner_size=xml_get_attribute_int(tag,"end");
        }

        tag=xml_findfirstchild("Rotate",ring_tag);
        if (tag!=-1) {
            ring->ang.x=xml_get_attribute_float(tag,"x");
            ring->ang.y=xml_get_attribute_float(tag,"y");
            ring->ang.z=xml_get_attribute_float(tag,"z");
            ring->rot.x=xml_get_attribute_float_default(tag,"x_add",0.0f);
            ring->rot.y=xml_get_attribute_float_default(tag,"y_add",0.0f);
            ring->rot.z=xml_get_attribute_float_default(tag,"z_add",0.0f);
            ring->rot_accel.x=xml_get_attribute_float_default(tag,"x_accel",0.0f);
            ring->rot_accel.y=xml_get_attribute_float_default(tag,"y_accel",0.0f);
            ring->rot_accel.z=xml_get_attribute_float_default(tag,"z_accel",0.0f);
		}

        tag=xml_findfirstchild("Move",ring_tag);
        if (tag!=-1) {
            ring->vct.x=xml_get_attribute_float(tag,"x");
            ring->vct.y=xml_get_attribute_float(tag,"y");
            ring->vct.z=xml_get_attribute_float(tag,"z");
        }
		
		ring->start_color.r=ring->start_color.g=ring->start_color.b=1.0f;
		ring->end_color.r=ring->end_color.g=ring->end_color.b=1.0f;
		ring->team_tint=FALSE;

        tag=xml_findfirstchild("Color",ring_tag);
        if (tag!=-1) {
			xml_get_attribute_color(tag,"start",&ring->start_color);
			xml_get_attribute_color(tag,"end",&ring->end_color);
			ring->team_tint=xml_get_attribute_boolean(tag,"team");
       }
		
        tag=xml_findfirstchild("Alpha",ring_tag);
        if (tag!=-1) {
            ring->start_alpha=xml_get_attribute_float(tag,"start");
            ring->end_alpha=xml_get_attribute_float(tag,"end");
        }
	
			// move on to next ring
			
		server.count.ring++;
		
		ring_tag=xml_findnextchild(ring_tag);
	}
	
	xml_close_file();
}
Exemple #11
0
void read_settings_crosshair(void)
{
	int					ncrosshair,crosshairs_head_tag,crosshair_tag,tag;
	char				path[1024];
	crosshair_type		*crosshair;

		// no crosshairs yet

	server.crosshairs=NULL;
	server.count.crosshair=0;
	
		// read in crosshairs from setting files
		
	file_paths_data(&setup.file_path_setup,path,"Settings","Crosshairs","xml");
	if (!xml_open_file(path)) return;
	
		// get counts
		
    crosshairs_head_tag=xml_findrootchild("Crosshairs");
    if (crosshairs_head_tag==-1) {
		xml_close_file();
		return;
	}

	ncrosshair=xml_countchildren(crosshairs_head_tag);

	if (ncrosshair==0) {
		xml_close_file();
		return;
	}

	server.crosshairs=(crosshair_type*)malloc(sizeof(crosshair_type)*ncrosshair);
	if (server.crosshairs==NULL) {
		xml_close_file();
		return;
	}

		// read the crosshairs
	
	crosshair_tag=xml_findfirstchild("Crosshair",crosshairs_head_tag);
	
	while (crosshair_tag!=-1) {
	
			// create a new crosshair
			
		crosshair=&server.crosshairs[server.count.crosshair];
		
		xml_get_attribute_text(crosshair_tag,"name",crosshair->name,name_str_len);
		
		tag=xml_findfirstchild("Image",crosshair_tag);
		if (tag!=-1) {
			xml_get_attribute_text(tag,"file",crosshair->bitmap_name,file_str_len);
		}
		
			// move on to next crosshair
			
		server.count.crosshair++;
		
		crosshair_tag=xml_findnextchild(crosshair_tag);
	}
	
	xml_close_file();
}
Exemple #12
0
void decode_mesh_v1_xml(model_type *model,int model_head)
{
	int						i,n,k,bone_idx,nbone,hit_box_idx,nhit_box,
							nfill,ntrig,frame_count,
							tag,hit_box_tag,vertex_tag,bone_tag,vtag,trig_tag,image_tag,
							fills_tag,fill_tag;
	model_hit_box_type		*hit_box;
    model_vertex_type		*vertex;
	model_material_type		*material;
    model_bone_type			*bone;
    model_trig_type			*trig;
    texture_type			*texture;
	
        // options
    
    tag=xml_findfirstchild("Options",model_head);
    if (tag!=-1) {
		model->deform_mode=xml_get_attribute_list(tag,"deform",(char*)deform_mode_str);
	}
	
        // center
    
    tag=xml_findfirstchild("Center",model_head);
    if (tag!=-1) {
		xml_get_attribute_3_coord_int(tag,"offset",&model->center.x,&model->center.y,&model->center.z);
    }
    
        // boxes
    
    tag=xml_findfirstchild("View_Box",model_head);
    if (tag!=-1) {
        xml_get_attribute_3_coord_int(tag,"size",&model->view_box.size.x,&model->view_box.size.y,&model->view_box.size.z);
        xml_get_attribute_3_coord_int(tag,"offset",&model->view_box.offset.x,&model->view_box.offset.y,&model->view_box.offset.z);
    }
	
        // light
        
    tag=xml_findfirstchild("Light",model_head);
    if (tag!=-1) {
        model->tags.light_bone_tag[0]=xml_get_attribute_model_tag(tag,"light_bone");
        model->tags.halo_bone_tag[0]=xml_get_attribute_model_tag(tag,"halo_bone");
    }
	
        // hit boxes
    
    hit_box_tag=xml_findfirstchild("Hit_Boxes",model_head);
	if (hit_box_tag!=-1) {
	
		nhit_box=xml_countchildren(hit_box_tag);
		tag=xml_findfirstchild("Hit_Box",hit_box_tag);
		
		for (i=0;i!=model->nhit_box;i++) {
 				
				// add new hit box

			hit_box_idx=model_hit_box_add(model);
			if (hit_box_idx==-1) break;

				// fill in hit box

			hit_box=&model->hit_boxes[hit_box_idx];

			xml_get_attribute_text(tag,"name",hit_box->name,64);
			xml_get_attribute_3_coord_int(tag,"size",&hit_box->box.size.x,&hit_box->box.size.y,&hit_box->box.size.z);
			xml_get_attribute_3_coord_int(tag,"offset",&hit_box->box.offset.x,&hit_box->box.offset.y,&hit_box->box.offset.z);
			
			tag=xml_findnextchild(tag);
		}
    }
	else {
		model->nhit_box=0;
	}
	
		// single mesh
		
	model->nmesh=1;
	strcpy(model->meshes[0].name,"Default");
	
        // vertexes
    
    vertex_tag=xml_findfirstchild("Vertexes",model_head);

    model->meshes[0].nvertex=xml_countchildren(vertex_tag);
	tag=xml_findfirstchild("v",vertex_tag);
	
    vertex=model->meshes[0].vertexes;
    
    for (i=0;i!=model->meshes[0].nvertex;i++) {
        xml_get_attribute_3_coord_int(tag,"c3",&vertex->pnt.x,&vertex->pnt.y,&vertex->pnt.z);
        xml_get_attribute_3_coord_float(tag,"n3",&vertex->normal.x,&vertex->normal.y,&vertex->normal.z);
		
        major_bone_tag[i]=xml_get_attribute_model_tag(tag,"major");
        minor_bone_tag[i]=xml_get_attribute_model_tag(tag,"minor");
        vertex->bone_factor=xml_get_attribute_float_default(tag,"factor",1);
    
        vertex++;
		tag=xml_findnextchild(tag);
    }
    
        // bones

    bone_tag=xml_findfirstchild("Bones",model_head);

    nbone=xml_countchildren(bone_tag);
	tag=xml_findfirstchild("Bone",bone_tag);
    
    for (i=0;i!=nbone;i++) {

			// add new bone

		bone_idx=model_bone_add(model,0,0,0);
		if (bone_idx==-1) break;

			// fill in bone

		bone=&model->bones[bone_idx];

        bone->tag=xml_get_attribute_model_tag(tag,"tag");
		xml_get_attribute_text(tag,"name",bone->name,name_str_len);
        
        xml_get_attribute_3_coord_int(tag,"c3",&bone->pnt.x,&bone->pnt.y,&bone->pnt.z);
        bone_parent_tag[i]=xml_get_attribute_model_tag(tag,"parent");
    
		tag=xml_findnextchild(tag);
    }
	
		// find the light bone
		
	model->tags.light_bone_idx[0]=model_find_bone(model,model->tags.light_bone_tag[0]);
	model->tags.halo_bone_idx[0]=model_find_bone(model,model->tags.halo_bone_tag[0]);
   
		// reset the vertexes from tags to indexes
		
	vertex=model->meshes[0].vertexes;
	
	for (i=0;i!=model->meshes[0].nvertex;i++) {
		vertex->major_bone_idx=model_find_bone(model,major_bone_tag[i]);
		vertex->minor_bone_idx=model_find_bone(model,minor_bone_tag[i]);
        if ((vertex->major_bone_idx==-1) || (vertex->minor_bone_idx==-1)) vertex->bone_factor=1;
		vertex++;
	}
		
		// reset the bones from tags to indexes
		
	bone=model->bones;
	
	for (i=0;i!=model->nbone;i++) {
		bone->parent_idx=model_find_bone(model,bone_parent_tag[i]);
		bone++;
	}
    
        // fills

	bzero(model->textures,(max_model_texture*sizeof(texture_type)));

		// count total # of trigs
		
    fills_tag=xml_findfirstchild("Fills",model_head);
	
    nfill=xml_countchildren(fills_tag);
	fill_tag=xml_findfirstchild("Fill",fills_tag);
    
	ntrig=0;
	
    for (n=0;n!=nfill;n++) {
        trig_tag=xml_findfirstchild("Triangles",fill_tag);
        ntrig+=xml_countchildren(trig_tag)/3;
		fill_tag=xml_findnextchild(fill_tag);
	}

		// load the fills and trigs
		
    ntrig=0;
    trig=model->meshes[0].trigs;

	texture=model->textures;
	material=model->meshes[0].materials;
	
	fill_tag=xml_findfirstchild("Fill",fills_tag);
    
    for (n=0;n!=nfill;n++) {
		texture->animate.current_frame=0;
		texture->animate.total_wait=0;
		
      	texture->animate.on=xml_get_attribute_boolean(fill_tag,"animate");
         
		image_tag=xml_findfirstchild("Images",fill_tag);
			
		frame_count=xml_countchildren(image_tag);
		tag=xml_findfirstchild("Image",image_tag);
		
		for (k=0;k!=frame_count;k++) {
			texture->animate.wait[k]=xml_get_attribute_int(tag,"wait");
			texture->animate.end_tick[k]=texture->animate.total_wait=texture->animate.total_wait+texture->animate.wait[k];
			xml_get_attribute_text(tag,"bitmap",texture->frames[k].name,file_str_len);
			
			tag=xml_findnextchild(tag);
		}
        
            // fill triangles
    
        trig_tag=xml_findfirstchild("Triangles",fill_tag);
        
        material->trig_start=ntrig;
        material->trig_count=xml_countchildren(trig_tag)/3;
		
		vtag=xml_findfirstchild("v",trig_tag);
    
        for (i=0;i!=material->trig_count;i++) {
    
            for (k=0;k!=3;k++) {
                trig->v[k]=xml_get_attribute_int(vtag,"id");
				xml_get_attribute_2_coord_float(vtag,"uv",&trig->gx[k],&trig->gy[k]);

				vtag=xml_findnextchild(vtag);
            }
            
            trig++;
            ntrig++;
        }
		
		texture++;
		material++;
		
		fill_tag=xml_findnextchild(fill_tag);
    }
    
    model->meshes[0].ntrig=ntrig;
}
Exemple #13
0
bool setup_xml_read_path(char *path)
{
	int							n,k,naction,nhost,noption,
								setup_tag,actions_tag,hosts_tag,options_tag,tag;
	char						tag_name[32];
	setup_action_type			*action;
	setup_network_hosts_type	*host;
	setup_network_option_type	*option;
	
		// read file
		
	setup_xml_default();

	if (!xml_open_file(path)) return(FALSE);
    
		// decode the file
       
    setup_tag=xml_findrootchild("Setup");
    if (setup_tag==-1) {
		xml_close_file();
		return(FALSE);
    }
	
		// keys

    xml_key_read_int(setup_tag,"Screen_Width",&setup.screen_wid);
    xml_key_read_int(setup_tag,"Screen_Height",&setup.screen_high);
	xml_key_read_boolean(setup_tag,"Lock_FPS_Refresh",&setup.lock_fps_refresh);
	xml_key_read_float(setup_tag,"Gamma",&setup.gamma);
    xml_key_read_int(setup_tag,"Tint",&setup.tint_color_idx);
    xml_key_read_boolean(setup_tag,"Texture_Compression",&setup.texture_compression);
    xml_key_read_int(setup_tag,"Anisotropic_Mode",&setup.anisotropic_mode);
    xml_key_read_int(setup_tag,"Mipmap_Mode",&setup.mipmap_mode);
	xml_key_read_int(setup_tag,"FSAA_Mode",&setup.fsaa_mode);
	xml_key_read_boolean(setup_tag,"Decal_On",&setup.decal_on);
	xml_key_read_boolean(setup_tag,"Shadow_On",&setup.shadow_on);
	xml_key_read_float(setup_tag,"Sound_Volume",&setup.sound_volume);
	xml_key_read_boolean(setup_tag,"Music_On",&setup.music_on);
	xml_key_read_float(setup_tag,"Music_Volume",&setup.music_volume);
	xml_key_read_boolean(setup_tag,"Always_Run",&setup.always_run);
	xml_key_read_boolean(setup_tag,"Toggle_Run",&setup.toggle_run);
	xml_key_read_boolean(setup_tag,"Invert_Look",&setup.invert_look);
	xml_key_read_boolean(setup_tag,"Mouse_Smooth",&setup.mouse_smooth);
	xml_key_read_float(setup_tag,"Mouse_X_Speed",&setup.mouse_x.speed);
	xml_key_read_float(setup_tag,"Mouse_X_Speed_Min",&setup.mouse_x.speed_min);
	xml_key_read_float(setup_tag,"Mouse_X_Speed_Max",&setup.mouse_x.speed_max);
	xml_key_read_float(setup_tag,"Mouse_X_Acceleration",&setup.mouse_x.acceleration);
	xml_key_read_float(setup_tag,"Mouse_X_Acceleration_Min",&setup.mouse_x.acceleration_min);
	xml_key_read_float(setup_tag,"Mouse_X_Acceleration_Max",&setup.mouse_x.acceleration_max);
	xml_key_read_float(setup_tag,"Mouse_Y_Speed",&setup.mouse_y.speed);
	xml_key_read_float(setup_tag,"Mouse_Y_Speed_Min",&setup.mouse_y.speed_min);
	xml_key_read_float(setup_tag,"Mouse_Y_Speed_Max",&setup.mouse_y.speed_max);
	xml_key_read_float(setup_tag,"Mouse_Y_Acceleration",&setup.mouse_y.acceleration);
	xml_key_read_float(setup_tag,"Mouse_Y_Acceleration_Min",&setup.mouse_y.acceleration_min);
	xml_key_read_float(setup_tag,"Mouse_Y_Acceleration_Max",&setup.mouse_y.acceleration_max);
	xml_key_read_float(setup_tag,"Joystick_X_Speed",&setup.joystick_x.speed);
	xml_key_read_float(setup_tag,"Joystick_X_Speed_Min",&setup.joystick_x.speed_min);
	xml_key_read_float(setup_tag,"Joystick_X_Speed_Max",&setup.joystick_x.speed_max);
	xml_key_read_float(setup_tag,"Joystick_X_Acceleration",&setup.joystick_x.acceleration);
	xml_key_read_float(setup_tag,"Joystick_X_Acceleration_Min",&setup.joystick_x.acceleration_min);
	xml_key_read_float(setup_tag,"Joystick_X_Acceleration_Max",&setup.joystick_x.acceleration_max);
	xml_key_read_float(setup_tag,"Joystick_Y_Speed",&setup.joystick_y.speed);
	xml_key_read_float(setup_tag,"Joystick_Y_Speed_Min",&setup.joystick_y.speed_min);
	xml_key_read_float(setup_tag,"Joystick_Y_Speed_Max",&setup.joystick_y.speed_max);
	xml_key_read_float(setup_tag,"Joystick_Y_Acceleration",&setup.joystick_y.acceleration);
	xml_key_read_float(setup_tag,"Joystick_Y_Acceleration_Min",&setup.joystick_y.acceleration_min);
	xml_key_read_float(setup_tag,"Joystick_Y_Acceleration_Max",&setup.joystick_y.acceleration_max);
	xml_key_read_int(setup_tag,"Joystick_Mode",&setup.joystick_mode);
	xml_key_read_text(setup_tag,"Network_Name",setup.network.name,name_str_len);
	xml_key_read_text(setup_tag,"Network_Last_Map",setup.network.last_map,name_str_len);
	xml_key_read_int(setup_tag,"Host_Bot_Count",&setup.network.bot.count);
	xml_key_read_int(setup_tag,"Host_Bot_Skill",&setup.network.bot.skill);
	xml_key_read_int(setup_tag,"Host_Game_Type",&setup.network.game_type);
	xml_key_read_int(setup_tag,"Host_Score_Limit",&setup.network.score_limit);
	xml_key_read_boolean(setup_tag,"Network_Show_Names",&setup.network.show_names);
	xml_key_read_boolean(setup_tag,"Debug_Console",&setup.debug_console);
	xml_key_read_boolean(setup_tag,"Window",&setup.window);
	xml_key_read_boolean(setup_tag,"Window_Editor",&setup.window_editor);

		// fix some items

	setup_xml_fix_axis(&setup.mouse_x);
	setup_xml_fix_axis(&setup.mouse_y);
	
		// actions

    actions_tag=xml_findfirstchild("Actions",setup_tag);
    if (actions_tag!=-1) {
	
		naction=xml_countchildren(actions_tag);
		tag=xml_findfirstchild("Action",actions_tag);
		
		setup.action_list.naction=naction;
		action=setup.action_list.actions;
		
        for (n=0;n!=naction;n++) {
			xml_get_attribute_text(tag,"name",action->name,32);
			
			for (k=0;k!=max_setup_action_attach;k++) {
				sprintf(tag_name,"attach_%d",k);
				if (!xml_get_attribute_text(tag,tag_name,action->attach[k],32)) action->attach[k][0]=0x0;
			}
           
			tag=xml_findnextchild(tag);
			
			action++;
        }
	}

		// hosts

    hosts_tag=xml_findfirstchild("Hosts",setup_tag);
    if (hosts_tag!=-1) {
	
		nhost=xml_countchildren(hosts_tag);
		tag=xml_findfirstchild("Host",hosts_tag);
		
		setup.network.nhost=nhost;
		host=setup.network.hosts;
		
        for (n=0;n!=nhost;n++) {
			xml_get_attribute_text(tag,"ip",host->ip,256);

			tag=xml_findnextchild(tag);
			host++;
        }
	}
	
 		// options

    options_tag=xml_findfirstchild("Options",setup_tag);
    if (options_tag!=-1) {
	
		noption=xml_countchildren(options_tag);
		tag=xml_findfirstchild("Option",options_tag);

		setup.network.noption=noption;
		option=setup.network.options;
		
        for (n=0;n!=noption;n++) {
			xml_get_attribute_text(tag,"name",option->name,name_str_len);
			
			tag=xml_findnextchild(tag);
  			option++;
		}
	}
  
	xml_close_file();
	
	return(TRUE);
}
Exemple #14
0
int xml_findrootchild(char *name)
{
    return(xml_findfirstchild(name,xml_root_tag));
}
Exemple #15
0
void decode_mesh_v2_xml(model_type *model,int model_head)
{
	int						i,n,k,j,bone_idx,nbone,hit_box_idx,nhit_box,
							mesh_idx,nmesh,nfill,ntrig,
							tag,hit_box_tag,meshes_tag,mesh_tag,
							vertex_tag,bone_tag,vtag,trig_tag,
							materials_tag,material_tag,fills_tag,fill_tag;
	char					tag_name[32];
	model_hit_box_type		*hit_box;
	model_mesh_type			*mesh;
    model_vertex_type		*vertex;
	model_material_type		*material;
    model_bone_type			*bone;
    model_trig_type			*trig;
    texture_type			*texture;

        // options
    
    tag=xml_findfirstchild("Options",model_head);
    if (tag!=-1) {
		model->deform_mode=xml_get_attribute_list(tag,"deform",(char*)deform_mode_str);
	}
	
        // center
    
    tag=xml_findfirstchild("Center",model_head);
    if (tag!=-1) {
		xml_get_attribute_3_coord_int(tag,"offset",&model->center.x,&model->center.y,&model->center.z);
    }
    
        // boxes
    
    tag=xml_findfirstchild("View_Box",model_head);
    if (tag!=-1) {
        xml_get_attribute_3_coord_int(tag,"size",&model->view_box.size.x,&model->view_box.size.y,&model->view_box.size.z);
        xml_get_attribute_3_coord_int(tag,"offset",&model->view_box.offset.x,&model->view_box.offset.y,&model->view_box.offset.z);
    }
	
        // light
        
    tag=xml_findfirstchild("Light",model_head);
    if (tag!=-1) {

		for (k=0;k!=max_model_light;k++) {
			if (k==0) {
				strcpy(tag_name,"light_bone");
			}
			else {
				sprintf(tag_name,"light_bone_%d",k);
			}
			model->tags.light_bone_tag[k]=xml_get_attribute_model_tag(tag,tag_name);
		}

		for (k=0;k!=max_model_halo;k++) {
			if (k==0) {
				strcpy(tag_name,"halo_bone");
			}
			else {
				sprintf(tag_name,"halo_bone_%d",k);
			}
			model->tags.halo_bone_tag[k]=xml_get_attribute_model_tag(tag,tag_name);
		}

        model->tags.name_bone_tag=xml_get_attribute_model_tag(tag,"name_bone");
    }
	
        // hit boxes
    
    hit_box_tag=xml_findfirstchild("Hit_Boxes",model_head);
	if (hit_box_tag!=-1) {
	
		nhit_box=xml_countchildren(hit_box_tag);
		tag=xml_findfirstchild("Hit_Box",hit_box_tag);
		
		for (i=0;i!=nhit_box;i++) {
 				
				// add new hit box

			hit_box_idx=model_hit_box_add(model);
			if (hit_box_idx==-1) break;

				// fill in hit box

			hit_box=&model->hit_boxes[hit_box_idx];

			xml_get_attribute_text(tag,"name",hit_box->name,64);
			xml_get_attribute_3_coord_int(tag,"size",&hit_box->box.size.x,&hit_box->box.size.y,&hit_box->box.size.z);
			xml_get_attribute_3_coord_int(tag,"offset",&hit_box->box.offset.x,&hit_box->box.offset.y,&hit_box->box.offset.z);
			
			tag=xml_findnextchild(tag);
		}
    }
	else {
		model->nhit_box=0;
	}
    
        // bones
 
    bone_tag=xml_findfirstchild("Bones",model_head);

    nbone=xml_countchildren(bone_tag);
	tag=xml_findfirstchild("Bone",bone_tag);
    
    for (i=0;i!=nbone;i++) {

 			// add new bone

		bone_idx=model_bone_add(model,0,0,0);
		if (bone_idx==-1) break;

			// fill in bone

		bone=&model->bones[bone_idx];
		
		bone->tag=xml_get_attribute_model_tag(tag,"tag");
		xml_get_attribute_text(tag,"name",bone->name,name_str_len);
        
        xml_get_attribute_3_coord_int(tag,"c3",&bone->pnt.x,&bone->pnt.y,&bone->pnt.z);
        bone_parent_tag[i]=xml_get_attribute_model_tag(tag,"parent");
    
		tag=xml_findnextchild(tag);
    }
	
		// find the light bone
		
	for (k=0;k!=max_model_light;k++) {
		model->tags.light_bone_idx[k]=model_find_bone(model,model->tags.light_bone_tag[k]);
	}

	for (k=0;k!=max_model_halo;k++) {
		model->tags.halo_bone_idx[k]=model_find_bone(model,model->tags.halo_bone_tag[k]);
	}

	model->tags.name_bone_idx=model_find_bone(model,model->tags.name_bone_tag);
		
		// reset the bones from tags to indexes
		
	bone=model->bones;
	
	for (i=0;i!=model->nbone;i++) {
		bone->parent_idx=model_find_bone(model,bone_parent_tag[i]);
		bone++;
	}
	
		// meshes
		
	meshes_tag=xml_findfirstchild("Meshes",model_head);

    nmesh=xml_countchildren(meshes_tag);
	mesh_tag=xml_findfirstchild("Mesh",meshes_tag);
	
	model->nmesh=1;				// new models have a single mesh
	
	for (j=0;j!=nmesh;j++) {
	
			// need new mesh?
			
		mesh_idx=j;
		if (j>0) {
			mesh_idx=model_mesh_add(model);
		}
		
		if (mesh_idx==-1) break;
	
			// mesh settings
			
		mesh=&model->meshes[mesh_idx];
		xml_get_attribute_text(mesh_tag,"name",mesh->name,name_str_len);
		mesh->no_lighting=xml_get_attribute_boolean(mesh_tag,"no_lighting");
		mesh->blend_add=xml_get_attribute_boolean(mesh_tag,"additive");
		mesh->tintable=xml_get_attribute_boolean(mesh_tag,"tintable");
		
			// don't allow blank mesh names
			
		if (mesh->name[0]==0x0) {
			if (mesh_idx==0) {
				strcpy(mesh->name,"Default");
			}
			else {
				sprintf(mesh->name,"Mesh %d",mesh_idx);
			}
		}
		
			// vertexes
		
		vertex_tag=xml_findfirstchild("Vertexes",mesh_tag);

		mesh->nvertex=xml_countchildren(vertex_tag);
		tag=xml_findfirstchild("v",vertex_tag);
		
		vertex=mesh->vertexes;
		
		for (i=0;i!=mesh->nvertex;i++) {
			xml_get_attribute_3_coord_int(tag,"c3",&vertex->pnt.x,&vertex->pnt.y,&vertex->pnt.z);
			xml_get_attribute_3_coord_float(tag,"n3",&vertex->normal.x,&vertex->normal.y,&vertex->normal.z);
			
			major_bone_tag[i]=xml_get_attribute_model_tag(tag,"major");
			minor_bone_tag[i]=xml_get_attribute_model_tag(tag,"minor");
			vertex->bone_factor=xml_get_attribute_float_default(tag,"factor",1);
		
			vertex++;
			tag=xml_findnextchild(tag);
		}
		
			// materials
			
		materials_tag=xml_findfirstchild("Materials",mesh_tag);
		
		ntrig=0;
		trig=mesh->trigs;

		texture=model->textures;
		material=mesh->materials;
		
		nfill=xml_countchildren(materials_tag);
		material_tag=xml_findfirstchild("Material",materials_tag);
		
		for (n=0;n!=nfill;n++) {
		
			trig_tag=xml_findfirstchild("Triangles",material_tag);
			
			material->trig_start=ntrig;
			material->trig_count=xml_countchildren(trig_tag)/3;
			
			vtag=xml_findfirstchild("v",trig_tag);
		
			for (i=0;i!=material->trig_count;i++) {
		
				for (k=0;k!=3;k++) {
					trig->v[k]=xml_get_attribute_int(vtag,"id");
					xml_get_attribute_2_coord_float(vtag,"uv",&trig->gx[k],&trig->gy[k]);

					vtag=xml_findnextchild(vtag);
				}
				
				trig++;
				ntrig++;
			}
			
			texture++;
			material++;
			
			material_tag=xml_findnextchild(material_tag);
		}
		
		mesh->ntrig=ntrig;
		
			// reset the vertexes from tags to indexes
			
		vertex=mesh->vertexes;
		
		for (i=0;i!=mesh->nvertex;i++) {
			vertex->major_bone_idx=model_find_bone(model,major_bone_tag[i]);
			vertex->minor_bone_idx=model_find_bone(model,minor_bone_tag[i]);
			if ((vertex->major_bone_idx==-1) || (vertex->minor_bone_idx==-1)) vertex->bone_factor=1;
			vertex++;
		}
		
		mesh_tag=xml_findnextchild(mesh_tag);
	}
	
	model->nmesh=nmesh;
  
        // fills

    fills_tag=xml_findfirstchild("Fills",model_head);
	nfill=xml_countchildren(fills_tag);

	texture=model->textures;
	
	fill_tag=xml_findfirstchild("Fill",fills_tag);
    
    for (n=0;n!=nfill;n++) {
	
		texture->animate.current_frame=0;
		texture->animate.total_wait=0;
		
		bitmap_texture_read_xml(texture,fill_tag,FALSE);
		texture++;
		
		fill_tag=xml_findnextchild(fill_tag);
    }
}
Exemple #16
0
bool setup_xml_read_path(char *path)
{
	int							n,k,naction,
								setup_tag,actions_tag,maps_tag,options_tag,tag;
	char						tag_name[32];
	setup_action_type			*action;
	
		// read file
		
	setup_xml_default();

	if (!xml_open_file(path)) return(FALSE);
    
		// decode the file
       
    setup_tag=xml_findrootchild("Setup");
    if (setup_tag==-1) {
		xml_close_file();
		return(FALSE);
    }
	
		// keys

	xml_key_read_int(setup_tag,"Screen_Width",&setup.screen_wid);
	xml_key_read_int(setup_tag,"Screen_Height",&setup.screen_high);
	xml_key_read_float(setup_tag,"Gamma",&setup.gamma);
	xml_key_read_int(setup_tag,"FSAA_Mode",&setup.fsaa_mode);
	xml_key_read_boolean(setup_tag,"Decal_On",&setup.decal_on);
	xml_key_read_boolean(setup_tag,"Shadow_On",&setup.shadow_on);
	xml_key_read_float(setup_tag,"Sound_Volume",&setup.sound_volume);
	xml_key_read_boolean(setup_tag,"Music_On",&setup.music_on);
	xml_key_read_float(setup_tag,"Music_Volume",&setup.music_volume);
	xml_key_read_boolean(setup_tag,"Always_Run",&setup.always_run);
	xml_key_read_boolean(setup_tag,"Toggle_Run",&setup.toggle_run);
	xml_key_read_boolean(setup_tag,"Invert_Look",&setup.invert_look);
	xml_key_read_boolean(setup_tag,"Auto_Aim",&setup.auto_aim);
	xml_key_read_boolean(setup_tag,"Mouse_Smooth",&setup.mouse_smooth);
	xml_key_read_float(setup_tag,"Mouse_Speed",&setup.mouse.speed);
	xml_key_read_float(setup_tag,"Mouse_Acceleration",&setup.mouse.acceleration);
	xml_key_read_float(setup_tag,"Joystick_Speed",&setup.joystick.speed);
	xml_key_read_float(setup_tag,"Joystick_Acceleration",&setup.joystick.acceleration);
	xml_key_read_text(setup_tag,"Network_Name",setup.network.name,name_str_len);
    xml_key_read_int(setup_tag,"Character",&setup.network.character_idx);
    xml_key_read_int(setup_tag,"Tint",&setup.network.tint_color_idx);
	xml_key_read_text(setup_tag,"Network_Custom_Host_IP",setup.network.custom_host_ip,64);
	xml_key_read_int(setup_tag,"Host_Bot_Count",&setup.network.bot.count);
	xml_key_read_int(setup_tag,"Host_Bot_Skill",&setup.network.bot.skill);
	xml_key_read_int(setup_tag,"Host_Game_Type",&setup.network.game_type);
	xml_key_read_int(setup_tag,"Host_Score_Limit",&setup.network.score_limit);
	xml_key_read_int(setup_tag,"Host_Game_Reset_Secs",&setup.network.game_reset_secs);
	xml_key_read_int(setup_tag,"Host_Respawn_Secs",&setup.network.respawn_secs);
	xml_key_read_boolean(setup_tag,"Network_Show_Names",&setup.network.show_names);
	xml_key_read_boolean(setup_tag,"Network_Map_Rotation",&setup.network.map_rotation);
	xml_key_read_boolean(setup_tag,"Window",&setup.window);
	xml_key_read_boolean(setup_tag,"Window_Editor",&setup.window_editor);
	xml_key_read_boolean(setup_tag,"No_HUD",&setup.no_hud);
	xml_key_read_boolean(setup_tag,"No_Draw_Weapon",&setup.no_draw_weapon);
	xml_key_read_boolean(setup_tag,"Metrics_On",&setup.metrics_on);
	xml_key_read_boolean(setup_tag,"Debug_On",&setup.debug_on);
	xml_key_read_boolean(setup_tag,"Ignore_FPS_Lock",&setup.ignore_fps_lock);
	xml_key_read_int(setup_tag,"Screen_dim3RTL_Width",&setup.screen_rtl_wid);
	xml_key_read_int(setup_tag,"Screen_dim3RTL_Height",&setup.screen_rtl_high);
	xml_key_read_boolean(setup_tag,"Screen_dim3RTL_Full_Window",&setup.screen_rtl_full_window);

		// actions

    actions_tag=xml_findfirstchild("Actions",setup_tag);
    if (actions_tag!=-1) {
	
		naction=xml_countchildren(actions_tag);
		tag=xml_findfirstchild("Action",actions_tag);
		
		setup.action_list.naction=naction;
		action=setup.action_list.actions;
		
        for (n=0;n!=naction;n++) {
			xml_get_attribute_text(tag,"name",action->name,32);
			
			for (k=0;k!=max_setup_action_attach;k++) {
				sprintf(tag_name,"attach_%d",k);
				xml_get_attribute_text(tag,tag_name,action->attach[k],32);
			}
           
			tag=xml_findnextchild(tag);
			
			action++;
        }
	}

 		// maps
		
    maps_tag=xml_findfirstchild("Maps",setup_tag);
    if (maps_tag!=-1) {
	
		setup.network.map_list.count=xml_countchildren(maps_tag);
		tag=xml_findfirstchild("Map",maps_tag);
		
        for (n=0;n!=setup.network.map_list.count;n++) {
			xml_get_attribute_text(tag,"name",setup.network.map_list.maps[n].name,name_str_len);
			tag=xml_findnextchild(tag);
 		}
	}
	
 		// options
		
    options_tag=xml_findfirstchild("Options",setup_tag);
    if (options_tag!=-1) {
	
		setup.network.option_list.count=xml_countchildren(options_tag);
		tag=xml_findfirstchild("Option",options_tag);
		
        for (n=0;n!=setup.network.option_list.count;n++) {
			xml_get_attribute_text(tag,"name",setup.network.option_list.options[n].name,name_str_len);
			tag=xml_findnextchild(tag);
 		}
	}
  
	xml_close_file();
	
	return(TRUE);
}
Exemple #17
0
bool decode_map_v1_xml(map_type *map,int map_head)
{
	int						i,k,j,y,idx,nportal,seg_cnt,
							main_portal_tag,portal_tag,msg_tag,
							main_seg_tag,seg_tag,main_light_tag,light_tag,main_sound_tag,sound_tag,
							main_particle_tag,particle_tag,main_node_tag,node_tag,
							main_obj_tag,obj_tag,tag,cnt;
	bool					convert_ok;
    portal_type				*portals,*portal;
    segment_type			*seg_list,*seg;
    map_light_type			*light;
    map_sound_type			*sound;
	map_particle_type		*particle;
    node_type				*node;
    spot_type				*spot;
	map_scenery_type		*scenery;
	
		// temporary segments and portals for converting from v1 to v3
		
	seg_cnt=0;
	
	seg_list=(segment_type*)malloc(max_segment*sizeof(segment_type));
	if (seg_list==NULL) return(FALSE);

	nportal=0;

	portals=(portal_type*)malloc(max_portal*sizeof(portal_type));
	if (portals==NULL) {
		free(seg_list);
		return(FALSE);
	}
	        
        // portals

    main_portal_tag=xml_findfirstchild("Portals",map_head);
    if (main_portal_tag!=-1) {
    
        nportal=xml_countchildren(main_portal_tag);
		portal_tag=xml_findfirstchild("Portal",main_portal_tag);
		
        portal=portals;
    
        for (i=0;i!=nportal;i++) {
            xml_get_attribute_3_coord_int(portal_tag,"tl_c3",&portal->x,&y,&portal->z);
            xml_get_attribute_3_coord_int(portal_tag,"br_c3",&portal->ex,&y,&portal->ez);
   
            portal->msg.entry_on=portal->msg.exit_on=portal->msg.base_on=portal->msg.map_change_on=FALSE;
            portal->msg.entry_id=portal->msg.exit_id=0;
			portal->msg.map_name[0]=0x0;
			strcpy(portal->msg.map_spot_name,"Start");
			strcpy(portal->msg.map_spot_type,"Player");
            
            msg_tag=xml_findfirstchild("Messages",portal_tag);
            if (msg_tag!=-1) {
                tag=xml_findfirstchild("Entry",msg_tag);
                if (tag!=-1) {
                    portal->msg.entry_on=xml_get_attribute_boolean(tag,"on");
                    portal->msg.entry_id=xml_get_attribute_int(tag,"id");
                }
                tag=xml_findfirstchild("Exit",msg_tag);
                if (tag!=-1) {
                    portal->msg.exit_on=xml_get_attribute_boolean(tag,"on");
                    portal->msg.exit_id=xml_get_attribute_int(tag,"id");
                }
                tag=xml_findfirstchild("Base",msg_tag);
                if (tag!=-1) {
                    portal->msg.base_on=xml_get_attribute_boolean(tag,"on");
                    portal->msg.base_team=xml_get_attribute_int(tag,"team");
                }
                tag=xml_findfirstchild("Map",msg_tag);
                if (tag!=-1) {
                    portal->msg.map_change_on=xml_get_attribute_boolean(tag,"on");
					xml_get_attribute_text(tag,"name", portal->msg.map_name,name_str_len);
					xml_get_attribute_text(tag,"spot_name", portal->msg.map_spot_name,name_str_len);
					xml_get_attribute_text(tag,"spot_type", portal->msg.map_spot_type,name_str_len);
                }
            }

				// walls
				
            main_seg_tag=xml_findfirstchild("Walls",portal_tag);
            if (main_seg_tag!=-1) {
                
                cnt=xml_countchildren(main_seg_tag);
				seg_tag=xml_findfirstchild("Wall",main_seg_tag);
                
                for (k=0;k!=cnt;k++) {
					seg=&seg_list[seg_cnt];
					seg_cnt++;
					
					read_single_segment(seg_tag,seg,i,sg_wall);

					tag=xml_findfirstchild("v",seg_tag);
					xml_get_attribute_3_coord_int(tag,"c3",&seg->data.wall.lx,&seg->data.wall.ty,&seg->data.wall.lz);
					tag=xml_findnextchild(tag);
					xml_get_attribute_3_coord_int(tag,"c3",&seg->data.wall.rx,&seg->data.wall.by,&seg->data.wall.rz);

					seg_tag=xml_findnextchild(seg_tag);
				}
			}

				// floors

            main_seg_tag=xml_findfirstchild("Floors",portal_tag);
            if (main_seg_tag!=-1) {
                
                cnt=xml_countchildren(main_seg_tag);
				seg_tag=xml_findfirstchild("Floor",main_seg_tag);
                
                for (k=0;k!=cnt;k++) {
					seg=&seg_list[seg_cnt];
					seg_cnt++;
					
					read_single_segment(seg_tag,seg,i,sg_floor);
					
					seg->data.fc.ptsz=xml_countchildren(seg_tag);
					tag=xml_findfirstchild("v",seg_tag);
					
					for (j=0;j!=seg->data.fc.ptsz;j++) {
						xml_get_attribute_3_coord_int(tag,"c3",&seg->data.fc.x[j],&seg->data.fc.y[j],&seg->data.fc.z[j]);
						tag=xml_findnextchild(tag);
					}
					
					seg_tag=xml_findnextchild(seg_tag);
				}
			}
			
				// ceilings
				
            main_seg_tag=xml_findfirstchild("Ceilings",portal_tag);
            if (main_seg_tag!=-1) {
                
                cnt=xml_countchildren(main_seg_tag);
				seg_tag=xml_findfirstchild("Ceiling",main_seg_tag);
                
                for (k=0;k!=cnt;k++) {
					seg=&seg_list[seg_cnt];
					seg_cnt++;
					
					read_single_segment(seg_tag,seg,i,sg_ceiling);
					
					seg->data.fc.ptsz=xml_countchildren(seg_tag);
					tag=xml_findfirstchild("v",seg_tag);
					
					for (j=0;j!=seg->data.fc.ptsz;j++) {
						xml_get_attribute_3_coord_int(tag,"c3",&seg->data.fc.x[j],&seg->data.fc.y[j],&seg->data.fc.z[j]);
						tag=xml_findnextchild(tag);
					}
					
					seg_tag=xml_findnextchild(seg_tag);
				}
			}

				// liquids
				
            main_seg_tag=xml_findfirstchild("Liquids",portal_tag);
            if (main_seg_tag!=-1) {
                
                cnt=xml_countchildren(main_seg_tag);
				seg_tag=xml_findfirstchild("Liquid",main_seg_tag);
                
                for (k=0;k!=cnt;k++) {
					seg=&seg_list[seg_cnt];
					seg_cnt++;
					
					read_single_segment(seg_tag,seg,i,sg_liquid);
					
					tag=xml_findfirstchild("v",seg_tag);
					xml_get_attribute_3_coord_int(tag,"c3",&seg->data.liquid.lft,&seg->data.liquid.y,&seg->data.liquid.top);
					tag=xml_findnextchild(tag);
					xml_get_attribute_3_coord_int(tag,"c3",&seg->data.liquid.rgt,&seg->data.liquid.y,&seg->data.liquid.bot);
					
					seg_tag=xml_findnextchild(seg_tag);
				}
			}

				// ambient walls
				
            main_seg_tag=xml_findfirstchild("Ambients",portal_tag);
            if (main_seg_tag!=-1) {
                
                cnt=xml_countchildren(main_seg_tag);
				seg_tag=xml_findfirstchild("Ambient",main_seg_tag);
                
                for (k=0;k!=cnt;k++) {
					seg=&seg_list[seg_cnt];
					seg_cnt++;
					
					read_single_segment(seg_tag,seg,i,sg_ambient_wall);
					
					tag=xml_findfirstchild("v",seg_tag);
					xml_get_attribute_3_coord_int(tag,"c3",&seg->data.ambient_wall.lx,&seg->data.ambient_wall.ty,&seg->data.ambient_wall.lz);
					tag=xml_findnextchild(tag);
					xml_get_attribute_3_coord_int(tag,"c3",&seg->data.ambient_wall.rx,&seg->data.ambient_wall.by,&seg->data.ambient_wall.rz);
					
					seg_tag=xml_findnextchild(seg_tag);
				}
			}
			
				// ambient floor/ceilings

            main_seg_tag=xml_findfirstchild("Ambient_FCs",portal_tag);
            if (main_seg_tag!=-1) {
                
                cnt=xml_countchildren(main_seg_tag);
				seg_tag=xml_findfirstchild("Ambient_FC",main_seg_tag);
                
                for (k=0;k!=cnt;k++) {
					seg=&seg_list[seg_cnt];
					seg_cnt++;
					
					read_single_segment(seg_tag,seg,i,sg_ambient_fc);
					
					seg->data.ambient_fc.ptsz=xml_countchildren(seg_tag);
					tag=xml_findfirstchild("v",seg_tag);
					
					for (j=0;j!=seg->data.ambient_fc.ptsz;j++) {
						xml_get_attribute_3_coord_int(tag,"c3",&seg->data.ambient_fc.x[j],&seg->data.ambient_fc.y[j],&seg->data.ambient_fc.z[j]);
						tag=xml_findnextchild(tag);
					}
					
					seg_tag=xml_findnextchild(seg_tag);
				}
			}

				// scenery
		
			main_obj_tag=xml_findfirstchild("Sceneries",portal_tag);
			if (main_obj_tag!=-1) {
			
				cnt=xml_countchildren(main_obj_tag);
				obj_tag=xml_findfirstchild("Scenery",main_obj_tag);
				
				for (k=0;k!=cnt;k++) {
					if (map->nscenery>=max_map_scenery) break;
					
					scenery=&map->sceneries[map->nscenery];
					map->nscenery++;
					
					xml_get_attribute_3_coord_int(obj_tag,"c3",&scenery->pnt.x,&scenery->pnt.y,&scenery->pnt.z);
					
					xml_get_attribute_text(obj_tag,"model_name",scenery->model_name,name_str_len);
					xml_get_attribute_text(obj_tag,"animation_name",scenery->animation_name,name_str_len);
					xml_get_attribute_3_coord_float(obj_tag,"angle",&scenery->ang.x,&scenery->ang.y,&scenery->ang.z);
					scenery->contact_object_on=xml_get_attribute_boolean(obj_tag,"contact");
					scenery->contact_projectile_on=xml_get_attribute_boolean(obj_tag,"contact_projectile");
					scenery->contact_hit_box=xml_get_attribute_boolean(obj_tag,"contact_hit_box");
					scenery->face_forward=xml_get_attribute_boolean(obj_tag,"face_forward");
					scenery->shadow=xml_get_attribute_boolean(obj_tag,"shadow");

					scenery->pnt.x=(scenery->pnt.x*map_enlarge)+(portal->x*map_enlarge);
					scenery->pnt.y=(scenery->pnt.y+1)*map_enlarge;
					scenery->pnt.z=(scenery->pnt.z*map_enlarge)+(portal->z*map_enlarge);
					
					scenery->resize=1.0f;
					
					obj_tag=xml_findnextchild(obj_tag);
				}
			}

				// lights
			
			main_light_tag=xml_findfirstchild("Lights",portal_tag);
			if (main_light_tag!=-1) {
			
				cnt=xml_countchildren(main_light_tag);
				light_tag=xml_findfirstchild("Light",main_light_tag);
				
				for (k=0;k!=cnt;k++) {
					if (map->nlight>=max_map_light) break;
					
					light=&map->lights[map->nlight];
					map->nlight++;
					
					light->type=xml_get_attribute_list(light_tag,"type",(char*)light_type_str);
					xml_get_attribute_3_coord_int(light_tag,"c3",&light->pnt.x,&light->pnt.y,&light->pnt.z);
					light->intensity=xml_get_attribute_int(light_tag,"intensity");
					xml_get_attribute_color(light_tag,"rgb",&light->col);
					light->on=!xml_get_attribute_boolean(light_tag,"off");
					
					light->pnt.x=(light->pnt.x*map_enlarge)+(portal->x*map_enlarge);
					light->pnt.y=(light->pnt.y+1)*map_enlarge;
					light->pnt.z=(light->pnt.z*map_enlarge)+(portal->z*map_enlarge);

					light->intensity*=map_enlarge;
					
					light->exponent=1.0f;
					light->direction=ld_all;
				
					light_tag=xml_findnextchild(light_tag);
				}
			}
			
				// sounds
				
			main_sound_tag=xml_findfirstchild("Sounds",portal_tag);
			if (main_sound_tag!=-1) {
			
				cnt=xml_countchildren(main_sound_tag);
				sound_tag=xml_findfirstchild("Sound",main_sound_tag);
				
				for (k=0;k!=cnt;k++) {
					if (map->nsound>=max_map_sound) break;
					
					sound=&map->sounds[map->nsound];
					map->nsound++;
					
					xml_get_attribute_text(sound_tag,"name",sound->name,file_str_len);
					xml_get_attribute_3_coord_int(sound_tag,"c3",&sound->pnt.x,&sound->pnt.y,&sound->pnt.z);
					sound->pitch=xml_get_attribute_float(sound_tag,"pitch");
					sound->on=!xml_get_attribute_boolean(sound_tag,"off");
					
					sound->pnt.x=(sound->pnt.x*map_enlarge)+(portal->x*map_enlarge);
					sound->pnt.y=(sound->pnt.y+1)*map_enlarge;
					sound->pnt.z=(sound->pnt.z*map_enlarge)+(portal->z*map_enlarge);
					
					sound_tag=xml_findnextchild(sound_tag);
				}
			}
			
				// particles
				
			main_particle_tag=xml_findfirstchild("Particles",portal_tag);
			if (main_particle_tag!=-1) {
			
				cnt=xml_countchildren(main_particle_tag);
				particle_tag=xml_findfirstchild("Particle",main_particle_tag);
				
				for (k=0;k!=cnt;k++) {
					if (map->nparticle>=max_map_particle) break;
					
					particle=&map->particles[map->nparticle];
					map->nparticle++;
					
					xml_get_attribute_text(particle_tag,"name",particle->name,file_str_len);
					xml_get_attribute_3_coord_int(particle_tag,"c3",&particle->pnt.x,&particle->pnt.y,&particle->pnt.z);
					particle->spawn_tick=xml_get_attribute_int(particle_tag,"spawn_tick");
					particle->slop_tick=xml_get_attribute_int(particle_tag,"slop_tick");
					particle->on=!xml_get_attribute_boolean(particle_tag,"off");
					
					particle->pnt.x=(particle->pnt.x*map_enlarge)+(portal->x*map_enlarge);
					particle->pnt.y=(particle->pnt.y+1)*map_enlarge;
					particle->pnt.z=(particle->pnt.z*map_enlarge)+(portal->z*map_enlarge);
					
					particle_tag=xml_findnextchild(particle_tag);
				}
			}
        
				// nodes
		
			main_node_tag=xml_findfirstchild("Nodes",portal_tag);
			if (main_node_tag!=-1) {
			
				cnt=xml_countchildren(main_node_tag);
				node_tag=xml_findfirstchild("Node",main_node_tag);
				
				for (k=0;k!=cnt;k++) {
				
					idx=xml_get_attribute_int(node_tag,"id");
					node=&map->nodes[idx];
					if (idx>=map->nnode) map->nnode=idx+1;

					node->idx=idx;

					for (j=0;j!=max_node_link;j++) {
						node->link[j]=-1;
					}
					for (j=0;j!=max_node;j++) {
						node->path_hint[j]=-1;
					}
					
					xml_get_attribute_3_coord_int(node_tag,"c3",&node->pnt.x,&node->pnt.y,&node->pnt.z);

					xml_get_attribute_3_coord_float(node_tag,"angle",&node->ang.x,&node->ang.y,&node->ang.z);

					xml_get_attribute_text(node_tag,"name",node->name,name_str_len);
					node->event_id=xml_get_attribute_int_default(node_tag,"event_id",0);
					
					tag=xml_findfirstchild("Link",node_tag);
					xml_get_attribute_short_array(tag,"node",node->link,max_node_link);
					
					tag=xml_findfirstchild("Hint",node_tag);
					xml_get_attribute_short_array(tag,"node",node->path_hint,map->nnode);

					node->pnt.x=(node->pnt.x*map_enlarge)+(portal->x*map_enlarge);
					node->pnt.y=(node->pnt.y+1)*map_enlarge;
					node->pnt.z=(node->pnt.z*map_enlarge)+(portal->z*map_enlarge);

					node->follow_camera=FALSE;
					
					node_tag=xml_findnextchild(node_tag);
				}
			}

				// spots
		
			main_obj_tag=xml_findfirstchild("Spots",portal_tag);
			if (main_obj_tag!=-1) {
			
				cnt=xml_countchildren(main_obj_tag);
				obj_tag=xml_findfirstchild("Spot",main_obj_tag);
				
				for (k=0;k!=cnt;k++) {
				
					idx=xml_get_attribute_int(obj_tag,"id");
					spot=&map->spots[idx];
					if (idx>=map->nspot) map->nspot=idx+1;
					
					xml_get_attribute_3_coord_int(obj_tag,"c3",&spot->pnt.x,&spot->pnt.y,&spot->pnt.z);
					
					xml_get_attribute_text(obj_tag,"name",spot->name,name_str_len);
					xml_get_attribute_text(obj_tag,"type",spot->type,name_str_len);
					if (!xml_get_attribute_text(obj_tag,"script",spot->script,name_str_len)) {		// supergumba -- remove later -- here to fix XML from older version
						strcpy(spot->script,spot->name);
					}
					xml_get_attribute_text(obj_tag,"display_model",spot->display_model,name_str_len);
					xml_get_attribute_text(obj_tag,"params",spot->params,param_str_len);
					spot->ang.y=xml_get_attribute_float(obj_tag,"angle");
					
					spot->skill=skill_easy;
					spot->spawn=spawn_always;

					spot->pnt.x=(spot->pnt.x*map_enlarge)+(portal->x*map_enlarge);
					spot->pnt.y=(spot->pnt.y+1)*map_enlarge;
					spot->pnt.z=(spot->pnt.z*map_enlarge)+(portal->z*map_enlarge);
					
					obj_tag=xml_findnextchild(obj_tag);
				}
			}
             
            portal++;
			portal_tag=xml_findnextchild(portal_tag);
        }
    }

	convert_ok=map_convert_v1(map,nportal,portals,seg_cnt,seg_list);
	
	free(portals);
	free(seg_list);
	
		// center map
		
	map_center(map);
	
	return(convert_ok);
}