1
1
mirror of https://github.com/tstellar/bygfoot.git synced 2025-06-05 21:49:20 +02:00

"Live game corrections."

This commit is contained in:
gyboth
2005-05-19 18:13:14 +00:00
parent d66fdfbd66
commit e770ef07ef
9 changed files with 213 additions and 186 deletions

View File

@ -1349,6 +1349,7 @@
<property name="wrap">False</property> <property name="wrap">False</property>
<property name="adjustment">0 -10 20 1 10 10</property> <property name="adjustment">0 -10 20 1 10 10</property>
<signal name="value_changed" handler="on_spinbutton_speed_value_changed" last_modification_time="Mon, 10 Jan 2005 15:04:50 GMT"/> <signal name="value_changed" handler="on_spinbutton_speed_value_changed" last_modification_time="Mon, 10 Jan 2005 15:04:50 GMT"/>
<signal name="button_press_event" handler="on_spinbutton_speed_button_press_event" last_modification_time="Thu, 19 May 2005 18:01:49 GMT"/>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>

View File

@ -767,7 +767,7 @@ game_update_stats(gpointer live_game, gconstpointer live_game_unit)
stats->values[unit->possession][LIVE_GAME_STAT_VALUE_PENALTIES]++; stats->values[unit->possession][LIVE_GAME_STAT_VALUE_PENALTIES]++;
else if(unit->event.type == LIVE_GAME_EVENT_INJURY) else if(unit->event.type == LIVE_GAME_EVENT_INJURY)
{ {
stats->values[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]][LIVE_GAME_STAT_VALUE_INJURIES]++; stats->values[unit->event.team][LIVE_GAME_STAT_VALUE_INJURIES]++;
game_update_stats_player(live_game, live_game_unit); game_update_stats_player(live_game, live_game_unit);
} }
else if(unit->event.type == LIVE_GAME_EVENT_FOUL || else if(unit->event.type == LIVE_GAME_EVENT_FOUL ||
@ -775,16 +775,16 @@ game_update_stats(gpointer live_game, gconstpointer live_game_unit)
unit->event.type == LIVE_GAME_EVENT_FOUL_RED || unit->event.type == LIVE_GAME_EVENT_FOUL_RED ||
unit->event.type == LIVE_GAME_EVENT_FOUL_RED_INJURY) unit->event.type == LIVE_GAME_EVENT_FOUL_RED_INJURY)
{ {
stats->values[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]][LIVE_GAME_STAT_VALUE_FOULS]++; stats->values[unit->event.team][LIVE_GAME_STAT_VALUE_FOULS]++;
if(unit->event.type == LIVE_GAME_EVENT_FOUL_YELLOW) if(unit->event.type == LIVE_GAME_EVENT_FOUL_YELLOW)
{ {
stats->values[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]][LIVE_GAME_STAT_VALUE_CARDS]++; stats->values[unit->event.team][LIVE_GAME_STAT_VALUE_CARDS]++;
game_update_stats_player(live_game, live_game_unit); game_update_stats_player(live_game, live_game_unit);
} }
} }
else if(unit->event.type == LIVE_GAME_EVENT_SEND_OFF) else if(unit->event.type == LIVE_GAME_EVENT_SEND_OFF)
{ {
stats->values[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]][LIVE_GAME_STAT_VALUE_REDS]++; stats->values[unit->event.team][LIVE_GAME_STAT_VALUE_REDS]++;
game_update_stats_player(live_game, live_game_unit); game_update_stats_player(live_game, live_game_unit);
} }
else if(unit->event.type == LIVE_GAME_EVENT_GOAL || else if(unit->event.type == LIVE_GAME_EVENT_GOAL ||
@ -792,7 +792,7 @@ game_update_stats(gpointer live_game, gconstpointer live_game_unit)
{ {
if(live_game_unit_before(unit, -1)->event.type != LIVE_GAME_EVENT_PENALTY && if(live_game_unit_before(unit, -1)->event.type != LIVE_GAME_EVENT_PENALTY &&
unit->event.type != LIVE_GAME_EVENT_OWN_GOAL) unit->event.type != LIVE_GAME_EVENT_OWN_GOAL)
stats->values[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]][LIVE_GAME_STAT_VALUE_GOALS_REGULAR]++; stats->values[unit->event.team][LIVE_GAME_STAT_VALUE_GOALS_REGULAR]++;
game_update_stats_player(live_game, live_game_unit); game_update_stats_player(live_game, live_game_unit);
} }
@ -817,9 +817,9 @@ game_update_stats_player(gpointer live_game, gconstpointer live_game_unit)
const LiveGameUnit *unit = (const LiveGameUnit*)live_game_unit; const LiveGameUnit *unit = (const LiveGameUnit*)live_game_unit;
gint minute = live_game_unit_get_minute(unit), array_index = -1; gint minute = live_game_unit_get_minute(unit), array_index = -1;
gboolean own_goal; gboolean own_goal;
gint team = unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM], gint team = unit->event.team,
player = unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER], player = unit->event.player,
player2 = unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER2]; player2 = unit->event.player2;
const Team *tm[2] = {((LiveGame*)live_game)->fix->teams[0], const Team *tm[2] = {((LiveGame*)live_game)->fix->teams[0],
((LiveGame*)live_game)->fix->teams[1]}; ((LiveGame*)live_game)->fix->teams[1]};
GString *new = NULL; GString *new = NULL;

View File

