[Freeciv-Dev] (PR#12885) blink the turn-done button once per half-second
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12885 >
Current the turn-done button blinks once every time the client timer
callback is called. This *used* to be "about" once every half-second,
which was fine for this purpose. But now it can happen as often as it
wants to - and with a selection circle it will be much more than once
every half-second.
This patch changes the blinking to use a proper timer, and follow a
rigid one-half-second blink interval.
-jason
Index: client/civclient.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v
retrieving revision 1.219
diff -u -r1.219 civclient.c
--- client/civclient.c 15 Apr 2005 05:08:09 -0000 1.219
+++ client/civclient.c 25 Apr 2005 08:46:21 -0000
@@ -675,23 +675,10 @@
return time_until_next_call;
}
- if (game.player_ptr->is_connected && game.player_ptr->is_alive &&
- !game.player_ptr->phase_done) {
- int is_waiting = 0, is_moving = 0;
-
- players_iterate(pplayer) {
- if (pplayer->is_alive && pplayer->is_connected) {
- if (pplayer->phase_done) {
- is_waiting++;
- } else {
- is_moving++;
- }
- }
- } players_iterate_end;
+ {
+ double blink_time = blink_turn_done_button();
- if (is_moving == 1 && is_waiting > 0) {
- update_turn_done_button(FALSE); /* stress the slow player! */
- }
+ time_until_next_call = MIN(time_until_next_call, blink_time);
}
if (get_unit_in_focus()) {
Index: client/control.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.c,v
retrieving revision 1.169
diff -u -r1.169 control.c
--- client/control.c 23 Apr 2005 17:40:22 -0000 1.169
+++ client/control.c 25 Apr 2005 08:46:21 -0000
@@ -440,6 +440,41 @@
return blink_time;
}
+/****************************************************************************
+ Blink the turn done button (if necessary). Return the time until the next
+ blink (in seconds).
+****************************************************************************/
+double blink_turn_done_button(void)
+{
+ static struct timer *blink_timer = NULL;
+ const double blink_time = 0.5; /* half-second blink interval */
+
+ if (game.player_ptr->is_connected && game.player_ptr->is_alive
+ && !game.player_ptr->phase_done) {
+ if (!blink_timer || read_timer_seconds(blink_timer) > blink_time) {
+ int is_waiting = 0, is_moving = 0;
+
+ players_iterate(pplayer) {
+ if (pplayer->is_alive && pplayer->is_connected) {
+ if (pplayer->phase_done) {
+ is_waiting++;
+ } else {
+ is_moving++;
+ }
+ }
+ } players_iterate_end;
+
+ if (is_moving == 1 && is_waiting > 0) {
+ update_turn_done_button(FALSE); /* stress the slow player! */
+ }
+ blink_timer = renew_timer_start(blink_timer, TIMER_USER, TIMER_ACTIVE);
+ }
+ return blink_time - read_timer_seconds(blink_timer);
+ }
+
+ return blink_time;
+}
+
/**************************************************************************
Update unit icons (and arrow) in the information display, for specified
punit as the active unit and other units on the same square. In practice
Index: client/control.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.h,v
retrieving revision 1.49
diff -u -r1.49 control.h
--- client/control.h 12 Feb 2005 18:47:18 -0000 1.49
+++ client/control.h 25 Apr 2005 08:46:21 -0000
@@ -113,6 +113,7 @@
struct unit *find_visible_unit(struct tile *ptile);
void set_units_in_combat(struct unit *pattacker, struct unit *pdefender);
double blink_active_unit(void);
+double blink_turn_done_button(void);
void update_unit_pix_label(struct unit *punit);
void process_caravan_arrival(struct unit *punit);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#12885) blink the turn-done button once per half-second,
Jason Short <=
|
|