PDA

View Full Version : Thrown weapons crash bug


BatCountry
03-08-2006, 08:12 AM
Please note this only crashes in Debug compiles of zoneperl 6.5-X

There is a problem in special_attacks.cpp:

in function Client::ThrowingAttack(Mob* other)

line 808:
DeleteItemInInventory(ammo_slot, 1, true);

Where it deletes one from a stack of ranged ammunition.

If you have only one of a type of item, you throw the item, it's deleted, then it moves on to do damage calculations.

However, it's reading from deleted memory. In debug compiles (MSVS .NET 2003) it crashes with a segmentation violation on line 855:
TryWeaponProc(RangeWeapon, target);

(tested with "a vile substance" thrown from ranged slot)

If you move lines 807 and 808
//consume ammo
DeleteItemInInventory(ammo_slot, 1, true);

to the bottom of the method or just above line 862
CheckIncreaseSkill(THROWING);

It will fix this behavior (tested).

-BatCountry
EsOEQ

fathernitwit
03-08-2006, 01:49 PM
hey, good catch. I kept seeing this crash, but never spent the time to figure out what was wrong. Change will be in CVS when I get to it.