1
1
mirror of https://github.com/tstellar/bygfoot.git synced 2025-02-23 06:47:56 +01:00

Team pointer load/save bugfix.

This commit is contained in:
gyboth 2009-01-10 10:41:27 +00:00
parent 1f0dae2f02
commit 6e0f9e885d
7 changed files with 52 additions and 6 deletions

View File

@ -110,8 +110,12 @@ debug_action(const gchar *text)
else if(g_str_has_prefix(text, "goto"))
{
sett_set_int("int_opt_goto_mode", 1);
while(week < value)
on_button_new_week_clicked(NULL, NULL);
if(value < 100)
while(week < value)
on_button_new_week_clicked(NULL, NULL);
else
while(season < value - 100)
on_button_new_week_clicked(NULL, NULL);
sett_set_int("int_opt_goto_mode", 0);
}
else if(g_str_has_prefix(text, "testcom") ||

View File

@ -394,6 +394,9 @@ fixture_write_cup_round_robin(Cup *cup, gint cup_round, GPtrArray *teams)
Table table_group[number_of_groups];
TableElement new_table_element;
if(debug > 100)
g_print("fixture_write_cup_round_robin: %s round %d teamlen %d\n", cup->name, cup_round, teams->len);
if(teams->len < number_of_groups)
main_exit_program(EXIT_FIXTURE_WRITE_ERROR,
"fixture_write_cup_round_robin: cup %s round %d: number of teams (%d) less than number of groups (%d)\n",

View File

@ -307,7 +307,7 @@ xml_loadsave_cup_text (GMarkupParseContext *context,
&g_array_index(new_round.teams, Team, i));
}
else if(state == TAG_CUP_ROUND_TEAM_PTR_ID)
g_ptr_array_add(new_round.team_ptrs, team_of_id(int_value));
g_ptr_array_add(new_round.team_ptrs, GINT_TO_POINTER(int_value));
else if(state == TAG_CUP_ROUND_TABLE_FILE)
{
new_table = table_new();

View File

@ -175,10 +175,7 @@ xml_loadsave_fixtures_text (GMarkupParseContext *context,
else if(state == TAG_FIXTURE_RESULT)
new_fixture.result[residx1][residx2] = int_value;
else if(state == TAG_TEAM_ID)
{
new_fixture.teams[teamidx] = team_of_id(int_value);
new_fixture.team_ids[teamidx] = int_value;
}
}
void

View File

@ -28,6 +28,7 @@
#include "free.h"
#include "league_struct.h"
#include "misc.h"
#include "team.h"
#include "xml.h"
#include "xml_loadsave_cup.h"
#include "xml_loadsave_league.h"
@ -163,6 +164,8 @@ xml_loadsave_leagues_cups_read(const gchar *dirname, const gchar *prefix)
g_warning("xml_loadsave_misc_read: error parsing file %s\n", file);
misc_print_error(&error, TRUE);
}
xml_loadsave_leagues_cups_adjust_team_ptrs();
}
/** Write the leagues into xml files with the given prefix. */
@ -203,3 +206,38 @@ xml_loadsave_leagues_cups_write(const gchar *prefix)
g_free(basename);
}
void
xml_loadsave_leagues_cups_adjust_team_ptrs(void)
{
gint i, j, k;
GPtrArray *team_ptrs;
for(i = 0; i < ligs->len; i++)
{
for(j = 0; j < lig(i).fixtures->len; j++)
{
for(k = 0; k < 2; k++)
g_array_index(lig(i).fixtures, Fixture, j).teams[k] = team_of_id(g_array_index(lig(i).fixtures, Fixture, j).team_ids[k]);
}
}
for(i = 0; i < cps->len; i++)
{
for(j = 0; j < cp(i).rounds->len; j++)
{
team_ptrs = g_ptr_array_new();
for(k = 0; k < g_array_index(cp(i).rounds, CupRound, j).team_ptrs->len; k++)
g_ptr_array_add(team_ptrs, team_of_id(GPOINTER_TO_INT(g_ptr_array_index(g_array_index(cp(i).rounds, CupRound, j).team_ptrs, k))));
g_ptr_array_free(g_array_index(cp(i).rounds, CupRound, j).team_ptrs, TRUE);
g_array_index(cp(i).rounds, CupRound, j).team_ptrs = team_ptrs;
}
for(j = 0; j < cp(i).fixtures->len; j++)
{
for(k = 0; k < 2; k++)
g_array_index(cp(i).fixtures, Fixture, j).teams[k] = team_of_id(g_array_index(cp(i).fixtures, Fixture, j).team_ids[k]);
}
}
}

View File

@ -57,4 +57,7 @@ void
xml_loadsave_leagues_cups_read(const gchar *dirname, const gchar *prefix);
void
xml_loadsave_leagues_cups_adjust_team_ptrs(void);
#endif

View File

@ -11,6 +11,7 @@
</leagues>
<cups>
<cup>armenia</cup>
<cup>europe_uefa</cup>
<cup>europe_champ_league</cup>
<cup>supercup_league_vs_cup</cup>