1
1
mirror of https://github.com/tstellar/bygfoot.git synced 2025-06-05 21:49:20 +02:00

"Switched most GStrings to gchar."

This commit is contained in:
gyboth
2005-10-09 09:35:44 +00:00
parent 6c959586c7
commit 53131dd2e9
80 changed files with 679 additions and 664 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -10,7 +10,7 @@ bin_PROGRAMS = bygfoot
bygfoot_SOURCES = \ bygfoot_SOURCES = \
callback_func.c callback_func.h callbacks.h cup.h finance.h fixture.h game_gui.h gui.h league.h live_game.h maths.h misc.h option.h player.h start_end.h team.h transfer.h treeview.h treeview_helper.h user.h window.h \ callback_func.c callback_func.h callbacks.h cup.h finance.h fixture.h game_gui.h gui.h league.h live_game.h maths.h misc.h option.h player.h start_end.h team.h transfer.h treeview.h treeview_helper.h user.h window.h \
callbacks.c callback_func.h callbacks.h debug.h free.h game_gui.h game.h gui.h league.h load_save.h main.h option.h player.h table.h team.h transfer.h treeview.h treeview_helper.h user.h window.h \ callbacks.c callback_func.h callbacks.h debug.h free.h game_gui.h game.h gui.h league.h load_save.h main.h option.h player.h table.h team.h transfer.h treeview2.h treeview.h treeview_helper.h user.h window.h \
cup.c cup.h fixture.h free.h league.h main.h maths.h misc.h option.h table.h team.h variables.h xml_league.h \ cup.c cup.h fixture.h free.h league.h main.h maths.h misc.h option.h table.h team.h variables.h xml_league.h \
debug.c callbacks.h debug.h game_gui.h option.h support.h user.h variables.h \ debug.c callbacks.h debug.h game_gui.h option.h support.h user.h variables.h \
file.c file.h free.h main.h misc.h option.h support.h variables.h \ file.c file.h free.h main.h misc.h option.h support.h variables.h \
@@ -22,22 +22,22 @@ bygfoot_SOURCES = \
gui.c gui.h misc.h support.h variables.h window.h \ gui.c gui.h misc.h support.h variables.h window.h \
interface.c callbacks.h interface.h support.h \ interface.c callbacks.h interface.h support.h \
language.c callbacks.h free.h language.h lg_commentary.h misc.h option.h variables.h window.h \ language.c callbacks.h free.h language.h lg_commentary.h misc.h option.h variables.h window.h \
lg_commentary.c cup.h file.h fixture.h league.h lg_commentary.h live_game.h main.h maths.h misc.h option.h player.h team.h variables.h xml_lg_commentary.h \ lg_commentary.c cup.h file.h fixture.h free.h league.h lg_commentary.h live_game.h main.h maths.h misc.h option.h player.h team.h variables.h xml_lg_commentary.h \
league.c cup.h free.h league.h main.h maths.h misc.h option.h player.h stat.h table.h team.h user.h variables.h \ league.c cup.h free.h league.h main.h maths.h misc.h option.h player.h stat.h table.h team.h user.h variables.h \
live_game.c callbacks.h fixture.h free.h game_gui.h game.h league.h lg_commentary.h live_game.h main.h maths.h misc_callback_func.h misc.h option.h player.h support.h team.h treeview.h user.h variables.h window.h \ live_game.c callbacks.h fixture.h free.h game_gui.h game.h league.h lg_commentary.h live_game.h main.h maths.h misc_callback_func.h misc.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 language.h load_save.h option.h support.h user.h variables.h xml.h xml_loadsave_cup.h xml_loadsave_league.h xml_loadsave_misc.h xml_loadsave_season_stats.h xml_loadsave_transfers.h xml_loadsave_users.h \ load_save.c callbacks.h file.h game_gui.h gui.h language.h load_save.h misc.h option.h support.h user.h variables.h window.h xml.h xml_loadsave_cup.h xml_loadsave_league.h xml_loadsave_misc.h xml_loadsave_season_stats.h xml_loadsave_transfers.h xml_loadsave_users.h \
main.c file.h free.h language.h lg_commentary_struct.h live_game.h main.h misc_callbacks.h misc.h name_struct.h option.h stat_struct.h transfer_struct.h variables.h window.h \ main.c file.h free.h language.h lg_commentary_struct.h live_game.h load_save.h main.h misc_callbacks.h misc.h name_struct.h option.h stat_struct.h transfer_struct.h variables.h window.h \
maths.c maths.h misc.h variables.h \ maths.c maths.h misc.h variables.h \
misc.c main.h maths.h misc.h \ misc.c main.h maths.h misc.h \
misc_callbacks.c callback_func.h callbacks.h game_gui.h game.h gui.h live_game.h load_save.h main.h maths.h misc_callback_func.h misc_callbacks.h option.h user.h variables.h window.h xml_country.h \ misc_callbacks.c callback_func.h callbacks.h game_gui.h game.h gui.h live_game.h load_save.h main.h maths.h misc_callback_func.h misc_callbacks.h option.h user.h variables.h window.h xml_country.h \
misc_callback_func.c callbacks.h finance.h game_gui.h game.h gui.h load_save.h maths.h misc_callback_func.h option.h start_end.h support.h treeview.h treeview_helper.h user.h variables.h window.h xml_country.h xml_name.h \ misc_callback_func.c callbacks.h finance.h game_gui.h game.h gui.h load_save.h maths.h misc_callback_func.h misc.h option.h start_end.h support.h treeview.h treeview_helper.h user.h variables.h window.h xml_country.h xml_name.h \
misc_interface.c misc_callbacks.h misc_interface.h support.h \ misc_interface.c misc_callbacks.h misc_interface.h support.h \
misc2_callbacks.c callback_func.h callbacks.h debug.h finance.h free.h game_gui.h load_save.h main.h misc2_callback_func.h misc2_callbacks.h misc2_interface.h player.h support.h transfer.h treeview2.h treeview.h treeview_helper.h user.h window.h \ misc2_callbacks.c callback_func.h callbacks.h debug.h finance.h free.h game_gui.h load_save.h main.h misc2_callback_func.h misc2_callbacks.h misc2_interface.h player.h support.h transfer.h treeview2.h treeview.h treeview_helper.h user.h window.h \
misc2_callback_func.c callback_func.h callbacks.h file.h finance.h free.h game_gui.h maths.h misc2_callback_func.h option.h player.h support.h team.h transfer.h treeview2.h treeview.h treeview_helper.h user.h window.h \ misc2_callback_func.c callback_func.h callbacks.h file.h finance.h free.h game_gui.h maths.h misc2_callback_func.h misc.h option.h player.h support.h team.h transfer.h treeview2.h treeview.h treeview_helper.h user.h window.h \
misc2_interface.c misc2_callbacks.h misc2_interface.h support.h \ misc2_interface.c misc2_callbacks.h misc2_interface.h support.h \
name.c main.h name.h option.h variables.h xml_name.h \ name.c main.h name.h option.h variables.h xml_name.h \
option.c main.h option.h variables.h \ option.c main.h misc.h option.h variables.h \
option_gui.c callbacks.h file.h game_gui.h language.h option_gui.h option.h support.h treeview.h user.h variables.h \ option_gui.c callbacks.h file.h game_gui.h language.h misc.h option_gui.h option.h support.h treeview.h user.h variables.h \
options_callbacks.c file.h option_gui.h options_callbacks.h options_interface.h support.h user.h variables.h window.h \ options_callbacks.c file.h option_gui.h options_callbacks.h options_interface.h support.h user.h variables.h window.h \
options_interface.c options_callbacks.h options_interface.h support.h \ options_interface.c options_callbacks.h options_interface.h support.h \
player.c cup.h fixture.h free.h game_gui.h league.h main.h maths.h misc.h name.h option.h player.h team.h transfer.h user.h \ player.c cup.h fixture.h free.h game_gui.h league.h main.h maths.h misc.h name.h option.h player.h team.h transfer.h user.h \
@@ -48,7 +48,7 @@ bygfoot_SOURCES = \
team.c cup.h file.h fixture.h game_gui.h game.h league.h main.h maths.h misc.h option.h player.h team.h transfer.h user.h xml_team.h \ team.c cup.h file.h fixture.h game_gui.h game.h league.h main.h maths.h misc.h option.h player.h team.h transfer.h user.h xml_team.h \
transfer.c callbacks.h cup.h finance.h free.h game_gui.h main.h maths.h misc.h option.h player.h support.h team.h transfer.h treeview.h user.h \ transfer.c callbacks.h cup.h finance.h free.h game_gui.h main.h maths.h misc.h option.h player.h support.h team.h transfer.h treeview.h user.h \
treeview.c cup.h finance.h fixture.h free.h game.h language.h league.h live_game.h maths.h misc.h option.h player.h support.h team.h transfer.h treeview.h treeview_helper.h user.h \ treeview.c cup.h finance.h fixture.h free.h game.h language.h league.h live_game.h maths.h misc.h option.h player.h support.h team.h transfer.h treeview.h treeview_helper.h user.h \
treeview2.c live_game.h option.h support.h treeview2.h treeview_helper.h user.h \ treeview2.c fixture.h league.h live_game.h option.h support.h treeview2.h treeview_helper.h user.h \
treeview_helper.c cup.h file.h fixture.h free.h league.h misc.h option.h player.h support.h team.h transfer.h treeview2.h treeview.h treeview_helper.h user.h variables.h \ treeview_helper.c cup.h file.h fixture.h free.h league.h misc.h option.h player.h support.h team.h transfer.h treeview2.h treeview.h treeview_helper.h user.h variables.h \
user.c cup.h file.h finance.h fixture.h free.h game_gui.h league.h live_game.h main.h maths.h misc.h name.h option.h player.h support.h team.h transfer.h treeview.h user.h window.h xml_mmatches.h youth_academy.h \ user.c cup.h file.h finance.h fixture.h free.h game_gui.h league.h live_game.h main.h maths.h misc.h name.h option.h player.h support.h team.h transfer.h treeview.h user.h window.h xml_mmatches.h youth_academy.h \
window.c callbacks.h file.h finance.h free.h game_gui.h gui.h interface.h league.h live_game.h load_save.h main.h misc2_interface.h misc_callback_func.h misc_interface.h option_gui.h option.h options_interface.h support.h transfer.h treeview2.h treeview.h treeview_helper.h user.h window.h \ window.c callbacks.h file.h finance.h free.h game_gui.h gui.h interface.h league.h live_game.h load_save.h main.h misc2_interface.h misc_callback_func.h misc_interface.h option_gui.h option.h options_interface.h support.h transfer.h treeview2.h treeview.h treeview_helper.h user.h window.h \
@@ -59,7 +59,7 @@ bygfoot_SOURCES = \
xml_loadsave_league_stat.c file.h misc.h stat.h team.h xml.h xml_loadsave_league_stat.h \ xml_loadsave_league_stat.c file.h misc.h stat.h team.h xml.h xml_loadsave_league_stat.h \
xml_loadsave_live_game.c cup.h file.h fixture.h league.h live_game.h misc.h option.h variables.h xml.h xml_loadsave_live_game.h \ xml_loadsave_live_game.c cup.h file.h fixture.h league.h live_game.h misc.h option.h variables.h xml.h xml_loadsave_live_game.h \
xml_loadsave_misc.c cup.h file.h misc.h variables.h xml.h xml_loadsave_cup.h xml_loadsave_league.h xml_loadsave_misc.h \ xml_loadsave_misc.c cup.h file.h misc.h variables.h xml.h xml_loadsave_cup.h xml_loadsave_league.h xml_loadsave_misc.h \
xml_loadsave_players.c player.h team.h xml.h xml_loadsave_players.h \ xml_loadsave_players.c misc.h player.h team.h xml.h xml_loadsave_players.h \
xml_loadsave_season_stats.c file.h free.h misc.h stat.h variables.h xml.h xml_loadsave_league_stat.h xml_loadsave_season_stats.h \ xml_loadsave_season_stats.c file.h free.h misc.h stat.h variables.h xml.h xml_loadsave_league_stat.h xml_loadsave_season_stats.h \
xml_loadsave_table.c file.h misc.h team.h xml.h xml_loadsave_table.h \ xml_loadsave_table.c file.h misc.h team.h xml.h xml_loadsave_table.h \
xml_loadsave_teams.c file.h misc.h player.h team.h xml.h xml_loadsave_players.h xml_loadsave_teams.h \ xml_loadsave_teams.c file.h misc.h player.h team.h xml.h xml_loadsave_players.h xml_loadsave_teams.h \

View File

