diff -Nurd -X clean/diff_ignore -x *.sav* clean/client/agents/agents.c work/client/agents/agents.c --- clean/client/agents/agents.c Sat Aug 24 15:38:51 2002 +++ work/client/agents/agents.c Tue Aug 27 16:38:06 2002 @@ -352,10 +352,27 @@ /*********************************************************************** 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()"); - freeze(); } /*********************************************************************** @@ -372,7 +389,6 @@ void agents_before_new_turn(void) { freelog(META_CALLBACKS_LOGLEVEL, "agents_before_new_turn()"); - freeze(); } /*********************************************************************** @@ -381,7 +397,6 @@ void agents_start_turn(void) { freelog(META_CALLBACKS_LOGLEVEL, "agents_start_turn()"); - thaw(); } /*********************************************************************** diff -Nurd -X clean/diff_ignore -x *.sav* clean/client/agents/agents.h work/client/agents/agents.h --- clean/client/agents/agents.h Wed Aug 7 14:38:11 2002 +++ work/client/agents/agents.h Sun Aug 25 19:59:56 2002 @@ -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); diff -Nurd -X clean/diff_ignore -x *.sav* clean/client/agents/cma_core.c work/client/agents/cma_core.c --- clean/client/agents/cma_core.c Wed Aug 7 14:38:11 2002 +++ work/client/agents/cma_core.c Sun Aug 25 19:59:56 2002 @@ -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); diff -Nurd -X clean/diff_ignore -x *.sav* clean/client/civclient.c work/client/civclient.c --- clean/client/civclient.c Sun Aug 25 19:53:40 2002 +++ work/client/civclient.c Tue Aug 27 16:52:14 2002 @@ -449,6 +449,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() @@ -572,6 +580,23 @@ { bool connect_error = (client_state == CLIENT_PRE_GAME_STATE) && (newstate == CLIENT_PRE_GAME_STATE); + + /* + * We are currently ignoring the CLIENT_GAME_OVER_STATE state + * because the client hasen't been changed to take care of it. So it + * breaks the show-whole-map-at-the-end-of-the-game. Nevertheless + * the server is so kind and sends the client this information. And + * in the future the client can/should take advantage of this + * information. + * + * FIXME: audit all client code to that it copes with + * CLIENT_GAME_OVER_STATE and implement specific + * CLIENT_GAME_OVER_STATE actions like history browsing. Then remove + * the kludge below. + */ + if (newstate == CLIENT_GAME_OVER_STATE) { + newstate = CLIENT_GAME_RUNNING_STATE; + } if(client_state!=newstate) { diff -Nurd -X clean/diff_ignore -x *.sav* clean/client/climisc.c work/client/climisc.c --- clean/client/climisc.c Sun Aug 25 19:53:40 2002 +++ work/client/climisc.c Sun Aug 25 19:59:56 2002 @@ -1192,6 +1192,8 @@ **************************************************************************/ void reports_freeze(void) { + freelog(LOG_DEBUG, "reports_freeze"); + meswin_freeze(); plrdlg_freeze(); report_dialogs_freeze(); @@ -1215,6 +1217,8 @@ **************************************************************************/ void reports_thaw(void) { + freelog(LOG_DEBUG, "reports_thaw"); + meswin_thaw(); plrdlg_thaw(); report_dialogs_thaw(); diff -Nurd -X clean/diff_ignore -x *.sav* clean/client/packhand.c work/client/packhand.c --- clean/client/packhand.c Sun Aug 25 19:53:40 2002 +++ work/client/packhand.c Sun Aug 25 19:59:56 2002 @@ -289,8 +289,6 @@ free_intro_radar_sprites(); agents_game_start(); - } else if(get_client_state() == CLIENT_GAME_OVER_STATE) { - reports_thaw(); } } @@ -677,7 +675,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) @@ -695,8 +692,6 @@ **************************************************************************/ void handle_start_turn(void) { - reports_thaw(); - agents_start_turn(); turn_done_sent = FALSE; @@ -1632,8 +1627,6 @@ { int i; - reports_freeze(); - tilespec_free_city_tiles(game.styles_count); ruleset_data_free(); @@ -2345,4 +2338,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(); } diff -Nurd -X clean/diff_ignore -x *.sav* clean/client/packhand.h work/client/packhand.h --- clean/client/packhand.h Sun Aug 25 18:42:55 2002 +++ work/client/packhand.h Sun Aug 25 19:59:56 2002 @@ -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); diff -Nurd -X clean/diff_ignore -x *.sav* clean/common/connection.h work/common/connection.h --- clean/common/connection.h Wed Aug 7 14:38:11 2002 +++ work/common/connection.h Sun Aug 25 19:59:56 2002 @@ -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; /* diff -Nurd -X clean/diff_ignore -x *.sav* clean/common/packets.c work/common/packets.c --- clean/common/packets.c Sun Aug 25 18:42:59 2002 +++ work/common/packets.c Sun Aug 25 19:59:56 2002 @@ -211,6 +211,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) { @@ -409,6 +415,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: diff -Nurd -X clean/diff_ignore -x *.sav* clean/common/packets.h work/common/packets.h --- clean/common/packets.h Sun Aug 25 18:42:59 2002 +++ work/common/packets.h Sun Aug 25 19:59:56 2002 @@ -126,6 +126,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 */ }; diff -Nurd -X clean/diff_ignore -x *.sav* clean/po/Makefile.in.in work/po/Makefile.in.in --- clean/po/Makefile.in.in Tue Aug 27 17:27:31 2002 +++ work/po/Makefile.in.in Tue Aug 27 18:31:17 2002 @@ -65,7 +65,7 @@ $(MSGMERGE) $< $(srcdir)/$(PACKAGE).pot -o $*.pox .po.mo: - $(MSGFMT) -c -o $@ $< + $(MSGFMT) -o $@ $< .po.gmo: file=$(srcdir)/`echo $* | sed 's,.*/,,'`.gmo \ diff -Nurd -X clean/diff_ignore -x *.sav* clean/server/sernet.c work/server/sernet.c --- clean/server/sernet.c Wed Aug 7 14:38:11 2002 +++ work/server/sernet.c Tue Aug 27 16:55:55 2002 @@ -815,3 +815,29 @@ 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; +} diff -Nurd -X clean/diff_ignore -x *.sav* clean/server/sernet.h work/server/sernet.h --- clean/server/sernet.h Wed Aug 7 14:38:11 2002 +++ work/server/sernet.h Sun Aug 25 19:59:56 2002 @@ -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 */ diff -Nurd -X clean/diff_ignore -x *.sav* clean/server/srv_main.c work/server/srv_main.c --- clean/server/srv_main.c Sun Aug 25 18:43:04 2002 +++ work/server/srv_main.c Sun Aug 25 19:59:56 2002 @@ -1358,12 +1358,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); @@ -1678,6 +1679,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"); @@ -1694,6 +1699,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", @@ -1724,6 +1732,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 @@ -1763,6 +1774,9 @@ if (is_game_over()) server_state=GAME_OVER_STATE; } + + /* To get a balance we have to do a final thaw. */ + send_POPF(); } /**************************************************************************