Issue information

Issue ID
#419
Status
Fixed
Severity
Fair
Started
Hercules Elf Bot
Nov 16, 2007 12:44
Last Post
Ind
Apr 16, 2013 6:47
Confirmation
N/A

Hercules Elf Bot - Nov 16, 2007 12:44

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

(originally reported in this topic)

I found a case of an incorrectly placed npc: its coordinates were outside of the map's dimensions.
Problem is that the code doesn't handle this situation very well...

CODE
nd->n = map_addnpc(m, nd);
status_change_init(&nd->bl);
unit_dataset(&nd->bl);
nd->ud.dir = dir;
npc_setcells(nd);
map_addblock(&nd->bl); <- this fails

So first it creates the npc, adds it to various databases, adds it to the map's npc list, deploys its trigger area,
and afterwards tries to attach the npc to a specific map square (returning '1'). No warnings whatsoever.
I suggest at least adding an 'if' here to report "invalid map or map coordinates".

The point of concern is that when doing @reloadscript, npc_remove_map() does "if(nd->bl.prev == NULL) return 1;", and doesn't remove the npc from the list. We then get npcs that don't get removed, and a followup warning message in the mapserver console.

This post has been edited by theultramage: Nov 20 2007, 11:15 AM

Ind - Apr 16, 2013 6:47

Fixed in [url="https://github.com/HerculesWS/Hercules/commit/c653a703757acc13edbff5a2624c16df74cca4f1"]https://github.com/HerculesWS/Hercules/commit/c653a703757acc13edbff5a2624c16df74cca4f1[/url]