View Single Post
Old January 9, 2011, 11:25   #1
pampl
RePosBand maintainer
 
Join Date: Sep 2008
Location: Seattle, WA, USA
Posts: 225
pampl is on a distinguished road
Possible off-by-one-error in PR_STATE

I didn't want to post this on the bug tracker yet because I'm a newbie programmer so I'm not sure whether this is my fault or a quirk in Angband. Anyway, in xtra3.c there's a function which draws in the player's state at the bottom of the screen. I modified it so that they player will always display as blessed and heroic when a certain condition is true (when they've killed the "standard bearer" monster for their species):
Code:
static size_t prt_tmd(int row, int col)
{
	size_t i, len = 0;

	for (i = 0; i < N_ELEMENTS(effects); i++)
	{
		/* If the player is the standard bearer, always display as blessed and heroic */
		if (p_ptr->timed[effects[i].value] || (((i == TMD_BLESSED) || (i == TMD_HERO)) && (p_ptr->standard_bearer)))
		{
			c_put_str(effects[i].attr, effects[i].str, row, col + len);
			len += effects[i].len;
		}
	}

	return len;
}
TMD_BLESSED works like it's supposed to but TMD_HERO displays Berserk.. one higher on the enumeration list. That off-by-oneness continues until TMD_STONESKIN, which doesn't display anything. I tried earlier values, like TMD_PROTEVIL, and they were off by two!

The thing is, the display seems to work fine in V, so I don't see how this bug could exist if it weren't for me introducing it. OTOH, I don't see how I could have introduced it.
pampl is offline   Reply With Quote