1
1
mirror of https://github.com/tstellar/bygfoot.git synced 2024-12-16 10:21:15 +01:00

Newspaper progressing.

This commit is contained in:
gyboth 2008-11-28 14:09:08 +00:00
parent 4df6303608
commit b82886fbec
17 changed files with 499 additions and 714 deletions

View File

@ -53,6 +53,7 @@ free_memory(void)
free_live_game(&live_game_temp);
free_lg_commentary(FALSE);
free_news(FALSE);
free_newspaper(FALSE);
free_support_dirs();
free_jobs(FALSE);
}
@ -709,7 +710,7 @@ free_lg_commentary(gboolean reset)
lg_commentary[i] = g_array_new(FALSE, FALSE, sizeof(LGCommentary));
}
/** Free the list with live game commentary text. */
/** Free the news variables. */
void
free_news(gboolean reset)
{
@ -745,6 +746,31 @@ free_news(gboolean reset)
news[i] = g_array_new(FALSE, FALSE, sizeof(NewsArticle));
}
void
free_newspaper(gboolean reset)
{
gint i;
for(i = 0; i < newspaper.names->len; i++)
g_free(g_ptr_array_index(newspaper.names, i));
g_ptr_array_free(newspaper.names, TRUE);
for(i = 0; i < newspaper.articles->len; i++)
{
g_free(g_array_index(newspaper.articles, NewsPaperArticle, i).title);
g_free(g_array_index(newspaper.articles, NewsPaperArticle, i).subtitle);
}
g_array_free(newspaper.articles, TRUE);
if(reset)
{
newspaper.names = g_ptr_array_new();
newspaper.articles = g_array_new(FALSE, FALSE, sizeof(NewsPaperArticle));
}
}
/**
Free a GPtrArray containing strings.
@param array The array to be freed.

View File

@ -149,4 +149,7 @@ free_jobs(gboolean reset);
void
free_news(gboolean reset);
void
free_newspaper(gboolean reset);
#endif

View File

@ -167,25 +167,13 @@ lg_commentary_check_commentary(const LGCommentary *commentary, gchar *dest)
printf("lg_commentary_check_commentary\n");
#endif
gchar buf[SMALL];
if(strlen(commentary->text) == 0 ||
(commentary->condition != NULL &&
!misc_parse_condition(commentary->condition, token_rep)) ||
(repetition == FALSE && query_lg_commentary_is_repetition(commentary->id)))
return FALSE;
strcpy(dest, commentary->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);
return misc_string_replace_all_tokens(token_rep, commentary->text, dest);
}
/** Check whether a commentary with given id has been used in the last

View File

@ -239,6 +239,9 @@ main_init_variables(void)
for(i=0;i<NEWS_ARTICLE_TYPE_END;i++)
news[i] = g_array_new(FALSE, FALSE, sizeof(NewsArticle));
newspaper.articles = g_array_new(FALSE, FALSE, sizeof(NewsPaperArticle));
newspaper.names = g_ptr_array_new();
file_load_conf_files();
xml_strategy_load_strategies();

View File

@ -728,3 +728,24 @@ misc_token_remove(GPtrArray **token_rep, gint idx)
g_ptr_array_remove_index_fast(token_rep[1], i);
}
}
/** Try to replace all tokens in the given text and write the result
into the dest variable. */
gboolean
misc_string_replace_all_tokens(GPtrArray **token_rep,
const gchar *text_tokens, gchar *dest)
{
gchar buf[SMALL];
strcpy(dest, text_tokens);
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);
}

View File

@ -121,4 +121,8 @@ void
misc_string_replace_parenthesised(gchar *string, const gchar *paren,
const gchar *replacement);
gboolean
misc_string_replace_all_tokens(GPtrArray **token_rep,
const gchar *text_tokens, gchar *dest);
#endif

View File

