Added cup fixture checking.

This commit is contained in:
gyboth 2008-11-23 15:06:00 +00:00
parent f433683ec9
commit b3d36c7a66
5 changed files with 42 additions and 8 deletions

View File

@ -1102,3 +1102,24 @@ cup_get_highlight_colour(const Cup *cup)
return NULL;
}
/** Check the cup fixtures for suspicious entries. */
gboolean
cup_check_fixtures(const Cup *cup)
{
gint i;
for(i = 0; i < cup->fixtures->len; i++)
{
if(g_array_index(cup->fixtures, Fixture, i).teams[0] ==
g_array_index(cup->fixtures, Fixture, i).teams[1])
{
if(!query_cup_has_property(cup->id, "silent_on_fixture_error"))
g_warning("cup_check_fixture: bad fixture found in cup %s; cup will be disabled\n", cup->name);
return FALSE;
}
}
return TRUE;
}

View File

@ -133,4 +133,7 @@ query_cup_transfer(void);
gchar*
cup_get_highlight_colour(const Cup *cup);
gboolean
cup_check_fixtures(const Cup *cup);
#endif

View File

@ -99,7 +99,7 @@ fixture_write_league_fixtures(League *league)
/** Write the fixtures for the given cup
at the beginning of a new season.
@param cup The cup we write the fixtures for. */
void
gboolean
fixture_write_cup_fixtures(Cup *cup)
{
gint i;
@ -115,6 +115,8 @@ fixture_write_cup_fixtures(Cup *cup)
fixture_write_knockout_round(
cup, 0, misc_copy_ptr_array(
g_array_index(cup->rounds, CupRound, 0).team_ptrs));
return cup_check_fixtures(cup);
}
/** Update the fixtures for the given cup.

View File

@ -43,7 +43,7 @@ enum FixtureCompare
void
fixture_write_league_fixtures(League *league);
void
gboolean
fixture_write_cup_fixtures(Cup *cup);
void

View File

@ -184,6 +184,13 @@ start_new_season(void)
}
}
for(i = acps->len - 1; i >= 0; i--)
if(!cup_check_fixtures(acp(i)))
{
cup_reset(acp(i));
g_ptr_array_remove_index(acps, i);
}
stat5 = -1;
for(i=0;i<name_lists->len;i++)
@ -433,7 +440,8 @@ end_week_round_update_fixtures(void)
query_cup_begins(&cp(i)))
{
cp(i).last_week = cup_get_last_week_from_first(&cp(i), week + 1);
fixture_write_cup_fixtures(&cp(i));
if(fixture_write_cup_fixtures(&cp(i)))
g_ptr_array_add(acps, &cp(i));
}
}
@ -525,8 +533,8 @@ start_week_add_cups(void)
for(i=0;i<cps->len;i++)
if(cp(i).add_week == week)
{
if(fixture_write_cup_fixtures(&cp(i)))
g_ptr_array_add(acps, &cp(i));
fixture_write_cup_fixtures(&cp(i));
}
}