Re: [Freeciv-Dev] (PR#17793) Wait cursor and non-simultaneous movement (gtk2 client, trunk)
URL: http://bugs.freeciv.org/Ticket/Display.html?id=17793 On 05/08/07, Marko Lindqvist [EMAIL PROTECTED] wrote: On 10/06/06, Andreas Røsdal [EMAIL PROTECTED] wrote: On Sat, 10 Jun 2006, Per I. Mathisen wrote: set simultaneousphases 0 Now the wait cursor appears whenever you press 'end turn' to indicate that you are done moving. However, you may still want to set gotos or change city production, which it would be nice to have a normal cursor for. This patch sets the wait cursor to only replace the default cursor between turns. Um, no. But this patch does. I had to introduce new packets END_TURN and BEGIN_TURN. So this one is suitable for trunk only, for S2_1 version capability checks have to be added. - ML diff -Nurd -X.diff_ignore freeciv/client/civclient.c freeciv/client/civclient.c --- freeciv/client/civclient.c 2007-08-12 21:14:05.0 +0300 +++ freeciv/client/civclient.c 2007-08-12 22:59:43.0 +0300 @@ -99,6 +99,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. @@ -758,3 +763,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-08-04 18:39:15.0 +0300 +++ freeciv/client/civclient.h 2007-08-12 22:56:33.0 +0300 @@ -36,6 +36,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-05 16:40:59.0 +0300 +++ freeciv/client/control.c 2007-08-12 23:00:23.0 +0300 @@ -890,7 +890,8 @@ return; } - if (turn_done_sent || waiting_for_end_turn) { + if (is_server_busy()) { +/* Server will not accept any commands. */ update_mouse_cursor(CURSOR_WAIT); return; } diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c --- freeciv/client/packhand.c 2007-08-12 21:14:05.0 +0300 +++ freeciv/client/packhand.c 2007-08-12 22:55:16.0 +0300 @@ -183,7 +183,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 @@ -388,8 +389,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); } } @@ -893,6 +899,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/common/packets.def
Re: [Freeciv-Dev] (PR#17793) Wait cursor and non-simultaneous movement (gtk2 client, trunk)
URL: http://bugs.freeciv.org/Ticket/Display.html?id=17793 On 12/08/07, Marko Lindqvist [EMAIL PROTECTED] wrote: I had to introduce new packets END_TURN and BEGIN_TURN. So this one is suitable for trunk only, for S2_1 version capability checks have to be added. Here is version with capability checks. As our capability string is getting rather long even before first release from this stable branch, I made capability just two letter abbreviation. It turns out that cursor handling has changed a lot between S2_1 and trunk. In S2_1 this patch does only bad things without additional support code to every client. - ML diff -Nurd -X.diff_ignore freeciv/client/civclient.c freeciv/client/civclient.c --- freeciv/client/civclient.c 2007-07-04 14:04:27.0 +0300 +++ freeciv/client/civclient.c 2007-08-12 23:09:46.0 +0300 @@ -101,6 +101,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. @@ -757,3 +762,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.0 +0200 +++ freeciv/client/civclient.h 2007-08-12 23:09:46.0 +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-07-04 14:04:27.0 +0300 +++ freeciv/client/control.c 2007-08-12 23:36:14.0 +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.0 +0200 +++ freeciv/client/control.h 2007-08-12 23:26:14.0 +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/packhand.c freeciv/client/packhand.c --- freeciv/client/packhand.c 2007-08-11 12:17:15.0 +0300 +++ freeciv/client/packhand.c 2007-08-12 23:09:46.0 +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); } } @@ -913,6 +919,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 +
Re: [Freeciv-Dev] (PR#17793) Wait cursor and non-simultaneous movement (gtk2 client, trunk)
URL: http://bugs.freeciv.org/Ticket/Display.html?id=17793 On 10/06/06, Andreas Røsdal [EMAIL PROTECTED] wrote: On Sat, 10 Jun 2006, Per I. Mathisen wrote: set simultaneousphases 0 Now the wait cursor appears whenever you press 'end turn' to indicate that you are done moving. However, you may still want to set gotos or change city production, which it would be nice to have a normal cursor for. This patch sets the wait cursor to only replace the default cursor between turns. Um, no. It just gives some other cursors higher priority when someone else is moving. For most part you still get wait cursor. Another problem is that other cursors (such as 'select unit/city') have higher priority even between turns. This is potentially bad with slow computers and lots of AI players. - ML ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev