1
1
mirror of https://github.com/tstellar/bygfoot.git synced 2024-12-15 09:54:52 +01:00

Minor fixes.

This commit is contained in:
gyboth 2005-04-27 15:50:26 +00:00
parent 273fd4eb5e
commit 5dd786d7d5
7 changed files with 67 additions and 19 deletions

View File

@ -109,17 +109,23 @@ void
load_save_load_game(const gchar* filename)
{
gchar buf[SMALL];
gchar *basename = g_path_get_basename(filename),
*dirname = g_path_get_dirname(filename);
gchar *prefix = g_strndup(basename, strlen(basename) - strlen(const_str("string_save_suffix")));
gchar *fullname = (g_str_has_suffix(filename, const_str("string_save_suffix"))) ?
g_strdup(filename) :
g_strdup_printf("%s%s", filename, const_str("string_save_suffix"));
gchar *basename = g_path_get_basename(fullname),
*dirname = g_path_get_dirname(fullname);
gchar *prefix = (g_str_has_suffix(basename, const_str("string_save_suffix"))) ?
g_strndup(basename, strlen(basename) - strlen(const_str("string_save_suffix"))) :
g_strdup(basename);
gtk_widget_hide(window.main);
if(strcmp(basename, "last_save") == 0)
if(strcmp(filename, "last_save") == 0)
{
g_free(basename);
g_free(dirname);
g_free(prefix);
g_free(fullname);
basename = load_save_last_save_get();
@ -136,7 +142,7 @@ load_save_load_game(const gchar* filename)
gui_show_progress(0, "Uncompressing savegame...");
file_decompress(filename);
file_decompress(fullname);
gui_show_progress(
((PROGRESS_MAX * gtk_progress_bar_get_fraction(
@ -188,13 +194,9 @@ load_save_load_game(const gchar* filename)
sprintf(buf, "rm -rf %s/%s___*", dirname, prefix);
file_my_system(buf);
g_free(basename);
g_free(dirname);
g_free(prefix);
g_string_printf(save_file, "%s", fullname);
g_string_printf(save_file, "%s", filename);
load_save_last_save_set(filename);
load_save_last_save_set(fullname);
gui_show_progress(-1, "");
@ -204,6 +206,11 @@ load_save_load_game(const gchar* filename)
cur_user = 0;
on_button_back_to_main_clicked(NULL, NULL);
g_free(basename);
g_free(dirname);
g_free(prefix);
g_free(fullname);
}
/** Store the name of the last savegame in the users home dir. */

View File

@ -80,7 +80,7 @@ on_button_warning_clicked (GtkWidget *widget,
{
window_destroy(&window.warning, FALSE);
if(stat1 == STATUS_SHOW_EVENT)
if(stat4 == STATUS_SHOW_EVENT)
user_event_show_next();
return FALSE;
@ -140,6 +140,9 @@ on_window_yesno_delete_event (GtkWidget *widget,
{
on_button_yesno_no_clicked(NULL, NULL);
if(stat4 == STATUS_SHOW_EVENT)
user_event_show_next();
return FALSE;
}
@ -181,6 +184,9 @@ on_button_yesno_yes_clicked (GtkButton *button,
main_exit_program(EXIT_OK, NULL);
break;
}
if(stat4 == STATUS_SHOW_EVENT)
user_event_show_next();
}
@ -189,6 +195,9 @@ on_button_yesno_no_clicked (GtkButton *button,
gpointer user_data)
{
window_destroy(&window.yesno, TRUE);
if(stat4 == STATUS_SHOW_EVENT)
user_event_show_next();
}

View File

@ -930,7 +930,8 @@ player_update_weekly(Team *tm, gint idx)
}
if(pl->contract * 12 <= opt_user_int("int_opt_user_contract_limit") &&
(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") &&
debug < 50)
{
sprintf(buf, _("%s's contract expires in %.1f years."),
pl->name->str, pl->contract);

View File

@ -64,14 +64,12 @@ transfer_add_offers(void)
trans(i).offers->len == 0 &&
math_rnd(0, 1) < const_float("float_transfer_offer_prob_max") -
(user_from_team(trans(i).tm)->scout % 10 * const_float("float_transfer_offer_prob_reduce")))
{
transfer_add_offer(i, transfer_team_get_new(),
(gint)rint((gfloat)player_of_id_team(trans(i).tm, trans(i).id)->value *
(1 + math_rnd(
scout_factor_bounds[user_from_team(trans(i).tm)->scout % 10][0],
scout_factor_bounds[user_from_team(trans(i).tm)->scout % 10][1]))),
-1);
}
else if(team_is_user(trans(i).tm) != -1 &&
trans(i).offers->len > 1)
{
@ -153,13 +151,14 @@ transfer_evaluate_offers(void)
{
gint i, j;
gint idx;
gboolean accept = FALSE;
gboolean accept;
for(i=transfer_list->len - 1;i>=0;i--)
{
if(team_is_user(trans(i).tm) == -1)
{
idx = -1;
accept = FALSE;
if(trans(i).offers->len > 1)
g_array_sort(trans(i).offers, transfer_offer_compare_func);

View File

@ -395,7 +395,7 @@ user_event_show_next(void)
if(current_user.events->len == 0)
return;
stat1 = STATUS_SHOW_EVENT;
stat4 = STATUS_SHOW_EVENT;
event = &g_array_index(current_user.events, Event, 0);

View File

@ -13,11 +13,16 @@ enum
TAG_TRANSFER_TIME,
TAG_TRANSFER_FEE,
TAG_TRANSFER_WAGE,
TAG_TRANSFER_OFFER,
TAG_TRANSFER_OFFER_TEAM_ID,
TAG_TRANSFER_OFFER_FEE,
TAG_TRANSFER_OFFER_WAGE,
TAG_END
};
gint state, feeidx, wageidx;
Transfer new_transfer;
TransferOffer new_offer;
void
xml_loadsave_transfers_start_element (GMarkupParseContext *context,
@ -73,6 +78,7 @@ xml_loadsave_transfers_end_element (GMarkupParseContext *context,
tag == TAG_TRANSFER_PLAYER_ID ||
tag == TAG_TRANSFER_TIME ||
tag == TAG_TRANSFER_FEE ||
tag == TAG_TRANSFER_OFFER ||
tag == TAG_TRANSFER_WAGE)
{
state = TAG_TRANSFER;
@ -80,7 +86,13 @@ xml_loadsave_transfers_end_element (GMarkupParseContext *context,
feeidx++;
else if(tag == TAG_TRANSFER_WAGE)
wageidx++;
else if(tag == TAG_TRANSFER_OFFER)
g_array_append_val(new_transfer.offers, new_offer);
}
else if(tag == TAG_TRANSFER_OFFER_WAGE ||
tag == TAG_TRANSFER_OFFER_FEE ||
tag == TAG_TRANSFER_OFFER_TEAM_ID)
state = TAG_TRANSFER_OFFER;
else if(tag != TAG_TRANSFERS)
g_warning("xml_loadsave_transfers_end_element: unknown tag: %s; I'm in state %d\n",
element_name, state);
@ -111,6 +123,12 @@ xml_loadsave_transfers_text (GMarkupParseContext *context,
new_transfer.fee[feeidx] = int_value;
else if(state == TAG_TRANSFER_WAGE)
new_transfer.wage[wageidx] = int_value;
else if(state == TAG_TRANSFER_OFFER_TEAM_ID)
new_offer.tm = team_of_id(int_value);
else if(state == TAG_TRANSFER_OFFER_WAGE)
new_offer.wage = int_value;
else if(state == TAG_TRANSFER_OFFER_FEE)
new_offer.fee = int_value;
}
void
@ -173,7 +191,21 @@ xml_loadsave_transfers_write(const gchar *prefix)
for(j=0;j<QUALITY_END;j++)
xml_write_int(fil, trans(i).wage[j], TAG_TRANSFER_WAGE, I1);
fprintf(fil, "</_%d>\n", TAG_TRANSFER);
for(j=0;j<trans(i).offers->len;j++)
{
fprintf(fil, "%s<_%d>\n", I1, TAG_TRANSFER_OFFER);
xml_write_int(fil, transoff(i, j).tm->id,
TAG_TRANSFER_OFFER_TEAM_ID, I2);
xml_write_int(fil, transoff(i, j).wage,
TAG_TRANSFER_OFFER_WAGE, I2);
xml_write_int(fil, transoff(i, j).fee,
TAG_TRANSFER_OFFER_FEE, I2);
fprintf(fil, "</_%d>\n", TAG_TRANSFER_OFFER);
}
fprintf(fil, "%s</_%d>\n", I1, TAG_TRANSFER);
}
fprintf(fil, "</_%d>\n", TAG_TRANSFERS);

View File

@ -653,7 +653,7 @@ float_transfer_scout_deviance_wage 300
# probability for an offer when a user
# player's on the list
float_transfer_offer_prob_max 5000
float_transfer_offer_prob_max 9000#***5000
# reduce factor (multiplied by the scout value)
float_transfer_offer_prob_reduce 1000