From 2f90b3a569c9627f0fa56ed282a33b596f0026f3 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sun, 9 Nov 2014 19:56:50 -0800 Subject: Add explicit check for mapless events --- src/map/map.hpp | 1 + src/map/npc-parse.cpp | 3 +++ src/map/npc.cpp | 7 +++---- 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 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 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 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 sd, NpcEvent eventname, { Option> ev_ = ev_db.search(eventname); dumb_ptr nd; - int xs, ys; if (sd == nullptr) { @@ -490,10 +489,10 @@ int npc_event(dumb_ptr 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 -- cgit v1.2.3-70-g09d2