<URL: http://bugs.freeciv.org/Ticket/Display.html?id=17793 >
On 16/08/07, Marko Lindqvist wrote: > > This was marked as S2_1 bug, though. Maybe wait cursors were meant to > be backported to S2_1? (...hmm... as a side(?) effect of this patch, > they are) Do all S2_1 tilesets contain wait cursor? Fixed number of problems from S2_1 version. It requires wait cursor graphics (#39563). - ML
diff -Nurd -X.diff_ignore freeciv/client/civclient.c freeciv/client/civclient.c --- freeciv/client/civclient.c 2007-08-25 15:16:07.000000000 +0300 +++ freeciv/client/civclient.c 2007-09-02 00:03:51.000000000 +0300 @@ -105,6 +105,11 @@ */ bool turn_done_sent = FALSE; +/* + * TRUE between receiving PACKET_END_TURN and PACKET_BEGIN_TURN + */ +static bool server_busy = FALSE; + /************************************************************************** Convert a text string from the internal to the data encoding, when it is written to the network. @@ -761,3 +766,26 @@ && (get_client_state() == CLIENT_GAME_RUNNING_STATE || get_client_state() == CLIENT_GAME_OVER_STATE)); } + +/************************************************************************** + Sets if server is considered busy. Currently it is considered busy + between turns. +**************************************************************************/ +void set_server_busy(bool busy) +{ + if (busy != server_busy) { + /* server_busy value will change */ + server_busy = busy; + + /* This may mean that we have to change from or to wait cursor */ + handle_mouse_cursor(NULL); + } +} + +/************************************************************************** + Returns if server is considered busy at the moment +**************************************************************************/ +bool is_server_busy(void) +{ + return server_busy; +} diff -Nurd -X.diff_ignore freeciv/client/civclient.h freeciv/client/civclient.h --- freeciv/client/civclient.h 2007-03-05 19:14:36.000000000 +0200 +++ freeciv/client/civclient.h 2007-09-02 00:03:51.000000000 +0300 @@ -34,6 +34,8 @@ void set_client_state(enum client_states newstate); enum client_states get_client_state(void); +void set_server_busy(bool busy); +bool is_server_busy(void); void client_remove_cli_conn(struct connection *pconn); void client_remove_all_cli_conn(void); diff -Nurd -X.diff_ignore freeciv/client/control.c freeciv/client/control.c --- freeciv/client/control.c 2007-08-25 15:16:07.000000000 +0300 +++ freeciv/client/control.c 2007-09-02 00:50:18.000000000 +0300 @@ -884,6 +884,13 @@ struct city *pcity = NULL; struct unit_list *active_units = get_units_in_focus(); + if (is_server_busy()) { + /* Server will not accept any commands. */ + action_state = CURSOR_ACTION_WAIT; + update_unit_info_label(active_units); + return; + } + if (!ptile) { if (hover_tile) { /* hover_tile is the tile which is currently under the mouse cursor. */ diff -Nurd -X.diff_ignore freeciv/client/control.h freeciv/client/control.h --- freeciv/client/control.h 2007-03-05 19:14:36.000000000 +0200 +++ freeciv/client/control.h 2007-09-02 00:03:51.000000000 +0300 @@ -31,7 +31,8 @@ CURSOR_ACTION_INVALID, CURSOR_ACTION_ATTACK, CURSOR_ACTION_NUKE, - CURSOR_ACTION_PARATROOPER + CURSOR_ACTION_PARATROOPER, + CURSOR_ACTION_WAIT }; /* Selecting unit from a stack without popup. */ diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/mapview.c freeciv/client/gui-gtk-2.0/mapview.c --- freeciv/client/gui-gtk-2.0/mapview.c 2007-08-01 19:21:33.000000000 +0300 +++ freeciv/client/gui-gtk-2.0/mapview.c 2007-09-02 00:33:39.000000000 +0300 @@ -215,6 +215,9 @@ gtk_label_set_text(GTK_LABEL(unit_info_label), get_unit_info_label_text2(punits)); + if (action_state == CURSOR_ACTION_WAIT) { + mouse_cursor_type = CURSOR_WAIT; + } else { switch (hover_state) { case HOVER_NONE: if (action_state == CURSOR_ACTION_SELECT) { @@ -259,6 +262,7 @@ mouse_cursor_type = CURSOR_PARADROP; break; } + } modify_mouse_cursor(mouse_cursor_type); diff -Nurd -X.diff_ignore freeciv/client/gui-sdl/gui_main.c freeciv/client/gui-sdl/gui_main.c --- freeciv/client/gui-sdl/gui_main.c 2007-08-22 03:26:25.000000000 +0300 +++ freeciv/client/gui-sdl/gui_main.c 2007-09-02 00:50:11.000000000 +0300 @@ -398,7 +398,11 @@ unsellect_widget_action(); } else { if (get_client_state() == CLIENT_GAME_RUNNING_STATE) { - handle_mouse_cursor(canvas_pos_to_tile(pMotionEvent->x, pMotionEvent->y)); + struct tile *ptile = canvas_pos_to_tile(pMotionEvent->x, pMotionEvent->y); + + handle_mouse_cursor(ptile); + hover_tile = ptile; + #ifndef UNDER_CE check_scroll_area(pMotionEvent->x, pMotionEvent->y); #endif diff -Nurd -X.diff_ignore freeciv/client/gui-sdl/mapview.c freeciv/client/gui-sdl/mapview.c --- freeciv/client/gui-sdl/mapview.c 2007-08-25 15:16:07.000000000 +0300 +++ freeciv/client/gui-sdl/mapview.c 2007-09-02 00:35:57.000000000 +0300 @@ -1144,6 +1144,9 @@ if(!is_anim_enabled()) { enable_focus_animation(); } + if (action_state == CURSOR_ACTION_WAIT) { + update_mouse_cursor(CURSOR_WAIT); + } else { switch (hover_state) { case HOVER_NONE: if (action_state == CURSOR_ACTION_SELECT) { @@ -1188,6 +1191,7 @@ update_mouse_cursor(CURSOR_PARADROP); break; } + } } else { disable_focus_animation(); } diff -Nurd -X.diff_ignore freeciv/client/gui-win32/mapview.c freeciv/client/gui-win32/mapview.c --- freeciv/client/gui-win32/mapview.c 2007-07-04 14:04:26.000000000 +0300 +++ freeciv/client/gui-win32/mapview.c 2007-09-02 00:36:42.000000000 +0300 @@ -201,6 +201,9 @@ SetWindowText(unit_info_frame, get_unit_info_label_text1(punitlist)); SetWindowText(unit_info_label, get_unit_info_label_text2(punitlist)); + if (action_state == CURSOR_ACTION_WAIT) { + cursor_type = CURSOR_WAIT; + } else { switch (hover_state) { case HOVER_NONE: if (action_state == CURSOR_ACTION_SELECT) { @@ -245,6 +248,7 @@ cursor_type = CURSOR_PARADROP; break; } + } do_mainwin_layout(); } diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c --- freeciv/client/packhand.c 2007-09-01 14:53:26.000000000 +0300 +++ freeciv/client/packhand.c 2007-09-02 00:03:51.000000000 +0300 @@ -184,7 +184,8 @@ aconnection.id = conn_id; agents_game_joined(); update_menus(); - + + set_server_busy(FALSE); if (get_client_page() == PAGE_MAIN || get_client_page() == PAGE_NETWORK @@ -389,8 +390,13 @@ update_unit_info_label(NULL); } - if (changed && can_client_change_view()) { - update_map_canvas_visible(); + if (changed) { + if (can_client_change_view()) { + update_map_canvas_visible(); + } + + /* If turn was going to change, that is now aborted. */ + set_server_busy(FALSE); } } @@ -897,6 +903,30 @@ } /************************************************************************** + Called when begin-turn packet is received. Server has finished processing + turn change. +**************************************************************************/ +void handle_begin_turn(void) +{ + freelog(LOG_DEBUG, "handle_begin_turn()"); + + /* Possibly replace wait cursor with something else */ + set_server_busy(FALSE); +} + +/************************************************************************** + Called when end-turn packet is received. Server starts processing turn + change. +**************************************************************************/ +void handle_end_turn(void) +{ + freelog(LOG_DEBUG, "handle_end_turn()"); + + /* Make sure wait cursor is in use */ + set_server_busy(TRUE); +} + +/************************************************************************** ... **************************************************************************/ void play_sound_for_event(enum event_type type) diff -Nurd -X.diff_ignore freeciv/client/tilespec.c freeciv/client/tilespec.c --- freeciv/client/tilespec.c 2007-09-01 04:02:28.000000000 +0300 +++ freeciv/client/tilespec.c 2007-09-02 00:15:07.000000000 +0300 @@ -2068,7 +2068,7 @@ for (f = 0; f < NUM_CURSOR_FRAMES; f++) { const char *names[CURSOR_LAST] = {"goto", "patrol", "paradrop", "nuke", "select", - "invalid", "attack"}; + "invalid", "attack", "wait"}; struct small_sprite *ss; my_snprintf(buffer, sizeof(buffer), "cursor.%s%d", names[i], f); diff -Nurd -X.diff_ignore freeciv/client/tilespec.h freeciv/client/tilespec.h --- freeciv/client/tilespec.h 2007-08-04 00:29:09.000000000 +0300 +++ freeciv/client/tilespec.h 2007-09-02 00:03:51.000000000 +0300 @@ -154,6 +154,7 @@ CURSOR_SELECT, CURSOR_INVALID, CURSOR_ATTACK, + CURSOR_WAIT, CURSOR_LAST, CURSOR_DEFAULT, }; diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def --- freeciv/common/packets.def 2007-08-21 21:41:47.000000000 +0300 +++ freeciv/common/packets.def 2007-09-02 00:03:51.000000000 +0300 @@ -242,7 +242,7 @@ Spaceship Ruleset -The last used packet number is 118. +The last used packet number is 138. ****************************************************/ @@ -999,6 +999,14 @@ end # Freeze reports and agents +PACKET_BEGIN_TURN=137;sc,lsend +end + +# Thaw reports and agents +PACKET_END_TURN=138;sc,lsend +end + +# Freeze reports and agents PACKET_FREEZE_CLIENT=135;sc,lsend end diff -Nurd -X.diff_ignore freeciv/server/srv_main.c freeciv/server/srv_main.c --- freeciv/server/srv_main.c 2007-08-30 12:36:18.000000000 +0300 +++ freeciv/server/srv_main.c 2007-09-02 00:50:26.000000000 +0300 @@ -116,6 +116,8 @@ static void freeze_clients(void); static void thaw_clients(void); +static void send_begin_turn(void); +static void send_end_turn(void); /* this is used in strange places, and is 'extern'd where needed (hence, it is not 'extern'd in srv_main.h) */ @@ -679,6 +681,13 @@ game.phase_timer = renew_timer_start(game.phase_timer, TIMER_USER, TIMER_ACTIVE); send_game_info(NULL); + + if (game.info.num_phases == 1) { + /* All players in the same phase. + * This means that AI has been handled above, and server + * will be responsive again */ + send_begin_turn(); + } } /************************************************************************** @@ -763,13 +772,15 @@ freelog(LOG_DEBUG, "Endturn"); /* Hack: because observer players never get an end-phase packet we send - * one here. It would be better perhaps to have a full end-turn packet. */ + * one here. */ conn_list_iterate(game.est_connections, pconn) { if (!pconn->player) { send_packet_end_phase(pconn); } } conn_list_iterate_end; + send_end_turn(); + map_calculate_borders(); freelog(LOG_DEBUG, "Season of native unrests"); @@ -1667,6 +1678,30 @@ } /************************************************************************** + Send PACKET_BEGIN_TURN to all clients capable of handling it. +**************************************************************************/ +static void send_begin_turn(void) +{ + conn_list_iterate(game.est_connections, pconn) { + if (has_capability("CF", pconn->capability)) { + send_packet_begin_turn(pconn); + } + } conn_list_iterate_end; +} + +/************************************************************************** + Send PACKET_END_TURN to all clients capable of handling it. +**************************************************************************/ +static void send_end_turn(void) +{ + conn_list_iterate(game.est_connections, pconn) { + if (has_capability("CF", pconn->capability)) { + send_packet_end_turn(pconn); + } + } conn_list_iterate_end; +} + +/************************************************************************** Play the game! Returns when server_state == GAME_OVER_STATE. **************************************************************************/ static void main_loop(void) @@ -1697,6 +1732,14 @@ * movement and AI diplomacy). */ begin_turn(is_new_turn); + if (game.info.num_phases != 1) { + /* We allow everyone to begin adjusting cities and such + * from the beginning of the turn. + * With simultaneous movement we send begin_turn packet in + * begin_phase() only after AI players have finished their actions. */ + send_begin_turn(); + } + for (; game.info.phase < game.info.num_phases; game.info.phase++) { freelog(LOG_DEBUG, "Starting phase %d/%d.", game.info.phase, game.info.num_phases); diff -Nurd -X.diff_ignore freeciv/version.in freeciv/version.in --- freeciv/version.in 2007-08-25 15:16:07.000000000 +0300 +++ freeciv/version.in 2007-09-02 00:04:10.000000000 +0300 @@ -21,6 +21,9 @@ # "ReportFreezeFix" allows clients to correctly freeze reports and agents # over turn change. # +# "CF" CursorFix makes sure that wait cursor is in use between +# turns and only between turns. +# # # - No new manditory capabilities can be added to the release branch; doing # so would break network capability of supposedly "compatible" releases. @@ -28,4 +31,4 @@ # - Avoid adding a new manditory capability to the development branch for # as long as possible. We want to maintain network compatibility with # the stable branch for as long as possible. -FREECIV_NETWORK_CAPSTRING(["+2.1f, ReportFreezeFix"]) +FREECIV_NETWORK_CAPSTRING(["+2.1f, ReportFreezeFix CF"])
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev