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; 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* gchar*
cup_get_highlight_colour(const Cup *cup); cup_get_highlight_colour(const Cup *cup);
gboolean
cup_check_fixtures(const Cup *cup);
#endif #endif

View File

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

View File

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

View File

@ -111,7 +111,7 @@ start_new_season(void)
{ {
cup_reset(&cp(i)); cup_reset(&cp(i));
fixture_write_cup_fixtures(&cp(i)); fixture_write_cup_fixtures(&cp(i));
} }
if(season > 1) if(season > 1)
{ {
@ -183,7 +183,14 @@ 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; stat5 = -1;
for(i=0;i<name_lists->len;i++) for(i=0;i<name_lists->len;i++)
@ -433,8 +440,9 @@ end_week_round_update_fixtures(void)
query_cup_begins(&cp(i))) query_cup_begins(&cp(i)))
{ {
cp(i).last_week = cup_get_last_week_from_first(&cp(i), week + 1); cp(i).last_week = cup_get_last_week_from_first(&cp(i), week + 1);
fixture_write_cup_fixtures(&cp(i));
g_ptr_array_add(acps, &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++) for(i=0;i<cps->len;i++)
if(cp(i).add_week == week) if(cp(i).add_week == week)
{ {
g_ptr_array_add(acps, &cp(i)); if(fixture_write_cup_fixtures(&cp(i)))
fixture_write_cup_fixtures(&cp(i)); g_ptr_array_add(acps, &cp(i));
} }
} }