@ -344,16 +344,16 @@ lg_commentary_set_strings(gchar *strings[][2], const LiveGameUnit *unit, const F
fix->teams[(unit->result[0] < unit->result[1])]->name->str; fix->teams[(unit->result[0] < unit->result[1])]->name->str;
strings[LG_TOKEN_TEAM][0] = const_str("string_lg_commentary_token_team"); strings[LG_TOKEN_TEAM][0] = const_str("string_lg_commentary_token_team");
strings[LG_TOKEN_TEAM][1] = (unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM] == -1) ? strings[LG_TOKEN_TEAM][1] = (unit->event.team == -1) ?
NULL : fix->teams[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str; NULL : fix->teams[unit->event.team]->name->str;
strings[LG_TOKEN_PLAYER1][0] = const_str("string_lg_commentary_token_player1"); strings[LG_TOKEN_PLAYER1][0] = const_str("string_lg_commentary_token_player1");
strings[LG_TOKEN_PLAYER1][1] = (unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER] == -1) ? strings[LG_TOKEN_PLAYER1][1] = (unit->event.player == -1) ?
NULL : lg_commentary_get_player_name(unit, fix, LIVE_GAME_EVENT_VALUE_PLAYER); NULL : lg_commentary_get_player_name(unit, fix, FALSE);
strings[LG_TOKEN_PLAYER2][0] = const_str("string_lg_commentary_token_player2"); strings[LG_TOKEN_PLAYER2][0] = const_str("string_lg_commentary_token_player2");
strings[LG_TOKEN_PLAYER2][1] = (unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] == -1) ? strings[LG_TOKEN_PLAYER2][1] = (unit->event.player2 == -1) ?
NULL : lg_commentary_get_player_name(unit, fix, LIVE_GAME_EVENT_VALUE_PLAYER2); NULL : lg_commentary_get_player_name(unit, fix, TRUE);
strings[LG_TOKEN_ATTENDANCE][0] = const_str("string_lg_commentary_token_attendance"); strings[LG_TOKEN_ATTENDANCE][0] = const_str("string_lg_commentary_token_attendance");
misc_print_grouped_int(fix->attendance, buf, FALSE); misc_print_grouped_int(fix->attendance, buf, FALSE);
@ -374,38 +374,34 @@ lg_commentary_set_strings(gchar *strings[][2], const LiveGameUnit *unit, const F
/** Return the name of a player involved in the unit (or NULL). /** Return the name of a player involved in the unit (or NULL).
@param player Which player we look for. */ @param player Which player we look for. */
gchar* gchar*
lg_commentary_get_player_name(const LiveGameUnit *unit, const Fixture *fix, gint player) lg_commentary_get_player_name(const LiveGameUnit *unit, const Fixture *fix, gboolean player2)
{ {
gchar *return_value = NULL; gchar *return_value = NULL;
if(unit->event.type == LIVE_GAME_EVENT_GENERAL) if(unit->event.type == LIVE_GAME_EVENT_GENERAL)
return_value = return_value = (player2) ?
player_of_id_team(fix->teams[unit->possession], player_of_id_team(fix->teams[unit->possession],
unit->event.values[player])->name->str; unit->event.player2)->name->str :
player_of_id_team(fix->teams[unit->possession],
unit->event.player)->name->str;
else if(unit->event.type == LIVE_GAME_EVENT_LOST_POSSESSION) else if(unit->event.type == LIVE_GAME_EVENT_LOST_POSSESSION)
{ {
if(player == LIVE_GAME_EVENT_VALUE_PLAYER) return_value = (player2) ?
return_value = player_of_id_team(fix->teams[!unit->possession],
player_of_id_team(fix->teams[unit->possession], unit->event.player2)->name->str:
unit->event.values[player])->name->str; player_of_id_team(fix->teams[unit->possession],
else unit->event.player)->name->str;
return_value =
player_of_id_team(fix->teams[!unit->possession],
unit->event.values[player])->name->str;
} }
else if(unit->event.type == LIVE_GAME_EVENT_SCORING_CHANCE || else if(unit->event.type == LIVE_GAME_EVENT_SCORING_CHANCE ||
unit->event.type == LIVE_GAME_EVENT_HEADER || unit->event.type == LIVE_GAME_EVENT_HEADER ||
unit->event.type == LIVE_GAME_EVENT_PENALTY || unit->event.type == LIVE_GAME_EVENT_PENALTY ||
unit->event.type == LIVE_GAME_EVENT_FREE_KICK) unit->event.type == LIVE_GAME_EVENT_FREE_KICK)
{ {
if(player == LIVE_GAME_EVENT_VALUE_PLAYER) return_value = (player2) ?
return_value = player_of_id_team(fix->teams[unit->possession],
player_of_id_team(fix->teams[unit->possession], unit->event.player2)->name->str :
unit->event.values[player])->name->str; player_of_id_team(fix->teams[unit->possession],
else unit->event.player)->name->str;
return_value =
player_of_id_team(fix->teams[unit->possession],
unit->event.values[player])->name->str;
} }
else if(unit->event.type == LIVE_GAME_EVENT_GOAL || else if(unit->event.type == LIVE_GAME_EVENT_GOAL ||
unit->event.type == LIVE_GAME_EVENT_MISSED || unit->event.type == LIVE_GAME_EVENT_MISSED ||
@ -413,40 +409,36 @@ lg_commentary_get_player_name(const LiveGameUnit *unit, const Fixture *fix, gint
unit->event.type == LIVE_GAME_EVENT_POST || unit->event.type == LIVE_GAME_EVENT_POST ||
unit->event.type == LIVE_GAME_EVENT_CROSS_BAR) unit->event.type == LIVE_GAME_EVENT_CROSS_BAR)
{ {
if(player == LIVE_GAME_EVENT_VALUE_PLAYER) return_value = (player2) ?
return_value = player_of_id_team(fix->teams[!unit->possession],
player_of_id_team(fix->teams[unit->possession], unit->event.player2)->name->str :
unit->event.values[player])->name->str; player_of_id_team(fix->teams[unit->possession],
else unit->event.player)->name->str;
return_value =
player_of_id_team(fix->teams[!unit->possession],
unit->event.values[player])->name->str;
} }
else if(unit->event.type == LIVE_GAME_EVENT_OWN_GOAL) else if(unit->event.type == LIVE_GAME_EVENT_OWN_GOAL)
return_value = return_value =
player_of_id_team(fix->teams[!unit->possession], player_of_id_team(fix->teams[!unit->possession],
unit->event.values[player])->name->str; unit->event.player)->name->str;
else if(unit->event.type == LIVE_GAME_EVENT_FOUL || 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 ||
unit->event.type == LIVE_GAME_EVENT_FOUL_RED_INJURY || unit->event.type == LIVE_GAME_EVENT_FOUL_RED_INJURY ||
unit->event.type == LIVE_GAME_EVENT_FOUL_YELLOW) unit->event.type == LIVE_GAME_EVENT_FOUL_YELLOW)
{ {
if(player == LIVE_GAME_EVENT_VALUE_PLAYER) return_value = (player2) ?
return_value = player_of_id_team(fix->teams[unit->event.team],
player_of_id_team(fix->teams[!unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]], unit->event.player2)->name->str :
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER])->name->str; player_of_id_team(fix->teams[!unit->event.team],
else unit->event.player)->name->str;
return_value =
player_of_id_team(fix->teams[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER2])->name->str;
} }
else if(unit->event.type == LIVE_GAME_EVENT_SEND_OFF || else if(unit->event.type == LIVE_GAME_EVENT_SEND_OFF ||
unit->event.type == LIVE_GAME_EVENT_INJURY || unit->event.type == LIVE_GAME_EVENT_INJURY ||
unit->event.type == LIVE_GAME_EVENT_TEMP_INJURY || unit->event.type == LIVE_GAME_EVENT_TEMP_INJURY ||
unit->event.type == LIVE_GAME_EVENT_SUBSTITUTION) unit->event.type == LIVE_GAME_EVENT_SUBSTITUTION)
return_value = return_value = (player2) ?
player_of_id_team(fix->teams[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]], player_of_id_team(fix->teams[unit->event.team],
unit->event.values[player])->name->str; unit->event.player2)->name->str :
player_of_id_team(fix->teams[unit->event.team],
unit->event.player)->name->str;
else else
g_warning("lg_commentary_get_player_name: unknown event type %d\n", g_warning("lg_commentary_get_player_name: unknown event type %d\n",
unit->event.type); unit->event.type);
@ -467,7 +459,7 @@ lg_commentary_get_extra_data(const LiveGameUnit *unit, const Fixture *fix)
break; break;
case LIVE_GAME_EVENT_STRUCTURE_CHANGE: case LIVE_GAME_EVENT_STRUCTURE_CHANGE:
sprintf(buf, "%d", sprintf(buf, "%d",
fix->teams[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->structure); fix->teams[unit->event.team]->structure);
break; break;
case LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_DEFEND: case LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_DEFEND:
strcpy(buf, "ALL OUT DEFEND"); strcpy(buf, "ALL OUT DEFEND");

View File

@ -99,9 +99,9 @@ live_game_create_unit(void)
new.minute = live_game_get_minute(); new.minute = live_game_get_minute();
new.time = live_game_get_time(&last_unit); new.time = live_game_get_time(&last_unit);
new.event.commentary = NULL; new.event.commentary = NULL;
new.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = new.event.team =
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = new.event.player =
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = -1; new.event.player2 = -1;
new.area = last_unit.area; new.area = last_unit.area;
new.result[0] = last_unit.result[0]; new.result[0] = last_unit.result[0];
new.result[1] = last_unit.result[1]; new.result[1] = last_unit.result[1];
@ -201,8 +201,8 @@ live_game_create_start_unit(void)
if(debug > 100 && fixture_user_team_involved(match->fix) != -1) if(debug > 100 && fixture_user_team_involved(match->fix) != -1)
printf("\t\tlive_game_create_start_unit\n"); printf("\t\tlive_game_create_start_unit\n");
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = new.event.player =
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = -1; new.event.player2 = -1;
new.event.commentary = NULL; new.event.commentary = NULL;
new.minute = 0; new.minute = 0;
@ -213,7 +213,7 @@ live_game_create_start_unit(void)
new.result[0] = new.result[1] = 0; new.result[0] = new.result[1] = 0;
new.event.type = LIVE_GAME_EVENT_START_MATCH; new.event.type = LIVE_GAME_EVENT_START_MATCH;
new.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = new.possession; new.event.team = new.possession;
g_array_append_val(unis, new); g_array_append_val(unis, new);
} }
@ -275,26 +275,26 @@ live_game_event_foul(void)
game_get_foul_possession_factor( game_get_foul_possession_factor(
tm[last_unit.possession]->boost, tm[!last_unit.possession]->boost)) tm[last_unit.possession]->boost, tm[!last_unit.possession]->boost))
{ {
foul_team = last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = !last_unit.possession; foul_team = last_unit.event.team = !last_unit.possession;
if(uni(unis->len - 2).event.type == LIVE_GAME_EVENT_GENERAL) if(uni(unis->len - 2).event.type == LIVE_GAME_EVENT_GENERAL)
fouled_player = last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = fouled_player = last_unit.event.player =
uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER]; uni(unis->len - 2).event.player;
else else
fouled_player = last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = fouled_player = last_unit.event.player =
game_get_player(tm[last_unit.possession], game_get_player(tm[last_unit.possession],
last_unit.area, 0, -1, FALSE); last_unit.area, 0, -1, FALSE);
foul_player = last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = foul_player = last_unit.event.player2 =
game_get_player(tm[!last_unit.possession], game_get_player(tm[!last_unit.possession],
last_unit.area, 0, -1, FALSE); last_unit.area, 0, -1, FALSE);
} }
else else
{ {
foul_team = last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = last_unit.possession; foul_team = last_unit.event.team = last_unit.possession;
fouled_player = last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = fouled_player = last_unit.event.player =
game_get_player(tm[!last_unit.possession], game_get_player(tm[!last_unit.possession],
last_unit.area, 0, -1, FALSE); last_unit.area, 0, -1, FALSE);
foul_player = last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = foul_player = last_unit.event.player2 =
game_get_player(tm[last_unit.possession], game_get_player(tm[last_unit.possession],
last_unit.area, 0, -1, FALSE); last_unit.area, 0, -1, FALSE);
} }
@ -347,15 +347,15 @@ live_game_event_lost_possession(void)
{ {
if(debug > 100 && fixture_user_team_involved(match->fix) != -1) if(debug > 100 && fixture_user_team_involved(match->fix) != -1)
printf("\t\tlive_game_event_lost_possession\n"); printf("\t\tlive_game_event_lost_possession\n");
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = last_unit.event.player =
game_get_player(tm[last_unit.possession], game_get_player(tm[last_unit.possession],
last_unit.area, 0, -1, TRUE); last_unit.area, 0, -1, TRUE);
if(uni(unis->len - 2).event.type == LIVE_GAME_EVENT_GENERAL) if(uni(unis->len - 2).event.type == LIVE_GAME_EVENT_GENERAL)
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = last_unit.event.player2 =
uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER]; uni(unis->len - 2).event.player;
else else
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = last_unit.event.player2 =
game_get_player(tm[!last_unit.possession], game_get_player(tm[!last_unit.possession],
uni(unis->len - 2).area, 0, -1, FALSE); uni(unis->len - 2).area, 0, -1, FALSE);
@ -383,9 +383,9 @@ live_game_event_injury(gint team, gint player, gboolean create_new)
new = last_unit; new = last_unit;
new.event.commentary = NULL; new.event.commentary = NULL;
g_array_append_val(unis, new); g_array_append_val(unis, new);
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = last_unit.event.player =
player; player;
last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = last_unit.event.team =
team; team;
} }
else else
@ -399,11 +399,11 @@ live_game_event_injury(gint team, gint player, gboolean create_new)
last_unit.event.type = LIVE_GAME_EVENT_TEMP_INJURY; last_unit.event.type = LIVE_GAME_EVENT_TEMP_INJURY;
if(debug < 50 || if(debug < 50 ||
team_is_user(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]) == -1) team_is_user(tm[last_unit.event.team]) == -1)
player_of_id_team(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]], player_of_id_team(tm[last_unit.event.team],
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER])->fitness = last_unit.event.player)->fitness =
MAX(0, player_of_id_team(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]], MAX(0, player_of_id_team(tm[last_unit.event.team],
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER])->fitness - last_unit.event.player)->fitness -
math_rnd(const_float("float_live_game_temp_injury_fitness_decrease_lower"), math_rnd(const_float("float_live_game_temp_injury_fitness_decrease_lower"),
const_float("float_live_game_temp_injury_fitness_decrease_upper"))); const_float("float_live_game_temp_injury_fitness_decrease_upper")));
} }
@ -411,39 +411,39 @@ live_game_event_injury(gint team, gint player, gboolean create_new)
live_game_finish_unit(); live_game_finish_unit();
if(debug >= 50 && if(debug >= 50 &&
team_is_user(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]) != -1) team_is_user(tm[last_unit.event.team]) != -1)
return; return;
if(last_unit.event.type == LIVE_GAME_EVENT_INJURY) if(last_unit.event.type == LIVE_GAME_EVENT_INJURY)
{ {
game_player_injury(player_of_id_team(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]], game_player_injury(player_of_id_team(tm[last_unit.event.team],
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER])); last_unit.event.player));
if(match->subs_left[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]] > 0) if(match->subs_left[last_unit.event.team] > 0)
{ {
if(show && if(show &&
team_is_user(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]) != -1 && team_is_user(tm[last_unit.event.team]) != -1 &&
((option_int("int_opt_user_pause_injury", ((option_int("int_opt_user_pause_injury",
&usr(team_is_user(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]])).options) && &usr(team_is_user(tm[last_unit.event.team])).options) &&
!option_int("int_opt_user_auto_sub", !option_int("int_opt_user_auto_sub",
&usr(team_is_user(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]])).options)) || &usr(team_is_user(tm[last_unit.event.team])).options)) ||
tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->players->len == 11)) tm[last_unit.event.team]->players->len == 11))
misc_callback_pause_live_game(); misc_callback_pause_live_game();
else if(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->players->len > 11) else if(tm[last_unit.event.team]->players->len > 11)
{ {
old_structure = tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->structure; old_structure = tm[last_unit.event.team]->structure;
live_game_event_substitution( live_game_event_substitution(
last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM], last_unit.event.team,
game_substitute_player( game_substitute_player(
tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]], tm[last_unit.event.team],
player_id_index(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]], player_id_index(tm[last_unit.event.team],
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER])), last_unit.event.player)),
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER]); last_unit.event.player);
match->subs_left[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]--; match->subs_left[last_unit.event.team]--;
if(old_structure != tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->structure) if(old_structure != tm[last_unit.event.team]->structure)
live_game_event_team_change(last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM], live_game_event_team_change(last_unit.event.team,
LIVE_GAME_EVENT_STRUCTURE_CHANGE); LIVE_GAME_EVENT_STRUCTURE_CHANGE);
} }
} }
@ -503,42 +503,42 @@ live_game_event_scoring_chance(void)
if(math_rnd(0, 1) < const_float("float_live_game_scoring_chance_is_own_goal")) if(math_rnd(0, 1) < const_float("float_live_game_scoring_chance_is_own_goal"))
{ {
last_unit.event.type = LIVE_GAME_EVENT_OWN_GOAL; last_unit.event.type = LIVE_GAME_EVENT_OWN_GOAL;
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = last_unit.event.player =
game_get_player(tm[!last_unit.possession], GAME_PLAYER_TYPE_DEFEND, 0, -1, FALSE); game_get_player(tm[!last_unit.possession], GAME_PLAYER_TYPE_DEFEND, 0, -1, FALSE);
last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = !last_unit.possession; last_unit.event.team = !last_unit.possession;
match->fix->result[last_unit.possession][res_idx]++; match->fix->result[last_unit.possession][res_idx]++;
last_unit.result[last_unit.possession]++; last_unit.result[last_unit.possession]++;
} }
else else
{ {
if(uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER] != -1 && if(uni(unis->len - 2).event.player != -1 &&
math_rnd(0, 1) < const_float("float_live_game_player_in_poss_shoots") && math_rnd(0, 1) < const_float("float_live_game_player_in_poss_shoots") &&
player_id_team(uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER]) == player_id_team(uni(unis->len - 2).event.player) ==
tm[last_unit.possession]) tm[last_unit.possession])
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = last_unit.event.player =
uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER]; uni(unis->len - 2).event.player;
else else
{ {
if(uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER] != -1 && if(uni(unis->len - 2).event.player != -1 &&
player_id_team(uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER]) == player_id_team(uni(unis->len - 2).event.player) ==
tm[last_unit.possession]) tm[last_unit.possession])
{ {
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = last_unit.event.player =
game_get_player(tm[last_unit.possession], last_unit.area, 0, game_get_player(tm[last_unit.possession], last_unit.area, 0,
uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER], uni(unis->len - 2).event.player,
TRUE); TRUE);
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = last_unit.event.player2 =
uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER]; uni(unis->len - 2).event.player;
} }
else else
{ {
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = last_unit.event.player =
game_get_player(tm[last_unit.possession], last_unit.area, 0, -1, TRUE); game_get_player(tm[last_unit.possession], last_unit.area, 0, -1, TRUE);
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = last_unit.event.player2 =
game_get_player(tm[last_unit.possession], last_unit.area, 0, game_get_player(tm[last_unit.possession], last_unit.area, 0,
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER], TRUE); last_unit.event.player, TRUE);
} }
} }
@ -571,43 +571,43 @@ live_game_event_penalty(void)
g_array_append_val(unis, new); g_array_append_val(unis, new);
} }
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = last_unit.event.player2 =
last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = -1; last_unit.event.team = -1;
if(last_unit.time == LIVE_GAME_UNIT_TIME_PENALTIES) if(last_unit.time == LIVE_GAME_UNIT_TIME_PENALTIES)
{ {
if(uni(unis->len - 2).event.type == LIVE_GAME_EVENT_PENALTIES) if(uni(unis->len - 2).event.type == LIVE_GAME_EVENT_PENALTIES)
{ {
last_unit.possession = math_rndi(0, 1); last_unit.possession = math_rndi(0, 1);
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = last_unit.event.player =
game_get_player(tm[last_unit.possession], game_get_player(tm[last_unit.possession],
GAME_PLAYER_TYPE_PENALTY, -1, -1, FALSE); GAME_PLAYER_TYPE_PENALTY, -1, -1, FALSE);
} }
else if(uni(unis->len - 4).event.type == LIVE_GAME_EVENT_PENALTIES) else if(uni(unis->len - 4).event.type == LIVE_GAME_EVENT_PENALTIES)
{ {
last_unit.possession = !uni(unis->len - 3).possession; last_unit.possession = !uni(unis->len - 3).possession;
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = last_unit.event.player =
game_get_player(tm[last_unit.possession], game_get_player(tm[last_unit.possession],
GAME_PLAYER_TYPE_PENALTY, -1, -1, FALSE); GAME_PLAYER_TYPE_PENALTY, -1, -1, FALSE);
} }
else else
{ {
last_unit.possession = !uni(unis->len - 3).possession; last_unit.possession = !uni(unis->len - 3).possession;
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = last_unit.event.player =
game_get_player(tm[last_unit.possession], game_get_player(tm[last_unit.possession],
GAME_PLAYER_TYPE_PENALTY, GAME_PLAYER_TYPE_PENALTY,
uni(unis->len - 4).event.values[LIVE_GAME_EVENT_VALUE_PLAYER], -1, FALSE); uni(unis->len - 4).event.player, -1, FALSE);
} }
} }
else else
{ {
last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = last_unit.event.team =
last_unit.possession; last_unit.possession;
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = last_unit.event.player =
game_get_default_penalty_shooter(tm[last_unit.possession]); game_get_default_penalty_shooter(tm[last_unit.possession]);
if(last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] == -1) if(last_unit.event.player == -1)
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = last_unit.event.player =
game_get_player(tm[last_unit.possession], GAME_PLAYER_TYPE_PENALTY, -1, -1, FALSE); game_get_player(tm[last_unit.possession], GAME_PLAYER_TYPE_PENALTY, -1, -1, FALSE);
} }
@ -633,7 +633,7 @@ live_game_event_general(gboolean create_new)
new.event.commentary = NULL; new.event.commentary = NULL;
new.result[0] = last_unit.result[0]; new.result[0] = last_unit.result[0];
new.result[1] = last_unit.result[1]; new.result[1] = last_unit.result[1];
new.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = -1; new.event.team = -1;
if(last_unit.event.type == LIVE_GAME_EVENT_GENERAL || if(last_unit.event.type == LIVE_GAME_EVENT_GENERAL ||
last_unit.event.type == LIVE_GAME_EVENT_START_MATCH || last_unit.event.type == LIVE_GAME_EVENT_START_MATCH ||
@ -697,10 +697,10 @@ live_game_event_general(gboolean create_new)
void void
live_game_event_general_get_players(void) live_game_event_general_get_players(void)
{ {
gint *pl1 = &last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER]; gint *pl1 = &last_unit.event.player;
gint *pl2 = &last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2]; gint *pl2 = &last_unit.event.player2;
gint old_pl1 = gint old_pl1 =
uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER]; uni(unis->len - 2).event.player;
gint type = uni(unis->len - 2).event.type; gint type = uni(unis->len - 2).event.type;
if(debug > 100 && fixture_user_team_involved(match->fix) != -1) if(debug > 100 && fixture_user_team_involved(match->fix) != -1)
@ -738,21 +738,21 @@ live_game_event_free_kick(void)
if(debug > 100 && fixture_user_team_involved(match->fix) != -1) if(debug > 100 && fixture_user_team_involved(match->fix) != -1)
printf("\t\tlive_game_event_free_kick\n"); printf("\t\tlive_game_event_free_kick\n");
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = new.event.player =
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = -1; new.event.player2 = -1;
new.minute = -1; new.minute = -1;
new.event.type = LIVE_GAME_EVENT_FREE_KICK; new.event.type = LIVE_GAME_EVENT_FREE_KICK;
new.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = new.event.team =
new.possession; new.possession;
new.event.commentary = NULL; new.event.commentary = NULL;
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = new.event.player =
game_get_default_penalty_shooter(tm[new.possession]); game_get_default_penalty_shooter(tm[new.possession]);
if(new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] == -1) if(new.event.player == -1)
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = new.event.player =
game_get_player(tm[new.possession], new.area, 0, -1, TRUE); game_get_player(tm[new.possession], new.area, 0, -1, TRUE);
g_array_append_val(unis, new); g_array_append_val(unis, new);
@ -771,14 +771,14 @@ live_game_event_send_off(gint team, gint player, gboolean second_yellow)
if(debug > 100 && fixture_user_team_involved(match->fix) != -1) if(debug > 100 && fixture_user_team_involved(match->fix) != -1)
printf("\t\tlive_game_event_send_off\n"); printf("\t\tlive_game_event_send_off\n");
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = new.event.player =
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = -1; new.event.player2 = -1;
new.minute = -1; new.minute = -1;
new.event.type = LIVE_GAME_EVENT_SEND_OFF; new.event.type = LIVE_GAME_EVENT_SEND_OFF;
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = player; new.event.player = player;
new.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = team; new.event.team = team;
new.event.commentary = NULL; new.event.commentary = NULL;
g_array_append_val(unis, new); g_array_append_val(unis, new);
@ -855,9 +855,9 @@ live_game_event_substitution(gint team_number, gint sub_in, gint sub_out)
new.event.commentary = NULL; new.event.commentary = NULL;
new.event.type = LIVE_GAME_EVENT_SUBSTITUTION; new.event.type = LIVE_GAME_EVENT_SUBSTITUTION;
new.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = team_number; new.event.team = team_number;
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = sub_in; new.event.player = sub_in;
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = sub_out; new.event.player2 = sub_out;
if(player_of_id_team(tm[team_number], sub_in)->cskill > 0) if(player_of_id_team(tm[team_number], sub_in)->cskill > 0)
@ -884,9 +884,9 @@ live_game_event_team_change(gint team_number, gint event_type)
new.time = live_game_get_time(&last_unit); new.time = live_game_get_time(&last_unit);
new.event.commentary = NULL; new.event.commentary = NULL;
new.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = team_number; new.event.team = team_number;
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = new.event.player =
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = -1; new.event.player2 = -1;
new.event.type = event_type; new.event.type = event_type;
g_array_append_val(unis, new); g_array_append_val(unis, new);
@ -909,14 +909,14 @@ live_game_event_duel(void)
printf("\t\tlive_game_event_duel\n"); printf("\t\tlive_game_event_duel\n");
new.minute = -1; new.minute = -1;
new.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = new.possession; new.event.team = new.possession;
new.event.commentary = NULL; new.event.commentary = NULL;
attacker = player_of_id_team(tm[new.possession], attacker = player_of_id_team(tm[new.possession],
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER]); new.event.player);
goalie = player_of_idx_team(tm[!new.possession], 0); goalie = player_of_idx_team(tm[!new.possession], 0);
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = goalie->id; new.event.player2 = goalie->id;
duel_factor = player_get_game_skill(attacker, FALSE) / duel_factor = player_get_game_skill(attacker, FALSE) /
player_get_game_skill(goalie, FALSE); player_get_game_skill(goalie, FALSE);
@ -984,7 +984,7 @@ query_live_game_second_yellow(gint team, gint player)
for(i=0;i<unis->len - 1;i++) for(i=0;i<unis->len - 1;i++)
if(uni(i).event.type == LIVE_GAME_EVENT_FOUL_YELLOW && if(uni(i).event.type == LIVE_GAME_EVENT_FOUL_YELLOW &&
uni(i).possession != team && uni(i).possession != team &&
uni(i).event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] == player) uni(i).event.player2 == player)
return TRUE; return TRUE;
return FALSE; return FALSE;
@ -1247,9 +1247,9 @@ live_game_finish_unit(void)
if(debug > 100 && fixture_user_team_involved(match->fix) != -1) if(debug > 100 && fixture_user_team_involved(match->fix) != -1)
printf("OOOO1 idx %d type %d poss %d team %d pl %d %d\n", unis->len - 1, printf("OOOO1 idx %d type %d poss %d team %d pl %d %d\n", unis->len - 1,
unit->event.type, unit->possession, unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM], unit->event.type, unit->possession, unit->event.team,
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER], unit->event.player,
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER2]); unit->event.player2);
if(unit->minute != -1 && unit->time != LIVE_GAME_UNIT_TIME_PENALTIES && if(unit->minute != -1 && unit->time != LIVE_GAME_UNIT_TIME_PENALTIES &&
fixture_user_team_involved(match->fix) != -1) fixture_user_team_involved(match->fix) != -1)
@ -1283,9 +1283,9 @@ live_game_finish_unit(void)
if(debug > 100 && fixture_user_team_involved(match->fix) != -1) if(debug > 100 && fixture_user_team_involved(match->fix) != -1)
printf("OOOO idx %d type %d poss %d team %d pl %d %d\n", unis->len - 1, printf("OOOO idx %d type %d poss %d team %d pl %d %d\n", unis->len - 1,
unit->event.type, unit->possession, unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM], unit->event.type, unit->possession, unit->event.team,
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER], unit->event.player,
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER2]); unit->event.player2);
} }
/** Find a random player (influenced by fitness) who gets /** Find a random player (influenced by fitness) who gets
@ -1323,17 +1323,17 @@ live_game_injury_get_player(void)
if(rndom < probs[0]) if(rndom < probs[0])
{ {
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = last_unit.event.player =
player_of_idx_team(tm0, 0)->id; player_of_idx_team(tm0, 0)->id;
last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = 0; last_unit.event.team = 0;
} }
else else
for(i=1;i<22;i++) for(i=1;i<22;i++)
if(probs[i - 1] <= rndom && rndom < probs[i]) if(probs[i - 1] <= rndom && rndom < probs[i])
{ {
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = last_unit.event.player =
player_of_idx_team(tm[(i > 10)], i % 11)->id; player_of_idx_team(tm[(i > 10)], i % 11)->id;
last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = (i > 10); last_unit.event.team = (i > 10);
} }
} }

View File

@ -55,16 +55,6 @@ enum LiveGameEventType
LIVE_GAME_EVENT_END LIVE_GAME_EVENT_END
}; };
/** Indices for the int_values in the
#LiveGameEvent struct. */
enum LiveGameEventValue
{
LIVE_GAME_EVENT_VALUE_TEAM = 0,
LIVE_GAME_EVENT_VALUE_PLAYER,
LIVE_GAME_EVENT_VALUE_PLAYER2,
LIVE_GAME_EVENT_VALUE_END
};
enum LiveGameUnitArea enum LiveGameUnitArea
{ {
LIVE_GAME_UNIT_AREA_DEFEND = 0, LIVE_GAME_UNIT_AREA_DEFEND = 0,
@ -137,9 +127,9 @@ typedef struct
/** Verbosity value. The lower the more important /** Verbosity value. The lower the more important
the event. */ the event. */
gint verbosity; gint verbosity;
/** @see #LiveGameEventValue1 /** Information about a team and two players
@see #LiveGameEventValue2 */ involved in the event. */
gint values[LIVE_GAME_EVENT_VALUE_END]; gint team, player, player2;
/** The commentary for the event. */ /** The commentary for the event. */
GString *commentary; GString *commentary;

View File

@ -327,3 +327,28 @@ on_combo_country_changed (GtkComboBox *combobox,
misc_callback_show_team_list(GTK_WIDGET(combobox), buf); misc_callback_show_team_list(GTK_WIDGET(combobox), buf);
g_free(buf); g_free(buf);
} }
gboolean
on_spinbutton_speed_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data)
{
if(event->button == 3)
{
if(option_int("int_opt_user_live_game_speed", &usr(stat2).options) == -10)
option_set_int("int_opt_user_live_game_speed", &usr(stat2).options, 20);
else if(option_int("int_opt_user_live_game_speed", &usr(stat2).options) == 20)
option_set_int("int_opt_user_live_game_speed", &usr(stat2).options, 0);
else
option_set_int("int_opt_user_live_game_speed", &usr(stat2).options, -10);
gtk_spin_button_set_value(
GTK_SPIN_BUTTON(lookup_widget(window.live, "spinbutton_speed")),
(gdouble)option_int("int_opt_user_live_game_speed", &usr(stat2).options));
return TRUE;
}
return FALSE;
}

