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); }
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); }