Index: client/climisc.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/climisc.c,v retrieving revision 1.97 diff -u -r1.97 climisc.c --- client/climisc.c 2002/05/25 17:44:06 1.97 +++ client/climisc.c 2002/06/10 14:26:58 @@ -301,6 +301,7 @@ bool fr_is_unit = cid_is_unit(x), to_is_unit = cid_is_unit(y); struct packet_city_request packet; char buf[512]; + int last_request_id = 0; my_snprintf(buf, sizeof(buf), _("Game: Changing production of every %s into %s."), @@ -310,6 +311,7 @@ name : get_improvement_name(to_id)); append_output_window(buf); + connection_do_buffer(&aconnection); city_list_iterate (game.player_ptr->cities, pcity) { if (((fr_is_unit && (pcity->is_building_unit) && @@ -325,11 +327,13 @@ packet.city_id = pcity->id; packet.build_id = to_id; packet.is_build_id_unit_id = to_is_unit; - send_packet_city_request (&aconnection, &packet, - PACKET_CITY_CHANGE); + last_request_id = send_packet_city_request(&aconnection, &packet, + PACKET_CITY_CHANGE); } - } - city_list_iterate_end; + } city_list_iterate_end; + + connection_do_unbuffer(&aconnection); + disable_cityrep_update_till(last_request_id); } /*************************************************************************** Index: client/clinet.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/clinet.c,v retrieving revision 1.71 diff -u -r1.71 clinet.c --- client/clinet.c 2002/05/25 17:44:06 1.71 +++ client/clinet.c 2002/06/10 14:26:59 @@ -100,7 +100,7 @@ popdown_races_dialog(); plrdlg_update_delay_off(); - report_update_delay_off(); + report_dialogs_thaw_all(); meswin_update_delay_off(); set_client_state(CLIENT_PRE_GAME_STATE); Index: client/packhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v retrieving revision 1.239 diff -u -r1.239 packhand.c --- client/packhand.c 2002/06/08 11:31:09 1.239 +++ client/packhand.c 2002/06/10 14:27:00 @@ -70,6 +70,7 @@ static void handle_city_packet_common(struct city *pcity, bool is_new, bool popup, bool investigate); +static int last_request_id_for_city_report = 0; #define TEST_ATTRIBUTES 0 @@ -704,8 +705,7 @@ plrdlg_update_delay_off(); update_players_dialog(); - report_update_delay_off(); - update_report_dialogs(); + report_dialogs_thaw(); meswin_update_delay_off(); update_meswin_dialog(); @@ -727,7 +727,7 @@ { clear_notify_window(); plrdlg_update_delay_on(); - report_update_delay_on(); + report_dialogs_freeze(); meswin_update_delay_on(); /* * The local idea of the game turn is increased here since the @@ -2345,6 +2345,14 @@ aconnection.client.request_id_of_currently_handled_packet = 0; agents_processing_finished(); + + if (last_request_id_for_city_report != 0 + && last_request_id_for_city_report == + aconnection.client.last_processed_request_id_seen) { + report_dialogs_thaw(); + output_window_thaw(); + last_request_id_for_city_report = 0; + } } /************************************************************************** @@ -2370,4 +2378,17 @@ packet_type, size, request_id); assert(request_id); +} + +/************************************************************************** + Disable the updating the city report dialog till the answer + (PACKET_PROCESSING_FINISHED) of the given request is received. +**************************************************************************/ +void disable_cityrep_update_till(int request_id) +{ + if (request_id != 0) { + report_dialogs_freeze(); + output_window_freeze(); + last_request_id_for_city_report = request_id; + } } Index: client/packhand.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/packhand.h,v retrieving revision 1.25 diff -u -r1.25 packhand.h --- client/packhand.h 2002/03/21 20:35:24 1.25 +++ client/packhand.h 2002/06/10 14:27:00 @@ -68,4 +68,5 @@ void notify_about_outgoing_packet(struct connection *pc, int packet_type, int size, int request_id); +void disable_cityrep_update_till(int request_id); #endif /* FC__PACKHAND_H */ Index: client/agents/cma_core.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_core.c,v retrieving revision 1.24 diff -u -r1.24 cma_core.c --- client/agents/cma_core.c 2002/06/09 15:10:11 1.24 +++ client/agents/cma_core.c 2002/06/10 14:27:02 @@ -710,6 +710,7 @@ &packet); stats.refresh_forced++; } + disable_cityrep_update_till(last_request_id); connection_do_unbuffer(&aconnection); Index: client/gui-gtk/chatline.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/chatline.c,v retrieving revision 1.16 diff -u -r1.16 chatline.c --- client/gui-gtk/chatline.c 2002/05/23 09:13:04 1.16 +++ client/gui-gtk/chatline.c 2002/06/10 14:27:02 @@ -32,8 +32,9 @@ struct genlist history_list; int history_pos; +static bool frozen_level = 0; +static char *remaining_str = NULL; - /************************************************************************** ... **************************************************************************/ @@ -63,16 +64,50 @@ gtk_entry_set_text(GTK_ENTRY(w), ""); } +void output_window_freeze() +{ + frozen_level++; + + if (frozen_level == 1) { + assert(remaining_str == NULL); + remaining_str = fc_malloc(1); + remaining_str[0] = '\0'; + } +} + +void output_window_thaw() +{ + frozen_level--; + assert(frozen_level >= 0); + + if (frozen_level == 0) { + if (strlen(remaining_str) > 1) { + append_output_window(remaining_str + 1); + } + free(remaining_str); + remaining_str = NULL; + } +} + /************************************************************************** ... **************************************************************************/ void append_output_window(char *astring) { - gtk_text_freeze(GTK_TEXT(main_message_area)); - gtk_text_insert(GTK_TEXT(main_message_area), NULL, NULL, NULL, "\n", -1); - gtk_text_insert(GTK_TEXT(main_message_area), NULL, NULL, NULL, astring, -1); - gtk_text_thaw(GTK_TEXT(main_message_area)); - + if (frozen_level == 0) { + gtk_text_freeze(GTK_TEXT(main_message_area)); + gtk_text_insert(GTK_TEXT(main_message_area), NULL, NULL, NULL, "\n", -1); + gtk_text_insert(GTK_TEXT(main_message_area), NULL, NULL, NULL, astring, + -1); + gtk_text_thaw(GTK_TEXT(main_message_area)); + } else { + remaining_str = + fc_realloc(remaining_str, + strlen(remaining_str) + 1 + 1 + strlen(astring)); + strcat(remaining_str, "\n"); + strcat(remaining_str, astring); + } + /* move the scrollbar forward by a ridiculous amount */ gtk_range_default_vmotion(GTK_RANGE(text_scrollbar), 0, 10000); } Index: client/gui-gtk/cityrep.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/cityrep.c,v retrieving revision 1.58 diff -u -r1.58 cityrep.c --- client/gui-gtk/cityrep.c 2002/04/09 15:16:20 1.58 +++ client/gui-gtk/cityrep.c 2002/06/10 14:27:03 @@ -27,6 +27,7 @@ #include "city.h" #include "fcintl.h" #include "game.h" +#include "log.h" #include "packets.h" #include "shared.h" #include "support.h" @@ -39,6 +40,7 @@ #include "gui_main.h" #include "gui_stuff.h" #include "mapview.h" +#include "packhand.h" #include "optiondlg.h" #include "options.h" #include "repodlgs.h" @@ -261,20 +263,24 @@ else { bool is_unit = cid_is_unit(cid); - int id = cid_id(cid); + int last_request_id = 0, id = cid_id(cid); GList* selection = GTK_CLIST(city_list)->selection; g_assert(selection); - - for(; selection; selection = g_list_next(selection)) - { - struct packet_city_request packet; - packet.city_id=city_from_glist(selection)->id; - packet.build_id=id; - packet.is_build_id_unit_id=is_unit; - send_packet_city_request(&aconnection, &packet, PACKET_CITY_CHANGE); - } + connection_do_buffer(&aconnection); + for (; selection; selection = g_list_next(selection)) { + struct packet_city_request packet; + + packet.city_id = city_from_glist(selection)->id; + packet.build_id = id; + packet.is_build_id_unit_id = is_unit; + last_request_id = send_packet_city_request(&aconnection, &packet, + PACKET_CITY_CHANGE); + } + + connection_do_unbuffer(&aconnection); + disable_cityrep_update_till(last_request_id); } } @@ -383,6 +389,9 @@ copy = g_list_append(copy, city_from_glist(selection)); } + report_dialogs_freeze(); + output_window_freeze(); + for (; copy; copy = g_list_next(copy)) { struct city *pcity = copy->data; @@ -391,8 +400,10 @@ } else { cma_put_city_under_agent(pcity, cmafec_preset_get_parameter(index)); } - refresh_city_dialog(pcity); + refresh_city_dialog(pcity); } + report_dialogs_thaw(); + output_window_thaw(); g_list_free(copy); } Index: client/gui-gtk/repodlgs.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/repodlgs.c,v retrieving revision 1.57 diff -u -r1.57 repodlgs.c --- client/gui-gtk/repodlgs.c 2002/04/09 15:16:22 1.57 +++ client/gui-gtk/repodlgs.c 2002/06/10 14:27:05 @@ -89,22 +89,39 @@ static int activeunits_dialog_shell_is_modal; /******************************************************************/ -int delay_report_update=0; +bool delay_report_update = FALSE; +static int frozen_level = 0; /****************************************************************** Turn off updating of reports *******************************************************************/ -void report_update_delay_on(void) +void report_dialogs_freeze(void) { - delay_report_update=1; + frozen_level++; + delay_report_update = TRUE; } /****************************************************************** Turn on updating of reports *******************************************************************/ -void report_update_delay_off(void) +void report_dialogs_thaw(void) { - delay_report_update=0; + frozen_level--; + assert(frozen_level >= 0); + if (frozen_level == 0) { + delay_report_update = FALSE; + update_report_dialogs(); + } +} + +/****************************************************************** + Turn on updating of reports +*******************************************************************/ +void report_dialogs_thaw_all(void) +{ + frozen_level = 0; + delay_report_update = FALSE; + update_report_dialogs(); } /****************************************************************** Index: client/gui-gtk/repodlgs.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/repodlgs.h,v retrieving revision 1.5 diff -u -r1.5 repodlgs.h --- client/gui-gtk/repodlgs.h 2001/01/29 18:55:30 1.5 +++ client/gui-gtk/repodlgs.h 2002/06/10 14:27:05 @@ -15,6 +15,6 @@ #include "repodlgs_g.h" -extern int delay_report_update; +extern bool delay_report_update; #endif /* FC__REPODLGS_H */ Index: client/gui-gtk-2.0/cityrep.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/cityrep.c,v retrieving revision 1.16 diff -u -r1.16 cityrep.c --- client/gui-gtk-2.0/cityrep.c 2002/06/09 23:20:09 1.16 +++ client/gui-gtk-2.0/cityrep.c 2002/06/10 14:27:06 @@ -294,8 +294,10 @@ packet.build_id = id; packet.is_build_id_unit_id = is_unit; + connection_do_buffer(&aconnection); gtk_tree_selection_selected_foreach(city_selection, impr_or_unit_iterate, &packet); + connection_do_unbuffer(&aconnection); } } Index: client/gui-win32/cityrep.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/cityrep.c,v retrieving revision 1.10 diff -u -r1.10 cityrep.c --- client/gui-win32/cityrep.c 2002/05/08 10:30:19 1.10 +++ client/gui-win32/cityrep.c 2002/06/10 14:27:07 @@ -502,8 +502,7 @@ static void cityrep_change_menu(HWND hWnd, cid cid) { int cityids[256]; - int selcount; - int i; + int selcount, i, last_request_id = 0; struct city *pcity; bool is_unit = cid_is_unit(cid); int number = cid_id(cid); @@ -513,18 +512,23 @@ selcount=MIN(256,selcount); selcount=ListBox_GetSelItems(GetDlgItem(hWnd,ID_CITYREP_LIST), selcount,&cityids[0]); - for (i=0;iid; - packet.build_id=number; - packet.is_build_id_unit_id=is_unit; - send_packet_city_request(&aconnection, &packet, PACKET_CITY_CHANGE); - ListBox_SetSel(GetDlgItem(hWnd,ID_CITYREP_LIST),FALSE,cityids[i]); - } + + connection_do_buffer(&aconnection); + for (i = 0; i < selcount; i++) { + struct packet_city_request packet; + pcity = (struct city *) ListBox_GetItemData(GetDlgItem(hWnd, + ID_CITYREP_LIST), + cityids[i]); + packet.city_id = pcity->id; + packet.build_id = number; + packet.is_build_id_unit_id = is_unit; + last_request_id = + send_packet_city_request(&aconnection, &packet, PACKET_CITY_CHANGE); + ListBox_SetSel(GetDlgItem(hWnd, ID_CITYREP_LIST), FALSE, cityids[i]); + } + + connection_do_unbuffer(&aconnection); + disable_cityrep_update_till(last_request_id); } /************************************************************************** Index: client/include/chatline_g.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/include/chatline_g.h,v retrieving revision 1.1 diff -u -r1.1 chatline_g.h --- client/include/chatline_g.h 1999/07/14 11:15:52 1.1 +++ client/include/chatline_g.h 2002/06/10 14:27:07 @@ -16,5 +16,7 @@ void append_output_window(char *astring); void log_output_window(void); void clear_output_window(void); +void output_window_freeze(void); +void output_window_thaw(void); #endif /* FC__CHATLINE_G_H */ Index: client/include/repodlgs_g.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/include/repodlgs_g.h,v retrieving revision 1.4 diff -u -r1.4 repodlgs_g.h --- client/include/repodlgs_g.h 2002/04/12 13:50:56 1.4 +++ client/include/repodlgs_g.h 2002/06/10 14:27:07 @@ -15,8 +15,10 @@ #include "shared.h" /* bool type */ -void report_update_delay_on(void); -void report_update_delay_off(void); +void report_dialogs_freeze(void); +void report_dialogs_thaw(void); +void report_dialogs_thaw_all(void); + char *get_report_title(char *report_name); void update_report_dialogs(void);