@ -24,146 +24,153 @@
*/
#include <locale.h>
#include <math.h>
#include "cup.h"
#include "file.h"
#include "fixture.h"
#include "language.h"
#include "league.h"
#include "main.h"
#include "maths.h"
#include "misc.h"
#include "news.h"
#include "option.h"
#include "team.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 */
/** Generate news for a user live game or a CPU fixture. */
void
news_generate_match(const LiveGame *live_game, const Fixture *fix)
{
#ifdef DEBUG
printf("news_generate_match\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); */
/* } */
gchar title[SMALL], subtitle[SMALL];
gint title_id, subtitle_id;
NewsPaperArticle new_article;
/* 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]; */
token_rep[0] = g_ptr_array_new();
token_rep[1] = g_ptr_array_new();
/* news_idx = news_select(commentaries, buf); */
news_set_match_tokens(live_game, fix);
/* if(news_idx == -1) */
/* g_warning("news_generate: didn't find fitting news for unit type %d \n", */
/* event_type); */
news_select(news[NEWS_ARTICLE_TYPE_MATCH], title, subtitle,
&title_id, &subtitle_id);
/* 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); */
/* } */
if(title_id != -1 && subtitle_id != -1)
{
new_article.week_number = week;
new_article.week_round_number = week_round;
new_article.title = g_strdup(title);
new_article.subtitle = g_strdup(subtitle);
new_article.title_id = title_id;
new_article.subtitle_id = subtitle_id;
// printf("%s / %s -- %d %d\n", title, subtitle, title_id, subtitle_id);
g_array_append_val(newspaper.articles, new_article);
}
/* /\** 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 */
news_free_tokens();
}
/* gint i, order[commentaries->len]; */
/** Select a news from the array depending on the tokens
available and write the texts and ids into the variables. */
void
news_select(const GArray *news_array, gchar *title, gchar *subtitle,
gint *title_id, gint *subtitle_id)
{
#ifdef DEBUG
printf("news_select\n");
#endif
/* news_get_order(commentaries, order); */
gint i;
const NewsArticle *article;
/* repetition = FALSE; */
*title_id = *subtitle_id = -1;
/* for(i=0;i<commentaries->len;i++) */
/* if(news_check_news(&g_array_index(commentaries, LGNews, order[i]), buf)) */
/* break; */
for(i=0;i<news_array->len;i++)
if(news_check_article_condition(&g_array_index(news_array, NewsArticle, i)))
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 == news_array->len)
return;
/* if(i == commentaries->len) */
/* { */
/* strcpy(buf, "FIXME!"); */
/* return -1; */
/* } */
article = &g_array_index(news_array, NewsArticle, i);
/* return order[i]; */
/* } */
gint order_titles[article->titles->len],
order_subtitles[article->subtitles->len];
news_titles_get_order(article->titles, order_titles);
news_titles_get_order(article->subtitles, order_subtitles);
/* /\** 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 */
*title_id = news_get_title(article->titles, title, order_titles, TRUE, FALSE);
if(*title_id == -1)
*title_id = news_get_title(article->titles, title, order_titles, TRUE, TRUE);
/* gchar buf[SMALL]; */
*subtitle_id = news_get_title(article->subtitles, subtitle, order_subtitles, FALSE, FALSE);
if(*subtitle_id == -1)
*subtitle_id = news_get_title(article->subtitles, subtitle, order_subtitles, FALSE, TRUE);
/* 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; */
return;
}
/** Try to find a news article title with valid tokens. */
gint
news_get_title(const GArray *titles, gchar *title, gint *order,
gboolean is_title, gboolean ignore_repetition)
{
gint i;
gint result;
for(i = 0; i < titles->len; i++)
{
if(misc_string_replace_all_tokens(token_rep, g_array_index(titles, NewsText, order[i]).text, title))
{
result = g_array_index(titles, NewsText, order[i]).id;
if(ignore_repetition || !news_check_for_repetition(result, is_title))
return result;
else
continue;
}
}
return -1;
}
/** Check whether a news article text has occurred in the paper recently. */
gboolean
news_check_for_repetition(gint id, gboolean is_title)
{
gint i;
gint end;
end = (newspaper.articles->len < const_int("int_news_repetition_check_number")) ?
0 : newspaper.articles->len - const_int("int_news_repetition_check_number");
for(i = newspaper.articles->len - 1; i >= end; i--)
if((is_title && g_array_index(newspaper.articles, NewsPaperArticle, i).title_id == id) ||
(!is_title && g_array_index(newspaper.articles, NewsPaperArticle, i).subtitle_id == id))
return TRUE;
return FALSE;
}
/** Check whether the news conditions are fulfilled and whether
we can replace all tokens in the news. */
gboolean
news_check_article_condition(const NewsArticle *news_article)
{
#ifdef DEBUG
printf("news_check_article_condition\n");
#endif
if(!misc_parse_condition(news_article->condition, token_rep))/* || */
/* (repetition == FALSE && query_news_is_repetition(news_article->id))) */
return FALSE;
/* strcpy(dest, news->text); */
@ -176,10 +183,11 @@ gboolean repetition;
/* while(strcmp(buf, dest) != 0); */
/* return (g_strrstr(dest, "_") == NULL); */
/* } */
return TRUE;
}
/* /\** Check whether a news with given id has been used in the last */
/* few commentaries. Return TRUE if so and FALSE otherwise. *\/ */
/** 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) */
/* { */
@ -198,442 +206,197 @@ gboolean repetition;
/* 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 */
/** 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_titles_get_order(const GArray *titles, gint *order)
{
#ifdef DEBUG
printf("news_titles_get_order\n");
#endif
/* gint i, j, order_idx = 0; */
/* gint priority_sum = 0, bounds[commentaries->len + 1]; */
gint i, j, order_idx = 0;
gint priority_sum = 0, bounds[titles->len + 1];
/* bounds[0] = 0; */
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; */
/* } */
for(i=0;i<titles->len;i++)
{
priority_sum += g_array_index(titles, NewsText, i).priority;
bounds[i + 1] = priority_sum;
order[i] = -1;
}
/* gint permutation[priority_sum]; */
gint permutation[priority_sum];
/* math_generate_permutation(permutation, 1, priority_sum); */
math_generate_permutation(permutation, 1, priority_sum);
/* for(i=0;i<priority_sum;i++) */
/* { */
/* if(order_idx == commentaries->len) */
/* break; */
for(i=0;i<priority_sum;i++)
{
if(order_idx == titles->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++; */
/* } */
for(j=0;j<titles->len;j++)
if(bounds[j] < permutation[i] && permutation[i] <= bounds[j + 1])
{
if(!query_integer_is_in_array(j, order, titles->len))
{
order[order_idx] = j;
order_idx++;
}
/* break; */
/* } */
/* } */
/* } */
break;
}
}
}
/* /\** Fill the stats tokens. *\/ */
/* void */
/* news_set_stats_tokens(const LiveGameStats *stats) */
/* { */
/* #ifdef DEBUG */
/* printf("news_set_stats_tokens\n"); */
/* #endif */
/** Set match-related tokens for the news. */
void
news_set_match_tokens(const LiveGame *live_game, const Fixture *fix_)
{
#ifdef DEBUG
printf("news_set_match_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])); */
gchar buf[SMALL];
const Fixture *fix;
gint avskill0, avskill1;
const Cup *cup;
const CupRound *cupround;
/* 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])); */
fix = (live_game == NULL) ? fix_ : live_game->fix;
/* 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])); */
/* } */
token_rep[0] = g_ptr_array_new();
token_rep[1] = g_ptr_array_new();
/* /\** 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 */
avskill0 = (gint)rint(team_get_average_skill(fix->teams[0], TRUE));
avskill1 = (gint)rint(team_get_average_skill(fix->teams[1], TRUE));
/* 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)); */
fixture_result_to_buf(fix, buf, FALSE);
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)); */
misc_token_add(token_rep,
option_int("string_token_goals0", &tokens),
misc_int_to_char(fix->result[0][0]));
misc_token_add(token_rep,
option_int("string_token_goals1", &tokens),
misc_int_to_char(fix->result[1][0]));
misc_token_add(token_rep,
option_int("string_token_goal_diff", &tokens),
misc_int_to_char(ABS(fix->result[0][0] - fix->result[1][0])));
/* 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)); */
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(query_fixture_is_draw(fix)) */
/* tmp_int = 120 - current_min; */
/* else */
/* tmp_int = 90 - current_min; */
if(fix->result[0][0] != fix->result[1][0])
{
misc_token_add(token_rep,
option_int("string_token_team_losing", &tokens),
g_strdup(fix->teams[(fix->result[0][0] > fix->result[1][0])]->name));
misc_token_add(token_rep,
option_int("string_token_team_winning", &tokens),
g_strdup(fix->teams[(fix->result[0][0] < fix->result[1][0])]->name));
misc_token_add(token_rep,
option_int("string_token_team_losingn", &tokens),
misc_int_to_char((fix->result[0][0] > fix->result[1][0])));
misc_token_add(token_rep,
option_int("string_token_team_winningn", &tokens),
misc_int_to_char((fix->result[0][0] < fix->result[1][0])));
}
/* 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)
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)); */
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))); */
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)); */
/* } */
if(fix->clid >= ID_CUP_START)
{
cup = cup_from_clid(fix->clid);
cupround = &g_array_index(cup->rounds, CupRound, fix->round);
/* 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_cup", &tokens),
g_strdup("1"));
/* misc_token_add(token_rep, */
/* option_int("string_token_yellow_limit", &tokens), */
/* misc_int_to_char(league_cup_get_yellow_red(fix->clid))); */
/* } */
cup_get_round_name(cup, fix->round, buf);
misc_token_add(token_rep,
option_int("string_token_cup_round_name", &tokens),
g_strdup(buf));
/* /\** 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 */
if(cupround->tables->len > 0)
{
misc_token_add(token_rep,
option_int("string_token_cup_knockout", &tokens),
g_strdup("0"));
misc_token_add(token_rep,
option_int("string_token_cup_round_robin", &tokens),
g_strdup("1"));
}
else
{
misc_token_add(token_rep,
option_int("string_token_cup_knockout", &tokens),
g_strdup("1"));
misc_token_add(token_rep,
option_int("string_token_cup_round_robin", &tokens),
g_strdup("0"));
/* gint i; */
}
if(fix->decisive)
misc_token_add(token_rep,
option_int("string_token_cup_match_winner", &tokens),
((Team*)fixture_winner_of(fix, FALSE))->name);
}
/* 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)); */
/* } */
misc_print_grouped_int(fix->attendance, buf);
misc_token_add(token_rep,
option_int("string_token_attendance", &tokens),
g_strdup(buf));
}
/* g_ptr_array_free(token_rep[0], TRUE); */
/* g_ptr_array_free(token_rep[1], TRUE); */
/* } */
/** 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. */
@ -687,60 +450,3 @@ news_load_news_file(const gchar *news_file, gboolean abort)
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); */
/* } */

