/* xml_loadsave_misc.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 "bet_struct.h" #include "cup.h" #include "file.h" #include "fixture.h" #include "free.h" #include "misc.h" #include "xml.h" #include "variables.h" #include "xml_loadsave_misc.h" #include "xml_loadsave_cup.h" #include "xml_loadsave_league.h" enum XmlLoadSaveCountryTags { TAG_MISC = TAG_START_MISC, TAG_MISC_RATING, TAG_MISC_SEASON, TAG_MISC_WEEK, TAG_MISC_WEEK_ROUND, TAG_MISC_COUNTER, TAG_MISC_ALLCUP, TAG_MISC_BET0, TAG_MISC_BET1, TAG_MISC_BET_FIX_ID, TAG_MISC_BET_ODD, TAG_MISC_VERSION, TAG_END }; gint state, countidx, oddidx, betidx; BetMatch new_bet; void xml_loadsave_misc_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_MISC;i\n", TAG_MISC); xml_write_string(fil, VERS, TAG_MISC_VERSION, I0); xml_write_string(fil, country.name, TAG_NAME, I0); xml_write_string(fil, country.symbol, TAG_SYMBOL, I0); xml_write_string(fil, country.sid, TAG_SID, I0); xml_write_int(fil, country.rating, TAG_MISC_RATING, I0); xml_write_int(fil, season, TAG_MISC_SEASON, I0); xml_write_int(fil, week, TAG_MISC_WEEK, I0); xml_write_int(fil, week_round, TAG_MISC_WEEK_ROUND, I0); for(i=0;ilen;i++) xml_write_int(fil, acp(i)->id, TAG_MISC_ALLCUP, I0); xml_loadsave_misc_write_bets(fil); fprintf(fil, "\n", TAG_MISC); fclose(fil); } /** Write the bets arrays into the file. */ void xml_loadsave_misc_write_bets(FILE *fil) { gint i, j, k; for(i=0;i<2;i++) for(j=0;jlen;j++) { fprintf(fil, "%s<_%d>\n", I0, (i == 0) ? TAG_MISC_BET0 : TAG_MISC_BET1); xml_write_int(fil, g_array_index(bets[i], BetMatch, j).fix_id, TAG_MISC_BET_FIX_ID, I1); for(k=0;k<3;k++) xml_write_float(fil, g_array_index(bets[i], BetMatch, j).odds[k], TAG_MISC_BET_ODD, I1); fprintf(fil, "%s\n", I0, (i == 0) ? TAG_MISC_BET0 : TAG_MISC_BET1); } }