I'm using SocketMUD and I seem to be having an issue with random_range. It crashes:
I have no idea why number is that high. It shouldn't go past 5.
The whole random.c file can be found here:
http://www.daimi.au.dk/~jobo/socketmud/download/snippets/random.tar.gz
Anyone know why it's such a high number? My fact_table has 5 facts so it should go up to only 5.
This doesn't happen everytime. About 1 in 10 times.
(gdb) f 4
#4 0x0804fe46 in pre_battle (acct=0xbfffe680, arg=0x80512b8 "") at battle.c:259
259 sprintf ( buf3, "Interesting fact #%d: %s", number+1, fact_table[number].text );
(gdb) p number
$1 = 544501582 number = random_range( 0, MAX_FACTS);
sprintf ( buf3, "Interesting fact #%d: %s", number+1, fact_table[number].text );
communicate(acct, buf3, COMM_INFO);#define MAX_FACTS 5I have no idea why number is that high. It shouldn't go past 5.
/* returns a random number between a and b */
int random_range(int a, int b)
{
return ((int)(rand_seed() * ((double) (b) - (a) + 1))) + (a);
}The whole random.c file can be found here:
http://www.daimi.au.dk/~jobo/socketmud/download/snippets/random.tar.gz
Anyone know why it's such a high number? My fact_table has 5 facts so it should go up to only 5.
This doesn't happen everytime. About 1 in 10 times.