@@ -96,7 +96,7 @@ enum ExitCodes
*/ */
typedef struct typedef struct
{ {
GString *name, /**< Name of the country. */ gchar *name, /**< Name of the country. */
*symbol, /**< Symbol of the country, eg a flag pixmap. */ *symbol, /**< Symbol of the country, eg a flag pixmap. */
*sid; /**< Id of the country, eg 'england'. */ *sid; /**< Id of the country, eg 'england'. */

View File

@@ -368,8 +368,8 @@ callback_transfer_list_user(gint button, gint idx)
else else
strcat(buf3, _(" less")); strcat(buf3, _(" less"));
sprintf(buf, _("%s would like to buy %s. They offer %s for him, which is %s than the player's value. Do you accept?"), transoff(idx, 0).tm->name->str, sprintf(buf, _("%s would like to buy %s. They offer %s for him, which is %s than the player's value. Do you accept?"), transoff(idx, 0).tm->name,
player_of_id_team(current_user.tm, trans(idx).id)->name->str, player_of_id_team(current_user.tm, trans(idx).id)->name,
buf2, buf3); buf2, buf3);
stat1 = STATUS_TRANSFER_OFFER_USER; stat1 = STATUS_TRANSFER_OFFER_USER;
stat2 = idx; stat2 = idx;
@@ -409,7 +409,7 @@ callback_transfer_list_cpu(gint button, gint idx)
misc_print_grouped_int(transoff(idx, 0).wage, buf3); misc_print_grouped_int(transoff(idx, 0).wage, buf3);
sprintf(buf, _("You offered a transfer fee of %s and a wage of %s for %s. The owners and the player are satisfied with your offer. Do you still want to buy the player?"), sprintf(buf, _("You offered a transfer fee of %s and a wage of %s for %s. The owners and the player are satisfied with your offer. Do you still want to buy the player?"),
buf2, buf3, player_of_id_team(trans(idx).tm, trans(idx).id)->name->str); buf2, buf3, player_of_id_team(trans(idx).tm, trans(idx).id)->name);
stat1 = STATUS_TRANSFER_OFFER_CPU; stat1 = STATUS_TRANSFER_OFFER_CPU;
stat2 = idx; stat2 = idx;
window_show_transfer_dialog(buf); window_show_transfer_dialog(buf);
@@ -438,7 +438,7 @@ callback_transfer_list_clicked(gint button, gint idx)
if(team_is_user(tr->tm) != -1) if(team_is_user(tr->tm) != -1)
{ {
game_gui_print_message(_("User %s didn't consider your offer yet."), game_gui_print_message(_("User %s didn't consider your offer yet."),
user_from_team(tr->tm)->name->str); user_from_team(tr->tm)->name);
} }
else else
callback_transfer_list_cpu(button, idx); callback_transfer_list_cpu(button, idx);
@@ -464,7 +464,7 @@ callback_transfer_list_clicked(gint button, gint idx)
if(old_wage == -1) if(old_wage == -1)
{ {
sprintf(buf, _("You are making an offer for %s. Your scout's recommendations for fee and wage are preset."), sprintf(buf, _("You are making an offer for %s. Your scout's recommendations for fee and wage are preset."),
player_of_id_team(tr->tm, tr->id)->name->str); player_of_id_team(tr->tm, tr->id)->name);
window_show_digits(buf, _("Fee"), tr->fee[current_user.scout % 10], window_show_digits(buf, _("Fee"), tr->fee[current_user.scout % 10],
_("Wage"), tr->wage[current_user.scout % 10]); _("Wage"), tr->wage[current_user.scout % 10]);
@@ -472,7 +472,7 @@ callback_transfer_list_clicked(gint button, gint idx)
else else
{ {
sprintf(buf, _("You are making an offer for %s again. Your previous values for fee and wage are preset."), sprintf(buf, _("You are making an offer for %s again. Your previous values for fee and wage are preset."),
player_of_id_team(tr->tm, tr->id)->name->str); player_of_id_team(tr->tm, tr->id)->name);
window_show_digits(buf, _("Fee"), old_fee, _("Wage"), old_wage); window_show_digits(buf, _("Fee"), old_fee, _("Wage"), old_wage);
} }
@@ -511,7 +511,8 @@ callback_offer_new_contract(gint idx)
window_create(WINDOW_CONTRACT); window_create(WINDOW_CONTRACT);
sprintf(buf, _("You are negotiating with %s about a new contract. Pay attention to what you're doing; if you don't come to terms with him within %d offers, he's going to leave your team after his current contract expires (unless you sell him). You may only abort BEFORE making the first offer.\nYour scout's recommendations are preset:"), pl->name->str, sprintf(buf, _("You are negotiating with %s about a new contract. Pay attention to what you're doing; if you don't come to terms with him within %d offers, he's going to leave your team after his current contract expires (unless you sell him). You may only abort BEFORE making the first offer.\nYour scout's recommendations are preset:"),
pl->name,
const_int("int_contract_max_offers")); const_int("int_contract_max_offers"));
gtk_label_set_text(GTK_LABEL(lookup_widget(window.contract, "label_contract")), buf); gtk_label_set_text(GTK_LABEL(lookup_widget(window.contract, "label_contract")), buf);
@@ -636,7 +637,7 @@ callback_fire_player(gint idx)
misc_print_grouped_int(stat3, buf2); misc_print_grouped_int(stat3, buf2);
sprintf(buf, _("You want to fire %s. Since his contract expires in %.1f years, he demands a compensation of %s. Do you accept?"), pl->name->str, pl->contract, buf2); sprintf(buf, _("You want to fire %s. Since his contract expires in %.1f years, he demands a compensation of %s. Do you accept?"), pl->name, pl->contract, buf2);
window_show_yesno(buf); window_show_yesno(buf);
} }

View File

@@ -57,10 +57,10 @@ on_menu_save_activate (GtkMenuItem *menuitem,
gpointer user_data) gpointer user_data)
{ {
if(!opt_int("int_opt_save_will_overwrite") || if(!opt_int("int_opt_save_will_overwrite") ||
strlen(save_file->str) == 0) save_file == NULL)
on_menu_save_as_activate(NULL, NULL); on_menu_save_as_activate(NULL, NULL);
else else
load_save_save_game(save_file->str); load_save_save_game(save_file);
} }
@@ -474,7 +474,7 @@ on_menu_shoots_penalties_activate (GtkMenuItem *menuitem,
else else
{ {
game_gui_print_message(_("%s will shoot penalties and free kicks when he plays."), game_gui_print_message(_("%s will shoot penalties and free kicks when he plays."),
player_of_idx_team(current_user.tm, selected_row)->name->str); player_of_idx_team(current_user.tm, selected_row)->name);
opt_user_set_int("int_opt_user_penalty_shooter", opt_user_set_int("int_opt_user_penalty_shooter",
player_of_idx_team(current_user.tm, selected_row)->id); player_of_idx_team(current_user.tm, selected_row)->id);
treeview_show_user_player_list(); treeview_show_user_player_list();
@@ -1126,7 +1126,7 @@ on_mm_add_last_match_activate (GtkMenuItem *menuitem,
return; return;
} }
if(strlen(current_user.mmatches_file->str) == 0) if(current_user.mmatches_file == NULL)
{ {
stat5 = STATUS_SELECT_MM_FILE_ADD; stat5 = STATUS_SELECT_MM_FILE_ADD;
window_show_file_sel(); window_show_file_sel();
@@ -1140,7 +1140,7 @@ void
on_mm_manage_matches_activate (GtkMenuItem *menuitem, on_mm_manage_matches_activate (GtkMenuItem *menuitem,
gpointer user_data) gpointer user_data)
{ {
if(strlen(current_user.mmatches_file->str) == 0) if(current_user.mmatches_file == NULL)
{ {
stat5 = STATUS_SELECT_MM_FILE_LOAD; stat5 = STATUS_SELECT_MM_FILE_LOAD;
window_show_file_sel(); window_show_file_sel();

View File

@@ -21,10 +21,10 @@ cup_new(gboolean new_id)
{ {
Cup new; Cup new;
new.name = g_string_new(""); new.name = NULL;
new.short_name = g_string_new(""); new.short_name = NULL;
new.symbol = g_string_new(""); new.symbol = NULL;
new.sid = g_string_new(""); new.sid = NULL;
new.id = (new_id) ? cup_id_new : -1; new.id = (new_id) ? cup_id_new : -1;
new.group = -1; new.group = -1;
@@ -55,7 +55,7 @@ cup_choose_team_new(void)
{ {
CupChooseTeam new; CupChooseTeam new;
new.sid = g_string_new(""); new.sid = NULL;
new.number_of_teams = -1; new.number_of_teams = -1;
new.start_idx = new.end_idx = -1; new.start_idx = new.end_idx = -1;
new.randomly = FALSE; new.randomly = FALSE;
@@ -93,7 +93,7 @@ cup_reset(Cup *cup)
{ {
gint i, j; gint i, j;
g_ptr_array_free(cup->team_names, TRUE); free_gchar_array(&cup->team_names);
cup->team_names = g_ptr_array_new(); cup->team_names = g_ptr_array_new();
if(cup->teams->len > 0) if(cup->teams->len > 0)
@@ -137,7 +137,7 @@ query_cup_choose_team_is_league(const gchar *sid)
gint i; gint i;
for(i=0;i<ligs->len;i++) for(i=0;i<ligs->len;i++)
if(strcmp(lig(i).sid->str, sid) == 0) if(strcmp(lig(i).sid, sid) == 0)
return TRUE; return TRUE;
return FALSE; return FALSE;
@@ -154,14 +154,14 @@ cup_get_choose_team_league_cup(const CupChooseTeam *ct,
*league = NULL; *league = NULL;
*cup = NULL; *cup = NULL;
sscanf(ct->sid->str, "%[^0-9]%d", trash, &idx); sscanf(ct->sid, "%[^0-9]%d", trash, &idx);
if(g_str_has_prefix(ct->sid->str, "LEAGUE")) if(g_str_has_prefix(ct->sid, "LEAGUE"))
{ {
*league = &lig(idx - 1); *league = &lig(idx - 1);
*cup = NULL; *cup = NULL;
} }
else if(g_str_has_prefix(ct->sid->str, "CUP")) else if(g_str_has_prefix(ct->sid, "CUP"))
{ {
*cup = &cp(idx - 1); *cup = &cp(idx - 1);
*league = NULL; *league = NULL;
@@ -170,7 +170,7 @@ cup_get_choose_team_league_cup(const CupChooseTeam *ct,
{ {
for(i=0;i<ligs->len;i++) for(i=0;i<ligs->len;i++)
{ {
if(strcmp(lig(i).sid->str, ct->sid->str) == 0) if(strcmp(lig(i).sid, ct->sid) == 0)
{ {
*league = &lig(i); *league = &lig(i);
*cup = NULL; *cup = NULL;
@@ -180,7 +180,7 @@ cup_get_choose_team_league_cup(const CupChooseTeam *ct,
for(i=0;i<cps->len;i++) for(i=0;i<cps->len;i++)
{ {
if(strcmp(cp(i).sid->str, ct->sid->str) == 0) if(strcmp(cp(i).sid, ct->sid) == 0)
{ {
*cup = &cp(i); *cup = &cp(i);
*league = NULL; *league = NULL;
@@ -192,7 +192,7 @@ cup_get_choose_team_league_cup(const CupChooseTeam *ct,
if(*league == NULL && *cup == NULL) if(*league == NULL && *cup == NULL)
{ {
g_warning("cup_get_choose_team_league_cup: no league nor cup found for chooseteam %s", g_warning("cup_get_choose_team_league_cup: no league nor cup found for chooseteam %s",
ct->sid->str); ct->sid);
main_exit_program(EXIT_CHOOSE_TEAM_ERROR, NULL); main_exit_program(EXIT_CHOOSE_TEAM_ERROR, NULL);
} }
} }
@@ -208,11 +208,11 @@ cup_get_team_pointers(Cup *cup, gint round)
GPtrArray *teams = cup_round->team_ptrs; GPtrArray *teams = cup_round->team_ptrs;
if(debug > 60) if(debug > 60)
printf("cup_get_team_pointers %s \n", cup->name->str); printf("cup_get_team_pointers %s \n", cup->name);
if(teams->len > 0) if(teams->len > 0)
g_warning("cup_get_team_pointers: round %d in cup %s has non-empty team pointers array.", g_warning("cup_get_team_pointers: round %d in cup %s has non-empty team pointers array.",
round, cup->name->str); round, cup->name);
for(i=0;i<cup_round->choose_teams->len;i++) for(i=0;i<cup_round->choose_teams->len;i++)
if(g_array_index(cup_round->choose_teams, CupChooseTeam, i).generate) if(g_array_index(cup_round->choose_teams, CupChooseTeam, i).generate)
@@ -238,7 +238,7 @@ cup_get_team_pointers(Cup *cup, gint round)
if(debug > 70) if(debug > 70)
for(i=0;i<teams->len;i++) for(i=0;i<teams->len;i++)
printf("cup_get_team_pointers: %d %s \n", i, ((Team*)g_ptr_array_index(teams, i))->name->str); printf("cup_get_team_pointers: %d %s \n", i, ((Team*)g_ptr_array_index(teams, i))->name);
} }
/** Get the pointers to the teams (already generated, in one of the leagues or cups) /** Get the pointers to the teams (already generated, in one of the leagues or cups)
@@ -254,8 +254,8 @@ cup_load_choose_team(Cup *cup, GPtrArray *teams, const CupChooseTeam *ct)
const Cup *cup_temp = NULL; const Cup *cup_temp = NULL;
if(debug > 60) if(debug > 60)
printf("cup_load_choose_team: %s, %s \n", cup->name->str, printf("cup_load_choose_team: %s, %s \n", cup->name,
ct->sid->str); ct->sid);
cup_get_choose_team_league_cup(ct, &league, &cup_temp); cup_get_choose_team_league_cup(ct, &league, &cup_temp);
@@ -270,7 +270,7 @@ cup_load_choose_team(Cup *cup, GPtrArray *teams, const CupChooseTeam *ct)
g_array_index(league->table.elements, TableElement, j).team_id)); g_array_index(league->table.elements, TableElement, j).team_id));
g_ptr_array_add( g_ptr_array_add(
cup->team_names, cup->team_names,
g_strdup(team_of_id(g_array_index(league->table.elements, TableElement, j).team_id)->name->str)); g_strdup(team_of_id(g_array_index(league->table.elements, TableElement, j).team_id)->name));
} }
} }
else else
@@ -290,7 +290,7 @@ cup_load_choose_team(Cup *cup, GPtrArray *teams, const CupChooseTeam *ct)
if(debug > 80) if(debug > 80)
printf("team %s isinint %d numteams %d\n", printf("team %s isinint %d numteams %d\n",
team_of_id(g_array_index(league->table.elements, team_of_id(g_array_index(league->table.elements,
TableElement, order[j]).team_id)->name->str, TableElement, order[j]).team_id)->name,
query_team_is_in_cups( query_team_is_in_cups(
team_of_id(g_array_index(league->table.elements, team_of_id(g_array_index(league->table.elements,
TableElement, order[j]).team_id), TableElement, order[j]).team_id),
@@ -304,7 +304,7 @@ cup_load_choose_team(Cup *cup, GPtrArray *teams, const CupChooseTeam *ct)
team_of_id(g_array_index(league->table.elements, TableElement, order[j]).team_id)); team_of_id(g_array_index(league->table.elements, TableElement, order[j]).team_id));
g_ptr_array_add( g_ptr_array_add(
cup->team_names, cup->team_names,
g_strdup(team_of_id(g_array_index(league->table.elements, TableElement, order[j]).team_id)->name->str)); g_strdup(team_of_id(g_array_index(league->table.elements, TableElement, order[j]).team_id)->name));
number_of_teams++; number_of_teams++;
if(number_of_teams == ct->number_of_teams) if(number_of_teams == ct->number_of_teams)
@@ -317,7 +317,7 @@ cup_load_choose_team(Cup *cup, GPtrArray *teams, const CupChooseTeam *ct)
number_of_teams != ct->number_of_teams) number_of_teams != ct->number_of_teams)
{ {
g_warning("cup_load_choose_team (1): not enough teams (that don't participate in international cups yet) found in chooseteam %s for cup %s (%d specified, %d found) cup group %d.\n ", g_warning("cup_load_choose_team (1): not enough teams (that don't participate in international cups yet) found in chooseteam %s for cup %s (%d specified, %d found) cup group %d.\n ",
ct->sid->str, cup->name->str, ct->number_of_teams, number_of_teams, cup->group); ct->sid, cup->name, ct->number_of_teams, number_of_teams, cup->group);
main_exit_program(EXIT_CHOOSE_TEAM_ERROR, NULL); main_exit_program(EXIT_CHOOSE_TEAM_ERROR, NULL);
} }
} }
@@ -328,7 +328,7 @@ cup_load_choose_team(Cup *cup, GPtrArray *teams, const CupChooseTeam *ct)
if(lig(0).teams->len < ct->number_of_teams) if(lig(0).teams->len < ct->number_of_teams)
{ {
g_warning("cup_load_choose_team: not enough teams in league 0 for chooseteam %s (%d; required: %d) in cup %s\n", g_warning("cup_load_choose_team: not enough teams in league 0 for chooseteam %s (%d; required: %d) in cup %s\n",
ct->sid->str, lig(0).teams->len, ct->number_of_teams, cup->name->str); ct->sid, lig(0).teams->len, ct->number_of_teams, cup->name);
main_exit_program(EXIT_CHOOSE_TEAM_ERROR, NULL); main_exit_program(EXIT_CHOOSE_TEAM_ERROR, NULL);
} }
@@ -345,7 +345,7 @@ cup_load_choose_team(Cup *cup, GPtrArray *teams, const CupChooseTeam *ct)
Team, permutation[i - ct->start_idx + 1])); Team, permutation[i - ct->start_idx + 1]));
g_ptr_array_add(cup->team_names, g_ptr_array_add(cup->team_names,
g_strdup(g_array_index(lig(0).teams, g_strdup(g_array_index(lig(0).teams,
Team, permutation[i - ct->start_idx + 1]).name->str)); Team, permutation[i - ct->start_idx + 1]).name));
number_of_teams++; number_of_teams++;
} }
@@ -356,7 +356,7 @@ cup_load_choose_team(Cup *cup, GPtrArray *teams, const CupChooseTeam *ct)
if(number_of_teams != ct->number_of_teams) if(number_of_teams != ct->number_of_teams)
{ {
g_warning("cup_load_choose_team (2): not enough teams found in league 0 for chooseteam %s (%d; required: %d) in cup %s (group %d)\n", g_warning("cup_load_choose_team (2): not enough teams found in league 0 for chooseteam %s (%d; required: %d) in cup %s (group %d)\n",
ct->sid->str, number_of_teams, ct->number_of_teams, cup->name->str, cup->group); ct->sid, number_of_teams, ct->number_of_teams, cup->name, cup->group);
main_exit_program(EXIT_CHOOSE_TEAM_ERROR, NULL); main_exit_program(EXIT_CHOOSE_TEAM_ERROR, NULL);
} }
} }
@@ -382,7 +382,7 @@ cup_load_choose_team(Cup *cup, GPtrArray *teams, const CupChooseTeam *ct)
{ {
g_ptr_array_add(teams, g_ptr_array_index(cup_teams_sorted, j)); g_ptr_array_add(teams, g_ptr_array_index(cup_teams_sorted, j));
g_ptr_array_add(cup->team_names, g_ptr_array_add(cup->team_names,
g_strdup(((Team*)g_ptr_array_index(cup_teams_sorted, j))->name->str)); g_strdup(((Team*)g_ptr_array_index(cup_teams_sorted, j))->name));
number_of_teams++; number_of_teams++;
if(number_of_teams == ct->number_of_teams) if(number_of_teams == ct->number_of_teams)
@@ -396,7 +396,7 @@ cup_load_choose_team(Cup *cup, GPtrArray *teams, const CupChooseTeam *ct)
number_of_teams != ct->number_of_teams) number_of_teams != ct->number_of_teams)
{ {
g_warning("cup_load_choose_team(3): not enough teams (that don't participate in international cups yet) found in chooseteam %s for cup %s (%d specified, %d found) cup group %d.\n ", g_warning("cup_load_choose_team(3): not enough teams (that don't participate in international cups yet) found in chooseteam %s for cup %s (%d specified, %d found) cup group %d.\n ",
ct->sid->str, cup->name->str, ct->number_of_teams, number_of_teams, cup->group); ct->sid, cup->name, ct->number_of_teams, number_of_teams, cup->group);
main_exit_program(EXIT_CHOOSE_TEAM_ERROR, NULL); main_exit_program(EXIT_CHOOSE_TEAM_ERROR, NULL);
} }
} }
@@ -404,7 +404,7 @@ cup_load_choose_team(Cup *cup, GPtrArray *teams, const CupChooseTeam *ct)
if(debug > 80) if(debug > 80)
for(i=debug_num;i<teams->len;i++) for(i=debug_num;i<teams->len;i++)
printf("cup_load_choose_team: %d %s \n", i, ((Team*)g_ptr_array_index(teams, i))->name->str); printf("cup_load_choose_team: %d %s \n", i, ((Team*)g_ptr_array_index(teams, i))->name);
} }
/** Load the teams specified in the chooseteam from a non-country league. */ /** Load the teams specified in the chooseteam from a non-country league. */
@@ -418,12 +418,12 @@ cup_load_choose_team_generate(Cup *cup, CupRound *cup_round, const CupChooseTeam
GPtrArray *sids = NULL; GPtrArray *sids = NULL;
if(debug > 60) if(debug > 60)
printf("cup_load_choose_team_generate: %s, %s \n", cup->name->str, printf("cup_load_choose_team_generate: %s, %s \n", cup->name,
ct->sid->str); ct->sid);
leagues = g_array_new(FALSE, FALSE, sizeof(League)); leagues = g_array_new(FALSE, FALSE, sizeof(League));
teams_local = g_array_new(FALSE, FALSE, sizeof(Team)); teams_local = g_array_new(FALSE, FALSE, sizeof(Team));
sids = misc_separate_strings(ct->sid->str); sids = misc_separate_strings(ct->sid);
for(j=0;j<sids->len;j++) for(j=0;j<sids->len;j++)
{ {
@@ -472,7 +472,7 @@ cup_load_choose_team_generate(Cup *cup, CupRound *cup_round, const CupChooseTeam
if(teams_local->len < end_idx) if(teams_local->len < end_idx)
{ {
g_warning("cup_load_choose_team_generate: not enough teams (%d) in chooseteam %s in cup %s (%d are specified) \n", g_warning("cup_load_choose_team_generate: not enough teams (%d) in chooseteam %s in cup %s (%d are specified) \n",
teams_local->len, ct->sid->str, cup->name->str, end_idx); teams_local->len, ct->sid, cup->name, end_idx);
free_teams_array(&teams_local, FALSE); free_teams_array(&teams_local, FALSE);
main_exit_program(EXIT_CHOOSE_TEAM_ERROR, NULL); main_exit_program(EXIT_CHOOSE_TEAM_ERROR, NULL);
@@ -485,7 +485,7 @@ cup_load_choose_team_generate(Cup *cup, CupRound *cup_round, const CupChooseTeam
g_array_append_val(cup_round->teams, g_array_index(teams_local, Team, permutation[j])); g_array_append_val(cup_round->teams, g_array_index(teams_local, Team, permutation[j]));
g_array_index(cup_round->teams, Team, cup_round->teams->len - 1).clid = cup->id; g_array_index(cup_round->teams, Team, cup_round->teams->len - 1).clid = cup->id;
g_ptr_array_add(cup->team_names, g_ptr_array_add(cup->team_names,
g_strdup(g_array_index(cup_round->teams, Team, cup_round->teams->len - 1).name->str)); g_strdup(g_array_index(cup_round->teams, Team, cup_round->teams->len - 1).name));
number_of_teams++; number_of_teams++;
} }
@@ -498,7 +498,7 @@ cup_load_choose_team_generate(Cup *cup, CupRound *cup_round, const CupChooseTeam
(ct->number_of_teams == -1 && number_of_teams != teams_local->len)) && (ct->number_of_teams == -1 && number_of_teams != teams_local->len)) &&
teams_local->len > 0) teams_local->len > 0)
{ {
g_warning("cup_load_choose_team_generate: not enough teams (that don't participate in international cups yet) found in chooseteam %s for cup %s (%d specified, %d found).\n ", ct->sid->str, cup->name->str, ct->number_of_teams, number_of_teams); g_warning("cup_load_choose_team_generate: not enough teams (that don't participate in international cups yet) found in chooseteam %s for cup %s (%d specified, %d found).\n ", ct->sid, cup->name, ct->number_of_teams, number_of_teams);
main_exit_program(EXIT_CHOOSE_TEAM_ERROR, NULL); main_exit_program(EXIT_CHOOSE_TEAM_ERROR, NULL);
} }
@@ -669,7 +669,7 @@ cup_get_first_week_of_cup_round(const Cup *cup, gint cup_round)
if(week_number <= 0) 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); 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, cup_round, week_number);
main_exit_program(EXIT_FIRST_WEEK_ERROR, NULL); main_exit_program(EXIT_FIRST_WEEK_ERROR, NULL);
} }
@@ -850,7 +850,7 @@ cup_from_sid(const gchar *sid)
gint i; gint i;
for(i=0;i<cps->len;i++) for(i=0;i<cps->len;i++)
if(strcmp(cp(i).sid->str, sid) == 0) if(strcmp(cp(i).sid, sid) == 0)
return &cp(i); return &cp(i);
g_warning("cup_from_sid: didn't find cup with sid %s \n", sid); g_warning("cup_from_sid: didn't find cup with sid %s \n", sid);

View File

@@ -61,7 +61,7 @@ typedef struct
{ {
/** The string id of the league we choose from. /** The string id of the league we choose from.
Default: "". */ Default: "". */
GString *sid; gchar *sid;
/** The number of teams chosen. /** The number of teams chosen.
Default: -1 (ie. all teams are chosen). */ Default: -1 (ie. all teams are chosen). */
gint number_of_teams; gint number_of_teams;
@@ -87,7 +87,7 @@ typedef struct
/** Name and short name of the cup, a pixmap path, /** Name and short name of the cup, a pixmap path,
and the string id (e.g. england_fa or so). and the string id (e.g. england_fa or so).
Default: "". */ Default: "". */
GString *name, *short_name, *symbol, *sid; gchar *name, *short_name, *symbol, *sid;
/** Numerical id. */ /** Numerical id. */
gint id; gint id;
/** An integer specifying which cups are mutually exclusive for /** An integer specifying which cups are mutually exclusive for
@@ -115,7 +115,7 @@ typedef struct
gint next_fixture_update_week; gint next_fixture_update_week;
gint next_fixture_update_week_round; gint next_fixture_update_week_round;
/** A GString pointer array of properties (like "national"). */ /** A gchar pointer array of properties (like "national"). */
GPtrArray *properties; GPtrArray *properties;
/** The rounds of the cup. /** The rounds of the cup.
@see #CupRound*/ @see #CupRound*/

View File

@@ -381,11 +381,11 @@ file_save_opt_file(const gchar *filename, OptionList *optionlist)
file_my_fopen(filename, "w", &fil, TRUE); file_my_fopen(filename, "w", &fil, TRUE);
for(i=0;i<optionlist->list->len;i++) for(i=0;i<optionlist->list->len;i++)
if(g_str_has_prefix(g_array_index(optionlist->list, Option, i).name->str, "string_")) if(g_str_has_prefix(g_array_index(optionlist->list, Option, i).name, "string_"))
fprintf(fil, "%s %s\n", g_array_index(optionlist->list, Option, i).name->str, fprintf(fil, "%s %s\n", g_array_index(optionlist->list, Option, i).name,
g_array_index(optionlist->list, Option, i).string_value->str); g_array_index(optionlist->list, Option, i).string_value);
else else
fprintf(fil, "%s %d\n", g_array_index(optionlist->list, Option, i).name->str, fprintf(fil, "%s %d\n", g_array_index(optionlist->list, Option, i).name,
g_array_index(optionlist->list, Option, i).value); g_array_index(optionlist->list, Option, i).value);
fclose(fil); fclose(fil);
@@ -407,10 +407,10 @@ file_load_opt_file(const gchar *filename, OptionList *optionlist)
while(file_get_next_opt_line(fil, opt_name, opt_value)) while(file_get_next_opt_line(fil, opt_name, opt_value))
{ {
new.name = g_string_new(opt_name); new.name = g_strdup(opt_name);
if(g_str_has_prefix(opt_name, "string_")) if(g_str_has_prefix(opt_name, "string_"))
{ {
new.string_value = g_string_new(opt_value); new.string_value = g_strdup(opt_value);
new.value = -1; new.value = -1;
} }
else else
@@ -420,19 +420,19 @@ file_load_opt_file(const gchar *filename, OptionList *optionlist)
} }
g_array_append_val(optionlist->list, new); g_array_append_val(optionlist->list, new);
if((g_str_has_suffix(new.name->str, "_unix") && os_is_unix) || if((g_str_has_suffix(new.name, "_unix") && os_is_unix) ||
(g_str_has_suffix(new.name->str, "_win32") && !os_is_unix)) (g_str_has_suffix(new.name, "_win32") && !os_is_unix))
{ {
strcpy(opt_name, new.name->str); strcpy(opt_name, new.name);
opt_name[strlen(new.name->str) - (os_is_unix ? 5 : 6)] = '\0'; opt_name[strlen(new.name) - (os_is_unix ? 5 : 6)] = '\0';
new.name = g_string_new(opt_name); new.name = g_strdup(opt_name);
new.string_value = g_string_new(opt_value); new.string_value = g_strdup(opt_value);
g_array_append_val(optionlist->list, new); g_array_append_val(optionlist->list, new);
} }
} }
for(i=0;i<optionlist->list->len;i++) for(i=0;i<optionlist->list->len;i++)
g_datalist_set_data(&optionlist->datalist, g_array_index(optionlist->list, Option, i).name->str, g_datalist_set_data(&optionlist->datalist, g_array_index(optionlist->list, Option, i).name,
&g_array_index(optionlist->list, Option, i)); &g_array_index(optionlist->list, Option, i));
fclose(fil); fclose(fil);
@@ -465,7 +465,7 @@ file_load_user_conf_file(User *user)
FILE *fil = NULL; FILE *fil = NULL;
gchar *conf_file = NULL, buf[SMALL]; gchar *conf_file = NULL, buf[SMALL];
sprintf(buf, "bygfoot_%s.conf", user->name->str); sprintf(buf, "bygfoot_%s.conf", user->name);
conf_file = file_find_support_file(buf, FALSE); conf_file = file_find_support_file(buf, FALSE);
if(conf_file == NULL || if(conf_file == NULL ||

View File

@@ -83,7 +83,7 @@ fixture_update(Cup *cup)
if(round + 1 > cup->rounds->len - 1) if(round + 1 > cup->rounds->len - 1)
{ {
g_warning("fixture_update: round index %d too high for round array (%d) in cup %s\n", g_warning("fixture_update: round index %d too high for round array (%d) in cup %s\n",
round + 1, cup->rounds->len - 1, cup->name->str); round + 1, cup->rounds->len - 1, cup->name);
g_ptr_array_free(teams, TRUE); g_ptr_array_free(teams, TRUE);
main_exit_program(EXIT_CUP_ROUND_ERROR, NULL); main_exit_program(EXIT_CUP_ROUND_ERROR, NULL);
} }
@@ -287,7 +287,7 @@ fixture_write_cup_round_robin(Cup *cup, gint cup_round, GPtrArray *teams)
if(teams->len < number_of_groups) if(teams->len < number_of_groups)
{ {
g_warning("fixture_write_cup_round_robin: cup %s round %d: number of teams (%d) less than number of groups (%d)\n", cup->name->str, cup_round, teams->len, number_of_groups); g_warning("fixture_write_cup_round_robin: cup %s round %d: number of teams (%d) less than number of groups (%d)\n", cup->name, cup_round, teams->len, number_of_groups);
main_exit_program(EXIT_FIXTURE_WRITE_ERROR, NULL); main_exit_program(EXIT_FIXTURE_WRITE_ERROR, NULL);
} }
@@ -297,7 +297,8 @@ fixture_write_cup_round_robin(Cup *cup, gint cup_round, GPtrArray *teams)
for(i=0;i<number_of_groups;i++) for(i=0;i<number_of_groups;i++)
{ {
table_group[i].name = g_string_new(cup->name->str); table_group[i].name = NULL;
misc_string_assign(&table_group[i].name, cup->name);
table_group[i].clid = cup->id; table_group[i].clid = cup->id;
table_group[i].round = cup_round; table_group[i].round = cup_round;
table_group[i].elements = g_array_new(FALSE, FALSE, sizeof(TableElement)); table_group[i].elements = g_array_new(FALSE, FALSE, sizeof(TableElement));
@@ -752,7 +753,7 @@ fixture_get_first_leg(const Fixture *fix)
if(first_leg == NULL) if(first_leg == NULL)
g_warning("fixture_get_first_leg: didn't find first leg match; cup %s round %d\n", g_warning("fixture_get_first_leg: didn't find first leg match; cup %s round %d\n",
cup_from_clid(fix->clid)->name->str, fix->round); cup_from_clid(fix->clid)->name, fix->round);
return first_leg; return first_leg;
} }

View File

@@ -6,7 +6,7 @@
/** /**
Free all memory allocated by the program. Free all memory allocated by the program.
This mainly means we have to free a lot of GStrings This mainly means we have to free a lot of strings
and GArrays. */ and GArrays. */
void void
free_memory(void) free_memory(void)
@@ -55,22 +55,22 @@ free_season_stats(gboolean reset)
for(j=0;j<g_array_index(season_stats, SeasonStat, i).league_champs->len;j++) for(j=0;j<g_array_index(season_stats, SeasonStat, i).league_champs->len;j++)
{ {
g_string_free( free_gchar_ptr(
g_array_index( g_array_index(
g_array_index(season_stats, SeasonStat, i).league_champs, ChampStat, j).cl_name, TRUE); g_array_index(season_stats, SeasonStat, i).league_champs, ChampStat, j).cl_name);
g_string_free( free_gchar_ptr(
g_array_index( g_array_index(
g_array_index(season_stats, SeasonStat, i).league_champs, ChampStat, j).team_name, TRUE); g_array_index(season_stats, SeasonStat, i).league_champs, ChampStat, j).team_name);
} }
for(j=0;j<g_array_index(season_stats, SeasonStat, i).cup_champs->len;j++) for(j=0;j<g_array_index(season_stats, SeasonStat, i).cup_champs->len;j++)
{ {
g_string_free( free_gchar_ptr(
g_array_index( g_array_index(
g_array_index(season_stats, SeasonStat, i).cup_champs, ChampStat, j).cl_name, TRUE); g_array_index(season_stats, SeasonStat, i).cup_champs, ChampStat, j).cl_name);
g_string_free( free_gchar_ptr(
g_array_index( g_array_index(
g_array_index(season_stats, SeasonStat, i).cup_champs, ChampStat, j).team_name, TRUE); g_array_index(season_stats, SeasonStat, i).cup_champs, ChampStat, j).team_name);
} }
g_array_free(g_array_index(season_stats, SeasonStat, i).cup_champs, TRUE); g_array_free(g_array_index(season_stats, SeasonStat, i).cup_champs, TRUE);
@@ -112,9 +112,9 @@ free_user(User *user)
{ {
gint i; gint i;
free_g_string(&user->name); free_gchar_ptr(user->name);
free_g_string(&user->sponsor.name); free_g_string(&user->sponsor.name);
free_g_string(&user->mmatches_file); free_gchar_ptr(user->mmatches_file);
free_live_game(&user->live_game); free_live_game(&user->live_game);
free_option_list(&user->options, FALSE); free_option_list(&user->options, FALSE);
@@ -123,8 +123,8 @@ free_user(User *user)
free_g_array(&user->events); free_g_array(&user->events);
for(i=0;i<user->history->len;i++) for(i=0;i<user->history->len;i++)
g_string_free(g_array_index(user->history, free_gchar_ptr(g_array_index(user->history,
UserHistory, i).value_string, TRUE); UserHistory, i).value_string);
free_g_array(&user->history); free_g_array(&user->history);
free_mmatches(&user->mmatches, FALSE); free_mmatches(&user->mmatches, FALSE);
@@ -149,7 +149,7 @@ free_mmatches(GArray **mmatches, gboolean reset)
for(i=0;i<(*mmatches)->len;i++) for(i=0;i<(*mmatches)->len;i++)
{ {
free_g_string(&g_array_index(*mmatches, MemMatch, i).competition_name); free_g_string(&g_array_index(*mmatches, MemMatch, i).competition_name);
free_g_string(&g_array_index(*mmatches, MemMatch, i).country_name); free_gchar_ptr(g_array_index(*mmatches, MemMatch, i).country_name);
free_live_game(&g_array_index(*mmatches, MemMatch, i).lg); free_live_game(&g_array_index(*mmatches, MemMatch, i).lg);
} }
free_g_array(mmatches); free_g_array(mmatches);
@@ -162,7 +162,7 @@ free_mmatches(GArray **mmatches, gboolean reset)
void void
free_event(Event *event) free_event(Event *event)
{ {
free_g_string(&event->value_string); free_gchar_ptr(event->value_string);
} }
/** Free an array of options. /** Free an array of options.
@@ -187,8 +187,8 @@ free_option_list(OptionList *optionlist, gboolean reset)
for(i=0;i<optionlist->list->len;i++) for(i=0;i<optionlist->list->len;i++)
{ {
free_g_string(&g_array_index(optionlist->list, Option, i).name); free_gchar_ptr(g_array_index(optionlist->list, Option, i).name);
free_g_string(&g_array_index(optionlist->list, Option, i).string_value); free_gchar_ptr(g_array_index(optionlist->list, Option, i).string_value);
} }
free_g_array(&optionlist->list); free_g_array(&optionlist->list);
@@ -210,15 +210,15 @@ free_live_game(LiveGame *match)
return; return;
for(i=0;i<match->units->len;i++) for(i=0;i<match->units->len;i++)
free_g_string(&g_array_index(match->units, LiveGameUnit, i).event.commentary); free_gchar_ptr(g_array_index(match->units, LiveGameUnit, i).event.commentary);
for(i=0;i<2;i++) for(i=0;i<2;i++)
{ {
free_g_string(&match->team_names[i]); free_gchar_ptr(match->team_names[i]);
for(j=0;j<LIVE_GAME_STAT_ARRAY_END;j++) for(j=0;j<LIVE_GAME_STAT_ARRAY_END;j++)
{ {
for(k=0;k<match->stats.players[i][j]->len;k++) for(k=0;k<match->stats.players[i][j]->len;k++)
free_g_string((GString**)&g_ptr_array_index(match->stats.players[i][j], k)); g_free(g_ptr_array_index(match->stats.players[i][j], k));
free_g_ptr_array(&match->stats.players[i][j]); free_g_ptr_array(&match->stats.players[i][j]);
} }
@@ -234,16 +234,9 @@ free_live_game(LiveGame *match)
void void
free_country(gboolean reset) free_country(gboolean reset)
{ {
gint i; free_gchar_ptr(country.name);
GString **strings[3] = free_gchar_ptr(country.symbol);
{&country.name, &country.symbol, &country.sid}; free_gchar_ptr(country.sid);
for(i=0;i<3;i++)
{
free_g_string(strings[i]);
if(reset)
*strings[i] = g_string_new("");
}
free_leagues_array(&ligs, reset); free_leagues_array(&ligs, reset);
free_cups_array(&cps, reset); free_cups_array(&cps, reset);
@@ -285,26 +278,18 @@ free_leagues_array(GArray **leagues, gboolean reset)
void void
free_league(League *league) free_league(League *league)
{ {
gint i; free_gchar_ptr(league->name);
GString **strings[6] = free_gchar_ptr(league->short_name);
{&league->name, free_gchar_ptr(league->symbol);
&league->short_name, free_gchar_ptr(league->sid);
&league->symbol, free_gchar_ptr(league->prom_rel.prom_games_dest_sid);
&league->sid, free_gchar_ptr(league->prom_rel.prom_games_cup_sid);
&league->prom_rel.prom_games_dest_sid,
&league->prom_rel.prom_games_cup_sid};
GArray **arrays[2] =
{&league->teams,
&league->prom_rel.elements};
for(i=0;i<6;i++)
free_g_string(strings[i]);
if(league->teams != NULL) if(league->teams != NULL)
free_teams_array(&league->teams, FALSE); free_teams_array(&league->teams, FALSE);
for(i=0;i<2;i++) free_g_array(&league->teams);
free_g_array(arrays[i]); free_g_array(&league->prom_rel.elements);;
free_table(&league->table); free_table(&league->table);
@@ -320,19 +305,19 @@ free_league_stats(LeagueStat *stats)
gint i; gint i;
for(i=0;i<stats->teams_off->len;i++) for(i=0;i<stats->teams_off->len;i++)
g_string_free(g_array_index(stats->teams_off, Stat, i).value_string, TRUE); free_gchar_ptr(g_array_index(stats->teams_off, Stat, i).value_string);
free_g_array(&stats->teams_off); free_g_array(&stats->teams_off);
for(i=0;i<stats->teams_def->len;i++) for(i=0;i<stats->teams_def->len;i++)
g_string_free(g_array_index(stats->teams_def, Stat, i).value_string, TRUE); free_gchar_ptr(g_array_index(stats->teams_def, Stat, i).value_string);
free_g_array(&stats->teams_def); free_g_array(&stats->teams_def);
for(i=0;i<stats->player_scorers->len;i++) for(i=0;i<stats->player_scorers->len;i++)
g_string_free(g_array_index(stats->player_scorers, Stat, i).value_string, TRUE); free_gchar_ptr(g_array_index(stats->player_scorers, Stat, i).value_string);
free_g_array(&stats->player_scorers); free_g_array(&stats->player_scorers);
for(i=0;i<stats->player_goalies->len;i++) for(i=0;i<stats->player_goalies->len;i++)
g_string_free(g_array_index(stats->player_goalies, Stat, i).value_string, TRUE); free_gchar_ptr(g_array_index(stats->player_goalies, Stat, i).value_string);
free_g_array(&stats->player_goalies); free_g_array(&stats->player_goalies);
} }
@@ -341,7 +326,7 @@ free_league_stats(LeagueStat *stats)
void void
free_table(Table *table) free_table(Table *table)
{ {
free_g_string(&table->name); free_gchar_ptr(table->name);
free_g_array(&table->elements); free_g_array(&table->elements);
} }
@@ -376,11 +361,11 @@ free_teams_array(GArray **teams, gboolean reset)
void void
free_team(Team *tm) free_team(Team *tm)
{ {
free_g_string(&tm->stadium.name); free_gchar_ptr(tm->stadium.name);
free_g_string(&tm->name); free_gchar_ptr(tm->name);
free_g_string(&tm->names_file); free_gchar_ptr(tm->names_file);
free_g_string(&tm->symbol); free_gchar_ptr(tm->symbol);
free_g_string(&tm->def_file); free_gchar_ptr(tm->def_file);
free_player_array(&tm->players); free_player_array(&tm->players);
} }
@@ -405,7 +390,7 @@ free_player_array(GArray **players)
void void
free_player(Player *pl) free_player(Player *pl)
{ {
free_g_string(&pl->name); free_gchar_ptr(pl->name);
free_g_array(&pl->cards); free_g_array(&pl->cards);
free_g_array(&pl->games_goals); free_g_array(&pl->games_goals);
@@ -444,14 +429,11 @@ void
free_cup(Cup *cup) free_cup(Cup *cup)
{ {
gint i, j; gint i, j;
GString **strings[4] =
{&cup->name,
&cup->short_name,
&cup->symbol,
&cup->sid};
for(i=0;i<4;i++) free_gchar_ptr(cup->name);
free_g_string(strings[i]); free_gchar_ptr(cup->short_name);
free_gchar_ptr(cup->symbol);
free_gchar_ptr(cup->sid);
for(i=0;i<cup->rounds->len;i++) for(i=0;i<cup->rounds->len;i++)
if(g_array_index(cup->rounds, CupRound, i).round_robin_number_of_groups > 0) if(g_array_index(cup->rounds, CupRound, i).round_robin_number_of_groups > 0)
@@ -484,7 +466,7 @@ free_cup(Cup *cup)
void void
free_cup_choose_team(CupChooseTeam *cup_choose_team) free_cup_choose_team(CupChooseTeam *cup_choose_team)
{ {
free_g_string(&cup_choose_team->sid); free_gchar_ptr(cup_choose_team->sid);
} }
/** Free some global variables (except for the country variable). */ /** Free some global variables (except for the country variable). */
@@ -497,7 +479,7 @@ free_variables(void)
free_option_list(&constants_app, FALSE); free_option_list(&constants_app, FALSE);
free_option_list(&lg_tokens, FALSE); free_option_list(&lg_tokens, FALSE);
free_g_string(&save_file); free_gchar_ptr(save_file);
g_rand_free(rand_generator); g_rand_free(rand_generator);
@@ -515,8 +497,8 @@ free_lg_commentary(gboolean reset)
{ {
for(j=0;j<lg_commentary[i]->len;j++) for(j=0;j<lg_commentary[i]->len;j++)
{ {
free_g_string(&g_array_index(lg_commentary[i], LGCommentary, j).text); free_gchar_ptr(g_array_index(lg_commentary[i], LGCommentary, j).text);
free_g_string(&g_array_index(lg_commentary[i], LGCommentary, j).condition); free_gchar_ptr(g_array_index(lg_commentary[i], LGCommentary, j).condition);
} }
free_g_array(&lg_commentary[i]); free_g_array(&lg_commentary[i]);
@@ -528,7 +510,7 @@ free_lg_commentary(gboolean reset)
} }
/** /**
Free a GPtrArray containing GStrings. Free a GPtrArray containing strings.
@param array The array to be freed. @param array The array to be freed.
*/ */
void void
@@ -540,7 +522,7 @@ free_gchar_array(GPtrArray **array)
return; return;
for(i=0;i<(*array)->len;i++) for(i=0;i<(*array)->len;i++)
g_free(g_ptr_array_index(*array, i)); free_gchar_ptr(g_ptr_array_index(*array, i));
free_g_ptr_array(array); free_g_ptr_array(array);
*array = NULL; *array = NULL;
@@ -596,7 +578,7 @@ free_support_dirs(void)
while(elem) while(elem)
{ {
g_free ((gchar*)elem->data); free_gchar_ptr(elem->data);
elem = elem->next; elem = elem->next;
} }
@@ -608,11 +590,13 @@ free_support_dirs(void)
void void
free_name_list(NameList *namelist, gboolean reset) free_name_list(NameList *namelist, gboolean reset)
{ {
gint i;
if(namelist->sid == NULL) if(namelist->sid == NULL)
{ {
if(reset) if(reset)
{ {
namelist->sid = g_string_new(""); namelist->sid = NULL;
namelist->first_names = g_ptr_array_new(); namelist->first_names = g_ptr_array_new();
namelist->last_names = g_ptr_array_new(); namelist->last_names = g_ptr_array_new();
} }
@@ -620,13 +604,19 @@ free_name_list(NameList *namelist, gboolean reset)
return; return;
} }
free_g_string(&namelist->sid); free_gchar_ptr(namelist->sid);
for(i=0;i<namelist->first_names->len;i++)
free_gchar_ptr(g_ptr_array_index(namelist->first_names, i));
free_g_ptr_array(&namelist->first_names); free_g_ptr_array(&namelist->first_names);
for(i=0;i<namelist->last_names->len;i++)
free_gchar_ptr(g_ptr_array_index(namelist->last_names, i));
free_g_ptr_array(&namelist->last_names); free_g_ptr_array(&namelist->last_names);
if(reset) if(reset)
{ {
namelist->sid = g_string_new(""); namelist->sid = NULL;
namelist->first_names = g_ptr_array_new(); namelist->first_names = g_ptr_array_new();
namelist->last_names = g_ptr_array_new(); namelist->last_names = g_ptr_array_new();
} }

View File

@@ -10,6 +10,8 @@
#include "team_struct.h" #include "team_struct.h"
#include "user_struct.h" #include "user_struct.h"
#define free_gchar_ptr(string) {g_free(string); string = NULL;}
void void
free_g_array(GArray **array); free_g_array(GArray **array);
@@ -100,4 +102,7 @@ free_names(gboolean reset);
void void
free_mmatches(GArray **mmatches, gboolean reset); free_mmatches(GArray **mmatches, gboolean reset);
void
free_ptr(gpointer *ptr);
#endif #endif

View File

@@ -159,7 +159,7 @@ game_get_player(const Team *tm, gint player_type,
{ {
if(i < 10) if(i < 10)
printf("prob %.3f ", probs[i]); printf("prob %.3f ", probs[i]);
printf("%d %20s health %d cskill %.2f\n", i, player_of_idx_team(tm, i)->name->str, printf("%d %20s health %d cskill %.2f\n", i, player_of_idx_team(tm, i)->name,
player_of_idx_team(tm, i)->health, player_of_idx_team(tm, i)->cskill); player_of_idx_team(tm, i)->health, player_of_idx_team(tm, i)->cskill);
} }
@@ -904,7 +904,6 @@ game_update_stats_player(gpointer live_game, gconstpointer live_game_unit)
player2 = unit->event.player2; player2 = unit->event.player2;
const Team *tm[2] = {((LiveGame*)live_game)->fix->teams[0], const Team *tm[2] = {((LiveGame*)live_game)->fix->teams[0],
((LiveGame*)live_game)->fix->teams[1]}; ((LiveGame*)live_game)->fix->teams[1]};
GString *new = NULL;
GPtrArray *players = NULL; GPtrArray *players = NULL;
if(unit->event.type == LIVE_GAME_EVENT_GOAL || if(unit->event.type == LIVE_GAME_EVENT_GOAL ||
@@ -926,50 +925,45 @@ game_update_stats_player(gpointer live_game, gconstpointer live_game_unit)
for(i=0;i<stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS]->len;i++) for(i=0;i<stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS]->len;i++)
{ {
if(g_str_has_prefix(((GString*)g_ptr_array_index( if(g_str_has_prefix((gchar*)g_ptr_array_index(
stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS], i))->str, stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS], i),
player_of_id_team(tm[team], player)->name->str)) player_of_id_team(tm[team], player)->name))
{ {
sprintf(buf, "%s %d%s", sprintf(buf, "%s %d%s",
((GString*)g_ptr_array_index( (gchar*)g_ptr_array_index(
stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS], i))->str, stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS], i),
minute, buf2); minute, buf2);
g_string_printf(((GString*)g_ptr_array_index( misc_string_assign((gchar**)&g_ptr_array_index(
stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS], i)), stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS], i), buf);
"%s", buf);
return; return;
} }
} }
sprintf(buf, "%s %d%s", player_of_id_team(tm[team], player)->name->str, sprintf(buf, "%s %d%s", player_of_id_team(tm[team], player)->name,
minute, buf2); minute, buf2);
new = g_string_new(buf); g_ptr_array_add(stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS], g_strdup(buf));
g_ptr_array_add(stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS], new);
} }
else else
{ {
strcpy(buf, ""); strcpy(buf, "");
if(unit->event.type == LIVE_GAME_EVENT_INJURY) if(unit->event.type == LIVE_GAME_EVENT_INJURY)
{ {
sprintf(buf, "%s", player_of_id_team(tm[team], player)->name->str); sprintf(buf, "%s", player_of_id_team(tm[team], player)->name);
players = stats->players[team][LIVE_GAME_STAT_ARRAY_INJURED]; players = stats->players[team][LIVE_GAME_STAT_ARRAY_INJURED];
} }
else if(unit->event.type == LIVE_GAME_EVENT_FOUL_YELLOW) else if(unit->event.type == LIVE_GAME_EVENT_FOUL_YELLOW)
{ {
sprintf(buf, "%s", player_of_id_team(tm[team], player2)->name->str); sprintf(buf, "%s", player_of_id_team(tm[team], player2)->name);
players = stats->players[team][LIVE_GAME_STAT_ARRAY_YELLOWS]; players = stats->players[team][LIVE_GAME_STAT_ARRAY_YELLOWS];
} }
else if(unit->event.type == LIVE_GAME_EVENT_SEND_OFF) else if(unit->event.type == LIVE_GAME_EVENT_SEND_OFF)
{ {
sprintf(buf, "%s", player_of_id_team(tm[team], player)->name->str); sprintf(buf, "%s", player_of_id_team(tm[team], player)->name);
players = stats->players[team][LIVE_GAME_STAT_ARRAY_REDS]; players = stats->players[team][LIVE_GAME_STAT_ARRAY_REDS];
} }
if(strlen(buf) > 0) if(strlen(buf) > 0)
{ g_ptr_array_add(players, strdup(buf));
new = g_string_new(buf);
g_ptr_array_add(players, new);
}
} }
} }
@@ -985,8 +979,8 @@ game_post_match(Fixture *fix)
if((debug > 100 && fixture_user_team_involved(fix) != -1) || if((debug > 100 && fixture_user_team_involved(fix) != -1) ||
debug > 130) debug > 130)
printf("game_post_match: %s - %s\n", printf("game_post_match: %s - %s\n",
fix->teams[0]->name->str, fix->teams[0]->name,
fix->teams[1]->name->str); fix->teams[1]->name);
if(query_fixture_has_tables(fix)) if(query_fixture_has_tables(fix))
table_update(fix); table_update(fix);
@@ -1013,11 +1007,11 @@ game_post_match(Fixture *fix)
if(team_is_user((Team*)g_ptr_array_index(teams, 0)) != -1) if(team_is_user((Team*)g_ptr_array_index(teams, 0)) != -1)
user_history_add(&usr(team_is_user((Team*)g_ptr_array_index(teams, 0))), user_history_add(&usr(team_is_user((Team*)g_ptr_array_index(teams, 0))),
USER_HISTORY_WIN_FINAL, ((Team*)g_ptr_array_index(teams, 0))->id, USER_HISTORY_WIN_FINAL, ((Team*)g_ptr_array_index(teams, 0))->id,
fix->clid, fix->round,((Team*)g_ptr_array_index(teams, 1))->name->str); fix->clid, fix->round,((Team*)g_ptr_array_index(teams, 1))->name);
else if(team_is_user((Team*)g_ptr_array_index(teams, 1)) != -1) else if(team_is_user((Team*)g_ptr_array_index(teams, 1)) != -1)
user_history_add(&usr(team_is_user((Team*)g_ptr_array_index(teams, 1))), user_history_add(&usr(team_is_user((Team*)g_ptr_array_index(teams, 1))),
USER_HISTORY_LOSE_FINAL, ((Team*)g_ptr_array_index(teams, 1))->id, USER_HISTORY_LOSE_FINAL, ((Team*)g_ptr_array_index(teams, 1))->id,
fix->clid, fix->round,((Team*)g_ptr_array_index(teams, 0))->name->str); fix->clid, fix->round,((Team*)g_ptr_array_index(teams, 0))->name);
g_ptr_array_free(teams, TRUE); g_ptr_array_free(teams, TRUE);
} }
else if(fixture_user_team_involved(fix) != -1) else if(fixture_user_team_involved(fix) != -1)

View File

@@ -208,7 +208,7 @@ game_gui_set_main_window_header(void)
GtkWidget *menu_users[2] = {lookup_widget(window.main, "menu_next_user"), GtkWidget *menu_users[2] = {lookup_widget(window.main, "menu_next_user"),
lookup_widget(window.main, "menu_previous_user")}; lookup_widget(window.main, "menu_previous_user")};
gtk_label_set_text(label_user, current_user.name->str); gtk_label_set_text(label_user, current_user.name);
gui_label_set_text_from_int(label_season, season, FALSE); gui_label_set_text_from_int(label_season, season, FALSE);
gui_label_set_text_from_int(label_week, week, FALSE); gui_label_set_text_from_int(label_week, week, FALSE);
gui_label_set_text_from_int(label_round, week_round, FALSE); gui_label_set_text_from_int(label_round, week_round, FALSE);
@@ -234,9 +234,8 @@ game_gui_set_main_window_header(void)
gtk_widget_hide(lookup_widget(window.main, "label29")); gtk_widget_hide(lookup_widget(window.main, "label29"));
} }
gtk_label_set_text(label_team, current_user.tm->name->str); gtk_label_set_text(label_team, current_user.tm->name);
gtk_label_set_text(label_league, gtk_label_set_text(label_league, league_cup_get_name_string(current_user.tm->clid));
league_from_clid(current_user.tm->clid)->name->str);
for(i=0;i<2;i++) for(i=0;i<2;i++)
gtk_widget_set_sensitive(menu_users[i], (users->len > 1)); gtk_widget_set_sensitive(menu_users[i], (users->len > 1));
@@ -424,9 +423,8 @@ game_gui_show_main(void)
user_show_sponsor_continue(); user_show_sponsor_continue();
} }
/** Print a message in the message area. */ /** Print a message in the message area. */
gboolean void
game_gui_print_message(gchar *format, ...) game_gui_print_message(gchar *format, ...)
{ {
gchar text[SMALL]; gchar text[SMALL];
@@ -436,13 +434,6 @@ game_gui_print_message(gchar *format, ...)
g_vsprintf(text, format, args); g_vsprintf(text, format, args);
va_end (args); va_end (args);
if(g_str_has_prefix(text, "___"))
{
gtk_entry_set_text(GTK_ENTRY(lookup_widget(window.main, "entry_message")),
text + 3);
g_free(format);
}
else
gtk_entry_set_text(GTK_ENTRY(lookup_widget(window.main, "entry_message")), text); gtk_entry_set_text(GTK_ENTRY(lookup_widget(window.main, "entry_message")), text);
if(timeout_id != -1) if(timeout_id != -1)
@@ -450,6 +441,15 @@ game_gui_print_message(gchar *format, ...)
timeout_id = g_timeout_add(const_int("int_game_gui_message_duration") * 1000, timeout_id = g_timeout_add(const_int("int_game_gui_message_duration") * 1000,
(GSourceFunc)game_gui_clear_entry_message, NULL); (GSourceFunc)game_gui_clear_entry_message, NULL);
}
/** Source function for the delay printing function. */
gboolean
game_gui_print_message_source(gpointer data)
{
game_gui_print_message((gchar*)data);
g_free(data);
return FALSE; return FALSE;
} }
@@ -459,17 +459,18 @@ void
game_gui_print_message_with_delay(const gchar *format, ...) game_gui_print_message_with_delay(const gchar *format, ...)
{ {
gchar text[SMALL]; gchar text[SMALL];
gchar *local_text = NULL;
va_list args; va_list args;
va_start (args, format); va_start (args, format);
g_vsprintf(text, format, args); g_vsprintf(text, format, args);
va_end (args); va_end (args);
local_text = g_strdup_printf("___%s", text); if(timeout_id != -1)
g_source_remove(timeout_id);
g_timeout_add(const_int("int_game_gui_message_delay") * 1000, g_timeout_add(const_int("int_game_gui_message_delay") * 1000,
(GSourceFunc)game_gui_print_message, local_text); (GSourceFunc)game_gui_print_message_source,
(gpointer)g_strdup(text));
} }
/** Function that gets called from time to time. */ /** Function that gets called from time to time. */
@@ -630,13 +631,13 @@ game_gui_show_job_offer(Team *team, gint type)
if(type == STATUS_JOB_OFFER_FIRE_FINANCE) if(type == STATUS_JOB_OFFER_FIRE_FINANCE)
sprintf(buf, _("The team owners have fired you because of financial mismanagement. Luckily, the owners of %s have heard of your dismissal and offer you a job. Here's some information on %s:"), sprintf(buf, _("The team owners have fired you because of financial mismanagement. Luckily, the owners of %s have heard of your dismissal and offer you a job. Here's some information on %s:"),
team->name->str, team->name->str); team->name, team->name);
else if(type == STATUS_JOB_OFFER_FIRE_FAILURE) else if(type == STATUS_JOB_OFFER_FIRE_FAILURE)
sprintf(buf, _("The team owners have fired you because of unsuccessfulness. Luckily, the owners of %s have heard of your dismissal and offer you a job. Here's some information on %s:"), sprintf(buf, _("The team owners have fired you because of unsuccessfulness. Luckily, the owners of %s have heard of your dismissal and offer you a job. Here's some information on %s:"),
team->name->str, team->name->str); team->name, team->name);
else if(type == STATUS_JOB_OFFER_SUCCESS) else if(type == STATUS_JOB_OFFER_SUCCESS)
sprintf(buf, _("The owners of %s are deeply impressed by your success with %s and would like to hire you. Here's some information on %s:"), sprintf(buf, _("The owners of %s are deeply impressed by your success with %s and would like to hire you. Here's some information on %s:"),
team->name->str, current_user.tm->name->str, team->name->str); team->name, current_user.tm->name, team->name);
strcpy(buf2, _("Accept?")); strcpy(buf2, _("Accept?"));
if(type != STATUS_JOB_OFFER_SUCCESS) if(type != STATUS_JOB_OFFER_SUCCESS)
@@ -644,8 +645,8 @@ game_gui_show_job_offer(Team *team, gint type)
gtk_label_set_text(label_text, buf); gtk_label_set_text(label_text, buf);
gtk_label_set_text(label_text2, buf2); gtk_label_set_text(label_text2, buf2);
gtk_label_set_text(label_name, team->name->str); gtk_label_set_text(label_name, team->name);
gtk_label_set_text(label_league, league_from_clid(team->clid)->name->str); gtk_label_set_text(label_league, league_cup_get_name_string(team->clid));
gui_label_set_text_from_int(label_rank, team_get_league_rank(team), FALSE); gui_label_set_text_from_int(label_rank, team_get_league_rank(team), FALSE);
misc_print_grouped_int(math_round_integer(team->stadium.capacity * misc_print_grouped_int(math_round_integer(team->stadium.capacity *
math_rndi(const_int("int_initial_money_lower"), math_rndi(const_int("int_initial_money_lower"),

View File

@@ -28,10 +28,13 @@ void
game_gui_show_warning(const gchar *format, ...) game_gui_show_warning(const gchar *format, ...)
__attribute__ ((format (printf, 1, 2))); __attribute__ ((format (printf, 1, 2)));
gboolean void
game_gui_print_message(gchar *format, ...) game_gui_print_message(gchar *format, ...)
__attribute__ ((format (printf, 1, 2))); __attribute__ ((format (printf, 1, 2)));
gboolean
game_gui_print_message_source(gpointer data);
void void
game_gui_print_message_with_delay(const gchar *format, ...) game_gui_print_message_with_delay(const gchar *format, ...)
__attribute__ ((format (printf, 1, 2))); __attribute__ ((format (printf, 1, 2)));

View File

@@ -22,20 +22,20 @@ league_new(gboolean new_id)
{ {
League new; League new;
new.name = g_string_new(""); new.name = NULL;
new.names_file = g_string_new(opt_str("string_opt_player_names_file")); new.names_file = g_strdup(opt_str("string_opt_player_names_file"));
new.sid = g_string_new(""); new.sid = NULL;
new.short_name = g_string_new(""); new.short_name = NULL;
new.symbol = g_string_new(""); new.symbol = NULL;
new.id = (new_id) ? league_id_new : -1; new.id = (new_id) ? league_id_new : -1;
new.layer = -1; new.layer = -1;
new.average_talent = 0; new.average_talent = 0;
new.prom_rel.prom_games_dest_sid = g_string_new(""); new.prom_rel.prom_games_dest_sid = NULL;
new.prom_rel.prom_games_loser_sid = g_string_new(""); new.prom_rel.prom_games_loser_sid = NULL;
new.prom_rel.prom_games_cup_sid = g_string_new(""); new.prom_rel.prom_games_cup_sid = NULL;
new.prom_rel.prom_games_number_of_advance = 1; new.prom_rel.prom_games_number_of_advance = 1;
new.prom_rel.elements = g_array_new(FALSE, FALSE, sizeof(PromRelElement)); new.prom_rel.elements = g_array_new(FALSE, FALSE, sizeof(PromRelElement));
@@ -69,7 +69,7 @@ prom_rel_element_new(void)
PromRelElement new; PromRelElement new;
new.ranks[0] = new.ranks[1] = 0; new.ranks[0] = new.ranks[1] = 0;
new.dest_sid = g_string_new(""); new.dest_sid = NULL;
new.type = PROM_REL_NONE; new.type = PROM_REL_NONE;
return new; return new;
@@ -311,7 +311,7 @@ league_index_from_sid(const gchar *sid)
gint i; gint i;
for(i=0;i<ligs->len;i++) for(i=0;i<ligs->len;i++)
if(strcmp(lig(i).sid->str, sid) == 0) if(strcmp(lig(i).sid, sid) == 0)
return i; return i;
g_warning("league_index_from_sid: no index found for sid '%s'.\n", sid); g_warning("league_index_from_sid: no index found for sid '%s'.\n", sid);
@@ -336,7 +336,7 @@ league_remove_team_with_id(League *league, gint id)
} }
g_warning("league_remove_team_with_id: team with id %d in league %s not found\n", g_warning("league_remove_team_with_id: team with id %d in league %s not found\n",
id, league->name->str); id, league->name);
} }
@@ -347,7 +347,7 @@ void
league_season_start(League *league) league_season_start(League *league)
{ {
gint i, j; gint i, j;
gint idx = league_index_from_sid(league->sid->str); gint idx = league_index_from_sid(league->sid);
gboolean user_champ = gboolean user_champ =
(team_is_user( (team_is_user(
team_of_id(g_array_index(lig(0).table.elements, TableElement, 0).team_id)) != -1); team_of_id(g_array_index(lig(0).table.elements, TableElement, 0).team_id)) != -1);
@@ -399,14 +399,14 @@ query_league_rank_in_prom_games(const League *league, gint rank)
for(i=0;i<ligs->len;i++) for(i=0;i<ligs->len;i++)
if(query_league_has_prom_games((&lig(i)))) if(query_league_has_prom_games((&lig(i))))
{ {
cup = cup_from_sid(lig(i).prom_rel.prom_games_cup_sid->str); cup = cup_from_sid(lig(i).prom_rel.prom_games_cup_sid);
for(k=0;k<cup->rounds->len;k++) for(k=0;k<cup->rounds->len;k++)
{ {
cup_round = &g_array_index(cup->rounds, CupRound, k); cup_round = &g_array_index(cup->rounds, CupRound, k);
for(j=0;j<cup_round->choose_teams->len;j++) for(j=0;j<cup_round->choose_teams->len;j++)
{ {
if(strcmp(g_array_index(cup_round->choose_teams, CupChooseTeam, j).sid->str, if(strcmp(g_array_index(cup_round->choose_teams, CupChooseTeam, j).sid,
league->sid->str) == 0 && league->sid) == 0 &&
((rank >= g_array_index(cup_round->choose_teams, ((rank >= g_array_index(cup_round->choose_teams,
CupChooseTeam, j).start_idx && CupChooseTeam, j).start_idx &&
rank <= g_array_index(cup_round->choose_teams, rank <= g_array_index(cup_round->choose_teams,
@@ -456,7 +456,7 @@ league_get_team_movements_prom_rel(const League *league, GArray *team_movements)
for(i=0;i<elements->len;i++) for(i=0;i<elements->len;i++)
{ {
dest_sids = misc_separate_strings( dest_sids = misc_separate_strings(
g_array_index(elements, PromRelElement, i).dest_sid->str); g_array_index(elements, PromRelElement, i).dest_sid);
gint dest_idcs_int[dest_sids->len]; gint dest_idcs_int[dest_sids->len];
gint dest_idcs_order[dest_sids->len]; gint dest_idcs_order[dest_sids->len];
@@ -494,8 +494,8 @@ league_get_team_movements_prom_games(const League *league, GArray *team_movement
gint i, j; gint i, j;
TeamMove new_move; TeamMove new_move;
GPtrArray *dest_sids = (up) ? GPtrArray *dest_sids = (up) ?
misc_separate_strings(league->prom_rel.prom_games_dest_sid->str) : misc_separate_strings(league->prom_rel.prom_games_dest_sid) :
misc_separate_strings(league->prom_rel.prom_games_loser_sid->str); misc_separate_strings(league->prom_rel.prom_games_loser_sid);
GArray *dest_idcs = NULL; GArray *dest_idcs = NULL;
gint dest_idcs_int[dest_sids->len]; gint dest_idcs_int[dest_sids->len];
gint dest_idcs_order[dest_sids->len]; gint dest_idcs_order[dest_sids->len];
@@ -544,12 +544,12 @@ league_get_team_movements(League *league, GArray *team_movements)
if(query_league_has_prom_games(league)) if(query_league_has_prom_games(league))
{ {
prom_cup = cup_from_sid(league->prom_rel.prom_games_cup_sid->str); prom_cup = cup_from_sid(league->prom_rel.prom_games_cup_sid);
if(prom_cup == NULL) if(prom_cup == NULL)
{ {
g_warning("league_get_team_movements: promotion games cup not found for league %s (cup sid %s).\n", g_warning("league_get_team_movements: promotion games cup not found for league %s (cup sid %s).\n",
league->name->str, league->prom_rel.prom_games_cup_sid->str); league->name, league->prom_rel.prom_games_cup_sid);
return; return;
} }
@@ -557,7 +557,7 @@ league_get_team_movements(League *league, GArray *team_movements)
league_get_team_movements_prom_games(league, team_movements, prom_games_teams, TRUE); league_get_team_movements_prom_games(league, team_movements, prom_games_teams, TRUE);
if(strlen(league->prom_rel.prom_games_loser_sid->str) > 0) if(league->prom_rel.prom_games_loser_sid != NULL)
league_get_team_movements_prom_games(league, team_movements, league_get_team_movements_prom_games(league, team_movements,
prom_games_teams, FALSE); prom_games_teams, FALSE);
@@ -609,11 +609,11 @@ league_team_movements_print(const GArray *team_movements,
{ {
tmove = &g_array_index(team_movements, TeamMove, i); tmove = &g_array_index(team_movements, TeamMove, i);
if(tmove->dest_assigned) if(tmove->dest_assigned)
printf("%-25s (%d) %s \t\t", tmove->tm.name->str, printf("%-25s (%d) %s \t\t", tmove->tm.name,
league_from_clid(tmove->tm.clid)->layer, league_from_clid(tmove->tm.clid)->layer,
lig(g_array_index(tmove->dest_idcs, gint, 0)).name->str); lig(g_array_index(tmove->dest_idcs, gint, 0)).name);
else else
printf("%-25s (%d) UNASSIGNED \t\t", tmove->tm.name->str, printf("%-25s (%d) UNASSIGNED \t\t", tmove->tm.name,
league_from_clid(tmove->tm.clid)->layer); league_from_clid(tmove->tm.clid)->layer);
for(j=0;j<tmove->dest_idcs->len;j++) for(j=0;j<tmove->dest_idcs->len;j++)
printf("%d ", g_array_index(tmove->dest_idcs, gint, j)); printf("%d ", g_array_index(tmove->dest_idcs, gint, j));
@@ -622,7 +622,7 @@ league_team_movements_print(const GArray *team_movements,
printf("%-20s Size Cursize\n", "League"); printf("%-20s Size Cursize\n", "League");
for(i=0;i<ligs->len;i++) for(i=0;i<ligs->len;i++)
printf("%-20s %d %d\n", lig(i).name->str, league_size[i], printf("%-20s %d %d\n", lig(i).name, league_size[i],
league_cur_size[i]); league_cur_size[i]);
} }
@@ -655,7 +655,7 @@ league_team_movements_assign_dest(GArray *team_movements, gint idx,
TeamMove *tmove = &g_array_index(team_movements, TeamMove, idx); TeamMove *tmove = &g_array_index(team_movements, TeamMove, idx);
if(debug > 60) if(debug > 60)
printf("league_team_movements_assign_dest %s\n", tmove->tm.name->str); printf("league_team_movements_assign_dest %s\n", tmove->tm.name);
if(tmove->dest_idcs->len == 1) if(tmove->dest_idcs->len == 1)
dest_idx = g_array_index(tmove->dest_idcs, gint, 0); dest_idx = g_array_index(tmove->dest_idcs, gint, 0);
@@ -672,14 +672,14 @@ league_team_movements_assign_dest(GArray *team_movements, gint idx,
if(league_cur_size[dest_idx] > league_size[dest_idx]) if(league_cur_size[dest_idx] > league_size[dest_idx])
{ {
g_warning("league_team_movements_assign_dest: no room in league %s for team %s.", g_warning("league_team_movements_assign_dest: no room in league %s for team %s.",
lig(dest_idx).name->str, tmove->tm.name->str); lig(dest_idx).name, tmove->tm.name);
main_exit_program(EXIT_PROM_REL, NULL); main_exit_program(EXIT_PROM_REL, NULL);
} }
tmove->dest_assigned = TRUE; tmove->dest_assigned = TRUE;
if(debug > 60) if(debug > 60)
g_print("%s %d -> %d\n", tmove->tm.name->str, g_print("%s %d -> %d\n", tmove->tm.name,
league_from_clid(tmove->tm.clid)->layer, league_from_clid(tmove->tm.clid)->layer,
league_from_clid(lig(dest_idx).id)->layer); league_from_clid(lig(dest_idx).id)->layer);
@@ -696,7 +696,7 @@ league_team_movements_assign_dest(GArray *team_movements, gint idx,
if(tmove->dest_idcs->len == 0) if(tmove->dest_idcs->len == 0)
{ {
g_warning("league_team_movements_assign_dest: no destinations left for team %s.", g_warning("league_team_movements_assign_dest: no destinations left for team %s.",
tmove->tm.name->str); tmove->tm.name);
main_exit_program(EXIT_PROM_REL, NULL); main_exit_program(EXIT_PROM_REL, NULL);
} }
} }

View File

@@ -8,10 +8,10 @@
#define league_cup_get_teams(clid) (clid < ID_CUP_START) ? ((gpointer)(league_from_clid(clid)->teams)) : ((gpointer)(cup_from_clid(clid)->teams)) #define league_cup_get_teams(clid) (clid < ID_CUP_START) ? ((gpointer)(league_from_clid(clid)->teams)) : ((gpointer)(cup_from_clid(clid)->teams))
#define league_cup_get_fixtures(clid) (clid < ID_CUP_START) ? (league_from_clid(clid)->fixtures) : (cup_from_clid(clid)->fixtures) #define league_cup_get_fixtures(clid) (clid < ID_CUP_START) ? (league_from_clid(clid)->fixtures) : (cup_from_clid(clid)->fixtures)
#define league_cup_get_name_string(clid) (clid < ID_CUP_START) ? league_from_clid(clid)->name->str : cup_from_clid(clid)->name->str #define league_cup_get_name_string(clid) (clid < ID_CUP_START) ? league_from_clid(clid)->name : cup_from_clid(clid)->name
#define league_cup_get_yellow_red(clid) (clid < ID_CUP_START) ? (league_from_clid(clid)->yellow_red) : (cup_from_clid(clid)->yellow_red) #define league_cup_get_yellow_red(clid) (clid < ID_CUP_START) ? (league_from_clid(clid)->yellow_red) : (cup_from_clid(clid)->yellow_red)
#define query_league_has_prom_games(league) (strlen(league->prom_rel.prom_games_dest_sid->str) > 0) #define query_league_has_prom_games(league) (league->prom_rel.prom_games_dest_sid != NULL)
/** A struct needed when managing promotions /** A struct needed when managing promotions
and relegations. */ and relegations. */

View File

@@ -22,7 +22,7 @@ enum PromRelType
typedef struct typedef struct
{ {
gint ranks[2]; /**< The range of teams; default 0 and 0 */ gint ranks[2]; /**< The range of teams; default 0 and 0 */
GString *dest_sid; /**< The id of the destination league. Default "" */ gchar *dest_sid; /**< The id of the destination league. Default "" */
gint type; /**< Type. Promotion or relegation or none. */ gint type; /**< Type. Promotion or relegation or none. */
} PromRelElement; } PromRelElement;
@@ -35,10 +35,10 @@ typedef struct
typedef struct typedef struct
{ {
/** The id of the league the promotion games winner gets promoted to. Default "" */ /** The id of the league the promotion games winner gets promoted to. Default "" */
GString *prom_games_dest_sid; gchar *prom_games_dest_sid;
/** The id of the league the promotion games losers get moved to. Default "" */ /** The id of the league the promotion games losers get moved to. Default "" */
GString *prom_games_loser_sid; gchar *prom_games_loser_sid;
/** Number of teams that advance from the promotion games. Default: 1. */ /** Number of teams that advance from the promotion games. Default: 1. */
gint prom_games_number_of_advance; gint prom_games_number_of_advance;
@@ -49,7 +49,7 @@ typedef struct
GArray *elements; GArray *elements;
/** The cup determining how the promotion games are handled. */ /** The cup determining how the promotion games are handled. */
GString *prom_games_cup_sid; gchar *prom_games_cup_sid;
} PromRel; } PromRel;
/** /**
@@ -60,11 +60,11 @@ typedef struct
typedef struct typedef struct
{ {
/** Default value "" */ /** Default value "" */
GString *name, *short_name, *sid, *symbol; gchar *name, *short_name, *sid, *symbol;
/** The sid of the player names file the /** The sid of the player names file the
teams in the league take their names from. teams in the league take their names from.
Default: 'general', meaning the 'player_names_general.xml' file. */ Default: 'general', meaning the 'player_names_general.xml' file. */
GString *names_file; gchar *names_file;
/** @see PromRel */ /** @see PromRel */
PromRel prom_rel; PromRel prom_rel;
/** Numerical id, as opposed to the string id 'sid'. */ /** Numerical id, as opposed to the string id 'sid'. */

View File

@@ -3,6 +3,7 @@
#include "cup.h" #include "cup.h"
#include "file.h" #include "file.h"
#include "fixture.h" #include "fixture.h"
#include "free.h"
#include "league.h" #include "league.h"
#include "lg_commentary.h" #include "lg_commentary.h"
#include "live_game.h" #include "live_game.h"
@@ -72,7 +73,7 @@ lg_commentary_generate(const LiveGame *live_game, LiveGameUnit *unit)
strcpy(buf, "FIXME!"); strcpy(buf, "FIXME!");
} }
unit->event.commentary = g_string_new(buf); unit->event.commentary = g_strdup(buf);
unit->event.commentary_id = (i == (*commentaries)->len) ? unit->event.commentary_id = (i == (*commentaries)->len) ?
-1 : g_array_index(*commentaries, LGCommentary, order[i]).id; -1 : g_array_index(*commentaries, LGCommentary, order[i]).id;
@@ -85,10 +86,7 @@ lg_commentary_generate(const LiveGame *live_game, LiveGameUnit *unit)
i != option_int("string_lg_commentary_token_yellow_limit", &lg_tokens) && i != option_int("string_lg_commentary_token_yellow_limit", &lg_tokens) &&
i != option_int("string_lg_commentary_token_team_layer0", &lg_tokens) && i != option_int("string_lg_commentary_token_team_layer0", &lg_tokens) &&
i != option_int("string_lg_commentary_token_team_layer1", &lg_tokens)) i != option_int("string_lg_commentary_token_team_layer1", &lg_tokens))
{ free_gchar_ptr(token_rep[i]);
g_free(token_rep[i]);
token_rep[i] = NULL;
}
} }
/** Check whether the commentary conditions are fulfilled and whether /** Check whether the commentary conditions are fulfilled and whether
@@ -98,13 +96,13 @@ lg_commentary_check_commentary(const LGCommentary *commentary, gchar *dest)
{ {
gchar buf[SMALL]; gchar buf[SMALL];
if(strlen(commentary->text->str) == 0 || if(strlen(commentary->text) == 0 ||
(commentary->condition != NULL && (commentary->condition != NULL &&
!lg_commentary_parse_condition(commentary->condition->str)) || !lg_commentary_parse_condition(commentary->condition)) ||
(repetition == FALSE && query_lg_commentary_is_repetition(commentary->id))) (repetition == FALSE && query_lg_commentary_is_repetition(commentary->id)))
return FALSE; return FALSE;
strcpy(dest, commentary->text->str); strcpy(dest, commentary->text);
do do
{ {
@@ -169,9 +167,6 @@ void lg_commentary_choose_random(gchar* s)
strcpy(s, start); strcpy(s, start);
} }
/** Replace simple arithmetic expressions like "1 + 2" /** Replace simple arithmetic expressions like "1 + 2"
and comparisons like "3 < 4" with the appropriate result. */ and comparisons like "3 < 4" with the appropriate result. */
void void
@@ -253,13 +248,13 @@ lg_commentary_replace_tokens(gchar *commentary_text)
for(i=0;i<lg_tokens.list->len;i++) for(i=0;i<lg_tokens.list->len;i++)
{ {
if(g_strrstr(commentary_text, if(g_strrstr(commentary_text,
g_array_index(lg_tokens.list, Option, i).string_value->str)) g_array_index(lg_tokens.list, Option, i).string_value))
{ {
if(token_rep[i] == NULL) if(token_rep[i] == NULL)
return FALSE; return FALSE;
else else
misc_string_replace_token(commentary_text, misc_string_replace_token(commentary_text,
g_array_index(lg_tokens.list, Option, i).string_value->str, g_array_index(lg_tokens.list, Option, i).string_value,
token_rep[i]); token_rep[i]);
} }
} }
@@ -443,9 +438,9 @@ lg_commentary_set_team_tokens(const LiveGameUnit *unit, const Fixture *fix)
if(unit->result[0] != unit->result[1]) if(unit->result[0] != unit->result[1])
{ {
token_rep[option_int("string_lg_commentary_token_team_losing", &lg_tokens)] = token_rep[option_int("string_lg_commentary_token_team_losing", &lg_tokens)] =
g_strdup(fix->teams[(unit->result[0] > unit->result[1])]->name->str); g_strdup(fix->teams[(unit->result[0] > unit->result[1])]->name);
token_rep[option_int("string_lg_commentary_token_team_winning", &lg_tokens)] = token_rep[option_int("string_lg_commentary_token_team_winning", &lg_tokens)] =
g_strdup(fix->teams[(unit->result[0] < unit->result[1])]->name->str); g_strdup(fix->teams[(unit->result[0] < unit->result[1])]->name);
token_rep[option_int("string_lg_commentary_token_team_losingn", &lg_tokens)] = token_rep[option_int("string_lg_commentary_token_team_losingn", &lg_tokens)] =
misc_int_to_char((unit->result[0] > unit->result[1])); misc_int_to_char((unit->result[0] > unit->result[1]));
token_rep[option_int("string_lg_commentary_token_team_winningn", &lg_tokens)] = token_rep[option_int("string_lg_commentary_token_team_winningn", &lg_tokens)] =
@@ -517,7 +512,7 @@ lg_commentary_set_player_tokens(const LiveGameUnit *unit, const Fixture *fix)
if(pl1 != NULL) if(pl1 != NULL)
{ {
token_rep[option_int("string_lg_commentary_token_player0", &lg_tokens)] = token_rep[option_int("string_lg_commentary_token_player0", &lg_tokens)] =
player_get_last_name(pl1->name->str); player_get_last_name(pl1->name);
token_rep[option_int("string_lg_commentary_token_player_goals0", &lg_tokens)] = token_rep[option_int("string_lg_commentary_token_player_goals0", &lg_tokens)] =
misc_int_to_char(player_games_goals_get(pl1, fix->clid, PLAYER_VALUE_GOALS)); misc_int_to_char(player_games_goals_get(pl1, fix->clid, PLAYER_VALUE_GOALS));
token_rep[option_int("string_lg_commentary_token_player_goals_all0", &lg_tokens)] = token_rep[option_int("string_lg_commentary_token_player_goals_all0", &lg_tokens)] =
@@ -527,7 +522,7 @@ lg_commentary_set_player_tokens(const LiveGameUnit *unit, const Fixture *fix)
if(pl2 != NULL) if(pl2 != NULL)
{ {
token_rep[option_int("string_lg_commentary_token_player1", &lg_tokens)] = token_rep[option_int("string_lg_commentary_token_player1", &lg_tokens)] =
player_get_last_name(pl2->name->str); player_get_last_name(pl2->name);
token_rep[option_int("string_lg_commentary_token_player_goals1", &lg_tokens)] = token_rep[option_int("string_lg_commentary_token_player_goals1", &lg_tokens)] =
misc_int_to_char(player_games_goals_get(pl2, fix->clid, PLAYER_VALUE_GOALS)); misc_int_to_char(player_games_goals_get(pl2, fix->clid, PLAYER_VALUE_GOALS));
token_rep[option_int("string_lg_commentary_token_player_goals_all1", &lg_tokens)] = token_rep[option_int("string_lg_commentary_token_player_goals_all1", &lg_tokens)] =
@@ -595,9 +590,9 @@ lg_commentary_initialize(const Fixture *fix)
token_rep[i] = NULL; token_rep[i] = NULL;
token_rep[option_int("string_lg_commentary_token_team_home", &lg_tokens)] = token_rep[option_int("string_lg_commentary_token_team_home", &lg_tokens)] =
g_strdup(fix->teams[0]->name->str); g_strdup(fix->teams[0]->name);
token_rep[option_int("string_lg_commentary_token_team_away", &lg_tokens)] = token_rep[option_int("string_lg_commentary_token_team_away", &lg_tokens)] =
g_strdup(fix->teams[1]->name->str); g_strdup(fix->teams[1]->name);
if(fix->teams[0]->clid < ID_CUP_START) if(fix->teams[0]->clid < ID_CUP_START)
token_rep[option_int("string_lg_commentary_token_team_layer0", &lg_tokens)] = token_rep[option_int("string_lg_commentary_token_team_layer0", &lg_tokens)] =

View File

@@ -6,10 +6,10 @@
typedef struct typedef struct
{ {
/** The commentary text (possibly containing tokens). */ /** The commentary text (possibly containing tokens). */
GString *text; gchar *text;
/** A condition (if not fulfilled, the commentary doesn't get /** A condition (if not fulfilled, the commentary doesn't get
shown). */ shown). */
GString *condition; gchar *condition;
/** Priority of the commentary (compared to /** Priority of the commentary (compared to
the other ones for the same event). the other ones for the same event).
The higher the priority the higher the The higher the priority the higher the

View File

@@ -53,7 +53,7 @@ live_game_calculate_fixture(Fixture *fix)
if((debug > 80 && fixture_user_team_involved(match->fix) != -1) || if((debug > 80 && fixture_user_team_involved(match->fix) != -1) ||
debug > 130) debug > 130)
printf("\n\nlive_game_calculate_fixture\n%04d %s %s %04d\n\n", printf("\n\nlive_game_calculate_fixture\n%04d %s %s %04d\n\n",
tm0->id, tm0->name->str, tm1->name->str, tm1->id); tm0->id, tm0->name, tm1->name, tm1->id);
do do
{ {
@@ -1375,16 +1375,16 @@ live_game_finish_unit(void)
if(-stat5 - 1000 == unit->event.type) if(-stat5 - 1000 == unit->event.type)
{ {
printf("type %d com **%s**", unit->event.type, unit->event.commentary->str); printf("type %d com **%s**", unit->event.type, unit->event.commentary);
if(g_strrstr(unit->event.commentary->str, "[") || if(g_strrstr(unit->event.commentary, "[") ||
g_strrstr(unit->event.commentary->str, "]") || g_strrstr(unit->event.commentary, "]") ||
g_strrstr(unit->event.commentary->str, "<") || g_strrstr(unit->event.commentary, "<") ||
g_strrstr(unit->event.commentary->str, ">") || g_strrstr(unit->event.commentary, ">") ||
g_strrstr(unit->event.commentary->str, "=") || g_strrstr(unit->event.commentary, "=") ||
g_strrstr(unit->event.commentary->str, " G ") || g_strrstr(unit->event.commentary, " G ") ||
g_strrstr(unit->event.commentary->str, " L ") || g_strrstr(unit->event.commentary, " L ") ||
g_strrstr(unit->event.commentary->str, " GE ") || g_strrstr(unit->event.commentary, " GE ") ||
g_strrstr(unit->event.commentary->str, " LE ")) g_strrstr(unit->event.commentary, " LE "))
printf(" ERROR?\n"); printf(" ERROR?\n");
else else
printf("\n"); printf("\n");
@@ -1519,8 +1519,8 @@ live_game_reset(LiveGame *live_game, Fixture *fix, gboolean free_variable)
if(fix != NULL) if(fix != NULL)
{ {
live_game->fix_id = fix->id; live_game->fix_id = fix->id;
live_game->team_names[0] = g_string_new(fix->teams[0]->name->str); live_game->team_names[0] = g_strdup(fix->teams[0]->name);
live_game->team_names[1] = g_string_new(fix->teams[1]->name->str); live_game->team_names[1] = g_strdup(fix->teams[1]->name);
} }
else else
{ {

View File

@@ -131,7 +131,7 @@ typedef struct
involved in the event. */ involved in the event. */
gint team, player, player2; gint team, player, player2;
/** The commentary for the event. */ /** The commentary for the event. */
GString *commentary; gchar *commentary;
/** Id of the commentary. */ /** Id of the commentary. */
gint commentary_id; gint commentary_id;
} LiveGameEvent; } LiveGameEvent;
@@ -177,7 +177,7 @@ typedef struct
gint fix_id; gint fix_id;
/** The names of the teams stored for later use (when the fixture /** The names of the teams stored for later use (when the fixture
already got freed). */ already got freed). */
GString *team_names[2]; gchar *team_names[2];
/** Substitutions left for the teams. */ /** Substitutions left for the teams. */
gint subs_left[2]; gint subs_left[2];
/** The team that started the game, 0 or 1. */ /** The team that started the game, 0 or 1. */

View File

@@ -4,6 +4,7 @@
#include "game_gui.h" #include "game_gui.h"
#include "language.h" #include "language.h"
#include "load_save.h" #include "load_save.h"
#include "misc.h"
#include "option.h" #include "option.h"
#include "support.h" #include "support.h"
#include "user.h" #include "user.h"
@@ -32,7 +33,7 @@ load_save_save_game(const gchar *filename)
g_strdup(filename) : g_strdup(filename) :
g_strdup_printf("%s%s", filename, const_str("string_fs_save_suffix")); g_strdup_printf("%s%s", filename, const_str("string_fs_save_suffix"));
g_string_printf(save_file, "%s", fullname); misc_string_assign(&save_file, fullname);
if(g_file_test(fullname, G_FILE_TEST_EXISTS)) if(g_file_test(fullname, G_FILE_TEST_EXISTS))
/*todo: replace with g_remove*/ /*todo: replace with g_remove*/
@@ -258,7 +259,7 @@ load_save_load_game(const gchar* filename, gboolean create_main_window)
sprintf(buf, "%s%s%s___*", dirname, G_DIR_SEPARATOR_S, prefix); sprintf(buf, "%s%s%s___*", dirname, G_DIR_SEPARATOR_S, prefix);
file_remove_files(buf); file_remove_files(buf);
g_string_printf(save_file, "%s", fullname); misc_string_assign(&save_file, fullname);
load_save_last_save_set(fullname); load_save_last_save_set(fullname);

View File

@@ -82,9 +82,9 @@ main_init_variables(void)
ligs = g_array_new(FALSE, FALSE, sizeof(League)); ligs = g_array_new(FALSE, FALSE, sizeof(League));
cps = g_array_new(FALSE, FALSE, sizeof(Cup));; cps = g_array_new(FALSE, FALSE, sizeof(Cup));;
acps = g_ptr_array_new(); acps = g_ptr_array_new();
country.name = g_string_new(""); country.name = NULL;
country.symbol = g_string_new(""); country.symbol = NULL;
country.sid = g_string_new("");; country.sid = NULL;;
season = week = week_round = 1; season = week = week_round = 1;
@@ -109,7 +109,7 @@ main_init_variables(void)
season_stats = g_array_new(FALSE, FALSE, sizeof(SeasonStat)); season_stats = g_array_new(FALSE, FALSE, sizeof(SeasonStat));
name_lists = g_array_new(FALSE, FALSE, sizeof(NameList)); name_lists = g_array_new(FALSE, FALSE, sizeof(NameList));
save_file = g_string_new(""); save_file = NULL;
constants_app.list = settings.list = constants_app.list = settings.list =
constants.list = options.list = lg_tokens.list = NULL; constants.list = options.list = lg_tokens.list = NULL;

View File

@@ -314,10 +314,12 @@ misc_parse_value(const gchar *s, gint *value)
const gchar* const gchar*
misc_parse_expression(const gchar *s, gint *result) misc_parse_expression(const gchar *s, gint *result)
{ {
gint value = 0; gint value = 0,
loop = 1;
s = misc_parse_value(s, &value); s = misc_parse_value(s, &value);
*result = value; *result = value;
gint loop = 1;
while (loop) { while (loop) {
s = misc_skip_spaces(s); s = misc_skip_spaces(s);
switch(*s) { switch(*s) {
@@ -453,3 +455,13 @@ misc_copy_ptr_array(const GPtrArray *array)
return copy; return copy;
} }
/** Free the string if it's non-NULL and assign the contents to it. */
void
misc_string_assign(gchar **string, const gchar *contents)
{
if(*string != NULL)
g_free(*string);
*string = g_strdup(contents);
}

View File

@@ -71,4 +71,7 @@ misc_parse(const gchar *s, gint *result);
GPtrArray* GPtrArray*
misc_copy_ptr_array(const GPtrArray *array); misc_copy_ptr_array(const GPtrArray *array);
void
misc_string_assign(gchar **string, const gchar *contents);
#endif #endif

View File

@@ -5,6 +5,7 @@
#include "free.h" #include "free.h"
#include "game_gui.h" #include "game_gui.h"
#include "maths.h" #include "maths.h"
#include "misc.h"
#include "misc2_callback_func.h" #include "misc2_callback_func.h"
#include "option.h" #include "option.h"
#include "player.h" #include "player.h"
@@ -47,11 +48,11 @@ misc2_callback_transfer_user_player(void)
else else
{ {
game_gui_show_warning(_("%s couldn't afford to buy %s or his roster was full."), game_gui_show_warning(_("%s couldn't afford to buy %s or his roster was full."),
user_from_team(new_team)->name->str, user_from_team(new_team)->name,
player_of_id_team(trans(stat2).tm, trans(stat2).id)->name->str); player_of_id_team(trans(stat2).tm, trans(stat2).id)->name);
user_event_add(user_from_team(new_team), EVENT_TYPE_WARNING, -1, -1, NULL, user_event_add(user_from_team(new_team), EVENT_TYPE_WARNING, -1, -1, NULL,
_("You didn't have enough money to buy %s or your roster was full."), _("You didn't have enough money to buy %s or your roster was full."),
player_of_id_team(trans(stat2).tm, trans(stat2).id)->name->str); player_of_id_team(trans(stat2).tm, trans(stat2).id)->name);
g_array_remove_index(trans(stat2).offers, 0); g_array_remove_index(trans(stat2).offers, 0);
if(trans(stat2).offers->len > 0 && if(trans(stat2).offers->len > 0 &&
transoff(stat2, 0).status == TRANSFER_OFFER_NOT_CONSIDERED) transoff(stat2, 0).status == TRANSFER_OFFER_NOT_CONSIDERED)
@@ -157,7 +158,7 @@ misc2_callback_contract_offer(void)
pl->contract += (i + 1); pl->contract += (i + 1);
pl->offers = 0; pl->offers = 0;
pl->wage = value; pl->wage = value;
game_gui_show_warning(_("%s accepts your offer."), pl->name->str); game_gui_show_warning(_("%s accepts your offer."), pl->name);
window_destroy(&window.contract, FALSE); window_destroy(&window.contract, FALSE);
} }
else else
@@ -165,12 +166,12 @@ misc2_callback_contract_offer(void)
pl->offers++; pl->offers++;
if(pl->offers < const_int("int_contract_max_offers")) if(pl->offers < const_int("int_contract_max_offers"))
game_gui_show_warning(_("%s rejects your offer. You may still make %d offers."), game_gui_show_warning(_("%s rejects your offer. You may still make %d offers."),
pl->name->str, pl->name,
const_int("int_contract_max_offers") - pl->offers); const_int("int_contract_max_offers") - pl->offers);
else else
{ {
game_gui_show_warning(_("%s rejects your offer and won't negotiate with you anymore. You should sell him before his contract expires (he'll simply leave your team otherwise)."), game_gui_show_warning(_("%s rejects your offer and won't negotiate with you anymore. You should sell him before his contract expires (he'll simply leave your team otherwise)."),
pl->name->str); pl->name);
window_destroy(&window.contract, FALSE); window_destroy(&window.contract, FALSE);
} }
} }
@@ -193,7 +194,7 @@ misc2_callback_add_user(void)
Team *tm = (Team*)treeview_helper_get_pointer(treeview_user_management_teams, 2); Team *tm = (Team*)treeview_helper_get_pointer(treeview_user_management_teams, 2);
if(strlen(user_name) > 0) if(strlen(user_name) > 0)
g_string_printf(new_user.name, "%s", user_name); misc_string_assign(&new_user.name, user_name);
gtk_entry_set_text(entry_user_management, ""); gtk_entry_set_text(entry_user_management, "");
@@ -234,7 +235,7 @@ misc2_callback_mmatches_button_press(GtkWidget *widget, gint row_num, gint col_n
{ {
gtk_widget_hide(widget); gtk_widget_hide(widget);
free_g_string(&g_array_index(current_user.mmatches, MemMatch, row_num).competition_name); free_g_string(&g_array_index(current_user.mmatches, MemMatch, row_num).competition_name);
free_g_string(&g_array_index(current_user.mmatches, MemMatch, row_num).country_name); free_gchar_ptr(g_array_index(current_user.mmatches, MemMatch, row_num).country_name);
free_live_game(&g_array_index(current_user.mmatches, MemMatch, row_num).lg); free_live_game(&g_array_index(current_user.mmatches, MemMatch, row_num).lg);
g_array_remove_index(current_user.mmatches, row_num); g_array_remove_index(current_user.mmatches, row_num);
treeview2_show_mmatches(); treeview2_show_mmatches();

View File

@@ -293,7 +293,7 @@ on_treeview_user_management_users_button_press_event
} }
stat2 = idx; stat2 = idx;
sprintf(buf, _("Remove user %s from the game?"), usr(idx).name->str); sprintf(buf, _("Remove user %s from the game?"), usr(idx).name);
window_show_yesno(buf); window_show_yesno(buf);
return FALSE; return FALSE;
@@ -524,7 +524,7 @@ on_button_mm_save_close_clicked (GtkButton *button,
gtk_entry_get_text(GTK_ENTRY(lookup_widget(window.mmatches, "entry_mm_file"))); gtk_entry_get_text(GTK_ENTRY(lookup_widget(window.mmatches, "entry_mm_file")));
user_mm_set_filename(filename, NULL); user_mm_set_filename(filename, NULL);
user_mm_save_file(current_user.mmatches_file->str, user_mm_save_file(current_user.mmatches_file,
current_user.mmatches); current_user.mmatches);
window_destroy(&window.mmatches, TRUE); window_destroy(&window.mmatches, TRUE);

View File

@@ -5,6 +5,7 @@
#include "gui.h" #include "gui.h"
#include "load_save.h" #include "load_save.h"
#include "maths.h" #include "maths.h"
#include "misc.h"
#include "misc_callback_func.h" #include "misc_callback_func.h"
#include "option.h" #include "option.h"
#include "start_end.h" #include "start_end.h"
@@ -82,7 +83,7 @@ misc_callback_add_player(void)
gtk_combo_box_get_active(combo_leagues); gtk_combo_box_get_active(combo_leagues);
if(strlen(player_name) > 0) if(strlen(player_name) > 0)
g_string_printf(new_user.name, "%s", player_name); misc_string_assign(&new_user.name, player_name);
gtk_entry_set_text(entry_player_name, ""); gtk_entry_set_text(entry_player_name, "");

View File

@@ -8,7 +8,7 @@
names list. If the names list is not found, create names list. If the names list is not found, create
it from file. If the file can't be found, either, it from file. If the file can't be found, either,
make some fuss and take one from the general names. */ make some fuss and take one from the general names. */
GString* gchar*
name_get(const gchar *names_file) name_get(const gchar *names_file)
{ {
gint i; gint i;
@@ -19,7 +19,7 @@ name_get(const gchar *names_file)
return name_get_from_random_list(); return name_get_from_random_list();
for(i=0;i<name_lists->len;i++) for(i=0;i<name_lists->len;i++)
if(strcmp(names_file, nli(i).sid->str) == 0) if(strcmp(names_file, nli(i).sid) == 0)
return name_get_from_list(&nli(i)); return name_get_from_list(&nli(i));
/** Create new name list. */ /** Create new name list. */
@@ -43,9 +43,9 @@ name_get(const gchar *names_file)
return name_get_from_list(&nli(name_lists->len - 1)); return name_get_from_list(&nli(name_lists->len - 1));
} }
/** Return a newly allocated GString with a randomly /** Return a newly allocated string with a randomly
picked combined name from the list. */ picked combined name from the list. */
GString* gchar*
name_get_from_list(const NameList *namelist) name_get_from_list(const NameList *namelist)
{ {
gchar buf[SMALL]; gchar buf[SMALL];
@@ -53,7 +53,7 @@ name_get_from_list(const NameList *namelist)
sprintf(buf, "%s %s", name_get_random_first_name(namelist), sprintf(buf, "%s %s", name_get_random_first_name(namelist),
name_get_random_last_name(namelist)); name_get_random_last_name(namelist));
return g_string_new(buf); return g_strdup(buf);
} }
/** Shorten a name list so that it doesn't occupy /** Shorten a name list so that it doesn't occupy
@@ -71,13 +71,13 @@ name_shorten_list(NameList *namelist)
const_float("float_name_first_last_ratio")) const_float("float_name_first_last_ratio"))
{ {
idx = math_rndi(0, namelist->first_names->len - 1); idx = math_rndi(0, namelist->first_names->len - 1);
g_string_free((GString*)g_ptr_array_index(namelist->first_names, idx), TRUE); g_free(g_ptr_array_index(namelist->first_names, idx));
g_ptr_array_remove_index_fast(namelist->first_names, idx); g_ptr_array_remove_index_fast(namelist->first_names, idx);
} }
else else
{ {
idx = math_rndi(0, namelist->last_names->len - 1); idx = math_rndi(0, namelist->last_names->len - 1);
g_string_free((GString*)g_ptr_array_index(namelist->last_names, idx), TRUE); g_free(g_ptr_array_index(namelist->last_names, idx));
g_ptr_array_remove_index_fast(namelist->last_names, idx); g_ptr_array_remove_index_fast(namelist->last_names, idx);
} }
} }
@@ -91,7 +91,7 @@ name_get_list_from_sid(const gchar *sid)
NameList new; NameList new;
for(i=0;i<name_lists->len;i++) for(i=0;i<name_lists->len;i++)
if(strcmp(sid, nli(i).sid->str) == 0) if(strcmp(sid, nli(i).sid) == 0)
return &nli(i); return &nli(i);
new.sid = NULL; new.sid = NULL;

View File

@@ -6,8 +6,8 @@
#include "maths.h" #include "maths.h"
#define nli(i) g_array_index(name_lists, NameList, i) #define nli(i) g_array_index(name_lists, NameList, i)
#define name_get_random_first_name(namelist) ((GString*)g_ptr_array_index(namelist->first_names, math_rndi(0, namelist->first_names->len - 1)))->str #define name_get_random_first_name(namelist) (gchar*)g_ptr_array_index(namelist->first_names, math_rndi(0, namelist->first_names->len - 1))
#define name_get_random_last_name(namelist) ((GString*)g_ptr_array_index(namelist->last_names, math_rndi(0, namelist->last_names->len - 1)))->str #define name_get_random_last_name(namelist) (gchar*)g_ptr_array_index(namelist->last_names, math_rndi(0, namelist->last_names->len - 1))
/** Get a name from a randomly picked name list. */ /** Get a name from a randomly picked name list. */
#define name_get_from_random_list() name_get_from_list(&nli(math_rndi(0, name_lists->len - 1))) #define name_get_from_random_list() name_get_from_list(&nli(math_rndi(0, name_lists->len - 1)))
@@ -15,10 +15,10 @@
void void
name_shorten_list(NameList *namelist); name_shorten_list(NameList *namelist);
GString* gchar*
name_get(const gchar *names_file); name_get(const gchar *names_file);
GString* gchar*
name_get_from_list(const NameList *namelist); name_get_from_list(const NameList *namelist);
NameList* NameList*

View File

@@ -8,8 +8,8 @@
typedef struct typedef struct
{ {
/** The file id (the part between 'player_names_' and '.xml'). */ /** The file id (the part between 'player_names_' and '.xml'). */
GString *sid; gchar *sid;
/** Arrays of GStrings holding the names. */ /** Arrays of strings holding the names. */
GPtrArray *first_names, GPtrArray *first_names,
*last_names; *last_names;

View File

@@ -1,4 +1,5 @@
#include "main.h" #include "main.h"
#include "misc.h"
#include "option.h" #include "option.h"
#include "variables.h" #include "variables.h"
@@ -15,7 +16,7 @@ option_string(const gchar *name, OptionList *optionlist)
if(element == NULL) if(element == NULL)
g_warning("option_string: option named %s not found\nMaybe you should delete the .bygfoot directory from your home dir", name); g_warning("option_string: option named %s not found\nMaybe you should delete the .bygfoot directory from your home dir", name);
else else
return ((Option*)element)->string_value->str; return ((Option*)element)->string_value;
main_exit_program(EXIT_OPTION_NOT_FOUND, NULL); main_exit_program(EXIT_OPTION_NOT_FOUND, NULL);
@@ -23,7 +24,7 @@ option_string(const gchar *name, OptionList *optionlist)
} }
/** Return the GString pointer going with the option. */ /** Return the GString pointer going with the option. */
GString* gchar**
option_string_pointer(const gchar *name, OptionList *optionlist) option_string_pointer(const gchar *name, OptionList *optionlist)
{ {
gpointer element = g_datalist_get_data(&optionlist->datalist, name); gpointer element = g_datalist_get_data(&optionlist->datalist, name);
@@ -31,7 +32,7 @@ option_string_pointer(const gchar *name, OptionList *optionlist)
if(element == NULL) if(element == NULL)
g_warning("option_string: option named %s not found\nMaybe you should delete the .bygfoot directory from your home dir", name); g_warning("option_string: option named %s not found\nMaybe you should delete the .bygfoot directory from your home dir", name);
else else
return ((Option*)element)->string_value; return &((Option*)element)->string_value;
main_exit_program(EXIT_OPTION_NOT_FOUND, NULL); main_exit_program(EXIT_OPTION_NOT_FOUND, NULL);
@@ -106,7 +107,7 @@ option_set_string(const gchar *name, OptionList *optionlist, const gchar *new_va
if(element == NULL) if(element == NULL)
g_warning("option_set_string: option named %s not found\nMaybe you should delete the .bygfoot directory from your home dir", name); g_warning("option_set_string: option named %s not found\nMaybe you should delete the .bygfoot directory from your home dir", name);
else else
g_string_printf(((Option*)element)->string_value, "%s", new_value); misc_string_assign(&((Option*)element)->string_value, new_value);
} }
/** Change the value of an int option in the array. /** Change the value of an int option in the array.
@@ -143,9 +144,9 @@ option_add(OptionList *optionlist, const gchar *name,
main_exit_program(EXIT_GENERAL, NULL); main_exit_program(EXIT_GENERAL, NULL);
} }
new.name = g_string_new(name); new.name = g_strdup(name);
new.value = int_value; new.value = int_value;
new.string_value = (string_value == NULL) ? NULL : g_string_new(string_value); new.string_value = (string_value == NULL) ? NULL : g_strdup(string_value);
if(optionlist->list == NULL) if(optionlist->list == NULL)
{ {
@@ -157,6 +158,6 @@ option_add(OptionList *optionlist, const gchar *name,
for(i=0;i<optionlist->list->len;i++) for(i=0;i<optionlist->list->len;i++)
g_datalist_set_data(&optionlist->datalist, g_datalist_set_data(&optionlist->datalist,
g_array_index(optionlist->list, Option, i).name->str, g_array_index(optionlist->list, Option, i).name,
&g_array_index(optionlist->list, Option, i)); &g_array_index(optionlist->list, Option, i));
} }

View File

@@ -48,7 +48,7 @@ option_int_pointer(const gchar *name, OptionList *optionlist);
gchar* gchar*
option_string(const gchar *name, OptionList *optionlist); option_string(const gchar *name, OptionList *optionlist);
GString* gchar**
option_string_pointer(const gchar *name, OptionList *optionlist); option_string_pointer(const gchar *name, OptionList *optionlist);
void void

View File

@@ -4,6 +4,7 @@
#include "language.h" #include "language.h"
#include "option.h" #include "option.h"
#include "option_gui.h" #include "option_gui.h"
#include "misc.h"
#include "support.h" #include "support.h"
#include "treeview.h" #include "treeview.h"
#include "user.h" #include "user.h"
@@ -361,7 +362,7 @@ enum EntryOptions
/** Write the pointers to the options and the corresponding widgets. */ /** Write the pointers to the options and the corresponding widgets. */
void void
option_gui_write_entry_widgets(GString **entry_options, GtkEntry **entry_widgets) option_gui_write_entry_widgets(gchar ***entry_options, GtkEntry **entry_widgets)
{ {
entry_widgets[ENTRY_OPT_CONSTANTS] = entry_widgets[ENTRY_OPT_CONSTANTS] =
GTK_ENTRY(lookup_widget(window.options, "entry_constants_file")); GTK_ENTRY(lookup_widget(window.options, "entry_constants_file"));
@@ -385,7 +386,7 @@ option_gui_set_up_window(void)
gint *spin_options[SPIN_OPT_END]; gint *spin_options[SPIN_OPT_END];
GtkEntry *entry_widgets[ENTRY_OPT_END]; GtkEntry *entry_widgets[ENTRY_OPT_END];
GString *entry_options[ENTRY_OPT_END]; gchar **entry_options[ENTRY_OPT_END];
treeview_show_language_combo(); treeview_show_language_combo();
@@ -400,7 +401,7 @@ option_gui_set_up_window(void)
gtk_spin_button_set_value(spin_widgets[i], (gfloat)(*(spin_options[i]))); gtk_spin_button_set_value(spin_widgets[i], (gfloat)(*(spin_options[i])));
for(i=0;i<ENTRY_OPT_END;i++) for(i=0;i<ENTRY_OPT_END;i++)
gtk_entry_set_text(entry_widgets[i], (entry_options[i])->str); gtk_entry_set_text(entry_widgets[i], *(entry_options[i]));
} }
/** Read the widget states in the options window and set the /** Read the widget states in the options window and set the
@@ -416,7 +417,7 @@ option_gui_write_options(void)
GtkSpinButton *spin_widgets[SPIN_OPT_END]; GtkSpinButton *spin_widgets[SPIN_OPT_END];
gint *spin_options[SPIN_OPT_END]; gint *spin_options[SPIN_OPT_END];
GtkEntry *entry_widgets[ENTRY_OPT_END]; GtkEntry *entry_widgets[ENTRY_OPT_END];
GString *entry_options[ENTRY_OPT_END]; gchar **entry_options[ENTRY_OPT_END];
language_set(language_index); language_set(language_index);
@@ -424,7 +425,6 @@ option_gui_write_options(void)
option_gui_write_spin_widgets(spin_options, spin_widgets); option_gui_write_spin_widgets(spin_options, spin_widgets);
option_gui_write_entry_widgets(entry_options, entry_widgets); option_gui_write_entry_widgets(entry_options, entry_widgets);
for(i=0;i<BOOL_OPT_END;i++) for(i=0;i<BOOL_OPT_END;i++)
*(bool_options[i]) = gtk_toggle_button_get_active(bool_widgets[i]); *(bool_options[i]) = gtk_toggle_button_get_active(bool_widgets[i]);
@@ -433,7 +433,7 @@ option_gui_write_options(void)
for(i=0;i<ENTRY_OPT_END;i++) for(i=0;i<ENTRY_OPT_END;i++)
{ {
g_string_printf(entry_options[i], "%s", gtk_entry_get_text(entry_widgets[i])); misc_string_assign(entry_options[i], gtk_entry_get_text(entry_widgets[i]));
if(i == ENTRY_OPT_CONSTANTS && if(i == ENTRY_OPT_CONSTANTS &&
strcmp(gtk_entry_get_text(entry_widgets[i]), opt_str("string_opt_constants_file")) != 0) strcmp(gtk_entry_get_text(entry_widgets[i]), opt_str("string_opt_constants_file")) != 0)

View File

@@ -10,7 +10,7 @@ void
option_gui_write_spin_widgets(gint **spin_options, GtkSpinButton **spin_widgets); option_gui_write_spin_widgets(gint **spin_options, GtkSpinButton **spin_widgets);
void void
option_gui_write_entry_widgets(GString **entry_options, GtkEntry **entry_widgets); option_gui_write_entry_widgets(gchar ***entry_options, GtkEntry **entry_widgets);
void void
option_gui_set_up_window(void); option_gui_set_up_window(void);

View File

@@ -4,7 +4,7 @@
/** A struct representing an option or a constant. */ /** A struct representing an option or a constant. */
typedef struct typedef struct
{ {
GString *name, *string_value; gchar *name, *string_value;
gint value; gint value;
} Option; } Option;

View File

@@ -30,10 +30,10 @@ on_button_options_ok_clicked (GtkButton *button,
if(save_user) if(save_user)
{ {
if(strcmp(current_user.name->str, "NONAME") == 0) if(strcmp(current_user.name, "NONAME") == 0)
sprintf(buf, "%s/bygfoot_user.conf", conf_dir); sprintf(buf, "%s/bygfoot_user.conf", conf_dir);
else else
sprintf(buf, "%s/bygfoot_%s.conf", conf_dir, current_user.name->str); sprintf(buf, "%s/bygfoot_%s.conf", conf_dir, current_user.name);
file_save_opt_file(buf, &current_user.options); file_save_opt_file(buf, &current_user.options);
} }

View File

@@ -27,7 +27,7 @@ player_new(Team *tm, gfloat average_talent, gboolean new_id)
Player new; Player new;
new.name = (new_id) ? new.name = (new_id) ?
name_get(tm->names_file->str) : g_string_new(""); name_get(tm->names_file) : NULL;
new.id = (new_id) ? player_id_new : -1; new.id = (new_id) ? player_id_new : -1;
new.pos = player_get_position_from_structure(tm->structure, tm->players->len); new.pos = player_get_position_from_structure(tm->structure, tm->players->len);
@@ -289,7 +289,7 @@ player_id_index(const Team *tm, gint player_id)
if(g_array_index(tm->players, Player, i).id == player_id) if(g_array_index(tm->players, Player, i).id == player_id)
return i; return i;
g_warning("player_id_index: didn't find player with id %d of team %s\n", player_id, tm->name->str); g_warning("player_id_index: didn't find player with id %d of team %s\n", player_id, tm->name);
main_exit_program(EXIT_INT_NOT_FOUND, NULL); main_exit_program(EXIT_INT_NOT_FOUND, NULL);
@@ -306,7 +306,7 @@ player_of_idx_team(const Team *tm, gint number)
if(tm->players->len <= number) if(tm->players->len <= number)
{ {
g_warning("player_of_idx_team: Player list of team %s too short for number %d.\n", g_warning("player_of_idx_team: Player list of team %s too short for number %d.\n",
tm->name->str, number); tm->name, number);
main_exit_program(EXIT_POINTER_NOT_FOUND, NULL); main_exit_program(EXIT_POINTER_NOT_FOUND, NULL);
@@ -330,7 +330,7 @@ player_of_id_team(const Team *tm, gint id)
if(g_array_index(tm->players, Player, i).id == id) if(g_array_index(tm->players, Player, i).id == id)
return &g_array_index(tm->players, Player, i); return &g_array_index(tm->players, Player, i);
g_warning("player_of_id_team: didn't find player with id %d of team %s\n", id, tm->name->str); g_warning("player_of_id_team: didn't find player with id %d of team %s\n", id, tm->name);
main_exit_program(EXIT_POINTER_NOT_FOUND, NULL); main_exit_program(EXIT_POINTER_NOT_FOUND, NULL);
@@ -1020,7 +1020,7 @@ player_update_streak(Player *pl)
else if(pl->streak == PLAYER_STREAK_COLD) else if(pl->streak == PLAYER_STREAK_COLD)
decrease_factor = 1; decrease_factor = 1;
else else
g_warning("player_update_streak: streak count is positive (%.1f) but player %s is not on a streak!\n", pl->streak_count, pl->name->str); g_warning("player_update_streak: streak count is positive (%.1f) but player %s is not on a streak!\n", pl->streak_count, pl->name);
pl->streak_count -= pl->streak_count -=
(pl->streak_prob * decrease_factor * (pl->streak_prob * decrease_factor *
@@ -1092,7 +1092,7 @@ player_update_weekly(Player *pl)
(pl->contract + 0.0192) * 12 > opt_user_int("int_opt_user_contract_limit")) (pl->contract + 0.0192) * 12 > opt_user_int("int_opt_user_contract_limit"))
user_event_add(user_from_team(pl->team), EVENT_TYPE_WARNING, user_event_add(user_from_team(pl->team), EVENT_TYPE_WARNING,
-1, -1, NULL, _("%s's contract expires in %.1f years."), -1, -1, NULL, _("%s's contract expires in %.1f years."),
pl->name->str, pl->contract); pl->name, pl->contract);
if(pl->contract <= 0) if(pl->contract <= 0)
player_remove_contract(pl); player_remove_contract(pl);
@@ -1112,7 +1112,7 @@ void
player_remove_contract(Player *pl) player_remove_contract(Player *pl)
{ {
user_event_add(user_from_team(pl->team), EVENT_TYPE_PLAYER_LEFT, -1, -1, NULL, user_event_add(user_from_team(pl->team), EVENT_TYPE_PLAYER_LEFT, -1, -1, NULL,
pl->name->str); pl->name);
player_remove_from_team(pl->team, player_id_index(pl->team, pl->id)); player_remove_from_team(pl->team, player_id_index(pl->team, pl->id));
} }
@@ -1177,7 +1177,7 @@ player_replace_by_new(Player *pl, gboolean free_player)
gint idx = player_id_index(tm, pl->id); gint idx = player_id_index(tm, pl->id);
Player new = player_new(tm, team_get_average_skill(tm, FALSE), FALSE); Player new = player_new(tm, team_get_average_skill(tm, FALSE), FALSE);
new.name = name_get(pl->team->names_file->str); new.name = name_get(pl->team->names_file);
new.pos = pl->pos; new.pos = pl->pos;
new.cpos = pl->cpos; new.cpos = pl->cpos;
new.id = pl->id; new.id = pl->id;

View File

@@ -91,7 +91,7 @@ enum PlayerValue
*/ */
typedef struct typedef struct
{ {
GString *name; gchar *name;
gint pos, /**< Position. @see #PlayerPos */ gint pos, /**< Position. @see #PlayerPos */
cpos, /**< Current position. @see #PlayerPos */ cpos, /**< Current position. @see #PlayerPos */

View File

@@ -247,9 +247,9 @@ end_week_round_results(void)
done++; done++;
fixture_result_to_buf(&g_array_index(lig(i).fixtures, Fixture, j), buf, FALSE); fixture_result_to_buf(&g_array_index(lig(i).fixtures, Fixture, j), buf, FALSE);
sprintf(buf2, "%s %s %s", sprintf(buf2, "%s %s %s",
g_array_index(lig(i).fixtures, Fixture, j).teams[0]->name->str, g_array_index(lig(i).fixtures, Fixture, j).teams[0]->name,
buf, buf,
g_array_index(lig(i).fixtures, Fixture, j).teams[1]->name->str); g_array_index(lig(i).fixtures, Fixture, j).teams[1]->name);
gui_show_progress((gfloat)done / num_matches, buf2); gui_show_progress((gfloat)done / num_matches, buf2);
if(debug > 120) if(debug > 120)
printf("%s \n", buf2); printf("%s \n", buf2);
@@ -267,9 +267,9 @@ end_week_round_results(void)
done++; done++;
fixture_result_to_buf(&g_array_index(acp(i)->fixtures, Fixture, j), buf, FALSE); fixture_result_to_buf(&g_array_index(acp(i)->fixtures, Fixture, j), buf, FALSE);
sprintf(buf2, "%s %s %s", sprintf(buf2, "%s %s %s",
g_array_index(acp(i)->fixtures, Fixture, j).teams[0]->name->str, g_array_index(acp(i)->fixtures, Fixture, j).teams[0]->name,
buf, buf,
g_array_index(acp(i)->fixtures, Fixture, j).teams[1]->name->str); g_array_index(acp(i)->fixtures, Fixture, j).teams[1]->name);
gui_show_progress((gfloat)done / num_matches, buf2); gui_show_progress((gfloat)done / num_matches, buf2);
if(debug > 120) if(debug > 120)
printf("%s \n", buf2); printf("%s \n", buf2);

View File

@@ -54,7 +54,6 @@ stat_update_league_players(League *league)
gint maxlen = const_int("int_stat_players_len"); gint maxlen = const_int("int_stat_players_len");
Stat new_stat; Stat new_stat;
for(i=0;i<league->teams->len;i++) for(i=0;i<league->teams->len;i++)
for(j=0;j<g_array_index(league->teams, Team, i).players->len;j++) for(j=0;j<g_array_index(league->teams, Team, i).players->len;j++)
{ {
@@ -80,7 +79,7 @@ stat_update_league_players(League *league)
{ {
pl = (Player*)g_ptr_array_index(players_sorted[i], j); pl = (Player*)g_ptr_array_index(players_sorted[i], j);
new_stat.team_id = pl->team->id; new_stat.team_id = pl->team->id;
new_stat.value_string = g_string_new(pl->name->str); new_stat.value_string = g_strdup(pl->name);
new_stat.value1 = new_stat.value1 =
player_games_goals_get(pl, pl->team->clid, PLAYER_VALUE_GOALS); player_games_goals_get(pl, pl->team->clid, PLAYER_VALUE_GOALS);
new_stat.value2 = new_stat.value2 =
@@ -118,7 +117,7 @@ stat_update_league_teams(const GArray *teams_array, gint compare_type)
new_stat.value1 = team_get_table_value((Team*)g_ptr_array_index(teams, i), TABLE_GF); 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.value2 = team_get_table_value((Team*)g_ptr_array_index(teams, i), TABLE_GA);
new_stat.value3 = -1; new_stat.value3 = -1;
new_stat.value_string = g_string_new(""); new_stat.value_string = NULL;
g_array_append_val(stats, new_stat); g_array_append_val(stats, new_stat);
} }
@@ -152,9 +151,9 @@ stat_create_season_stat(void)
for(i=0;i<ligs->len;i++) for(i=0;i<ligs->len;i++)
{ {
new_champ.cl_name = g_string_new(lig(i).name->str); new_champ.cl_name = g_strdup(lig(i).name);
new_champ.team_name = new_champ.team_name =
g_string_new(g_array_index(lig(i).table.elements, TableElement, 0).team->name->str); g_strdup(g_array_index(lig(i).table.elements, TableElement, 0).team->name);
g_array_append_val(new.league_champs, new_champ); g_array_append_val(new.league_champs, new_champ);
g_array_append_val(new.league_stats, lig(i).stats); g_array_append_val(new.league_stats, lig(i).stats);
@@ -163,9 +162,9 @@ stat_create_season_stat(void)
for(i=0;i<acps->len;i++) for(i=0;i<acps->len;i++)
{ {
new_champ.cl_name = g_string_new(acp(i)->name->str); new_champ.cl_name = g_strdup(acp(i)->name);
new_champ.team_name = new_champ.team_name =
g_string_new(cup_get_winner(acp(i))->name->str); g_strdup(cup_get_winner(acp(i))->name);
g_array_append_val(new.cup_champs, new_champ); g_array_append_val(new.cup_champs, new_champ);
} }

View File

@@ -7,7 +7,7 @@ typedef struct
{ {
gint team_id; gint team_id;
gint value1, value2, value3; gint value1, value2, value3;
GString *value_string; gchar *value_string;
} Stat; } Stat;
/** A structure holding some stat arrays about a league. */ /** A structure holding some stat arrays about a league. */
@@ -24,8 +24,7 @@ typedef struct
/** A team name and a competition name. */ /** A team name and a competition name. */
typedef struct typedef struct
{ {
GString *team_name, gchar *team_name, *cl_name;
*cl_name;
} ChampStat; } ChampStat;
/** A season statistics structure. */ /** A season statistics structure. */

View File

@@ -10,7 +10,7 @@ table_new(void)
{ {
Table new; Table new;
new.name = g_string_new(""); new.name = NULL;
new.clid = -1; new.clid = -1;
new.round = -1; new.round = -1;
new.elements = g_array_new(FALSE, FALSE, sizeof(TableElement)); new.elements = g_array_new(FALSE, FALSE, sizeof(TableElement));

View File

@@ -43,7 +43,7 @@ typedef struct
*/ */
typedef struct typedef struct
{ {
GString *name; gchar *name;
gint clid; gint clid;
/** The cup round (or -1 if it's a league). */ /** The cup round (or -1 if it's a league). */
gint round; gint round;

View File

@@ -25,9 +25,9 @@ team_new(gboolean new_id)
{ {
Team new; Team new;
new.name = g_string_new(""); new.name = NULL;
new.names_file = g_string_new(""); new.names_file = NULL;
new.symbol = g_string_new(""); new.symbol = NULL;
new.def_file = NULL; new.def_file = NULL;
new.stadium.name = NULL; new.stadium.name = NULL;
@@ -161,12 +161,12 @@ query_team_is_in_cups(const Team *tm, gint group)
for(i=0;i<cps->len;i++) for(i=0;i<cps->len;i++)
if(cp(i).group == group) if(cp(i).group == group)
for(j=0;j<cp(i).team_names->len;j++) for(j=0;j<cp(i).team_names->len;j++)
if(strcmp(tm->name->str, if(strcmp(tm->name,
(gchar*)g_ptr_array_index(cp(i).team_names, j)) == 0) (gchar*)g_ptr_array_index(cp(i).team_names, j)) == 0)
{ {
if(debug > 90) if(debug > 90)
printf("team %s group %d found in %s \n", tm->name->str, printf("team %s group %d found in %s \n", tm->name,
group, cp(i).name->str); group, cp(i).name);
return TRUE; return TRUE;
} }
@@ -183,7 +183,7 @@ query_team_is_in_cup(const Team *tm, const Cup *cup)
gint i; gint i;
for(i=0;i<cup->team_names->len;i++) for(i=0;i<cup->team_names->len;i++)
if(strcmp(tm->name->str, if(strcmp(tm->name,
(gchar*)g_ptr_array_index(cup->team_names, i)) == 0) (gchar*)g_ptr_array_index(cup->team_names, i)) == 0)
return TRUE; return TRUE;
@@ -412,7 +412,7 @@ team_get_league_rank(const Team *tm)
return i + 1; return i + 1;
g_warning("team_get_league_rank: no rank found for team %s in league %s. \n", g_warning("team_get_league_rank: no rank found for team %s in league %s. \n",
tm->name->str, league_cup_get_name_string(tm->clid)); tm->name, league_cup_get_name_string(tm->clid));
main_exit_program(EXIT_INT_NOT_FOUND, NULL); main_exit_program(EXIT_INT_NOT_FOUND, NULL);
@@ -435,7 +435,7 @@ team_get_cup_rank(const Team *tm, const CupRound *cupround, gboolean abort)
if(abort) if(abort)
{ {
g_warning("team_get_cup_rank: no rank found for team %s. \n ", tm->name->str); g_warning("team_get_cup_rank: no rank found for team %s. \n ", tm->name);
main_exit_program(EXIT_INT_NOT_FOUND, NULL); main_exit_program(EXIT_INT_NOT_FOUND, NULL);
} }
@@ -746,7 +746,7 @@ team_get_table_value(const Team *tm, gint type)
if(tm->clid >= ID_CUP_START) if(tm->clid >= ID_CUP_START)
{ {
g_warning("team_get_table_value: team is not a league team: %s \n", tm->name->str); g_warning("team_get_table_value: team is not a league team: %s \n", tm->name);
main_exit_program(EXIT_INT_NOT_FOUND, NULL); main_exit_program(EXIT_INT_NOT_FOUND, NULL);
@@ -761,7 +761,7 @@ team_get_table_value(const Team *tm, gint type)
if(i == elements->len) if(i == elements->len)
{ {
g_warning("team_get_table_value: table entry not found for team %s \n", tm->name->str); g_warning("team_get_table_value: table entry not found for team %s \n", tm->name);
main_exit_program(EXIT_INT_NOT_FOUND, NULL); main_exit_program(EXIT_INT_NOT_FOUND, NULL);
@@ -928,7 +928,7 @@ team_get_index(const Team *tm)
return i; return i;
} }
g_warning("team_get_index: team %s not found.\n", tm->name->str); g_warning("team_get_index: team %s not found.\n", tm->name);
main_exit_program(EXIT_INT_NOT_FOUND, NULL); main_exit_program(EXIT_INT_NOT_FOUND, NULL);
@@ -1129,7 +1129,7 @@ team_has_def_file(const Team *tm)
if(tm->def_file != NULL && opt_int("int_opt_load_defs") != 0) if(tm->def_file != NULL && opt_int("int_opt_load_defs") != 0)
{ {
sprintf(buf, "team_%s.xml", tm->def_file->str); sprintf(buf, "team_%s.xml", tm->def_file);
return_value = file_find_support_file(buf, FALSE); return_value = file_find_support_file(buf, FALSE);
} }
@@ -1226,7 +1226,7 @@ team_complete_def_sort(Team *tm)
if(j == tm->players->len) if(j == tm->players->len)
{ {
sprintf(buf, "team_complete_def_sort (1): cannot sort according to structure %d (team %s).", sprintf(buf, "team_complete_def_sort (1): cannot sort according to structure %d (team %s).",
tm->structure, tm->name->str); tm->structure, tm->name);
main_exit_program(EXIT_DEF_SORT, buf); main_exit_program(EXIT_DEF_SORT, buf);
} }
@@ -1250,7 +1250,7 @@ team_complete_def_sort(Team *tm)
if(j == 11) if(j == 11)
{ {
sprintf(buf, "team_complete_def_sort (2): cannot sort according to structure %d (team %s).", sprintf(buf, "team_complete_def_sort (2): cannot sort according to structure %d (team %s).",
tm->structure, tm->name->str); tm->structure, tm->name);
main_exit_program(EXIT_DEF_SORT, buf); main_exit_program(EXIT_DEF_SORT, buf);
} }
@@ -1265,7 +1265,7 @@ team_complete_def_sort(Team *tm)
if(j == tm->players->len) if(j == tm->players->len)
{ {
sprintf(buf, "team_complete_def_sort (3): cannot sort according to structure %d (team %s).", sprintf(buf, "team_complete_def_sort (3): cannot sort according to structure %d (team %s).",
tm->structure, tm->name->str); tm->structure, tm->name);
main_exit_program(EXIT_DEF_SORT, buf); main_exit_program(EXIT_DEF_SORT, buf);
} }

View File

@@ -32,7 +32,7 @@ enum TeamAttribute
/** The stadium of a team. */ /** The stadium of a team. */
typedef struct typedef struct
{ {
GString *name; gchar *name;
gint capacity, /**< How many people fit in. Default: -1 (depends on league). */ gint capacity, /**< How many people fit in. Default: -1 (depends on league). */
average_attendance, /**< How many people watched on average. Default: 0. */ average_attendance, /**< How many people watched on average. Default: 0. */
possible_attendance, /**< How many people would've watched if every game had been possible_attendance, /**< How many people would've watched if every game had been
@@ -47,11 +47,11 @@ typedef struct
@see Player */ @see Player */
typedef struct typedef struct
{ {
GString *name, *symbol; gchar *name, *symbol;
/** File the team takes the /** File the team takes the
player names from. */ player names from. */
GString *names_file; gchar *names_file;
GString *def_file; gchar *def_file;
gint clid, /**< Numerical id of the league or cup the team belongs to. */ gint clid, /**< Numerical id of the league or cup the team belongs to. */
id, /**< Id of the team. */ id, /**< Id of the team. */

View File

@@ -151,12 +151,12 @@ transfer_offers_notify(Transfer *tr, gboolean sort)
if(team_is_user(tr->tm) != -1) if(team_is_user(tr->tm) != -1)
user_event_add(user_from_team(tr->tm), EVENT_TYPE_TRANSFER_OFFER_USER, user_event_add(user_from_team(tr->tm), EVENT_TYPE_TRANSFER_OFFER_USER,
-1, -1, NULL, player_of_id_team(tr->tm, tr->id)->name->str); -1, -1, NULL, player_of_id_team(tr->tm, tr->id)->name);
else else
user_event_add(user_from_team(off->tm), user_event_add(user_from_team(off->tm),
EVENT_TYPE_TRANSFER_OFFER_CPU, -1, -1, EVENT_TYPE_TRANSFER_OFFER_CPU, -1, -1,
NULL, player_of_id_team(tr->tm, tr->id)->name->str); NULL, player_of_id_team(tr->tm, tr->id)->name);
if(!sort) if(!sort)
user_event_show_next(); user_event_show_next();
@@ -187,7 +187,7 @@ transfer_evaluate_offers(void)
user_event_add(user_from_team(transoff(i, j).tm), user_event_add(user_from_team(transoff(i, j).tm),
EVENT_TYPE_TRANSFER_OFFER_REJECTED_FEE_WAGE, EVENT_TYPE_TRANSFER_OFFER_REJECTED_FEE_WAGE,
transoff(i, j).fee, transoff(i, j).wage, transoff(i, j).fee, transoff(i, j).wage,
trans(i).tm, player_of_id_team(trans(i).tm, trans(i).id)->name->str); trans(i).tm, player_of_id_team(trans(i).tm, trans(i).id)->name);
transoff(i, j).status = TRANSFER_OFFER_REJECTED; transoff(i, j).status = TRANSFER_OFFER_REJECTED;
} }
else if(player_of_id_team(trans(i).tm, trans(i).id)->value > transoff(i, j).fee) else if(player_of_id_team(trans(i).tm, trans(i).id)->value > transoff(i, j).fee)
@@ -195,7 +195,7 @@ transfer_evaluate_offers(void)
user_event_add(user_from_team(transoff(i, j).tm), user_event_add(user_from_team(transoff(i, j).tm),
EVENT_TYPE_TRANSFER_OFFER_REJECTED_FEE, EVENT_TYPE_TRANSFER_OFFER_REJECTED_FEE,
transoff(i, j).fee, transoff(i, j).wage, transoff(i, j).fee, transoff(i, j).wage,
trans(i).tm, player_of_id_team(trans(i).tm, trans(i).id)->name->str); trans(i).tm, player_of_id_team(trans(i).tm, trans(i).id)->name);
transoff(i, j).status = TRANSFER_OFFER_REJECTED; transoff(i, j).status = TRANSFER_OFFER_REJECTED;
} }
else if(player_of_id_team(trans(i).tm, trans(i).id)->wage > transoff(i, j).wage) else if(player_of_id_team(trans(i).tm, trans(i).id)->wage > transoff(i, j).wage)
@@ -203,7 +203,7 @@ transfer_evaluate_offers(void)
user_event_add(user_from_team(transoff(i, j).tm), user_event_add(user_from_team(transoff(i, j).tm),
EVENT_TYPE_TRANSFER_OFFER_REJECTED_WAGE, EVENT_TYPE_TRANSFER_OFFER_REJECTED_WAGE,
transoff(i, j).fee, transoff(i, j).wage, transoff(i, j).fee, transoff(i, j).wage,
trans(i).tm, player_of_id_team(trans(i).tm, trans(i).id)->name->str); trans(i).tm, player_of_id_team(trans(i).tm, trans(i).id)->name);
transoff(i, j).status = TRANSFER_OFFER_REJECTED; transoff(i, j).status = TRANSFER_OFFER_REJECTED;
} }
else else
@@ -432,7 +432,7 @@ transfer_add_remove_user_player(Player *pl)
(gint)rint(((gfloat)const_int("int_transfer_time_lower") + (gint)rint(((gfloat)const_int("int_transfer_time_lower") +
(gfloat)const_int("int_transfer_time_upper")) / 2)); (gfloat)const_int("int_transfer_time_upper")) / 2));
game_gui_print_message(_("%s has been added to the transfer list for %d weeks."), game_gui_print_message(_("%s has been added to the transfer list for %d weeks."),
pl->name->str, pl->name,
(gint)rint(((gfloat)const_int("int_transfer_time_lower") + (gint)rint(((gfloat)const_int("int_transfer_time_lower") +
(gfloat)const_int("int_transfer_time_upper")) / 2)); (gfloat)const_int("int_transfer_time_upper")) / 2));
} }

View File

@@ -48,11 +48,11 @@ treeview_create_team_selection_list(gboolean show_cup_teams, gboolean show_user_
if(team_is_user(&g_array_index(lig(i).teams, Team, j)) == -1) if(team_is_user(&g_array_index(lig(i).teams, Team, j)) == -1)
{ {
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
treeview_helper_insert_icon(ls, &iter, 1, g_array_index(lig(i).teams, Team, j).symbol->str); treeview_helper_insert_icon(ls, &iter, 1, g_array_index(lig(i).teams, Team, j).symbol);
gtk_list_store_set(ls, &iter, gtk_list_store_set(ls, &iter,
0, cnt++, 0, cnt++,
2, (gpointer)&g_array_index(lig(i).teams, Team, j), 2, (gpointer)&g_array_index(lig(i).teams, Team, j),
3, lig(i).name->str, 3, lig(i).name,
4, (gpointer)&g_array_index(lig(i).teams, Team, j), 4, (gpointer)&g_array_index(lig(i).teams, Team, j),
-1); -1);
} }
@@ -68,11 +68,11 @@ treeview_create_team_selection_list(gboolean show_cup_teams, gboolean show_user_
{ {
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
treeview_helper_insert_icon(ls, &iter, 1, treeview_helper_insert_icon(ls, &iter, 1,
((Team*)g_ptr_array_index(cp(i).teams, j))->symbol->str); ((Team*)g_ptr_array_index(cp(i).teams, j))->symbol);
gtk_list_store_set(ls, &iter, gtk_list_store_set(ls, &iter,
0, cnt++, 0, cnt++,
2, g_ptr_array_index(cp(i).teams, j), 2, g_ptr_array_index(cp(i).teams, j),
3, cp(i).name->str, 3, cp(i).name,
4, g_ptr_array_index(cp(i).teams, j), 4, g_ptr_array_index(cp(i).teams, j),
-1); -1);
} }
@@ -436,12 +436,12 @@ treeview_live_game_show_commentary(const LiveGameUnit *unit)
sprintf(buf2, "<span background='%s' foreground='%s'>%s</span>", sprintf(buf2, "<span background='%s' foreground='%s'>%s</span>",
const_app("string_treeview_live_game_commentary_away_bg"), const_app("string_treeview_live_game_commentary_away_bg"),
const_app("string_treeview_live_game_commentary_away_fg"), const_app("string_treeview_live_game_commentary_away_fg"),
unit->event.commentary->str); unit->event.commentary);
else else
sprintf(buf2, "<span background='%s' foreground='%s'>%s</span>", sprintf(buf2, "<span background='%s' foreground='%s'>%s</span>",
const_app("string_treeview_helper_color_default_background"), const_app("string_treeview_helper_color_default_background"),
const_app("string_treeview_helper_color_default_foreground"), const_app("string_treeview_helper_color_default_foreground"),
unit->event.commentary->str); unit->event.commentary);
gtk_list_store_prepend(ls, &iter); gtk_list_store_prepend(ls, &iter);
treeview_helper_insert_icon(ls, &iter, 1, treeview_helper_live_game_icon(unit->event.type)); treeview_helper_insert_icon(ls, &iter, 1, treeview_helper_live_game_icon(unit->event.type));
@@ -471,7 +471,7 @@ treeview_live_game_create_init_commentary(const LiveGameUnit *unit)
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
treeview_helper_insert_icon(ls, &iter, 1, treeview_helper_live_game_icon(unit->event.type)); treeview_helper_insert_icon(ls, &iter, 1, treeview_helper_live_game_icon(unit->event.type));
gtk_list_store_set(ls, &iter, 0, buf, 2, unit->event.commentary->str, -1); gtk_list_store_set(ls, &iter, 0, buf, 2, unit->event.commentary, -1);
return GTK_TREE_MODEL(ls); return GTK_TREE_MODEL(ls);
} }
@@ -548,9 +548,9 @@ treeview_live_game_create_result(const LiveGameUnit *unit)
live_game_unit_result_to_buf(unit, buf, FALSE); live_game_unit_result_to_buf(unit, buf, FALSE);
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
gtk_list_store_set(ls, &iter, gtk_list_store_set(ls, &iter,
0, ((LiveGame*)statp)->team_names[0]->str, 0, ((LiveGame*)statp)->team_names[0],
1, buf, 1, buf,
2, ((LiveGame*)statp)->team_names[1]->str, -1); 2, ((LiveGame*)statp)->team_names[1], -1);
return GTK_TREE_MODEL(ls); return GTK_TREE_MODEL(ls);
} }
@@ -618,22 +618,22 @@ treeview_create_users(void)
{ {
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
gtk_list_store_set(ls, &iter, 0, i + 1, gtk_list_store_set(ls, &iter, 0, i + 1,
1, usr(i).name->str, 1, usr(i).name,
2, usr(i).tm->name->str, 2, usr(i).tm->name,
-1); -1);
if(stat0 == STATUS_TEAM_SELECTION) if(stat0 == STATUS_TEAM_SELECTION)
{ {
if(usr(i).scout == -1) if(usr(i).scout == -1)
gtk_list_store_set(ls, &iter, 3, gtk_list_store_set(ls, &iter, 3,
league_from_clid(usr(i).tm->clid)->name->str, -1); league_cup_get_name_string(usr(i).tm->clid), -1);
else else
gtk_list_store_set(ls, &iter, 3, gtk_list_store_set(ls, &iter, 3,
lig(usr(i).scout).name->str, -1); lig(usr(i).scout).name, -1);
} }
else else
gtk_list_store_set(ls, &iter, 3, gtk_list_store_set(ls, &iter, 3,
league_from_clid(usr(i).tm->clid)->name->str, -1); league_cup_get_name_string(usr(i).tm->clid), -1);
} }
return GTK_TREE_MODEL(ls); return GTK_TREE_MODEL(ls);
@@ -715,9 +715,9 @@ treeview_create_game_stats(LiveGame *live_game)
fixture_result_to_buf(live_game->fix, buf[0], FALSE); fixture_result_to_buf(live_game->fix, buf[0], FALSE);
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
gtk_list_store_set(ls, &iter, 0, live_game->fix->teams[0]->name->str, gtk_list_store_set(ls, &iter, 0, live_game->fix->teams[0]->name,
1, buf[0], 1, buf[0],
2, live_game->fix->teams[1]->name->str, 2, live_game->fix->teams[1]->name,
-1); -1);
for(k=0;k<LIVE_GAME_STAT_ARRAY_END;k++) for(k=0;k<LIVE_GAME_STAT_ARRAY_END;k++)
@@ -751,7 +751,7 @@ treeview_create_game_stats(LiveGame *live_game)
if(i < stats->players[j][k]->len) if(i < stats->players[j][k]->len)
{ {
sprintf(buf3, "%s%s%s", buf[0], sprintf(buf3, "%s%s%s", buf[0],
((GString*)g_ptr_array_index(stats->players[j][k], i))->str, (gchar*)g_ptr_array_index(stats->players[j][k], i),
buf[1]); buf[1]);
gtk_list_store_set(ls, &iter, j * 2, buf3, -1); gtk_list_store_set(ls, &iter, j * 2, buf3, -1);
} }
@@ -864,17 +864,17 @@ treeview_create_fixtures_header(const Fixture *fix, GtkListStore *ls, gboolean b
if(fix->clid < ID_CUP_START) if(fix->clid < ID_CUP_START)
{ {
name = league_from_clid(fix->clid)->name->str; name = league_cup_get_name_string(fix->clid);
strcpy(round_name, ""); strcpy(round_name, "");
symbol = league_from_clid(fix->clid)->symbol->str; symbol = league_from_clid(fix->clid)->symbol;
} }
else else
{ {
name = cup_from_clid(fix->clid)->name->str; name = cup_from_clid(fix->clid)->name;
cup_round_name(fix, buf); cup_round_name(fix, buf);
sprintf(round_name, "\n%s", buf); sprintf(round_name, "\n%s", buf);
strcat(buf3, "\n"); strcat(buf3, "\n");
symbol = cup_from_clid(fix->clid)->symbol->str; symbol = cup_from_clid(fix->clid)->symbol;
} }
sprintf(buf, "<span background='%s' foreground='%s'>%s%s</span>", sprintf(buf, "<span background='%s' foreground='%s'>%s%s</span>",
@@ -910,7 +910,7 @@ treeview_create_fixture(const Fixture *fix, GtkListStore *ls)
if(fix->clid >= ID_CUP_START && if(fix->clid >= ID_CUP_START &&
query_cup_is_international(fix->clid)) query_cup_is_international(fix->clid))
for(i=0;i<2;i++) for(i=0;i<2;i++)
symbol[i] = fix->teams[i]->symbol->str; symbol[i] = fix->teams[i]->symbol;
if(fixture_user_team_involved(fix) != -1) if(fixture_user_team_involved(fix) != -1)
treeview_helper_set_user_colours(usr(fixture_user_team_involved(fix)).tm, treeview_helper_set_user_colours(usr(fixture_user_team_involved(fix)).tm,
@@ -933,16 +933,16 @@ treeview_create_fixture(const Fixture *fix, GtkListStore *ls)
cup_get_last_tables_round(fix->clid), TRUE); cup_get_last_tables_round(fix->clid), TRUE);
sprintf(buf[i], "<span background='%s' foreground='%s'>%s [%d]</span>", sprintf(buf[i], "<span background='%s' foreground='%s'>%s [%d]</span>",
colour_bg, colour_fg, fix->teams[i]->name->str, rank); colour_bg, colour_fg, fix->teams[i]->name, rank);
} }
else if(fix->clid >= ID_CUP_START && else if(fix->clid >= ID_CUP_START &&
query_cup_is_national(fix->clid)) query_cup_is_national(fix->clid))
sprintf(buf[i], "<span background='%s' foreground='%s'>%s (%d)</span>", sprintf(buf[i], "<span background='%s' foreground='%s'>%s (%d)</span>",
colour_bg, colour_fg, fix->teams[i]->name->str, colour_bg, colour_fg, fix->teams[i]->name,
league_from_clid(fix->teams[i]->clid)->layer); league_from_clid(fix->teams[i]->clid)->layer);
else else
sprintf(buf[i], "<span background='%s' foreground='%s'>%s</span>", sprintf(buf[i], "<span background='%s' foreground='%s'>%s</span>",
colour_bg, colour_fg, fix->teams[i]->name->str); colour_bg, colour_fg, fix->teams[i]->name);
sprintf(buf[2], "<span background='%s' foreground='%s'>%s</span>", sprintf(buf[2], "<span background='%s' foreground='%s'>%s</span>",
colour_bg, colour_fg, buf_result); colour_bg, colour_fg, buf_result);
@@ -1061,18 +1061,18 @@ treeview_table_write_header(GtkListStore *ls, const Table *table, gint number)
if(table->clid < ID_CUP_START) if(table->clid < ID_CUP_START)
{ {
symbol = league_from_clid(table->clid)->symbol->str; symbol = league_from_clid(table->clid)->symbol;
strcpy(buf, league_from_clid(table->clid)->name->str); strcpy(buf, league_cup_get_name_string(table->clid));
} }
else else
{ {
symbol = cup_from_clid(table->clid)->symbol->str; symbol = cup_from_clid(table->clid)->symbol;
if(g_array_index(cup_from_clid(table->clid)->rounds, CupRound, if(g_array_index(cup_from_clid(table->clid)->rounds, CupRound,
table->round).tables->len > 1) table->round).tables->len > 1)
/* A group of a round robin stage of a cup. */ /* A group of a round robin stage of a cup. */
sprintf(buf, _("%s Group %d"), cup_from_clid(table->clid)->name->str, number); sprintf(buf, _("%s Group %d"), cup_from_clid(table->clid)->name, number);
else else
sprintf(buf, "%s", cup_from_clid(table->clid)->name->str); sprintf(buf, "%s", cup_from_clid(table->clid)->name);
} }
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
@@ -1104,7 +1104,7 @@ treeview_create_single_table(GtkListStore *ls, const Table *table, gint number)
elem = &g_array_index(table->elements, TableElement, i); elem = &g_array_index(table->elements, TableElement, i);
if(table->clid >= ID_CUP_START) if(table->clid >= ID_CUP_START)
treeview_helper_insert_icon(ls, &iter, 0, elem->team->symbol->str); treeview_helper_insert_icon(ls, &iter, 0, elem->team->symbol);
if(elem->old_rank > i) if(elem->old_rank > i)
treeview_helper_insert_icon(ls, &iter, 2, treeview_helper_insert_icon(ls, &iter, 2,
@@ -1123,7 +1123,7 @@ treeview_create_single_table(GtkListStore *ls, const Table *table, gint number)
treeview_helper_get_table_element_colours(table, i, &colour_fg, &colour_bg, TRUE); treeview_helper_get_table_element_colours(table, i, &colour_fg, &colour_bg, TRUE);
sprintf(buf[1], "<span background='%s' foreground='%s'>%s</span>", sprintf(buf[1], "<span background='%s' foreground='%s'>%s</span>",
colour_bg, colour_fg, elem->team->name->str); colour_bg, colour_fg, elem->team->name);
gtk_list_store_set(ls, &iter, 1, buf[0], 3, buf[1], -1); gtk_list_store_set(ls, &iter, 1, buf[0], 3, buf[1], -1);
@@ -1269,7 +1269,7 @@ treeview_create_stadium_summary(GtkListStore *ls)
{ {
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
gtk_list_store_set(ls, &iter, 0, _("Stadium"), gtk_list_store_set(ls, &iter, 0, _("Stadium"),
1, current_user.tm->stadium.name->str, 2, "", -1); 1, current_user.tm->stadium.name, 2, "", -1);
} }
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
@@ -1582,7 +1582,7 @@ treeview_create_next_opponent(void)
gtk_list_store_set(ls, &iter, 0, "", 1, "", -1); gtk_list_store_set(ls, &iter, 0, "", 1, "", -1);
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
gtk_list_store_set(ls, &iter, 0, _("Team"), 1, opp->name->str, -1); gtk_list_store_set(ls, &iter, 0, _("Team"), 1, opp->name, -1);
if(opp->clid < ID_CUP_START) if(opp->clid < ID_CUP_START)
{ {
@@ -1690,9 +1690,9 @@ treeview_create_league_results(void)
if(team_is_user(g_array_index(table_elements, TableElement, i).team) != -1) if(team_is_user(g_array_index(table_elements, TableElement, i).team) != -1)
sprintf(name, "<span background='%s'>%s</span>", sprintf(name, "<span background='%s'>%s</span>",
const_app("string_treeview_user_bg"), const_app("string_treeview_user_bg"),
g_array_index(table_elements, TableElement, i).team->name->str); g_array_index(table_elements, TableElement, i).team->name);
else else
strcpy(name, g_array_index(table_elements, TableElement, i).team->name->str); strcpy(name, g_array_index(table_elements, TableElement, i).team->name);
team_write_own_results(g_array_index(table_elements, TableElement, i).team, team_write_own_results(g_array_index(table_elements, TableElement, i).team,
results, TRUE, FALSE); results, TRUE, FALSE);
@@ -1988,7 +1988,7 @@ treeview_create_user_history(void)
gtk_list_store_set(ls, &iter, gtk_list_store_set(ls, &iter,
0, g_array_index(current_user.history, UserHistory, i).season, 0, g_array_index(current_user.history, UserHistory, i).season,
1, g_array_index(current_user.history, UserHistory, i).week, 1, g_array_index(current_user.history, UserHistory, i).week,
2, team_of_id(g_array_index(current_user.history, UserHistory, i).team_id)->name->str, 2, team_of_id(g_array_index(current_user.history, UserHistory, i).team_id)->name,
4, buf, -1); 4, buf, -1);
} }
@@ -2077,9 +2077,9 @@ treeview_create_league_stats(GtkListStore *ls, const LeagueStat *league_stat)
gchar *colour_fg = NULL, *colour_bg = NULL; gchar *colour_fg = NULL, *colour_bg = NULL;
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
treeview_helper_insert_icon(ls, &iter, 0, league_from_clid(league_stat->clid)->symbol->str); treeview_helper_insert_icon(ls, &iter, 0, league_from_clid(league_stat->clid)->symbol);
gtk_list_store_set(ls, &iter, 1, const_int("int_treeview_helper_int_empty"), gtk_list_store_set(ls, &iter, 1, const_int("int_treeview_helper_int_empty"),
2, league_from_clid(league_stat->clid)->name->str, 3, "", 4, "", 5, "", -1); 2, league_cup_get_name_string(league_stat->clid), 3, "", 4, "", 5, "", -1);
for(i=0;i<2;i++) for(i=0;i<2;i++)
{ {
@@ -2103,7 +2103,7 @@ treeview_create_league_stats(GtkListStore *ls, const LeagueStat *league_stat)
&colour_bg, &colour_fg); &colour_bg, &colour_fg);
sprintf(buf2, "<span background='%s' foreground='%s'>%s</span>", sprintf(buf2, "<span background='%s' foreground='%s'>%s</span>",
colour_bg, colour_fg, team_of_id(g_array_index(teams[i], Stat, j).team_id)->name->str); colour_bg, colour_fg, team_of_id(g_array_index(teams[i], Stat, j).team_id)->name);
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
gtk_list_store_set(ls, &iter, 0, NULL, 1, j + 1, gtk_list_store_set(ls, &iter, 0, NULL, 1, j + 1,
@@ -2145,8 +2145,8 @@ treeview_create_league_stats(GtkListStore *ls, const LeagueStat *league_stat)
&colour_bg, &colour_fg); &colour_bg, &colour_fg);
sprintf(buf3, "<span background='%s' foreground='%s'>%s (%s)</span>", sprintf(buf3, "<span background='%s' foreground='%s'>%s (%s)</span>",
colour_bg, colour_fg, colour_bg, colour_fg,
g_array_index(players[i], Stat, j).value_string->str, g_array_index(players[i], Stat, j).value_string,
team_of_id(g_array_index(players[i], Stat, j).team_id)->name->str); team_of_id(g_array_index(players[i], Stat, j).team_id)->name);
sprintf(buf4, "%d", g_array_index(players[i], Stat, j).value1); sprintf(buf4, "%d", g_array_index(players[i], Stat, j).value1);
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
@@ -2236,8 +2236,8 @@ treeview_create_season_history_champions(GtkListStore *ls, const GArray* league_
{ {
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
gtk_list_store_set(ls, &iter, 0, NULL, 1, const_int("int_treeview_helper_int_empty"), gtk_list_store_set(ls, &iter, 0, NULL, 1, const_int("int_treeview_helper_int_empty"),
2, g_array_index(champs[i], ChampStat, j).cl_name->str, 2, g_array_index(champs[i], ChampStat, j).cl_name,
3, g_array_index(champs[i], ChampStat, j).team_name->str, 3, g_array_index(champs[i], ChampStat, j).team_name,
4, "", 5, "", -1); 4, "", 5, "", -1);
} }
@@ -2336,18 +2336,18 @@ treeview_show_contributors(const OptionList *help_list)
{ {
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
if(g_str_has_prefix(g_array_index(help_list->list, Option, i).name->str, if(g_str_has_prefix(g_array_index(help_list->list, Option, i).name,
"string_contrib_title")) "string_contrib_title"))
{ {
sprintf(buf, "\n<span %s>%s</span>", sprintf(buf, "\n<span %s>%s</span>",
const_app("string_help_window_title_attribute"), const_app("string_help_window_title_attribute"),
g_array_index(help_list->list, Option, i).string_value->str); g_array_index(help_list->list, Option, i).string_value);
gtk_list_store_set(ls, &iter, 0, buf, -1); gtk_list_store_set(ls, &iter, 0, buf, -1);
} }
else if(g_str_has_prefix(g_array_index(help_list->list, Option, i).name->str, else if(g_str_has_prefix(g_array_index(help_list->list, Option, i).name,
"string_contrib_")) "string_contrib_"))
{ {
strcpy(buf, g_array_index(help_list->list, Option, i).string_value->str); strcpy(buf, g_array_index(help_list->list, Option, i).string_value);
gtk_list_store_set(ls, &iter, 0, buf, -1); gtk_list_store_set(ls, &iter, 0, buf, -1);
} }
@@ -2370,7 +2370,7 @@ treeview_create_league_list(void)
for(i=0;i<ligs->len;i++) for(i=0;i<ligs->len;i++)
{ {
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
gtk_list_store_set(ls, &iter, 0, lig(i).name->str, -1); gtk_list_store_set(ls, &iter, 0, lig(i).name, -1);
} }
return GTK_TREE_MODEL(ls); return GTK_TREE_MODEL(ls);

View File

@@ -30,7 +30,7 @@ treeview2_create_mmatches(GtkListStore *ls)
4, g_array_index(current_user.mmatches, MemMatch, i). 4, g_array_index(current_user.mmatches, MemMatch, i).
competition_name->str, competition_name->str,
5, g_array_index(current_user.mmatches, MemMatch, i). 5, g_array_index(current_user.mmatches, MemMatch, i).
country_name->str, -1); country_name, -1);
gtk_list_store_set(ls, &iter, gtk_list_store_set(ls, &iter,
TREEVIEW_MMATCH_COL_REPLAY, _("REPLAY"), TREEVIEW_MMATCH_COL_REPLAY, _("REPLAY"),
TREEVIEW_MMATCH_COL_REMOVE, _("REMOVE"), TREEVIEW_MMATCH_COL_REMOVE, _("REMOVE"),

View File

@@ -443,9 +443,9 @@ treeview_helper_get_table_element_colour_cups(const League *league,
cup_round = &g_array_index(cp(i).rounds, CupRound, k); cup_round = &g_array_index(cp(i).rounds, CupRound, k);
for(j=0;j<cup_round->choose_teams->len;j++) for(j=0;j<cup_round->choose_teams->len;j++)
if(strcmp(g_array_index(cup_round->choose_teams, if(strcmp(g_array_index(cup_round->choose_teams,
CupChooseTeam, j).sid->str, buf) == 0 || CupChooseTeam, j).sid, buf) == 0 ||
strcmp(g_array_index(cup_round->choose_teams, strcmp(g_array_index(cup_round->choose_teams,
CupChooseTeam, j).sid->str, league->sid->str) == 0) CupChooseTeam, j).sid, league->sid) == 0)
{ {
if((idx + 1 >= g_array_index(cup_round->choose_teams, if((idx + 1 >= g_array_index(cup_round->choose_teams,
CupChooseTeam, j).start_idx && CupChooseTeam, j).start_idx &&
@@ -501,8 +501,8 @@ treeview_helper_get_table_element_colour_cups_cup(const Cup *cup,
cup_round = &g_array_index(cp(i).rounds, CupRound, k); cup_round = &g_array_index(cp(i).rounds, CupRound, k);
for(j=0;j<cup_round->choose_teams->len;j++) for(j=0;j<cup_round->choose_teams->len;j++)
if(strcmp(g_array_index( if(strcmp(g_array_index(
cup_round->choose_teams, CupChooseTeam, j).sid->str, cup_round->choose_teams, CupChooseTeam, j).sid,
cup->sid->str) == 0) cup->sid) == 0)
{ {
if((idx + 1 >= g_array_index(cup_round->choose_teams, if((idx + 1 >= g_array_index(cup_round->choose_teams,
CupChooseTeam, j).start_idx && CupChooseTeam, j).start_idx &&
@@ -667,7 +667,7 @@ treeview_helper_team_selection(GtkTreeViewColumn *col,
gtk_tree_model_get(model, iter, column, &team_pointer, -1); gtk_tree_model_get(model, iter, column, &team_pointer, -1);
if(column == 2) if(column == 2)
g_object_set(renderer, "text", ((Team*)team_pointer)->name->str, NULL); g_object_set(renderer, "text", ((Team*)team_pointer)->name, NULL);
else if(column == 4) else if(column == 4)
{ {
sprintf(buf, "%.1f", team_get_average_skill((Team*)team_pointer, FALSE)); sprintf(buf, "%.1f", team_get_average_skill((Team*)team_pointer, FALSE));
@@ -1034,7 +1034,7 @@ treeview_helper_player_to_cell(GtkTreeViewColumn *col,
treeview_helper_player_contract_to_cell(renderer, buf, pl->contract); treeview_helper_player_contract_to_cell(renderer, buf, pl->contract);
break; break;
case PLAYER_LIST_ATTRIBUTE_TEAM: case PLAYER_LIST_ATTRIBUTE_TEAM:
sprintf(buf, "%s", pl->team->name->str); sprintf(buf, "%s", pl->team->name);
break; break;
case PLAYER_LIST_ATTRIBUTE_LEAGUE_CUP: case PLAYER_LIST_ATTRIBUTE_LEAGUE_CUP:
strcpy(buf, league_cup_get_name_string(pl->team->clid)); strcpy(buf, league_cup_get_name_string(pl->team->clid));
@@ -1053,7 +1053,7 @@ treeview_helper_player_name_to_cell(GtkCellRenderer *renderer, gchar *buf, const
const gchar *colour_fg = const_app("string_treeview_helper_color_default_foreground"), const gchar *colour_fg = const_app("string_treeview_helper_color_default_foreground"),
*colour_bg = const_app("string_treeview_helper_color_default_background"); *colour_bg = const_app("string_treeview_helper_color_default_background");
strcpy(buf, pl->name->str); strcpy(buf, pl->name);
if(pl->team == current_user.tm && if(pl->team == current_user.tm &&
opt_user_int("int_opt_user_penalty_shooter") == pl->id) opt_user_int("int_opt_user_penalty_shooter") == pl->id)
/* Penalty shooter. */ /* Penalty shooter. */
@@ -1434,9 +1434,9 @@ treeview_helper_mm_teams(GtkTreeViewColumn *col,
if(mm != NULL) if(mm != NULL)
{ {
if(column == 1) if(column == 1)
g_object_set(renderer, "text", mm->lg.team_names[mm->user_team]->str, NULL); g_object_set(renderer, "text", mm->lg.team_names[mm->user_team], NULL);
else else
g_object_set(renderer, "text", mm->lg.team_names[!mm->user_team]->str, NULL); g_object_set(renderer, "text", mm->lg.team_names[!mm->user_team], NULL);
if(!mm->neutral && if(!mm->neutral &&
((column == 1 && mm->user_team == 1) || ((column == 1 && mm->user_team == 1) ||
@@ -1508,7 +1508,7 @@ treeview_helper_season_results(GtkTreeViewColumn *col,
if(column == 3) if(column == 3)
{ {
strcpy(buf, fix->teams[!user_idx]->name->str); strcpy(buf, fix->teams[!user_idx]->name);
if(user_idx == 1) if(user_idx == 1)
g_object_set(renderer, "background", g_object_set(renderer, "background",
const_app("string_treeview_live_game_commentary_away_bg"), NULL); const_app("string_treeview_live_game_commentary_away_bg"), NULL);

View File

@@ -27,7 +27,7 @@ user_new(void)
{ {
User new; User new;
new.name = g_string_new("NONAME"); new.name = g_strdup("NONAME");
new.tm = NULL; new.tm = NULL;
new.team_id = -1; new.team_id = -1;
@@ -45,7 +45,7 @@ user_new(void)
new.youth_academy.pos_pref = PLAYER_POS_ANY; new.youth_academy.pos_pref = PLAYER_POS_ANY;
new.youth_academy.coach = QUALITY_AVERAGE; new.youth_academy.coach = QUALITY_AVERAGE;
new.mmatches_file = g_string_new(""); new.mmatches_file = NULL;
new.mmatches = g_array_new(FALSE, FALSE, sizeof(MemMatch)); new.mmatches = g_array_new(FALSE, FALSE, sizeof(MemMatch));
return new; return new;
@@ -71,10 +71,10 @@ user_set_up_team_new_game(User *user)
while(team_is_user(&g_array_index(lig(user->scout).teams, Team, rndom)) != -1) while(team_is_user(&g_array_index(lig(user->scout).teams, Team, rndom)) != -1)
rndom = math_rndi(0, lig(user->scout).teams->len - 1); rndom = math_rndi(0, lig(user->scout).teams->len - 1);
sprintf(buf, "%s", g_array_index(lig(user->scout).teams, Team, rndom).name->str); sprintf(buf, "%s", g_array_index(lig(user->scout).teams, Team, rndom).name);
g_string_printf(g_array_index(lig(user->scout).teams, Team, rndom).name, "%s", misc_string_assign(&g_array_index(lig(user->scout).teams, Team, rndom).name,
user->tm->name->str); user->tm->name);
g_string_printf(user->tm->name, "%s", buf); misc_string_assign(&user->tm->name, buf);
user->tm = &g_array_index(lig(user->scout).teams, Team, rndom); user->tm = &g_array_index(lig(user->scout).teams, Team, rndom);
user->team_id = g_array_index(lig(user->scout).teams, Team, rndom).id; user->team_id = g_array_index(lig(user->scout).teams, Team, rndom).id;
@@ -193,7 +193,7 @@ user_set_player_list_attributes(const User *user, PlayerListAttribute *attribute
sprintf(prefix, "int_opt_user_pl%d_att", list_number); sprintf(prefix, "int_opt_user_pl%d_att", list_number);
for(i=0;i<user->options.list->len;i++) for(i=0;i<user->options.list->len;i++)
if(g_str_has_prefix(g_array_index(user->options.list, Option, i).name->str, prefix)) if(g_str_has_prefix(g_array_index(user->options.list, Option, i).name, prefix))
{ {
attribute->on_off[cnt] = g_array_index(user->options.list, Option, i).value; attribute->on_off[cnt] = g_array_index(user->options.list, Option, i).value;
cnt++; cnt++;
@@ -250,7 +250,7 @@ user_from_team(const Team *tm)
return &usr(i); return &usr(i);
g_warning("User going with team %s not found.\n", g_warning("User going with team %s not found.\n",
tm->name->str); tm->name);
main_exit_program(EXIT_POINTER_NOT_FOUND, NULL); main_exit_program(EXIT_POINTER_NOT_FOUND, NULL);
@@ -272,7 +272,7 @@ user_job_offer(User *user)
!user->counters[COUNT_USER_WARNING]) !user->counters[COUNT_USER_WARNING])
{ {
user_event_add(user, EVENT_TYPE_WARNING, -1, -1, NULL, user_event_add(user, EVENT_TYPE_WARNING, -1, -1, NULL,
_("The owners of %s are not satisfied with the recent performance of the team. There are rumours they're looking for a new manager."), user->tm->name->str); _("The owners of %s are not satisfied with the recent performance of the team. There are rumours they're looking for a new manager."), user->tm->name);
user->counters[COUNT_USER_WARNING] = 1; user->counters[COUNT_USER_WARNING] = 1;
return; return;
} }
@@ -387,7 +387,7 @@ user_event_add(User *user, gint type, gint value1, gint value2,
va_start (args, format); va_start (args, format);
g_vsprintf(text, format, args); g_vsprintf(text, format, args);
va_end (args); va_end (args);
new.value_string = g_string_new(text); new.value_string = g_strdup(text);
} }
else else
new.value_string = NULL; new.value_string = NULL;
@@ -427,10 +427,10 @@ user_event_show_next(void)
break; break;
case EVENT_TYPE_PLAYER_LEFT: case EVENT_TYPE_PLAYER_LEFT:
game_gui_show_warning(_("%s has left your team because his contract expired."), game_gui_show_warning(_("%s has left your team because his contract expired."),
event->value_string->str); event->value_string);
break; break;
case EVENT_TYPE_WARNING: case EVENT_TYPE_WARNING:
game_gui_show_warning(event->value_string->str); game_gui_show_warning(event->value_string);
break; break;
case EVENT_TYPE_FIRE_FINANCE: case EVENT_TYPE_FIRE_FINANCE:
stat2 = STATUS_JOB_OFFER_FIRE_FINANCE; stat2 = STATUS_JOB_OFFER_FIRE_FINANCE;
@@ -455,47 +455,47 @@ user_event_show_next(void)
break; break;
case EVENT_TYPE_TRANSFER_OFFER_USER: case EVENT_TYPE_TRANSFER_OFFER_USER:
game_gui_show_warning(_("Have a look at the transfer list, there's an offer for %s."), game_gui_show_warning(_("Have a look at the transfer list, there's an offer for %s."),
event->value_string->str); event->value_string);
break; break;
case EVENT_TYPE_TRANSFER_OFFER_CPU: case EVENT_TYPE_TRANSFER_OFFER_CPU:
game_gui_show_warning(_("Your offer for %s has been accepted. If you still want to buy him, go to the transfer list and left click on the player."), game_gui_show_warning(_("Your offer for %s has been accepted. If you still want to buy him, go to the transfer list and left click on the player."),
event->value_string->str); event->value_string);
break; break;
case EVENT_TYPE_TRANSFER_OFFER_REJECTED_BETTER_OFFER: case EVENT_TYPE_TRANSFER_OFFER_REJECTED_BETTER_OFFER:
misc_print_grouped_int(event->value1, buf2); misc_print_grouped_int(event->value1, buf2);
misc_print_grouped_int(event->value2, buf3); misc_print_grouped_int(event->value2, buf3);
game_gui_show_warning(_("The owners of %s have rejected your offer (%s / %s) for %s. There was a better offer for the player than yours."), ((Team*)event->value_pointer)->name->str, buf2, buf3, event->value_string->str); game_gui_show_warning(_("The owners of %s have rejected your offer (%s / %s) for %s. There was a better offer for the player than yours."), ((Team*)event->value_pointer)->name, buf2, buf3, event->value_string);
break; break;
case EVENT_TYPE_TRANSFER_OFFER_REJECTED_FEE_WAGE: case EVENT_TYPE_TRANSFER_OFFER_REJECTED_FEE_WAGE:
misc_print_grouped_int(event->value1, buf2); misc_print_grouped_int(event->value1, buf2);
misc_print_grouped_int(event->value2, buf3); misc_print_grouped_int(event->value2, buf3);
game_gui_show_warning(_("The owners of %s have rejected your offer (%s / %s) for %s. Neither the fee nor the wage you offered were acceptable, they say."), ((Team*)event->value_pointer)->name->str, buf2, buf3, event->value_string->str); game_gui_show_warning(_("The owners of %s have rejected your offer (%s / %s) for %s. Neither the fee nor the wage you offered were acceptable, they say."), ((Team*)event->value_pointer)->name, buf2, buf3, event->value_string);
break; break;
case EVENT_TYPE_TRANSFER_OFFER_REJECTED_FEE: case EVENT_TYPE_TRANSFER_OFFER_REJECTED_FEE:
misc_print_grouped_int(event->value1, buf2); misc_print_grouped_int(event->value1, buf2);
misc_print_grouped_int(event->value2, buf3); misc_print_grouped_int(event->value2, buf3);
game_gui_show_warning(_("The owners of %s have rejected your offer (%s / %s) for %s. The team owners weren't satisfied with the fee you offered."), ((Team*)event->value_pointer)->name->str, buf2, buf3, event->value_string->str); game_gui_show_warning(_("The owners of %s have rejected your offer (%s / %s) for %s. The team owners weren't satisfied with the fee you offered."), ((Team*)event->value_pointer)->name, buf2, buf3, event->value_string);
break; break;
case EVENT_TYPE_TRANSFER_OFFER_REJECTED_WAGE: case EVENT_TYPE_TRANSFER_OFFER_REJECTED_WAGE:
misc_print_grouped_int(event->value1, buf2); misc_print_grouped_int(event->value1, buf2);
misc_print_grouped_int(event->value2, buf3); misc_print_grouped_int(event->value2, buf3);
/* A player from a team has rejected a transfer offer. */ /* A player from a team has rejected a transfer offer. */
game_gui_show_warning(_("%s of %s has rejected your offer (%s / %s). He wasn't satisfied with the wage you offered."), game_gui_show_warning(_("%s of %s has rejected your offer (%s / %s). He wasn't satisfied with the wage you offered."),
event->value_string->str, event->value_string,
((Team*)event->value_pointer)->name->str, buf2, buf3); ((Team*)event->value_pointer)->name, buf2, buf3);
break; break;
case EVENT_TYPE_TRANSFER_OFFER_MONEY: case EVENT_TYPE_TRANSFER_OFFER_MONEY:
/* Buy a player from a team. */ /* Buy a player from a team. */
game_gui_show_warning(_("You didn't have enough money to buy %s from %s."), game_gui_show_warning(_("You didn't have enough money to buy %s from %s."),
event->value_string->str, ((Team*)event->value_pointer)->name->str); event->value_string, ((Team*)event->value_pointer)->name);
break; break;
case EVENT_TYPE_TRANSFER_OFFER_ROSTER: case EVENT_TYPE_TRANSFER_OFFER_ROSTER:
/* Buy a player from a team. */ /* Buy a player from a team. */
game_gui_show_warning(_("Your roster is full. You couldn't buy %s from %s."), game_gui_show_warning(_("Your roster is full. You couldn't buy %s from %s."),
event->value_string->str, ((Team*)event->value_pointer)->name->str); event->value_string, ((Team*)event->value_pointer)->name);
break; break;
case EVENT_TYPE_PLAYER_CAREER_STOP: case EVENT_TYPE_PLAYER_CAREER_STOP:
sprintf(buf, _("%s's injury was so severe that he can't play football on a professional level anymore. He leaves your team."), player_of_id_team(event->user->tm, event->value1)->name->str); sprintf(buf, _("%s's injury was so severe that he can't play football on a professional level anymore. He leaves your team."), player_of_id_team(event->user->tm, event->value1)->name);
if(event->user->tm->players->len < 12) if(event->user->tm->players->len < 12)
{ {
strcat(buf, _(" Fortunately he's got a cousin who can help your team out.")); strcat(buf, _(" Fortunately he's got a cousin who can help your team out."));
@@ -662,12 +662,12 @@ user_history_add(User *user, gint type, gint team_id,
if(replace) if(replace)
{ {
g_string_printf(his->value_string, "%s", string); misc_string_assign(&his->value_string, string);
g_array_sort(user->history, (GCompareFunc)user_history_compare); g_array_sort(user->history, (GCompareFunc)user_history_compare);
} }
else else
{ {
his->value_string = g_string_new(string); his->value_string = g_strdup(string);
g_array_prepend_val(user->history, *his); g_array_prepend_val(user->history, *his);
} }
} }
@@ -687,29 +687,29 @@ user_history_to_string(const UserHistory *history, gchar *buf)
case USER_HISTORY_START_GAME: case USER_HISTORY_START_GAME:
/* Buy a team in a league. */ /* Buy a team in a league. */
sprintf(buf, _("You start the game with %s in the %s."), sprintf(buf, _("You start the game with %s in the %s."),
team_of_id(history->team_id)->name->str, team_of_id(history->team_id)->name,
league_cup_get_name_string(history->value1)); league_cup_get_name_string(history->value1));
break; break;
case USER_HISTORY_FIRE_FINANCES: case USER_HISTORY_FIRE_FINANCES:
/* Team fires, team in a league. */ /* Team fires, team in a league. */
sprintf(buf, _("%s fires you because of financial mismanagement.\nYou find a new job with %s in the %s."), sprintf(buf, _("%s fires you because of financial mismanagement.\nYou find a new job with %s in the %s."),
team_of_id(history->team_id)->name->str, team_of_id(history->team_id)->name,
team_of_id(history->value1)->name->str, team_of_id(history->value1)->name,
league_cup_get_name_string(history->value2)); league_cup_get_name_string(history->value2));
break; break;
case USER_HISTORY_FIRE_FAILURE: case USER_HISTORY_FIRE_FAILURE:
/* Team fires, team in a league. */ /* Team fires, team in a league. */
sprintf(buf, _("%s fires you because of unsuccessfulness.\nYou find a new job with %s in the %s."), sprintf(buf, _("%s fires you because of unsuccessfulness.\nYou find a new job with %s in the %s."),
team_of_id(history->team_id)->name->str, team_of_id(history->team_id)->name,
team_of_id(history->value1)->name->str, team_of_id(history->value1)->name,
league_cup_get_name_string(history->value2)); league_cup_get_name_string(history->value2));
break; break;
case USER_HISTORY_JOB_OFFER_ACCEPTED: case USER_HISTORY_JOB_OFFER_ACCEPTED:
/* Team in a league. Leave team. */ /* Team in a league. Leave team. */
sprintf(buf, _("%s offer you a job in the %s.\nYou accept the challenge and leave %s."), sprintf(buf, _("%s offer you a job in the %s.\nYou accept the challenge and leave %s."),
team_of_id(history->value1)->name->str, team_of_id(history->value1)->name,
league_cup_get_name_string(history->value2), league_cup_get_name_string(history->value2),
team_of_id(history->team_id)->name->str); team_of_id(history->team_id)->name);
break; break;
case USER_HISTORY_END_SEASON: case USER_HISTORY_END_SEASON:
/* League name. */ /* League name. */
@@ -731,13 +731,13 @@ user_history_to_string(const UserHistory *history, gchar *buf)
/* Cup name, team name. */ /* Cup name, team name. */
sprintf(buf, _("You win the %s final against %s."), sprintf(buf, _("You win the %s final against %s."),
league_cup_get_name_string(history->value1), league_cup_get_name_string(history->value1),
history->value_string->str); history->value_string);
break; break;
case USER_HISTORY_LOSE_FINAL: case USER_HISTORY_LOSE_FINAL:
/* Cup name, team name. */ /* Cup name, team name. */
sprintf(buf, _("You lose in the %s final against %s."), sprintf(buf, _("You lose in the %s final against %s."),
league_cup_get_name_string(history->value1), league_cup_get_name_string(history->value1),
history->value_string->str); history->value_string);
break; break;
case USER_HISTORY_REACH_CUP_ROUND: case USER_HISTORY_REACH_CUP_ROUND:
cup_get_round_name(cup_from_clid(history->value1), history->value2, buf2); cup_get_round_name(cup_from_clid(history->value1), history->value2, buf2);
@@ -834,7 +834,7 @@ user_get_sponsor(const User *user)
/* Company addition. */ /* Company addition. */
_(" Bros.")}; _(" Bros.")};
new.name = g_string_new(name_get_random_last_name(name_get_list_from_sid(user->tm->names_file->str))); new.name = g_string_new(name_get_random_last_name(name_get_list_from_sid(user->tm->names_file)));
if(math_rnd(0, 1) < 0.2) if(math_rnd(0, 1) < 0.2)
g_string_append(new.name, name_add[math_rndi(0, 2)]); g_string_append(new.name, name_add[math_rndi(0, 2)]);
g_string_append(new.name, names[math_rndi(0, 17)]); g_string_append(new.name, names[math_rndi(0, 17)]);
@@ -949,7 +949,7 @@ user_mm_load_file(const gchar *filename, GArray *mmatches)
file_remove_files(prefix); file_remove_files(prefix);
if(mmatches == NULL) if(mmatches == NULL)
g_string_printf(current_user.mmatches_file, "%s", filename_local); misc_string_assign(&current_user.mmatches_file, filename_local);
} }
/** Add the last match to the MM file. /** Add the last match to the MM file.
@@ -973,7 +973,7 @@ user_mm_add_last_match(gboolean load_file, gboolean save_file)
league_cup_get_name_string(fix->clid), buf); league_cup_get_name_string(fix->clid), buf);
} }
new.country_name = g_string_new(country.name->str); new.country_name = g_strdup(country.name);
new.neutral = !(fix->home_advantage); new.neutral = !(fix->home_advantage);
new.user_team = (fix->team_ids[0] != current_user.team_id); new.user_team = (fix->team_ids[0] != current_user.team_id);
new.lg = current_user.live_game; new.lg = current_user.live_game;
@@ -986,13 +986,13 @@ user_mm_add_last_match(gboolean load_file, gboolean save_file)
g_array_new(FALSE, FALSE, sizeof(LiveGameUnit)); g_array_new(FALSE, FALSE, sizeof(LiveGameUnit));
if(load_file) if(load_file)
user_mm_load_file(current_user.mmatches_file->str, NULL); user_mm_load_file(current_user.mmatches_file, NULL);
g_array_append_val(current_user.mmatches, new); g_array_append_val(current_user.mmatches, new);
game_gui_print_message(_("Memorable match added.")); game_gui_print_message(_("Memorable match added."));
if(save_file) if(save_file)
user_mm_save_file(current_user.mmatches_file->str, user_mm_save_file(current_user.mmatches_file,
current_user.mmatches); current_user.mmatches);
} }
@@ -1022,7 +1022,7 @@ user_mm_set_filename(const gchar *filename, gchar *dest)
if(g_str_has_suffix(filename, ".bmm.zip")) if(g_str_has_suffix(filename, ".bmm.zip"))
{ {
if(dest == NULL) if(dest == NULL)
g_string_printf(current_user.mmatches_file, "%s", filename); misc_string_assign(&current_user.mmatches_file, filename);
else else
strcpy(dest, filename); strcpy(dest, filename);
return; return;
@@ -1035,7 +1035,10 @@ user_mm_set_filename(const gchar *filename, gchar *dest)
buf[strlen(buf) - 4] = '\0'; buf[strlen(buf) - 4] = '\0';
if(dest == NULL) if(dest == NULL)
g_string_printf(current_user.mmatches_file, "%s.bmm.zip", buf); {
strcat(buf, ".bmm.zip");
misc_string_assign(&current_user.mmatches_file, buf);
}
else else
sprintf(dest, "%s.bmm.zip", buf); sprintf(dest, "%s.bmm.zip", buf);
} }

View File

@@ -75,7 +75,7 @@ enum UserHistoryType
typedef struct typedef struct
{ {
/** Name of the country the user was playing with. */ /** Name of the country the user was playing with. */
GString *country_name; gchar *country_name;
/** The name of the competition, including /** The name of the competition, including
the cup round name. */ the cup round name. */
GString *competition_name; GString *competition_name;
@@ -101,7 +101,7 @@ typedef struct
/** These can hold various information like /** These can hold various information like
team or league/cup ids. */ team or league/cup ids. */
value1, value2; value1, value2;
GString *value_string; gchar *value_string;
} UserHistory; } UserHistory;
@@ -117,7 +117,7 @@ typedef struct
typedef struct typedef struct
{ {
/** Username. */ /** Username. */
GString *name; gchar *name;
/** The team the user manages. */ /** The team the user manages. */
Team *tm; Team *tm;
/** The team id (needed when the team pointer gets invalid). */ /** The team id (needed when the team pointer gets invalid). */
@@ -146,7 +146,7 @@ typedef struct
/** Youth academy of the user. */ /** Youth academy of the user. */
YouthAcademy youth_academy; YouthAcademy youth_academy;
/** The currently used MM file. */ /** The currently used MM file. */
GString *mmatches_file; gchar *mmatches_file;
/** The array of MMs. */ /** The array of MMs. */
GArray *mmatches; GArray *mmatches;
} User; } User;
@@ -185,8 +185,7 @@ typedef struct
/** A pointer for different purposes. */ /** A pointer for different purposes. */
gpointer value_pointer; gpointer value_pointer;
/** A string for different purposes. */ /** A string for different purposes. */
GString *value_string; gchar *value_string;
} Event; } Event;

View File

@@ -87,7 +87,7 @@ GList *support_directories;
/** The name of the current save file (gets updated when a game is /** The name of the current save file (gets updated when a game is
saved or loaded). */ saved or loaded). */
GString *save_file; gchar *save_file;
/** Whether we are using a Unix system or Windows. */ /** Whether we are using a Unix system or Windows. */
gboolean os_is_unix; gboolean os_is_unix;

View File

@@ -157,12 +157,12 @@ window_show_file_sel(void)
if((stat5 == STATUS_SAVE_GAME || if((stat5 == STATUS_SAVE_GAME ||
stat5 == STATUS_LOAD_GAME || stat5 == STATUS_LOAD_GAME ||
stat5 == STATUS_LOAD_GAME_TEAM_SELECTION) && stat5 == STATUS_LOAD_GAME_TEAM_SELECTION) &&
strlen(save_file->str) > 0) save_file != NULL)
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(window.file_chooser), gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(window.file_chooser),
save_file->str); save_file);
else if(users->len > 0 && strlen(current_user.mmatches_file->str) > 0) else if(users->len > 0 && current_user.mmatches_file != NULL)
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(window.file_chooser), gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(window.file_chooser),
current_user.mmatches_file->str); current_user.mmatches_file);
else else
{ {
if(os_is_unix) if(os_is_unix)
@@ -207,7 +207,7 @@ window_show_file_sel(void)
else if(stat5 == STATUS_SELECT_MM_FILE_ADD) else if(stat5 == STATUS_SELECT_MM_FILE_ADD)
{ {
user_mm_set_filename(filename, NULL); user_mm_set_filename(filename, NULL);
mm_file_exists = g_file_test(current_user.mmatches_file->str, mm_file_exists = g_file_test(current_user.mmatches_file,
G_FILE_TEST_EXISTS); G_FILE_TEST_EXISTS);
user_mm_add_last_match(mm_file_exists, TRUE); user_mm_add_last_match(mm_file_exists, TRUE);
} }
@@ -242,7 +242,7 @@ window_show_mmatches(void)
treeview2_show_mmatches(); treeview2_show_mmatches();
gtk_entry_set_text(GTK_ENTRY(lookup_widget(window.mmatches, "entry_mm_file")), gtk_entry_set_text(GTK_ENTRY(lookup_widget(window.mmatches, "entry_mm_file")),
current_user.mmatches_file->str); current_user.mmatches_file);
} }
/** Show the options window. */ /** Show the options window. */
@@ -348,7 +348,7 @@ window_show_stadium(void)
gui_label_set_text_from_int(label_average_attendance, tm->stadium.average_attendance, FALSE); gui_label_set_text_from_int(label_average_attendance, tm->stadium.average_attendance, FALSE);
if(tm->stadium.name != NULL) if(tm->stadium.name != NULL)
gtk_label_set_text(label_name, tm->stadium.name->str); gtk_label_set_text(label_name, tm->stadium.name);
else else
gtk_widget_hide(GTK_WIDGET(label_name)); gtk_widget_hide(GTK_WIDGET(label_name));

View File

@@ -78,7 +78,7 @@ xml_load_league(const gchar *dirname, const gchar *basename, const GPtrArray *di
g_array_append_val(ligs, new); g_array_append_val(ligs, new);
sprintf(buf, _("Loading league: %s"), sprintf(buf, _("Loading league: %s"),
new.name->str); new.name);
gui_show_progress( gui_show_progress(
gtk_progress_bar_get_fraction( gtk_progress_bar_get_fraction(
GTK_PROGRESS_BAR(lookup_widget(window.progress, "progressbar"))), buf); GTK_PROGRESS_BAR(lookup_widget(window.progress, "progressbar"))), buf);
@@ -141,7 +141,7 @@ xml_load_cup(Cup *cup, const gchar *dirname, const gchar *basename, const GPtrAr
xml_loadsave_cup_read(buf, cup); xml_loadsave_cup_read(buf, cup);
sprintf(buf, _("Loading cup: %s"), sprintf(buf, _("Loading cup: %s"),
cup->name->str); cup->name);
gui_show_progress( gui_show_progress(
gtk_progress_bar_get_fraction( gtk_progress_bar_get_fraction(
GTK_PROGRESS_BAR(lookup_widget(window.progress, "progressbar"))), buf); GTK_PROGRESS_BAR(lookup_widget(window.progress, "progressbar"))), buf);

View File

@@ -135,11 +135,11 @@ xml_country_read_text (GMarkupParseContext *context,
int_value = (gint)g_ascii_strtod(buf, NULL); int_value = (gint)g_ascii_strtod(buf, NULL);
if(state == STATE_NAME) if(state == STATE_NAME)
country.name = g_string_new(buf); misc_string_assign(&country.name, buf);
else if(state == STATE_SYMBOL) else if(state == STATE_SYMBOL)
country.symbol = g_string_new(buf); misc_string_assign(&country.symbol, buf);
else if(state == STATE_SID) else if(state == STATE_SID)
country.sid = g_string_new(buf); misc_string_assign(&country.sid, buf);
else if(state == STATE_SUPERNATIONAL) else if(state == STATE_SUPERNATIONAL)
{ {
sett_set_int("int_opt_disable_finances", 1); sett_set_int("int_opt_disable_finances", 1);

View File

@@ -261,13 +261,13 @@ xml_cup_read_text (GMarkupParseContext *context,
float_value = (gfloat)g_ascii_strtod(buf, NULL); float_value = (gfloat)g_ascii_strtod(buf, NULL);
if(state == STATE_NAME) if(state == STATE_NAME)
g_string_printf(new_cup.name, "%s", buf); misc_string_assign(&new_cup.name, buf);
else if(state == STATE_SHORT_NAME) else if(state == STATE_SHORT_NAME)
g_string_printf(new_cup.short_name, "%s", buf); misc_string_assign(&new_cup.short_name, buf);
else if(state == STATE_SYMBOL) else if(state == STATE_SYMBOL)
g_string_printf(new_cup.symbol, "%s", buf); misc_string_assign(&new_cup.symbol, buf);
else if(state == STATE_SID) else if(state == STATE_SID)
g_string_printf(new_cup.sid, "%s", buf); misc_string_assign(&new_cup.sid, buf);
else if(state == STATE_GROUP) else if(state == STATE_GROUP)
new_cup.group = int_value; new_cup.group = int_value;
else if(state == STATE_LAST_WEEK) else if(state == STATE_LAST_WEEK)
@@ -302,7 +302,7 @@ xml_cup_read_text (GMarkupParseContext *context,
else if(state == STATE_CUP_ROUND_NUMBER_OF_BEST_ADVANCE) else if(state == STATE_CUP_ROUND_NUMBER_OF_BEST_ADVANCE)
new_round.round_robin_number_of_best_advance = int_value; new_round.round_robin_number_of_best_advance = int_value;
else if(state == STATE_CHOOSE_TEAM_SID) else if(state == STATE_CHOOSE_TEAM_SID)
g_string_printf(new_choose_team.sid, "%s", buf); misc_string_assign(&new_choose_team.sid, buf);
else if(state == STATE_CHOOSE_TEAM_NUMBER_OF_TEAMS) else if(state == STATE_CHOOSE_TEAM_NUMBER_OF_TEAMS)
new_choose_team.number_of_teams = int_value; new_choose_team.number_of_teams = int_value;
else if(state == STATE_CHOOSE_TEAM_START_IDX) else if(state == STATE_CHOOSE_TEAM_START_IDX)

View File

@@ -169,8 +169,8 @@ xml_league_read_start_element (GMarkupParseContext *context,
else if(strcmp(element_name, TAG_TEAM) == 0) else if(strcmp(element_name, TAG_TEAM) == 0)
{ {
new_team = team_new(TRUE); new_team = team_new(TRUE);
g_string_printf(new_team.symbol, "%s", new_league.symbol->str); misc_string_assign(&new_team.symbol, new_league.symbol);
g_string_printf(new_team.names_file, "%s", new_league.names_file->str); misc_string_assign(&new_team.names_file, new_league.names_file);
new_team.clid = new_league.id; new_team.clid = new_league.id;
g_array_append_val(new_league.teams, new_team); g_array_append_val(new_league.teams, new_team);
state = STATE_TEAM; state = STATE_TEAM;
@@ -268,15 +268,15 @@ xml_league_read_text (GMarkupParseContext *context,
if(state == STATE_NAME) if(state == STATE_NAME)
{ {
g_string_printf(new_league.name, "%s", buf); misc_string_assign(&new_league.name, buf);
g_string_printf(new_league.table.name, "%s", buf); misc_string_assign(&new_league.table.name, buf);
} }
else if(state == STATE_SHORT_NAME) else if(state == STATE_SHORT_NAME)
g_string_printf(new_league.short_name, "%s", buf); misc_string_assign(&new_league.short_name, buf);
else if(state == STATE_SID) else if(state == STATE_SID)
g_string_printf(new_league.sid, "%s", buf); misc_string_assign(&new_league.sid, buf);
else if(state == STATE_SYMBOL) else if(state == STATE_SYMBOL)
g_string_printf(new_league.symbol, "%s", buf); misc_string_assign(&new_league.symbol, buf);
else if(state == STATE_LAYER) else if(state == STATE_LAYER)
new_league.layer = int_value; new_league.layer = int_value;
else if(state == STATE_FIRST_WEEK) else if(state == STATE_FIRST_WEEK)
@@ -291,17 +291,17 @@ xml_league_read_text (GMarkupParseContext *context,
new_league.average_talent = new_league.average_talent =
(float_value / 10000) * const_float("float_player_max_skill"); (float_value / 10000) * const_float("float_player_max_skill");
else if(state == STATE_NAMES_FILE) else if(state == STATE_NAMES_FILE)
g_string_printf(new_league.names_file, "%s", buf); misc_string_assign(&new_league.names_file, buf);
else if(state == STATE_ACTIVE) else if(state == STATE_ACTIVE)
new_league.active = int_value; new_league.active = int_value;
else if(state == STATE_PROM_GAMES_DEST_SID) else if(state == STATE_PROM_GAMES_DEST_SID)
g_string_printf(new_league.prom_rel.prom_games_dest_sid, "%s", buf); misc_string_assign(&new_league.prom_rel.prom_games_dest_sid, buf);
else if(state == STATE_PROM_GAMES_LOSER_SID) else if(state == STATE_PROM_GAMES_LOSER_SID)
g_string_printf(new_league.prom_rel.prom_games_loser_sid, "%s", buf); misc_string_assign(&new_league.prom_rel.prom_games_loser_sid, buf);
else if(state == STATE_PROM_GAMES_NUMBER_OF_ADVANCE) else if(state == STATE_PROM_GAMES_NUMBER_OF_ADVANCE)
new_league.prom_rel.prom_games_number_of_advance = int_value; new_league.prom_rel.prom_games_number_of_advance = int_value;
else if(state == STATE_PROM_GAMES_CUP_SID) else if(state == STATE_PROM_GAMES_CUP_SID)
g_string_printf(new_league.prom_rel.prom_games_cup_sid, "%s", buf); misc_string_assign(&new_league.prom_rel.prom_games_cup_sid, buf);
else if(state == STATE_PROM_REL_ELEMENT_RANK_START) else if(state == STATE_PROM_REL_ELEMENT_RANK_START)
g_array_index(new_league.prom_rel.elements, g_array_index(new_league.prom_rel.elements,
PromRelElement, PromRelElement,
@@ -311,9 +311,9 @@ xml_league_read_text (GMarkupParseContext *context,
PromRelElement, PromRelElement,
new_league.prom_rel.elements->len - 1).ranks[1] = int_value; new_league.prom_rel.elements->len - 1).ranks[1] = int_value;
else if(state == STATE_PROM_REL_ELEMENT_DEST_SID) else if(state == STATE_PROM_REL_ELEMENT_DEST_SID)
g_string_printf(g_array_index(new_league.prom_rel.elements, misc_string_assign(&g_array_index(new_league.prom_rel.elements,
PromRelElement, PromRelElement,
new_league.prom_rel.elements->len - 1).dest_sid, "%s", buf); new_league.prom_rel.elements->len - 1).dest_sid, buf);
else if(state == STATE_PROM_REL_ELEMENT_TYPE) else if(state == STATE_PROM_REL_ELEMENT_TYPE)
{ {
if(strcmp(buf, "promotion") == 0) if(strcmp(buf, "promotion") == 0)
@@ -326,21 +326,20 @@ xml_league_read_text (GMarkupParseContext *context,
new_league.prom_rel.elements->len - 1).type = PROM_REL_RELEGATION; new_league.prom_rel.elements->len - 1).type = PROM_REL_RELEGATION;
} }
else if(state == STATE_TEAM_NAME) else if(state == STATE_TEAM_NAME)
g_string_printf(g_array_index(new_league.teams, Team, misc_string_assign(&g_array_index(new_league.teams, Team,
new_league.teams->len - 1).name, "%s", buf); new_league.teams->len - 1).name, buf);
else if(state == STATE_TEAM_SYMBOL) else if(state == STATE_TEAM_SYMBOL)
g_string_printf(g_array_index(new_league.teams, Team, misc_string_assign(&g_array_index(new_league.teams, Team,
new_league.teams->len - 1).symbol, "%s", buf); new_league.teams->len - 1).symbol, buf);
else if(state == STATE_TEAM_NAMES_FILE) else if(state == STATE_TEAM_NAMES_FILE)
g_string_printf(g_array_index(new_league.teams, Team, misc_string_assign(&g_array_index(new_league.teams, Team,
new_league.teams->len - 1).names_file, "%s", buf); new_league.teams->len - 1).names_file, buf);
else if(state == STATE_TEAM_AVERAGE_TALENT) else if(state == STATE_TEAM_AVERAGE_TALENT)
g_array_index(new_league.teams, Team, g_array_index(new_league.teams, Team,
new_league.teams->len - 1).average_talent = new_league.teams->len - 1).average_talent =
(float_value / 10000) * const_float("float_player_max_skill"); (float_value / 10000) * const_float("float_player_max_skill");
else if(state == STATE_TEAM_DEF_FILE) else if(state == STATE_TEAM_DEF_FILE)
g_array_index(new_league.teams, Team, new_league.teams->len - 1).def_file = misc_string_assign(&g_array_index(new_league.teams, Team, new_league.teams->len - 1).def_file, buf);
g_string_new(buf);
} }
/** /**

View File

@@ -56,7 +56,7 @@ enum XmlLgCommentaryStates
}; };
gint state, commentary_idx, priority; gint state, commentary_idx, priority;
GString *condition; gchar *condition;
/** /**
* The function called by the parser when an opening tag is read. * The function called by the parser when an opening tag is read.
@@ -88,7 +88,7 @@ xml_lg_commentary_read_start_element (GMarkupParseContext *context,
while(attribute_names[atidx] != NULL) while(attribute_names[atidx] != NULL)
{ {
if(strcmp(attribute_names[atidx], ATT_NAME_CONDITION) == 0) if(strcmp(attribute_names[atidx], ATT_NAME_CONDITION) == 0)
condition = g_string_new(attribute_values[atidx]); condition = g_strdup(attribute_values[atidx]);
else if(strcmp(attribute_names[atidx], ATT_NAME_PRIORITY) == 0) else if(strcmp(attribute_names[atidx], ATT_NAME_PRIORITY) == 0)
priority = (gint)g_ascii_strtod(attribute_values[atidx], NULL); priority = (gint)g_ascii_strtod(attribute_values[atidx], NULL);
@@ -138,6 +138,9 @@ xml_lg_commentary_read_text (GMarkupParseContext *context,
gchar buf[text_len + 1]; gchar buf[text_len + 1];
LGCommentary commentary; LGCommentary commentary;
commentary.text = NULL;
commentary.condition = NULL;
strncpy(buf, text, text_len); strncpy(buf, text, text_len);
buf[text_len] = '\0'; buf[text_len] = '\0';
@@ -210,7 +213,7 @@ xml_lg_commentary_read_text (GMarkupParseContext *context,
} }
else if(state == STATE_EVENT_COMMENTARY) else if(state == STATE_EVENT_COMMENTARY)
{ {
commentary.text = g_string_new(buf); misc_string_assign(&commentary.text, buf);
commentary.condition = condition; commentary.condition = condition;
commentary.priority = MAX(1, priority); commentary.priority = MAX(1, priority);
commentary.id = lg_commentary_id_new; commentary.id = lg_commentary_id_new;

View File

@@ -166,13 +166,13 @@ xml_loadsave_cup_text (GMarkupParseContext *context,
float_value = (gfloat)g_ascii_strtod(buf, NULL); float_value = (gfloat)g_ascii_strtod(buf, NULL);
if(state == TAG_NAME) if(state == TAG_NAME)
g_string_printf(new_cup->name, "%s", buf); misc_string_assign(&new_cup->name, buf);
else if(state == TAG_SHORT_NAME) else if(state == TAG_SHORT_NAME)
g_string_printf(new_cup->short_name, "%s", buf); misc_string_assign(&new_cup->short_name, buf);
else if(state == TAG_SYMBOL) else if(state == TAG_SYMBOL)
g_string_printf(new_cup->symbol, "%s", buf); misc_string_assign(&new_cup->symbol, buf);
else if(state == TAG_SID) else if(state == TAG_SID)
g_string_printf(new_cup->sid, "%s", buf); misc_string_assign(&new_cup->sid, buf);
else if(state == TAG_ID) else if(state == TAG_ID)
new_cup->id = int_value; new_cup->id = int_value;
else if(state == TAG_WEEK_GAP) else if(state == TAG_WEEK_GAP)
@@ -198,7 +198,7 @@ xml_loadsave_cup_text (GMarkupParseContext *context,
else if(state == TAG_CUP_TEAM_NAME) else if(state == TAG_CUP_TEAM_NAME)
g_ptr_array_add(new_cup->team_names, g_strdup(buf)); g_ptr_array_add(new_cup->team_names, g_strdup(buf));
else if(state == TAG_CUP_CHOOSE_TEAM_SID) else if(state == TAG_CUP_CHOOSE_TEAM_SID)
g_string_printf(new_choose_team.sid, "%s", buf); misc_string_assign(&new_choose_team.sid, buf);
else if(state == TAG_CUP_CHOOSE_TEAM_NUMBER_OF_TEAMS) else if(state == TAG_CUP_CHOOSE_TEAM_NUMBER_OF_TEAMS)
new_choose_team.number_of_teams = int_value; new_choose_team.number_of_teams = int_value;
else if(state == TAG_CUP_CHOOSE_TEAM_START_IDX) else if(state == TAG_CUP_CHOOSE_TEAM_START_IDX)
@@ -302,10 +302,10 @@ xml_loadsave_cup_write(const gchar *prefix, const Cup *cup)
fprintf(fil, "<_%d>\n", TAG_CUP); fprintf(fil, "<_%d>\n", TAG_CUP);
xml_write_g_string(fil, cup->name, TAG_NAME, I0); xml_write_string(fil, cup->name, TAG_NAME, I0);
xml_write_g_string(fil, cup->short_name, TAG_SHORT_NAME, I0); xml_write_string(fil, cup->short_name, TAG_SHORT_NAME, I0);
xml_write_g_string(fil, cup->sid, TAG_SID, I0); xml_write_string(fil, cup->sid, TAG_SID, I0);
xml_write_g_string(fil, cup->symbol, TAG_SYMBOL, I0); xml_write_string(fil, cup->symbol, TAG_SYMBOL, I0);
xml_write_int(fil, cup->id, TAG_ID, I0); xml_write_int(fil, cup->id, TAG_ID, I0);
xml_write_int(fil, cup->last_week, TAG_CUP_LAST_WEEK, I0); xml_write_int(fil, cup->last_week, TAG_CUP_LAST_WEEK, I0);
@@ -408,7 +408,7 @@ xml_loadsave_cup_write_choose_team(FILE *fil, const CupChooseTeam *choose_team)
{ {
fprintf(fil, "%s<_%d>\n", I1, TAG_CUP_CHOOSE_TEAM); fprintf(fil, "%s<_%d>\n", I1, TAG_CUP_CHOOSE_TEAM);
xml_write_g_string(fil, choose_team->sid, TAG_CUP_CHOOSE_TEAM_SID, I2); xml_write_string(fil, choose_team->sid, TAG_CUP_CHOOSE_TEAM_SID, I2);
xml_write_int(fil, choose_team->number_of_teams, xml_write_int(fil, choose_team->number_of_teams,
TAG_CUP_CHOOSE_TEAM_NUMBER_OF_TEAMS, I2); TAG_CUP_CHOOSE_TEAM_NUMBER_OF_TEAMS, I2);
xml_write_int(fil, choose_team->start_idx, xml_write_int(fil, choose_team->start_idx,

View File

@@ -134,15 +134,15 @@ xml_loadsave_league_text (GMarkupParseContext *context,
int_value = (gint)g_ascii_strtod(buf, NULL); int_value = (gint)g_ascii_strtod(buf, NULL);
if(state == TAG_NAME) if(state == TAG_NAME)
g_string_printf(new_league->name, "%s", buf); misc_string_assign(&new_league->name, buf);
else if(state == TAG_SHORT_NAME) else if(state == TAG_SHORT_NAME)
g_string_printf(new_league->short_name, "%s", buf); misc_string_assign(&new_league->short_name, buf);
else if(state == TAG_NAMES_FILE) else if(state == TAG_NAMES_FILE)
g_string_printf(new_league->names_file, "%s", buf); misc_string_assign(&new_league->names_file, buf);
else if(state == TAG_SYMBOL) else if(state == TAG_SYMBOL)
g_string_printf(new_league->symbol, "%s", buf); misc_string_assign(&new_league->symbol, buf);
else if(state == TAG_SID) else if(state == TAG_SID)
g_string_printf(new_league->sid, "%s", buf); misc_string_assign(&new_league->sid, buf);
else if(state == TAG_ID) else if(state == TAG_ID)
new_league->id = int_value; new_league->id = int_value;
else if(state == TAG_LEAGUE_LAYER) else if(state == TAG_LEAGUE_LAYER)
@@ -158,19 +158,19 @@ xml_loadsave_league_text (GMarkupParseContext *context,
else if(state == TAG_LEAGUE_ACTIVE) else if(state == TAG_LEAGUE_ACTIVE)
new_league->active = int_value; new_league->active = int_value;
else if(state == TAG_LEAGUE_PROM_REL_PROM_GAMES_DEST_SID) else if(state == TAG_LEAGUE_PROM_REL_PROM_GAMES_DEST_SID)
g_string_printf(new_league->prom_rel.prom_games_dest_sid, "%s", buf); misc_string_assign(&new_league->prom_rel.prom_games_dest_sid, buf);
else if(state == TAG_LEAGUE_PROM_REL_PROM_GAMES_CUP_SID) else if(state == TAG_LEAGUE_PROM_REL_PROM_GAMES_CUP_SID)
g_string_printf(new_league->prom_rel.prom_games_cup_sid, "%s", buf); misc_string_assign(&new_league->prom_rel.prom_games_cup_sid, buf);
else if(state == TAG_LEAGUE_PROM_REL_PROM_GAMES_NUMBER_OF_ADVANCE) else if(state == TAG_LEAGUE_PROM_REL_PROM_GAMES_NUMBER_OF_ADVANCE)
new_league->prom_rel.prom_games_number_of_advance = int_value; new_league->prom_rel.prom_games_number_of_advance = int_value;
else if(state == TAG_LEAGUE_PROM_REL_PROM_GAMES_LOSER_SID) else if(state == TAG_LEAGUE_PROM_REL_PROM_GAMES_LOSER_SID)
g_string_printf(new_league->prom_rel.prom_games_loser_sid, "%s", buf); misc_string_assign(&new_league->prom_rel.prom_games_loser_sid, buf);
else if(state == TAG_LEAGUE_PROM_REL_ELEMENT_RANK) else if(state == TAG_LEAGUE_PROM_REL_ELEMENT_RANK)
new_element.ranks[promrankidx] = int_value; new_element.ranks[promrankidx] = int_value;
else if(state == TAG_LEAGUE_PROM_REL_ELEMENT_TYPE) else if(state == TAG_LEAGUE_PROM_REL_ELEMENT_TYPE)
new_element.type = int_value; new_element.type = int_value;
else if(state == TAG_LEAGUE_PROM_REL_ELEMENT_DEST_SID) else if(state == TAG_LEAGUE_PROM_REL_ELEMENT_DEST_SID)
g_string_printf(new_element.dest_sid, "%s", buf); misc_string_assign(&new_element.dest_sid, buf);
} }
void void
@@ -232,11 +232,11 @@ xml_loadsave_league_write(const gchar *prefix, const League *league)
fprintf(fil, "%s<_%d>\n", I0, TAG_LEAGUE); fprintf(fil, "%s<_%d>\n", I0, TAG_LEAGUE);
xml_write_g_string(fil, league->name, TAG_NAME, I0); xml_write_string(fil, league->name, TAG_NAME, I0);
xml_write_g_string(fil, league->short_name, TAG_SHORT_NAME, I0); xml_write_string(fil, league->short_name, TAG_SHORT_NAME, I0);
xml_write_g_string(fil, league->names_file, TAG_NAMES_FILE, I0); xml_write_string(fil, league->names_file, TAG_NAMES_FILE, I0);
xml_write_g_string(fil, league->sid, TAG_SID, I0); xml_write_string(fil, league->sid, TAG_SID, I0);
xml_write_g_string(fil, league->symbol, TAG_SYMBOL, I0); xml_write_string(fil, league->symbol, TAG_SYMBOL, I0);
xml_write_int(fil, league->id, TAG_ID, I0); xml_write_int(fil, league->id, TAG_ID, I0);
xml_write_int(fil, league->layer, TAG_LEAGUE_LAYER, I0); xml_write_int(fil, league->layer, TAG_LEAGUE_LAYER, I0);
@@ -248,13 +248,13 @@ xml_loadsave_league_write(const gchar *prefix, const League *league)
fprintf(fil, "%s<_%d>\n", I0, TAG_LEAGUE_PROM_REL); fprintf(fil, "%s<_%d>\n", I0, TAG_LEAGUE_PROM_REL);
xml_write_g_string(fil, league->prom_rel.prom_games_dest_sid, xml_write_string(fil, league->prom_rel.prom_games_dest_sid,
TAG_LEAGUE_PROM_REL_PROM_GAMES_DEST_SID, I1); TAG_LEAGUE_PROM_REL_PROM_GAMES_DEST_SID, I1);
xml_write_g_string(fil, league->prom_rel.prom_games_cup_sid, xml_write_string(fil, league->prom_rel.prom_games_cup_sid,
TAG_LEAGUE_PROM_REL_PROM_GAMES_CUP_SID, I1); TAG_LEAGUE_PROM_REL_PROM_GAMES_CUP_SID, I1);
xml_write_int(fil, league->prom_rel.prom_games_number_of_advance, xml_write_int(fil, league->prom_rel.prom_games_number_of_advance,
TAG_LEAGUE_PROM_REL_PROM_GAMES_NUMBER_OF_ADVANCE, I1); TAG_LEAGUE_PROM_REL_PROM_GAMES_NUMBER_OF_ADVANCE, I1);
xml_write_g_string(fil, league->prom_rel.prom_games_loser_sid, xml_write_string(fil, league->prom_rel.prom_games_loser_sid,
TAG_LEAGUE_PROM_REL_PROM_GAMES_LOSER_SID, I1); TAG_LEAGUE_PROM_REL_PROM_GAMES_LOSER_SID, I1);
fprintf(fil, "%s<_%d>\n", I1, TAG_LEAGUE_PROM_REL_ELEMENTS); fprintf(fil, "%s<_%d>\n", I1, TAG_LEAGUE_PROM_REL_ELEMENTS);
@@ -267,7 +267,7 @@ xml_loadsave_league_write(const gchar *prefix, const League *league)
TAG_LEAGUE_PROM_REL_ELEMENT_RANK, I2); TAG_LEAGUE_PROM_REL_ELEMENT_RANK, I2);
xml_write_int(fil, g_array_index(league->prom_rel.elements, PromRelElement, i).type, xml_write_int(fil, g_array_index(league->prom_rel.elements, PromRelElement, i).type,
TAG_LEAGUE_PROM_REL_ELEMENT_TYPE, I2); TAG_LEAGUE_PROM_REL_ELEMENT_TYPE, I2);
xml_write_g_string(fil, g_array_index(league->prom_rel.elements, PromRelElement, i).dest_sid, xml_write_string(fil, g_array_index(league->prom_rel.elements, PromRelElement, i).dest_sid,
TAG_LEAGUE_PROM_REL_ELEMENT_DEST_SID, I2); TAG_LEAGUE_PROM_REL_ELEMENT_DEST_SID, I2);
fprintf(fil, "%s</_%d>\n", I1, TAG_LEAGUE_PROM_REL_ELEMENT); fprintf(fil, "%s</_%d>\n", I1, TAG_LEAGUE_PROM_REL_ELEMENT);
} }

View File

@@ -20,7 +20,7 @@ enum
gint state, in_state, valueidx; gint state, in_state, valueidx;
Stat new_stat; Stat new_stat;
LeagueStat *lstat; LeagueStat *lig_stat;
void void
xml_loadsave_league_stat_start_element (GMarkupParseContext *context, xml_loadsave_league_stat_start_element (GMarkupParseContext *context,
@@ -80,13 +80,13 @@ xml_loadsave_league_stat_end_element (GMarkupParseContext *context,
{ {
state = in_state; state = in_state;
if(in_state == TAG_STAT_TEAMS_OFF) if(in_state == TAG_STAT_TEAMS_OFF)
stat_array = lstat->teams_off; stat_array = lig_stat->teams_off;
else if(in_state == TAG_STAT_TEAMS_DEF) else if(in_state == TAG_STAT_TEAMS_DEF)
stat_array = lstat->teams_def; stat_array = lig_stat->teams_def;
else if(in_state == TAG_STAT_PLAYER_SCORERS) else if(in_state == TAG_STAT_PLAYER_SCORERS)
stat_array = lstat->player_scorers; stat_array = lig_stat->player_scorers;
else if(in_state == TAG_STAT_PLAYER_GOALIES) else if(in_state == TAG_STAT_PLAYER_GOALIES)
stat_array = lstat->player_goalies; stat_array = lig_stat->player_goalies;
else else
{ {
g_warning("xml_loadsave_league_stat_end_element: unknown in_state %d \n", g_warning("xml_loadsave_league_stat_end_element: unknown in_state %d \n",
@@ -126,7 +126,7 @@ xml_loadsave_league_stat_text (GMarkupParseContext *context,
int_value = (gint)g_ascii_strtod(buf, NULL); int_value = (gint)g_ascii_strtod(buf, NULL);
if(state == TAG_ID) if(state == TAG_ID)
lstat->clid = int_value; lig_stat->clid = int_value;
else if(state == TAG_TEAM_ID) else if(state == TAG_TEAM_ID)
new_stat.team_id = int_value; new_stat.team_id = int_value;
else if(state == TAG_STAT_VALUE) else if(state == TAG_STAT_VALUE)
@@ -139,7 +139,7 @@ xml_loadsave_league_stat_text (GMarkupParseContext *context,
new_stat.value3 = int_value; new_stat.value3 = int_value;
} }
else if(state == TAG_STAT_VALUE_STRING) else if(state == TAG_STAT_VALUE_STRING)
new_stat.value_string = g_string_new(buf); new_stat.value_string = g_strdup(buf);
} }
void void
@@ -162,7 +162,7 @@ xml_loadsave_league_stat_read(const gchar *filename, LeagueStat *league_stat)
misc_print_error(&error, TRUE); misc_print_error(&error, TRUE);
} }
lstat = league_stat; lig_stat = league_stat;
if(g_markup_parse_context_parse(context, file_contents, length, &error)) if(g_markup_parse_context_parse(context, file_contents, length, &error))
{ {
@@ -227,7 +227,7 @@ xml_loadsave_league_stat_write_stat(FILE *fil, const Stat *stat)
xml_write_int(fil, stat->value1, TAG_STAT_VALUE, I1); xml_write_int(fil, stat->value1, TAG_STAT_VALUE, I1);
xml_write_int(fil, stat->value2, TAG_STAT_VALUE, I1); xml_write_int(fil, stat->value2, TAG_STAT_VALUE, I1);
xml_write_int(fil, stat->value3, TAG_STAT_VALUE, I1); xml_write_int(fil, stat->value3, TAG_STAT_VALUE, I1);
xml_write_g_string(fil, stat->value_string, TAG_STAT_VALUE_STRING, I1); xml_write_string(fil, stat->value_string, TAG_STAT_VALUE_STRING, I1);
fprintf(fil, "%s</_%d>\n", I1, TAG_STAT); fprintf(fil, "%s</_%d>\n", I1, TAG_STAT);
} }

View File

@@ -152,7 +152,6 @@ xml_loadsave_live_game_text (GMarkupParseContext *context,
{ {
gchar buf[SMALL]; gchar buf[SMALL];
gint int_value = -1; gint int_value = -1;
GString *new_string = NULL;
strncpy(buf, text, text_len); strncpy(buf, text, text_len);
buf[text_len] = '\0'; buf[text_len] = '\0';
@@ -165,7 +164,7 @@ xml_loadsave_live_game_text (GMarkupParseContext *context,
lgame->fix = fixture_from_id(int_value); lgame->fix = fixture_from_id(int_value);
} }
else if(state == TAG_LIVE_GAME_TEAM_NAME) else if(state == TAG_LIVE_GAME_TEAM_NAME)
lgame->team_names[team_name_idx] = g_string_new(buf); misc_string_assign(&lgame->team_names[team_name_idx], buf);
else if(state == TAG_LIVE_GAME_UNIT_POSSESSION) else if(state == TAG_LIVE_GAME_UNIT_POSSESSION)
new_unit.possession = int_value; new_unit.possession = int_value;
else if(state == TAG_LIVE_GAME_UNIT_AREA) else if(state == TAG_LIVE_GAME_UNIT_AREA)
@@ -185,7 +184,7 @@ xml_loadsave_live_game_text (GMarkupParseContext *context,
else if(state == TAG_LIVE_GAME_UNIT_EVENT_PLAYER2) else if(state == TAG_LIVE_GAME_UNIT_EVENT_PLAYER2)
new_unit.event.player2 = int_value; new_unit.event.player2 = int_value;
else if(state == TAG_LIVE_GAME_UNIT_EVENT_COMMENTARY) else if(state == TAG_LIVE_GAME_UNIT_EVENT_COMMENTARY)
new_unit.event.commentary = g_string_new(buf); new_unit.event.commentary = g_strdup(buf);
else if(state == TAG_LIVE_GAME_UNIT_EVENT_VERBOSITY) else if(state == TAG_LIVE_GAME_UNIT_EVENT_VERBOSITY)
new_unit.event.verbosity = int_value; new_unit.event.verbosity = int_value;
else if(state == TAG_LIVE_GAME_STAT_POSSESSION) else if(state == TAG_LIVE_GAME_STAT_POSSESSION)
@@ -193,11 +192,8 @@ xml_loadsave_live_game_text (GMarkupParseContext *context,
else if(state == TAG_LIVE_GAME_STAT_VALUE) else if(state == TAG_LIVE_GAME_STAT_VALUE)
lgame->stats.values[statvalidx][statvalidx2] = int_value; lgame->stats.values[statvalidx][statvalidx2] = int_value;
else if(state == TAG_LIVE_GAME_STAT_PLAYER_ELEMENT) else if(state == TAG_LIVE_GAME_STAT_PLAYER_ELEMENT)
{
new_string = g_string_new(buf);
g_ptr_array_add(lgame->stats.players[statplidx][statplidx2], g_ptr_array_add(lgame->stats.players[statplidx][statplidx2],
new_string); g_strdup(buf));
}
} }
void void
@@ -221,6 +217,8 @@ xml_loadsave_live_game_read(const gchar *filename, LiveGame *live_game)
} }
lgame = live_game; lgame = live_game;
lgame->team_names[0] =
lgame->team_names[1] = NULL;
if(g_markup_parse_context_parse(context, file_contents, length, &error)) if(g_markup_parse_context_parse(context, file_contents, length, &error))
{ {
@@ -256,7 +254,7 @@ xml_loadsave_live_game_write(const gchar *filename, const LiveGame *live_game)
league_cup_get_name_string(live_game->fix->id)); league_cup_get_name_string(live_game->fix->id));
for(i=0;i<2;i++) for(i=0;i<2;i++)
xml_write_g_string(fil, live_game->team_names[i], xml_write_string(fil, live_game->team_names[i],
TAG_LIVE_GAME_TEAM_NAME, I0); TAG_LIVE_GAME_TEAM_NAME, I0);
} }
@@ -297,7 +295,7 @@ xml_loadsave_live_game_write_unit(FILE *fil, const LiveGameUnit *unit)
xml_write_int(fil, unit->event.verbosity, xml_write_int(fil, unit->event.verbosity,
TAG_LIVE_GAME_UNIT_EVENT_VERBOSITY, I2); TAG_LIVE_GAME_UNIT_EVENT_VERBOSITY, I2);
xml_write_g_string(fil, unit->event.commentary, xml_write_string(fil, unit->event.commentary,
TAG_LIVE_GAME_UNIT_EVENT_COMMENTARY, I2); TAG_LIVE_GAME_UNIT_EVENT_COMMENTARY, I2);
xml_write_int(fil, unit->event.team, xml_write_int(fil, unit->event.team,
@@ -338,8 +336,8 @@ xml_loadsave_live_game_write_stats(FILE *fil, const LiveGameStats *stats)
{ {
fprintf(fil, "%s<_%d>\n", I1, TAG_LIVE_GAME_STAT_PLAYER); fprintf(fil, "%s<_%d>\n", I1, TAG_LIVE_GAME_STAT_PLAYER);
for(k=0;k<stats->players[i][j]->len;k++) for(k=0;k<stats->players[i][j]->len;k++)
xml_write_g_string(fil, xml_write_string(fil,
(GString*)g_ptr_array_index(stats->players[i][j], k), (gchar*)g_ptr_array_index(stats->players[i][j], k),
TAG_LIVE_GAME_STAT_PLAYER_ELEMENT, I2); TAG_LIVE_GAME_STAT_PLAYER_ELEMENT, I2);
fprintf(fil, "%s</_%d>\n", I1, TAG_LIVE_GAME_STAT_PLAYER); fprintf(fil, "%s</_%d>\n", I1, TAG_LIVE_GAME_STAT_PLAYER);
} }

View File

@@ -96,11 +96,11 @@ xml_loadsave_misc_text (GMarkupParseContext *context,
int_value = (gint)g_ascii_strtod(buf, NULL); int_value = (gint)g_ascii_strtod(buf, NULL);
if(state == TAG_NAME) if(state == TAG_NAME)
g_string_printf(country.name, "%s", buf); misc_string_assign(&country.name, buf);
else if(state == TAG_SYMBOL) else if(state == TAG_SYMBOL)
g_string_printf(country.symbol, "%s", buf); misc_string_assign(&country.symbol, buf);
else if(state == TAG_SID) else if(state == TAG_SID)
g_string_printf(country.sid, "%s", buf); misc_string_assign(&country.sid, buf);
else if(state == TAG_MISC_SEASON) else if(state == TAG_MISC_SEASON)
season = int_value; season = int_value;
else if(state == TAG_MISC_WEEK) else if(state == TAG_MISC_WEEK)
@@ -168,9 +168,9 @@ xml_loadsave_misc_write(const gchar *prefix)
fprintf(fil, "<_%d>\n", TAG_MISC); fprintf(fil, "<_%d>\n", TAG_MISC);
xml_write_g_string(fil, country.name, TAG_NAME, I0); xml_write_string(fil, country.name, TAG_NAME, I0);
xml_write_g_string(fil, country.symbol, TAG_SYMBOL, I0); xml_write_string(fil, country.symbol, TAG_SYMBOL, I0);
xml_write_g_string(fil, country.sid, TAG_SID, I0); xml_write_string(fil, country.sid, TAG_SID, I0);
xml_write_int(fil, season, TAG_MISC_SEASON, I0); xml_write_int(fil, season, TAG_MISC_SEASON, I0);
xml_write_int(fil, week, TAG_MISC_WEEK, I0); xml_write_int(fil, week, TAG_MISC_WEEK, I0);
xml_write_int(fil, week_round, TAG_MISC_WEEK_ROUND, I0); xml_write_int(fil, week_round, TAG_MISC_WEEK_ROUND, I0);

View File

@@ -1,3 +1,4 @@
#include "misc.h"
#include "player.h" #include "player.h"
#include "team.h" #include "team.h"
#include "xml.h" #include "xml.h"
@@ -138,7 +139,7 @@ xml_loadsave_players_text(gchar *text)
float_value = (gfloat)g_ascii_strtod(text, NULL) / 10000; float_value = (gfloat)g_ascii_strtod(text, NULL) / 10000;
if(state == TAG_PLAYER_NAME) if(state == TAG_PLAYER_NAME)
g_string_printf(new_player.name, "%s", text); misc_string_assign(&new_player.name, text);
else if(state == TAG_PLAYER_POS) else if(state == TAG_PLAYER_POS)
new_player.pos = int_value; new_player.pos = int_value;
else if(state == TAG_PLAYER_CPOS) else if(state == TAG_PLAYER_CPOS)
@@ -221,7 +222,7 @@ xml_loadsave_players_write_player(FILE *fil, const Player *pl)
fprintf(fil, "%s<_%d>\n", I1, TAG_PLAYER); fprintf(fil, "%s<_%d>\n", I1, TAG_PLAYER);
xml_write_g_string(fil, pl->name, TAG_PLAYER_NAME, I2); xml_write_string(fil, pl->name, TAG_PLAYER_NAME, I2);
xml_write_int(fil, pl->pos, TAG_PLAYER_POS, I2); xml_write_int(fil, pl->pos, TAG_PLAYER_POS, I2);
xml_write_int(fil, pl->cpos, TAG_PLAYER_CPOS, I2); xml_write_int(fil, pl->cpos, TAG_PLAYER_CPOS, I2);
xml_write_int(fil, pl->health, TAG_PLAYER_HEALTH, I2); xml_write_int(fil, pl->health, TAG_PLAYER_HEALTH, I2);

View File

@@ -119,9 +119,9 @@ xml_loadsave_season_stats_text (GMarkupParseContext *context,
if(state == TAG_SEASON_NUMBER) if(state == TAG_SEASON_NUMBER)
new_season_stat.season_number = int_value; new_season_stat.season_number = int_value;
else if(state == TAG_CHAMP_STAT_TEAM_NAME) else if(state == TAG_CHAMP_STAT_TEAM_NAME)
new_champ_stat.team_name = g_string_new(buf); new_champ_stat.team_name = g_strdup(buf);
else if(state == TAG_CHAMP_STAT_CL_NAME) else if(state == TAG_CHAMP_STAT_CL_NAME)
new_champ_stat.cl_name = g_string_new(buf); new_champ_stat.cl_name = g_strdup(buf);
else if(state == TAG_LEAGUE_STAT_FILE) else if(state == TAG_LEAGUE_STAT_FILE)
{ {
new_league_stat = stat_league_new(-1); new_league_stat = stat_league_new(-1);
@@ -195,12 +195,12 @@ xml_loadsave_season_stats_write(const gchar *prefix)
for(j=0;j<g_array_index(season_stats, SeasonStat, i).league_champs->len;j++) for(j=0;j<g_array_index(season_stats, SeasonStat, i).league_champs->len;j++)
{ {
fprintf(fil, "%s<_%d>\n", I2, TAG_CHAMP_STAT); fprintf(fil, "%s<_%d>\n", I2, TAG_CHAMP_STAT);
xml_write_g_string(fil, xml_write_string(fil,
g_array_index( g_array_index(
g_array_index( g_array_index(
season_stats, SeasonStat, i).league_champs, ChampStat, j).team_name, season_stats, SeasonStat, i).league_champs, ChampStat, j).team_name,
TAG_CHAMP_STAT_TEAM_NAME, I2); TAG_CHAMP_STAT_TEAM_NAME, I2);
xml_write_g_string(fil, xml_write_string(fil,
g_array_index( g_array_index(
g_array_index( g_array_index(
season_stats, SeasonStat, i).league_champs, ChampStat, j).cl_name, season_stats, SeasonStat, i).league_champs, ChampStat, j).cl_name,
@@ -214,11 +214,11 @@ xml_loadsave_season_stats_write(const gchar *prefix)
for(j=0;j<g_array_index(season_stats, SeasonStat, i).cup_champs->len;j++) for(j=0;j<g_array_index(season_stats, SeasonStat, i).cup_champs->len;j++)
{ {
fprintf(fil, "%s<_%d>\n", I2, TAG_CHAMP_STAT); fprintf(fil, "%s<_%d>\n", I2, TAG_CHAMP_STAT);
xml_write_g_string(fil, g_array_index( xml_write_string(fil, g_array_index(
g_array_index( g_array_index(
season_stats, SeasonStat, i).cup_champs, ChampStat, j).team_name, season_stats, SeasonStat, i).cup_champs, ChampStat, j).team_name,
TAG_CHAMP_STAT_TEAM_NAME, I2); TAG_CHAMP_STAT_TEAM_NAME, I2);
xml_write_g_string(fil, g_array_index( xml_write_string(fil, g_array_index(
g_array_index( g_array_index(
season_stats, SeasonStat, i).cup_champs, ChampStat, j).cl_name, season_stats, SeasonStat, i).cup_champs, ChampStat, j).cl_name,
TAG_CHAMP_STAT_CL_NAME, I2); TAG_CHAMP_STAT_CL_NAME, I2);

View File

@@ -97,7 +97,7 @@ xml_loadsave_table_text (GMarkupParseContext *context,
int_value = (gint)g_ascii_strtod(buf, NULL); int_value = (gint)g_ascii_strtod(buf, NULL);
if(state == TAG_NAME) if(state == TAG_NAME)
g_string_printf(new_table->name, "%s", buf); misc_string_assign(&new_table->name, buf);
else if(state == TAG_ID) else if(state == TAG_ID)
new_table->clid = int_value; new_table->clid = int_value;
else if(state == TAG_ROUND) else if(state == TAG_ROUND)
@@ -158,7 +158,7 @@ xml_loadsave_table_write(const gchar *filename, const Table *table)
fprintf(fil, "<_%d>\n", TAG_TABLE); fprintf(fil, "<_%d>\n", TAG_TABLE);
xml_write_g_string(fil, table->name, TAG_NAME, I0); xml_write_string(fil, table->name, TAG_NAME, I0);
xml_write_int(fil, table->clid, TAG_ID, I0); xml_write_int(fil, table->clid, TAG_ID, I0);
xml_write_int(fil, table->round, TAG_ROUND, I0); xml_write_int(fil, table->round, TAG_ROUND, I0);

View File

@@ -131,11 +131,11 @@ xml_loadsave_teams_text (GMarkupParseContext *context,
float_value = (gfloat)g_ascii_strtod(buf, NULL) / 10000; float_value = (gfloat)g_ascii_strtod(buf, NULL) / 10000;
if(state == TAG_NAME) if(state == TAG_NAME)
g_string_printf(new_team.name, "%s", buf); misc_string_assign(&new_team.name, buf);
else if(state == TAG_SYMBOL) else if(state == TAG_SYMBOL)
g_string_printf(new_team.symbol, "%s", buf); misc_string_assign(&new_team.symbol, buf);
else if(state == TAG_TEAM_NAMES_FILE) else if(state == TAG_TEAM_NAMES_FILE)
g_string_printf(new_team.names_file, buf); misc_string_assign(&new_team.names_file, buf);
else if(state == TAG_TEAM_CLID) else if(state == TAG_TEAM_CLID)
new_team.clid = int_value; new_team.clid = int_value;
else if(state == TAG_TEAM_ID) else if(state == TAG_TEAM_ID)
@@ -147,7 +147,7 @@ xml_loadsave_teams_text (GMarkupParseContext *context,
else if(state == TAG_TEAM_BOOST) else if(state == TAG_TEAM_BOOST)
new_team.boost = int_value; new_team.boost = int_value;
else if(state == TAG_TEAM_STADIUM_NAME) else if(state == TAG_TEAM_STADIUM_NAME)
new_team.stadium.name = g_string_new(buf); misc_string_assign(&new_team.stadium.name, buf);
else if(state == TAG_TEAM_STADIUM_CAPACITY) else if(state == TAG_TEAM_STADIUM_CAPACITY)
new_team.stadium.capacity = int_value; new_team.stadium.capacity = int_value;
else if(state == TAG_TEAM_STADIUM_AVERAGE_ATTENDANCE) else if(state == TAG_TEAM_STADIUM_AVERAGE_ATTENDANCE)
@@ -225,9 +225,9 @@ xml_loadsave_teams_write_team(FILE *fil, const Team* team)
{ {
fprintf(fil, "<_%d>\n", TAG_TEAM); fprintf(fil, "<_%d>\n", TAG_TEAM);
xml_write_g_string(fil, team->name, TAG_NAME, I1); xml_write_string(fil, team->name, TAG_NAME, I1);
xml_write_g_string(fil, team->symbol, TAG_SYMBOL, I1); xml_write_string(fil, team->symbol, TAG_SYMBOL, I1);
xml_write_g_string(fil, team->names_file, TAG_TEAM_NAMES_FILE, I1); xml_write_string(fil, team->names_file, TAG_TEAM_NAMES_FILE, I1);
xml_write_int(fil, team->clid, TAG_TEAM_CLID, I1); xml_write_int(fil, team->clid, TAG_TEAM_CLID, I1);
xml_write_int(fil, team->id, TAG_TEAM_ID, I1); xml_write_int(fil, team->id, TAG_TEAM_ID, I1);
@@ -238,7 +238,7 @@ xml_loadsave_teams_write_team(FILE *fil, const Team* team)
fprintf(fil, "%s<_%d>\n", I1, TAG_TEAM_STADIUM); fprintf(fil, "%s<_%d>\n", I1, TAG_TEAM_STADIUM);
if(team->stadium.name != NULL) if(team->stadium.name != NULL)
xml_write_g_string(fil, team->stadium.name, TAG_TEAM_STADIUM_NAME, I2); xml_write_string(fil, team->stadium.name, TAG_TEAM_STADIUM_NAME, I2);
xml_write_int(fil, team->stadium.capacity, TAG_TEAM_STADIUM_CAPACITY, I2); xml_write_int(fil, team->stadium.capacity, TAG_TEAM_STADIUM_CAPACITY, I2);
xml_write_int(fil, team->stadium.average_attendance, TAG_TEAM_STADIUM_AVERAGE_ATTENDANCE, I2); xml_write_int(fil, team->stadium.average_attendance, TAG_TEAM_STADIUM_AVERAGE_ATTENDANCE, I2);

View File

@@ -97,6 +97,11 @@ xml_loadsave_users_start_element (GMarkupParseContext *context,
state == TAG_USER_MONEY_INS) state == TAG_USER_MONEY_INS)
idx = 0; idx = 0;
if(tag == TAG_USER_HISTORY)
new_history.value_string = NULL;
else if(tag == TAG_USER_EVENT)
new_event.value_string = NULL;
if(!valid_tag) if(!valid_tag)
g_warning("xml_loadsave_users_start_element: unknown tag: %s; I'm in state %d\n", g_warning("xml_loadsave_users_start_element: unknown tag: %s; I'm in state %d\n",
element_name, state); element_name, state);
@@ -199,7 +204,7 @@ xml_loadsave_users_text (GMarkupParseContext *context,
float_value = (gfloat)g_ascii_strtod(text, NULL) / 10000; float_value = (gfloat)g_ascii_strtod(text, NULL) / 10000;
if(state == TAG_NAME) if(state == TAG_NAME)
g_string_printf(new_user.name, "%s", buf); misc_string_assign(&new_user.name, buf);
else if(state == TAG_TEAM_ID) else if(state == TAG_TEAM_ID)
{ {
new_user.tm = team_of_id(int_value); new_user.tm = team_of_id(int_value);
@@ -242,7 +247,7 @@ xml_loadsave_users_text (GMarkupParseContext *context,
else if(state == TAG_USER_HISTORY_VALUE2) else if(state == TAG_USER_HISTORY_VALUE2)
new_history.value2 = int_value; new_history.value2 = int_value;
else if(state == TAG_USER_HISTORY_VALUE_STRING) else if(state == TAG_USER_HISTORY_VALUE_STRING)
new_history.value_string = g_string_new(buf); misc_string_assign(&new_history.value_string, buf);
else if(state == TAG_USER_EVENT_TYPE) else if(state == TAG_USER_EVENT_TYPE)
new_event.type = int_value; new_event.type = int_value;
else if(state == TAG_USER_EVENT_VALUE1) else if(state == TAG_USER_EVENT_VALUE1)
@@ -250,7 +255,7 @@ xml_loadsave_users_text (GMarkupParseContext *context,
else if(state == TAG_USER_EVENT_VALUE2) else if(state == TAG_USER_EVENT_VALUE2)
new_event.value2 = int_value; new_event.value2 = int_value;
else if(state == TAG_USER_EVENT_VALUE_STRING) else if(state == TAG_USER_EVENT_VALUE_STRING)
new_event.value_string = g_string_new(buf); misc_string_assign(&new_event.value_string, buf);
else if(state == TAG_USER_YA_COACH) else if(state == TAG_USER_YA_COACH)
new_user.youth_academy.coach = int_value; new_user.youth_academy.coach = int_value;
else if(state == TAG_USER_YA_PERCENTAGE) else if(state == TAG_USER_YA_PERCENTAGE)
@@ -326,7 +331,7 @@ xml_loadsave_users_write(const gchar *prefix)
{ {
fprintf(fil, "<_%d>\n", TAG_USER); fprintf(fil, "<_%d>\n", TAG_USER);
xml_write_g_string(fil, usr(i).name, TAG_NAME, I1); xml_write_string(fil, usr(i).name, TAG_NAME, I1);
xml_write_int(fil, usr(i).team_id, TAG_TEAM_ID, I1); xml_write_int(fil, usr(i).team_id, TAG_TEAM_ID, I1);
xml_write_int(fil, usr(i).money, TAG_USER_MONEY, I1); xml_write_int(fil, usr(i).money, TAG_USER_MONEY, I1);
xml_write_int(fil, usr(i).debt, TAG_USER_DEBT, I1); xml_write_int(fil, usr(i).debt, TAG_USER_DEBT, I1);
@@ -374,7 +379,7 @@ xml_loadsave_users_write(const gchar *prefix)
TAG_USER_HISTORY_VALUE1, I2); TAG_USER_HISTORY_VALUE1, I2);
xml_write_int(fil, g_array_index(usr(i).history, UserHistory, j).value2, xml_write_int(fil, g_array_index(usr(i).history, UserHistory, j).value2,
TAG_USER_HISTORY_VALUE2, I2); TAG_USER_HISTORY_VALUE2, I2);
xml_write_g_string(fil, g_array_index(usr(i).history, UserHistory, j).value_string, xml_write_string(fil, g_array_index(usr(i).history, UserHistory, j).value_string,
TAG_USER_HISTORY_VALUE_STRING, I2); TAG_USER_HISTORY_VALUE_STRING, I2);
fprintf(fil, "%s</_%d>\n", I1, TAG_USER_HISTORY); fprintf(fil, "%s</_%d>\n", I1, TAG_USER_HISTORY);
@@ -390,7 +395,7 @@ xml_loadsave_users_write(const gchar *prefix)
TAG_USER_EVENT_VALUE1, I2); TAG_USER_EVENT_VALUE1, I2);
xml_write_int(fil, g_array_index(usr(i).events, Event, j).value2, xml_write_int(fil, g_array_index(usr(i).events, Event, j).value2,
TAG_USER_EVENT_VALUE2, I2); TAG_USER_EVENT_VALUE2, I2);
xml_write_g_string(fil, g_array_index(usr(i).events, Event, j).value_string, xml_write_string(fil, g_array_index(usr(i).events, Event, j).value_string,
TAG_USER_EVENT_VALUE_STRING, I2); TAG_USER_EVENT_VALUE_STRING, I2);
fprintf(fil, "%s</_%d>\n", I1, TAG_USER_EVENT); fprintf(fil, "%s</_%d>\n", I1, TAG_USER_EVENT);

View File

@@ -46,6 +46,9 @@ xml_mmatches_start_element (GMarkupParseContext *context,
valid_tag = TRUE; valid_tag = TRUE;
} }
if(tag == TAG_MMATCH)
new_match.country_name = NULL;
if(!valid_tag) if(!valid_tag)
g_warning("xml_loadsave_mmatches_start_element: unknown tag: %s; I'm in state %d\n", g_warning("xml_loadsave_mmatches_start_element: unknown tag: %s; I'm in state %d\n",
element_name, state); element_name, state);
@@ -93,7 +96,7 @@ xml_mmatches_text (GMarkupParseContext *context,
if(state == TAG_MMATCHES_COMP_NAME) if(state == TAG_MMATCHES_COMP_NAME)
new_match.competition_name = g_string_new(buf); new_match.competition_name = g_string_new(buf);
else if(state == TAG_MMATCHES_COUNTRY_NAME) else if(state == TAG_MMATCHES_COUNTRY_NAME)
new_match.country_name = g_string_new(buf); misc_string_assign(&new_match.country_name, buf);
else if(state == TAG_MMATCHES_NEUTRAL) else if(state == TAG_MMATCHES_NEUTRAL)
new_match.neutral = int_value; new_match.neutral = int_value;
else if(state == TAG_MMATCHES_USER_TEAM) else if(state == TAG_MMATCHES_USER_TEAM)
@@ -166,7 +169,7 @@ xml_mmatches_write(const gchar *prefix, const GArray *mmatches)
xml_write_g_string(fil, xml_write_g_string(fil,
g_array_index(mmatches, MemMatch, i).competition_name, g_array_index(mmatches, MemMatch, i).competition_name,
TAG_MMATCHES_COMP_NAME, I1); TAG_MMATCHES_COMP_NAME, I1);
xml_write_g_string(fil, xml_write_string(fil,
g_array_index(mmatches, MemMatch, i).country_name, g_array_index(mmatches, MemMatch, i).country_name,
TAG_MMATCHES_COUNTRY_NAME, I1); TAG_MMATCHES_COUNTRY_NAME, I1);
xml_write_int(fil, xml_write_int(fil,

View File

@@ -66,17 +66,14 @@ xml_name_read_text (GMarkupParseContext *context,
GError **error) GError **error)
{ {
gchar buf[text_len + 1]; gchar buf[text_len + 1];
GString *new_name = NULL;
strncpy(buf, text, text_len); strncpy(buf, text, text_len);
buf[text_len] = '\0'; buf[text_len] = '\0';
new_name = g_string_new(buf);
if(state == STATE_FIRST_NAME) if(state == STATE_FIRST_NAME)
g_ptr_array_add(nlist->first_names, new_name); g_ptr_array_add(nlist->first_names, g_strdup(buf));
else if(state == STATE_LAST_NAME) else if(state == STATE_LAST_NAME)
g_ptr_array_add(nlist->last_names, new_name); g_ptr_array_add(nlist->last_names, g_strdup(buf));
} }
/** Fill the name list with names from the /** Fill the name list with names from the
@@ -110,7 +107,7 @@ xml_name_read(const gchar *sid, NameList *namelist)
} }
free_name_list(namelist, TRUE); free_name_list(namelist, TRUE);
g_string_assign(namelist->sid, sid); misc_string_assign(&namelist->sid, sid);
nlist = namelist; nlist = namelist;

View File

@@ -166,23 +166,23 @@ xml_team_read_text (GMarkupParseContext *context,
float_value = (gfloat)g_ascii_strtod(buf, NULL); float_value = (gfloat)g_ascii_strtod(buf, NULL);
if(state == STATE_TEAM_NAME) if(state == STATE_TEAM_NAME)
g_string_printf(team->name, "%s", buf); misc_string_assign(&team->name, buf);
else if(state == STATE_STADIUM_NAME) else if(state == STATE_STADIUM_NAME)
{ {
free_g_string(&team->stadium.name); g_free(team->stadium.name);
team->stadium.name = g_string_new(buf); misc_string_assign(&team->stadium.name, buf);
} }
else if(state == STATE_SYMBOL) else if(state == STATE_SYMBOL)
g_string_printf(team->symbol, "%s", buf); misc_string_assign(&team->symbol, buf);
else if(state == STATE_AVERAGE_TALENT && opt_int("int_opt_load_defs") == 1) else if(state == STATE_AVERAGE_TALENT && opt_int("int_opt_load_defs") == 1)
team->average_talent = team->average_talent =
(float_value / 10000) * const_float("float_player_max_skill"); (float_value / 10000) * const_float("float_player_max_skill");
else if(state == STATE_FORMATION) else if(state == STATE_FORMATION)
team->structure = int_value; team->structure = int_value;
else if(state == STATE_NAMES_FILE) else if(state == STATE_NAMES_FILE)
g_string_printf(team->names_file, "%s", buf); misc_string_assign(&team->names_file, buf);
else if(state == STATE_PLAYER_NAME) else if(state == STATE_PLAYER_NAME)
g_string_printf(new_player.name, "%s", buf); misc_string_assign(&new_player.name, buf);
else if(state == STATE_PLAYER_BIRTH_YEAR && opt_int("int_opt_load_defs") == 1) else if(state == STATE_PLAYER_BIRTH_YEAR && opt_int("int_opt_load_defs") == 1)
birth_year = int_value; birth_year = int_value;
else if(state == STATE_PLAYER_BIRTH_MONTH && opt_int("int_opt_load_defs") == 1) else if(state == STATE_PLAYER_BIRTH_MONTH && opt_int("int_opt_load_defs") == 1)

View File

@@ -53,7 +53,7 @@ youth_academy_add_new_player(YouthAcademy *youth_academy)
gfloat percentage_coach_talent_factor; gfloat percentage_coach_talent_factor;
Player new; Player new;
new.name = name_get(youth_academy->tm->names_file->str); new.name = name_get(youth_academy->tm->names_file);
new.id = player_id_new; new.id = player_id_new;
@@ -170,12 +170,12 @@ youth_academy_update_weekly(void)
g_array_index(ya->players, Player, j).age + 0.08 <= g_array_index(ya->players, Player, j).age + 0.08 <=
const_float("float_player_age_lower")) const_float("float_player_age_lower"))
user_event_add(&usr(i), EVENT_TYPE_WARNING, -1, -1, NULL, user_event_add(&usr(i), EVENT_TYPE_WARNING, -1, -1, NULL,
_("Youth %s will be too old for the youth academy soon. Move him to your team or kick him out of the academy. Otherwise he'll probably look for another team to play in."), g_array_index(ya->players, Player, j).name->str); _("Youth %s will be too old for the youth academy soon. Move him to your team or kick him out of the academy. Otherwise he'll probably look for another team to play in."), g_array_index(ya->players, Player, j).name);
else if(g_array_index(ya->players, Player, j).age > const_float("float_player_age_lower")) else if(g_array_index(ya->players, Player, j).age > const_float("float_player_age_lower"))
{ {
user_event_add(&usr(i), EVENT_TYPE_WARNING, -1, -1, NULL, user_event_add(&usr(i), EVENT_TYPE_WARNING, -1, -1, NULL,
_("Youth %s thought he's old enough for a real contract and left your youth academy."), _("Youth %s thought he's old enough for a real contract and left your youth academy."),
g_array_index(ya->players, Player, j).name->str); g_array_index(ya->players, Player, j).name);
free_player(&g_array_index(ya->players, Player, j)); free_player(&g_array_index(ya->players, Player, j));
g_array_remove_index(ya->players, j); g_array_remove_index(ya->players, j);
} }