mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-01-31 16:04:48 +01:00
Minor fixes.
This commit is contained in:
parent
fdcba17f18
commit
752adb16e6
@ -23,7 +23,7 @@ bygfoot_SOURCES = \
|
||||
league.c cup.h league.h maths.h misc.h option.h player.h stat.h table.h team.h user.h variables.h \
|
||||
live_game.c fixture.h free.h game.h game_gui.h live_game.h maths.h misc_callback_func.h option.h player.h support.h team.h treeview.h user.h variables.h window.h \
|
||||
load_save.c callbacks.h file.h game_gui.h gui.h load_save.h option.h support.h user.h variables.h xml_loadsave_misc.h xml_loadsave_cup.h xml_loadsave_league.h xml_loadsave_transfers.h xml_loadsave_users.h xml.h \
|
||||
main.c cup_struct.h misc_callbacks.h file.h free.h league_struct.h live_game.h main.h transfer_struct.h variables.h window.h \
|
||||
main.c cup_struct.h misc_callbacks.h file.h free.h league_struct.h live_game.h main.h stat_struct.h transfer_struct.h variables.h window.h \
|
||||
maths.c maths.h misc.h \
|
||||
misc.c main.h maths.h misc.h \
|
||||
misc_callbacks.c callbacks.h callback_func.h game.h game_gui.h live_game.h load_save.h main.h misc_callback_func.h misc_callbacks.h option.h user.h variables.h window.h xml_country.h \
|
||||
@ -38,7 +38,7 @@ bygfoot_SOURCES = \
|
||||
options_interface.c options_interface.h options_callbacks.h support.h \
|
||||
player.c cup.h fixture.h free.h game_gui.h league.h maths.h misc.h option.h player.h team.h user.h \
|
||||
start_end.c cup.h file.h finance.h fixture.h free.h game_gui.h gui.h league.h load_save.h live_game.h main.h maths.h option.h start_end.h stat.h table.h team.h transfer.h user.h variables.h xml_name.h \
|
||||
stat.c free.h option.h player.h stat.h table_struct.h team.h variables.h \
|
||||
stat.c cup.h free.h option.h player.h stat.h table_struct.h team.h variables.h \
|
||||
support.c support.h \
|
||||
table.c cup.h league.h table.h variables.h \
|
||||
team.c cup.h fixture.h game.h game_gui.h league.h maths.h misc.h option.h player.h team.h transfer.h user.h \
|
||||
|
@ -114,6 +114,19 @@ callback_player_clicked(gint idx, GdkEventButton *event)
|
||||
}
|
||||
|
||||
setsav0;
|
||||
|
||||
/*d*/
|
||||
gint i;
|
||||
printf("%s %d \n ", lig(1).name->str, lig(1).id);
|
||||
for(i=0;i<lig(1).fixtures->len;i++)
|
||||
if(g_array_index(lig(1).fixtures, Fixture, i).week_number == 15)
|
||||
printf("%s %d %d %s %d %d \n",
|
||||
g_array_index(lig(1).fixtures, Fixture, i).teams[0]->name->str,
|
||||
g_array_index(lig(1).fixtures, Fixture, i).result[0][0],
|
||||
g_array_index(lig(1).fixtures, Fixture, i).result[1][0],
|
||||
g_array_index(lig(1).fixtures, Fixture, i).teams[1]->name->str,
|
||||
g_array_index(lig(1).fixtures, Fixture, i).clid,
|
||||
query_fixture_has_tables(&g_array_index(lig(1).fixtures, Fixture, i)));
|
||||
}
|
||||
|
||||
/** Show the last match of the current user. */
|
||||
|
12
src/cup.c
12
src/cup.c
@ -823,3 +823,15 @@ cup_has_tables(gint clid)
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Return the team that won the cup. */
|
||||
Team*
|
||||
cup_get_winner(const Cup *cup)
|
||||
{
|
||||
GPtrArray *teams_sorted = cup_get_teams_sorted(cup);
|
||||
Team *tm = (Team*)g_ptr_array_index(teams_sorted, 0);
|
||||
|
||||
g_ptr_array_free(teams_sorted, TRUE);
|
||||
|
||||
return tm;
|
||||
}
|
||||
|
@ -80,4 +80,7 @@ cup_get_round_name(const Cup *cup, gint round, gchar *buf);
|
||||
gint
|
||||
cup_has_tables(gint clid);
|
||||
|
||||
Team*
|
||||
cup_get_winner(const Cup *cup);
|
||||
|
||||
#endif
|
||||
|
37
src/free.c
37
src/free.c
@ -16,6 +16,43 @@ free_memory(void)
|
||||
free_support_dirs();
|
||||
}
|
||||
|
||||
/** Free the memory occupied by the season stats. */
|
||||
void
|
||||
free_season_stats(void)
|
||||
{
|
||||
gint i, j;
|
||||
|
||||
for(i=0;i<season_stats->len;i++)
|
||||
{
|
||||
for(j=0;j<g_array_index(season_stats, SeasonStat, i).league_stats->len;j++)
|
||||
free_league_stats(
|
||||
&g_array_index(g_array_index(season_stats, SeasonStat, i).league_stats,
|
||||
LeagueStat, j));
|
||||
|
||||
for(j=0;j<g_array_index(season_stats, SeasonStat, i).league_champs->len;j++)
|
||||
{
|
||||
g_string_free(
|
||||
g_array_index(
|
||||
g_array_index(season_stats, SeasonStat, i).league_champs, ChampStat, j).cl_name, TRUE);
|
||||
g_string_free(
|
||||
g_array_index(
|
||||
g_array_index(season_stats, SeasonStat, i).league_champs, ChampStat, j).team_name, TRUE);
|
||||
}
|
||||
|
||||
for(j=0;j<g_array_index(season_stats, SeasonStat, i).cup_champs->len;j++)
|
||||
{
|
||||
g_string_free(
|
||||
g_array_index(
|
||||
g_array_index(season_stats, SeasonStat, i).cup_champs, ChampStat, j).cl_name, TRUE);
|
||||
g_string_free(
|
||||
g_array_index(
|
||||
g_array_index(season_stats, SeasonStat, i).cup_champs, ChampStat, j).team_name, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
g_array_free(season_stats, TRUE);
|
||||
}
|
||||
|
||||
/** Free the users array. */
|
||||
void
|
||||
free_users(gboolean reset)
|
||||
|
@ -81,4 +81,7 @@ free_table(Table *table);
|
||||
void
|
||||
free_league_stats(LeagueStat *stats);
|
||||
|
||||
void
|
||||
free_season_stats(void);
|
||||
|
||||
#endif
|
||||
|
@ -69,7 +69,7 @@ live_game_calculate_fixture(Fixture *fix)
|
||||
while(last_unit.event.type != LIVE_GAME_EVENT_END_MATCH &&
|
||||
stat0 != STATUS_LIVE_GAME_PAUSE);
|
||||
|
||||
if(stat0 != STATUS_LIVE_GAME_PAUSE)
|
||||
if(last_unit.event.type == LIVE_GAME_EVENT_END_MATCH)
|
||||
game_post_match(fix);
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "live_game.h"
|
||||
#include "main.h"
|
||||
#include "transfer_struct.h"
|
||||
#include "stat_struct.h"
|
||||
#include "variables.h"
|
||||
#include "window.h"
|
||||
|
||||
@ -25,7 +26,6 @@ main_init_variables(void)
|
||||
ligs = cps = scps = NULL;
|
||||
acps = NULL;
|
||||
country.name = country.symbol = country.sid = NULL;
|
||||
transfer_list = NULL;
|
||||
player_names = NULL;
|
||||
|
||||
season = week = week_round = 1;
|
||||
@ -48,6 +48,7 @@ main_init_variables(void)
|
||||
|
||||
users = g_array_new(FALSE, FALSE, sizeof(User));
|
||||
transfer_list = g_array_new(FALSE, FALSE, sizeof(Transfer));
|
||||
season_stats = g_array_new(FALSE, FALSE, sizeof(SeasonStat));
|
||||
|
||||
save_file = g_string_new("");
|
||||
|
||||
|
@ -127,6 +127,11 @@ misc_callback_remove_user(GdkEventButton *event)
|
||||
void
|
||||
misc_callback_pause_live_game(void)
|
||||
{
|
||||
if(g_array_index(usr(stat2).live_game.units, LiveGameUnit,
|
||||
usr(stat2).live_game.units->len - 1).event.type ==
|
||||
LIVE_GAME_EVENT_END_MATCH)
|
||||
return;
|
||||
|
||||
gtk_widget_set_sensitive(lookup_widget(window.live, "button_pause"), FALSE);
|
||||
gtk_widget_set_sensitive(lookup_widget(window.live, "button_resume"), TRUE);
|
||||
|
||||
|
@ -64,7 +64,6 @@ start_new_season(void)
|
||||
|
||||
week = week_round = 1;
|
||||
|
||||
/*todo: nullify, promotion/relegation*/
|
||||
if(season > 1)
|
||||
{
|
||||
for(i=0;i<users->len;i++)
|
||||
@ -186,6 +185,8 @@ end_week_round(void)
|
||||
|
||||
if(query_start_end_season_end())
|
||||
{
|
||||
end_season();
|
||||
|
||||
season++;
|
||||
week = 1;
|
||||
|
||||
@ -331,7 +332,7 @@ start_week_round(void)
|
||||
start_func++;
|
||||
}
|
||||
|
||||
if(/*d*/FALSE && !query_user_games_this_week_round() &&
|
||||
if(/*d*//* FALSE && */!query_user_games_this_week_round() &&
|
||||
((week_round == 1 &&
|
||||
!query_user_games_in_week_round(week - 1, fixture_get_last_week_round(week - 1))) ||
|
||||
(week_round > 1 &&
|
||||
@ -471,3 +472,10 @@ start_new_season_team_movements(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** End a season (store stats etc.) */
|
||||
void
|
||||
end_season(void)
|
||||
{
|
||||
stat_create_season_stat();
|
||||
}
|
||||
|
@ -60,4 +60,7 @@ start_new_season_team_movements(void);
|
||||
void
|
||||
end_week(void);
|
||||
|
||||
void
|
||||
end_season(void);
|
||||
|
||||
#endif
|
||||
|
42
src/stat.c
42
src/stat.c
@ -1,3 +1,4 @@
|
||||
#include "cup.h"
|
||||
#include "free.h"
|
||||
#include "option.h"
|
||||
#include "player.h"
|
||||
@ -75,7 +76,6 @@ stat_update_league_players(League *league)
|
||||
for(j=0;j<maxlen;j++)
|
||||
{
|
||||
pl = (Player*)g_ptr_array_index(players_sorted[i], j);
|
||||
new_stat.tm = pl->team;
|
||||
new_stat.team_id = pl->team->id;
|
||||
new_stat.value_string = g_string_new(pl->name->str);
|
||||
new_stat.value1 =
|
||||
@ -111,10 +111,9 @@ stat_update_league_teams(const GArray *teams_array, gint compare_type)
|
||||
|
||||
for(i=0;i<maxlen;i++)
|
||||
{
|
||||
new_stat.tm = (Team*)g_ptr_array_index(teams, i);
|
||||
new_stat.team_id = ((Team*)g_ptr_array_index(teams, i))->id;
|
||||
new_stat.value1 = team_get_table_value(new_stat.tm, TABLE_GF);
|
||||
new_stat.value2 = team_get_table_value(new_stat.tm, TABLE_GA);
|
||||
new_stat.value1 = team_get_table_value((Team*)g_ptr_array_index(teams, i), TABLE_GF);
|
||||
new_stat.value2 = team_get_table_value((Team*)g_ptr_array_index(teams, i), TABLE_GA);
|
||||
new_stat.value3 = -1;
|
||||
new_stat.value_string = g_string_new("");
|
||||
|
||||
@ -125,3 +124,38 @@ stat_update_league_teams(const GArray *teams_array, gint compare_type)
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
||||
/** Create a seasonstat struct at the end of a season. */
|
||||
void
|
||||
stat_create_season_stat(void)
|
||||
{
|
||||
gint i;
|
||||
SeasonStat new;
|
||||
ChampStat new_champ;
|
||||
|
||||
new.season_number = season;
|
||||
new.league_champs = g_array_new(FALSE, FALSE, sizeof(ChampStat));
|
||||
new.cup_champs = g_array_new(FALSE, FALSE, sizeof(ChampStat));
|
||||
new.league_stats = g_array_new(FALSE, FALSE, sizeof(LeagueStat));
|
||||
|
||||
for(i=0;i<ligs->len;i++)
|
||||
{
|
||||
new_champ.cl_name = g_string_new(lig(i).name->str);
|
||||
new_champ.team_name =
|
||||
g_string_new(g_array_index(lig(i).table.elements, TableElement, 0).team->name->str);
|
||||
g_array_append_val(new.league_champs, new_champ);
|
||||
|
||||
g_array_append_val(new.league_stats, lig(i).stats);
|
||||
lig(i).stats = stat_league_new(lig(i).id);
|
||||
}
|
||||
|
||||
for(i=0;i<acps->len;i++)
|
||||
if(acp(i)->id < ID_PROM_CUP_START ||
|
||||
acp(i)->id >= ID_SUPERCUP_START)
|
||||
{
|
||||
new_champ.cl_name = g_string_new(acp(i)->name->str);
|
||||
new_champ.team_name =
|
||||
g_string_new(cup_get_winner(acp(i))->name->str);
|
||||
g_array_append_val(new.cup_champs, new_champ);
|
||||
}
|
||||
}
|
||||
|
@ -17,4 +17,7 @@ stat_update_leagues(void);
|
||||
void
|
||||
stat_update_league_players(League *league);
|
||||
|
||||
void
|
||||
stat_create_season_stat(void);
|
||||
|
||||
#endif
|
||||
|
@ -5,7 +5,6 @@
|
||||
string and integer values. */
|
||||
typedef struct
|
||||
{
|
||||
Team *tm;
|
||||
gint team_id;
|
||||
gint value1, value2, value3;
|
||||
GString *value_string;
|
||||
@ -22,4 +21,25 @@ typedef struct
|
||||
GArray *player_scorers, *player_goalies;
|
||||
} LeagueStat;
|
||||
|
||||
/** A team name and a competition name. */
|
||||
typedef struct
|
||||
{
|
||||
GString *team_name,
|
||||
*cl_name;
|
||||
} ChampStat;
|
||||
|
||||
/** A season statistics structure. */
|
||||
typedef struct
|
||||
{
|
||||
/** Which season */
|
||||
gint season_number;
|
||||
|
||||
/** League and cup winners. */
|
||||
GArray *league_champs;
|
||||
GArray *cup_champs;
|
||||
|
||||
/** The league stats at the end of the season. */
|
||||
GArray *league_stats;
|
||||
} SeasonStat;
|
||||
|
||||
#endif
|
||||
|
@ -2015,11 +2015,11 @@ treeview_create_league_stats(GtkListStore *ls, const League *league)
|
||||
g_array_index(teams[i], Stat, j).value1,
|
||||
g_array_index(teams[i], Stat, j).value2);
|
||||
|
||||
treeview_helper_set_user_colours(g_array_index(teams[i], Stat, j).tm,
|
||||
treeview_helper_set_user_colours(team_of_id(g_array_index(teams[i], Stat, j).team_id),
|
||||
&colour_bg, &colour_fg);
|
||||
|
||||
sprintf(buf2, "<span background='%s' foreground='%s'>%s</span>",
|
||||
colour_bg, colour_fg, g_array_index(teams[i], Stat, j).tm->name->str);
|
||||
colour_bg, colour_fg, team_of_id(g_array_index(teams[i], Stat, j).team_id)->name->str);
|
||||
|
||||
gtk_list_store_append(ls, &iter);
|
||||
gtk_list_store_set(ls, &iter, 0, NULL, 1, j + 1,
|
||||
@ -2055,12 +2055,12 @@ treeview_create_league_stats(GtkListStore *ls, const League *league)
|
||||
100 * (1 - (gfloat)g_array_index(players[i], Stat, j).value1 /
|
||||
(gfloat)g_array_index(players[i], Stat, j).value3));
|
||||
|
||||
treeview_helper_set_user_colours(g_array_index(players[i], Stat, j).tm,
|
||||
treeview_helper_set_user_colours(team_of_id(g_array_index(players[i], Stat, j).team_id),
|
||||
&colour_bg, &colour_fg);
|
||||
sprintf(buf3, "<span background='%s' foreground='%s'>%s (%s)</span>",
|
||||
colour_bg, colour_fg,
|
||||
g_array_index(players[i], Stat, j).value_string->str,
|
||||
g_array_index(players[i], Stat, j).tm->name->str);
|
||||
team_of_id(g_array_index(players[i], Stat, j).team_id)->name->str);
|
||||
sprintf(buf4, "%d", g_array_index(players[i], Stat, j).value1);
|
||||
|
||||
gtk_list_store_append(ls, &iter);
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "live_game_struct.h"
|
||||
#include "option_struct.h"
|
||||
#include "player_struct.h"
|
||||
#include "stat_struct.h"
|
||||
#include "team_struct.h"
|
||||
#include "user_struct.h"
|
||||
|
||||
@ -30,6 +31,10 @@ OptionList constants;
|
||||
@see TransferPlayer */
|
||||
GArray *transfer_list;
|
||||
|
||||
/** Array with season statistics (updated at the
|
||||
end of each season. */
|
||||
GArray *season_stats;
|
||||
|
||||
/** Some counters we use. */
|
||||
gint counters[COUNT_END];
|
||||
|
||||
|
@ -124,10 +124,7 @@ xml_loadsave_league_stat_text (GMarkupParseContext *context,
|
||||
if(state == TAG_ID)
|
||||
lstat->clid = int_value;
|
||||
else if(state == TAG_TEAM_ID)
|
||||
{
|
||||
new_stat.team_id = int_value;
|
||||
new_stat.tm = team_of_id(int_value);
|
||||
}
|
||||
else if(state == TAG_STAT_VALUE)
|
||||
{
|
||||
if(valueidx == 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user