1
1
mirror of https://github.com/tstellar/bygfoot.git synced 2025-01-28 14:39:22 +01:00

Restructured definition directory.

This commit is contained in:
gyboth 2005-04-20 17:56:31 +00:00
parent 2d1dc97f66
commit df4df46065
6 changed files with 75 additions and 39 deletions

View File

@ -87,6 +87,7 @@ enum ExitCodes
EXIT_FIXTURE_WRITE_ERROR, /** There was an error writing the fixtures. */
EXIT_USER_FIRED,
EXIT_CUP_LAST_ROUND,
EXIT_FIRST_WEEK_ERROR,
EXIT_END
};

View File

@ -548,6 +548,12 @@ cup_get_first_week_of_cup_round(const Cup *cup, gint cup_round)
week_number = cup_get_first_week_of_cup_round(cup, cup_round + 1) -
cup_get_matchdays_in_cup_round(cup, cup_round) * cup->week_gap;
if(week_number <= 0)
{
g_warning("cup_get_first_week_of_cup_round: first week of cup %s cup round %d is not positive (%d).\nPlease lower the week gap or set a later last week.\n", cup->name->str, cup_round, week_number);
main_exit_program(EXIT_FIRST_WEEK_ERROR, NULL);
}
return week_number;
}
@ -668,19 +674,15 @@ cup_round_name(const Fixture *fix, gchar *buf)
cup_get_round_name(cup, fix->round, buf);
if(cup_round->round_robin_number_of_groups == 0)
strcpy(buf, "Round robin");
{
if(cup_round->home_away)
{
if(fix->second_leg)
strcat(buf, " -- Second leg");
else
strcat(buf, " -- First leg");
}
else if(fix->replay_number > 0)
strcat(buf, " -- Replay match");
}
if(cup_round->home_away)
{
if(fix->second_leg)
strcat(buf, " -- Second leg");
else
strcat(buf, " -- First leg");
}
else if(fix->replay_number > 0)
strcat(buf, " -- Replay match");
}
/** Return the cup round given by the number. */

View File

@ -68,13 +68,14 @@ file_find_support_file (const gchar *filename, gboolea
{
gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
G_DIR_SEPARATOR_S, filename);
if (g_file_test (pathname, G_FILE_TEST_EXISTS))
if (g_file_test (pathname, G_FILE_TEST_EXISTS) &&
!g_file_test(pathname, G_FILE_TEST_IS_DIR))
return pathname;
g_free (pathname);
elem = elem->next;
}
if(warning)
g_warning("file_find_support_file: file '%s' not found.", filename);
@ -181,35 +182,64 @@ file_check_home_dir_copy_conf_files(void)
/** Copy the xml definition files into the home dir. */
void
file_check_home_dir_copy_definition_files(void)
file_check_home_dir_copy_definition_dir(const gchar *dirname, const gchar *basename)
{
gint i;
gchar buf[SMALL];
gchar buf[SMALL], buf2[SMALL];
const gchar *home = g_get_home_dir();
GPtrArray *dir_contents = NULL;
GPtrArray *dir_contents = NULL;
sprintf(buf, "%s/%s/%s", home, HOMEDIRNAME, basename);
if(!g_file_test(buf, G_FILE_TEST_EXISTS))
{
sprintf(buf2, "mkdir -v %s", buf);
file_my_system(buf2);
}
dir_contents = file_dir_get_contents(dirname, "", "");
for(i=0;i<dir_contents->len;i++)
{
sprintf(buf, "%s/%s/%s/%s", home, HOMEDIRNAME, basename,
((GString*)g_ptr_array_index(dir_contents, i))->str);
if(g_str_has_suffix(((GString*)g_ptr_array_index(dir_contents, i))->str, ".xml") &&
!g_file_test(buf, G_FILE_TEST_EXISTS))
{
sprintf(buf2, "cp -v %s/%s %s", dirname,
((GString*)g_ptr_array_index(dir_contents, i))->str,
buf);
file_my_system(buf2);
}
else
{
sprintf(buf, "%s/%s", dirname, ((GString*)g_ptr_array_index(dir_contents, i))->str);
if(g_file_test(buf, G_FILE_TEST_IS_DIR))
{
sprintf(buf2, "%s/%s", basename,
((GString*)g_ptr_array_index(dir_contents, i))->str);
file_check_home_dir_copy_definition_dir(buf, buf2);
}
}
}
free_g_string_array(&dir_contents);
}
/** Copy the xml definition files into the home dir. */
void
file_check_home_dir_copy_definition_files(void)
{
GList *elem = support_directories;
while(elem != NULL)
{
if(g_str_has_suffix((gchar*)elem->data, "definitions"))
{
dir_contents = file_dir_get_contents((gchar*)elem->data, "", ".xml");
for(i=0;i<dir_contents->len;i++)
{
sprintf(buf, "%s/%s/definitions/%s", home, HOMEDIRNAME,
((GString*)g_ptr_array_index(dir_contents, i))->str);
if(!g_file_test(buf, G_FILE_TEST_EXISTS))
{
sprintf(buf, "cp -v %s/%s %s/%s/definitions/%s", (gchar*)elem->data,
((GString*)g_ptr_array_index(dir_contents, i))->str,
home, HOMEDIRNAME, ((GString*)g_ptr_array_index(dir_contents, i))->str);
file_my_system(buf);
}
}
free_g_string_array(&dir_contents);
}
file_check_home_dir_copy_definition_dir((const gchar*)elem->data, "definitions");
elem = elem->next;
}

View File

@ -47,6 +47,9 @@ file_check_home_dir_copy_conf_files(void);
void
file_check_home_dir_copy_definition_files(void);
void
file_check_home_dir_copy_definition_dir(const gchar *dirname, const gchar *basename);
gboolean
file_my_system(const gchar *command);

View File

@ -373,7 +373,7 @@ fixture_write_round_robin(gpointer league_cup, gint cup_round, GPtrArray *teams)
if(first_week < 1)
{
g_warning("fixture_write_round_robin: first week is not positive: %d\n", first_week);
g_warning("fixture_write_round_robin: first week of %s is not positive (%d).\nPlease lower the week gap or set a later last week.\n", league_cup_get_name_string(clid), first_week);
main_exit_program(EXIT_FIXTURE_WRITE_ERROR, NULL);
}

View File

@ -21,7 +21,7 @@ int_opt_player_precision 0
int_opt_live_game_player_list_refresh 48
# whether some debugging info's shown (in the console)
int_opt_debug 0
int_opt_debug 60
string_opt_player_names_file player_names.xml
string_opt_constants_file bygfoot_constants