Update of bug #18079 (project freeciv):

                Category:                    None => general                
                  Status:                    None => Ready For Test         
             Assigned to:                    None => jtn                    
         Planned Release:                         => 2.3.0                  
                 Summary: set timeout advances turn => "set timeout"
sometimes advances turn immediately, sometimes ignored


Follow-up Comment #1:

I can reproduce the immediate end turn on transitions from timeout=0
(disabled) to nonzero, and the lack of effect on nonzero->nonzero

What's happening here is that game.info.seconds_to_phasedone is only set from
the 'timeout' setting at the start of the turn (at the same time as the turn
timer is started).

If timeout=0 at turn start, the turn would end as soon as it started, except
that the relevant code in server_sniff_all_input() checks for timeout>0, so
seconds_to_phasedone is ignored. When timeout changes to nonzero, suddenly
seconds_to_phasedone takes effect, is compared against phase_timer that's been
running since the start of the turn, and the turn ends immediately.

If timeout is changed from one nonzero value to another, then
seconds_to_phasedone isn't changed and so there's no net effect.

The second problem was also reported by pepeto ages ago in RT#39770
> When you use the command /set timeout 60 while the game is 
> running, the timeout change only the next turn. The problem is 
> that game.info.seconds_to_phasedone doesn't change when 
> game.info.timeout is changed.
> A callback like:

Change timeout...
static bool timeout_callback(int new_timeout, const char **error_string)
error_string = NULL;

game.info.seconds_to_phasedone += new_timeout - game.info.timeout;

return TRUE;

> is missing. But there is an other problem, votes for '/set' 
> are still buggy (I made a ticket some months ago, rejected). 
> This callback would be call when the vote will be checked.
> So, the timeout will change virtually.

I don't think the problem with pepeto's proposed solution still applies now
that there are separate 'validation' and 'action' callbacks (as of S2_3), so
it should be a simple matter of doing this in a new action callback.

book also laments in RT#40399
> Subject: Timeout change does not take effect immediately :(
> While testing I found to my horror that that timeout
> setting behaviour has been changed in 2.1+ to only
> take effect after the turn changes. This is very very
> bad for multiplayer games, since often a turn needs
> to be extended immediately to handle something (e.g.
> a player connection is lost, or someone needs a pause
> due to the telephone, etc.).
> I strongly suggest that this behaviour be changed back
> to how it worked in 2.0.

I think the attached patch addresses all this. Notes:
* If the timeout is reduced, or changed from disabled ("infinite") to
enabled, it will be counted from when the current turn started, and so may be
in the past, in which case it will end immediately.
** An alternative implementation avoiding this behaviour would be to restart
the timeout timer whenever '/set timeout' was accepted.
** The S2_0 behaviour was, in effect, to reset the timer only on transitions
from disabled to enabled (by continually restarting the equivalent of
phase_timer whenever timeout=0). I haven't implemented this.
* Any effects that modified the timeout from its original setting, such as
"timeoutincrease" or "timeaddenemymove", will be lost.
* I tested it with voting (after pepeto's concern) and it seemed to work.

(file #13000)

Additional Item Attachment:

File name: trunk-S2_3-timeout-immediate.diff Size:3 KB


Reply to this item at:


  Message sent via/by Gna!

Freeciv-dev mailing list

Reply via email to