[comp.sources.games.bugs] umoria bug

cjs@moncsbruce.oz (Chris Stuart) (04/04/88)

There is a bug in the file generate.c, in the procedure vault_trap.
The fourth argument in the call to place_trap should be between
0 and MAX_TRAP-1. You should subtract 1 from the result of the randint
call.

Original source extract:

      do
	{
	  y1 = y - yd - 1 + randint(2*yd+1);
	  x1 = x - xd - 1 + randint(2*xd+1);
	  c_ptr = &cave[y1][x1];
	  if ((c_ptr->fval > 0) && (c_ptr->fval < 8) && (c_ptr->fval != 3))
	    if (c_ptr->tptr == 0) 
	      {
		place_trap(y1, x1, 1, randint(MAX_TRAPA));
		flag = TRUE;
	      }
	  count++;
	}
      while ((!flag) && (count <= 5));

Correction:

      do
	{
	  y1 = y - yd - 1 + randint(2*yd+1);
	  x1 = x - xd - 1 + randint(2*xd+1);
	  c_ptr = &cave[y1][x1];
	  if ((c_ptr->fval > 0) && (c_ptr->fval < 8) && (c_ptr->fval != 3))
	    if (c_ptr->tptr == 0) 
	      {
		place_trap(y1, x1, 1, randint(MAX_TRAPA)-1);
		flag = TRUE;
	      }
	  count++;
	}
      while ((!flag) && (count <= 5));