Ticket #33: arend_7_8.1c.diff

File arend_7_8.1c.diff, 3.7 KB (added by arend, 6 years ago)

Fixes some buglets caused by arend_7_8.1b, most notably causing a violation of the GTP time_settings command.

  • engine/clock.c

    RCS file: /cvsroot/gnugo/gnugo/engine/clock.c,v
    retrieving revision 1.24
    diff -u -p -r1.24 clock.c
    clock_print(int color) 
    124124/* 
    125125 * Initialize the time settings for this game. 
    126126 * -1 means "do not modify this value". 
     127 * 
     128 *  byo_time > 0 and byo_stones == 0 means no time settings. 
    127129 */ 
    128130void 
    129131clock_settings(int time, int byo_time, int byo_stones) 
    clock_settings(int time, int byo_time, i 
    141143 * 0 otherwise. 
    142144 */ 
    143145int 
    144 get_clock_settings(int *t, int *byo_t, int *byo_s) 
     146have_time_settings(void) 
    145147{ 
    146   if (t) 
    147     *t = main_time; 
    148   if (byo_t) 
    149     *byo_t = byoyomi_time; 
    150   if (byo_s) 
    151     *byo_s = byoyomi_stones; 
    152   return (main_time >= 0 || byoyomi_time >= 0); 
     148  /* According to the semantics of the GTP command 'time_settings', the 
     149   * following signifies no time limits. 
     150   */ 
     151  if (byoyomi_time > 0 && byoyomi_stones == 0) 
     152    return 0; 
     153  else 
     154    return (main_time >= 0 || byoyomi_time >= 0); 
    153155} 
    154156 
    155157 
    update_time_left(int color, int time_lef 
    182184    = ((color == BLACK) ? &black_time_data : &white_time_data); 
    183185  int time_used = td->official.time_left - time_left; 
    184186 
     187  if (time_left > 0) 
     188    td->time_out = 0; 
     189  else  
     190    td->time_out = 1; 
     191 
    185192  /* Did our estimate for time usage go wrong? */ 
    186193  if (time_used > 0 
    187194      && gg_abs(time_used - td->estimated.time_for_last_move) >= 1.0) 
    update_time_left(int color, int time_lef 
    193200    td->estimated.time_left = time_left; 
    194201  if (stones > 0) 
    195202    td->estimated.in_byoyomi = 1; 
     203  else 
     204    td->estimated.in_byoyomi = 0; 
    196205 
    197206  td->official.stones = stones; 
    198207  td->official.movenum = movenum; 
    clock_push_button(int color) 
    213222    = (color == BLACK) ? &black_time_data : &white_time_data; 
    214223  double now = gg_gettimeofday(); 
    215224 
     225  if (!have_time_settings()) 
     226    return; 
     227 
    216228  if (last_movenum >= 0 
    217229      && movenum == last_movenum + 1 
    218230      && movenum > td->estimated.movenum) { 
    analyze_time_data(int color, double *tim 
    274286                       : &white_time_data.estimated; 
    275287 
    276288  /* Do we have any time limits. */ 
    277   if (!get_clock_settings(NULL, NULL, NULL)) 
     289  if (!have_time_settings()) 
    278290    return 0; 
    279291 
    280292  /* If we don't have consistent time information yet, just return. */ 
  • engine/clock.h

    RCS file: /cvsroot/gnugo/gnugo/engine/clock.h,v
    retrieving revision 1.12
    diff -u -p -r1.12 clock.h
     
    2626#include "gnugo.h" 
    2727 
    2828/* initialization and activation */ 
    29 void clock_settings(int time, int byo_time, int byo_stones); 
     29void clock_settings(int maintyime, int byotime, int byostones); 
    3030void init_timers(void); 
    3131  
    3232/* main access */ 
    3333void clock_push_button(int color); 
    3434void update_time_left(int color, int time_left, int stones); 
    3535void clock_print(int color); 
    36 int get_clock_settings(int *t, int *byo_t, int *byo_s); 
     36int have_time_settings(void); 
    3737 
    3838void adjust_level_offset(int color); 
    3939 
  • interface/play_ascii.c

    RCS file: /cvsroot/gnugo/gnugo/interface/play_ascii.c,v
    retrieving revision 1.63
    diff -u -p -r1.63 play_ascii.c
    do_play_ascii(Gameinfo *gameinfo) 
    627627  char *tmpstring; 
    628628  int state = 1; 
    629629 
    630   if (get_clock_settings(NULL, NULL, NULL)) 
     630  if (have_time_settings()) 
    631631    clock_on = 1; 
    632632 
    633633  while (state == 1) {