PDA

View Full Version : A crash, a terrible crash!


KLS
10-14-2006, 03:26 PM
I >>believe<< I've found the crash that has plagued the poor 60+ EQemu monks of Norrath.

Took me forever to reproduced it under my own compile and pinpoint it.. yet now it seems so utterly obvious, and I'm kicking myself for skipping over it so many times.

Little background on the bug, sometimes when a monk kills something the zone will crash, only happens to monks with triple attack aka 60+.

What I believe is happening is the target is dying betweek the normal attacks and the triple attacks and so attack is getting called with a null pointer. What's also happening is mlog COMBAT__ATTACKS is on when this happens.

Here's the code that I think needs fixed:

bool Client::Attack(Mob* other, int Hand, bool bRiposte)
{
mlog(COMBAT__ATTACKS, "Attacking %s with hand %d %s", other->GetName(), Hand, bRiposte?"(this is a riposte)":"");

//SetAttackTimer();
if (
(IsCasting() && GetClass() != BARD)
|| other == NULL
|| ((IsClient() && CastToClient()->dead) || (other->IsClient() && other->CastToClient()->dead))
|| (GetHP() < 0)
|| (!IsAttackAllowed(other))
) {
mlog(COMBAT__ATTACKS, "Attack canceled, invalid circumstances.");
return false; // Only bards can attack while casting
}


Notice how mlog is being called BEFORE we check if other is NULL. And acting on null like it exists.. ie potential crash.

Change the first mlog to:

mlog(COMBAT__ATTACKS, "Attacking %s with hand %d %s", other?other->GetName():"NOBODY", Hand, bRiposte?"(this is a riposte)":"");

or move it below the check if the pointer is NULL

Thanks to John for telling me about it and giving me the info to fix it. Haven't crashed since I changed that line of code, so hopefully this fixes the problem.

And yeah pretty sure it solved something, an excerpt from my console after I applied this fix.

[Debug] [COMBAT__ATTACKS] Sara: Attacking froglok_jin_shaman08 with hand 13
[Debug] [COMBAT__ATTACKS] Sara: Attacking with weapon: Big Soul Devourer (11000)

[Debug] [COMBAT__ATTACKS] Sara: Attacking with Big Soul Devourer in slot 13 usin
g skill 1
[Debug] [COMBAT__ATTACKS] Sara: Attacking froglok_jin_shaman07 with hand 13
[Debug] [COMBAT__ATTACKS] Sara: Attacking with weapon: Big Soul Devourer (11000)

[Debug] [COMBAT__ATTACKS] Sara: Attacking with Big Soul Devourer in slot 13 usin
g skill 1
[Debug] [COMBAT__ATTACKS] Sara: Attacking froglok_jin_shaman07 with hand 13 (thi
s is a riposte)
[Debug] [COMBAT__ATTACKS] Sara: Attacking with weapon: Big Soul Devourer (11000)

[Debug] [COMBAT__ATTACKS] Sara: Attacking with Big Soul Devourer in slot 13 usin
g skill 1
[Debug] [COMBAT__ATTACKS] Sara: Attacking NOBODY with hand 13...

John Adams
10-17-2006, 12:44 AM
If this is the fix, I will need a photo of you to put on my wall to worship. :) :) Thanks for taking the time to look into it. I can't wait to try it out!