/* xml_loadsave_players.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 "misc.h" #include "player.h" #include "team.h" #include "xml.h" #include "xml_loadsave_players.h" enum { TAG_PLAYERS = TAG_START_PLAYERS, TAG_PLAYER, TAG_PLAYER_NAME, TAG_PLAYER_POS, TAG_PLAYER_CPOS, TAG_PLAYER_HEALTH, TAG_PLAYER_RECOVERY, TAG_PLAYER_ID, TAG_PLAYER_VALUE, TAG_PLAYER_WAGE, TAG_PLAYER_OFFERS, TAG_PLAYER_SKILL, TAG_PLAYER_CSKILL, TAG_PLAYER_TALENT, TAG_PLAYER_ETAL, TAG_PLAYER_FITNESS, TAG_PLAYER_LSU, TAG_PLAYER_AGE, TAG_PLAYER_PEAK_AGE, TAG_PLAYER_PEAK_REGION, TAG_PLAYER_CONTRACT, TAG_PLAYER_PARTICIPATION, TAG_PLAYER_GAMES_GOAL, TAG_PLAYER_GAMES_GOAL_CLID, TAG_PLAYER_GAMES_GOAL_GAMES, TAG_PLAYER_GAMES_GOAL_GOALS, TAG_PLAYER_GAMES_GOAL_SHOTS, TAG_PLAYER_CARD, TAG_PLAYER_CARD_CLID, TAG_PLAYER_CARD_YELLOW, TAG_PLAYER_CARD_RED, TAG_PLAYER_CAREER, TAG_PLAYER_STREAK, TAG_PLAYER_STREAK_COUNT, TAG_PLAYER_STREAK_PROB, TAG_END }; gint state, etalidx, careeridx; Player new_player; PlayerGamesGoals new_games_goals; PlayerCard new_card; void xml_loadsave_players_start_element(gint tag, Team *tm) { #ifdef DEBUG printf("xml_loadsave_players_start_element\n"); #endif gint i; gboolean valid_tag = FALSE; for(i=TAG_PLAYERS;i\n", I1, TAG_PLAYERS); for(i=0;ilen;i++) xml_loadsave_players_write_player(fil, &g_array_index(players, Player, i)); fprintf(fil, "%s\n", I1, TAG_PLAYERS); } void xml_loadsave_players_write_player(FILE *fil, const Player *pl) { #ifdef DEBUG printf("xml_loadsave_players_write_player\n"); #endif gint i; fprintf(fil, "%s<_%d>\n", I1, TAG_PLAYER); xml_write_string(fil, pl->name, TAG_PLAYER_NAME, I2); xml_write_int(fil, pl->pos, TAG_PLAYER_POS, I2); xml_write_int(fil, pl->cpos, TAG_PLAYER_CPOS, I2); xml_write_int(fil, pl->health, TAG_PLAYER_HEALTH, I2); xml_write_int(fil, pl->recovery, TAG_PLAYER_RECOVERY, I2); xml_write_int(fil, pl->id, TAG_PLAYER_ID, I2); xml_write_int(fil, pl->value, TAG_PLAYER_VALUE, I2); xml_write_int(fil, pl->wage, TAG_PLAYER_WAGE, I2); xml_write_int(fil, pl->offers, TAG_PLAYER_OFFERS, I2); xml_write_int(fil, pl->participation, TAG_PLAYER_PARTICIPATION, I2); xml_write_float(fil, pl->skill, TAG_PLAYER_SKILL, I2); xml_write_float(fil, pl->cskill, TAG_PLAYER_CSKILL, I2); xml_write_float(fil, pl->talent, TAG_PLAYER_TALENT, I2); xml_write_float(fil, pl->fitness, TAG_PLAYER_FITNESS, I2); xml_write_float(fil, pl->lsu, TAG_PLAYER_LSU, I2); xml_write_float(fil, pl->age, TAG_PLAYER_AGE, I2); xml_write_float(fil, pl->peak_age, TAG_PLAYER_PEAK_AGE, I2); xml_write_float(fil, pl->peak_region, TAG_PLAYER_PEAK_REGION, I2); xml_write_float(fil, pl->contract, TAG_PLAYER_CONTRACT, I2); for(i=0;i<4;i++) xml_write_float(fil, pl->etal[i], TAG_PLAYER_ETAL, I3); for(i=0;icareer[i], TAG_PLAYER_CAREER, I2); xml_write_int(fil, pl->streak, TAG_PLAYER_STREAK, I2); xml_write_float(fil, pl->streak_count, TAG_PLAYER_STREAK_COUNT, I2); xml_write_float(fil, pl->streak_prob, TAG_PLAYER_STREAK_PROB, I2); for(i=0;igames_goals->len;i++) { fprintf(fil, "%s<_%d>\n", I2, TAG_PLAYER_GAMES_GOAL); xml_write_int(fil, g_array_index(pl->games_goals, PlayerGamesGoals, i).clid, TAG_PLAYER_GAMES_GOAL_CLID, I3); xml_write_int(fil, g_array_index(pl->games_goals, PlayerGamesGoals, i).games, TAG_PLAYER_GAMES_GOAL_GAMES, I3); xml_write_int(fil, g_array_index(pl->games_goals, PlayerGamesGoals, i).goals, TAG_PLAYER_GAMES_GOAL_GOALS, I3); xml_write_int(fil, g_array_index(pl->games_goals, PlayerGamesGoals, i).shots, TAG_PLAYER_GAMES_GOAL_SHOTS, I3); fprintf(fil, "%s\n", I2, TAG_PLAYER_GAMES_GOAL); } for(i=0;icards->len;i++) { fprintf(fil, "%s<_%d>\n", I2, TAG_PLAYER_CARD); xml_write_int(fil, g_array_index(pl->cards, PlayerCard, i).clid, TAG_PLAYER_CARD_CLID, I3); xml_write_int(fil, g_array_index(pl->cards, PlayerCard, i).yellow, TAG_PLAYER_CARD_YELLOW, I3); xml_write_int(fil, g_array_index(pl->cards, PlayerCard, i).red, TAG_PLAYER_CARD_RED, I3); fprintf(fil, "%s\n", I2, TAG_PLAYER_CARD); } fprintf(fil, "%s\n", I1, TAG_PLAYER); }