Issue information

Issue ID
#8469
Status
Fixed
Severity
None
Started
Emistry
Dec 19, 2014 13:48
Last Post
malufett
Dec 22, 2014 13:56
Confirmation
N/A

Emistry - Dec 19, 2014 13:48

[url="https://github.com/HerculesWS/Hercules/issues/417"]https://github.com/HerculesWS/Hercules/issues/417[/url]
Latest GIT

I dont have the GDB, I am using the MSVC
[url="http://herc.ws/wiki/MSVC_Crash_Debugging"]http://herc.ws/wiki/MSVC_Crash_Debugging[/url]

this is the result i obtained when it crashed.
[img]http://i.imgur.com/TNoR52k.png[/img]

Emistry - Dec 19, 2014 13:53

When I check my previous git revision, date 20141201,
status.c[code=auto:11546] #ifdef RENEWAL if( sd && sd->right_weapon.overrefine > 0 ) { (*matk_min)++; *matk_max += sd->right_weapon.overrefine - 1; } #endif [/code]
it look like this


when updated to recent GIT, date 20141213 ~ 20141219 , same to line [b]11476[/b] ...[code=auto:11562] #ifdef RENEWAL if ( sd && !(flag & 2) ) { short index = sd->equip_index[EQI_HAND_R], refine; if ( index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == IT_WEAPON && (refine = sd->status.inventory[index].refine) < 16 && refine ) { int r = (rnd() % 100) % ((status->refine_info[sd->inventory_data[index]->wlv].randombonus_max[refine + (4 - sd->inventory_data[index]->wlv)] / 100)) + 1; st->matk_max += r / 10; } } #endif [/code]
and it get the error that shown in picture above and crashed.
Integer division by zero.

This post has been edited by Emistry on Dec 19, 2014 14:28

malufett - Dec 19, 2014 14:50

ow...1%0 leads to Integer division by zero.

:meow:

malufett - Dec 19, 2014 15:53

ok..now I'll use the code direct from aegis..seems like I failed in deriving the formula to be shorty..:P[code=auto:0] bonus = *(_DWORD *)&refineBonus[4 * (in_refiningLevel + 16 * in_weaponLevel) + 12]; result = 0; if ( bonus ) result = GetServerRandom(0, 20000) % bonus + 1; [/code]
:meow:

malufett - Dec 19, 2014 16:15

Fixed @ 772cb2b111973c0c749e505ffd2685bb67e887bd
:meow:

hemagx - Dec 19, 2014 17:21

clean one for you ? :P
[code=auto:0] private: int __thiscall CPC::AddRandomAttackPower(int in_weaponLevel, int in_refiningLevel) const { static const int rangeTable[4][16] = { 0, 0, 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 14, 28, 42, 56, 70, 84, 98, 112, 126, 140, 154, 168, 182, 196, 210, 224 }; if ( in_weaponLevel > 4 ) return 0; if ( in_refiningLevel > 16 ) return 0; int bonus = rangeTable[in_weaponLevel][in_refiningLevel]; if ( bonus == 0 ) return 0; return GetServerRandom(0, 20000) % bonus + 1; }; [/code]

Emistry - Dec 21, 2014 14:47

I think the issue still exist, later I will try compile with MSVC see if I can get any more information on this.


I experience map server crash when refined to +4.

Michi - Dec 22, 2014 12:08

Can confirm that the crash is not solved

malufett - Dec 22, 2014 13:56

oopps...sorry my bad..I over use the division,,,XD
Follow up@32a86ea5bb527ff34d0452d0fe4ede34bde9cde5

:meow: