Issue information

Issue ID
#4470
Status
Fixed
Severity
Low
Started
Hercules Elf Bot
Oct 7, 2010 1:35
Last Post
Hercules Elf Bot
Oct 7, 2010 1:35
Confirmation
N/A

Hercules Elf Bot - Oct 7, 2010 1:35

Originally posted by [b]Ai4rei[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=4470

This is an ancient bug, which is in since pre-svn, and has even been rewritten, keeping the bug "intact".

CODE
/*==========================================
* RID?????
*------------------------------------------*/
BUILDIN_FUNC(attachrid)
{
    st->rid=script_getnum(st,2);
    script_pushint(st,(map_id2sd(st->rid)!=NULL));
    return 0;
}


First the code sets st->rid to the first attachrid parameter and then pushes the return value depending on the result of map_id2sd, which even when the rid is invalid, does not reset sd->rid again.

Suggested solution:
CODE
/*==========================================
* RID?????
*------------------------------------------*/
BUILDIN_FUNC(attachrid)
{
    int rid = script_getnum(st,2);

    if(map_id2sd(rid))
    {
        st->rid = rid;
        script_pushint(st,1);
    }
    else
    {
        script_pushint(st,0);
    }
    return 0;
}


attachrid-fix.diff (0.5K)

This post has been edited by Ai4rei: Oct 8 2010, 12:06 PM