HerculesWS/Hercules — pull request #45 by MishimaHaruna (2013-06-20 02:21:26+00:00)
Title: Fixed an unsafe TBL_PC* cast in battle_calc_elefix

This would cause a mapserver crash whenever the function was called by a monster attack.
The issue was introduced in 03956104

The crash was very frequent when fighting against MvPs (i.e. tested on Eddga,) and only in pre-renewal mode.

battle_calc_base_damage checks for (!sd) to figure out whether it is a mob or a PC, and passing a TBL_MOB* cast to TBL_PC* (valid, non NULL pointer) would cause the PC check to pass, and then a segmentation fault when trying to access sd->inventory_data[sd->equip_index[type]])