Kenny1337 8 Posted August 2, 2017 Share Posted August 2, 2017 sysser/syslog is clear core: #0 0x0807c84c in CHARACTER::BroadcastTargetPacket (this=0x301dc800) at char.cpp:5239 p = {header = 63 '?', dwVID = 4672, bHPPercent = 0 '\0'} it = {<std::tr1::__detail::_Hashtable_iterator_base<CHARACTER*,false>> = {_M_cur_node = 0xbfbf9df8, _M_cur_bucket = 0x82355d9}, <No data fields>} __FUNCTION__ = "BroadcastTargetPacket" #1 0x08082ce8 in CHARACTER::PointChange (this=0x301dc800, type=5 '\005', amount=-2874, bAmount=false, bBroadcast=false) at char.cpp:3284 prev_hp = 0 val = -2874 __FUNCTION__ = "PointChange" #2 0x08099011 in CHARACTER::Damage (this=0x301dc800, pAttacker=0x99101800, dam=2874, type=DAMAGE_TYPE_NORMAL) at char_battle.cpp:2293 pkSk = <value optimized out> iCriticalPct = <value optimized out> iPenetratePct = <value optimized out> iCurHP = 0 iCurSP = 0 IsCritical = false IsPenetrate = true IsDeathBlow = false #3 0x08062f62 in battle_hit (pkAttacker=0x99101800, pkVictim=0x301dc800, iRetDam=@0xbfbfa034) at battle.cpp:690 iDam = <value optimized out> pkWeapon = <value optimized out> #4 0x08063220 in battle_melee_attack (ch=0x99101800, victim=0x301dc800) at battle.cpp:165 max = 300 distance = 136 dam = 1807 ret = <value optimized out> #5 0x0809a449 in CHARACTER::Attack (this=0x99101800, pkVictim=0x301dc800, bType=0 '\0') at char_battle.cpp:227 dwCurrentTime = 823674 iRet = <value optimized out> __FUNCTION__ = "Attack" #6 0x081576e4 in CInputMain::Attack (this=0x4b3bf09c, ch=0x99101800, header=2 '\002', data=0x537dd000 "\002") at input_main.cpp:1837 victim = 0x301dc800 #7 0x0815dae5 in CInputMain::Analyze (this=0x4b3bf09c, d=0x4b3bf000, bHeader=<value optimized out>, c_pData=0x537dd000 "\002") at input_main.cpp:3219 ch = 0x99101800 iExtraLen = <value optimized out> __FUNCTION__ = "Analyze" #8 0x081466cb in CInputProcessor::Process (this=0x4b3bf09c, Link to comment Share on other sites More sharing options...
Den 46 Posted August 2, 2017 Share Posted August 2, 2017 Show your char.cpp line 5239. You probably killed a mob that respawns with 0hp. Link to comment Share on other sites More sharing options...
Kenny1337 8 Posted August 2, 2017 Author Share Posted August 2, 2017 24 minuty temu, Den napisał: Show your char.cpp line 5239. You probably killed a mob that respawns with 0hp. void CHARACTER::BroadcastTargetPacket() { if (m_set_pkChrTargetedBy.empty()) return; TPacketGCTarget p; p.header = HEADER_GC_TARGET; p.dwVID = GetVID(); if (IsPC()) p.bHPPercent = 0; else p.bHPPercent = MINMAX(0, (GetHP() * 100) / GetMaxHP(), 100); --- 5239 line CHARACTER_SET::iterator it = m_set_pkChrTargetedBy.begin(); while (it != m_set_pkChrTargetedBy.end()) { LPCHARACTER pkChr = *it++; if (!pkChr->GetDesc()) { sys_err("%s %p does not have desc", pkChr->GetName(), get_pointer(pkChr)); abort(); } pkChr->GetDesc()->Packet(&p, sizeof(TPacketGCTarget)); } } hmm, i checked mob_proto and have one monster with 0hp... vnum 0, no name etc. i removed it and will check if the problem then appear again Link to comment Share on other sites More sharing options...
Den 46 Posted August 2, 2017 Share Posted August 2, 2017 10 minutes ago, Kenny1337 said: void CHARACTER::BroadcastTargetPacket() { if (m_set_pkChrTargetedBy.empty()) return; TPacketGCTarget p; p.header = HEADER_GC_TARGET; p.dwVID = GetVID(); if (IsPC()) p.bHPPercent = 0; else p.bHPPercent = MINMAX(0, (GetHP() * 100) / GetMaxHP(), 100); --- 5239 line CHARACTER_SET::iterator it = m_set_pkChrTargetedBy.begin(); while (it != m_set_pkChrTargetedBy.end()) { LPCHARACTER pkChr = *it++; if (!pkChr->GetDesc()) { sys_err("%s %p does not have desc", pkChr->GetName(), get_pointer(pkChr)); abort(); } pkChr->GetDesc()->Packet(&p, sizeof(TPacketGCTarget)); } } hmm, i checked mob_proto and have one monster with 0hp... vnum 0, no name etc. i removed it and will check if the problem then appear again Change the condition to: if (IsPC()) p.bHPPercent = 0; else if (GetMaxHP() <= 0) p.bHPPercent = 0; else p.bHPPercent = MINMAX(0, (GetHP() * 100) / GetMaxHP(), 100); You can't divide by 0 so you'll always get a crash when mob's maxhp is 0. 1 Link to comment Share on other sites More sharing options...
Kenny1337 8 Posted August 15, 2017 Author Share Posted August 15, 2017 nevermind Link to comment Share on other sites More sharing options...
Premium North 1272 Posted August 15, 2017 Premium Share Posted August 15, 2017 On 8/2/2017 at 10:23 AM, Den said: Change the condition to: if (IsPC()) p.bHPPercent = 0; else if (GetMaxHP() <= 0) p.bHPPercent = 0; else p.bHPPercent = MINMAX(0, (GetHP() * 100) / GetMaxHP(), 100); You can't divide by 0 so you'll always get a crash when mob's maxhp is 0. you have minmax for that, you can just: i didnt dig into the problem tho, so this is to intent as a correction to him and not to a fix for the bug you have. Btw what you did is checking if getmaxhp its minor or equal to 0, then assign 0 again so the = statement even lose his effectivness. If you want to have something more than 0 on p.bHPPercent as min you have to do: p.bHPPercent = MINMAX(1, (GetHP() * 100 / GetMaxHP(), 100); And since you doing the same thing on both checks, you can also if (IsPC() || GetMaxHP() < 0) p.bHPPercent = 0; 1 Link to comment Share on other sites More sharing options...
mast210 0 Posted February 12 Share Posted February 12 I know this is old topic but shouldn't fix be like this else if (GetHP() <= 0) p.bHPPercent = 0; Instead of else if (GetMaxHP() <= 0) p.bHPPercent = 0; Because GetHP() is divided, not GetMaxHP() Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now