View File

@ -29,39 +29,28 @@
#include "bygfoot.h"
#include "news_struct.h"
/* void */
/* news_free_tokens(void); */
void
news_free_tokens(void);
/* void */
/* news_initialize(const Fixture *fix); */
void
news_set_match_tokens(const LiveGame *live_game, const Fixture *fix_);
/* gboolean */
/* news_check_news(const LGNews *news, gchar *dest); */
void
news_generate_match(const LiveGame *live_game, const Fixture *fix);
/* gboolean */
/* query_news_is_repetition(gint id); */
void
news_select(const GArray *news_array, gchar *title, gchar *subtitle,
gint *title_id, gint *subtitle_id);
/* void */
/* news_get_order(const GArray *commentaries, gint *order); */
gint
news_get_title(const GArray *titles, gchar *title, gint *order,
gboolean is_title, gboolean ignore_repetition);
/* void */
/* news_set_basic_tokens(const LiveGameUnit *unit, const Fixture *fix);; */
gboolean
news_check_for_repetition(gint id, gboolean is_title);
/* 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); */
gboolean
news_check_article_condition(const NewsArticle *news_article);
void
news_load_news_file_from_option(void);
@ -69,14 +58,8 @@ 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_titles_get_order(const GArray *titles, gint *order);
/* 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

View File

@ -29,9 +29,7 @@
/** 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_MATCH = 0, /**< Article about a 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. */
@ -40,7 +38,7 @@ enum NewsArticleTypes
NEWS_ARTICLE_TYPE_END
};
/** Structure containing a news title or subtitle. */
/** Structure containing a news title or subtitle with tokens. */
typedef struct
{
gchar *text;
@ -52,9 +50,10 @@ typedef struct
/** 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. */
/** Structure describing a news paper article with tokens. */
typedef struct
{
/** Possible article titles (possibly containing tokens). */
@ -64,7 +63,27 @@ typedef struct
/** A condition (if not fulfilled, the article doesn't get
shown). */
gchar *condition;
} NewsArticle;
/** Structure holding an article without tokens (ie. the real deal that's displayed). */
typedef struct
{
gint week_number, week_round_number;
gint title_id, subtitle_id;
gchar *title, *subtitle;
} NewsPaperArticle;
/** Structure holding the newspaper for the game. */
typedef struct
{
/** A selection of newspaper names. */
GPtrArray *names;
/** The array of created articles. */
GArray *articles;
} NewsPaper;
#endif

View File

@ -39,6 +39,7 @@
#include "maths.h"
#include "misc.h"
#include "name.h"
#include "news.h"
#include "option.h"
#include "player.h"
#include "start_end.h"
@ -358,6 +359,9 @@ end_week_round_results(void)
{
live_game_calculate_fixture(&g_array_index(lig(i).fixtures, Fixture, j));
if(fixture_user_team_involved(&g_array_index(lig(i).fixtures, Fixture, j)) != -1)
news_generate_match(NULL, &g_array_index(lig(i).fixtures, Fixture, j));
done++;
fixture_result_to_buf(&g_array_index(lig(i).fixtures, Fixture, j),
buf, FALSE);

View File

@ -62,6 +62,9 @@ GArray *lg_commentary[LIVE_GAME_EVENT_END];
/** The array containing the news article strings. */
GArray *news[NEWS_ARTICLE_TYPE_END];
/** Newspaper containing the news articles. */
NewsPaper newspaper;
/** The array containing players to be transfered.
@see TransferPlayer */
GArray *transfer_list;

View File

@ -30,6 +30,7 @@
#include "xml_news.h"
#define TAG_NEWS "news"
#define TAG_PAPER_NAME "paper_name"
#define TAG_ARTICLE "news_article"
#define TAG_ARTICLE_TYPE "type"
#define TAG_ARTICLE_CONDITION "condition"
@ -38,9 +39,7 @@
#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_MATCH "match"
#define ARTICLE_TYPE_NAME_FINANCES "finances"
#define ARTICLE_TYPE_NAME_STAR_PLAYER_TRANSFER "star_player_transfer"
#define ARTICLE_TYPE_NAME_LEAGUE_CHAMPION "league_champion"
@ -50,6 +49,7 @@
enum XmlNewsStates
{
STATE_NEWS = 0,
STATE_PAPER_NAME,
STATE_ARTICLE,
STATE_ARTICLE_TYPE,
STATE_ARTICLE_CONDITION,
@ -73,12 +73,8 @@ xml_news_article_type_to_int(const gchar *type_string)
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;
if(strcmp(type_string, ARTICLE_TYPE_NAME_MATCH) == 0)
return_value = NEWS_ARTICLE_TYPE_MATCH;
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)
@ -116,6 +112,8 @@ xml_news_read_start_element (GMarkupParseContext *context,
if(strcmp(element_name, TAG_NEWS) == 0)
state = STATE_NEWS;
else if(strcmp(element_name, TAG_PAPER_NAME) == 0)
state = STATE_PAPER_NAME;
else if(strcmp(element_name, TAG_ARTICLE) == 0)
{
state = STATE_ARTICLE;
@ -169,6 +167,8 @@ xml_news_read_end_element (GMarkupParseContext *context,
state = STATE_NEWS;
g_array_append_val(news[article_idx], new_article);
}
else if(strcmp(element_name, TAG_PAPER_NAME) == 0)
state = STATE_NEWS;
else if(strcmp(element_name, TAG_ARTICLE_TYPE) == 0 ||
strcmp(element_name, TAG_ARTICLE_CONDITION) == 0 ||
strcmp(element_name, TAG_ARTICLE_TITLE) == 0 ||
@ -201,7 +201,9 @@ xml_news_read_text (GMarkupParseContext *context,
strncpy(buf, text, text_len);
buf[text_len] = '\0';
if(state == STATE_ARTICLE_TYPE)
if(state == STATE_PAPER_NAME)
g_ptr_array_add(newspaper.names, g_strdup(buf));
else 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);
@ -257,6 +259,7 @@ xml_news_read(const gchar *news_file)
}
free_news(TRUE);
free_newspaper(TRUE);
if(g_markup_parse_context_parse(context, file_contents, length, &error))
{

View File

@ -1,5 +1,5 @@
int_opt_confirm_quit 0
int_opt_confirm_unfit 1
int_opt_confirm_unfit 0
int_opt_save_will_overwrite 0
int_opt_maximize_main_window 1
int_opt_prefer_messages 0
@ -22,3 +22,6 @@ int_opt_randomise_teams 0
int_opt_calodds 0
int_opt_load_defs 1
int_opt_randomise_teams 0
int_opt_calodds 0
int_opt_load_defs 1
int_opt_randomise_teams 0

View File

@ -997,3 +997,7 @@ int_training_camps_per_season 12
# number of training camps allowed per week
int_training_camps_week 2
# how many news articles to check backwards
# to avoid news repetitions
int_news_repetition_check_number 10

View File

@ -9,36 +9,36 @@
#------------------------------------
# general
string_token_league_cup_name _LEAGUECUPNAME_
string_token_cup_round_name _CUPROUNDNAME_
string_token_attendance _AT_
string_token_result _RE_
string_token_league_cup_name _LEAGUECUPNAME_ # also for news
string_token_cup_round_name _CUPROUNDNAME_ # also for news
string_token_attendance _AT_ # also for news
string_token_result _RE_ # also for news
string_token_time _TIME_
string_token_minute _MI_
string_token_minute_remaining _MR_
string_token_minute_total _MT_
string_token_yellow_limit _YELLOWLIMIT_
string_token_goals0 _GOALS0_
string_token_goals1 _GOALS1_
string_token_goal_diff _GD_
string_token_goals0 _GOALS0_ # also for news
string_token_goals1 _GOALS1_ # also for news
string_token_goal_diff _GD_ # also for news
string_token_possession _POSS_
string_token_no_possession _NPOSS_
# misc
string_token_extra _EX_
# team
string_token_team_home _T0_
string_token_team_away _T1_
string_token_team_losing _TL_
string_token_team_winning _TW_
string_token_team_winningn _TWN_
string_token_team_losingn _TLN_
string_token_team_home _T0_ # also for news
string_token_team_away _T1_ # also for news
string_token_team_losing _TL_ # also for news
string_token_team_winning _TW_ # also for news
string_token_team_winningn _TWN_ # also for news
string_token_team_losingn _TLN_ # also for news
string_token_team _TT_
string_token_team_layer0 _TLAYER0_
string_token_team_layer1 _TLAYER1_
string_token_team_layerdiff _LAYERDIFF_
string_token_team_avskill0 _TAVSKILL0_
string_token_team_avskill1 _TAVSKILL1_
string_token_team_avskilldiff _TAVSKILLDIFF_
string_token_team_layer0 _TLAYER0_ # also for news
string_token_team_layer1 _TLAYER1_ # also for news
string_token_team_layerdiff _LAYERDIFF_ # also for news
string_token_team_avskill0 _TAVSKILL0_ # also for news
string_token_team_avskill1 _TAVSKILL1_ # also for news
string_token_team_avskilldiff _TAVSKILLDIFF_ # also for news
# player
string_token_player0 _P0_
string_token_player1 _P1_
@ -48,22 +48,22 @@ string_token_player_goals1 _PLGOALS1_
string_token_player_goals_all1 _PLGOALSALL1_
string_token_player_yellows _PLYELLOWS_
# stat tokens
string_token_stat_shots0 _SHOTS0_
string_token_stat_shots1 _SHOTS1_
string_token_stat_shot_per0 _SHOTPER0_
string_token_stat_shot_per1 _SHOTPER1_
string_token_stat_poss0 _POSS0_
string_token_stat_poss1 _POSS1_
string_token_stat_pen0 _PEN0_
string_token_stat_pen1 _PEN1_
string_token_stat_fouls0 _FOULS0_
string_token_stat_fouls1 _FOULS1_
string_token_stat_yellows0 _YELLOWS0_
string_token_stat_yellows1 _YELLOWS1_
string_token_stat_reds0 _REDS0_
string_token_stat_reds1 _REDS1_
string_token_stat_injs0 _INJS0_
string_token_stat_injs1 _INJS1_
string_token_stat_shots0 _SHOTS0_ # also for news
string_token_stat_shots1 _SHOTS1_ # also for news
string_token_stat_shot_per0 _SHOTPER0_ # also for news
string_token_stat_shot_per1 _SHOTPER1_ # also for news
string_token_stat_poss0 _POSS0_ # also for news
string_token_stat_poss1 _POSS1_ # also for news
string_token_stat_pen0 _PEN0_ # also for news
string_token_stat_pen1 _PEN1_ # also for news
string_token_stat_fouls0 _FOULS0_ # also for news
string_token_stat_fouls1 _FOULS1_ # also for news
string_token_stat_yellows0 _YELLOWS0_ # also for news
string_token_stat_yellows1 _YELLOWS1_ # also for news
string_token_stat_reds0 _REDS0_ # also for news
string_token_stat_reds1 _REDS1_ # also for news
string_token_stat_injs0 _INJS0_ # also for news
string_token_stat_injs1 _INJS1_ # also for news
# tokens for CPU strategy
#--------------------------
@ -80,3 +80,14 @@ string_token_num_def _NUMDEF_
string_token_num_mid _NUMMID_
string_token_num_att _NUMATT_
string_token_form _FORMATION_
# tokens for news articles
#------------------------------------
string_token_cup _CUP_
string_token_cup_round_robin _CUPRR_
string_token_cup_knockout _CUPKO_
string_token_cup_stage _CUPSTAGE_
string_token_cup_match_winner _CUPMATCHWINNER_
string_token_scorers _SCORERS_
string_token_highscorer _HIGHSCORER_
string_token_highscorer_goals _HIGHGOALS_

View File

@ -1,21 +1,23 @@
<news>
<paper_name>Bygfoot Herald</paper_name>
<paper_name>4TehFans</paper_name>
<paper_name>Football Online</paper_name>
<paper_name>11vs11</paper_name>
<paper_name>The Pitch</paper_name>
<paper_name>News Of The Sports World</paper_name>
<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>
<type>match</type>
<condition>_GD_ > 1</condition>
<title>_TW_ [beats|crushes|kills] _TL_!</title>
<subtitle>Result: _RE_</subtitle>
<title priority="5">_TL_ loses to _TW_!</title>
<subtitle priority="5">_TL_ doesn't stand a chance against a _GOALS_TWN__ goal barrage.</subtitle>
<title>_TW_ wipes out _TL_!</title>
<subtitle>_RE_ is flattering for _TL_.</subtitle>
<title>_TL_ loses again!</title>
<subtitle>_TW_ just too strong.</subtitle>
<title>_TL_ in a world of misery!</title>
<subtitle>_TW_: _RE_ against _TL_.</subtitle>
</news_article>
</news>

View File

@ -1,21 +1,23 @@
<news>
<paper_name>Bygfoot Herald</paper_name>
<paper_name>4TehFans</paper_name>
<paper_name>Football Online</paper_name>
<paper_name>11vs11</paper_name>
<paper_name>The Pitch</paper_name>
<paper_name>News Of The Sports World</paper_name>
<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>
<type>match</type>
<condition>_GD_ > 1</condition>
<title>_TW_ [beats|crushes|kills] _TL_!</title>
<subtitle>Result: _RE_</subtitle>
<title priority="5">_TL_ loses to _TW_!</title>
<subtitle priority="5">_TL_ doesn't stand a chance against a _GOALS_TWN__ goal barrage.</subtitle>
<title>_TW_ wipes out _TL_!</title>
<subtitle>_RE_ is flattering for _TL_.</subtitle>
<title>_TL_ loses again!</title>
<subtitle>_TW_ just too strong.</subtitle>
<title>_TL_ in a world of misery!</title>
<subtitle>_TW_: _RE_ against _TL_.</subtitle>
</news_article>
</news>