Jump to content
Maintenance ×
×
×
  • Create New...
  • 0

channel crash


Kenny1337

Question

 

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,
    [email protected]) 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

5 answers to this question

Recommended Posts

  • 0
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

  • 0
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.

  • Love 1
Link to comment
Share on other sites

  • 0
  • Premium
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;

 

  • Love 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.


  • Activity

    1. 4

      problem Dargon Soul Changre Attribute

    2. 41

      Global Chat

    3. 4

      problem Dargon Soul Changre Attribute

    4. 2

      Startup Loading Window Library

    5. 28

      Ludus2: metin2 fan project

    6. 44

      Inbuild GR2 Animation

    7. 6

      Minimap Mob proto

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.