25 Mar, 2009, Igabod wrote in the 1st comment:
Votes: 0
Ok I made a few changes to the mud and now any time a player gets into a fight lasting longer than one round the mud crashes. I've tried reversing some of the changes I made recently but it appears this is something from before the recent changes and I never caught it before cause I don't make a habit of killing npc's on my Imm.

Anyway, here's the gdb results:
Starting program: /home/Brandon/mud/low4/area/merc.exe 6001
[New thread 4004.0xfac]
[New thread 4004.0xd3c]
Wed Mar 25 00:19:04 2009 :: {mReign of Legends is ready to rock on port {Y6001{x
[New thread 4004.0xff8]
Wed Mar 25 00:19:08 2009 :: Sock.sinaddr: 127.0.0.1
Wed Mar 25 00:19:34 2009 :: Igabod trying to connect.
Wed Mar 25 00:19:37 2009 :: Igabod@Comcrap has connected.
Wed Mar 25 00:19:37 2009 :: LOGIN-INFO: The first GOD has connected.
Wed Mar 25 00:19:37 2009 :: LOGIN-INFO: The first WEREWOLF has connected.

Program received signal SIGSEGV, Segmentation fault.
0x004645b8 in update_damcap (ch=0x13ed440, victim=0x15d8db4) at fight.c:1651
warning: Source file is more recent than executable.
1651 if (ch->pcdata->stats[UNI_GEN] == 1)
(gdb) bt
#0 0x004645b8 in update_damcap (ch=0x13ed440, victim=0x15d8db4) at fight.c:1651
#1 0x0046463c in damage (ch=0x13ed440, victim=0x15d8db4, dam=374, dt=1001) at fight.c:1676
#2 0x00463931 in one_hit (ch=0x13ed440, victim=0x15d8db4, dt=1001, handtype=1001) at fight.c:1232
#3 0x00461da8 in multi_hit (ch=0x13ed440, victim=0x15d8db4, dt=-1) at fight.c:643
#4 0x00461605 in violence_update () at fight.c:330
#5 0x004e1901 in update_handler () at update.c:2535
#6 0x0044e203 in game_loop_unix (control=4) at comm.c:917
#7 0x0044dc79 in main (argc=2, argv=0x11a1b68) at comm.c:497
(gdb)


fight.c:1651 in update_damcap
if ( max_dam < 1000 ) max_dam = 1000;
if (ch->pcdata->stats[UNI_GEN] == 1) <———–line in question
{
if (max_dam > 15000) max_dam = 15000;
}

else if ( max_dam > 10000 ) max_dam = 10000;
ch->damcap[DAM_CAP] = max_dam;
ch->damcap[DAM_CHANGE] = 0;
return;
}


fight.c:1676 in void damage
void damage( CHAR_DATA *ch, CHAR_DATA *victim, int dam, int dt )
{
int max_dam = ch->damcap[DAM_CAP];
bool agg_dam = FALSE;

if ( victim->position == POS_DEAD )
return;

/*
* Stop up any residual loopholes.
*/
<—————– oddly enough this blank line is 1676
if (ch->damcap[DAM_CHANGE] == 1) update_damcap(ch,victim);

if ( dam > max_dam ) dam = max_dam;

if ( victim != ch )
{
/*
* Certain attacks are forbidden.
* Most other attacks are returned.
*/
if ( is_safe( ch, victim ) )
return;
check_killer( ch, victim );


fight.c:1232 in void one_hit
if ( dt == gsn_backstab )
{
if ( IS_CLASS(ch, CLASS_DROW) )
dam *= number_range( 3, 4 );
else
dam *= number_range( 2, 3 );
}

if(dt == gsn_spiderform)dam /= 2.25;
if(dt == gsn_blinky)dam /= 2.25;
damage( ch, victim, dam, dt ); <——-line in question
tail_chain( );
if (!is_safe(ch,victim))
{
improve_wpn(ch,dt,right_hand);
improve_stance(ch);
}
return;
}


fight.c:643 in void multi_hit
if ( IS_CREATOR(ch) || IS_CLASS(ch, CLASS_MONK) )
{
if (!IS_NPC(ch))
{
unarmed = number_range(1,7);
if ( !IS_NPC(ch) && ch->cmbt[unarmed] != 0 )
{
fightaction(ch,victim,ch->cmbt[unarmed], dt, wieldtype);
}
}
}

unarmed = 0;
one_hit( ch, victim, dt, wieldtype ); <———-line in question

if ( victim == NULL || victim->position != POS_FIGHTING ) return;


I'm not sure if this is enough information to help, but if I need to post anything else lemme know. I appreciate any help I receive. Just to clarify, this is with the godwars/low4 codebase. I used my immortal character with almighty legend and generation 1 werewolf and have tested it on mortals without those same stats and had the same results.
25 Mar, 2009, Sharmair wrote in the 2nd comment:
Votes: 0
gdb said:
warning: Source file is more recent than executable.

This might explain the line number not seeming to make sense. If you change a source
file out from under the binary, the source lines printed might no longer line up. In your
case though, the call chain does seem to make sense, and the only line that seems to
miss is in the function with the highest line numbers (if lines were deleted or added, it
would mess up the line sync only after the added/deleted lines), so I will assume the
info is valid.

As far as the crash, your code uses pcdata, but I don't see where you are validating that
ch is in fact a PC (and therefor has a valid pcdata you can dereference). Remember, ch
is the mob in this case when the mob is doing the hitting.
25 Mar, 2009, Igabod wrote in the 3rd comment:
Votes: 0
The only reason it says the source is more recent is because I do coding offline and the time on my machine is different than the time on the server. Though I've done a clean compile since the last code upload so that message shouldn't be showing up.

As for that last bit, which part of the code are you talking about? In update_damcap? If that's what you mean then I'm thinking the following would fix the problem:

if (!IS_NPC(ch) && (ch->pcdata->stats[UNI_GEN] == 1))
{
if (max_dam > 15000) max_dam = 15000;
}

else if ( max_dam > 10000 ) max_dam = 10000;
ch->damcap[DAM_CAP] = max_dam;
ch->damcap[DAM_CHANGE] = 0;
return;
}


Is this what you meant? Or is there a better way of doing this that doesn't rely on a compound if? (by compound if I mean more than one variable, don't know if that's an actual term or not but I like it)

[edit to add] I made those changes and that fixed it, thanks again Sharmair. If this weren't a Diku deriv I'd have to pay you for all the help you've given me lately.
25 Mar, 2009, Kline wrote in the 4th comment:
Votes: 0
Any time you reference pcdata always check for !IS_NPC(). I've had more than one embarrassing crash due to that before :)
25 Mar, 2009, Igabod wrote in the 5th comment:
Votes: 0
well there is an !IS_NPC check in that function and I thought I was still inside it, but that portion is closed right above the lstatus bonuses.
0.0/5