summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgumi <git@gumi.ca>2018-03-03 17:28:42 -0500
committergumi <git@gumi.ca>2018-03-03 17:28:42 -0500
commit60aad92539fa33c2bd63e683628bd29978c17e0e (patch)
treeef601c2af7b08b7bebb80db15a1b869436c7ceed
parent3a574aaf1b78b08fe3a4ffe99b32c58a81c312d6 (diff)
downloadtmwa-60aad92539fa33c2bd63e683628bd29978c17e0e.tar.gz
tmwa-60aad92539fa33c2bd63e683628bd29978c17e0e.tar.bz2
tmwa-60aad92539fa33c2bd63e683628bd29978c17e0e.tar.xz
tmwa-60aad92539fa33c2bd63e683628bd29978c17e0e.zip
don't blindly trust event npc name
-rw-r--r--src/map/npc.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/map/npc.cpp b/src/map/npc.cpp
index 531ad28..3388ea1 100644
--- a/src/map/npc.cpp
+++ b/src/map/npc.cpp
@@ -579,7 +579,14 @@ int npc_event(dumb_ptr<map_session_data> sd, NpcEvent eventname,
{
if (!eventname.label && eventname.npc && sd)
{
- ev.nd = npc_name2id(eventname.npc)->is_script();
+ dumb_ptr<npc_data> fnd = npc_name2id(eventname.npc);
+ if (fnd == nullptr)
+ {
+ PRINTF("npc_event: NPC not found when calling event [%s]\n"_fmt,
+ eventname.npc);
+ return 0;
+ }
+ ev.nd = fnd->is_script();
ev.pos = 0; // start from the beginning of a npc
}
else