mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-02-21 14:01:03 +01:00
Newspaper progressing.
This commit is contained in:
parent
6951acd7dc
commit
526ce56d5d
@ -162,6 +162,7 @@ debug_calibrate_betting_odds(gint skilldiffmax, gint matches_per_skilldiff)
|
|||||||
|
|
||||||
gint i, skilldiff, matches;
|
gint i, skilldiff, matches;
|
||||||
Fixture *fix = &g_array_index(lig(0).fixtures, Fixture, 0);
|
Fixture *fix = &g_array_index(lig(0).fixtures, Fixture, 0);
|
||||||
|
LiveGame live_game;
|
||||||
|
|
||||||
fix->home_advantage = FALSE;
|
fix->home_advantage = FALSE;
|
||||||
|
|
||||||
@ -183,7 +184,7 @@ debug_calibrate_betting_odds(gint skilldiffmax, gint matches_per_skilldiff)
|
|||||||
g_array_index(fix->teams[1]->players, Player, i).fitness = 0.9;
|
g_array_index(fix->teams[1]->players, Player, i).fitness = 0.9;
|
||||||
}
|
}
|
||||||
|
|
||||||
live_game_calculate_fixture(fix);
|
live_game_calculate_fixture(fix, &live_game);
|
||||||
if(fix->result[0][0] < fix->result[1][0])
|
if(fix->result[0][0] < fix->result[1][0])
|
||||||
res[2]++;
|
res[2]++;
|
||||||
else
|
else
|
||||||
|
@ -739,6 +739,7 @@ fixture_write(GArray *fixtures, Team *home_team, Team *away_team, gint week_numb
|
|||||||
new.teams[1] = away_team;
|
new.teams[1] = away_team;
|
||||||
new.team_ids[0] = home_team->id;
|
new.team_ids[0] = home_team->id;
|
||||||
new.team_ids[1] = away_team->id;
|
new.team_ids[1] = away_team->id;
|
||||||
|
new.live_game = NULL;
|
||||||
|
|
||||||
for(i=0;i<3;i++)
|
for(i=0;i<3;i++)
|
||||||
new.result[0][i] = new.result[1][i] = 0;
|
new.result[0][i] = new.result[1][i] = 0;
|
||||||
|
@ -57,6 +57,8 @@ typedef struct
|
|||||||
/** How many people attended and whether there were
|
/** How many people attended and whether there were
|
||||||
special events. */
|
special events. */
|
||||||
gint attendance;
|
gint attendance;
|
||||||
|
/** Pointer to the live game used for the fixture calculation. */
|
||||||
|
gpointer live_game;
|
||||||
} Fixture;
|
} Fixture;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -50,12 +50,13 @@ free_memory(void)
|
|||||||
free_country(&country, FALSE);
|
free_country(&country, FALSE);
|
||||||
free_users(FALSE);
|
free_users(FALSE);
|
||||||
free_bets(FALSE);
|
free_bets(FALSE);
|
||||||
free_live_game(&live_game_temp);
|
|
||||||
free_lg_commentary(FALSE);
|
free_lg_commentary(FALSE);
|
||||||
free_news(FALSE);
|
free_news(FALSE);
|
||||||
free_newspaper(FALSE);
|
free_newspaper(FALSE);
|
||||||
free_support_dirs();
|
free_support_dirs();
|
||||||
free_jobs(FALSE);
|
free_jobs(FALSE);
|
||||||
|
|
||||||
|
free_g_array(&live_games);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Free the transfer list. */
|
/** Free the transfer list. */
|
||||||
@ -728,12 +729,18 @@ free_news(gboolean reset)
|
|||||||
g_free(g_array_index(news[i], NewsArticle, j).condition);
|
g_free(g_array_index(news[i], NewsArticle, j).condition);
|
||||||
|
|
||||||
for(k = 0; k < g_array_index(news[i], NewsArticle, j).titles->len; k++)
|
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_free(g_array_index(g_array_index(news[i], NewsArticle, j).titles, NewsText, k).text);
|
||||||
|
g_free(g_array_index(g_array_index(news[i], NewsArticle, j).titles, NewsText, k).condition);
|
||||||
|
}
|
||||||
|
|
||||||
g_array_free(g_array_index(news[i], NewsArticle, j).titles, TRUE);
|
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++)
|
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_free(g_array_index(g_array_index(news[i], NewsArticle, j).subtitles, NewsText, k).text);
|
||||||
|
g_free(g_array_index(g_array_index(news[i], NewsArticle, j).subtitles, NewsText, k).condition);
|
||||||
|
}
|
||||||
|
|
||||||
g_array_free(g_array_index(news[i], NewsArticle, j).subtitles, TRUE);
|
g_array_free(g_array_index(news[i], NewsArticle, j).subtitles, TRUE);
|
||||||
}
|
}
|
||||||
|
24
src/game.c
24
src/game.c
@ -32,7 +32,6 @@
|
|||||||
#include "live_game.h"
|
#include "live_game.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "maths.h"
|
#include "maths.h"
|
||||||
#include "news.h"
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "option.h"
|
#include "option.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
@ -984,6 +983,7 @@ game_update_stats_player(LiveGame *lg, const LiveGameUnit *unit)
|
|||||||
const Team *tm[2] = {lg->fix->teams[0],
|
const Team *tm[2] = {lg->fix->teams[0],
|
||||||
lg->fix->teams[1]};
|
lg->fix->teams[1]};
|
||||||
GPtrArray *players = NULL;
|
GPtrArray *players = NULL;
|
||||||
|
const gchar *player_name;
|
||||||
|
|
||||||
if(unit->event.type == LIVE_GAME_EVENT_GOAL ||
|
if(unit->event.type == LIVE_GAME_EVENT_GOAL ||
|
||||||
unit->event.type == LIVE_GAME_EVENT_OWN_GOAL)
|
unit->event.type == LIVE_GAME_EVENT_OWN_GOAL)
|
||||||
@ -998,29 +998,34 @@ game_update_stats_player(LiveGame *lg, const LiveGameUnit *unit)
|
|||||||
/* A goal scored with a free kick. */
|
/* A goal scored with a free kick. */
|
||||||
strcpy(buf2, _(" (FK)"));
|
strcpy(buf2, _(" (FK)"));
|
||||||
else if(unit->event.type == LIVE_GAME_EVENT_OWN_GOAL)
|
else if(unit->event.type == LIVE_GAME_EVENT_OWN_GOAL)
|
||||||
|
/* An own goal */
|
||||||
strcpy(buf2, _(" (OG)"));
|
strcpy(buf2, _(" (OG)"));
|
||||||
else
|
else
|
||||||
strcpy(buf2, "");
|
strcpy(buf2, "");
|
||||||
|
|
||||||
for(i=0;i<stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS]->len;i++)
|
player_name = player_of_id_team(tm[team], player)->name;
|
||||||
|
if(!own_goal)
|
||||||
|
g_ptr_array_add(stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS], g_strdup(player_name));
|
||||||
|
|
||||||
|
for(i=0;i<stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS_FOR_DISPLAY]->len;i++)
|
||||||
{
|
{
|
||||||
if(g_str_has_prefix((gchar*)g_ptr_array_index(
|
if(g_str_has_prefix((gchar*)g_ptr_array_index(
|
||||||
stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS], i),
|
stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS_FOR_DISPLAY], i),
|
||||||
player_of_id_team(tm[team], player)->name))
|
player_name))
|
||||||
{
|
{
|
||||||
sprintf(buf, "%s %d%s",
|
sprintf(buf, "%s %d%s",
|
||||||
(gchar*)g_ptr_array_index(
|
(gchar*)g_ptr_array_index(
|
||||||
stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS], i),
|
stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS_FOR_DISPLAY], i),
|
||||||
minute, buf2);
|
minute, buf2);
|
||||||
misc_string_assign((gchar**)&g_ptr_array_index(
|
misc_string_assign((gchar**)&g_ptr_array_index(
|
||||||
stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS], i), buf);
|
stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS_FOR_DISPLAY], i), buf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(buf, "%s %d%s", player_of_id_team(tm[team], player)->name,
|
sprintf(buf, "%s %d%s", player_name,
|
||||||
minute, buf2);
|
minute, buf2);
|
||||||
g_ptr_array_add(stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS], g_strdup(buf));
|
g_ptr_array_add(stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS_FOR_DISPLAY], g_strdup(buf));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1075,9 +1080,6 @@ game_post_match(Fixture *fix)
|
|||||||
for(i=0;i<2;i++)
|
for(i=0;i<2;i++)
|
||||||
team_update_post_match(fix->teams[i], fix);
|
team_update_post_match(fix->teams[i], fix);
|
||||||
|
|
||||||
if(usr_idx != -1)
|
|
||||||
news_generate_match(&usr(usr_idx).live_game, fix);
|
|
||||||
|
|
||||||
if(fix->clid < ID_CUP_START)
|
if(fix->clid < ID_CUP_START)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -62,17 +62,19 @@ gboolean show;
|
|||||||
/** Calculate the result of a fixture using
|
/** Calculate the result of a fixture using
|
||||||
the live game variable.
|
the live game variable.
|
||||||
@param fix The fixture we calculate.
|
@param fix The fixture we calculate.
|
||||||
|
@param live_game The live game used for calculation.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
live_game_calculate_fixture(Fixture *fix)
|
live_game_calculate_fixture(Fixture *fix, LiveGame *live_game)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("live_game_calculate_fixture\n");
|
printf("live_game_calculate_fixture\n");
|
||||||
#endif
|
#endif
|
||||||
|
statp = live_game;
|
||||||
|
|
||||||
if(stat0 != STATUS_LIVE_GAME_PAUSE &&
|
if(stat0 != STATUS_LIVE_GAME_PAUSE &&
|
||||||
stat0 != STATUS_LIVE_GAME_CHANGE)
|
stat0 != STATUS_LIVE_GAME_CHANGE)
|
||||||
live_game_initialize(fix);
|
live_game_initialize(fix, live_game);
|
||||||
else
|
else
|
||||||
stat0 = STATUS_SHOW_LIVE_GAME;
|
stat0 = STATUS_SHOW_LIVE_GAME;
|
||||||
|
|
||||||
@ -105,7 +107,7 @@ live_game_calculate_fixture(Fixture *fix)
|
|||||||
|
|
||||||
/** Initialize a few things at the beginning of a live game. */
|
/** Initialize a few things at the beginning of a live game. */
|
||||||
void
|
void
|
||||||
live_game_initialize(Fixture *fix)
|
live_game_initialize(Fixture *fix, LiveGame *live_game)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("live_game_initialize\n");
|
printf("live_game_initialize\n");
|
||||||
@ -113,13 +115,12 @@ live_game_initialize(Fixture *fix)
|
|||||||
|
|
||||||
stat2 = fixture_user_team_involved(fix);
|
stat2 = fixture_user_team_involved(fix);
|
||||||
|
|
||||||
statp = (stat2 != -1) ?
|
statp = live_game;
|
||||||
&usr(stat2).live_game : &live_game_temp;
|
|
||||||
show = (stat2 != -1 &&
|
show = (stat2 != -1 &&
|
||||||
option_int("int_opt_user_show_live_game",
|
option_int("int_opt_user_show_live_game",
|
||||||
&usr(stat2).options));
|
&usr(stat2).options));
|
||||||
|
|
||||||
live_game_reset(match, fix, TRUE);
|
live_game_reset(match, fix, (stat2 != -1));
|
||||||
|
|
||||||
if(show)
|
if(show)
|
||||||
{
|
{
|
||||||
@ -131,11 +132,12 @@ live_game_initialize(Fixture *fix)
|
|||||||
else
|
else
|
||||||
gtk_window_set_title(
|
gtk_window_set_title(
|
||||||
GTK_WINDOW(window.live),
|
GTK_WINDOW(window.live),
|
||||||
league_cup_get_name_string(((LiveGame*)statp)->fix->clid));
|
league_cup_get_name_string(match->fix->clid));
|
||||||
window_live_set_up();
|
window_live_set_up();
|
||||||
game_gui_live_game_show_opponent();
|
game_gui_live_game_show_opponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fix->live_game = match;
|
||||||
game_initialize(fix);
|
game_initialize(fix);
|
||||||
match->attendance = fix->attendance;
|
match->attendance = fix->attendance;
|
||||||
|
|
||||||
@ -1704,7 +1706,7 @@ live_game_resume(void)
|
|||||||
tms[i]->boost + 1);
|
tms[i]->boost + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
live_game_calculate_fixture(usr(stat2).live_game.fix);
|
live_game_calculate_fixture(usr(stat2).live_game.fix, &usr(stat2).live_game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,10 +30,10 @@
|
|||||||
#include "live_game_struct.h"
|
#include "live_game_struct.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
live_game_calculate_fixture(Fixture *fix);
|
live_game_calculate_fixture(Fixture *fix, LiveGame *live_game);
|
||||||
|
|
||||||
void
|
void
|
||||||
live_game_initialize(Fixture *fix);
|
live_game_initialize(Fixture *fix, LiveGame *live_game);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
query_live_game_event_is_break(gint minute, gint time);
|
query_live_game_event_is_break(gint minute, gint time);
|
||||||
|
@ -116,7 +116,8 @@ enum LiveGameStatValue
|
|||||||
|
|
||||||
enum LiveGameStatArray
|
enum LiveGameStatArray
|
||||||
{
|
{
|
||||||
LIVE_GAME_STAT_ARRAY_SCORERS = 0,
|
LIVE_GAME_STAT_ARRAY_SCORERS_FOR_DISPLAY = 0,
|
||||||
|
LIVE_GAME_STAT_ARRAY_SCORERS,
|
||||||
LIVE_GAME_STAT_ARRAY_YELLOWS,
|
LIVE_GAME_STAT_ARRAY_YELLOWS,
|
||||||
LIVE_GAME_STAT_ARRAY_REDS,
|
LIVE_GAME_STAT_ARRAY_REDS,
|
||||||
LIVE_GAME_STAT_ARRAY_INJURED,
|
LIVE_GAME_STAT_ARRAY_INJURED,
|
||||||
|
@ -209,13 +209,12 @@ main_init_variables(void)
|
|||||||
window.mmatches = window.bets = window.splash =
|
window.mmatches = window.bets = window.splash =
|
||||||
window.training_camp = NULL;
|
window.training_camp = NULL;
|
||||||
|
|
||||||
live_game_reset(&live_game_temp, NULL, FALSE);
|
|
||||||
|
|
||||||
users = g_array_new(FALSE, FALSE, sizeof(User));
|
users = g_array_new(FALSE, FALSE, sizeof(User));
|
||||||
transfer_list = g_array_new(FALSE, FALSE, sizeof(Transfer));
|
transfer_list = g_array_new(FALSE, FALSE, sizeof(Transfer));
|
||||||
season_stats = g_array_new(FALSE, FALSE, sizeof(SeasonStat));
|
season_stats = g_array_new(FALSE, FALSE, sizeof(SeasonStat));
|
||||||
name_lists = g_array_new(FALSE, FALSE, sizeof(NameList));
|
name_lists = g_array_new(FALSE, FALSE, sizeof(NameList));
|
||||||
strategies = g_array_new(FALSE, FALSE, sizeof(Strategy));
|
strategies = g_array_new(FALSE, FALSE, sizeof(Strategy));
|
||||||
|
live_games = g_array_new(FALSE, FALSE, sizeof(LiveGame));
|
||||||
bets[0] = g_array_new(FALSE, FALSE, sizeof(BetMatch));
|
bets[0] = g_array_new(FALSE, FALSE, sizeof(BetMatch));
|
||||||
bets[1] = g_array_new(FALSE, FALSE, sizeof(BetMatch));
|
bets[1] = g_array_new(FALSE, FALSE, sizeof(BetMatch));
|
||||||
jobs = g_array_new(FALSE, FALSE, sizeof(Job));
|
jobs = g_array_new(FALSE, FALSE, sizeof(Job));
|
||||||
|
@ -706,6 +706,10 @@ misc_token_add(GPtrArray **token_rep, gint token_idx,
|
|||||||
gchar *replacement)
|
gchar *replacement)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/* printf("tok +%s+ rep +%s+\n", */
|
||||||
|
/* g_strdup(g_array_index(tokens.list, Option, token_idx).string_value), */
|
||||||
|
/* replacement); */
|
||||||
|
|
||||||
g_ptr_array_add(token_rep[0],
|
g_ptr_array_add(token_rep[0],
|
||||||
(gpointer)g_strdup(g_array_index(tokens.list, Option, token_idx).string_value));
|
(gpointer)g_strdup(g_array_index(tokens.list, Option, token_idx).string_value));
|
||||||
g_ptr_array_add(token_rep[1], (gpointer)replacement);
|
g_ptr_array_add(token_rep[1], (gpointer)replacement);
|
||||||
|
302
src/news.c
302
src/news.c
@ -31,6 +31,7 @@
|
|||||||
#include "fixture.h"
|
#include "fixture.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "lg_commentary.h"
|
#include "lg_commentary.h"
|
||||||
|
#include "live_game.h"
|
||||||
#include "league.h"
|
#include "league.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "maths.h"
|
#include "maths.h"
|
||||||
@ -38,6 +39,7 @@
|
|||||||
#include "news.h"
|
#include "news.h"
|
||||||
#include "option.h"
|
#include "option.h"
|
||||||
#include "team.h"
|
#include "team.h"
|
||||||
|
#include "user.h"
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
#include "xml_news.h"
|
#include "xml_news.h"
|
||||||
|
|
||||||
@ -46,7 +48,7 @@ GPtrArray *token_rep_news[2];
|
|||||||
|
|
||||||
/** Generate news for a user live game or a CPU fixture. */
|
/** Generate news for a user live game or a CPU fixture. */
|
||||||
void
|
void
|
||||||
news_generate_match(const LiveGame *live_game, const Fixture *fix)
|
news_generate_match(const LiveGame *live_game)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("news_generate_match\n");
|
printf("news_generate_match\n");
|
||||||
@ -59,7 +61,7 @@ news_generate_match(const LiveGame *live_game, const Fixture *fix)
|
|||||||
token_rep_news[0] = g_ptr_array_new();
|
token_rep_news[0] = g_ptr_array_new();
|
||||||
token_rep_news[1] = g_ptr_array_new();
|
token_rep_news[1] = g_ptr_array_new();
|
||||||
|
|
||||||
news_set_match_tokens(live_game, fix);
|
news_set_match_tokens(live_game);
|
||||||
|
|
||||||
news_select(news[NEWS_ARTICLE_TYPE_MATCH], title, subtitle,
|
news_select(news[NEWS_ARTICLE_TYPE_MATCH], title, subtitle,
|
||||||
&title_id, &subtitle_id);
|
&title_id, &subtitle_id);
|
||||||
@ -134,7 +136,8 @@ news_get_title(const GArray *titles, gchar *title, gint *order,
|
|||||||
|
|
||||||
for(i = 0; i < titles->len; i++)
|
for(i = 0; i < titles->len; i++)
|
||||||
{
|
{
|
||||||
if(misc_string_replace_all_tokens(token_rep_news, g_array_index(titles, NewsText, order[i]).text, title))
|
if(misc_parse_condition(g_array_index(titles, NewsText, order[i]).condition, token_rep_news) &&
|
||||||
|
misc_string_replace_all_tokens(token_rep_news, g_array_index(titles, NewsText, order[i]).text, title))
|
||||||
{
|
{
|
||||||
result = g_array_index(titles, NewsText, order[i]).id;
|
result = g_array_index(titles, NewsText, order[i]).id;
|
||||||
if(ignore_repetition || !news_check_for_repetition(result, is_title))
|
if(ignore_repetition || !news_check_for_repetition(result, is_title))
|
||||||
@ -214,25 +217,199 @@ news_titles_get_order(const GArray *titles, gint *order)
|
|||||||
|
|
||||||
/** Set match-related tokens for the news. */
|
/** Set match-related tokens for the news. */
|
||||||
void
|
void
|
||||||
news_set_match_tokens(const LiveGame *live_game, const Fixture *fix_)
|
news_set_match_tokens(const LiveGame *live_game)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("news_set_match_tokens\n");
|
printf("news_set_match_tokens\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
lg_commentary_set_stats_tokens(&live_game->stats, token_rep_news);
|
||||||
|
news_set_fixture_tokens(live_game->fix);
|
||||||
|
news_set_league_cup_tokens(live_game->fix);
|
||||||
|
news_set_scorer_tokens(&live_game->stats);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
news_set_scorer_tokens(const LiveGameStats *stats)
|
||||||
|
{
|
||||||
|
gint i, j, k;
|
||||||
|
GPtrArray *scorers[2];
|
||||||
|
GArray *goals[2];
|
||||||
|
gchar buf[SMALL];
|
||||||
|
gchar scorer_str[SMALL];
|
||||||
|
const gchar *scorer;
|
||||||
|
gchar high_scorer[SMALL];
|
||||||
|
gint scorer_goals;
|
||||||
|
gint max_goals;
|
||||||
|
|
||||||
|
for(i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
scorers[i] = g_ptr_array_new();
|
||||||
|
goals[i] = g_array_new(FALSE, FALSE, sizeof(gint));
|
||||||
|
|
||||||
|
for(j = 0; j < stats->players[i][LIVE_GAME_STAT_ARRAY_SCORERS]->len; j++)
|
||||||
|
{
|
||||||
|
scorer = (gchar*)g_ptr_array_index(stats->players[i][LIVE_GAME_STAT_ARRAY_SCORERS], j);
|
||||||
|
|
||||||
|
for(k=0;k<scorers[i]->len;k++)
|
||||||
|
{
|
||||||
|
if(strcmp(scorer, (gchar*)g_ptr_array_index(scorers[i], k)) == 0)
|
||||||
|
{
|
||||||
|
g_array_index(goals[i], gint, k) = g_array_index(goals[i], gint, k) + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(k == scorers[i]->len)
|
||||||
|
{
|
||||||
|
gint onegoal = 1;
|
||||||
|
g_ptr_array_add(scorers[i], (gpointer)scorer);
|
||||||
|
g_array_append_val(goals[i], onegoal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
max_goals = 0;
|
||||||
|
strcpy(buf, "");
|
||||||
|
strcpy(scorer_str, "");
|
||||||
|
strcpy(high_scorer, "");
|
||||||
|
|
||||||
|
for(j = 0; j < scorers[i]->len; j++)
|
||||||
|
{
|
||||||
|
scorer_goals = g_array_index(goals[i], gint, j);
|
||||||
|
scorer = (gchar*)g_ptr_array_index(scorers[i], j);
|
||||||
|
|
||||||
|
if(scorer_goals > max_goals)
|
||||||
|
{
|
||||||
|
max_goals = scorer_goals;
|
||||||
|
strcpy(high_scorer, scorer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(j == 0)
|
||||||
|
{
|
||||||
|
if(scorer_goals > 1)
|
||||||
|
sprintf(scorer_str, "%s (%d)", scorer, scorer_goals);
|
||||||
|
else
|
||||||
|
sprintf(scorer_str, "%s", scorer);
|
||||||
|
}
|
||||||
|
else if(j == scorers[i]->len - 1 && j != 0)
|
||||||
|
{
|
||||||
|
if(scorer_goals > 1)
|
||||||
|
sprintf(scorer_str, "%s and %s (%d)", buf, scorer, scorer_goals);
|
||||||
|
else
|
||||||
|
sprintf(scorer_str, "%s and %s", buf, scorer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(scorer_goals > 1)
|
||||||
|
sprintf(scorer_str, "%s, %s (%d)", buf, scorer, scorer_goals);
|
||||||
|
else
|
||||||
|
sprintf(scorer_str, "%s, %s", buf, scorer);
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(buf, scorer_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* printf("%d +%s+ +%s+ %d\n", i, scorer_str, high_scorer, max_goals); */
|
||||||
|
|
||||||
|
if(strcmp(scorer_str, "") != 0)
|
||||||
|
{
|
||||||
|
sprintf(buf, "string_token_multiple_scorers%d", i);
|
||||||
|
misc_token_add(token_rep_news,
|
||||||
|
option_int(buf, &tokens),
|
||||||
|
misc_int_to_char((scorers[i]->len > 1)));
|
||||||
|
|
||||||
|
sprintf(buf, "string_token_scorers%d", i);
|
||||||
|
misc_token_add(token_rep_news,
|
||||||
|
option_int(buf, &tokens),
|
||||||
|
g_strdup(scorer_str));
|
||||||
|
sprintf(buf, "string_token_highscorer%d", i);
|
||||||
|
misc_token_add(token_rep_news,
|
||||||
|
option_int(buf, &tokens),
|
||||||
|
g_strdup(high_scorer));
|
||||||
|
sprintf(buf, "string_token_highscorer_goals%d", i);
|
||||||
|
misc_token_add(token_rep_news,
|
||||||
|
option_int(buf, &tokens),
|
||||||
|
misc_int_to_char(max_goals));
|
||||||
|
}
|
||||||
|
|
||||||
|
g_ptr_array_free(scorers[i], TRUE);
|
||||||
|
g_array_free(goals[i], TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
news_set_league_cup_tokens(const Fixture *fix)
|
||||||
|
{
|
||||||
gchar buf[SMALL];
|
gchar buf[SMALL];
|
||||||
const Fixture *fix;
|
|
||||||
gint avskill0, avskill1;
|
|
||||||
const Cup *cup;
|
const Cup *cup;
|
||||||
const CupRound *cupround;
|
const CupRound *cupround;
|
||||||
|
|
||||||
if(live_game == NULL)
|
if(fix->teams[0]->clid < ID_CUP_START)
|
||||||
fix = fix_;
|
misc_token_add(token_rep_news,
|
||||||
else
|
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_news,
|
||||||
|
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_news,
|
||||||
|
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_news,
|
||||||
|
option_int("string_token_league_cup_name", &tokens),
|
||||||
|
g_strdup(league_cup_get_name_string(fix->clid)));
|
||||||
|
|
||||||
|
misc_token_add(token_rep_news,
|
||||||
|
option_int("string_token_cup", &tokens),
|
||||||
|
misc_int_to_char((fix->clid >= ID_CUP_START)));
|
||||||
|
|
||||||
|
if(fix->clid >= ID_CUP_START)
|
||||||
{
|
{
|
||||||
fix = live_game->fix;
|
cup = cup_from_clid(fix->clid);
|
||||||
lg_commentary_set_stats_tokens(&live_game->stats, token_rep_news);
|
cupround = &g_array_index(cup->rounds, CupRound, fix->round);
|
||||||
|
|
||||||
|
cup_get_round_name(cup, fix->round, buf);
|
||||||
|
misc_token_add(token_rep_news,
|
||||||
|
option_int("string_token_cup_round_name", &tokens),
|
||||||
|
g_strdup(buf));
|
||||||
|
|
||||||
|
if(cupround->tables->len > 0)
|
||||||
|
{
|
||||||
|
misc_token_add(token_rep_news,
|
||||||
|
option_int("string_token_cup_knockout", &tokens),
|
||||||
|
g_strdup("0"));
|
||||||
|
misc_token_add(token_rep_news,
|
||||||
|
option_int("string_token_cup_round_robin", &tokens),
|
||||||
|
g_strdup("1"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
misc_token_add(token_rep_news,
|
||||||
|
option_int("string_token_cup_knockout", &tokens),
|
||||||
|
g_strdup("1"));
|
||||||
|
misc_token_add(token_rep_news,
|
||||||
|
option_int("string_token_cup_round_robin", &tokens),
|
||||||
|
g_strdup("0"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fix->decisive)
|
||||||
|
misc_token_add(token_rep_news,
|
||||||
|
option_int("string_token_cup_match_winner", &tokens),
|
||||||
|
((Team*)fixture_winner_of(fix, FALSE))->name);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
news_set_fixture_tokens(const Fixture *fix)
|
||||||
|
{
|
||||||
|
gchar buf[SMALL];
|
||||||
|
gint avskill0, avskill1;
|
||||||
|
|
||||||
avskill0 = (gint)rint(team_get_average_skill(fix->teams[0], TRUE));
|
avskill0 = (gint)rint(team_get_average_skill(fix->teams[0], TRUE));
|
||||||
avskill1 = (gint)rint(team_get_average_skill(fix->teams[1], TRUE));
|
avskill1 = (gint)rint(team_get_average_skill(fix->teams[1], TRUE));
|
||||||
@ -242,6 +419,11 @@ news_set_match_tokens(const LiveGame *live_game, const Fixture *fix_)
|
|||||||
option_int("string_token_result", &tokens),
|
option_int("string_token_result", &tokens),
|
||||||
g_strdup(buf));
|
g_strdup(buf));
|
||||||
|
|
||||||
|
misc_print_grouped_int(fix->attendance, buf);
|
||||||
|
misc_token_add(token_rep_news,
|
||||||
|
option_int("string_token_attendance", &tokens),
|
||||||
|
g_strdup(buf));
|
||||||
|
|
||||||
misc_token_add(token_rep_news,
|
misc_token_add(token_rep_news,
|
||||||
option_int("string_token_goals0", &tokens),
|
option_int("string_token_goals0", &tokens),
|
||||||
misc_int_to_char(fix->result[0][0]));
|
misc_int_to_char(fix->result[0][0]));
|
||||||
@ -273,72 +455,7 @@ news_set_match_tokens(const LiveGame *live_game, const Fixture *fix_)
|
|||||||
misc_token_add(token_rep_news,
|
misc_token_add(token_rep_news,
|
||||||
option_int("string_token_team_winningn", &tokens),
|
option_int("string_token_team_winningn", &tokens),
|
||||||
misc_int_to_char((fix->result[0][0] < fix->result[1][0])));
|
misc_int_to_char((fix->result[0][0] < fix->result[1][0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fix->teams[0]->clid < ID_CUP_START)
|
|
||||||
misc_token_add(token_rep_news,
|
|
||||||
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_news,
|
|
||||||
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_news,
|
|
||||||
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_news,
|
|
||||||
option_int("string_token_league_cup_name", &tokens),
|
|
||||||
g_strdup(league_cup_get_name_string(fix->clid)));
|
|
||||||
|
|
||||||
if(fix->clid >= ID_CUP_START)
|
|
||||||
{
|
|
||||||
cup = cup_from_clid(fix->clid);
|
|
||||||
cupround = &g_array_index(cup->rounds, CupRound, fix->round);
|
|
||||||
|
|
||||||
misc_token_add(token_rep_news,
|
|
||||||
option_int("string_token_cup", &tokens),
|
|
||||||
g_strdup("1"));
|
|
||||||
|
|
||||||
cup_get_round_name(cup, fix->round, buf);
|
|
||||||
misc_token_add(token_rep_news,
|
|
||||||
option_int("string_token_cup_round_name", &tokens),
|
|
||||||
g_strdup(buf));
|
|
||||||
|
|
||||||
if(cupround->tables->len > 0)
|
|
||||||
{
|
|
||||||
misc_token_add(token_rep_news,
|
|
||||||
option_int("string_token_cup_knockout", &tokens),
|
|
||||||
g_strdup("0"));
|
|
||||||
misc_token_add(token_rep_news,
|
|
||||||
option_int("string_token_cup_round_robin", &tokens),
|
|
||||||
g_strdup("1"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
misc_token_add(token_rep_news,
|
|
||||||
option_int("string_token_cup_knockout", &tokens),
|
|
||||||
g_strdup("1"));
|
|
||||||
misc_token_add(token_rep_news,
|
|
||||||
option_int("string_token_cup_round_robin", &tokens),
|
|
||||||
g_strdup("0"));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(fix->decisive)
|
|
||||||
misc_token_add(token_rep_news,
|
|
||||||
option_int("string_token_cup_match_winner", &tokens),
|
|
||||||
((Team*)fixture_winner_of(fix, FALSE))->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
misc_print_grouped_int(fix->attendance, buf);
|
|
||||||
misc_token_add(token_rep_news,
|
|
||||||
option_int("string_token_attendance", &tokens),
|
|
||||||
g_strdup(buf));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Free the memory occupied by the tokens array and the permanent tokens. */
|
/** Free the memory occupied by the tokens array and the permanent tokens. */
|
||||||
@ -415,3 +532,34 @@ news_load_news_file(const gchar *news_file, gboolean abort)
|
|||||||
news_load_news_file("news_en.xml", TRUE);
|
news_load_news_file("news_en.xml", TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Find out if the match is interesting from a newspaper article
|
||||||
|
generation point of view. */
|
||||||
|
gboolean
|
||||||
|
news_check_match_relevant(const LiveGame *live_game)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
GArray *user_leagues;
|
||||||
|
|
||||||
|
if(fixture_user_team_involved(live_game->fix) != -1)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
user_leagues = g_array_new(FALSE, FALSE, sizeof(gint));
|
||||||
|
|
||||||
|
if(live_game->fix->clid >= ID_CUP_START &&
|
||||||
|
live_game->fix->round >= cup_from_clid(live_game->fix->clid)->rounds->len - 4)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
for(i = 0; i < users->len; i++)
|
||||||
|
if(!query_misc_integer_is_in_g_array(usr(i).tm->clid, user_leagues))
|
||||||
|
g_array_append_val(user_leagues, usr(i).tm->clid);
|
||||||
|
|
||||||
|
if(query_misc_integer_is_in_g_array(live_game->fix->clid, user_leagues))
|
||||||
|
{
|
||||||
|
g_array_free(user_leagues, TRUE);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_array_free(user_leagues, TRUE);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
15
src/news.h
15
src/news.h
@ -33,10 +33,10 @@ void
|
|||||||
news_free_tokens(void);
|
news_free_tokens(void);
|
||||||
|
|
||||||
void
|
void
|
||||||
news_set_match_tokens(const LiveGame *live_game, const Fixture *fix_);
|
news_set_match_tokens(const LiveGame *live_game);
|
||||||
|
|
||||||
void
|
void
|
||||||
news_generate_match(const LiveGame *live_game, const Fixture *fix);
|
news_generate_match(const LiveGame *live_game);
|
||||||
|
|
||||||
void
|
void
|
||||||
news_select(const GArray *news_array, gchar *title, gchar *subtitle,
|
news_select(const GArray *news_array, gchar *title, gchar *subtitle,
|
||||||
@ -58,5 +58,16 @@ news_load_news_file(const gchar *news_file, gboolean abort);
|
|||||||
void
|
void
|
||||||
news_titles_get_order(const GArray *titles, gint *order);
|
news_titles_get_order(const GArray *titles, gint *order);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
news_check_match_relevant(const LiveGame *live_game);
|
||||||
|
|
||||||
|
void
|
||||||
|
news_set_scorer_tokens(const LiveGameStats *stats);
|
||||||
|
|
||||||
|
void
|
||||||
|
news_set_league_cup_tokens(const Fixture *fix);
|
||||||
|
|
||||||
|
void
|
||||||
|
news_set_fixture_tokens(const Fixture *fix);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -49,7 +49,10 @@ typedef struct
|
|||||||
gint priority;
|
gint priority;
|
||||||
/** An id to keep track of already used texts
|
/** An id to keep track of already used texts
|
||||||
(so as not to use the same one too frequently). */
|
(so as not to use the same one too frequently). */
|
||||||
gint id;
|
gint id;
|
||||||
|
/** A condition (if not fulfilled, the title or subtitle
|
||||||
|
doesn't get considered). */
|
||||||
|
gchar *condition;
|
||||||
|
|
||||||
} NewsText;
|
} NewsText;
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ typedef void(*WeekFunc)(void);
|
|||||||
is ended. */
|
is ended. */
|
||||||
WeekFunc end_week_round_funcs[] =
|
WeekFunc end_week_round_funcs[] =
|
||||||
{end_week_round_results, end_week_round_sort_tables,
|
{end_week_round_results, end_week_round_sort_tables,
|
||||||
end_week_round_update_fixtures, NULL};
|
end_week_round_update_fixtures, end_week_round_generate_news, NULL};
|
||||||
|
|
||||||
/** Array of functions called when a week round
|
/** Array of functions called when a week round
|
||||||
is started. */
|
is started. */
|
||||||
@ -346,9 +346,17 @@ end_week_round_results(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
gint i, j, done = 0;
|
gint i, j, done = 0;
|
||||||
|
LiveGame live_game;
|
||||||
gchar buf[SMALL], buf2[SMALL];
|
gchar buf[SMALL], buf2[SMALL];
|
||||||
gfloat num_matches =
|
gfloat num_matches =
|
||||||
(gfloat)fixture_get_number_of_matches(week, week_round);
|
(gfloat)fixture_get_number_of_matches(week, week_round);
|
||||||
|
gint usr_idx;
|
||||||
|
|
||||||
|
/** Free the matches from last week. */
|
||||||
|
for(i = 0; i < live_games->len; i++)
|
||||||
|
free_live_game(&g_array_index(live_games, LiveGame, i));
|
||||||
|
g_array_free(live_games, TRUE);
|
||||||
|
live_games = g_array_new(FALSE, FALSE, sizeof(LiveGame));
|
||||||
|
|
||||||
for(i=0;i<ligs->len;i++)
|
for(i=0;i<ligs->len;i++)
|
||||||
{
|
{
|
||||||
@ -356,8 +364,18 @@ end_week_round_results(void)
|
|||||||
if(g_array_index(lig(i).fixtures, Fixture, j).week_number == week &&
|
if(g_array_index(lig(i).fixtures, Fixture, j).week_number == week &&
|
||||||
g_array_index(lig(i).fixtures, Fixture, j).week_round_number == week_round &&
|
g_array_index(lig(i).fixtures, Fixture, j).week_round_number == week_round &&
|
||||||
g_array_index(lig(i).fixtures, Fixture, j).attendance == -1)
|
g_array_index(lig(i).fixtures, Fixture, j).attendance == -1)
|
||||||
{
|
{
|
||||||
live_game_calculate_fixture(&g_array_index(lig(i).fixtures, Fixture, j));
|
usr_idx = fixture_user_team_involved(&g_array_index(lig(i).fixtures, Fixture, j));
|
||||||
|
|
||||||
|
if(usr_idx == -1)
|
||||||
|
{
|
||||||
|
g_array_append_val(live_games, live_game);
|
||||||
|
live_game_calculate_fixture(&g_array_index(lig(i).fixtures, Fixture, j),
|
||||||
|
&g_array_index(live_games, LiveGame, live_games->len - 1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
live_game_calculate_fixture(&g_array_index(lig(i).fixtures, Fixture, j),
|
||||||
|
&usr(usr_idx).live_game);
|
||||||
|
|
||||||
done++;
|
done++;
|
||||||
fixture_result_to_buf(&g_array_index(lig(i).fixtures, Fixture, j),
|
fixture_result_to_buf(&g_array_index(lig(i).fixtures, Fixture, j),
|
||||||
@ -381,7 +399,17 @@ end_week_round_results(void)
|
|||||||
g_array_index(acp(i)->fixtures, Fixture, j).week_round_number == week_round &&
|
g_array_index(acp(i)->fixtures, Fixture, j).week_round_number == week_round &&
|
||||||
g_array_index(acp(i)->fixtures, Fixture, j).attendance == -1)
|
g_array_index(acp(i)->fixtures, Fixture, j).attendance == -1)
|
||||||
{
|
{
|
||||||
live_game_calculate_fixture(&g_array_index(acp(i)->fixtures, Fixture, j));
|
usr_idx = fixture_user_team_involved(&g_array_index(acp(i)->fixtures, Fixture, j));
|
||||||
|
|
||||||
|
if(usr_idx == -1)
|
||||||
|
{
|
||||||
|
g_array_append_val(live_games, live_game);
|
||||||
|
live_game_calculate_fixture(&g_array_index(acp(i)->fixtures, Fixture, j),
|
||||||
|
&g_array_index(live_games, LiveGame, live_games->len - 1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
live_game_calculate_fixture(&g_array_index(acp(i)->fixtures, Fixture, j),
|
||||||
|
&usr(usr_idx).live_game);
|
||||||
|
|
||||||
done++;
|
done++;
|
||||||
fixture_result_to_buf(&g_array_index(acp(i)->fixtures, Fixture, j),
|
fixture_result_to_buf(&g_array_index(acp(i)->fixtures, Fixture, j),
|
||||||
@ -484,6 +512,25 @@ end_week_round_update_fixtures(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Write newspaper articles after week round. */
|
||||||
|
void
|
||||||
|
end_week_round_generate_news(void)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
/** News for user matches. */
|
||||||
|
for(i = 0; i < users->len; i++)
|
||||||
|
if(usr(i).live_game.fix != NULL &&
|
||||||
|
usr(i).live_game.fix->week_number == week &&
|
||||||
|
usr(i).live_game.fix->week_round_number == week_round)
|
||||||
|
news_generate_match(&usr(i).live_game);
|
||||||
|
|
||||||
|
/** News for other matches. */
|
||||||
|
for(i = 0; i < live_games->len; i++)
|
||||||
|
if(news_check_match_relevant(&g_array_index(live_games, LiveGame, i)))
|
||||||
|
news_generate_match(&g_array_index(live_games, LiveGame, i));
|
||||||
|
}
|
||||||
|
|
||||||
/** Start a new week round. */
|
/** Start a new week round. */
|
||||||
void
|
void
|
||||||
start_week_round(void)
|
start_week_round(void)
|
||||||
|
@ -94,4 +94,7 @@ start_new_season_reset_ids(void);
|
|||||||
void
|
void
|
||||||
start_week_update_leagues(void);
|
start_week_update_leagues(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
end_week_round_generate_news(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -205,7 +205,8 @@ stat_create_season_stat(void)
|
|||||||
|
|
||||||
for(i=0;i<ligs->len;i++)
|
for(i=0;i<ligs->len;i++)
|
||||||
{
|
{
|
||||||
if(!query_league_cup_has_property(lig(i).id, "omit_from_history"))
|
if(!query_league_cup_has_property(lig(i).id, "omit_from_history") &&
|
||||||
|
!query_league_cup_has_property(lig(i).id, "inactive"))
|
||||||
{
|
{
|
||||||
for(j = 0; j < lig(i).tables->len; j++)
|
for(j = 0; j < lig(i).tables->len; j++)
|
||||||
{
|
{
|
||||||
|
@ -845,7 +845,10 @@ treeview_create_game_stats(LiveGame *live_game)
|
|||||||
|
|
||||||
for(k=0;k<LIVE_GAME_STAT_ARRAY_END;k++)
|
for(k=0;k<LIVE_GAME_STAT_ARRAY_END;k++)
|
||||||
{
|
{
|
||||||
if(k == LIVE_GAME_STAT_ARRAY_SCORERS)
|
if(k == LIVE_GAME_STAT_ARRAY_SCORERS)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(k == LIVE_GAME_STAT_ARRAY_SCORERS_FOR_DISPLAY)
|
||||||
{
|
{
|
||||||
strcpy(buf[0], "");
|
strcpy(buf[0], "");
|
||||||
strcpy(buf[1], "");
|
strcpy(buf[1], "");
|
||||||
@ -2395,7 +2398,7 @@ treeview_create_league_stats(GtkListStore *ls, const LeagueStat *league_stat)
|
|||||||
gchar *player_icons[2] = {const_app("string_treeview_league_stats_scorers_icon"),
|
gchar *player_icons[2] = {const_app("string_treeview_league_stats_scorers_icon"),
|
||||||
const_app("string_treeview_league_stats_goalies_icon")};
|
const_app("string_treeview_league_stats_goalies_icon")};
|
||||||
gchar *colour_fg = NULL, *colour_bg = NULL;
|
gchar *colour_fg = NULL, *colour_bg = NULL;
|
||||||
|
|
||||||
gtk_list_store_append(ls, &iter);
|
gtk_list_store_append(ls, &iter);
|
||||||
treeview_helper_insert_icon(ls, &iter, 0,
|
treeview_helper_insert_icon(ls, &iter, 0,
|
||||||
league_stat->league_symbol);
|
league_stat->league_symbol);
|
||||||
|
@ -104,8 +104,8 @@ GArray *name_lists;
|
|||||||
/** The struct containing the window pointers. */
|
/** The struct containing the window pointers. */
|
||||||
Windows window;
|
Windows window;
|
||||||
|
|
||||||
/** The variable for non-user games (which aren't shown). */
|
/** The variables for non-user live games (which aren't shown). */
|
||||||
LiveGame live_game_temp;
|
GArray *live_games;
|
||||||
|
|
||||||
/** The index of the current user in the #users array. */
|
/** The index of the current user in the #users array. */
|
||||||
gint cur_user;
|
gint cur_user;
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#define TAG_ARTICLE_SUBTITLE "subtitle"
|
#define TAG_ARTICLE_SUBTITLE "subtitle"
|
||||||
|
|
||||||
#define ATT_NAME_TEXT_PRIORITY "priority"
|
#define ATT_NAME_TEXT_PRIORITY "priority"
|
||||||
|
#define ATT_NAME_TEXT_CONDITION "condition"
|
||||||
|
|
||||||
#define ARTICLE_TYPE_NAME_MATCH "match"
|
#define ARTICLE_TYPE_NAME_MATCH "match"
|
||||||
#define ARTICLE_TYPE_NAME_FINANCES "finances"
|
#define ARTICLE_TYPE_NAME_FINANCES "finances"
|
||||||
@ -109,6 +110,9 @@ xml_news_read_start_element (GMarkupParseContext *context,
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("xml_news_read_start_element\n");
|
printf("xml_news_read_start_element\n");
|
||||||
#endif
|
#endif
|
||||||
|
gint atidx;
|
||||||
|
|
||||||
|
atidx = 0;
|
||||||
|
|
||||||
if(strcmp(element_name, TAG_NEWS) == 0)
|
if(strcmp(element_name, TAG_NEWS) == 0)
|
||||||
state = STATE_NEWS;
|
state = STATE_NEWS;
|
||||||
@ -119,6 +123,7 @@ xml_news_read_start_element (GMarkupParseContext *context,
|
|||||||
state = STATE_ARTICLE;
|
state = STATE_ARTICLE;
|
||||||
new_article.titles = g_array_new(FALSE, FALSE, sizeof(NewsText));
|
new_article.titles = g_array_new(FALSE, FALSE, sizeof(NewsText));
|
||||||
new_article.subtitles = g_array_new(FALSE, FALSE, sizeof(NewsText));
|
new_article.subtitles = g_array_new(FALSE, FALSE, sizeof(NewsText));
|
||||||
|
new_article.condition = g_strdup("0");
|
||||||
}
|
}
|
||||||
else if(strcmp(element_name, TAG_ARTICLE_TYPE) == 0)
|
else if(strcmp(element_name, TAG_ARTICLE_TYPE) == 0)
|
||||||
state = STATE_ARTICLE_TYPE;
|
state = STATE_ARTICLE_TYPE;
|
||||||
@ -128,19 +133,33 @@ xml_news_read_start_element (GMarkupParseContext *context,
|
|||||||
{
|
{
|
||||||
state = STATE_ARTICLE_TITLE;
|
state = STATE_ARTICLE_TITLE;
|
||||||
new_title.id = news_title_id_new;
|
new_title.id = news_title_id_new;
|
||||||
if(attribute_names[0] != NULL && strcmp(attribute_names[0], ATT_NAME_TEXT_PRIORITY) == 0)
|
new_title.priority = 1;
|
||||||
new_title.priority = (gint)g_ascii_strtod(attribute_values[0], NULL);
|
new_title.condition = g_strdup("1");
|
||||||
else
|
|
||||||
new_title.priority = 1;
|
while(attribute_names[atidx] != NULL)
|
||||||
|
{
|
||||||
|
if(strcmp(attribute_names[atidx], ATT_NAME_TEXT_PRIORITY) == 0)
|
||||||
|
new_title.priority = (gint)g_ascii_strtod(attribute_values[atidx], NULL);
|
||||||
|
else if(strcmp(attribute_names[atidx], ATT_NAME_TEXT_CONDITION) == 0)
|
||||||
|
misc_string_assign(&new_title.condition, attribute_values[atidx]);
|
||||||
|
atidx++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(strcmp(element_name, TAG_ARTICLE_SUBTITLE) == 0)
|
else if(strcmp(element_name, TAG_ARTICLE_SUBTITLE) == 0)
|
||||||
{
|
{
|
||||||
state = STATE_ARTICLE_SUBTITLE;
|
state = STATE_ARTICLE_SUBTITLE;
|
||||||
new_subtitle.id = news_subtitle_id_new;
|
new_subtitle.id = news_subtitle_id_new;
|
||||||
if(attribute_names[0] != NULL && strcmp(attribute_names[0], ATT_NAME_TEXT_PRIORITY) == 0)
|
new_subtitle.priority = 1;
|
||||||
new_subtitle.priority = (gint)g_ascii_strtod(attribute_values[0], NULL);
|
new_subtitle.condition = g_strdup("1");
|
||||||
else
|
|
||||||
new_subtitle.priority = 1;
|
while(attribute_names[atidx] != NULL)
|
||||||
|
{
|
||||||
|
if(strcmp(attribute_names[atidx], ATT_NAME_TEXT_PRIORITY) == 0)
|
||||||
|
new_subtitle.priority = (gint)g_ascii_strtod(attribute_values[atidx], NULL);
|
||||||
|
else if(strcmp(attribute_names[atidx], ATT_NAME_TEXT_CONDITION) == 0)
|
||||||
|
misc_string_assign(&new_subtitle.condition, attribute_values[atidx]);
|
||||||
|
atidx++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
g_warning("xml_news_read_start_element: unknown tag: %s; I'm in state %d\n",
|
g_warning("xml_news_read_start_element: unknown tag: %s; I'm in state %d\n",
|
||||||
@ -206,7 +225,7 @@ xml_news_read_text (GMarkupParseContext *context,
|
|||||||
else if(state == STATE_ARTICLE_TYPE)
|
else if(state == STATE_ARTICLE_TYPE)
|
||||||
article_idx = xml_news_article_type_to_int(buf);
|
article_idx = xml_news_article_type_to_int(buf);
|
||||||
else if(state == STATE_ARTICLE_CONDITION)
|
else if(state == STATE_ARTICLE_CONDITION)
|
||||||
new_article.condition = g_strdup(buf);
|
misc_string_assign(&new_article.condition, buf);
|
||||||
else if(state == STATE_ARTICLE_TITLE)
|
else if(state == STATE_ARTICLE_TITLE)
|
||||||
{
|
{
|
||||||
new_title.text = g_strdup(buf);
|
new_title.text = g_strdup(buf);
|
||||||
|
@ -88,6 +88,11 @@ string_token_cup_round_robin _CUPRR_
|
|||||||
string_token_cup_knockout _CUPKO_
|
string_token_cup_knockout _CUPKO_
|
||||||
string_token_cup_stage _CUPSTAGE_
|
string_token_cup_stage _CUPSTAGE_
|
||||||
string_token_cup_match_winner _CUPMATCHWINNER_
|
string_token_cup_match_winner _CUPMATCHWINNER_
|
||||||
string_token_scorers _SCORERS_
|
string_token_multiple_scorers0 _MULTIPLESCORERS_
|
||||||
string_token_highscorer _HIGHSCORER_
|
string_token_multiple_scorers1 _MULTIPLESCORERS_
|
||||||
string_token_highscorer_goals _HIGHGOALS_
|
string_token_scorers0 _SCORERS0_
|
||||||
|
string_token_highscorer0 _HIGHSCORER0_
|
||||||
|
string_token_highscorer_goals0 _HIGHGOALS0_
|
||||||
|
string_token_scorers1 _SCORERS1_
|
||||||
|
string_token_highscorer1 _HIGHSCORER1_
|
||||||
|
string_token_highscorer_goals1 _HIGHGOALS1_
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
<subtitle>_TW_: _RE_ against _TL_.</subtitle>
|
<subtitle>_TW_: _RE_ against _TL_.</subtitle>
|
||||||
<title priority="15">_LEAGUECUPNAME_: _TL_ loses to _TW_!</title>
|
<title priority="15">_LEAGUECUPNAME_: _TL_ loses to _TW_!</title>
|
||||||
<subtitle priority="15">_TL_ overwhelmed by _SHOTS_TWN__ shots.</subtitle>
|
<subtitle priority="15">_TL_ overwhelmed by _SHOTS_TWN__ shots.</subtitle>
|
||||||
|
<subtitle priority="25" condition="_MULTIPLESCORERS_ = 1">_SCORERS_TWN__ ensure victory for _TW_.</subtitle>
|
||||||
</news_article>
|
</news_article>
|
||||||
|
|
||||||
</news>
|
</news>
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
<subtitle>_TW_ just too strong.</subtitle>
|
<subtitle>_TW_ just too strong.</subtitle>
|
||||||
<title>_TL_ in a world of misery!</title>
|
<title>_TL_ in a world of misery!</title>
|
||||||
<subtitle>_TW_: _RE_ against _TL_.</subtitle>
|
<subtitle>_TW_: _RE_ against _TL_.</subtitle>
|
||||||
|
<title priority="15">_LEAGUECUPNAME_: _TL_ loses to _TW_!</title>
|
||||||
|
<subtitle priority="15">_TL_ overwhelmed by _SHOTS_TWN__ shots.</subtitle>
|
||||||
|
<subtitle priority="25" condition="_MULTIPLESCORERS_ = 1">_SCORERS_TWN__ ensure victory for _TW_.</subtitle>
|
||||||
</news_article>
|
</news_article>
|
||||||
|
|
||||||
</news>
|
</news>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user