mirror of
https://github.com/tstellar/bygfoot.git
synced 2024-12-16 02:11:23 +01:00
News, first steps.
This commit is contained in:
parent
884d69c524
commit
14b1a6bcf8
@ -175,7 +175,6 @@ sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AM_CFLAGS = -Wall #-fprofile-arcs -ftest-coverage -pg
|
||||
|
@ -40,6 +40,7 @@ bygfoot_SOURCES = \
|
||||
misc2_interface.c misc2_callbacks.h misc2_interface.h support.h \
|
||||
misc3_interface.c misc3_callbacks.h misc3_interface.h support.h \
|
||||
name.c main.h name.h option.h variables.h xml_name.h \
|
||||
news.c news.h variables.h xml_news.h \
|
||||
option.c main.h misc.h option.h variables.h \
|
||||
option_gui.c callbacks.h file.h game_gui.h language.h misc.h option_gui.h option.h support.h training.h treeview.h user.h variables.h \
|
||||
options_callbacks.c file.h option_gui.h options_callbacks.h options_interface.h support.h training.h user.h variables.h window.h \
|
||||
@ -81,6 +82,7 @@ bygfoot_SOURCES = \
|
||||
xml_lg_commentary.c free.h lg_commentary.h live_game.h misc.h variables.h xml_lg_commentary.h \
|
||||
xml_mmatches.c file.h free.h live_game.h misc.h user.h xml.h xml_loadsave_live_game.h xml_mmatches.h \
|
||||
xml_name.c file.h free.h misc.h name.h variables.h xml_name.h \
|
||||
xml_news.c file.h free.h news.h variables.h xml_news.h \
|
||||
xml_strategy.c file.h free.h main.h misc.h strategy_struct.h xml_strategy.h \
|
||||
xml_team.c file.h free.h main.h misc.h option.h player.h team.h variables.h xml_team.h \
|
||||
youth_academy.c free.h maths.h name.h option.h player.h team.h user.h youth_academy.h
|
||||
|
@ -54,12 +54,12 @@ am_bygfoot_OBJECTS = bet.$(OBJEXT) callback_func.$(OBJEXT) \
|
||||
misc_callback_func.$(OBJEXT) misc2_callbacks.$(OBJEXT) \
|
||||
misc3_callbacks.$(OBJEXT) misc2_callback_func.$(OBJEXT) \
|
||||
misc_interface.$(OBJEXT) misc2_interface.$(OBJEXT) \
|
||||
misc3_interface.$(OBJEXT) name.$(OBJEXT) option.$(OBJEXT) \
|
||||
option_gui.$(OBJEXT) options_callbacks.$(OBJEXT) \
|
||||
options_interface.$(OBJEXT) player.$(OBJEXT) \
|
||||
start_end.$(OBJEXT) stat.$(OBJEXT) strategy.$(OBJEXT) \
|
||||
support.$(OBJEXT) table.$(OBJEXT) team.$(OBJEXT) \
|
||||
training.$(OBJEXT) training_callbacks.$(OBJEXT) \
|
||||
misc3_interface.$(OBJEXT) name.$(OBJEXT) news.$(OBJEXT) \
|
||||
option.$(OBJEXT) option_gui.$(OBJEXT) \
|
||||
options_callbacks.$(OBJEXT) options_interface.$(OBJEXT) \
|
||||
player.$(OBJEXT) start_end.$(OBJEXT) stat.$(OBJEXT) \
|
||||
strategy.$(OBJEXT) support.$(OBJEXT) table.$(OBJEXT) \
|
||||
team.$(OBJEXT) training.$(OBJEXT) training_callbacks.$(OBJEXT) \
|
||||
training_interface.$(OBJEXT) transfer.$(OBJEXT) \
|
||||
treeview.$(OBJEXT) treeview2.$(OBJEXT) \
|
||||
treeview_helper.$(OBJEXT) user.$(OBJEXT) window.$(OBJEXT) \
|
||||
@ -75,8 +75,8 @@ am_bygfoot_OBJECTS = bet.$(OBJEXT) callback_func.$(OBJEXT) \
|
||||
xml_loadsave_transfers.$(OBJEXT) xml_loadsave_users.$(OBJEXT) \
|
||||
xml_cup.$(OBJEXT) xml_country.$(OBJEXT) xml_league.$(OBJEXT) \
|
||||
xml_lg_commentary.$(OBJEXT) xml_mmatches.$(OBJEXT) \
|
||||
xml_name.$(OBJEXT) xml_strategy.$(OBJEXT) xml_team.$(OBJEXT) \
|
||||
youth_academy.$(OBJEXT)
|
||||
xml_name.$(OBJEXT) xml_news.$(OBJEXT) xml_strategy.$(OBJEXT) \
|
||||
xml_team.$(OBJEXT) youth_academy.$(OBJEXT)
|
||||
bygfoot_OBJECTS = $(am_bygfoot_OBJECTS)
|
||||
am__DEPENDENCIES_1 =
|
||||
bygfoot_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
@ -199,7 +199,6 @@ sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AM_CFLAGS = -Wall #-fprofile-arcs -ftest-coverage -pg
|
||||
@ -240,6 +239,7 @@ bygfoot_SOURCES = \
|
||||
misc2_interface.c misc2_callbacks.h misc2_interface.h support.h \
|
||||
misc3_interface.c misc3_callbacks.h misc3_interface.h support.h \
|
||||
name.c main.h name.h option.h variables.h xml_name.h \
|
||||
news.c news.h variables.h xml_news.h \
|
||||
option.c main.h misc.h option.h variables.h \
|
||||
option_gui.c callbacks.h file.h game_gui.h language.h misc.h option_gui.h option.h support.h training.h treeview.h user.h variables.h \
|
||||
options_callbacks.c file.h option_gui.h options_callbacks.h options_interface.h support.h training.h user.h variables.h window.h \
|
||||
@ -281,6 +281,7 @@ bygfoot_SOURCES = \
|
||||
xml_lg_commentary.c free.h lg_commentary.h live_game.h misc.h variables.h xml_lg_commentary.h \
|
||||
xml_mmatches.c file.h free.h live_game.h misc.h user.h xml.h xml_loadsave_live_game.h xml_mmatches.h \
|
||||
xml_name.c file.h free.h misc.h name.h variables.h xml_name.h \
|
||||
xml_news.c file.h free.h news.h variables.h xml_news.h \
|
||||
xml_strategy.c file.h free.h main.h misc.h strategy_struct.h xml_strategy.h \
|
||||
xml_team.c file.h free.h main.h misc.h option.h player.h team.h variables.h xml_team.h \
|
||||
youth_academy.c free.h maths.h name.h option.h player.h team.h user.h youth_academy.h
|
||||
@ -383,6 +384,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc_callbacks.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc_interface.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/name.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/news.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/option.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/option_gui.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options_callbacks.Po@am__quote@
|
||||
@ -424,6 +426,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xml_loadsave_users.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xml_mmatches.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xml_name.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xml_news.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xml_strategy.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xml_team.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/youth_academy.Po@am__quote@
|
||||
|
@ -63,6 +63,8 @@
|
||||
#define league_id_new (counters[COUNT_LEAGUE_ID]++)
|
||||
#define fixture_id_new (counters[COUNT_FIX_ID]++)
|
||||
#define lg_commentary_id_new (counters[COUNT_LG_COMM_ID]++)
|
||||
#define news_title_id_new (counters[COUNT_NEWS_TITLE_ID]++)
|
||||
#define news_subtitle_id_new (counters[COUNT_NEWS_SUBTITLE_ID]++)
|
||||
|
||||
/** Convenience abbreviation. */
|
||||
#define ligs country.leagues
|
||||
|
@ -37,6 +37,8 @@ enum Counters
|
||||
COUNT_LEAGUE_ID,
|
||||
COUNT_FIX_ID,
|
||||
COUNT_LG_COMM_ID,
|
||||
COUNT_NEWS_TITLE_ID,
|
||||
COUNT_NEWS_SUBTITLE_ID,
|
||||
COUNT_SHOW_DEBUG,
|
||||
COUNT_HINT_NUMBER,
|
||||
COUNT_END
|
||||
|
38
src/free.c
38
src/free.c
@ -26,6 +26,7 @@
|
||||
#include "bet_struct.h"
|
||||
#include "free.h"
|
||||
#include "lg_commentary_struct.h"
|
||||
#include "news_struct.h"
|
||||
#include "strategy_struct.h"
|
||||
#include "transfer.h"
|
||||
#include "user.h"
|
||||
@ -51,6 +52,7 @@ free_memory(void)
|
||||
free_bets(FALSE);
|
||||
free_live_game(&live_game_temp);
|
||||
free_lg_commentary(FALSE);
|
||||
free_news(FALSE);
|
||||
free_support_dirs();
|
||||
free_jobs(FALSE);
|
||||
}
|
||||
@ -707,6 +709,42 @@ free_lg_commentary(gboolean reset)
|
||||
lg_commentary[i] = g_array_new(FALSE, FALSE, sizeof(LGCommentary));
|
||||
}
|
||||
|
||||
/** Free the list with live game commentary text. */
|
||||
void
|
||||
free_news(gboolean reset)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("free_news\n");
|
||||
#endif
|
||||
|
||||
gint i, j, k;
|
||||
|
||||
for(i=0;i<NEWS_ARTICLE_TYPE_END;i++)
|
||||
if(news[i] != NULL)
|
||||
{
|
||||
for(j=0;j<news[i]->len;j++)
|
||||
{
|
||||
g_free(g_array_index(news[i], NewsArticle, j).condition);
|
||||
|
||||
for(k = 0; k < g_array_index(news[i], NewsArticle, j).titles->len; k++)
|
||||
g_free(g_array_index(g_array_index(news[i], NewsArticle, j).titles, NewsText, k).text);
|
||||
|
||||
g_array_free(g_array_index(news[i], NewsArticle, j).titles, TRUE);
|
||||
|
||||
for(k = 0; k < g_array_index(news[i], NewsArticle, j).subtitles->len; k++)
|
||||
g_free(g_array_index(g_array_index(news[i], NewsArticle, j).subtitles, NewsText, k).text);
|
||||
|
||||
g_array_free(g_array_index(news[i], NewsArticle, j).subtitles, TRUE);
|
||||
}
|
||||
|
||||
free_g_array(&news[i]);
|
||||
}
|
||||
|
||||
if(reset)
|
||||
for(i=0;i<NEWS_ARTICLE_TYPE_END;i++)
|
||||
news[i] = g_array_new(FALSE, FALSE, sizeof(NewsArticle));
|
||||
}
|
||||
|
||||
/**
|
||||
Free a GPtrArray containing strings.
|
||||
@param array The array to be freed.
|
||||
|
@ -146,4 +146,7 @@ free_job(Job *job, gboolean free_tm);
|
||||
void
|
||||
free_jobs(gboolean reset);
|
||||
|
||||
void
|
||||
free_news(gboolean reset);
|
||||
|
||||
#endif
|
||||
|
@ -932,8 +932,8 @@ game_gui_set_help_labels(void)
|
||||
|
||||
g_string_append_printf(text, _("At the Bygfoot forums you can report bugs, ask for help and discuss the game:\n"));
|
||||
g_string_append_printf(text, "http://bygfoot.sourceforge.net/forum\n");
|
||||
g_string_append_printf(text, _("\nIf you feel you've found out something about the game that has to be shared, you can add it to the Bygfoot Wiki:\n"));
|
||||
g_string_append_printf(text, "http://mec-symonds.eng.monash.edu.au/twiki/bin/view/Bygfoot/WebHome");
|
||||
g_string_append_printf(text, _("\nYou can also write an email to the authors:\n"));
|
||||
g_string_append_printf(text, "gunnar@bygfoot.com, gyboth@bygfoot.com");
|
||||
|
||||
gtk_label_set_text(label_help_text2, text->str);
|
||||
g_string_free(text, TRUE);
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "language.h"
|
||||
#include "lg_commentary.h"
|
||||
#include "misc.h"
|
||||
#include "news.h"
|
||||
#include "option.h"
|
||||
#include "variables.h"
|
||||
#include "window.h"
|
||||
@ -86,6 +87,7 @@ language_set(gint index)
|
||||
}
|
||||
|
||||
lg_commentary_load_commentary_file_from_option();
|
||||
news_load_news_file_from_option();
|
||||
g_free(pwd);
|
||||
free_gchar_array(&codes);
|
||||
}
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "misc.h"
|
||||
#include "misc_callbacks.h"
|
||||
#include "name_struct.h"
|
||||
#include "news_struct.h"
|
||||
#include "option.h"
|
||||
#include "start_end.h"
|
||||
#include "stat_struct.h"
|
||||
@ -235,6 +236,9 @@ main_init_variables(void)
|
||||
for(i=0;i<LIVE_GAME_EVENT_END;i++)
|
||||
lg_commentary[i] = g_array_new(FALSE, FALSE, sizeof(LGCommentary));
|
||||
|
||||
for(i=0;i<NEWS_ARTICLE_TYPE_END;i++)
|
||||
news[i] = g_array_new(FALSE, FALSE, sizeof(NewsArticle));
|
||||
|
||||
file_load_conf_files();
|
||||
xml_strategy_load_strategies();
|
||||
|
||||
|
746
src/news.c
Normal file
746
src/news.c
Normal file
@ -0,0 +1,746 @@
|
||||
/*
|
||||
news.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 <locale.h>
|
||||
|
||||
#include "file.h"
|
||||
#include "language.h"
|
||||
#include "main.h"
|
||||
#include "news.h"
|
||||
#include "variables.h"
|
||||
#include "xml_news.h"
|
||||
|
||||
/** The replacement strings for the news tokens. */
|
||||
GPtrArray *token_rep[2];
|
||||
/** Whether there was a news repetition rejection. */
|
||||
gboolean repetition;
|
||||
|
||||
/* /\** Generate news for the live game event in the unit. */
|
||||
/* @param live_game The live game being calculated. */
|
||||
/* @param unit The live game unit we generate the news for. */
|
||||
/* @param event_type The event type we generate the news for (needed */
|
||||
/* when news is being tested). *\/ */
|
||||
/* void */
|
||||
/* news_generate(const LiveGame *live_game, LiveGameUnit *unit, */
|
||||
/* const gchar *event_name, gint ev_type) */
|
||||
/* { */
|
||||
/* #ifdef DEBUG */
|
||||
/* printf("news_generate\n"); */
|
||||
/* #endif */
|
||||
|
||||
/* gint i, event_type = -1; */
|
||||
/* gint news_idx = -1; */
|
||||
/* gchar buf[SMALL]; */
|
||||
/* GArray *commentaries = NULL; */
|
||||
|
||||
/* if(unit != NULL) */
|
||||
/* event_type = unit->event.type; */
|
||||
/* else */
|
||||
/* event_type = (event_name == NULL) ? ev_type : */
|
||||
/* xml_news_event_name_to_int(event_name); */
|
||||
|
||||
/* if(event_type == -1) */
|
||||
/* return; */
|
||||
|
||||
/* if(live_game != NULL) */
|
||||
/* { */
|
||||
/* news_set_basic_tokens(unit, live_game->fix); */
|
||||
/* news_set_team_tokens(unit, live_game->fix); */
|
||||
/* news_set_player_tokens(unit, live_game->fix); */
|
||||
/* news_set_stats_tokens(&live_game->stats); */
|
||||
/* } */
|
||||
|
||||
/* if(event_type == LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_DEFEND || */
|
||||
/* event_type == LIVE_GAME_EVENT_STYLE_CHANGE_DEFEND || */
|
||||
/* event_type == LIVE_GAME_EVENT_STYLE_CHANGE_BALANCED || */
|
||||
/* event_type == LIVE_GAME_EVENT_STYLE_CHANGE_ATTACK || */
|
||||
/* event_type == LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_ATTACK) */
|
||||
/* commentaries = news[LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_DEFEND]; */
|
||||
/* else if(event_type == LIVE_GAME_EVENT_BOOST_CHANGE_ANTI || */
|
||||
/* event_type == LIVE_GAME_EVENT_BOOST_CHANGE_OFF || */
|
||||
/* event_type == LIVE_GAME_EVENT_BOOST_CHANGE_ON) */
|
||||
/* commentaries = news[LIVE_GAME_EVENT_BOOST_CHANGE_ANTI]; */
|
||||
/* else */
|
||||
/* commentaries = news[event_type]; */
|
||||
|
||||
/* news_idx = news_select(commentaries, buf); */
|
||||
|
||||
/* if(news_idx == -1) */
|
||||
/* g_warning("news_generate: didn't find fitting news for unit type %d \n", */
|
||||
/* event_type); */
|
||||
|
||||
/* if(live_game != NULL) */
|
||||
/* { */
|
||||
/* unit->event.news = g_strdup(buf); */
|
||||
/* unit->event.news_id = (news_idx == -1) ? */
|
||||
/* -1 : g_array_index(commentaries, LGNews, news_idx).id; */
|
||||
|
||||
/* for(i=0;i<tokens.list->len;i++) */
|
||||
/* if(i != option_int("string_token_team_home", &tokens) && */
|
||||
/* i != option_int("string_token_team_away", &tokens) && */
|
||||
/* i != option_int("string_token_attendance", &tokens) && */
|
||||
/* i != option_int("string_token_cup_round_name", &tokens) && */
|
||||
/* i != option_int("string_token_league_cup_name", &tokens) && */
|
||||
/* i != option_int("string_token_yellow_limit", &tokens) && */
|
||||
/* i != option_int("string_token_team_layer0", &tokens) && */
|
||||
/* i != option_int("string_token_team_layer1", &tokens)) */
|
||||
/* misc_token_remove(token_rep, i); */
|
||||
/* } */
|
||||
/* else */
|
||||
/* g_print("%s: \"%s\"\n", event_name, buf); */
|
||||
/* } */
|
||||
|
||||
/* /\** Select a news from the array depending on the tokens */
|
||||
/* available and write the text into the buffer. *\/ */
|
||||
/* gint */
|
||||
/* news_select(const GArray *commentaries, gchar *buf) */
|
||||
/* { */
|
||||
/* #ifdef DEBUG */
|
||||
/* printf("news_select\n"); */
|
||||
/* #endif */
|
||||
|
||||
/* gint i, order[commentaries->len]; */
|
||||
|
||||
/* news_get_order(commentaries, order); */
|
||||
|
||||
/* repetition = FALSE; */
|
||||
|
||||
/* for(i=0;i<commentaries->len;i++) */
|
||||
/* if(news_check_news(&g_array_index(commentaries, LGNews, order[i]), buf)) */
|
||||
/* break; */
|
||||
|
||||
/* if(i == commentaries->len) */
|
||||
/* { */
|
||||
/* repetition = TRUE; */
|
||||
/* for(i=0;i<commentaries->len;i++) */
|
||||
/* if(news_check_news(&g_array_index(commentaries, LGNews, order[i]), buf)) */
|
||||
/* break; */
|
||||
/* } */
|
||||
|
||||
/* if(i == commentaries->len) */
|
||||
/* { */
|
||||
/* strcpy(buf, "FIXME!"); */
|
||||
/* return -1; */
|
||||
/* } */
|
||||
|
||||
/* return order[i]; */
|
||||
/* } */
|
||||
|
||||
/* /\** Check whether the news conditions are fulfilled and whether */
|
||||
/* we can replace all tokens in the news. *\/ */
|
||||
/* gboolean */
|
||||
/* news_check_news(const LGNews *news, gchar *dest) */
|
||||
/* { */
|
||||
/* #ifdef DEBUG */
|
||||
/* printf("news_check_news\n"); */
|
||||
/* #endif */
|
||||
|
||||
/* gchar buf[SMALL]; */
|
||||
|
||||
/* if(strlen(news->text) == 0 || */
|
||||
/* (news->condition != NULL && */
|
||||
/* !misc_parse_condition(news->condition, token_rep)) || */
|
||||
/* (repetition == FALSE && query_news_is_repetition(news->id))) */
|
||||
/* return FALSE; */
|
||||
|
||||
/* strcpy(dest, news->text); */
|
||||
|
||||
/* do */
|
||||
/* { */
|
||||
/* strcpy(buf, dest); */
|
||||
/* misc_string_replace_tokens(dest, token_rep); */
|
||||
/* misc_string_replace_expressions(dest); */
|
||||
/* } */
|
||||
/* while(strcmp(buf, dest) != 0); */
|
||||
|
||||
/* return (g_strrstr(dest, "_") == NULL); */
|
||||
/* } */
|
||||
|
||||
/* /\** Check whether a news with given id has been used in the last */
|
||||
/* few commentaries. Return TRUE if so and FALSE otherwise. *\/ */
|
||||
/* gboolean */
|
||||
/* query_news_is_repetition(gint id) */
|
||||
/* { */
|
||||
/* #ifdef DEBUG */
|
||||
/* printf("query_news_is_repetition\n"); */
|
||||
/* #endif */
|
||||
|
||||
/* const GArray *units = ((LiveGame*)statp)->units; */
|
||||
/* gint units_min = units->len - const_int("int_news_check_backwards") - 1; */
|
||||
/* gint i, min = MAX(units_min, 0); */
|
||||
|
||||
/* for(i=units->len - 2; i>= min; i--) */
|
||||
/* if(g_array_index(units, LiveGameUnit, i).event.news_id == id) */
|
||||
/* return TRUE; */
|
||||
|
||||
/* return FALSE; */
|
||||
/* } */
|
||||
|
||||
/* /\** 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 */
|
||||
/* news_get_order(const GArray *commentaries, gint *order) */
|
||||
/* { */
|
||||
/* #ifdef DEBUG */
|
||||
/* printf("news_get_order\n"); */
|
||||
/* #endif */
|
||||
|
||||
/* gint i, j, order_idx = 0; */
|
||||
/* gint priority_sum = 0, bounds[commentaries->len + 1]; */
|
||||
|
||||
/* bounds[0] = 0; */
|
||||
|
||||
/* for(i=0;i<commentaries->len;i++) */
|
||||
/* { */
|
||||
/* priority_sum += g_array_index(commentaries, LGNews, i).priority; */
|
||||
/* bounds[i + 1] = priority_sum; */
|
||||
/* order[i] = -1; */
|
||||
/* } */
|
||||
|
||||
/* gint permutation[priority_sum]; */
|
||||
|
||||
/* math_generate_permutation(permutation, 1, priority_sum); */
|
||||
|
||||
/* for(i=0;i<priority_sum;i++) */
|
||||
/* { */
|
||||
/* if(order_idx == commentaries->len) */
|
||||
/* break; */
|
||||
|
||||
/* for(j=0;j<commentaries->len;j++) */
|
||||
/* if(bounds[j] < permutation[i] && permutation[i] <= bounds[j + 1]) */
|
||||
/* { */
|
||||
/* if(!query_integer_is_in_array(j, order, commentaries->len)) */
|
||||
/* { */
|
||||
/* order[order_idx] = j; */
|
||||
/* order_idx++; */
|
||||
/* } */
|
||||
|
||||
/* break; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* /\** Fill the stats tokens. *\/ */
|
||||
/* void */
|
||||
/* news_set_stats_tokens(const LiveGameStats *stats) */
|
||||
/* { */
|
||||
/* #ifdef DEBUG */
|
||||
/* printf("news_set_stats_tokens\n"); */
|
||||
/* #endif */
|
||||
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_stat_shots0", &tokens), */
|
||||
/* misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_SHOTS])); */
|
||||
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_stat_shot_per0", &tokens), */
|
||||
/* misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_SHOT_PERCENTAGE])); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_stat_poss0", &tokens), */
|
||||
/* misc_int_to_char((gint)rint(100 * */
|
||||
/* ((gfloat)stats->values[0][LIVE_GAME_STAT_VALUE_POSSESSION] / */
|
||||
/* ((gfloat)stats->values[0][LIVE_GAME_STAT_VALUE_POSSESSION] + */
|
||||
/* (gfloat)stats->values[1][LIVE_GAME_STAT_VALUE_POSSESSION]))))); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_stat_pen0", &tokens), */
|
||||
/* misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_PENALTIES])); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_stat_fouls0", &tokens), */
|
||||
/* misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_FOULS])); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_stat_yellows0", &tokens), */
|
||||
/* misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_CARDS])); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_stat_reds0", &tokens), */
|
||||
/* misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_REDS])); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_stat_injs0", &tokens), */
|
||||
/* misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_INJURIES])); */
|
||||
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_stat_shots1", &tokens), */
|
||||
/* misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_SHOTS])); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_stat_shot_per1", &tokens), */
|
||||
/* misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_SHOT_PERCENTAGE])); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_stat_poss1", &tokens), */
|
||||
/* misc_int_to_char((gint)rint(100 * ((gfloat)stats->values[1][LIVE_GAME_STAT_VALUE_POSSESSION] / */
|
||||
/* ((gfloat)stats->values[0][LIVE_GAME_STAT_VALUE_POSSESSION] + */
|
||||
/* (gfloat)stats->values[1][LIVE_GAME_STAT_VALUE_POSSESSION]))))); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_stat_pen1", &tokens), */
|
||||
/* misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_PENALTIES])); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_stat_fouls1", &tokens), */
|
||||
/* misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_FOULS])); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_stat_yellows1", &tokens), */
|
||||
/* misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_CARDS])); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_stat_reds1", &tokens), */
|
||||
/* misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_REDS])); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_stat_injs1", &tokens), */
|
||||
/* misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_INJURIES])); */
|
||||
/* } */
|
||||
|
||||
/* /\** Fill the tokens that contain general information. *\/ */
|
||||
/* void */
|
||||
/* news_set_basic_tokens(const LiveGameUnit *unit, const Fixture *fix) */
|
||||
/* { */
|
||||
/* #ifdef DEBUG */
|
||||
/* printf("news_set_basic_tokens\n"); */
|
||||
/* #endif */
|
||||
|
||||
/* 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]); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_result", &tokens), */
|
||||
/* g_strdup(buf)); */
|
||||
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_time", &tokens), */
|
||||
/* misc_int_to_char(unit->time)); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_minute", &tokens), */
|
||||
/* misc_int_to_char(current_min)); */
|
||||
|
||||
/* tmp_int = live_game_get_minutes_remaining(unit); */
|
||||
|
||||
/* if(tmp_int > 0) */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_minute_remaining", &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) */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_minute_total", &tokens), */
|
||||
/* misc_int_to_char(tmp_int)); */
|
||||
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_goals0", &tokens), */
|
||||
/* misc_int_to_char(unit->result[0])); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_goals1", &tokens), */
|
||||
/* misc_int_to_char(unit->result[1])); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_goal_diff", &tokens), */
|
||||
/* misc_int_to_char(ABS(unit->result[0] - unit->result[1]))); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_extra", &tokens), */
|
||||
/* news_get_extra_data(unit, fix)); */
|
||||
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_possession", &tokens), */
|
||||
/* misc_int_to_char(unit->possession)); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_no_possession", &tokens), */
|
||||
/* misc_int_to_char(!unit->possession)); */
|
||||
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_team_avskill0", &tokens), */
|
||||
/* misc_int_to_char(avskill0)); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_team_avskill1", &tokens), */
|
||||
/* misc_int_to_char(avskill1)); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_team_avskilldiff", &tokens), */
|
||||
/* misc_int_to_char(ABS(avskill0 - avskill1))); */
|
||||
/* } */
|
||||
|
||||
/* /\** Set the tokens containing team data. *\/ */
|
||||
/* void */
|
||||
/* news_set_team_tokens(const LiveGameUnit *unit, const Fixture *fix) */
|
||||
/* { */
|
||||
/* #ifdef DEBUG */
|
||||
/* printf("news_set_team_tokens\n"); */
|
||||
/* #endif */
|
||||
|
||||
/* if(unit->result[0] != unit->result[1]) */
|
||||
/* { */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_team_losing", &tokens), */
|
||||
/* g_strdup(fix->teams[(unit->result[0] > unit->result[1])]->name)); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_team_winning", &tokens), */
|
||||
/* g_strdup(fix->teams[(unit->result[0] < unit->result[1])]->name)); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_team_losingn", &tokens), */
|
||||
/* misc_int_to_char((unit->result[0] > unit->result[1]))); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_team_winningn", &tokens), */
|
||||
/* misc_int_to_char((unit->result[0] < unit->result[1]))); */
|
||||
/* } */
|
||||
|
||||
/* if(unit->event.team != -1) */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_team", &tokens), */
|
||||
/* misc_int_to_char(unit->event.team)); */
|
||||
/* } */
|
||||
|
||||
/* /\** Set the player tokens. *\/ */
|
||||
/* void */
|
||||
/* news_set_player_tokens(const LiveGameUnit *unit, const Fixture *fix) */
|
||||
/* { */
|
||||
/* #ifdef DEBUG */
|
||||
/* printf("news_set_player_tokens\n"); */
|
||||
/* #endif */
|
||||
|
||||
/* 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_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) */
|
||||
/* { */
|
||||
/* 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) */
|
||||
/* 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) */
|
||||
/* { */
|
||||
/* 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); */
|
||||
/* } */
|
||||
|
||||
/* if(pl1 != NULL) */
|
||||
/* { */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_player0", &tokens), */
|
||||
/* player_get_last_name(pl1->name)); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_player_goals0", &tokens), */
|
||||
/* misc_int_to_char(player_games_goals_get( */
|
||||
/* pl1, fix->clid, PLAYER_VALUE_GOALS))); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_player_goals_all0", &tokens), */
|
||||
/* misc_int_to_char(player_all_games_goals(pl1, PLAYER_VALUE_GOALS))); */
|
||||
/* } */
|
||||
|
||||
/* if(pl2 != NULL) */
|
||||
/* { */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_player1", &tokens), */
|
||||
/* player_get_last_name(pl2->name)); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_player_goals1", &tokens), */
|
||||
/* misc_int_to_char(player_games_goals_get(pl2, fix->clid, PLAYER_VALUE_GOALS))); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_player_goals_all1", &tokens), */
|
||||
/* misc_int_to_char(player_all_games_goals(pl2, PLAYER_VALUE_GOALS))); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_player_yellows", &tokens), */
|
||||
/* misc_int_to_char(player_card_get(pl2, fix->clid, PLAYER_VALUE_CARD_YELLOW))); */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* /\** Return some extra data depending on the unit type. *\/ */
|
||||
/* gchar* */
|
||||
/* news_get_extra_data(const LiveGameUnit *unit, const Fixture *fix) */
|
||||
/* { */
|
||||
/* #ifdef DEBUG */
|
||||
/* printf("news_get_extra_data\n"); */
|
||||
/* #endif */
|
||||
|
||||
/* #ifdef DEBUG */
|
||||
/* printf("news_get_extra_data\n"); */
|
||||
/* #endif */
|
||||
|
||||
/* gchar buf[SMALL]; */
|
||||
|
||||
/* switch(unit->event.type) */
|
||||
/* { */
|
||||
/* default: */
|
||||
/* return NULL; */
|
||||
/* break; */
|
||||
/* case LIVE_GAME_EVENT_STRUCTURE_CHANGE: */
|
||||
/* sprintf(buf, "%d", */
|
||||
/* fix->teams[unit->event.team]->structure); */
|
||||
/* break; */
|
||||
/* case LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_DEFEND: */
|
||||
/* strcpy(buf, _("ALL OUT DEFEND")); */
|
||||
/* break; */
|
||||
/* case LIVE_GAME_EVENT_STYLE_CHANGE_DEFEND: */
|
||||
/* strcpy(buf, _("DEFEND")); */
|
||||
/* break; */
|
||||
/* case LIVE_GAME_EVENT_STYLE_CHANGE_BALANCED: */
|
||||
/* strcpy(buf, _("BALANCED")); */
|
||||
/* break; */
|
||||
/* case LIVE_GAME_EVENT_STYLE_CHANGE_ATTACK: */
|
||||
/* strcpy(buf, _("ATTACK")); */
|
||||
/* break; */
|
||||
/* case LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_ATTACK: */
|
||||
/* strcpy(buf, _("ALL OUT ATTACK")); */
|
||||
/* break; */
|
||||
/* case LIVE_GAME_EVENT_BOOST_CHANGE_ANTI: */
|
||||
/* strcpy(buf, _("ANTI")); */
|
||||
/* break; */
|
||||
/* case LIVE_GAME_EVENT_BOOST_CHANGE_OFF: */
|
||||
/* strcpy(buf, _("OFF")); */
|
||||
/* break; */
|
||||
/* case LIVE_GAME_EVENT_BOOST_CHANGE_ON: */
|
||||
/* strcpy(buf, _("ON")); */
|
||||
/* break; */
|
||||
/* } */
|
||||
|
||||
/* return g_strdup(buf); */
|
||||
/* } */
|
||||
|
||||
/* /\** Allocate memory for the token array and fill some tokens */
|
||||
/* at the beginning of the live game that don't change later. *\/ */
|
||||
/* void */
|
||||
/* news_initialize(const Fixture *fix) */
|
||||
/* { */
|
||||
/* #ifdef DEBUG */
|
||||
/* printf("news_initialize\n"); */
|
||||
/* #endif */
|
||||
|
||||
/* gchar buf[SMALL]; */
|
||||
|
||||
/* token_rep[0] = g_ptr_array_new(); */
|
||||
/* token_rep[1] = g_ptr_array_new(); */
|
||||
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_team_home", &tokens), */
|
||||
/* g_strdup(fix->teams[0]->name)); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_team_away", &tokens), */
|
||||
/* g_strdup(fix->teams[1]->name)); */
|
||||
|
||||
/* if(fix->teams[0]->clid < ID_CUP_START) */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_team_layer0", &tokens), */
|
||||
/* misc_int_to_char(league_from_clid(fix->teams[0]->clid)->layer)); */
|
||||
/* if(fix->teams[1]->clid < ID_CUP_START) */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_team_layer1", &tokens), */
|
||||
/* misc_int_to_char(league_from_clid(fix->teams[1]->clid)->layer)); */
|
||||
|
||||
/* if(fix->teams[0]->clid < ID_CUP_START && */
|
||||
/* fix->teams[1]->clid < ID_CUP_START) */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_team_layerdiff", &tokens), */
|
||||
/* misc_int_to_char(league_from_clid(fix->teams[0]->clid)->layer - */
|
||||
/* league_from_clid(fix->teams[1]->clid)->layer)); */
|
||||
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_league_cup_name", &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); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_cup_round_name", &tokens), */
|
||||
/* g_strdup(buf)); */
|
||||
/* } */
|
||||
|
||||
/* misc_print_grouped_int(fix->attendance, buf); */
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_attendance", &tokens), */
|
||||
/* g_strdup(buf)); */
|
||||
|
||||
/* misc_token_add(token_rep, */
|
||||
/* option_int("string_token_yellow_limit", &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 */
|
||||
/* news_free_tokens(void) */
|
||||
/* { */
|
||||
/* #ifdef DEBUG */
|
||||
/* printf("news_free_tokens\n"); */
|
||||
/* #endif */
|
||||
|
||||
/* gint i; */
|
||||
|
||||
/* for(i=token_rep[0]->len - 1;i >= 0; i--) */
|
||||
/* { */
|
||||
/* g_free(g_ptr_array_index(token_rep[0], i)); */
|
||||
/* g_free(g_ptr_array_index(token_rep[1], i)); */
|
||||
/* } */
|
||||
|
||||
/* g_ptr_array_free(token_rep[0], TRUE); */
|
||||
/* g_ptr_array_free(token_rep[1], TRUE); */
|
||||
/* } */
|
||||
|
||||
/** Load the appropriate news file by evaluating
|
||||
the language option. */
|
||||
void
|
||||
news_load_news_file_from_option(void)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("news_load_news_file_from_option\n");
|
||||
#endif
|
||||
|
||||
gchar buf[SMALL], news_file[SMALL];
|
||||
|
||||
language_get_code(buf);
|
||||
|
||||
sprintf(news_file, "news_%s.xml", buf);
|
||||
|
||||
news_load_news_file(news_file, FALSE);
|
||||
}
|
||||
|
||||
/** Load the news file given. Abort if not found and abort=TRUE,
|
||||
load default english file otherwise. */
|
||||
void
|
||||
news_load_news_file(const gchar *news_file, gboolean abort)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("news_load_news_file\n");
|
||||
#endif
|
||||
|
||||
gchar *file_name = NULL;
|
||||
|
||||
if(g_file_test(news_file, G_FILE_TEST_EXISTS))
|
||||
{
|
||||
xml_news_read(news_file);
|
||||
return;
|
||||
}
|
||||
|
||||
file_name = file_find_support_file(news_file, FALSE);
|
||||
|
||||
if(file_name != NULL)
|
||||
{
|
||||
xml_news_read(file_name);
|
||||
g_free(file_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(abort)
|
||||
main_exit_program(EXIT_FILE_NOT_FOUND,
|
||||
"news_load_news_file: file %s not found \n",
|
||||
file_name);
|
||||
else
|
||||
news_load_news_file("news_en.xml", TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/* /\** Load a file with tokens for news testing purposes. *\/ */
|
||||
/* void */
|
||||
/* news_test_load_token_file(const gchar *token_file) */
|
||||
/* { */
|
||||
/* #ifdef DEBUG */
|
||||
/* printf("news_test_load_token_file\n"); */
|
||||
/* #endif */
|
||||
|
||||
/* gchar token_name[SMALL], token_value[SMALL]; */
|
||||
/* FILE *fil = NULL; */
|
||||
|
||||
/* file_my_fopen(token_file, "r", &fil, TRUE); */
|
||||
|
||||
/* token_rep[0] = g_ptr_array_new(); */
|
||||
/* token_rep[1] = g_ptr_array_new(); */
|
||||
|
||||
/* while(file_get_next_opt_line(fil, token_name, token_value)) */
|
||||
/* { */
|
||||
/* g_ptr_array_add(token_rep[0], (gpointer)g_strdup(token_name)); */
|
||||
/* g_ptr_array_add(token_rep[1], (gpointer)g_strdup(token_value)); */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* /\** Test a live game news file. */
|
||||
/* @param news_file the news file to test. */
|
||||
/* @param token_file the file containing the token values to use. */
|
||||
/* @param event_name the event to test (or 'all' to test all events). */
|
||||
/* @param number_of_passes how many commentaries to generate. *\/ */
|
||||
/* void */
|
||||
/* news_test(const gchar *news_file, const gchar* token_file, */
|
||||
/* const gchar *event_name, gint number_of_passes) */
|
||||
/* { */
|
||||
/* #ifdef DEBUG */
|
||||
/* printf("news_test\n"); */
|
||||
/* #endif */
|
||||
|
||||
/* gint i, j; */
|
||||
/* LiveGame dummy; */
|
||||
|
||||
/* news_load_news_file(news_file, TRUE); */
|
||||
|
||||
/* news_test_load_token_file(token_file); */
|
||||
|
||||
/* dummy.units = g_array_new(FALSE, FALSE, sizeof(gint)); */
|
||||
/* statp = (gpointer)&dummy; */
|
||||
|
||||
/* if(event_name == NULL) */
|
||||
/* for(i=0;i<LIVE_GAME_EVENT_END;i++) */
|
||||
/* for(j=0;j<number_of_passes;j++) */
|
||||
/* news_generate(NULL, NULL, NULL, i); */
|
||||
/* else */
|
||||
/* for(i=0;i<number_of_passes;i++) */
|
||||
/* news_generate(NULL, NULL, event_name, -1); */
|
||||
|
||||
/* g_array_free(dummy.units, TRUE); */
|
||||
/* } */
|
82
src/news.h
Normal file
82
src/news.h
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
news.h
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef NEWS_H
|
||||
#define NEWS_H
|
||||
|
||||
#include "bygfoot.h"
|
||||
#include "news_struct.h"
|
||||
|
||||
/* void */
|
||||
/* news_free_tokens(void); */
|
||||
|
||||
/* void */
|
||||
/* news_initialize(const Fixture *fix); */
|
||||
|
||||
/* gboolean */
|
||||
/* news_check_news(const LGNews *news, gchar *dest); */
|
||||
|
||||
/* gboolean */
|
||||
/* query_news_is_repetition(gint id); */
|
||||
|
||||
/* void */
|
||||
/* news_get_order(const GArray *commentaries, gint *order); */
|
||||
|
||||
/* void */
|
||||
/* news_set_basic_tokens(const LiveGameUnit *unit, const Fixture *fix);; */
|
||||
|
||||
/* void */
|
||||
/* news_set_player_tokens(const LiveGameUnit *unit, const Fixture *fix); */
|
||||
|
||||
/* void */
|
||||
/* news_set_team_tokens(const LiveGameUnit *unit, const Fixture *fix); */
|
||||
|
||||
/* void */
|
||||
/* news_set_stats_tokens(const LiveGameStats *stats); */
|
||||
|
||||
/* void */
|
||||
/* news_generate(const LiveGame *live_game, LiveGameUnit *unit, */
|
||||
/* const gchar *event_name, gint ev_type); */
|
||||
|
||||
/* gchar* */
|
||||
/* news_get_extra_data(const LiveGameUnit *unit, const Fixture *fix); */
|
||||
|
||||
void
|
||||
news_load_news_file_from_option(void);
|
||||
|
||||
void
|
||||
news_load_news_file(const gchar *news_file, gboolean abort);
|
||||
|
||||
/* void */
|
||||
/* news_test_load_token_file(const gchar *token_file); */
|
||||
|
||||
/* void */
|
||||
/* news_test(const gchar *news_file, const gchar* token_file, */
|
||||
/* const gchar *event_name, gint number_of_passes); */
|
||||
|
||||
/* gint */
|
||||
/* news_select(const GArray *commentaries, gchar *buf); */
|
||||
|
||||
#endif
|
70
src/news_struct.h
Normal file
70
src/news_struct.h
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
news_struct.h
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef NEWS_STRUCT_H
|
||||
#define NEWS_STRUCT_H
|
||||
|
||||
/** Enumeration of news article types. */
|
||||
enum NewsArticleTypes
|
||||
{
|
||||
NEWS_ARTICLE_TYPE_MATCH_LEAGUE = 0, /**< Article about a legue match. */
|
||||
NEWS_ARTICLE_TYPE_MATCH_NATIONAL_CUP, /**< Article about a national cup match. */
|
||||
NEWS_ARTICLE_TYPE_MATCH_INTERNATIONAL_CUP, /**< Article about an international cup match. */
|
||||
NEWS_ARTICLE_TYPE_FINANCES, /**< Article about user finances. */
|
||||
NEWS_ARTICLE_TYPE_STAR_PLAYER_TRANSFER, /**< Article about good players appearing on the transfer list. */
|
||||
NEWS_ARTICLE_TYPE_LEAGUE_CHAMPION, /**< Article about teams clinching the championship. */
|
||||
NEWS_ARTICLE_TYPE_CUP_QUALIFICATION, /**< Article about teams clinching cup berths. */
|
||||
NEWS_ARTICLE_TYPE_RELEGATION, /**< Article about teams getting relegated. */
|
||||
NEWS_ARTICLE_TYPE_END
|
||||
};
|
||||
|
||||
/** Structure containing a news title or subtitle. */
|
||||
typedef struct
|
||||
{
|
||||
gchar *text;
|
||||
/** Priority of the text (compared to
|
||||
the other ones for the same article type).
|
||||
The higher the priority the higher the
|
||||
probability that the text gets picked. */
|
||||
gint priority;
|
||||
/** An id to keep track of already used texts
|
||||
(so as not to use the same one too frequently). */
|
||||
gint id;
|
||||
} NewsText;
|
||||
|
||||
/** Structure describing a news paper article. */
|
||||
typedef struct
|
||||
{
|
||||
/** Possible article titles (possibly containing tokens). */
|
||||
GArray *titles;
|
||||
/** Possible article subtitles (possibly containing tokens). */
|
||||
GArray *subtitles;
|
||||
/** A condition (if not fulfilled, the article doesn't get
|
||||
shown). */
|
||||
gchar *condition;
|
||||
} NewsArticle;
|
||||
|
||||
#endif
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "bygfoot.h"
|
||||
#include "enums.h"
|
||||
#include "live_game_struct.h"
|
||||
#include "news_struct.h"
|
||||
#include "option_struct.h"
|
||||
|
||||
/**
|
||||
@ -58,6 +59,9 @@ OptionList tokens;
|
||||
/** The array containing the live game commentary strings. */
|
||||
GArray *lg_commentary[LIVE_GAME_EVENT_END];
|
||||
|
||||
/** The array containing the news article strings. */
|
||||
GArray *news[NEWS_ARTICLE_TYPE_END];
|
||||
|
||||
/** The array containing players to be transfered.
|
||||
@see TransferPlayer */
|
||||
GArray *transfer_list;
|
||||
|
@ -230,7 +230,7 @@ xml_lg_commentary_read_end_element (GMarkupParseContext *context,
|
||||
strcmp(element_name, TAG_EVENT_COMMENTARY) == 0)
|
||||
state = STATE_EVENT;
|
||||
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",
|
||||
g_warning("xml_lg_commentary_read_end_element: unknown tag: %s; I'm in state %d\n",
|
||||
element_name, state);
|
||||
}
|
||||
|
||||
|
279
src/xml_news.c
Normal file
279
src/xml_news.c
Normal file
@ -0,0 +1,279 @@
|
||||
/*
|
||||
xml_news.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 "free.h"
|
||||
#include "news.h"
|
||||
#include "misc.h"
|
||||
#include "variables.h"
|
||||
#include "xml_news.h"
|
||||
|
||||
#define TAG_NEWS "news"
|
||||
#define TAG_ARTICLE "news_article"
|
||||
#define TAG_ARTICLE_TYPE "type"
|
||||
#define TAG_ARTICLE_CONDITION "condition"
|
||||
#define TAG_ARTICLE_TITLE "title"
|
||||
#define TAG_ARTICLE_SUBTITLE "subtitle"
|
||||
|
||||
#define ATT_NAME_TEXT_PRIORITY "priority"
|
||||
|
||||
#define ARTICLE_TYPE_NAME_MATCH_LEAGUE "match_league"
|
||||
#define ARTICLE_TYPE_NAME_MATCH_NATIONAL_CUP "match_national_cup"
|
||||
#define ARTICLE_TYPE_NAME_MATCH_INTERNATIONAL_CUP "match_international_cup"
|
||||
#define ARTICLE_TYPE_NAME_FINANCES "finances"
|
||||
#define ARTICLE_TYPE_NAME_STAR_PLAYER_TRANSFER "star_player_transfer"
|
||||
#define ARTICLE_TYPE_NAME_LEAGUE_CHAMPION "league_champion"
|
||||
#define ARTICLE_TYPE_NAME_CUP_QUALIFICATION "cup_qualification"
|
||||
#define ARTICLE_TYPE_NAME_RELEGATION "relegation"
|
||||
|
||||
enum XmlNewsStates
|
||||
{
|
||||
STATE_NEWS = 0,
|
||||
STATE_ARTICLE,
|
||||
STATE_ARTICLE_TYPE,
|
||||
STATE_ARTICLE_CONDITION,
|
||||
STATE_ARTICLE_TITLE,
|
||||
STATE_ARTICLE_SUBTITLE,
|
||||
STATE_END
|
||||
};
|
||||
|
||||
gint state, article_idx, priority;
|
||||
gchar *condition;
|
||||
NewsArticle new_article;
|
||||
NewsText new_title, new_subtitle;
|
||||
|
||||
/** Return the appropriate enum integer going with the type string. */
|
||||
gint
|
||||
xml_news_article_type_to_int(const gchar *type_string)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("xml_news_type_to_int\n");
|
||||
#endif
|
||||
|
||||
gint return_value = -1;
|
||||
|
||||
if(strcmp(type_string, ARTICLE_TYPE_NAME_MATCH_LEAGUE) == 0)
|
||||
return_value = NEWS_ARTICLE_TYPE_MATCH_LEAGUE;
|
||||
else if(strcmp(type_string, ARTICLE_TYPE_NAME_MATCH_NATIONAL_CUP) == 0)
|
||||
return_value = NEWS_ARTICLE_TYPE_MATCH_NATIONAL_CUP;
|
||||
else if(strcmp(type_string, ARTICLE_TYPE_NAME_MATCH_INTERNATIONAL_CUP) == 0)
|
||||
return_value = NEWS_ARTICLE_TYPE_MATCH_INTERNATIONAL_CUP;
|
||||
else if(strcmp(type_string, ARTICLE_TYPE_NAME_FINANCES) == 0)
|
||||
return_value = NEWS_ARTICLE_TYPE_FINANCES;
|
||||
else if(strcmp(type_string, ARTICLE_TYPE_NAME_STAR_PLAYER_TRANSFER) == 0)
|
||||
return_value = NEWS_ARTICLE_TYPE_STAR_PLAYER_TRANSFER;
|
||||
else if(strcmp(type_string, ARTICLE_TYPE_NAME_LEAGUE_CHAMPION) == 0)
|
||||
return_value = NEWS_ARTICLE_TYPE_LEAGUE_CHAMPION;
|
||||
else if(strcmp(type_string, ARTICLE_TYPE_NAME_CUP_QUALIFICATION) == 0)
|
||||
return_value = NEWS_ARTICLE_TYPE_CUP_QUALIFICATION;
|
||||
else if(strcmp(type_string, ARTICLE_TYPE_NAME_RELEGATION) == 0)
|
||||
return_value = NEWS_ARTICLE_TYPE_RELEGATION;
|
||||
else
|
||||
g_warning("xml_news_type_to_int: unknown type name %s \n",
|
||||
type_string);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The function called by the parser when an opening tag is read.
|
||||
* The state variable is changed in this function and
|
||||
* sometimes memory allocated for the information that's going to be read.
|
||||
* @see The GLib manual (Simple XML parser).
|
||||
*/
|
||||
void
|
||||
xml_news_read_start_element (GMarkupParseContext *context,
|
||||
const gchar *element_name,
|
||||
const gchar **attribute_names,
|
||||
const gchar **attribute_values,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("xml_news_read_start_element\n");
|
||||
#endif
|
||||
|
||||
if(strcmp(element_name, TAG_NEWS) == 0)
|
||||
state = STATE_NEWS;
|
||||
else if(strcmp(element_name, TAG_ARTICLE) == 0)
|
||||
{
|
||||
state = STATE_ARTICLE;
|
||||
new_article.titles = g_array_new(FALSE, FALSE, sizeof(NewsText));
|
||||
new_article.subtitles = g_array_new(FALSE, FALSE, sizeof(NewsText));
|
||||
}
|
||||
else if(strcmp(element_name, TAG_ARTICLE_TYPE) == 0)
|
||||
state = STATE_ARTICLE_TYPE;
|
||||
else if(strcmp(element_name, TAG_ARTICLE_CONDITION) == 0)
|
||||
state = STATE_ARTICLE_CONDITION;
|
||||
else if(strcmp(element_name, TAG_ARTICLE_TITLE) == 0)
|
||||
{
|
||||
state = STATE_ARTICLE_TITLE;
|
||||
new_title.id = news_title_id_new;
|
||||
if(attribute_names[0] != NULL && strcmp(attribute_names[0], ATT_NAME_TEXT_PRIORITY) == 0)
|
||||
new_title.priority = (gint)g_ascii_strtod(attribute_values[0], NULL);
|
||||
else
|
||||
new_title.priority = 1;
|
||||
}
|
||||
else if(strcmp(element_name, TAG_ARTICLE_SUBTITLE) == 0)
|
||||
{
|
||||
state = STATE_ARTICLE_SUBTITLE;
|
||||
new_subtitle.id = news_subtitle_id_new;
|
||||
if(attribute_names[0] != NULL && strcmp(attribute_names[0], ATT_NAME_TEXT_PRIORITY) == 0)
|
||||
new_subtitle.priority = (gint)g_ascii_strtod(attribute_values[0], NULL);
|
||||
else
|
||||
new_subtitle.priority = 1;
|
||||
}
|
||||
else
|
||||
g_warning("xml_news_read_start_element: unknown tag: %s; I'm in state %d\n",
|
||||
element_name, state);
|
||||
}
|
||||
|
||||
/**
|
||||
* The function called by the parser when a closing tag is read.
|
||||
* The state variable is changed in this function.
|
||||
* @see The GLib manual (Simple XML parser).
|
||||
*/
|
||||
void
|
||||
xml_news_read_end_element (GMarkupParseContext *context,
|
||||
const gchar *element_name,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("xml_news_read_end_element\n");
|
||||
#endif
|
||||
|
||||
if(strcmp(element_name, TAG_ARTICLE) == 0)
|
||||
{
|
||||
state = STATE_NEWS;
|
||||
g_array_append_val(news[article_idx], new_article);
|
||||
}
|
||||
else if(strcmp(element_name, TAG_ARTICLE_TYPE) == 0 ||
|
||||
strcmp(element_name, TAG_ARTICLE_CONDITION) == 0 ||
|
||||
strcmp(element_name, TAG_ARTICLE_TITLE) == 0 ||
|
||||
strcmp(element_name, TAG_ARTICLE_SUBTITLE) == 0)
|
||||
state = STATE_ARTICLE;
|
||||
else if(strcmp(element_name, TAG_NEWS) != 0)
|
||||
g_warning("xml_news_read_end_element: unknown tag: %s; I'm in state %d\n",
|
||||
element_name, state);
|
||||
}
|
||||
|
||||
/**
|
||||
* The function called by the parser when the text between tags is read.
|
||||
* This function is responsible for filling in the variables (e.g. team names)
|
||||
* when a file gets loaded.
|
||||
* @see The GLib manual (Simple XML parser).
|
||||
*/
|
||||
void
|
||||
xml_news_read_text (GMarkupParseContext *context,
|
||||
const gchar *text,
|
||||
gsize text_len,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("xml_news_read_text\n");
|
||||
#endif
|
||||
|
||||
gchar buf[text_len + 1];
|
||||
|
||||
strncpy(buf, text, text_len);
|
||||
buf[text_len] = '\0';
|
||||
|
||||
if(state == STATE_ARTICLE_TYPE)
|
||||
article_idx = xml_news_article_type_to_int(buf);
|
||||
else if(state == STATE_ARTICLE_CONDITION)
|
||||
new_article.condition = g_strdup(buf);
|
||||
else if(state == STATE_ARTICLE_TITLE)
|
||||
{
|
||||
new_title.text = g_strdup(buf);
|
||||
g_array_append_val(new_article.titles, new_title);
|
||||
}
|
||||
else if(state == STATE_ARTICLE_SUBTITLE)
|
||||
{
|
||||
new_subtitle.text = g_strdup(buf);
|
||||
g_array_append_val(new_article.subtitles, new_subtitle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function reading an XML file specifying a country.
|
||||
* The variable #country gets freed and overwritten afterwards.
|
||||
* @param news_file Name of the xml file (e.g. 'news_en.xml')
|
||||
* to be read. Full path is not necessary, if the file is located in
|
||||
* one of the suppport directories; neither are the prefix 'news_'
|
||||
* or the suffix '.xml'.
|
||||
*/
|
||||
void
|
||||
xml_news_read(const gchar *news_file)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("xml_news_read\n");
|
||||
#endif
|
||||
|
||||
GMarkupParser parser = {xml_news_read_start_element,
|
||||
xml_news_read_end_element,
|
||||
xml_news_read_text, NULL, NULL};
|
||||
GMarkupParseContext *context;
|
||||
gchar *file_contents;
|
||||
gsize length;
|
||||
GError *error = NULL;
|
||||
|
||||
context =
|
||||
g_markup_parse_context_new(&parser, 0, NULL, NULL);
|
||||
|
||||
if(!g_file_get_contents(news_file, &file_contents, &length, &error))
|
||||
{
|
||||
g_warning("xml_news_read: error reading file %s\n", news_file);
|
||||
if(g_str_has_suffix(news_file, "news_en.xml"))
|
||||
misc_print_error(&error, TRUE);
|
||||
else
|
||||
{
|
||||
misc_print_error(&error, FALSE);
|
||||
news_load_news_file("news_en.xml", TRUE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
free_news(TRUE);
|
||||
|
||||
if(g_markup_parse_context_parse(context, file_contents, length, &error))
|
||||
{
|
||||
g_markup_parse_context_end_parse(context, NULL);
|
||||
g_markup_parse_context_free(context);
|
||||
g_free(file_contents);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning("xml_news_read: error parsing file %s\n", news_file);
|
||||
if(g_str_has_suffix(news_file, "news_en.xml"))
|
||||
misc_print_error(&error, TRUE);
|
||||
else
|
||||
{
|
||||
misc_print_error(&error, FALSE);
|
||||
news_load_news_file("news_en.xml", TRUE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
59
src/xml_news.h
Normal file
59
src/xml_news.h
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
xml_news.h
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef XML_NEWS_H
|
||||
#define XML_NEWS_H
|
||||
|
||||
#include "bygfoot.h"
|
||||
|
||||
void
|
||||
xml_news_read(const gchar *news_file);
|
||||
|
||||
void
|
||||
xml_news_read_text (GMarkupParseContext *context,
|
||||
const gchar *text,
|
||||
gsize text_len,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
|
||||
void
|
||||
xml_news_read_end_element (GMarkupParseContext *context,
|
||||
const gchar *element_name,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
|
||||
void
|
||||
xml_news_read_start_element (GMarkupParseContext *context,
|
||||
const gchar *element_name,
|
||||
const gchar **attribute_names,
|
||||
const gchar **attribute_values,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
|
||||
gint
|
||||
xml_news_article_type_to_int(const gchar *type_string);
|
||||
|
||||
#endif
|
||||
|
@ -1,9 +1,15 @@
|
||||
# this file contains info that gets displayed
|
||||
# in the help window
|
||||
|
||||
string_contrib_title Author
|
||||
string_contrib_entry Győző Both
|
||||
string_contrib_entry Mark Lawrenz (mark@bygfoot.com)
|
||||
string_contrib_title Authors
|
||||
string_contrib_entry Ronald Sterckx (gunnar@bygfoot.com)
|
||||
string_contrib_entry Győző Both (gyboth@bygfoot.com)
|
||||
|
||||
string_contrib_title Definitions team
|
||||
string_contrib_entry Mihai Floran (mihai@bygfoot.com)
|
||||
string_contrib_entry Christopher Hunter (chris@bygfoot.com)
|
||||
string_contrib_entry Ivan Ramirez (ircarrascal@bygfoot.com)
|
||||
string_contrib_entry Tommasi (tommasi@bygfoot.com)
|
||||
|
||||
string_contrib_title Artwork
|
||||
string_contrib_entry Mark D. Symonds, Marcelo Garrone
|
||||
@ -14,24 +20,6 @@ string_contrib_entry Simon Binns, Carlos Garces
|
||||
string_contrib_title Patches and ideas
|
||||
string_contrib_entry Mark Calderbank, Michal Rudolf, Mark Lawrenz
|
||||
|
||||
string_contrib_title Country definitions
|
||||
string_contrib_entry Győző Both (Australia, Brazil, Italy, Scotland, WC2006, Euro 2008)
|
||||
string_contrib_entry Mark Calderbank (Bulgaria, England, Ireland, Spain, Victoria, Wales)
|
||||
string_contrib_entry Tobe & Arne Deprez (Belgium)
|
||||
string_contrib_entry Daniel Nylander (Sweden)
|
||||
string_contrib_entry Theodore Dimitriadis (Greece)
|
||||
string_contrib_entry Pechorin (Serbia & Montenegro)
|
||||
string_contrib_entry Koen Pijnenburg (Netherlands)
|
||||
string_contrib_entry Arnaud Le Rouzic (France)
|
||||
string_contrib_entry Michal Rudolf (Poland)
|
||||
string_contrib_entry Cristian Spoiala, Mihai Floran (Romania)
|
||||
string_contrib_entry Sebastian Vöcking (Germany)
|
||||
string_contrib_entry Christopher Hunter (USA, Argentina, Mexico, Japan)
|
||||
string_contrib_entry Onur Aydin (Turkey)
|
||||
string_contrib_entry Mark Lawrenz (Germany)
|
||||
string_contrib_entry Pavel Pulpan (Czech Republic)
|
||||
string_contrib_entry Mihai Floran (Hungary, Russia, Portugal, Austria, Ukraine, Moldova, Romania)
|
||||
|
||||
string_contrib_title Translations
|
||||
string_contrib_entry Benyuan Liu (Chinese)
|
||||
string_contrib_entry Alexandre Beraud, Arnaud Le Rouzic, Alexandre Coutherez, Forjan Frédéric, Marc Schneider (French)
|
||||
@ -39,7 +27,6 @@ string_contrib_entry Győző Both, Michael Trent, Mark Lawrenz (German)
|
||||
string_contrib_entry Tobe & Arne Deprez (Dutch)
|
||||
string_contrib_entry Marcelo Garrone, Carlos Garces (Spanish)
|
||||
string_contrib_entry Kristian Poul Herkild (Danish)
|
||||
string_contrib_entry Benyuan Liu (Chinese)
|
||||
string_contrib_entry Daniel Nylander (Swedish)
|
||||
string_contrib_entry Rostislav "zbrox" Raykov (Bulgarian)
|
||||
string_contrib_entry Michal Rudolf (Polish)
|
||||
@ -50,4 +37,4 @@ string_contrib_title Pictures
|
||||
string_contrib_entry Michael Dücker
|
||||
|
||||
|
||||
string_contrib_title Forgotten anyone? Write me! (mark@bygfoot.com)
|
||||
string_contrib_title Forgotten anyone? Write us!
|
||||
|
21
support_files/news/news_de.xml
Normal file
21
support_files/news/news_de.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<news>
|
||||
|
||||
<news_article>
|
||||
<type>match_league</type>
|
||||
<condition>cond</condition>
|
||||
<title>title1</title>
|
||||
<subtitle>subtitle1</subtitle>
|
||||
<title priority="5">title2</title>
|
||||
<subtitle priority="5">subtitle2</subtitle>
|
||||
</news_article>
|
||||
|
||||
<news_article>
|
||||
<type>match_national_cup</type>
|
||||
<condition>condn</condition>
|
||||
<title>title1n</title>
|
||||
<subtitle>subtitle1n</subtitle>
|
||||
<title priority="5">title2n</title>
|
||||
<subtitle priority="5">subtitle2n</subtitle>
|
||||
</news_article>
|
||||
|
||||
</news>
|
Loading…
Reference in New Issue
Block a user