Re: BUG report

From: Daniel W. Burke (
Date: 08/18/95

>On Thu, 17 Aug 1995, Daniel W. Burke wrote:
>> same for detect invis potions also.... appears to be a general bug 
>> durations......
>> hmm..... what's the number range for sh_int?   if it's not that 
>> the when it hits the limit it will go negative..... maybe for 
>> duration's a MAX duration has to be defined somewhere....
>sh_int is typedef'ed as an unsigned short integer.  I'm no C guru so I 

>don't know exactly what this will look like in practice, but if you 
>assume an integer is 16 bits, then a short int would be 8 bts.  The 
>unsigned part has me a little puzzled, but since negative values are 
>in the code, that sign has to come from somewhere, so knock off one 
>bit for the sign.  What you've got left is 7 bits for a maximum value 
>127 before you run into negative values.
>Solution?  Setting a max duration as stated above seems to be the best 

>way to handle it.  You could also make duration a regular int, though 
>this may cause problems (I believe you'd have to change the 
>Setting a limit wouldn't be tough.  Just add a little routine in like:
>if (duration < -1) duration = 127;
>That would take advantage of the fact that 127 + 1 = -128 if my theory 

I'm not sure about 127 being the positive limit.... I seem to remember 
seeing durations around 200.....

This archive was generated by hypermail 2b30 : 12/18/00 PST