Re: Seg. fault, multi-attack

From: Pooge (
Date: 09/21/95

>Now, if I start a fight on the SunOS mashine I get some combat messages, 
>and then the mud crashes... 
>when using gdb it said it crashed in line 765 of the fight.c code... 
>this is in the hit() procedure... 
> (line 765:)    if (ch->in_room != victim->in_room) {
>                  if (FIGHTING(ch) && FIGHTING(ch) == victim)
>                     stop_fighting(ch);
>                     return;
>This is as far as I could trace the bug... it seems as if the problem 
>arises when the ch->in_room  ot victim->in_room is evaluated... but on 
>the other hand, if this is the case it should crash on both mashines... 

I faced the exact same problem in my MUD when I added multi-hit.  The
problem is that there is a possiblility of killing the mob with one hit and
then attacking it again with the second.  Since the mob is NULL at the time
of the second hit, accessing an element of a NULL pointer causes a crash
simply add a check such as:

if (!ch || !victim)
before the ch->in_room check 

Hope this helps! :)

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