Issue information

Issue ID
#1615
Status
Fixed
Severity
None
Started
Hercules Elf Bot
Jun 4, 2008 9:58
Last Post
Hercules Elf Bot
Jun 4, 2008 9:58
Confirmation
N/A

Hercules Elf Bot - Jun 4, 2008 9:58

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

QUOTE
npc.c: In function `npc_touch_areanpc2':
npc.c:784: warning: 'ev' might be used uninitialized in this function

CODE
int npc_touch_areanpc2(struct mob_data *md)
{
    struct event_data* ev;
    ...
    for( i = 0; i < map[m].npc_num; i++ )
    {
        if( x >= map[m].npc[i]->bl.x-xs && x <= map[m].npc[i]->bl.x+xs && y >= map[m].npc[i]->bl.y-ys && y <= map[m].npc[i]->bl.y+ys )
        {
            if( map[m].npc[i]->subtype == SCRIPT
                && ((ev = (struct event_data*)strdb_get(ev_db, eventname)) == NULL || ev->nd == NULL) )
                continue; // No OnTouchNPC Event found

            break;
        }
    }
    ...
        case SCRIPT:
        {
            if( md->areanpc_id == map[m].npc[i]->bl.id )
                return 0; // Allready touch this NPC

            md->areanpc_id = map[m].npc[i]->bl.id;
            run_script(ev->nd->u.scr.script, ev->pos, md->bl.id, ev->nd->bl.id);

Apart from having a rather complicated structure, there is also another problem.
The exit condition in the npc-searching loop doesn't look right. When rewritten, it would be
CODE
if( map[m].npc[i]->subtype != SCRIPT )
    break;
if( ev = (struct event_data*)strdb_get(ev_db, eventname)) != NULL || ev->nd != NULL)
    break;

continue;
why do I get the feeling that the 'script' part should have been in reverse...