From aeb715bcf94304664ee2f2be2981d025b8e91973 Mon Sep 17 00:00:00 2001 From: gyboth Date: Fri, 1 Jul 2005 20:51:46 +0000 Subject: [PATCH] "Commentary improvements." --- Makefile.am | 2 +- configure.in | 2 +- po/bygfoot.pot | 64 ++-- src/Makefile.am | 8 +- src/callback_func.c | 22 +- src/callbacks.c | 1 - src/file.c | 12 +- src/free.c | 30 +- src/free.h | 3 + src/game_gui.c | 6 +- src/gui.c | 2 +- src/lg_commentary.c | 609 +++++++++++++++++++++----------- src/lg_commentary.h | 57 +-- src/lg_commentary_struct.h | 21 ++ src/live_game.c | 83 +++-- src/live_game.h | 6 + src/main.c | 3 +- src/misc.c | 17 +- src/misc.h | 12 +- src/treeview.c | 24 +- src/treeview_helper.c | 4 +- src/user.c | 16 +- src/variables.h | 2 +- src/xml_lg_commentary.c | 43 ++- support_files/bygfoot_constants | 6 +- 25 files changed, 658 insertions(+), 397 deletions(-) create mode 100644 src/lg_commentary_struct.h diff --git a/Makefile.am b/Makefile.am index 66c883f9..cbb9ddee 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,7 +13,7 @@ EXTRA_DIST = \ SUPPORT_DIRS = support_files support_files/names support_files/pixmaps support_files/pixmaps/history support_files/pixmaps/symbols support_files/pixmaps/live_game support_files/definitions support_files/definitions/brazil support_files/definitions/short_leagues support_files/definitions/europe support_files/definitions/misc support_files/definitions/belgium support_files/definitions/england support_files/definitions/romania support_files/definitions/france support_files/definitions/usa support_files/definitions/germany support_files/definitions/scotland support_files/definitions/short_leagues_south_america support_files/definitions/italy support_files/definitions/argentina support_files/definitions/wales support_files/definitions/ireland support_files/definitions/scg support_files/lg_commentary -SUPPORT_FILES = support_files/names/player_names_brazil.xml support_files/names/player_names_england.xml support_files/names/player_names_belgium.xml support_files/names/player_names_usa.xml support_files/names/player_names_general.xml support_files/names/player_names_germany.xml support_files/names/player_names_romania.xml support_files/names/player_names_scotland.xml support_files/names/player_names_france.xml support_files/names/player_names_scg.xml support_files/names/player_names_italy.xml support_files/bygfoot.conf support_files/pixmaps/history/champion.png support_files/pixmaps/history/start_game.png support_files/pixmaps/history/fire_finance.png support_files/pixmaps/history/fire_failure.png support_files/pixmaps/history/job_offer.png support_files/pixmaps/history/end_season.png support_files/pixmaps/history/promoted.png support_files/pixmaps/history/relegated.png support_files/pixmaps/history/win_final.png support_files/pixmaps/history/lose_final.png support_files/pixmaps/history/reach_cup_round.png support_files/pixmaps/menu_history.png support_files/pixmaps/bygfoot_icon.png support_files/pixmaps/menu_league_stats.png support_files/pixmaps/new_week.png support_files/pixmaps/preview.png support_files/pixmaps/symbols/flag_germany.png support_files/pixmaps/symbols/flag_ch.png support_files/pixmaps/symbols/flag_cz.png support_files/pixmaps/symbols/flag_usa.png support_files/pixmaps/symbols/flag_dk.png support_files/pixmaps/symbols/flag_scg.png support_files/pixmaps/symbols/flag_es.png support_files/pixmaps/symbols/flag_eu.png support_files/pixmaps/symbols/flag_gr.png support_files/pixmaps/symbols/flag_hu.png support_files/pixmaps/symbols/flag_wales.png support_files/pixmaps/symbols/flag_nl.png support_files/pixmaps/symbols/flag_pt.png support_files/pixmaps/symbols/flag_ru.png support_files/pixmaps/symbols/flag_tr.png support_files/pixmaps/symbols/flag_uk.png support_files/pixmaps/symbols/flag_belgium.png support_files/pixmaps/symbols/flag_england.png support_files/pixmaps/symbols/flag_france.png support_files/pixmaps/symbols/flag_romania.png support_files/pixmaps/symbols/flag_brazil.png support_files/pixmaps/symbols/flag_scotland.png support_files/pixmaps/symbols/flag_ecuador.png support_files/pixmaps/symbols/flag_argentina.png support_files/pixmaps/symbols/flag_bolivia.png support_files/pixmaps/symbols/flag_chile.png support_files/pixmaps/symbols/flag_colombia.png support_files/pixmaps/symbols/flag_peru.png support_files/pixmaps/symbols/flag_paraguay.png support_files/pixmaps/symbols/flag_uruguay.png support_files/pixmaps/symbols/flag_venezuela.png support_files/pixmaps/symbols/flag_mexico.png support_files/pixmaps/symbols/flag_italy.png support_files/pixmaps/symbols/flag_ireland.png support_files/pixmaps/symbols/flag_n_ireland.png support_files/pixmaps/symbols/map_ireland.png support_files/pixmaps/symbols/flag_poland.png support_files/pixmaps/transfers.png support_files/pixmaps/menu_league_results.png support_files/pixmaps/menu_table.png support_files/pixmaps/menu_fixtures_comp.png support_files/pixmaps/menu_fixtures.png support_files/pixmaps/menu_boost.png support_files/pixmaps/menu_browse_tms.png support_files/pixmaps/menu_finances.png support_files/pixmaps/menu_last_match.png support_files/pixmaps/live_game/sub.png support_files/pixmaps/live_game/red.png support_files/pixmaps/live_game/save.png support_files/pixmaps/live_game/goal.png support_files/pixmaps/live_game/yellow.png support_files/pixmaps/live_game/scoring_chance.png support_files/pixmaps/live_game/injury_temp.png support_files/pixmaps/live_game/injury.png support_files/pixmaps/live_game/structure_change.png support_files/pixmaps/live_game/whistle.png support_files/pixmaps/live_game/miss.png support_files/pixmaps/live_game/foul.png support_files/pixmaps/live_game/cross_bar.png support_files/pixmaps/live_game/post.png support_files/pixmaps/live_game/penalty.png support_files/pixmaps/live_game/stadium_brkn.png support_files/pixmaps/live_game/stadium_fire.png support_files/pixmaps/live_game/stadium_riot.png support_files/pixmaps/live_game/header.png support_files/pixmaps/live_game/goal_own.png support_files/pixmaps/live_game/lost_possession.png support_files/pixmaps/menu_match_stats.png support_files/pixmaps/menu_physio.png support_files/pixmaps/boost_anti.png support_files/pixmaps/boost_off.png support_files/pixmaps/boost_on.png support_files/pixmaps/menu_player_browse.png support_files/pixmaps/style_def.png support_files/pixmaps/style_atk.png support_files/pixmaps/style_bal.png support_files/pixmaps/style_all_atk.png support_files/pixmaps/style_all_def.png support_files/pixmaps/menu_player_contract.png support_files/pixmaps/menu_player_fire.png support_files/pixmaps/menu_player_info.png support_files/pixmaps/menu_player_put_transfer.png support_files/pixmaps/menu_player_remove_transfer.png support_files/pixmaps/table_up.png support_files/pixmaps/table_down.png support_files/pixmaps/table_stay.png support_files/pixmaps/menu_player_shoots.png support_files/pixmaps/menu_rearrange.png support_files/pixmaps/menu_scout.png support_files/pixmaps/menu_stadium.png support_files/pixmaps/menu_structure.png support_files/pixmaps/menu_style.png support_files/definitions/brazil/country_brazil.xml support_files/definitions/brazil/cup_brazil_prom_games2.xml support_files/definitions/brazil/cup_brazil_prom_games3.xml support_files/definitions/brazil/cup_brazil_prom_games4.xml support_files/definitions/brazil/cup_brazil_prom_games5.xml support_files/definitions/brazil/cup_brazil_prom_games6.xml support_files/definitions/brazil/league_brazil1.xml support_files/definitions/brazil/league_brazil2.xml support_files/definitions/brazil/league_brazil3.xml support_files/definitions/brazil/league_brazil4.xml support_files/definitions/brazil/league_brazil5.xml support_files/definitions/brazil/league_brazil6.xml support_files/definitions/brazil/cup_brazil_sul_am_bo_ve.xml support_files/definitions/brazil/cup_brazil_libertadores.xml support_files/definitions/brazil/cup_brazil_copa_do_brasil.xml support_files/definitions/brazil/cup_brazil_sul_am_br2.xml support_files/definitions/brazil/cup_brazil_sul_am_br1.xml support_files/definitions/brazil/cup_brazil_sul_am_br3.xml support_files/definitions/brazil/cup_brazil_sul_am_ar.xml support_files/definitions/brazil/cup_brazil_sul_am_br4.xml support_files/definitions/brazil/cup_brazil_sul_am_pa_ur.xml support_files/definitions/brazil/cup_brazil_sul_am_ch_pe.xml support_files/definitions/brazil/cup_brazil_sul_am_co_ec.xml support_files/definitions/brazil/cup_brazil_sul_am_knockout.xml support_files/definitions/brazil/cup_supercup_brazil_intercontinental.xml support_files/definitions/short_leagues/league_czech1_short.xml support_files/definitions/short_leagues/league_denmark1_short.xml support_files/definitions/short_leagues/league_greece1_short.xml support_files/definitions/short_leagues/league_netherlands1_short.xml support_files/definitions/short_leagues/league_portugal1_short.xml support_files/definitions/short_leagues/league_russia1_short.xml support_files/definitions/short_leagues/league_spain1_short.xml support_files/definitions/short_leagues/league_switzerland1_short.xml support_files/definitions/short_leagues/league_turkey1_short.xml support_files/definitions/short_leagues/league_ukraine1_short.xml support_files/definitions/europe/cup_europe_champ_league.xml support_files/definitions/europe/cup_europe_cwc.xml support_files/definitions/europe/league_europe_div.xml support_files/definitions/europe/cup_europe_uefa.xml support_files/definitions/europe/cup_supercup_europe_uefa.xml support_files/definitions/europe/cup_supercup_europe_intercontinental.xml support_files/definitions/misc/cup_supercup_league_vs_cup.xml support_files/definitions/belgium/country_belgium.xml support_files/definitions/belgium/cup_belgium.xml support_files/definitions/belgium/league_belgium2.xml support_files/definitions/belgium/league_belgium1.xml support_files/definitions/belgium/league_belgium3a.xml support_files/definitions/belgium/league_belgium3b.xml support_files/definitions/belgium/league_belgium4a.xml support_files/definitions/belgium/league_belgium4b.xml support_files/definitions/belgium/league_belgium4c.xml support_files/definitions/belgium/league_belgium4d.xml support_files/definitions/belgium/cup_belgium_eindronde2.xml support_files/definitions/england/country_england.xml support_files/definitions/england/league_england1.xml support_files/definitions/england/league_england2.xml support_files/definitions/england/league_england3.xml support_files/definitions/england/league_england4.xml support_files/definitions/england/league_england5.xml support_files/definitions/england/cup_england_fa.xml support_files/definitions/england/cup_england_prom_games2.xml support_files/definitions/england/cup_england_league.xml support_files/definitions/england/cup_england_prom_games3.xml support_files/definitions/england/cup_england_prom_games4.xml support_files/definitions/england/cup_england_prom_games5.xml support_files/definitions/romania/country_romania.xml support_files/definitions/romania/cup_romania_cupa.xml support_files/definitions/romania/cup_supercup_romania.xml support_files/definitions/romania/league_romania1.xml support_files/definitions/romania/league_romania2.xml support_files/definitions/romania/league_romania3.xml support_files/definitions/france/country_france.xml support_files/definitions/france/cup_france_coupe.xml support_files/definitions/france/league_france1.xml support_files/definitions/france/league_france2.xml support_files/definitions/france/league_france3.xml support_files/definitions/france/cup_france_ligue.xml support_files/definitions/france/league_france4a.xml support_files/definitions/france/league_france4b.xml support_files/definitions/france/league_france4c.xml support_files/definitions/france/league_france4d.xml support_files/definitions/usa/league_usa_econf.xml support_files/definitions/usa/country_usa.xml support_files/definitions/usa/league_usa_wconf.xml support_files/definitions/usa/cup_usa_eplayoff.xml support_files/definitions/usa/cup_usa_wplayoff.xml support_files/definitions/usa/cup_usa_mls_cup.xml support_files/definitions/germany/cup_germany_dfb.xml support_files/definitions/germany/league_germany1.xml support_files/definitions/germany/league_germany3a.xml support_files/definitions/germany/league_germany2.xml support_files/definitions/germany/league_germany3b.xml support_files/definitions/germany/country_germany.xml support_files/definitions/scotland/league_scotland1.xml support_files/definitions/scotland/country_scotland.xml support_files/definitions/scotland/league_scotland2.xml support_files/definitions/scotland/league_scotland3.xml support_files/definitions/scotland/league_scotland4.xml support_files/definitions/scotland/cup_scotland_fa.xml support_files/definitions/scotland/cup_scotland_league.xml support_files/definitions/short_leagues_south_america/league_bolivia1_short.xml support_files/definitions/short_leagues_south_america/league_chile1_short.xml support_files/definitions/short_leagues_south_america/league_colombia1_short.xml support_files/definitions/short_leagues_south_america/league_ecuador1_short.xml support_files/definitions/short_leagues_south_america/league_mexico1_short.xml support_files/definitions/short_leagues_south_america/league_paraguay1_short.xml support_files/definitions/short_leagues_south_america/league_peru1_short.xml support_files/definitions/short_leagues_south_america/league_uruguay1_short.xml support_files/definitions/short_leagues_south_america/league_venezuela1_short.xml support_files/definitions/italy/league_italy1.xml support_files/definitions/italy/cup_italy_coppa.xml support_files/definitions/italy/league_italy2.xml support_files/definitions/italy/league_italy3a.xml support_files/definitions/italy/league_italy3b.xml support_files/definitions/italy/country_italy.xml support_files/definitions/argentina/league_argentina1.xml support_files/definitions/wales/league_wales1.xml support_files/definitions/wales/league_wales2a.xml support_files/definitions/wales/league_wales2b.xml support_files/definitions/wales/country_wales.xml support_files/definitions/wales/cup_wales_welsh.xml support_files/definitions/wales/cup_wales_challenge.xml support_files/definitions/wales/cup_wales_premier.xml support_files/definitions/wales/league_wales_english.xml support_files/definitions/wales/cup_wales_uefa_q.xml support_files/definitions/wales/cup_wales_uefa.xml support_files/definitions/wales/cup_wales_cl.xml support_files/definitions/wales/cup_wales_cl_q.xml support_files/definitions/ireland/country_ireland.xml support_files/definitions/ireland/cup_ireland_league.xml support_files/definitions/ireland/cup_ireland_senior.xml support_files/definitions/ireland/league_ireland1.xml support_files/definitions/ireland/league_n_ireland1.xml support_files/definitions/ireland/league_ireland2.xml support_files/definitions/ireland/cup_ireland_prom_games.xml support_files/definitions/ireland/cup_ireland_setanta.xml support_files/definitions/ireland/cup_ireland_cl.xml support_files/definitions/ireland/cup_ireland_cl_q.xml support_files/definitions/ireland/cup_ireland_uefa.xml support_files/definitions/ireland/cup_ireland_uefa_q.xml support_files/definitions/scg/country_scg.xml support_files/definitions/scg/cup_scg.xml support_files/definitions/scg/league_scg2a.xml support_files/definitions/scg/league_scg2b.xml support_files/definitions/scg/league_scg1.xml support_files/bygfoot_constants support_files/bygfoot_user.conf support_files/lg_commentary/lg_commentary_de.xml support_files/lg_commentary/lg_commentary_en.xml support_files/bygfoot_app support_files/bygfoot_help support_files/bygfoot.conf.sav support_files/bygfoot_lg_tokens +SUPPORT_FILES = support_files/names/player_names_brazil.xml support_files/names/player_names_england.xml support_files/names/player_names_belgium.xml support_files/names/player_names_usa.xml support_files/names/player_names_general.xml support_files/names/player_names_germany.xml support_files/names/player_names_romania.xml support_files/names/player_names_scotland.xml support_files/names/player_names_france.xml support_files/names/player_names_scg.xml support_files/names/player_names_italy.xml support_files/bygfoot.conf support_files/pixmaps/history/champion.png support_files/pixmaps/history/start_game.png support_files/pixmaps/history/fire_finance.png support_files/pixmaps/history/fire_failure.png support_files/pixmaps/history/job_offer.png support_files/pixmaps/history/end_season.png support_files/pixmaps/history/promoted.png support_files/pixmaps/history/relegated.png support_files/pixmaps/history/win_final.png support_files/pixmaps/history/lose_final.png support_files/pixmaps/history/reach_cup_round.png support_files/pixmaps/menu_history.png support_files/pixmaps/bygfoot_icon.png support_files/pixmaps/menu_league_stats.png support_files/pixmaps/new_week.png support_files/pixmaps/preview.png support_files/pixmaps/symbols/flag_germany.png support_files/pixmaps/symbols/flag_ch.png support_files/pixmaps/symbols/flag_cz.png support_files/pixmaps/symbols/flag_usa.png support_files/pixmaps/symbols/flag_dk.png support_files/pixmaps/symbols/flag_scg.png support_files/pixmaps/symbols/flag_es.png support_files/pixmaps/symbols/flag_eu.png support_files/pixmaps/symbols/flag_gr.png support_files/pixmaps/symbols/flag_hu.png support_files/pixmaps/symbols/flag_wales.png support_files/pixmaps/symbols/flag_nl.png support_files/pixmaps/symbols/flag_pt.png support_files/pixmaps/symbols/flag_ru.png support_files/pixmaps/symbols/flag_tr.png support_files/pixmaps/symbols/flag_uk.png support_files/pixmaps/symbols/flag_belgium.png support_files/pixmaps/symbols/flag_england.png support_files/pixmaps/symbols/flag_france.png support_files/pixmaps/symbols/flag_romania.png support_files/pixmaps/symbols/flag_brazil.png support_files/pixmaps/symbols/flag_scotland.png support_files/pixmaps/symbols/flag_ecuador.png support_files/pixmaps/symbols/flag_argentina.png support_files/pixmaps/symbols/flag_bolivia.png support_files/pixmaps/symbols/flag_chile.png support_files/pixmaps/symbols/flag_colombia.png support_files/pixmaps/symbols/flag_peru.png support_files/pixmaps/symbols/flag_paraguay.png support_files/pixmaps/symbols/flag_uruguay.png support_files/pixmaps/symbols/flag_venezuela.png support_files/pixmaps/symbols/flag_mexico.png support_files/pixmaps/symbols/flag_italy.png support_files/pixmaps/symbols/flag_ireland.png support_files/pixmaps/symbols/flag_n_ireland.png support_files/pixmaps/symbols/map_ireland.png support_files/pixmaps/symbols/flag_poland.png support_files/pixmaps/transfers.png support_files/pixmaps/menu_league_results.png support_files/pixmaps/menu_table.png support_files/pixmaps/menu_fixtures_comp.png support_files/pixmaps/menu_fixtures.png support_files/pixmaps/menu_boost.png support_files/pixmaps/menu_browse_tms.png support_files/pixmaps/menu_finances.png support_files/pixmaps/menu_last_match.png support_files/pixmaps/live_game/sub.png support_files/pixmaps/live_game/red.png support_files/pixmaps/live_game/save.png support_files/pixmaps/live_game/goal.png support_files/pixmaps/live_game/yellow.png support_files/pixmaps/live_game/scoring_chance.png support_files/pixmaps/live_game/injury_temp.png support_files/pixmaps/live_game/injury.png support_files/pixmaps/live_game/structure_change.png support_files/pixmaps/live_game/whistle.png support_files/pixmaps/live_game/miss.png support_files/pixmaps/live_game/foul.png support_files/pixmaps/live_game/cross_bar.png support_files/pixmaps/live_game/post.png support_files/pixmaps/live_game/penalty.png support_files/pixmaps/live_game/stadium_brkn.png support_files/pixmaps/live_game/stadium_fire.png support_files/pixmaps/live_game/stadium_riot.png support_files/pixmaps/live_game/header.png support_files/pixmaps/live_game/goal_own.png support_files/pixmaps/live_game/lost_possession.png support_files/pixmaps/menu_match_stats.png support_files/pixmaps/menu_physio.png support_files/pixmaps/boost_anti.png support_files/pixmaps/boost_off.png support_files/pixmaps/boost_on.png support_files/pixmaps/menu_player_browse.png support_files/pixmaps/style_def.png support_files/pixmaps/style_atk.png support_files/pixmaps/style_bal.png support_files/pixmaps/style_all_atk.png support_files/pixmaps/style_all_def.png support_files/pixmaps/menu_player_contract.png support_files/pixmaps/menu_player_fire.png support_files/pixmaps/menu_player_info.png support_files/pixmaps/menu_player_put_transfer.png support_files/pixmaps/menu_player_remove_transfer.png support_files/pixmaps/table_up.png support_files/pixmaps/table_down.png support_files/pixmaps/table_stay.png support_files/pixmaps/menu_player_shoots.png support_files/pixmaps/menu_rearrange.png support_files/pixmaps/menu_scout.png support_files/pixmaps/menu_stadium.png support_files/pixmaps/menu_structure.png support_files/pixmaps/menu_style.png support_files/definitions/brazil/country_brazil.xml support_files/definitions/brazil/cup_brazil_prom_games2.xml support_files/definitions/brazil/cup_brazil_prom_games3.xml support_files/definitions/brazil/cup_brazil_prom_games4.xml support_files/definitions/brazil/cup_brazil_prom_games5.xml support_files/definitions/brazil/cup_brazil_prom_games6.xml support_files/definitions/brazil/league_brazil1.xml support_files/definitions/brazil/league_brazil2.xml support_files/definitions/brazil/league_brazil3.xml support_files/definitions/brazil/league_brazil4.xml support_files/definitions/brazil/league_brazil5.xml support_files/definitions/brazil/league_brazil6.xml support_files/definitions/brazil/cup_brazil_sul_am_bo_ve.xml support_files/definitions/brazil/cup_brazil_libertadores.xml support_files/definitions/brazil/cup_brazil_copa_do_brasil.xml support_files/definitions/brazil/cup_brazil_sul_am_br2.xml support_files/definitions/brazil/cup_brazil_sul_am_br1.xml support_files/definitions/brazil/cup_brazil_sul_am_br3.xml support_files/definitions/brazil/cup_brazil_sul_am_ar.xml support_files/definitions/brazil/cup_brazil_sul_am_br4.xml support_files/definitions/brazil/cup_brazil_sul_am_pa_ur.xml support_files/definitions/brazil/cup_brazil_sul_am_ch_pe.xml support_files/definitions/brazil/cup_brazil_sul_am_co_ec.xml support_files/definitions/brazil/cup_brazil_sul_am_knockout.xml support_files/definitions/brazil/cup_supercup_brazil_intercontinental.xml support_files/definitions/short_leagues/league_czech1_short.xml support_files/definitions/short_leagues/league_denmark1_short.xml support_files/definitions/short_leagues/league_greece1_short.xml support_files/definitions/short_leagues/league_netherlands1_short.xml support_files/definitions/short_leagues/league_portugal1_short.xml support_files/definitions/short_leagues/league_russia1_short.xml support_files/definitions/short_leagues/league_spain1_short.xml support_files/definitions/short_leagues/league_switzerland1_short.xml support_files/definitions/short_leagues/league_turkey1_short.xml support_files/definitions/short_leagues/league_ukraine1_short.xml support_files/definitions/europe/cup_europe_champ_league.xml support_files/definitions/europe/cup_europe_cwc.xml support_files/definitions/europe/league_europe_div.xml support_files/definitions/europe/cup_europe_uefa.xml support_files/definitions/europe/cup_supercup_europe_uefa.xml support_files/definitions/europe/cup_supercup_europe_intercontinental.xml support_files/definitions/misc/cup_supercup_league_vs_cup.xml support_files/definitions/belgium/country_belgium.xml support_files/definitions/belgium/cup_belgium.xml support_files/definitions/belgium/league_belgium2.xml support_files/definitions/belgium/league_belgium1.xml support_files/definitions/belgium/league_belgium3a.xml support_files/definitions/belgium/league_belgium3b.xml support_files/definitions/belgium/league_belgium4a.xml support_files/definitions/belgium/league_belgium4b.xml support_files/definitions/belgium/league_belgium4c.xml support_files/definitions/belgium/league_belgium4d.xml support_files/definitions/belgium/cup_belgium_eindronde2.xml support_files/definitions/england/country_england.xml support_files/definitions/england/league_england1.xml support_files/definitions/england/league_england2.xml support_files/definitions/england/league_england3.xml support_files/definitions/england/league_england4.xml support_files/definitions/england/league_england5.xml support_files/definitions/england/cup_england_fa.xml support_files/definitions/england/cup_england_prom_games2.xml support_files/definitions/england/cup_england_league.xml support_files/definitions/england/cup_england_prom_games3.xml support_files/definitions/england/cup_england_prom_games4.xml support_files/definitions/england/cup_england_prom_games5.xml support_files/definitions/romania/country_romania.xml support_files/definitions/romania/cup_romania_cupa.xml support_files/definitions/romania/cup_supercup_romania.xml support_files/definitions/romania/league_romania1.xml support_files/definitions/romania/league_romania2.xml support_files/definitions/romania/league_romania3.xml support_files/definitions/france/country_france.xml support_files/definitions/france/cup_france_coupe.xml support_files/definitions/france/league_france1.xml support_files/definitions/france/league_france2.xml support_files/definitions/france/league_france3.xml support_files/definitions/france/cup_france_ligue.xml support_files/definitions/france/league_france4a.xml support_files/definitions/france/league_france4b.xml support_files/definitions/france/league_france4c.xml support_files/definitions/france/league_france4d.xml support_files/definitions/usa/league_usa_econf.xml support_files/definitions/usa/country_usa.xml support_files/definitions/usa/league_usa_wconf.xml support_files/definitions/usa/cup_usa_eplayoff.xml support_files/definitions/usa/cup_usa_wplayoff.xml support_files/definitions/usa/cup_usa_mls_cup.xml support_files/definitions/germany/cup_germany_dfb.xml support_files/definitions/germany/league_germany1.xml support_files/definitions/germany/league_germany3a.xml support_files/definitions/germany/league_germany2.xml support_files/definitions/germany/league_germany3b.xml support_files/definitions/germany/country_germany.xml support_files/definitions/scotland/league_scotland1.xml support_files/definitions/scotland/country_scotland.xml support_files/definitions/scotland/league_scotland2.xml support_files/definitions/scotland/league_scotland3.xml support_files/definitions/scotland/league_scotland4.xml support_files/definitions/scotland/cup_scotland_fa.xml support_files/definitions/scotland/cup_scotland_league.xml support_files/definitions/short_leagues_south_america/league_bolivia1_short.xml support_files/definitions/short_leagues_south_america/league_chile1_short.xml support_files/definitions/short_leagues_south_america/league_colombia1_short.xml support_files/definitions/short_leagues_south_america/league_ecuador1_short.xml support_files/definitions/short_leagues_south_america/league_mexico1_short.xml support_files/definitions/short_leagues_south_america/league_paraguay1_short.xml support_files/definitions/short_leagues_south_america/league_peru1_short.xml support_files/definitions/short_leagues_south_america/league_uruguay1_short.xml support_files/definitions/short_leagues_south_america/league_venezuela1_short.xml support_files/definitions/italy/league_italy1.xml support_files/definitions/italy/cup_italy_coppa.xml support_files/definitions/italy/league_italy2.xml support_files/definitions/italy/league_italy3a.xml support_files/definitions/italy/league_italy3b.xml support_files/definitions/italy/country_italy.xml support_files/definitions/argentina/league_argentina1.xml support_files/definitions/wales/league_wales1.xml support_files/definitions/wales/league_wales2a.xml support_files/definitions/wales/league_wales2b.xml support_files/definitions/wales/country_wales.xml support_files/definitions/wales/cup_wales_welsh.xml support_files/definitions/wales/cup_wales_challenge.xml support_files/definitions/wales/cup_wales_premier.xml support_files/definitions/wales/league_wales_english.xml support_files/definitions/wales/cup_wales_uefa_q.xml support_files/definitions/wales/cup_wales_uefa.xml support_files/definitions/wales/cup_wales_cl.xml support_files/definitions/wales/cup_wales_cl_q.xml support_files/definitions/ireland/country_ireland.xml support_files/definitions/ireland/cup_ireland_league.xml support_files/definitions/ireland/cup_ireland_senior.xml support_files/definitions/ireland/league_ireland1.xml support_files/definitions/ireland/league_n_ireland1.xml support_files/definitions/ireland/league_ireland2.xml support_files/definitions/ireland/cup_ireland_prom_games.xml support_files/definitions/ireland/cup_ireland_setanta.xml support_files/definitions/ireland/cup_ireland_cl.xml support_files/definitions/ireland/cup_ireland_cl_q.xml support_files/definitions/ireland/cup_ireland_uefa.xml support_files/definitions/ireland/cup_ireland_uefa_q.xml support_files/definitions/scg/country_scg.xml support_files/definitions/scg/cup_scg.xml support_files/definitions/scg/league_scg2a.xml support_files/definitions/scg/league_scg2b.xml support_files/definitions/scg/league_scg1.xml support_files/bygfoot_constants support_files/bygfoot_user.conf support_files/lg_commentary/lg_commentary_de.xml support_files/lg_commentary/lg_commentary_en.xml support_files/lg_commentary/lg_commentary_nl.xml support_files/bygfoot_app support_files/bygfoot_help support_files/bygfoot.conf.sav support_files/bygfoot_lg_tokens install-data-local: @$(NORMAL_INSTALL) diff --git a/configure.in b/configure.in index cc68ed7a..4aa86599 100644 --- a/configure.in +++ b/configure.in @@ -20,7 +20,7 @@ AC_SUBST(GETTEXT_PACKAGE) AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.]) dnl Add the languages which your application supports here. -ALL_LINGUAS="de nl" +ALL_LINGUAS="de nl fr" AM_GLIB_GNU_GETTEXT AC_OUTPUT([ diff --git a/po/bygfoot.pot b/po/bygfoot.pot index c9480482..819097a4 100644 --- a/po/bygfoot.pot +++ b/po/bygfoot.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2005-06-28 04:05+0200\n" +"POT-Creation-Date: 2005-07-01 22:48+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -71,7 +71,7 @@ msgid "" "player's value. Do you accept?" msgstr "" -#: src/callback_func.c:383 src/callbacks.c:538 +#: src/callback_func.c:383 src/callbacks.c:537 msgid "Your offer has been removed." msgstr "" @@ -148,7 +148,7 @@ msgstr "" msgid "The current game state is unsaved and will be lost. Continue?" msgstr "" -#: src/callbacks.c:148 src/callbacks.c:402 +#: src/callbacks.c:148 src/callbacks.c:401 msgid "Transfers are disabled in this country definition." msgstr "" @@ -161,86 +161,86 @@ msgstr "" msgid "Transfer deadline is Week %d" msgstr "" -#: src/callbacks.c:162 +#: src/callbacks.c:161 msgid "The transfer deadline is over." msgstr "" -#: src/callbacks.c:171 src/callbacks.c:566 src/callbacks.c:583 +#: src/callbacks.c:170 src/callbacks.c:565 src/callbacks.c:582 msgid "You still have some transfer business to manage." msgstr "" -#: src/callbacks.c:175 +#: src/callbacks.c:174 msgid "At least one user didn't take his turn this week. Continue?" msgstr "" -#: src/callbacks.c:181 +#: src/callbacks.c:180 msgid "There are injured or banned players in one of the user teams. Continue?" msgstr "" -#: src/callbacks.c:386 +#: src/callbacks.c:385 msgid "This is your first season." msgstr "" -#: src/callbacks.c:404 src/callbacks.c:420 src/callbacks.c:436 -#: src/callbacks.c:454 src/callbacks.c:799 src/callbacks.c:815 +#: src/callbacks.c:403 src/callbacks.c:419 src/callbacks.c:435 +#: src/callbacks.c:453 src/callbacks.c:798 src/callbacks.c:814 msgid "You haven't selected a player." msgstr "" -#: src/callbacks.c:406 +#: src/callbacks.c:405 msgid "The player is already on the list." msgstr "" -#: src/callbacks.c:422 +#: src/callbacks.c:421 msgid "The player is not on the list." msgstr "" -#: src/callbacks.c:438 +#: src/callbacks.c:437 msgid "Your team can't have less than 11 players." msgstr "" -#: src/callbacks.c:459 +#: src/callbacks.c:458 msgid "Penalty/free kick shooter deselected." msgstr "" -#: src/callbacks.c:465 +#: src/callbacks.c:464 #, c-format msgid "%s will shoot penalties and free kicks when he plays." msgstr "" -#: src/callbacks.c:540 +#: src/callbacks.c:539 msgid "You haven't made an offer for the player." msgstr "" -#: src/callbacks.c:599 +#: src/callbacks.c:598 msgid "Enter a structure. The digits must sum up to 10." msgstr "" -#: src/callbacks.c:600 +#: src/callbacks.c:599 msgid "Structure" msgstr "" -#: src/callbacks.c:633 src/callbacks.c:649 +#: src/callbacks.c:632 src/callbacks.c:648 msgid "No match stored." msgstr "" -#: src/callbacks.c:727 src/game_gui.c:309 +#: src/callbacks.c:726 src/game_gui.c:309 msgid "Boost ON is disabled in this country definition." msgstr "" -#: src/callbacks.c:749 +#: src/callbacks.c:748 msgid "Finances are disabled in this country definition." msgstr "" -#: src/callbacks.c:754 +#: src/callbacks.c:753 msgid "" "Left-click: get loan; Right-click: pay back; Middle click: stadium window." msgstr "" -#: src/callbacks.c:768 +#: src/callbacks.c:767 msgid "Stadium management is disabled in this country definition." msgstr "" -#: src/callbacks.c:793 +#: src/callbacks.c:792 msgid "Contracts are disabled in this country definition." msgstr "" @@ -733,38 +733,38 @@ msgstr "" msgid "Next (W)" msgstr "" -#: src/lg_commentary.c:331 src/team.c:500 +#: src/lg_commentary.c:524 src/team.c:500 msgid "ALL OUT DEFEND" msgstr "" -#: src/lg_commentary.c:334 src/team.c:502 +#: src/lg_commentary.c:527 src/team.c:502 msgid "DEFEND" msgstr "" -#: src/lg_commentary.c:337 src/team.c:504 +#: src/lg_commentary.c:530 src/team.c:504 msgid "BALANCED" msgstr "" -#: src/lg_commentary.c:340 src/team.c:506 +#: src/lg_commentary.c:533 src/team.c:506 msgid "ATTACK" msgstr "" -#: src/lg_commentary.c:343 src/team.c:508 +#: src/lg_commentary.c:536 src/team.c:508 msgid "ALL OUT ATTACK" msgstr "" #. Boost value. -#: src/lg_commentary.c:346 src/team.c:516 +#: src/lg_commentary.c:539 src/team.c:516 msgid "ANTI" msgstr "" #. Boost value. -#: src/lg_commentary.c:349 src/team.c:519 +#: src/lg_commentary.c:542 src/team.c:519 msgid "OFF" msgstr "" #. Boost value. -#: src/lg_commentary.c:352 src/team.c:522 +#: src/lg_commentary.c:545 src/team.c:522 msgid "ON" msgstr "" diff --git a/src/Makefile.am b/src/Makefile.am index 1457fc7e..6c355c4f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,17 +16,17 @@ bygfoot_SOURCES = \ file.c file.h free.h main.h misc.h option.h support.h variables.h \ finance.c callbacks.h finance.h game_gui.h maths.h option.h player.h team.h user.h \ fixture.c cup.h fixture.h free.h league.h main.h maths.h misc.h option.h table.h team.h user.h variables.h \ - free.c free.h transfer.h user.h variables.h \ + free.c free.h lg_commentary_struct.h transfer.h user.h variables.h \ game.c cup.h finance.h fixture.h game_gui.h game.h league.h live_game.h main.h maths.h misc.h option.h player.h table.h team.h treeview.h user.h variables.h \ game_gui.c callbacks.h file.h game_gui.h gui.h league.h live_game.h maths.h misc.h option.h support.h team.h treeview.h user.h variables.h window.h \ gui.c gui.h misc.h support.h variables.h window.h \ interface.c callbacks.h interface.h support.h \ language.c callbacks.h free.h language.h lg_commentary.h misc.h option.h variables.h window.h \ - lg_commentary.c file.h free.h lg_commentary.h live_game.h main.h misc.h option.h player.h variables.h xml_lg_commentary.h \ + lg_commentary.c cup.h file.h fixture.h league.h lg_commentary.h live_game.h main.h maths.h misc.h option.h player.h team.h variables.h xml_lg_commentary.h \ league.c cup.h free.h league.h main.h maths.h misc.h option.h player.h stat.h table.h team.h user.h variables.h \ - live_game.c callbacks.h fixture.h free.h game_gui.h game.h lg_commentary.h live_game.h main.h maths.h misc_callback_func.h option.h player.h support.h team.h treeview.h user.h variables.h window.h \ + live_game.c callbacks.h fixture.h free.h game_gui.h game.h lg_commentary.h live_game.h main.h maths.h misc_callback_func.h misc.h option.h player.h support.h team.h treeview.h user.h variables.h window.h \ load_save.c callbacks.h file.h game_gui.h gui.h language.h load_save.h option.h support.h user.h variables.h xml.h xml_loadsave_cup.h xml_loadsave_league.h xml_loadsave_misc.h xml_loadsave_season_stats.h xml_loadsave_transfers.h xml_loadsave_users.h \ - main.c file.h free.h language.h live_game.h main.h misc_callbacks.h name_struct.h option.h stat_struct.h transfer_struct.h variables.h window.h \ + main.c file.h free.h language.h lg_commentary_struct.h live_game.h main.h misc_callbacks.h name_struct.h option.h stat_struct.h transfer_struct.h variables.h window.h \ maths.c maths.h misc.h variables.h \ misc.c main.h maths.h misc.h \ misc_callbacks.c callback_func.h callbacks.h game_gui.h game.h gui.h live_game.h load_save.h main.h maths.h misc_callback_func.h misc_callbacks.h option.h user.h variables.h window.h xml_country.h \ diff --git a/src/callback_func.c b/src/callback_func.c index ec914fb1..8e15723c 100644 --- a/src/callback_func.c +++ b/src/callback_func.c @@ -287,7 +287,7 @@ callback_get_loan(void) } stat1 = STATUS_GET_LOAN; - misc_print_grouped_int(max_loan, buf2, FALSE); + misc_print_grouped_int(max_loan, buf2); sprintf(buf, _("You can take out at most %s."), buf2); window_show_digits(buf, _("Loan"), max_loan, NULL, 0); @@ -313,7 +313,7 @@ callback_pay_loan(void) } stat1 = STATUS_PAY_LOAN; - misc_print_grouped_int(max_payback, buf2, FALSE); + misc_print_grouped_int(max_payback, buf2); sprintf(buf, _("You can pay back at most %s"), buf2); window_show_digits(buf, _("Payback"), max_payback, NULL, 0); @@ -344,10 +344,10 @@ callback_transfer_list_user(gint button, gint idx) game_gui_print_message(_("There are some offers for the player which you rejected or will see next week.")); else { - misc_print_grouped_int(transoff(idx, 0).fee, buf2, FALSE); + misc_print_grouped_int(transoff(idx, 0).fee, buf2); misc_print_grouped_int(ABS(transoff(idx, 0).fee - player_of_id_team(current_user.tm, - trans(idx).id)->value), buf3, FALSE); + trans(idx).id)->value), buf3); if(transoff(idx, 0).fee - player_of_id_team(current_user.tm, trans(idx).id)->value > 0) strcat(buf3, _(" more")); @@ -391,8 +391,8 @@ callback_transfer_list_cpu(gint button, gint idx) return; } - misc_print_grouped_int(transoff(idx, 0).fee, buf2, FALSE); - misc_print_grouped_int(transoff(idx, 0).wage, buf3, FALSE); + misc_print_grouped_int(transoff(idx, 0).fee, buf2); + misc_print_grouped_int(transoff(idx, 0).wage, buf3); sprintf(buf, _("You offered a transfer fee of %s and a wage of %s for %s. The owners and the player are satisfied with your offer. Do you still want to buy the player?"), buf2, buf3, player_of_id_team(trans(idx).tm, trans(idx).id)->name->str); @@ -435,13 +435,7 @@ callback_transfer_list_clicked(gint button, gint idx) return; } - - if (week >= transfer_get_deadline()-1) - { - game_gui_print_message(_("You can't make an offer so close to the transfer deadline.")); - return; - } - + stat1 = STATUS_SHOW_TRANSFER_LIST; stat2 = idx; @@ -617,7 +611,7 @@ callback_fire_player(gint idx) stat2 = idx; stat3 = (gint)rint(pl->wage * const_float("float_player_fire_wage_factor") * pl->contract); - misc_print_grouped_int(stat3, buf2, FALSE); + misc_print_grouped_int(stat3, buf2); sprintf(buf, _("You want to fire %s. Since his contract expires in %.1f years, he demands a compensation of %s. Do you accept?"), pl->name->str, pl->contract, buf2); diff --git a/src/callbacks.c b/src/callbacks.c index 10de9bca..e54ccc5b 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -151,7 +151,6 @@ on_button_transfers_clicked (GtkButton *button, stat0 = STATUS_SHOW_TRANSFER_LIST; game_gui_print_message(_("Left click to make an offer. Right click to remove offer.")); sprintf(buf, _("Transfer deadline is Week %d"), transfer_get_deadline()); - printf("buf %s \n", buf); game_gui_print_message_with_delay(buf); treeview_show_transfer_list(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right"))); gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(window.main, "notebook_player")), 1); diff --git a/src/file.c b/src/file.c index 340001ff..31db46d3 100644 --- a/src/file.c +++ b/src/file.c @@ -160,16 +160,14 @@ void file_check_home_dir_copy_conf_files(void) { gint i; - gchar *conf_files[4] = + gchar *conf_files[2] = {"bygfoot.conf", - "bygfoot_user.conf", - "bygfoot_constants", - "bygfoot_app"}; + "bygfoot_user.conf"}; const gchar *home = g_get_home_dir(); gchar *conf_file = NULL; gchar buf[SMALL]; - for(i=0;i<4;i++) + for(i=0;i<2;i++) { sprintf(buf, "%s/%s/%s", home, HOMEDIRNAME, conf_files[i]); if(!g_file_test(buf, G_FILE_TEST_EXISTS)) @@ -444,6 +442,7 @@ file_load_opt_file(const gchar *filename, OptionList *optionlist) void file_load_conf_files(void) { + gint i; gchar *conf_file = file_find_support_file("bygfoot.conf", TRUE); file_load_opt_file(conf_file, &options); @@ -452,6 +451,9 @@ file_load_conf_files(void) file_load_opt_file(opt_str("string_opt_constants_file"), &constants); file_load_opt_file(opt_str("string_opt_appearance_file"), &constants_app); file_load_opt_file("bygfoot_lg_tokens", &lg_tokens); + + for(i=0;ilen;i++) + g_array_index(lg_tokens.list, Option, i).value = i; } /** Load a user-specific conf file. diff --git a/src/free.c b/src/free.c index b1861e02..7b779d66 100644 --- a/src/free.c +++ b/src/free.c @@ -1,4 +1,5 @@ #include "free.h" +#include "lg_commentary_struct.h" #include "transfer.h" #include "user.h" #include "variables.h" @@ -16,6 +17,7 @@ free_memory(void) free_country(FALSE); free_users(FALSE); free_live_game(&live_game_temp); + free_lg_commentary(FALSE); free_support_dirs(); } @@ -450,7 +452,7 @@ free_cup_choose_team(CupChooseTeam *cup_choose_team) void free_variables(void) { - gint i; + gint i, j; free_option_list(&options, FALSE); free_option_list(&settings, FALSE); @@ -458,9 +460,6 @@ free_variables(void) free_option_list(&constants_app, FALSE); free_option_list(&lg_tokens, FALSE); - for(i=0;ilen;j++) + { + free_g_string(&g_array_index(lg_commentary[i], LGCommentary, j).text); + free_g_string(&g_array_index(lg_commentary[i], LGCommentary, j).condition); + } + + free_g_array(&lg_commentary[i]); + } + + if(reset) + for(i=0;istadium.capacity * math_rndi(const_int("int_initial_money_lower"), const_int("int_initial_money_upper")), 2), - buf, FALSE); + buf); gtk_label_set_text(label_money, buf); - misc_print_grouped_int(team->stadium.capacity, buf, FALSE); + misc_print_grouped_int(team->stadium.capacity, buf); gtk_label_set_text(label_cap, buf); gui_label_set_text_from_int(label_saf, (gint)rint(team->stadium.safety * 100), FALSE); diff --git a/src/gui.c b/src/gui.c index 527babbc..858ade87 100644 --- a/src/gui.c +++ b/src/gui.c @@ -18,7 +18,7 @@ gui_label_set_text_from_int(GtkLabel *label, gint number, gboolean append) strcpy(buf2, ""); if(number > 1000) - misc_print_grouped_int(number, buf, FALSE); + misc_print_grouped_int(number, buf); else sprintf(buf, "%d", number); diff --git a/src/lg_commentary.c b/src/lg_commentary.c index 50e7620f..3d7e656b 100644 --- a/src/lg_commentary.c +++ b/src/lg_commentary.c @@ -1,28 +1,96 @@ #include +#include "cup.h" #include "file.h" -#include "free.h" +#include "fixture.h" +#include "league.h" #include "lg_commentary.h" #include "live_game.h" #include "main.h" +#include "maths.h" #include "misc.h" #include "option.h" #include "player.h" +#include "team.h" #include "variables.h" #include "xml_lg_commentary.h" +/** The replacement strings for the live game commentary tokens. */ +gchar **token_rep; + +/** Allocate memory for the token array and fill some tokens + at the beginning of the live game that don't change later. */ +void +lg_commentary_initialize(const Fixture *fix) +{ + gint i; + gchar buf[SMALL]; + + token_rep = (gchar**)g_malloc(sizeof(gchar*) * lg_tokens.list->len); + + for(i=0;ilen;i++) + token_rep[i] = NULL; + + token_rep[option_int("string_lg_commentary_token_team_home", &lg_tokens)] = + g_strdup(fix->teams[0]->name->str); + token_rep[option_int("string_lg_commentary_token_team_away", &lg_tokens)] = + g_strdup(fix->teams[1]->name->str); + + if(fix->teams[0]->clid < ID_CUP_START) + token_rep[option_int("string_lg_commentary_token_team_layer0", &lg_tokens)] = + misc_int_to_char(league_from_clid(fix->teams[0]->clid)->layer); + if(fix->teams[1]->clid < ID_CUP_START) + token_rep[option_int("string_lg_commentary_token_team_layer1", &lg_tokens)] = + misc_int_to_char(league_from_clid(fix->teams[1]->clid)->layer); + + token_rep[option_int("string_lg_commentary_token_league_cup_name", &lg_tokens)] = + g_strdup(league_cup_get_name_string(fix->clid)); + + if(fix->clid >= ID_CUP_START) + { + cup_get_round_name(cup_from_clid(fix->clid), fix->round, buf); + token_rep[option_int("string_lg_commentary_token_cup_round_name", &lg_tokens)] = + g_strdup(buf); + } + + misc_print_grouped_int(fix->attendance, buf); + token_rep[option_int("string_lg_commentary_token_attendance", &lg_tokens)] = + g_strdup(buf); + + token_rep[option_int("string_lg_commentary_token_yellow_limit", &lg_tokens)] = + misc_int_to_char(league_cup_get_yellow_red(fix->clid)); +} + +/** Free the memory occupied by the tokens array and the permanent tokens. */ +void +lg_commentary_post_match(void) +{ + g_free(token_rep[option_int("string_lg_commentary_token_team_home", &lg_tokens)]); + g_free(token_rep[option_int("string_lg_commentary_token_team_away", &lg_tokens)]); + g_free(token_rep[option_int("string_lg_commentary_token_attendance", &lg_tokens)]); + g_free(token_rep[option_int("string_lg_commentary_token_league_cup_name", &lg_tokens)]); + g_free(token_rep[option_int("string_lg_commentary_token_cup_round_name", &lg_tokens)]); + g_free(token_rep[option_int("string_lg_commentary_token_yellow_limit", &lg_tokens)]); + g_free(token_rep[option_int("string_lg_commentary_token_team_layer0", &lg_tokens)]); + g_free(token_rep[option_int("string_lg_commentary_token_team_layer1", &lg_tokens)]); + + g_free(token_rep); +} + /** Generate commentary for the live game event in the unit. @param unit The unit we comment. @param fix The fixture being calculated. */ void -lg_commentary_generate(LiveGameUnit *unit, const Fixture *fix) +lg_commentary_generate(const LiveGame *live_game, LiveGameUnit *unit) { gchar buf[SMALL]; - GPtrArray **commentaries = NULL; - GPtrArray *strings = g_ptr_array_new(); + GArray **commentaries = NULL; gint i; - lg_commentary_set_strings(strings, unit, fix); + lg_commentary_set_basic_tokens(unit, live_game->fix); + lg_commentary_set_team_tokens(unit, live_game->fix); + lg_commentary_set_player_tokens(unit, live_game->fix); + lg_commentary_set_stats_tokens(&live_game->stats); if(unit->event.type == LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_DEFEND || unit->event.type == LIVE_GAME_EVENT_STYLE_CHANGE_DEFEND || @@ -37,12 +105,12 @@ lg_commentary_generate(LiveGameUnit *unit, const Fixture *fix) else commentaries = &lg_commentary[unit->event.type]; - *commentaries = misc_randomise_g_pointer_array(*commentaries); + gint order[(*commentaries)->len]; + lg_commentary_get_order(*commentaries, order); for(i=0;i<(*commentaries)->len;i++) { - if(lg_commentary_replace_tokens( - ((GString*)g_ptr_array_index((*commentaries), i))->str, strings, buf)) + if(lg_commentary_check_commentary(&g_array_index(*commentaries, LGCommentary, order[i]), buf)) break; } @@ -56,260 +124,385 @@ lg_commentary_generate(LiveGameUnit *unit, const Fixture *fix) unit->event.commentary = g_string_new(buf); for(i=0;ilen;i++) - g_free(g_ptr_array_index(strings, i)); + if(i != option_int("string_lg_commentary_token_team_home", &lg_tokens) && + i != option_int("string_lg_commentary_token_team_away", &lg_tokens) && + i != option_int("string_lg_commentary_token_attendance", &lg_tokens) && + i != option_int("string_lg_commentary_token_cup_round_name", &lg_tokens) && + i != option_int("string_lg_commentary_token_league_cup_name", &lg_tokens) && + i != option_int("string_lg_commentary_token_yellow_limit", &lg_tokens) && + i != option_int("string_lg_commentary_token_team_layer0", &lg_tokens) && + i != option_int("string_lg_commentary_token_team_layer1", &lg_tokens)) + { + g_free(token_rep[i]); + token_rep[i] = NULL; + } +} - g_ptr_array_free(strings, TRUE); +/** Check whether the commentary conditions are fulfilled and whether + we can replace all tokens in the commentary. */ +gboolean +lg_commentary_check_commentary(const LGCommentary *commentary, gchar *dest) +{ + if(commentary->condition != NULL && + !lg_commentary_parse_condition(commentary->condition->str)) + return FALSE; + + strcpy(dest, commentary->text->str); + + if(lg_commentary_replace_tokens(dest)) + { + lg_commentary_replace_expressions(dest); + + if(lg_commentary_replace_tokens(dest)) + return TRUE; + } + + return FALSE; +} + +/** Replace simple arithmetic expressions like "1 + 2" + and comparisons like "3 < 4" with the appropriate result. */ +void +lg_commentary_replace_expressions(gchar *commentary_text) +{ + gint i, j, last_idx = 0; + gint value = -1; + gchar buf[SMALL], buf2[SMALL]; + + strcpy(buf, commentary_text); + strcpy(commentary_text, ""); + + for(i=0;i") || + query_misc_string_contains(buf2, "=")) + misc_parse(buf2, &value); + else + misc_parse_expression(buf2, &value); + + sprintf(buf2, "%d", value); + strcat(commentary_text, buf2); + value = -1; + + last_idx = j + 1; + break; + } + } + } + + if(last_idx < strlen(buf)) + { + strncpy(buf2, buf + last_idx, strlen(buf) - last_idx); + buf2[strlen(buf) - last_idx] = '\0'; + strcat(commentary_text, buf2); + } } /** Try to replace all special tokens in the string and write the result to dest. - @param string The commentary string with tokens. - @param strings The replacements of the tokens. + @param commentary The commentary with tokens. @param dest The destination string. - @return TRUE if we could replace all tokens, FALSE otherwise. */ + @return TRUE if we could replace all tokens and the commentary condition + was fulfilled, FALSE otherwise. */ gboolean -lg_commentary_replace_tokens(const gchar *string, const GPtrArray *strings, gchar *dest) +lg_commentary_replace_tokens(gchar *commentary_text) { gint i; - gboolean condition; + + for(i=0;ilen;i++) + { + if(query_misc_string_contains(commentary_text, + g_array_index(lg_tokens.list, Option, i).string_value->str)) + { + if(token_rep[i] == NULL) + return FALSE; + else + misc_string_replace_token(commentary_text, + g_array_index(lg_tokens.list, Option, i).string_value->str, + token_rep[i]); + } + } + + return TRUE; +} + +/** Find out whether the conditions of the commentary are fulfilled. */ +gboolean +lg_commentary_parse_condition(const gchar *condition) +{ + gint i; + gboolean return_value = FALSE; gchar buf[SMALL]; - const gchar *buf2 = NULL; - strcpy(buf, string); + strcpy(buf, condition); for(i=0;ilen;i++) { if(query_misc_string_contains(buf, g_array_index(lg_tokens.list, Option, i).string_value->str)) { - if(g_ptr_array_index(strings, i) == NULL) + if(token_rep[i] == NULL) return FALSE; else misc_string_replace_token(buf, g_array_index(lg_tokens.list, Option, i).string_value->str, - (gchar*)g_ptr_array_index(strings, i)); + token_rep[i]); } } - misc_replace_sums(buf); + misc_parse(buf, &return_value); - if(buf[0] == '#') - { - buf2 = misc_parse(buf + 1, &condition); - strcpy(dest, buf2); - - return condition; - } - else - strcpy(dest, buf); - - - - return TRUE; + return return_value; } -/** Get the strings corresponding to the commentary tokens. */ + +/** Write a random order of indices into the integer array + (only depending on the priority values of the commentaries). + I don't like this implementation of ordering the commentaries + according to their priority :-P can't think of a better one, though. */ void -lg_commentary_set_strings(GPtrArray *strings, const LiveGameUnit *unit, const Fixture *fix) +lg_commentary_get_order(const GArray *commentaries, gint *order) { - gint i, tmp_int = 1; - gchar buf[SMALL]; + gint i, j, order_idx = 0; + gint priority_sum = 0, bounds[commentaries->len + 1]; - for(i=0;ilen;i++) + bounds[0] = 0; + + for(i=0;ilen;i++) { - if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_team_home")) == 0) - g_ptr_array_add(strings, g_strdup(fix->teams[0]->name->str)); - else if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_team_away")) == 0) - g_ptr_array_add(strings, g_strdup(fix->teams[1]->name->str)); - else if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_team_in_poss")) == 0) - g_ptr_array_add(strings, g_strdup(fix->teams[unit->possession]->name->str)); - else if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_team_not_in_poss")) == 0) - g_ptr_array_add(strings, g_strdup(fix->teams[!unit->possession]->name->str)); - else if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_team_losing")) == 0) - { - if(unit->result[0] == unit->result[1]) - g_ptr_array_add(strings, NULL); - else - g_ptr_array_add(strings, g_strdup(fix->teams[(unit->result[0] > unit->result[1])]->name->str)); - } - else if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_team_winning")) == 0) - { - if(unit->result[0] == unit->result[1]) - g_ptr_array_add(strings, NULL); - else - g_ptr_array_add(strings, g_strdup(fix->teams[(unit->result[0] < unit->result[1])]->name->str)); - } - else if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_team")) == 0) - { - if(unit->event.team == -1) - g_ptr_array_add(strings, NULL); - else - g_ptr_array_add(strings, g_strdup(fix->teams[unit->event.team]->name->str)); - } - else if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_player1")) == 0) - g_ptr_array_add(strings, lg_commentary_get_player_name(unit, fix, FALSE)); - else if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_player2")) == 0) - g_ptr_array_add(strings, lg_commentary_get_player_name(unit, fix, TRUE)); - else if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_attendance")) == 0) - { - misc_print_grouped_int(fix->attendance, buf, FALSE); - g_ptr_array_add(strings, g_strdup(buf)); - } - else if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_time")) == 0) - { - sprintf(buf, "%d", unit->time); - g_ptr_array_add(strings, g_strdup(buf)); - } - else if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_minute")) == 0) - { - sprintf(buf, "%d", live_game_unit_get_minute(unit)); - g_ptr_array_add(strings, g_strdup(buf)); - } - else if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_minute_remaining")) == 0) - { - if(unit->time == LIVE_GAME_UNIT_TIME_EXTRA_TIME) - tmp_int = 120 - live_game_unit_get_minute(unit); - else if(unit->time == LIVE_GAME_UNIT_TIME_SECOND_HALF) - tmp_int = 90 - live_game_unit_get_minute(unit); - else if(unit->time == LIVE_GAME_UNIT_TIME_FIRST_HALF) - tmp_int = 45 - live_game_unit_get_minute(unit); - - if(unit->time == LIVE_GAME_UNIT_TIME_PENALTIES || - tmp_int <= 0) - g_ptr_array_add(strings, NULL); - else + priority_sum += g_array_index(commentaries, LGCommentary, i).priority; + bounds[i + 1] = priority_sum; + order[i] = -1; + } + + gint permutation[priority_sum]; + + math_generate_permutation(permutation, 1, priority_sum); + + for(i=0;ilen) + break; + + for(j=0;jlen;j++) + if(bounds[j] < permutation[i] && permutation[i] <= bounds[j + 1]) { - sprintf(buf, "%d", tmp_int); - g_ptr_array_add(strings, g_strdup(buf)); + if(!query_integer_is_in_array(j, order, 0, commentaries->len)) + { + order[order_idx] = j; + order_idx++; + } + + break; } - } - else if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_result")) == 0) - { - sprintf(buf, "%d : %d", unit->result[0], unit->result[1]); - g_ptr_array_add(strings, g_strdup(buf)); - } - else if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_goals_home")) == 0) - { - sprintf(buf, "%d", unit->result[0]); - g_ptr_array_add(strings, g_strdup(buf)); - } - else if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_goals_away")) == 0) - { - sprintf(buf, "%d", unit->result[1]); - g_ptr_array_add(strings, g_strdup(buf)); - } - else if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_goal_diff")) == 0) - { - sprintf(buf, "%d", ABS(unit->result[0] - unit->result[1])); - g_ptr_array_add(strings, strdup(buf)); - } - else if(strcmp(g_array_index(lg_tokens.list, Option, i).string_value->str, - lg_token("string_lg_commentary_token_extra")) == 0) - g_ptr_array_add(strings, lg_commentary_get_extra_data(unit, fix)); - else - { - g_warning("lg_commentary_set_strings: no rule found for token %s.", - g_array_index(lg_tokens.list, Option, i).string_value->str); - main_exit_program(EXIT_GENERAL, NULL); - } } } -/** Return the name of a player involved in the unit (or NULL). - @param player Which player we look for. */ -gchar* -lg_commentary_get_player_name(const LiveGameUnit *unit, const Fixture *fix, gboolean player2) +/** Fill the stats tokens. */ +void +lg_commentary_set_stats_tokens(const LiveGameStats *stats) { - gchar *return_value = NULL; + token_rep[option_int("string_lg_commentary_token_stat_shots0", &lg_tokens)] = + misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_SHOTS]); + token_rep[option_int("string_lg_commentary_token_stat_shot_per0", &lg_tokens)] = + misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_SHOT_PERCENTAGE]); + token_rep[option_int("string_lg_commentary_token_stat_poss0", &lg_tokens)] = + misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_POSSESSION]); + token_rep[option_int("string_lg_commentary_token_stat_pen0", &lg_tokens)] = + misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_PENALTIES]); + token_rep[option_int("string_lg_commentary_token_stat_fouls0", &lg_tokens)] = + misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_FOULS]); + token_rep[option_int("string_lg_commentary_token_stat_yellows0", &lg_tokens)] = + misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_CARDS]); + token_rep[option_int("string_lg_commentary_token_stat_reds0", &lg_tokens)] = + misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_REDS]); + token_rep[option_int("string_lg_commentary_token_stat_injs0", &lg_tokens)] = + misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_INJURIES]); - if((player2 && unit->event.player2 == -1) || - (!player2 && unit->event.player == -1)) - return NULL; + token_rep[option_int("string_lg_commentary_token_stat_shots1", &lg_tokens)] = + misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_SHOTS]); + token_rep[option_int("string_lg_commentary_token_stat_shot_per1", &lg_tokens)] = + misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_SHOT_PERCENTAGE]); + token_rep[option_int("string_lg_commentary_token_stat_poss1", &lg_tokens)] = + misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_POSSESSION]); + token_rep[option_int("string_lg_commentary_token_stat_pen1", &lg_tokens)] = + misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_PENALTIES]); + token_rep[option_int("string_lg_commentary_token_stat_fouls1", &lg_tokens)] = + misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_FOULS]); + token_rep[option_int("string_lg_commentary_token_stat_yellows1", &lg_tokens)] = + misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_CARDS]); + token_rep[option_int("string_lg_commentary_token_stat_reds1", &lg_tokens)] = + misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_REDS]); + token_rep[option_int("string_lg_commentary_token_stat_injs1", &lg_tokens)] = + misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_INJURIES]); +} - if(unit->event.type == LIVE_GAME_EVENT_GENERAL) - return_value = (player2) ? - player_get_last_name(player_of_id_team(fix->teams[unit->possession], - unit->event.player2)->name->str) : - player_get_last_name(player_of_id_team(fix->teams[unit->possession], - unit->event.player)->name->str); - else if(unit->event.type == LIVE_GAME_EVENT_LOST_POSSESSION) +/** Fill the tokens that contain general information. */ +void +lg_commentary_set_basic_tokens(const LiveGameUnit *unit, const Fixture *fix) +{ + gchar buf[SMALL]; + gint tmp_int = 1, current_min = live_game_unit_get_minute(unit); + gint avskill0 = (gint)rint(team_get_average_skill(fix->teams[0], TRUE)), + avskill1 = (gint)rint(team_get_average_skill(fix->teams[1], TRUE)); + + sprintf(buf, "%d : %d", unit->result[0], unit->result[1]); + token_rep[option_int("string_lg_commentary_token_result", &lg_tokens)] = + g_strdup(buf); + + token_rep[option_int("string_lg_commentary_token_time", &lg_tokens)] = + misc_int_to_char(unit->time); + token_rep[option_int("string_lg_commentary_token_minute", &lg_tokens)] = + misc_int_to_char(live_game_unit_get_minute(unit)); + + if(unit->time == LIVE_GAME_UNIT_TIME_EXTRA_TIME) + tmp_int = 120 - current_min; + else if(unit->time == LIVE_GAME_UNIT_TIME_SECOND_HALF) + tmp_int = 90 - current_min; + else if(unit->time == LIVE_GAME_UNIT_TIME_FIRST_HALF) + tmp_int = 45 - current_min; + + if(unit->time != LIVE_GAME_UNIT_TIME_PENALTIES && tmp_int > 0) + token_rep[option_int("string_lg_commentary_token_minute_remaining", &lg_tokens)] = + misc_int_to_char(tmp_int); + + if(query_fixture_is_draw(fix)) + tmp_int = 120 - current_min; + else + tmp_int = 90 - current_min; + + if(tmp_int > 0) + token_rep[option_int("string_lg_commentary_token_minute_total", &lg_tokens)] = + misc_int_to_char(tmp_int); + + token_rep[option_int("string_lg_commentary_token_goals0", &lg_tokens)] = + misc_int_to_char(unit->result[0]); + token_rep[option_int("string_lg_commentary_token_goals1", &lg_tokens)] = + misc_int_to_char(unit->result[1]); + token_rep[option_int("string_lg_commentary_token_goal_diff", &lg_tokens)] = + misc_int_to_char(ABS(unit->result[0] - unit->result[1])); + token_rep[option_int("string_lg_commentary_token_extra", &lg_tokens)] = + lg_commentary_get_extra_data(unit, fix); + + token_rep[option_int("string_lg_commentary_token_possession", &lg_tokens)] = + misc_int_to_char(unit->possession); + token_rep[option_int("string_lg_commentary_token_no_possession", &lg_tokens)] = + misc_int_to_char(!unit->possession); + + token_rep[option_int("string_lg_commentary_token_team_avskill0", &lg_tokens)] = + misc_int_to_char(avskill0); + token_rep[option_int("string_lg_commentary_token_team_avskill1", &lg_tokens)] = + misc_int_to_char(avskill1); + token_rep[option_int("string_lg_commentary_token_team_avskilldiff", &lg_tokens)] = + misc_int_to_char(ABS(avskill0 - avskill1)); +} + +/** Set the tokens containing team data. */ +void +lg_commentary_set_team_tokens(const LiveGameUnit *unit, const Fixture *fix) +{ + if(unit->result[0] != unit->result[1]) { - return_value = (player2) ? - player_get_last_name(player_of_id_team(fix->teams[!unit->possession], - unit->event.player2)->name->str): - player_get_last_name(player_of_id_team(fix->teams[unit->possession], - unit->event.player)->name->str); + token_rep[option_int("string_lg_commentary_token_team_losing", &lg_tokens)] = + g_strdup(fix->teams[(unit->result[0] > unit->result[1])]->name->str); + token_rep[option_int("string_lg_commentary_token_team_winning", &lg_tokens)] = + g_strdup(fix->teams[(unit->result[0] < unit->result[1])]->name->str); } - else if(unit->event.type == LIVE_GAME_EVENT_SCORING_CHANCE || - unit->event.type == LIVE_GAME_EVENT_HEADER || - unit->event.type == LIVE_GAME_EVENT_PENALTY || - unit->event.type == LIVE_GAME_EVENT_FREE_KICK) - { - return_value = (player2) ? - player_get_last_name(player_of_id_team(fix->teams[unit->possession], - unit->event.player2)->name->str) : - player_get_last_name(player_of_id_team(fix->teams[unit->possession], - unit->event.player)->name->str); + + if(unit->event.team != -1) + token_rep[option_int("string_lg_commentary_token_team", &lg_tokens)] = + g_strdup(fix->teams[unit->event.team]->name->str); +} + +/** Set the player tokens. */ +void +lg_commentary_set_player_tokens(const LiveGameUnit *unit, const Fixture *fix) +{ + Player *pl1 = NULL, + *pl2 = NULL; + + if(unit->event.type == LIVE_GAME_EVENT_GENERAL || + unit->event.type == LIVE_GAME_EVENT_SCORING_CHANCE || + unit->event.type == LIVE_GAME_EVENT_HEADER || + unit->event.type == LIVE_GAME_EVENT_PENALTY || + unit->event.type == LIVE_GAME_EVENT_FREE_KICK) + { + pl1 = player_of_id_team(fix->teams[unit->possession], + unit->event.player); + + if(unit->event.player2 != -1) + pl2 = player_of_id_team(fix->teams[unit->possession], + unit->event.player2); } - else if(unit->event.type == LIVE_GAME_EVENT_GOAL || + else if(unit->event.type == LIVE_GAME_EVENT_SEND_OFF || + unit->event.type == LIVE_GAME_EVENT_INJURY || + unit->event.type == LIVE_GAME_EVENT_TEMP_INJURY || + unit->event.type == LIVE_GAME_EVENT_SUBSTITUTION) + { + pl1 = player_of_id_team(fix->teams[unit->event.team], + unit->event.player); + if(unit->event.player2 != -1) + pl2 = player_of_id_team(fix->teams[unit->event.team], + unit->event.player2); + } + else if(unit->event.type == LIVE_GAME_EVENT_LOST_POSSESSION || + unit->event.type == LIVE_GAME_EVENT_GOAL || unit->event.type == LIVE_GAME_EVENT_MISS || unit->event.type == LIVE_GAME_EVENT_SAVE || unit->event.type == LIVE_GAME_EVENT_POST || unit->event.type == LIVE_GAME_EVENT_CROSS_BAR) { - return_value = (player2) ? - player_get_last_name(player_of_id_team(fix->teams[!unit->possession], - unit->event.player2)->name->str) : - player_get_last_name(player_of_id_team(fix->teams[unit->possession], - unit->event.player)->name->str); + pl1 = player_of_id_team(fix->teams[unit->possession], + unit->event.player); + pl2 = player_of_id_team(fix->teams[!unit->possession], + unit->event.player2); } else if(unit->event.type == LIVE_GAME_EVENT_OWN_GOAL) - return_value = - player_get_last_name(player_of_id_team(fix->teams[!unit->possession], - unit->event.player)->name->str); + pl1 = player_of_id_team(fix->teams[!unit->possession], + unit->event.player); else if(unit->event.type == LIVE_GAME_EVENT_FOUL || unit->event.type == LIVE_GAME_EVENT_FOUL_RED || unit->event.type == LIVE_GAME_EVENT_FOUL_RED_INJURY || unit->event.type == LIVE_GAME_EVENT_FOUL_YELLOW) { - return_value = (player2) ? - player_get_last_name(player_of_id_team(fix->teams[unit->event.team], - unit->event.player2)->name->str) : - player_get_last_name(player_of_id_team(fix->teams[!unit->event.team], - unit->event.player)->name->str); - } - else if(unit->event.type == LIVE_GAME_EVENT_SEND_OFF || - unit->event.type == LIVE_GAME_EVENT_INJURY || - unit->event.type == LIVE_GAME_EVENT_TEMP_INJURY || - unit->event.type == LIVE_GAME_EVENT_SUBSTITUTION) - return_value = (player2) ? - player_get_last_name(player_of_id_team(fix->teams[unit->event.team], - unit->event.player2)->name->str) : - player_get_last_name(player_of_id_team(fix->teams[unit->event.team], - unit->event.player)->name->str); - else - { - g_warning("lg_commentary_get_player_name: unknown event type %d\n", - unit->event.type); - main_exit_program(EXIT_INT_NOT_FOUND, NULL); + pl1 = player_of_id_team(fix->teams[!unit->event.team], + unit->event.player); + pl2 = player_of_id_team(fix->teams[unit->event.team], + unit->event.player2); } - return return_value; + if(pl1 != NULL) + { + token_rep[option_int("string_lg_commentary_token_player0", &lg_tokens)] = + player_get_last_name(pl1->name->str); + token_rep[option_int("string_lg_commentary_token_player_goals0", &lg_tokens)] = + misc_int_to_char(player_games_goals_get(pl1, fix->clid, PLAYER_VALUE_GOALS)); + token_rep[option_int("string_lg_commentary_token_player_goals_all0", &lg_tokens)] = + misc_int_to_char(player_all_games_goals(pl1, PLAYER_VALUE_GOALS)); + token_rep[option_int("string_lg_commentary_token_player_yellows", &lg_tokens)] = + misc_int_to_char(player_card_get(pl1, fix->clid, PLAYER_VALUE_CARD_YELLOW)); + } + + if(pl2 != NULL) + { + token_rep[option_int("string_lg_commentary_token_player1", &lg_tokens)] = + player_get_last_name(pl2->name->str); + token_rep[option_int("string_lg_commentary_token_player_goals1", &lg_tokens)] = + misc_int_to_char(player_games_goals_get(pl2, fix->clid, PLAYER_VALUE_GOALS)); + token_rep[option_int("string_lg_commentary_token_player_goals_all1", &lg_tokens)] = + misc_int_to_char(player_all_games_goals(pl2, PLAYER_VALUE_GOALS)); + } } /** Return some extra data depending on the unit type. */ diff --git a/src/lg_commentary.h b/src/lg_commentary.h index 4f574d3e..035200d8 100644 --- a/src/lg_commentary.h +++ b/src/lg_commentary.h @@ -3,43 +3,44 @@ #include "bygfoot.h" #include "fixture_struct.h" +#include "lg_commentary_struct.h" #include "live_game_struct.h" -/** Tokens that get replaced in the commentary text. */ -enum LGTokens -{ - LG_TOKEN_TEAM_HOME = 0, - LG_TOKEN_TEAM_AWAY, - LG_TOKEN_TEAM_IN_POSS, - LG_TOKEN_TEAM_NOT_IN_POSS, - LG_TOKEN_TEAM_LOSING, - LG_TOKEN_TEAM_WINNING, - LG_TOKEN_TEAM, - LG_TOKEN_ATTENDANCE, - LG_TOKEN_PLAYER1, - LG_TOKEN_PLAYER2, - LG_TOKEN_RESULT, - LG_TOKEN_MINUTE, - LG_TOKEN_GOALS_HOME, - LG_TOKEN_GOALS_AWAY, - LG_TOKEN_GOAL_DIFF, - LG_TOKEN_EXTRA, - LG_TOKEN_END -}; +void +lg_commentary_post_match(void); -#define lg_token(name) option_string(name, &lg_tokens) - -gchar* -lg_commentary_get_player_name(const LiveGameUnit *unit, const Fixture *fix, gint player); +void +lg_commentary_initialize(const Fixture *fix); gboolean -lg_commentary_replace_tokens(const gchar *string, const GPtrArray *strings, gchar *dest); +lg_commentary_check_commentary(const LGCommentary *commentary, gchar *dest); + +gboolean +lg_commentary_replace_tokens(gchar *commentary_text); void -lg_commentary_set_strings(GPtrArray *strings, const LiveGameUnit *unit, const Fixture *fix); +lg_commentary_replace_expressions(gchar *commentary_text); + +gboolean +lg_commentary_parse_condition(const gchar *condition); void -lg_commentary_generate(LiveGameUnit *unit, const Fixture *fix); +lg_commentary_get_order(const GArray *commentaries, gint *order); + +void +lg_commentary_set_basic_tokens(const LiveGameUnit *unit, const Fixture *fix);; + +void +lg_commentary_set_player_tokens(const LiveGameUnit *unit, const Fixture *fix); + +void +lg_commentary_set_team_tokens(const LiveGameUnit *unit, const Fixture *fix); + +void +lg_commentary_set_stats_tokens(const LiveGameStats *stats); + +void +lg_commentary_generate(const LiveGame *live_game, LiveGameUnit *unit); gchar* lg_commentary_get_extra_data(const LiveGameUnit *unit, const Fixture *fix); diff --git a/src/lg_commentary_struct.h b/src/lg_commentary_struct.h new file mode 100644 index 00000000..3d273ede --- /dev/null +++ b/src/lg_commentary_struct.h @@ -0,0 +1,21 @@ +#ifndef LG_COMMENTARY_STRUCT_H +#define LG_COMMENTARY_STRUCT_H + +/** Structure describing a commentary + for the live game. */ +typedef struct +{ + /** The commentary text (possibly containing tokens). */ + GString *text; + /** A condition (if not fulfilled, the commentary doesn't get + shown). */ + GString *condition; + /** Priority of the commentary (compared to + the other ones for the same event). + The higher the priority the higher the + probability that the commentary gets picked. */ + gint priority; +} LGCommentary; + +#endif + diff --git a/src/live_game.c b/src/live_game.c index 803dccc0..2cbf4f2d 100644 --- a/src/live_game.c +++ b/src/live_game.c @@ -7,6 +7,7 @@ #include "live_game.h" #include "main.h" #include "maths.h" +#include "misc.h" #include "misc_callback_func.h" #include "option.h" #include "player.h" @@ -39,31 +40,7 @@ void live_game_calculate_fixture(Fixture *fix) { if(stat0 != STATUS_LIVE_GAME_PAUSE) - { - match = (fixture_user_team_involved(fix) != -1) ? - &usr(fixture_user_team_involved(fix)).live_game : &live_game_temp; - show = (fixture_user_team_involved(fix) != -1 && - option_int("int_opt_user_show_live_game", - &usr(fixture_user_team_involved(fix)).options)); - - stat2 = fixture_user_team_involved(fix); - statp = match; - - live_game_reset(match, fix, TRUE); - - if(show) - { - cur_user = stat2; - on_button_back_to_main_clicked(NULL, NULL); - - if(window.live == NULL) - window.live = window_create(WINDOW_LIVE); - else - window_live_set_spinbuttons(); - } - - game_initialize(fix); - } + live_game_initialize(fix); else stat0 = STATUS_SHOW_LIVE_GAME; @@ -83,7 +60,44 @@ live_game_calculate_fixture(Fixture *fix) stat0 != STATUS_LIVE_GAME_PAUSE); if(last_unit.event.type == LIVE_GAME_EVENT_END_MATCH) + { + if(fixture_user_team_involved(match->fix) != -1) + lg_commentary_post_match(); game_post_match(fix); + } +} + +/** Initialize a few things at the beginning of a live game. */ +void +live_game_initialize(Fixture *fix) +{ + match = (fixture_user_team_involved(fix) != -1) ? + &usr(fixture_user_team_involved(fix)).live_game : &live_game_temp; + show = (fixture_user_team_involved(fix) != -1 && + option_int("int_opt_user_show_live_game", + &usr(fixture_user_team_involved(fix)).options)); + + stat2 = fixture_user_team_involved(fix); + statp = match; + + live_game_reset(match, fix, TRUE); + + if(show) + { + cur_user = stat2; + on_button_back_to_main_clicked(NULL, NULL); + + if(window.live == NULL) + window.live = window_create(WINDOW_LIVE); + else + window_live_set_spinbuttons(); + + } + + game_initialize(fix); + + if(fixture_user_team_involved(match->fix) != -1) + lg_commentary_initialize(fix); } /** Create a game unit for the live game. @@ -216,8 +230,8 @@ live_game_create_start_unit(void) new.event.player = new.event.player2 = -1; - new.event.commentary = NULL; new.minute = 0; + new.event.commentary = NULL; new.time = LIVE_GAME_UNIT_TIME_FIRST_HALF; new.possession = math_rndi(0, 1); new.area = LIVE_GAME_UNIT_AREA_MIDFIELD; @@ -272,9 +286,7 @@ live_game_evaluate_unit(LiveGameUnit *unit) type); } -/** Calculate a foul event. - @param general Whether to create a general event after - showing this one. @see live_game_event_general() */ +/** Calculate a foul event. */ void live_game_event_foul(void) { @@ -581,9 +593,9 @@ live_game_event_penalty(void) if(last_unit.time != LIVE_GAME_UNIT_TIME_PENALTIES) { new = last_unit; + new.event.commentary = NULL; new.minute = -1; new.event.type = LIVE_GAME_EVENT_PENALTY; - new.event.commentary = NULL; g_array_append_val(unis, new); } @@ -646,8 +658,8 @@ live_game_event_general(gboolean create_new) { new.minute = live_game_get_minute(); new.time = last_unit.time; + new.event.commentary = NULL; new.event.type = LIVE_GAME_EVENT_GENERAL; - new.event.commentary = NULL; new.result[0] = last_unit.result[0]; new.result[1] = last_unit.result[1]; new.event.team = -1; @@ -874,13 +886,12 @@ live_game_event_substitution(gint team_number, gint sub_in, gint sub_out) new.minute = -1; new.time = live_game_get_time(&last_unit); - new.event.commentary = NULL; new.event.type = LIVE_GAME_EVENT_SUBSTITUTION; new.event.team = team_number; new.event.player = sub_in; new.event.player2 = sub_out; - + new.event.commentary = NULL; if(player_of_id_team(tm[team_number], sub_in)->cskill > 0) { @@ -905,12 +916,12 @@ live_game_event_team_change(gint team_number, gint event_type) new.minute = -1; new.time = live_game_get_time(&last_unit); - new.event.commentary = NULL; new.event.team = team_number; new.event.player = new.event.player2 = -1; new.event.type = event_type; + new.event.commentary = NULL; g_array_append_val(unis, new); @@ -933,7 +944,6 @@ live_game_event_duel(void) new.minute = -1; new.event.team = new.possession; - new.event.commentary = NULL; attacker = player_of_id_team(tm[new.possession], @@ -1307,7 +1317,7 @@ live_game_finish_unit(void) match); } - lg_commentary_generate(unit, match->fix); + lg_commentary_generate(match, unit); unit->event.verbosity = live_game_event_get_verbosity(unit->event.type); } @@ -1514,4 +1524,3 @@ live_game_event_get_verbosity(gint event_type) return return_value; } - diff --git a/src/live_game.h b/src/live_game.h index 48c39cc6..a6cf4ae9 100644 --- a/src/live_game.h +++ b/src/live_game.h @@ -7,6 +7,12 @@ void live_game_calculate_fixture(Fixture *fix); +void +live_game_initialize(Fixture *fix); + +void +live_game_post_match(void); + gboolean query_live_game_event_is_break(gint minute, gint time); diff --git a/src/main.c b/src/main.c index f76ba820..27df30da 100644 --- a/src/main.c +++ b/src/main.c @@ -8,6 +8,7 @@ #include "file.h" #include "free.h" #include "language.h" +#include "lg_commentary_struct.h" #include "live_game.h" #include "main.h" #include "misc_callbacks.h" @@ -65,7 +66,7 @@ main_init_variables(void) timeout_id = -1; for(i=0;i= 1) { @@ -341,7 +339,7 @@ misc_parse_value(const gchar *s, gint *value) /* parse numeric expression (supports + and -) */ const gchar* -misc_parse_expression(const gchar *s, gboolean *result) +misc_parse_expression(const gchar *s, gint *result) { gint value = 0; s = misc_parse_value(s, &value); @@ -367,7 +365,7 @@ misc_parse_expression(const gchar *s, gboolean *result) /* parse comparison (supports '<', '>' and '=') */ const gchar* -misc_parse_comparison(const gchar *s, gboolean *result) +misc_parse_comparison(const gchar *s, gint *result) { gint value = 0; s = misc_parse_expression(s, result); @@ -413,7 +411,7 @@ misc_parse_comparison(const gchar *s, gboolean *result) } const gchar* -misc_parse_and(const gchar *s, gboolean *result) +misc_parse_and(const gchar *s, gint *result) { gint value = 0; s = misc_parse_comparison(s, result); @@ -428,7 +426,7 @@ misc_parse_and(const gchar *s, gboolean *result) } const gchar* -misc_parse(const gchar *s, gboolean *result) +misc_parse(const gchar *s, gint *result) { gint value = 0; s = misc_parse_and(s, result); @@ -440,4 +438,3 @@ misc_parse(const gchar *s, gboolean *result) } return s; } - diff --git a/src/misc.h b/src/misc.h index aa2be39b..6f57a06f 100644 --- a/src/misc.h +++ b/src/misc.h @@ -3,6 +3,8 @@ #include "bygfoot.h" +#define misc_int_to_char(number) g_strdup_printf("%d", number) + void misc_print_error(GError **error, gboolean abort_program); @@ -19,7 +21,7 @@ GPtrArray* misc_randomise_g_pointer_array(GPtrArray *array); void -misc_print_grouped_int(gint number, gchar *buf, gboolean append); +misc_print_grouped_int(gint number, gchar *buf); gboolean query_integer_is_in_array(gint item, gint *array, gint min, gint max); @@ -58,15 +60,15 @@ const gchar* misc_parse_value(const gchar *s, gint *value); const gchar* -misc_parse_expression(const gchar *s, gboolean *result); +misc_parse_expression(const gchar *s, gint *result); const gchar* -misc_parse_comparison(const gchar *s, gboolean *result); +misc_parse_comparison(const gchar *s, gint *result); const gchar* -misc_parse_and(const gchar *s, gboolean *result); +misc_parse_and(const gchar *s, gint *result); const gchar* -misc_parse(const gchar *s, gboolean *result); +misc_parse(const gchar *s, gint *result); #endif diff --git a/src/treeview.c b/src/treeview.c index 016f9358..aa830ce0 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -724,7 +724,7 @@ treeview_create_game_stats(LiveGame *live_game) } } - misc_print_grouped_int(live_game->fix->attendance, buf[0], FALSE); + misc_print_grouped_int(live_game->fix->attendance, buf[0]); sprintf(buf[1], _("Attendance\n%s"), buf[0]); gtk_list_store_append(ls, &iter); gtk_list_store_set(ls, &iter, 0, buf[1], 1, "", 2, "", -1); @@ -1236,7 +1236,7 @@ treeview_create_stadium_summary(GtkListStore *ls) } gtk_list_store_append(ls, &iter); - misc_print_grouped_int(current_user.tm->stadium.capacity, buf, FALSE); + misc_print_grouped_int(current_user.tm->stadium.capacity, buf); gtk_list_store_set(ls, &iter, 0, _("Stadium capacity"), 1, buf, 2, "", -1); gtk_list_store_append(ls, &iter); @@ -1292,7 +1292,7 @@ treeview_create_finances(const User* user) for(i=0;i%s", const_app("string_treeview_finances_expenses_fg"), buf3); gtk_list_store_append(ls, &iter); @@ -1309,7 +1309,7 @@ treeview_create_finances(const User* user) balance += out[i]; } - misc_print_grouped_int(balance, buf, FALSE); + misc_print_grouped_int(balance, buf); gtk_list_store_append(ls, &iter); /* Finances balance. */ gtk_list_store_set(ls, &iter, 0, _("Balance"), 1, "", 2, "", -1); @@ -1325,8 +1325,8 @@ treeview_create_finances(const User* user) if(in[MON_IN_TRANSFERS] != 0 || out[MON_OUT_TRANSFERS] != 0) { - misc_print_grouped_int(in[MON_IN_TRANSFERS], buf, FALSE); - misc_print_grouped_int(out[MON_OUT_TRANSFERS], buf3, FALSE); + misc_print_grouped_int(in[MON_IN_TRANSFERS], buf); + misc_print_grouped_int(out[MON_OUT_TRANSFERS], buf3); sprintf(buf2, "%s", const_app("string_treeview_finances_expenses_fg"), buf3); gtk_list_store_append(ls, &iter); @@ -1336,7 +1336,7 @@ treeview_create_finances(const User* user) if(out[MON_OUT_STADIUM_IMPROVEMENT] + out[MON_OUT_STADIUM_BILLS] != 0) { misc_print_grouped_int(out[MON_OUT_STADIUM_IMPROVEMENT] + out[MON_OUT_STADIUM_BILLS], - buf, FALSE); + buf); sprintf(buf2, "%s", const_app("string_treeview_finances_expenses_fg"), buf); gtk_list_store_append(ls, &iter); @@ -1346,7 +1346,7 @@ treeview_create_finances(const User* user) gtk_list_store_append(ls, &iter); gtk_list_store_set(ls, &iter, 0, "", 1, "", 2, "", -1); - misc_print_grouped_int(user->money, buf, FALSE); + misc_print_grouped_int(user->money, buf); gtk_list_store_append(ls, &iter); if(user->money >= 0) strcpy(buf2, buf); @@ -1355,13 +1355,13 @@ treeview_create_finances(const User* user) const_app("string_treeview_finances_expenses_fg"), buf); gtk_list_store_set(ls, &iter, 0, _("Money"), 1, buf2, 2, "", -1); - misc_print_grouped_int(finance_team_drawing_credit_loan(user->tm, FALSE), buf, FALSE); + misc_print_grouped_int(finance_team_drawing_credit_loan(user->tm, FALSE), buf); gtk_list_store_append(ls, &iter); gtk_list_store_set(ls, &iter, 0, _("Drawing credit"), 1, buf, 2, "", -1); if(user->debt != 0) { - misc_print_grouped_int(user->debt, buf, FALSE); + misc_print_grouped_int(user->debt, buf); sprintf(buf2, "%s", const_app("string_treeview_finances_expenses_fg"), buf); sprintf(buf, _("Debt (repay in %d weeks)"), user->counters[COUNT_USER_LOAN]); @@ -1376,7 +1376,7 @@ treeview_create_finances(const User* user) gtk_list_store_set(ls, &iter, 0, _("Sponsor"), 1, user->sponsor.name->str, 2, "", -1); - misc_print_grouped_int(user->sponsor.benefit, buf, FALSE); + misc_print_grouped_int(user->sponsor.benefit, buf); /* Contract time and money a sponsor pays. */ sprintf(buf2, _("%.1f months / %s"), ((gfloat)user->sponsor.contract) / 4, buf); gtk_list_store_append(ls, &iter); diff --git a/src/treeview_helper.c b/src/treeview_helper.c index 1d2c90ef..92e643bf 100644 --- a/src/treeview_helper.c +++ b/src/treeview_helper.c @@ -933,10 +933,10 @@ treeview_helper_player_to_cell(GtkTreeViewColumn *col, pl->etal[current_user.scout % 10]); break; case PLAYER_LIST_ATTRIBUTE_VALUE: - misc_print_grouped_int(pl->value, buf, FALSE); + misc_print_grouped_int(pl->value, buf); break; case PLAYER_LIST_ATTRIBUTE_WAGE: - misc_print_grouped_int(pl->wage, buf, FALSE); + misc_print_grouped_int(pl->wage, buf); break; case PLAYER_LIST_ATTRIBUTE_CONTRACT: treeview_helper_player_contract_to_cell(renderer, buf, pl->contract); diff --git a/src/user.c b/src/user.c index 5664009e..705e5bba 100644 --- a/src/user.c +++ b/src/user.c @@ -443,26 +443,26 @@ user_event_show_next(void) game_gui_show_warning(buf); break; case EVENT_TYPE_TRANSFER_OFFER_REJECTED_BETTER_OFFER: - misc_print_grouped_int(event->value1, buf2, FALSE); - misc_print_grouped_int(event->value2, buf3, FALSE); + misc_print_grouped_int(event->value1, buf2); + misc_print_grouped_int(event->value2, buf3); sprintf(buf, _("The owners of %s have rejected your offer (%s / %s) for %s. There was a better offer for the player than yours."), ((Team*)event->value_pointer)->name->str, buf2, buf3, event->value_string->str); game_gui_show_warning(buf); break; case EVENT_TYPE_TRANSFER_OFFER_REJECTED_FEE_WAGE: - misc_print_grouped_int(event->value1, buf2, FALSE); - misc_print_grouped_int(event->value2, buf3, FALSE); + misc_print_grouped_int(event->value1, buf2); + misc_print_grouped_int(event->value2, buf3); sprintf(buf, _("The owners of %s have rejected your offer (%s / %s) for %s. Neither the fee nor the wage you offered were acceptable, they say."), ((Team*)event->value_pointer)->name->str, buf2, buf3, event->value_string->str); game_gui_show_warning(buf); break; case EVENT_TYPE_TRANSFER_OFFER_REJECTED_FEE: - misc_print_grouped_int(event->value1, buf2, FALSE); - misc_print_grouped_int(event->value2, buf3, FALSE); + misc_print_grouped_int(event->value1, buf2); + misc_print_grouped_int(event->value2, buf3); sprintf(buf, _("The owners of %s have rejected your offer (%s / %s) for %s. The team owners weren't satisfied with the fee you offered."), ((Team*)event->value_pointer)->name->str, buf2, buf3, event->value_string->str); game_gui_show_warning(buf); break; case EVENT_TYPE_TRANSFER_OFFER_REJECTED_WAGE: - misc_print_grouped_int(event->value1, buf2, FALSE); - misc_print_grouped_int(event->value2, buf3, FALSE); + misc_print_grouped_int(event->value1, buf2); + misc_print_grouped_int(event->value2, buf3); /* A player from a team has rejected a transfer offer. */ sprintf(buf, _("%s of %s has rejected your offer (%s / %s). He wasn't satisfied with the wage you offered."), event->value_string->str, diff --git a/src/variables.h b/src/variables.h index c76fa8d9..dee2ab77 100644 --- a/src/variables.h +++ b/src/variables.h @@ -35,7 +35,7 @@ OptionList settings; OptionList lg_tokens; /** The array containing the live game commentary strings. */ -GPtrArray *lg_commentary[LIVE_GAME_EVENT_END]; +GArray *lg_commentary[LIVE_GAME_EVENT_END]; /** The array containing players to be transfered. @see TransferPlayer */ diff --git a/src/xml_lg_commentary.c b/src/xml_lg_commentary.c index 35caa2e0..c56aff65 100644 --- a/src/xml_lg_commentary.c +++ b/src/xml_lg_commentary.c @@ -10,6 +10,9 @@ #define TAG_EVENT_NAME "name" #define TAG_EVENT_COMMENTARY "commentary" +#define ATT_NAME_CONDITION "cond" +#define ATT_NAME_PRIORITY "pri" + #define EVENT_NAME_GENERAL "general" #define EVENT_NAME_START_MATCH "start_match" #define EVENT_NAME_HALF_TIME "half_time" @@ -52,8 +55,8 @@ enum XmlLgCommentaryStates STATE_END }; -gint state, commentary_idx; -gchar condition[SMALL]; +gint state, commentary_idx, priority; +GString *condition; /** * The function called by the parser when an opening tag is read. @@ -69,6 +72,8 @@ xml_lg_commentary_read_start_element (GMarkupParseContext *context, gpointer user_data, GError **error) { + gint atidx = 0; + if(strcmp(element_name, TAG_EVENT) == 0) state = STATE_EVENT; else if(strcmp(element_name, TAG_EVENT_NAME) == 0) @@ -76,10 +81,20 @@ xml_lg_commentary_read_start_element (GMarkupParseContext *context, else if(strcmp(element_name, TAG_EVENT_COMMENTARY) == 0) { state = STATE_EVENT_COMMENTARY; - if(attribute_names[0] != NULL) - sprintf(condition, "#%s", attribute_values[0]); - else - strcpy(condition, ""); + + condition = NULL; + priority = 1; + + while(attribute_names[atidx] != NULL) + { + if(strcmp(attribute_names[atidx], ATT_NAME_CONDITION) == 0) + condition = g_string_new(attribute_values[atidx]); + else if(strcmp(attribute_names[atidx], ATT_NAME_PRIORITY) == 0) + priority = (gint)g_ascii_strtod(attribute_values[atidx], NULL); + + atidx++; + } + } else if(strcmp(element_name, TAG_LG_COMMENTARY) != 0) g_warning("xml_lg_commentary_read_start_element: unknown tag: %s; I'm in state %d\n", @@ -121,7 +136,7 @@ xml_lg_commentary_read_text (GMarkupParseContext *context, GError **error) { gchar buf[text_len + 1]; - GString *commentary = NULL; + LGCommentary commentary; strncpy(buf, text, text_len); buf[text_len] = '\0'; @@ -195,9 +210,10 @@ xml_lg_commentary_read_text (GMarkupParseContext *context, } else if(state == STATE_EVENT_COMMENTARY) { - commentary = g_string_new(""); - g_string_printf(commentary, "%s%s", condition, buf); - g_ptr_array_add(lg_commentary[commentary_idx], commentary); + commentary.text = g_string_new(buf); + commentary.condition = condition; + commentary.priority = MAX(1, priority); + g_array_append_val(lg_commentary[commentary_idx], commentary); } } @@ -219,7 +235,6 @@ xml_lg_commentary_read(const gchar *commentary_file) gchar *file_contents; gint length; GError *error = NULL; - gint i; context = g_markup_parse_context_new(&parser, 0, NULL, NULL); @@ -237,11 +252,7 @@ xml_lg_commentary_read(const gchar *commentary_file) return; } - for(i=0;i