Re: About the gtetrinet tetrinet_sendfield patch



I see the problem. I wasn't counting bangs. I'm mexico costing about $5/min for 
inet access. Here is a patch. Sorry for the inconvience.

void tetrinet_sendfield (int reset)
{
  int x, y, i, d = 0; /* d is the number of differences */
  char buf[1024], *p;

  /* Each difference is two bytes, each block needs a marker */
  char diff_buf[15][FIELDWIDTH * FIELDHEIGHT * 2 + 1] = {0};

  int row_count[15] = {0};

  g_snprintf (buf, sizeof(buf), "%d ", playernum);

  if(!reset) {
    /* Find out which blocks changed, how, and how many */
    for (y = 0; y < FIELDHEIGHT; y++) {
      for (x = 0; x < FIELDWIDTH; x++) {
        const int block = fields[playernum][y][x];

        if (block != sentfield[y][x]) {
          diff_buf[block][++row_count[block]] = x + '3';
          diff_buf[block][++row_count[block]] = y + '3';

        } /* if != sentfield */
      } /* for FIELDWIDTH */
    } /* for FIELDHEIGHT */

    /* Count the difference INCLUDING block start markers */
    for(i=0; i < 15; ++i) if(row_count[i]) d += row_count[i] + 1;

    if (d == 0) return; /* no differences */

  } /* if(!reset) */

  if (reset || d >= FIELDHEIGHT*FIELDWIDTH) {
    /* sending entire field is more efficient */
    p = buf + 2;
    for (y = 0; y < FIELDHEIGHT; y ++)
      for (x = 0; x < FIELDWIDTH; x ++)
        *p++ = blocks[(int)fields[playernum][y][x]];
    *p = 0;
  } /* if reset or big difference */
  else {
    /* Difference is small, now we create the buffer strings */
    for(i = 0; i < 15; ++i) {
      if(row_count[i]) {
        diff_buf[i][0] = '!' + i;
        GTET_O_STRCAT (buf, diff_buf[i]);
      } /* if row_count */
    } /* for */
  } /* else */


  /* send it */
  client_outmessage (OUT_F, buf);
  /* update the one in our memory */
  copyfield (sentfield, fields[playernum]);
}


> Hi Ian
> 
> I'm one of the GTetrinet developers. After applying your patch, we're
> seeing some weird behaviour from GTetrinet. Sometimes we just get kicked
> from the server when we're playing. The reason is always the same:
> 
> Slot(bocata): Bailout error on field update!!Mar  2 19:35:54 Broken
> client from bocata (ffff:ffff:ec16::)
> 
> We haven't tracked down this bug yet, mainly because it only happens
> from time to time :( I was playing for 3 hours yesterday, and it kicked
> me 3 only 3 times, so it's hard to hit it. It seems to happen mostly
> when there is a great movement in your field, i.e. when someone fires a
> Q or a S at you.
> 
> So, we can't blame anyone for now :) but we want you to do a quick
> review of your patch, the reason of the kick seems to point to your code
> (Bailout error on field update) but we aren't sure.
> 
> Please, review your patch and let us know, maybe you've been hit by the
> same bug, if you've been playing with your patch applied. If not, let us
> know too :) Oh, and please answer to the GTetrinet mailing list
> (gtetrinet-list gnome org)
> 
> Bye
> -- 
> // By Daniel Carbonell Fraj, mamón itinerante
> // Public GnuPG key  $ gpg --recv-keys --keyserver wwwkeys.pgp.net 73D91D7E
> 
> #include <gnome.h>
> 
> gtk_widget_hide (GTK_WIDGET (this_email));
> gtk_widget_destroy (GTK_WIDGET (this_email));
> 



---------------------------------------------
http://www.valuenet.net





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]