View File

@ -122,8 +122,13 @@ on_window_stadium_delete_event (GtkWidget *widget,
void void
on_combo_country_changed (GtkComboBox *combobox, on_combo_country_changed (GtkComboBox *combobox,
gpointer user_data); gpointer user_data);
#endif
void void
on_spinbutton_verbosity_value_changed (GtkSpinButton *spinbutton, on_spinbutton_verbosity_value_changed (GtkSpinButton *spinbutton,
gpointer user_data); gpointer user_data);
gboolean
on_spinbutton_speed_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
#endif

View File

@ -773,6 +773,9 @@ create_window_live (void)
g_signal_connect ((gpointer) spinbutton_speed, "value_changed", g_signal_connect ((gpointer) spinbutton_speed, "value_changed",
G_CALLBACK (on_spinbutton_speed_value_changed), G_CALLBACK (on_spinbutton_speed_value_changed),
NULL); NULL);
g_signal_connect ((gpointer) spinbutton_speed, "button_press_event",
G_CALLBACK (on_spinbutton_speed_button_press_event),
NULL);
g_signal_connect ((gpointer) spinbutton_verbosity, "value_changed", g_signal_connect ((gpointer) spinbutton_verbosity, "value_changed",
G_CALLBACK (on_spinbutton_verbosity_value_changed), G_CALLBACK (on_spinbutton_verbosity_value_changed),
NULL); NULL);

View File

@ -22,8 +22,11 @@ enum
TAG_LIVE_GAME_UNIT_RESULT, TAG_LIVE_GAME_UNIT_RESULT,
TAG_LIVE_GAME_UNIT_EVENT, TAG_LIVE_GAME_UNIT_EVENT,
TAG_LIVE_GAME_UNIT_EVENT_TYPE, TAG_LIVE_GAME_UNIT_EVENT_TYPE,
TAG_LIVE_GAME_UNIT_EVENT_VALUE, TAG_LIVE_GAME_UNIT_EVENT_TEAM,
TAG_LIVE_GAME_UNIT_EVENT_PLAYER,
TAG_LIVE_GAME_UNIT_EVENT_PLAYER2,
TAG_LIVE_GAME_UNIT_EVENT_COMMENTARY, TAG_LIVE_GAME_UNIT_EVENT_COMMENTARY,
TAG_LIVE_GAME_UNIT_EVENT_VERBOSITY,
TAG_LIVE_GAME_STAT, TAG_LIVE_GAME_STAT,
TAG_LIVE_GAME_STAT_POSSESSION, TAG_LIVE_GAME_STAT_POSSESSION,
TAG_LIVE_GAME_STAT_VALUES, TAG_LIVE_GAME_STAT_VALUES,
@ -103,13 +106,12 @@ xml_loadsave_live_game_end_element (GMarkupParseContext *context,
unitidx++; unitidx++;
} }
else if(tag == TAG_LIVE_GAME_UNIT_EVENT_TYPE || else if(tag == TAG_LIVE_GAME_UNIT_EVENT_TYPE ||
tag == TAG_LIVE_GAME_UNIT_EVENT_VALUE || tag == TAG_LIVE_GAME_UNIT_EVENT_TEAM ||
tag == TAG_LIVE_GAME_UNIT_EVENT_PLAYER ||
tag == TAG_LIVE_GAME_UNIT_EVENT_PLAYER2 ||
tag == TAG_LIVE_GAME_UNIT_EVENT_VERBOSITY ||
tag == TAG_LIVE_GAME_UNIT_EVENT_COMMENTARY) tag == TAG_LIVE_GAME_UNIT_EVENT_COMMENTARY)
{
state = TAG_LIVE_GAME_UNIT_EVENT; state = TAG_LIVE_GAME_UNIT_EVENT;
if(tag == TAG_LIVE_GAME_UNIT_EVENT_VALUE)
unitidx++;
}
else if(tag == TAG_LIVE_GAME_STAT_POSSESSION || else if(tag == TAG_LIVE_GAME_STAT_POSSESSION ||
tag == TAG_LIVE_GAME_STAT_PLAYERS || tag == TAG_LIVE_GAME_STAT_PLAYERS ||
tag == TAG_LIVE_GAME_STAT_VALUES) tag == TAG_LIVE_GAME_STAT_VALUES)
@ -178,10 +180,16 @@ xml_loadsave_live_game_text (GMarkupParseContext *context,
new_unit.result[unitidx] = int_value; new_unit.result[unitidx] = int_value;
else if(state == TAG_LIVE_GAME_UNIT_EVENT_TYPE) else if(state == TAG_LIVE_GAME_UNIT_EVENT_TYPE)
new_unit.event.type = int_value; new_unit.event.type = int_value;
else if(state == TAG_LIVE_GAME_UNIT_EVENT_VALUE) else if(state == TAG_LIVE_GAME_UNIT_EVENT_TEAM)
new_unit.event.values[unitidx] = int_value; new_unit.event.team = int_value;
else if(state == TAG_LIVE_GAME_UNIT_EVENT_PLAYER)
new_unit.event.player = int_value;
else if(state == TAG_LIVE_GAME_UNIT_EVENT_PLAYER2)
new_unit.event.player2 = int_value;
else if(state == TAG_LIVE_GAME_UNIT_EVENT_COMMENTARY) else if(state == TAG_LIVE_GAME_UNIT_EVENT_COMMENTARY)
new_unit.event.commentary = g_string_new(buf); new_unit.event.commentary = g_string_new(buf);
else if(state == TAG_LIVE_GAME_UNIT_EVENT_VERBOSITY)
new_unit.event.verbosity = int_value;
else if(state == TAG_LIVE_GAME_STAT_POSSESSION) else if(state == TAG_LIVE_GAME_STAT_POSSESSION)
lgame->stats.possession = int_value; lgame->stats.possession = int_value;
else if(state == TAG_LIVE_GAME_STAT_VALUE) else if(state == TAG_LIVE_GAME_STAT_VALUE)
@ -260,8 +268,6 @@ xml_loadsave_live_game_write(const gchar *filename, const LiveGame *live_game)
void void
xml_loadsave_live_game_write_unit(FILE *fil, const LiveGameUnit *unit) xml_loadsave_live_game_write_unit(FILE *fil, const LiveGameUnit *unit)
{ {
gint i;
fprintf(fil, "<_%d>\n", TAG_LIVE_GAME_UNIT); fprintf(fil, "<_%d>\n", TAG_LIVE_GAME_UNIT);
xml_write_int(fil, unit->possession, xml_write_int(fil, unit->possession,
@ -279,16 +285,21 @@ xml_loadsave_live_game_write_unit(FILE *fil, const LiveGameUnit *unit)
fprintf(fil, "%s<_%d>\n", I1, TAG_LIVE_GAME_UNIT_EVENT); fprintf(fil, "%s<_%d>\n", I1, TAG_LIVE_GAME_UNIT_EVENT);
xml_write_int(fil, xml_write_int(fil, unit->event.type,
unit->event.type,
TAG_LIVE_GAME_UNIT_EVENT_TYPE, I2); TAG_LIVE_GAME_UNIT_EVENT_TYPE, I2);
xml_write_int(fil, unit->event.verbosity,
TAG_LIVE_GAME_UNIT_EVENT_VERBOSITY, I2);
xml_write_g_string(fil, unit->event.commentary, xml_write_g_string(fil, unit->event.commentary,
TAG_LIVE_GAME_UNIT_EVENT_COMMENTARY, I2); TAG_LIVE_GAME_UNIT_EVENT_COMMENTARY, I2);
for(i=0;i<LIVE_GAME_EVENT_VALUE_END;i++)
xml_write_int(fil, unit->event.values[i],
TAG_LIVE_GAME_UNIT_EVENT_VALUE, I2);
xml_write_int(fil, unit->event.team,
TAG_LIVE_GAME_UNIT_EVENT_TEAM, I2);
xml_write_int(fil, unit->event.player,
TAG_LIVE_GAME_UNIT_EVENT_PLAYER, I2);
xml_write_int(fil, unit->event.player2,
TAG_LIVE_GAME_UNIT_EVENT_PLAYER2, I2);
fprintf(fil, "%s</_%d>\n", I1, TAG_LIVE_GAME_UNIT_EVENT); fprintf(fil, "%s</_%d>\n", I1, TAG_LIVE_GAME_UNIT_EVENT);
fprintf(fil, "</_%d>\n", TAG_LIVE_GAME_UNIT); fprintf(fil, "</_%d>\n", TAG_LIVE_GAME_UNIT);