Page 1 of 1

[FIXED]Crash EQ2Emu :p

Posted: Thu Feb 23, 2012 11:25 am
by alfa
Using SF client, testing some bow trick, I have try to unequip bow and range attack. No action, no message, no response from server when I try to equip bow or view stat of a new item.

Maybe crash cause by range attack calculation whitout stat :p

Re: Crash EQ2Emu :p

Posted: Fri Feb 24, 2012 7:51 am
by John Adams
Definitely a crash, and in the damn LogWrite again. SCAT!

Why is this wrong?

Code: Select all

if(fighter->IsPlayer())
{
	weapon = ((Player*)fighter)->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
	ammo = ((Player*)fighter)->GetEquipmentList()->GetItem(EQ2_AMMO_SLOT);
	LogWrite(COMBAT__DETAIL, "Combat", "Weapon '%s', Ammo '%s'", weapon->name.c_str(), ammo->name.c_str());
}
Not only is COMBAT__DETAIL off, but the name's are c_str()'d so why is this crashing world?

Commenting out for now.

Edit: Ohhh.... if Alfa unequipped both weapon and ammo, there would be no values. Is this the issue? and, would this fix it?

Code: Select all

LogWrite(COMBAT__DETAIL, "Combat", "Weapon '%s', Ammo '%s'", ( weapon )? weapon->name.c_str() : "None", ( ammo ) ? ammo->name.c_str() : "None");

But, the more important question:
Why is this logger crashing when COMBAT__DETAIL is disabled?

Re: Crash EQ2Emu :p

Posted: Sat Feb 25, 2012 6:00 pm
by Scatman
Yes thats the appropriate fix. Not sure why its crashing there. Im stuck in philly this weekend moving my girlfriend to a new apartment and painting and all that jazz so i will get to it on monday.

Re: Crash EQ2Emu :p

Posted: Sun Feb 26, 2012 10:30 am
by John Adams
I've already fixed and committed it. Hoping Alfa will try that action to see if he can get it to crash again.

Scat, you know the rules on "no girlfriends", they are a detriment to EQ2Emulator's progress ;)

Re: Crash EQ2Emu :p

Posted: Sun Feb 26, 2012 11:14 am
by alfa
Well it seem to be ok

Re: Crash EQ2Emu :p

Posted: Sun Feb 26, 2012 10:15 pm
by Scatman
John Adams wrote:I've already fixed and committed it. Hoping Alfa will try that action to see if he can get it to crash again.

Scat, you know the rules on "no girlfriends", they are a detriment to EQ2Emulator's progress ;)
Yes i know. I keep her locked in the basement but as a x4 raid mob she escaped and i couldnt take her down solo :(

Re: Crash EQ2Emu :p

Posted: Tue Feb 28, 2012 12:59 pm
by John Adams
Scatman wrote:Yes i know. I keep her locked in the basement but as a x4 raid mob she escaped and i couldnt take her down solo :(
Noob.

Re: Crash EQ2Emu :p

Posted: Tue Feb 28, 2012 6:45 pm
by Scatman
This was crashing because even though COMBAT__DETAIL is disabled, you're still trying to access a function of a NULL object. So since the variable 'ammo' was null, calling c_str() on a NULL pointer resulted in a crash. This is because it needs to call c_str() before LogWrite() can even get called, so it never even got into the LogWrite() function.

So adding the check for ammo==NULL is the appropriate and only fix we need here.