/* xml_loadsave_season_stats.c Bygfoot Football Manager -- a small and simple GTK2-based football management game. http://bygfoot.sourceforge.net Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "file.h" #include "free.h" #include "misc.h" #include "stat.h" #include "variables.h" #include "xml.h" #include "xml_loadsave_league_stat.h" #include "xml_loadsave_season_stats.h" enum { TAG_SEASON_STATS = TAG_START_SEASON_STATS, TAG_SEASON_STAT, TAG_SEASON_NUMBER, TAG_LEAGUE_CHAMPS, TAG_CUP_CHAMPS, TAG_CHAMP_STAT, TAG_CHAMP_STAT_TEAM_NAME, TAG_CHAMP_STAT_CL_NAME, TAG_LEAGUE_STAT_FILE, TAG_END }; gint state, in_state; ChampStat new_champ_stat; SeasonStat new_season_stat; const gchar *dirname2; void xml_loadsave_season_stats_start_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer user_data, GError **error) { gint i; gint tag = xml_get_tag_from_name(element_name); gboolean valid_tag = FALSE; for(i=TAG_SEASON_STATS;i\n", TAG_SEASON_STATS); for(i=0;ilen;i++) { fprintf(fil, "<_%d>\n", TAG_SEASON_STAT); xml_write_int(fil, g_array_index(season_stats, SeasonStat, i).season_number, TAG_SEASON_NUMBER, I1); fprintf(fil, "%s<_%d>\n", I1, TAG_LEAGUE_CHAMPS); for(j=0;jlen;j++) { fprintf(fil, "%s<_%d>\n", I2, TAG_CHAMP_STAT); xml_write_string(fil, g_array_index( g_array_index( season_stats, SeasonStat, i).league_champs, ChampStat, j).team_name, TAG_CHAMP_STAT_TEAM_NAME, I2); xml_write_string(fil, g_array_index( g_array_index( season_stats, SeasonStat, i).league_champs, ChampStat, j).cl_name, TAG_CHAMP_STAT_CL_NAME, I2); fprintf(fil, "%s\n", I2, TAG_CHAMP_STAT); } fprintf(fil, "%s\n", I1, TAG_LEAGUE_CHAMPS); fprintf(fil, "%s<_%d>\n", I1, TAG_CUP_CHAMPS); for(j=0;jlen;j++) { fprintf(fil, "%s<_%d>\n", I2, TAG_CHAMP_STAT); xml_write_string(fil, g_array_index( g_array_index( season_stats, SeasonStat, i).cup_champs, ChampStat, j).team_name, TAG_CHAMP_STAT_TEAM_NAME, I2); xml_write_string(fil, g_array_index( g_array_index( season_stats, SeasonStat, i).cup_champs, ChampStat, j).cl_name, TAG_CHAMP_STAT_CL_NAME, I2); fprintf(fil, "%s\n", I2, TAG_CHAMP_STAT); } fprintf(fil, "%s\n", I1, TAG_CUP_CHAMPS); for(j=0;jlen;j++) { sprintf(buf, "%s___season_stats_league_stat_%02d-%02d.xml", prefix, i, j); basename = g_path_get_basename(buf); xml_write_string(fil, basename, TAG_LEAGUE_STAT_FILE, I1); xml_loadsave_league_stat_write(buf, &g_array_index( g_array_index(season_stats, SeasonStat, i).league_stats, LeagueStat, j)); g_free(basename); } fprintf(fil, "\n", TAG_SEASON_STAT); } fprintf(fil, "\n", TAG_SEASON_STATS); fclose(fil); }