summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/clif.c3
-rw-r--r--src/map/npc.c9
-rw-r--r--src/map/pc.h1
-rw-r--r--src/map/script.c3
4 files changed, 15 insertions, 1 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index eab61ca4e..26de41816 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -8671,6 +8671,9 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
instance_check_idle(map[sd->bl.m].instance_id);
}
sd->state.debug_remove_map = 0; // temporary state to track double remove_map's [FlavioJS]
+
+ // reset the callshop flag if the player changes map
+ sd->state.callshop = 0;
map_addblock(&sd->bl);
clif_spawn(&sd->bl);
diff --git a/src/map/npc.c b/src/map/npc.c
index 3eb92dcf6..3a8ea376f 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1174,8 +1174,15 @@ int npc_buysellsel(struct map_session_data* sd, int id, int type)
}
if (nd->sc.option&OPTION_INVISIBLE) // 無効化されている
return 1;
+ if( nd->class_ < 0 && !sd->state.callshop )
+ {// not called through a script and is not a visible NPC so an invalid call
+ return 1;
+ }
+
+ // reset the callshop state for future calls
+ sd->state.callshop = 0;
+ sd->npc_shopid = id;
- sd->npc_shopid=id;
if (type==0) {
clif_buylist(sd,nd);
} else {
diff --git a/src/map/pc.h b/src/map/pc.h
index 16c31e69c..39e38bc34 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -135,6 +135,7 @@ struct map_session_data {
unsigned int vending : 1;
unsigned int noks : 3; // [Zeph Kill Steal Protection]
unsigned int changemap : 1;
+ unsigned int callshop : 1; // flag to indicate that a script used callshop; on a shop
short pmap; // Previous map on Map Change
unsigned short autoloot;
unsigned short autolootid; // [Zephyrus]
diff --git a/src/map/script.c b/src/map/script.c
index ea8e26c23..88380af29 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -13816,6 +13816,9 @@ BUILDIN_FUNC(callshop)
if( nd->subtype == SHOP )
{
+ // flag the user as using a valid script call for opening the shop (for floating NPCs)
+ sd->state.callshop = 1;
+
switch( flag )
{
case 1: npc_buysellsel(sd,nd->bl.id,0); break; //Buy window