Index: client/civclient.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v retrieving revision 1.141 diff -u -r1.141 civclient.c --- client/civclient.c 2002/07/23 02:48:45 1.141 +++ client/civclient.c 2002/08/07 09:30:55 @@ -443,6 +443,14 @@ handle_start_turn(); break; + case PACKET_OTHER_PROCESSING_STARTED: + handle_other_processing_started(); + break; + + case PACKET_OTHER_PROCESSING_FINISHED: + handle_other_processing_finished(); + break; + default: freelog(LOG_ERROR, "Received unknown packet (type %d) from server!", type); /* Old clients (<= some 1.11.5-devel, capstr +1.11) used to exit() Index: client/climisc.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/climisc.c,v retrieving revision 1.99 diff -u -r1.99 climisc.c --- client/climisc.c 2002/06/27 00:59:10 1.99 +++ client/climisc.c 2002/08/07 09:30:56 @@ -1191,6 +1191,8 @@ **************************************************************************/ void reports_freeze(void) { + freelog(LOG_DEBUG, "reports_freeze"); + meswin_freeze(); plrdlg_freeze(); report_dialogs_freeze(); @@ -1214,6 +1216,8 @@ **************************************************************************/ void reports_thaw(void) { + freelog(LOG_DEBUG, "reports_thaw"); + meswin_thaw(); plrdlg_thaw(); report_dialogs_thaw(); Index: client/packhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v retrieving revision 1.248 diff -u -r1.248 packhand.c --- client/packhand.c 2002/07/29 13:13:38 1.248 +++ client/packhand.c 2002/08/07 09:30:57 @@ -292,8 +292,6 @@ free_intro_radar_sprites(); agents_game_start(); - } else if(get_client_state() == CLIENT_GAME_OVER_STATE) { - reports_thaw(); } } @@ -685,7 +683,6 @@ void handle_before_new_year(void) { clear_notify_window(); - reports_freeze(); /* * The local idea of the game turn is increased here since the * client will get unit updates (reset of move points for example) @@ -703,8 +700,6 @@ **************************************************************************/ void handle_start_turn(void) { - reports_thaw(); - agents_start_turn(); if(game.player_ptr->ai.control && !ai_manual_turn_done) { @@ -1642,8 +1637,6 @@ { int i; - reports_freeze(); - tilespec_free_city_tiles(game.styles_count); ruleset_data_free(); @@ -2355,4 +2348,28 @@ fc_realloc(reports_thaw_requests, reports_thaw_requests_size * sizeof(int)); reports_thaw_requests[reports_thaw_requests_size - 1] = request_id; +} + +/************************************************************************** +... +**************************************************************************/ +void handle_other_processing_started(void) +{ + freelog(LOG_DEBUG, "handle_other_processing_started"); + + reports_freeze(); + + agents_other_processing_started(); +} + +/************************************************************************** +... +**************************************************************************/ +void handle_other_processing_finished(void) +{ + freelog(LOG_DEBUG, "handle_other_processing_finished"); + + reports_thaw(); + + agents_other_processing_finished(); } Index: client/packhand.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/packhand.h,v retrieving revision 1.26 diff -u -r1.26 packhand.h --- client/packhand.h 2002/06/27 00:59:12 1.26 +++ client/packhand.h 2002/08/07 09:30:57 @@ -62,6 +62,8 @@ void handle_processing_started(void); void handle_processing_finished(void); void handle_start_turn(void); +void handle_other_processing_started(void); +void handle_other_processing_finished(void); void notify_about_incoming_packet(struct connection *pc, int packet_type, int size); Index: client/agents/agents.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/agents/agents.c,v retrieving revision 1.15 diff -u -r1.15 agents.c --- client/agents/agents.c 2002/06/23 16:06:23 1.15 +++ client/agents/agents.c 2002/08/07 09:30:58 @@ -354,6 +354,24 @@ /*********************************************************************** Called from client/packhand.c. ***********************************************************************/ +void agents_other_processing_started(void) +{ + freelog(META_CALLBACKS_LOGLEVEL, "agents_other_processing_started()"); + freeze(); +} + +/*********************************************************************** + Called from client/packhand.c. +***********************************************************************/ +void agents_other_processing_finished(void) +{ + freelog(META_CALLBACKS_LOGLEVEL, "agents_other_processing_finished()"); + thaw(); +} + +/*********************************************************************** + Called from client/packhand.c. +***********************************************************************/ void agents_game_joined(void) { freelog(META_CALLBACKS_LOGLEVEL, "agents_game_joined()"); @@ -374,7 +392,6 @@ void agents_before_new_turn(void) { freelog(META_CALLBACKS_LOGLEVEL, "agents_before_new_turn()"); - freeze(); } /*********************************************************************** @@ -383,7 +400,6 @@ void agents_start_turn(void) { freelog(META_CALLBACKS_LOGLEVEL, "agents_start_turn()"); - thaw(); } /*********************************************************************** Index: client/agents/agents.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/agents/agents.h,v retrieving revision 1.4 diff -u -r1.4 agents.h --- client/agents/agents.h 2002/06/07 16:11:24 1.4 +++ client/agents/agents.h 2002/08/07 09:30:58 @@ -48,6 +48,8 @@ void agents_disconnect(void); void agents_processing_started(void); void agents_processing_finished(void); +void agents_other_processing_started(void); +void agents_other_processing_finished(void); void agents_game_joined(void); void agents_game_start(void); void agents_before_new_turn(void); Index: client/agents/cma_core.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_core.c,v retrieving revision 1.27 diff -u -r1.27 cma_core.c --- client/agents/cma_core.c 2002/06/29 18:35:04 1.27 +++ client/agents/cma_core.c 2002/08/07 09:30:59 @@ -1719,6 +1719,8 @@ bool handled; int i; + assert(find_city_by_id(pcity->id) == pcity); + len = attr_city_get(ATTR_CITY_CMA_PARAMETER, pcity->id, sizeof(parameter), ¶meter); Index: common/connection.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/connection.h,v retrieving revision 1.21 diff -u -r1.21 connection.h --- common/connection.h 2002/02/14 15:17:10 1.21 +++ common/connection.h 2002/08/07 09:31:00 @@ -149,6 +149,14 @@ * Will increase for every received packet. */ int last_request_id_seen; + /* + * Should a POPS be send? + */ + bool POPS_required; + /* + * Was a POPS sent? + */ + bool POPS_sent; } server; /* Index: common/packets.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/packets.c,v retrieving revision 1.210 diff -u -r1.210 packets.c --- common/packets.c 2002/07/29 13:13:41 1.210 +++ common/packets.c 2002/08/07 09:31:02 @@ -198,6 +198,12 @@ get_next_request_id(pc->client.last_request_id_used); result = pc->client.last_request_id_used; freelog(LOG_DEBUG, "sending request %d", result); + } else { + if (pc->server.POPS_required && !pc->server.POPS_sent) { + pc->server.POPS_sent = TRUE; + freelog(LOG_DEBUG, "sending POPS to %s", conn_description(pc)); + send_packet_generic_empty(pc, PACKET_OTHER_PROCESSING_STARTED); + } } if (pc->outgoing_packet_notify) { @@ -396,6 +402,8 @@ case PACKET_PROCESSING_FINISHED: case PACKET_START_TURN: case PACKET_SELECT_NATION_OK: + case PACKET_OTHER_PROCESSING_STARTED: + case PACKET_OTHER_PROCESSING_FINISHED: return receive_packet_generic_empty(pc); case PACKET_NEW_YEAR: Index: common/packets.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/packets.h,v retrieving revision 1.118 diff -u -r1.118 packets.h --- common/packets.h 2002/07/29 13:13:41 1.118 +++ common/packets.h 2002/08/07 09:31:03 @@ -125,6 +125,8 @@ PACKET_PLAYER_ATTRIBUTE_BLOCK, PACKET_START_TURN, PACKET_SELECT_NATION_OK, + PACKET_OTHER_PROCESSING_STARTED, + PACKET_OTHER_PROCESSING_FINISHED, PACKET_LAST /* leave this last */ }; Index: server/sernet.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/sernet.c,v retrieving revision 1.93 diff -u -r1.93 sernet.c --- server/sernet.c 2002/07/14 13:40:26 1.93 +++ server/sernet.c 2002/08/07 09:31:03 @@ -565,15 +565,18 @@ err = gettimeofday(&start, &tz); assert(!err); #endif - connection_do_buffer(pconn); + conn_list_do_buffer(&game.all_connections); start_processing_request(pconn, pconn->server. last_request_id_seen); + prepare_for_sending_POPS(pconn); + command_ok = handle_packet_input(pconn, packet, type); packet = NULL; + send_POPF(); finish_processing_request(pconn); - connection_do_unbuffer(pconn); + conn_list_do_unbuffer(&game.all_connections); if (!command_ok) { close_connection(pconn); } @@ -809,4 +812,30 @@ pconn->server.currently_processed_request_id, pconn->id); send_packet_generic_empty(pconn, PACKET_PROCESSING_FINISHED); pconn->server.currently_processed_request_id = 0; +} + +/************************************************************************** +... +**************************************************************************/ +void prepare_for_sending_POPS(struct connection *generating_conn) +{ + conn_list_iterate(game.all_connections, pconn) { + pconn->server.POPS_required = (pconn != generating_conn); + pconn->server.POPS_sent = FALSE; + } conn_list_iterate_end; +} + +/************************************************************************** +... +**************************************************************************/ +void send_POPF(void) +{ + conn_list_iterate(game.all_connections, pconn) { + if (pconn->server.POPS_sent) { + freelog(LOG_DEBUG, "sending POPF to %s", conn_description(pconn)); + send_packet_generic_empty(pconn, PACKET_OTHER_PROCESSING_FINISHED); + } + pconn->server.POPS_required = FALSE; + pconn->server.POPS_sent = FALSE; + } conn_list_iterate_end; } Index: server/sernet.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/sernet.h,v retrieving revision 1.7 diff -u -r1.7 sernet.h --- server/sernet.h 2000/09/18 20:36:15 1.7 +++ server/sernet.h 2002/08/07 09:31:03 @@ -25,5 +25,7 @@ void close_connections_and_socket(void); void init_connections(void); void close_connection(struct connection *pconn); +void prepare_for_sending_POPS(struct connection *generating_conn); +void send_POPF(void); #endif /* FC__SERNET_H */ Index: server/srv_main.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v retrieving revision 1.87 diff -u -r1.87 srv_main.c --- server/srv_main.c 2002/07/27 17:10:54 1.87 +++ server/srv_main.c 2002/08/07 09:31:05 @@ -1338,12 +1338,13 @@ join_game_accept(pconn, TRUE); introduce_game_to_connection(pconn); if(server_state==RUN_GAME_STATE) { + send_packet_generic_empty(pconn, PACKET_OTHER_PROCESSING_STARTED); send_rulesets(&pconn->self); send_all_info(&pconn->self); send_game_state(&pconn->self, CLIENT_GAME_RUNNING_STATE); send_player_info(NULL,NULL); send_diplomatic_meetings(pconn); - send_packet_generic_empty(pconn, PACKET_START_TURN); + send_packet_generic_empty(pconn, PACKET_OTHER_PROCESSING_FINISHED); } if (game.auto_ai_toggle && pplayer->ai.control) { toggle_ai_player_direct(NULL, pplayer); @@ -1658,6 +1659,10 @@ eot_timer = new_timer_start(TIMER_CPU, TIMER_ACTIVE); + /* This will freeze the reports and agents at the client. */ + /* Do this before the body so that the send_POPF call is balanced. */ + prepare_for_sending_POPS(NULL); + while(server_state==RUN_GAME_STATE) { /* absolute beginning of a turn */ freelog(LOG_DEBUG, "Begin turn"); @@ -1674,6 +1679,9 @@ freelog(LOG_DEBUG, "Aistartturn"); ai_start_turn(); send_start_turn_to_clients(); + + /* Thaw the reports and agents at the client. */ + send_POPF(); /* Before sniff (human player activites), report time to now: */ freelog(LOG_VERBOSE, "End/start-turn server/ai activities: %g seconds", @@ -1704,6 +1712,9 @@ sanity_check(); #endif + /* This will freeze the reports and agents at the client. */ + prepare_for_sending_POPS(NULL); + before_end_year(); /* This empties the client Messages window; put this before everything else below, since otherwise any messages from @@ -1743,6 +1754,9 @@ if (is_game_over()) server_state=GAME_OVER_STATE; } + + /* To get a balance we have to do a final thaw. */ + send_POPF(); } /**************************************************************************