Re: BUG report

From: Herbert Kremser (kremser@flinux.tu-graz.ac.at)
Date: 08/18/95


On Fri, 18 Aug 1995, Sammy wrote:

> On Thu, 17 Aug 1995, Daniel W. Burke wrote:
> 
> > hmm..... what's the number range for sh_int?   if it's not that high, 
> > 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.

There are no standard values for int or short int in C.
All a C-Compiler has to do is

sizeof(short int) <= sizeof(int) <= sizeof(long int)

So if for instance int is 16 bit, short int can be 16 bit too, etc. etc.
Taking the average machines, circle muds usually run on (32-bit machines),
most compilers use short as 16 bit, int as 32 bit, and long also as 32bit.
DEC Alphas for instance (64bit machines) already use 64 bit long ints.
If you have a PC with DOS, many compilers though only handle it as a
16bit machine, thus int will be just 16 bits. Not sure if the circle
codes rely on 32bits int, but i'm not the one who is going to find out. :)

So you can see, there is absolute no standard on the size of ints.

> unsigned part has me a little puzzled, but since negative values are used 
> in the code, that sign has to come from somewhere, so knock off one more 
> bit for the sign.  What you've got left is 7 bits for a maximum value of 
> 127 before you run into negative values.

the 8 bit ints in circle muds are defined as sbyte, not sh_int.

> 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 pfiles...ugh).
> 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 is 
> correct.

I don't think the bug, as stated in the original post, is caused by duration,
it's rather the modifier, and the ability self.  (Str is defined as sbyte
in circle mud).
Modifier shouldn't be a problem, but if you have too many str items
the str itself can get out of bound.
So you have to put the check into affect_modify where it says

  case APPLY_STR:
    GET_STR(ch) += mod;
    break;

and all similar affections.

Herbert

[on public request 12 lines of signature deleted]  *snip* ;)



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