summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-11-09 19:56:50 -0800
committerBen Longbons <b.r.longbons@gmail.com>2014-11-09 19:58:49 -0800
commit2f90b3a569c9627f0fa56ed282a33b596f0026f3 (patch)
treeada9ce73b798b18596c3225d250087fc70f56489 /src
parentf5db6b09fb461d7bb60ff443d603bb10820d5f14 (diff)
downloadtmwa-2f90b3a569c9627f0fa56ed282a33b596f0026f3.tar.gz
tmwa-2f90b3a569c9627f0fa56ed282a33b596f0026f3.tar.bz2
tmwa-2f90b3a569c9627f0fa56ed282a33b596f0026f3.tar.xz
tmwa-2f90b3a569c9627f0fa56ed282a33b596f0026f3.zip
Add explicit check for mapless events
Diffstat (limited to 'src')
-rw-r--r--src/map/map.hpp1
-rw-r--r--src/map/npc-parse.cpp3
-rw-r--r--src/map/npc.cpp7
3 files changed, 7 insertions, 4 deletions
diff --git a/src/map/map.hpp b/src/map/map.hpp
index 14ea6a7..fc48126 100644
--- a/src/map/map.hpp
+++ b/src/map/map.hpp
@@ -357,6 +357,7 @@ public:
std::unique_ptr<const ScriptBuffer> script;
// Diameter.
short xs, ys;
+ bool event_needs_map;
// Whether the timer advances if not beyond end.
bool timer_active;
diff --git a/src/map/npc-parse.cpp b/src/map/npc-parse.cpp
index 2bd801d..8b47502 100644
--- a/src/map/npc-parse.cpp
+++ b/src/map/npc-parse.cpp
@@ -440,6 +440,7 @@ bool npc_load_script_none(ast::script::ScriptBody& body, ast::npc::ScriptNone& s
dumb_ptr<npc_data_script> nd;
nd.new_();
+ nd->scr.event_needs_map = false;
nd->name = script_none.name.data;
@@ -535,6 +536,7 @@ bool npc_load_script_map_none(ast::script::ScriptBody& body, ast::npc::ScriptMap
dumb_ptr<npc_data_script> nd;
nd.new_();
+ nd->scr.event_needs_map = false;
nd->name = script_map_none.name.data;
@@ -667,6 +669,7 @@ bool npc_load_script_map(ast::script::ScriptBody& body, ast::npc::ScriptMap& scr
nd->scr.xs = xs;
nd->scr.ys = ys;
+ nd->scr.event_needs_map = true;
}
nd->name = script_map.name.data;
diff --git a/src/map/npc.cpp b/src/map/npc.cpp
index 304224a..90ac917 100644
--- a/src/map/npc.cpp
+++ b/src/map/npc.cpp
@@ -465,7 +465,6 @@ int npc_event(dumb_ptr<map_session_data> sd, NpcEvent eventname,
{
Option<P<struct event_data>> ev_ = ev_db.search(eventname);
dumb_ptr<npc_data_script> nd;
- int xs, ys;
if (sd == nullptr)
{
@@ -490,10 +489,10 @@ int npc_event(dumb_ptr<map_session_data> sd, NpcEvent eventname,
return 0;
}
- xs = nd->scr.xs;
- ys = nd->scr.ys;
- if (xs >= 0 && ys >= 0)
+ if (nd->scr.event_needs_map)
{
+ int xs = nd->scr.xs;
+ int ys = nd->scr.ys;
if (nd->bl_m != sd->bl_m)
return 1;
if (xs > 0