Re: About the gtetrinet tetrinet_sendfield patch



Hey,

Sorry. I've been in Cancun, Mexico for the last week on spring break.
When I got your email I took a look and discovered in fact I wasn't
counting the !'s like someone else already discovered. I hit reply and
sent the patch but apparently it caught in moderator approval and I
didn't get back online to see it had bounced ($5/min from Mexico). I
basically wrote the same patch that is already applied. I've pasted the
version I wrote below. However, if the current version works, no real
reason to change it. I also figured out I was allocating about 26 too
many bytes into the diff_buf, but that's hardly a big deal. I'm sorry
for the inconvenience.

Ian

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]);
}


On Mon, 2003-03-03 at 10:58, Dani Carbonell wrote:
> 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
-- 
/***
 * Ian Zink				www.z4ce.com
 * Engineer Maryville Technologies	www.maryville.com 
 * Student Washington University  	www.wustl.edu 
 *
 * How could I ever save the world on cup-o-soup 
 * and student loans?
 *					- FiF 
 ***/




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