mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-01-29 23:14:46 +01:00
Restructured definition directory.
This commit is contained in:
parent
2d1dc97f66
commit
df4df46065
@ -87,6 +87,7 @@ enum ExitCodes
|
|||||||
EXIT_FIXTURE_WRITE_ERROR, /** There was an error writing the fixtures. */
|
EXIT_FIXTURE_WRITE_ERROR, /** There was an error writing the fixtures. */
|
||||||
EXIT_USER_FIRED,
|
EXIT_USER_FIRED,
|
||||||
EXIT_CUP_LAST_ROUND,
|
EXIT_CUP_LAST_ROUND,
|
||||||
|
EXIT_FIRST_WEEK_ERROR,
|
||||||
EXIT_END
|
EXIT_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
28
src/cup.c
28
src/cup.c
@ -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) -
|
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;
|
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;
|
return week_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -668,19 +674,15 @@ cup_round_name(const Fixture *fix, gchar *buf)
|
|||||||
|
|
||||||
cup_get_round_name(cup, fix->round, buf);
|
cup_get_round_name(cup, fix->round, buf);
|
||||||
|
|
||||||
if(cup_round->round_robin_number_of_groups == 0)
|
if(cup_round->home_away)
|
||||||
strcpy(buf, "Round robin");
|
{
|
||||||
{
|
if(fix->second_leg)
|
||||||
if(cup_round->home_away)
|
strcat(buf, " -- Second leg");
|
||||||
{
|
else
|
||||||
if(fix->second_leg)
|
strcat(buf, " -- First leg");
|
||||||
strcat(buf, " -- Second leg");
|
}
|
||||||
else
|
else if(fix->replay_number > 0)
|
||||||
strcat(buf, " -- First leg");
|
strcat(buf, " -- Replay match");
|
||||||
}
|
|
||||||
else if(fix->replay_number > 0)
|
|
||||||
strcat(buf, " -- Replay match");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the cup round given by the number. */
|
/** Return the cup round given by the number. */
|
||||||
|
78
src/file.c
78
src/file.c
@ -68,13 +68,14 @@ file_find_support_file (const gchar *filename, gboolea
|
|||||||
{
|
{
|
||||||
gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
|
gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
|
||||||
G_DIR_SEPARATOR_S, filename);
|
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;
|
return pathname;
|
||||||
|
|
||||||
g_free (pathname);
|
g_free (pathname);
|
||||||
elem = elem->next;
|
elem = elem->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(warning)
|
if(warning)
|
||||||
g_warning("file_find_support_file: file '%s' not found.", filename);
|
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. */
|
/** Copy the xml definition files into the home dir. */
|
||||||
void
|
void
|
||||||
file_check_home_dir_copy_definition_files(void)
|
file_check_home_dir_copy_definition_dir(const gchar *dirname, const gchar *basename)
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
gchar buf[SMALL];
|
gchar buf[SMALL], buf2[SMALL];
|
||||||
const gchar *home = g_get_home_dir();
|
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;
|
GList *elem = support_directories;
|
||||||
|
|
||||||
while(elem != NULL)
|
while(elem != NULL)
|
||||||
{
|
{
|
||||||
if(g_str_has_suffix((gchar*)elem->data, "definitions"))
|
if(g_str_has_suffix((gchar*)elem->data, "definitions"))
|
||||||
{
|
file_check_home_dir_copy_definition_dir((const 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
elem = elem->next;
|
elem = elem->next;
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,9 @@ file_check_home_dir_copy_conf_files(void);
|
|||||||
void
|
void
|
||||||
file_check_home_dir_copy_definition_files(void);
|
file_check_home_dir_copy_definition_files(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
file_check_home_dir_copy_definition_dir(const gchar *dirname, const gchar *basename);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
file_my_system(const gchar *command);
|
file_my_system(const gchar *command);
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@ fixture_write_round_robin(gpointer league_cup, gint cup_round, GPtrArray *teams)
|
|||||||
|
|
||||||
if(first_week < 1)
|
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);
|
main_exit_program(EXIT_FIXTURE_WRITE_ERROR, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ int_opt_player_precision 0
|
|||||||
int_opt_live_game_player_list_refresh 48
|
int_opt_live_game_player_list_refresh 48
|
||||||
|
|
||||||
# whether some debugging info's shown (in the console)
|
# 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_player_names_file player_names.xml
|
||||||
string_opt_constants_file bygfoot_constants
|
string_opt_constants_file bygfoot_constants
|
||||||
|
Loading…
x
Reference in New Issue
Block a user