mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-03-09 07:17:43 +01:00
"Minor bugfixes."
This commit is contained in:
parent
75d9ee4a56
commit
0df6829fe0
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -62,7 +62,7 @@
|
||||
#define stat4 status[4]
|
||||
#define stat5 status[5]
|
||||
|
||||
#define debug opt_int("int_opt_debug")
|
||||
#define debug const_int("int_debug")
|
||||
|
||||
/**
|
||||
* Exit codes.
|
||||
|
@ -262,9 +262,9 @@ callback_show_tables(gint type)
|
||||
if(type == SHOW_CURRENT)
|
||||
clid = team_get_table_clid(current_user.tm);
|
||||
else if(type == SHOW_NEXT_LEAGUE)
|
||||
clid = league_cup_get_next_clid(stat1);
|
||||
clid = league_cup_get_next_clid(stat1, FALSE);
|
||||
else if(type == SHOW_PREVIOUS_LEAGUE)
|
||||
clid = league_cup_get_previous_clid(stat1);
|
||||
clid = league_cup_get_previous_clid(stat1, FALSE);
|
||||
else
|
||||
{
|
||||
g_warning("callback_show_tables: unknown type %d \n", type);
|
||||
@ -275,9 +275,9 @@ callback_show_tables(gint type)
|
||||
(clid >= ID_CUP_START && cup_has_tables(clid) == -1))
|
||||
{
|
||||
if(type == SHOW_PREVIOUS_LEAGUE)
|
||||
clid = league_cup_get_previous_clid(clid);
|
||||
clid = league_cup_get_previous_clid(clid, FALSE);
|
||||
else
|
||||
clid = league_cup_get_next_clid(clid);
|
||||
clid = league_cup_get_next_clid(clid, FALSE);
|
||||
}
|
||||
|
||||
stat1 = clid;
|
||||
@ -550,15 +550,15 @@ callback_show_team(gint type)
|
||||
{
|
||||
if(type == SHOW_NEXT_LEAGUE)
|
||||
{
|
||||
stat2 = league_cup_get_next_clid(stat2);
|
||||
stat2 = league_cup_get_next_clid(stat2, TRUE);
|
||||
while(stat2 >= ID_CUP_START && cup_from_clid(stat2)->teams->len == 0)
|
||||
stat2 = league_cup_get_next_clid(stat2);
|
||||
stat2 = league_cup_get_next_clid(stat2, TRUE);
|
||||
}
|
||||
else if(type == SHOW_PREVIOUS_LEAGUE)
|
||||
{
|
||||
stat2 = league_cup_get_previous_clid(stat2);
|
||||
stat2 = league_cup_get_previous_clid(stat2, TRUE);
|
||||
while(stat2 >= ID_CUP_START && cup_from_clid(stat2)->teams->len == 0)
|
||||
stat2 = league_cup_get_previous_clid(stat2);
|
||||
stat2 = league_cup_get_previous_clid(stat2, TRUE);
|
||||
}
|
||||
|
||||
if(stat2 < ID_CUP_START)
|
||||
@ -609,14 +609,14 @@ callback_show_player_list(gint type)
|
||||
stat1 = current_user.tm->clid;
|
||||
break;
|
||||
case SHOW_NEXT_LEAGUE:
|
||||
stat1 = league_cup_get_next_clid(stat1);
|
||||
stat1 = league_cup_get_next_clid(stat1, TRUE);
|
||||
while(stat1 >= ID_CUP_START && cup_from_clid(stat1)->teams->len == 0)
|
||||
stat1 = league_cup_get_next_clid(stat1);
|
||||
stat1 = league_cup_get_next_clid(stat1, TRUE);
|
||||
break;
|
||||
case SHOW_PREVIOUS_LEAGUE:
|
||||
stat1 = league_cup_get_previous_clid(stat1);
|
||||
stat1 = league_cup_get_previous_clid(stat1, TRUE);
|
||||
while(stat1 >= ID_CUP_START && cup_from_clid(stat1)->teams->len == 0)
|
||||
stat1 = league_cup_get_previous_clid(stat1);
|
||||
stat1 = league_cup_get_previous_clid(stat1, TRUE);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -656,17 +656,17 @@ callback_show_league_stats(gint type)
|
||||
stat1 = current_user.tm->clid;
|
||||
while(stat1 >= ID_CUP_START ||
|
||||
!league_from_clid(stat1)->active)
|
||||
stat1 = league_cup_get_next_clid(stat1);
|
||||
stat1 = league_cup_get_next_clid(stat1, FALSE);
|
||||
break;
|
||||
case SHOW_NEXT_LEAGUE:
|
||||
stat1 = league_cup_get_next_clid(stat1);
|
||||
stat1 = league_cup_get_next_clid(stat1, FALSE);
|
||||
while(stat1 >= ID_CUP_START)
|
||||
stat1 = league_cup_get_next_clid(stat1);
|
||||
stat1 = league_cup_get_next_clid(stat1, FALSE);
|
||||
break;
|
||||
case SHOW_PREVIOUS_LEAGUE:
|
||||
stat1 = league_cup_get_previous_clid(stat1);
|
||||
stat1 = league_cup_get_previous_clid(stat1, FALSE);
|
||||
while(stat1 >= ID_CUP_START)
|
||||
stat1 = league_cup_get_previous_clid(stat1);
|
||||
stat1 = league_cup_get_previous_clid(stat1, FALSE);
|
||||
break;
|
||||
}
|
||||
|
||||
|
23
src/file.c
23
src/file.c
@ -148,20 +148,11 @@ file_check_home_dir_create_dirs(void)
|
||||
const gchar *home = g_get_home_dir();
|
||||
gchar buf[SMALL];
|
||||
|
||||
if(os_is_unix)
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
sprintf(buf, "%s%s%s", home, G_DIR_SEPARATOR_S, dirs[i]);
|
||||
if(!g_file_test(buf, G_FILE_TEST_EXISTS))
|
||||
file_mkdir(buf);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(buf, ".%ssaves", G_DIR_SEPARATOR_S);
|
||||
sprintf(buf, "%s%s%s", home, G_DIR_SEPARATOR_S, dirs[i]);
|
||||
if(!g_file_test(buf, G_FILE_TEST_EXISTS))
|
||||
file_mkdir(buf);
|
||||
file_mkdir(buf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,12 +248,8 @@ void
|
||||
file_check_home_dir(void)
|
||||
{
|
||||
file_check_home_dir_create_dirs();
|
||||
|
||||
if(os_is_unix)
|
||||
{
|
||||
file_check_home_dir_copy_conf_files();
|
||||
file_check_home_dir_copy_definition_files();
|
||||
}
|
||||
file_check_home_dir_copy_conf_files();
|
||||
file_check_home_dir_copy_definition_files();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -928,8 +928,8 @@ fixture_get(gint type, gint clid, gint week_number,
|
||||
type == SHOW_PREVIOUS_LEAGUE)
|
||||
{
|
||||
new_clid = (type == SHOW_NEXT_LEAGUE) ?
|
||||
league_cup_get_next_clid(clid):
|
||||
league_cup_get_previous_clid(clid);
|
||||
league_cup_get_next_clid(clid, FALSE):
|
||||
league_cup_get_previous_clid(clid, FALSE);
|
||||
|
||||
fix = fixture_get(SHOW_CURRENT, new_clid, week, week_round, NULL);
|
||||
}
|
||||
|
34
src/league.c
34
src/league.c
@ -131,9 +131,10 @@ league_from_clid(gint clid)
|
||||
|
||||
/** Return the id of the next league (or cup if we are
|
||||
at the end of the leagues array).
|
||||
@param clid The id of the current league or cup. */
|
||||
@param clid The id of the current league or cup.
|
||||
@param count_inactive Whether inactive leagues count. */
|
||||
gint
|
||||
league_cup_get_next_clid(gint clid)
|
||||
league_cup_get_next_clid(gint clid, gboolean count_inactive)
|
||||
{
|
||||
gint i, return_value = -1;
|
||||
|
||||
@ -145,19 +146,19 @@ league_cup_get_next_clid(gint clid)
|
||||
|
||||
if(i != ligs->len - 1)
|
||||
{
|
||||
if(lig(i + 1).active)
|
||||
if(lig(i + 1).active || count_inactive)
|
||||
return_value = lig(i + 1).id;
|
||||
else
|
||||
return_value = league_cup_get_next_clid(lig(i + 1).id);
|
||||
return_value = league_cup_get_next_clid(lig(i + 1).id, count_inactive);
|
||||
}
|
||||
else if(acps->len > 0)
|
||||
return_value = acp(0)->id;
|
||||
else
|
||||
{
|
||||
if(lig(0).active)
|
||||
if(lig(0).active || count_inactive)
|
||||
return_value = lig(0).id;
|
||||
else
|
||||
return_value = league_cup_get_next_clid(lig(0).id);
|
||||
return_value = league_cup_get_next_clid(lig(0).id, count_inactive);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -170,10 +171,10 @@ league_cup_get_next_clid(gint clid)
|
||||
return_value = acp(i + 1)->id;
|
||||
else
|
||||
{
|
||||
if(lig(0).active)
|
||||
if(lig(0).active || count_inactive)
|
||||
return_value = lig(0).id;
|
||||
else
|
||||
return_value = league_cup_get_next_clid(lig(0).id);
|
||||
return_value = league_cup_get_next_clid(lig(0).id, count_inactive);
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,9 +183,10 @@ league_cup_get_next_clid(gint clid)
|
||||
|
||||
|
||||
/** Return the id of the previous league or cup.
|
||||
@param clid The id of the current league or cup. */
|
||||
@param clid The id of the current league or cup.
|
||||
@param count_inactive Whether inactive leagues count. */
|
||||
gint
|
||||
league_cup_get_previous_clid(gint clid)
|
||||
league_cup_get_previous_clid(gint clid, gboolean count_inactive)
|
||||
{
|
||||
gint i, return_value = -1;
|
||||
|
||||
@ -196,19 +198,19 @@ league_cup_get_previous_clid(gint clid)
|
||||
|
||||
if(i != 0)
|
||||
{
|
||||
if(lig(i - 1).active)
|
||||
if(lig(i - 1).active || count_inactive)
|
||||
return_value = lig(i - 1).id;
|
||||
else
|
||||
return_value = league_cup_get_previous_clid(lig(i - 1).id);
|
||||
return_value = league_cup_get_previous_clid(lig(i - 1).id, count_inactive);
|
||||
}
|
||||
else if(acps->len > 0)
|
||||
return_value = acp(acps->len - 1)->id;
|
||||
else
|
||||
{
|
||||
if(lig(ligs->len - 1).active)
|
||||
if(lig(ligs->len - 1).active || count_inactive)
|
||||
return_value = lig(ligs->len - 1).id;
|
||||
else
|
||||
return_value = league_cup_get_previous_clid(lig(ligs->len - 1).id);
|
||||
return_value = league_cup_get_previous_clid(lig(ligs->len - 1).id, count_inactive);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -221,10 +223,10 @@ league_cup_get_previous_clid(gint clid)
|
||||
return_value = acp(i - 1)->id;
|
||||
else
|
||||
{
|
||||
if(lig(ligs->len - 1).active)
|
||||
if(lig(ligs->len - 1).active || count_inactive)
|
||||
return_value = lig(ligs->len - 1).id;
|
||||
else
|
||||
return_value = league_cup_get_previous_clid(lig(ligs->len - 1).id);
|
||||
return_value = league_cup_get_previous_clid(lig(ligs->len - 1).id, count_inactive);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,10 +38,10 @@ League*
|
||||
league_from_clid(gint clid);
|
||||
|
||||
gint
|
||||
league_cup_get_next_clid(gint clid);
|
||||
league_cup_get_next_clid(gint clid, gboolean count_inactive);
|
||||
|
||||
gint
|
||||
league_cup_get_previous_clid(gint clid);
|
||||
league_cup_get_previous_clid(gint clid, gboolean count_inactive);
|
||||
|
||||
Fixture*
|
||||
league_cup_get_next_fixture(gint clid, gint week_number, gint week_round_number);
|
||||
|
@ -627,14 +627,14 @@ live_game_event_penalty(void)
|
||||
|
||||
if(last_unit.time == LIVE_GAME_UNIT_TIME_PENALTIES)
|
||||
{
|
||||
if(uni(unis->len - 2).event.type == LIVE_GAME_EVENT_PENALTIES)
|
||||
if(live_game_penalties_taken() == 1)
|
||||
{
|
||||
last_unit.possession = math_rndi(0, 1);
|
||||
last_unit.event.player =
|
||||
game_get_player(tm[last_unit.possession],
|
||||
GAME_PLAYER_TYPE_PENALTY, -1, -1, FALSE);
|
||||
}
|
||||
else if(uni(unis->len - 4).event.type == LIVE_GAME_EVENT_PENALTIES)
|
||||
else if(live_game_penalties_taken() == 2)
|
||||
{
|
||||
last_unit.possession = !uni(unis->len - 3).possession;
|
||||
last_unit.event.player =
|
||||
@ -1619,3 +1619,21 @@ live_game_unit_result_to_buf(const LiveGameUnit *unit, gchar *buf, gboolean swap
|
||||
sprintf(buf, "%d : %d", unit->result[idx],
|
||||
unit->result[!idx]);
|
||||
}
|
||||
|
||||
/** Count the number of penalties taken during penalty shoot-out. */
|
||||
gint
|
||||
live_game_penalties_taken(void)
|
||||
{
|
||||
gint i, penalties = 0;
|
||||
|
||||
for(i=unis->len - 1;i>=0;i--)
|
||||
{
|
||||
if(uni(i).event.type == LIVE_GAME_EVENT_PENALTIES)
|
||||
break;
|
||||
else if(uni(i).time == LIVE_GAME_UNIT_TIME_PENALTIES &&
|
||||
uni(i).event.type == LIVE_GAME_EVENT_PENALTY)
|
||||
penalties++;
|
||||
}
|
||||
|
||||
return penalties;
|
||||
}
|
||||
|
@ -109,4 +109,7 @@ live_game_event_get_verbosity(gint event_type);
|
||||
void
|
||||
live_game_unit_result_to_buf(const LiveGameUnit *unit, gchar *buf, gboolean swap);
|
||||
|
||||
gint
|
||||
live_game_penalties_taken(void);
|
||||
|
||||
#endif
|
||||
|
26
src/main.c
26
src/main.c
@ -28,22 +28,25 @@ main_parse_cl_arguments(gint *argc, gchar ***argv)
|
||||
{
|
||||
gchar *support_dir = NULL, *lang = NULL;
|
||||
gint deb_level = -1;
|
||||
gboolean load_last_save = FALSE;
|
||||
GError *error = NULL;
|
||||
GOptionContext *context = NULL;
|
||||
GOptionEntry entries[] =
|
||||
{{ "support-dir", 's', 0, G_OPTION_ARG_STRING, &support_dir,
|
||||
"Specify additional support directory (takes priority over default ones)", "DIR" },
|
||||
_("Specify additional support directory (takes priority over default ones)"), "DIR" },
|
||||
|
||||
{ "debug-level", 'd', 0, G_OPTION_ARG_INT, &deb_level, "Debug level to use", "N" },
|
||||
{ "debug-level", 'd', 0, G_OPTION_ARG_INT, &deb_level, _("Debug level to use"), "N" },
|
||||
|
||||
{ "lang", 'l', 0, G_OPTION_ARG_STRING, &lang, "Language to use (a code like 'de')", "CODE" },
|
||||
{ "lang", 'L', 0, G_OPTION_ARG_STRING, &lang, _("Language to use (a code like 'de')"), "CODE" },
|
||||
|
||||
{ "last-save", 'l', 0, G_OPTION_ARG_NONE, &load_last_save, _("Load last savegame"), NULL },
|
||||
|
||||
{NULL}};
|
||||
|
||||
if(argc == NULL || argv == NULL)
|
||||
return;
|
||||
|
||||
context = g_option_context_new("- a simple and addictive GTK2 football manager");
|
||||
context = g_option_context_new(_("- a simple and addictive GTK2 football manager"));
|
||||
g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
|
||||
g_option_context_add_group(context, gtk_get_option_group (TRUE));
|
||||
g_option_context_parse(context, argc, argv, &error);
|
||||
@ -60,10 +63,16 @@ main_parse_cl_arguments(gint *argc, gchar ***argv)
|
||||
}
|
||||
|
||||
if(deb_level != -1)
|
||||
opt_set_int("int_opt_debug", deb_level);
|
||||
option_set_int("int_debug", &constants, deb_level);
|
||||
|
||||
if(lang != NULL)
|
||||
language_set(language_get_code_index(lang) + 1);
|
||||
|
||||
/*todo*/
|
||||
if(load_last_save)
|
||||
{
|
||||
/*add 'last_save' to arguments*/
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -161,15 +170,18 @@ main_init(gint *argc, gchar ***argv)
|
||||
#endif
|
||||
|
||||
sprintf(buf, "%s%ssupport_files", pwd, G_DIR_SEPARATOR_S);
|
||||
g_free(pwd);
|
||||
file_add_support_directory_recursive(buf);
|
||||
sprintf(buf, "%s%ssaves", pwd, G_DIR_SEPARATOR_S);
|
||||
file_add_support_directory_recursive(buf);
|
||||
g_free(pwd);
|
||||
|
||||
/* initialize the random nr generator */
|
||||
rand_generator = g_rand_new();
|
||||
|
||||
main_init_variables();
|
||||
|
||||
file_check_home_dir();
|
||||
if(os_is_unix)
|
||||
file_check_home_dir();
|
||||
|
||||
main_parse_cl_arguments(argc, argv);
|
||||
}
|
||||
|
@ -4,6 +4,9 @@
|
||||
# can be found in 'bygfoot_app'.
|
||||
#########
|
||||
|
||||
# debug level
|
||||
int_debug 0
|
||||
|
||||
#### float constants get divided by 100000 and loaded as floats
|
||||
#### so we write 50000 if we'd like to have 0.5
|
||||
|
||||
@ -429,10 +432,13 @@ float_live_game_player_in_poss_shoots 30000
|
||||
# prob that the scoring chance is a header
|
||||
float_live_game_scoring_chance_is_header 25000
|
||||
|
||||
# probability that a scoring chance is an own goal.
|
||||
float_live_game_scoring_chance_is_own_goal 1#000
|
||||
|
||||
# base probability to score with a scoring chance.
|
||||
float_live_game_score_base_prob 30000
|
||||
float_live_game_score_base_prob 3#0000
|
||||
# base probability to score with a free kick.
|
||||
float_live_game_score_free_kick 5000
|
||||
float_live_game_score_free_kick 5#000
|
||||
# base probability to score with a penalty.
|
||||
float_live_game_score_penalty 80000
|
||||
# influence of the attacker/goalie skills on the probability to score.
|
||||
@ -549,9 +555,6 @@ float_player_injury_recovery_fitness_upper 70000
|
||||
float_live_game_temp_injury_fitness_decrease_lower 2000
|
||||
float_live_game_temp_injury_fitness_decrease_upper 8000
|
||||
|
||||
# probability that a scoring chance is an own goal.
|
||||
float_live_game_scoring_chance_is_own_goal 1000
|
||||
|
||||
# probability of a free kick after a foul.
|
||||
float_live_game_free_kick_prob 15000
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user