viewing paste Unknown #5804 | C

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
Index: src/map/atcommand.c
===================================================================
--- src/map/atcommand.c (revision 17312)
+++ src/map/atcommand.c (working copy)
@@ -3726,10 +3726,18 @@
  *------------------------------------------*/
 ACMD_FUNC(reloadscript)
 {
+       struct s_mapiterator* iter;
+       struct map_session_data* pl_sd;
+
        nullpo_retr(-1, sd);
        //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
        //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
 
+       iter = mapit_getallusers();
+       for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
+               pc_close_npc(pl_sd,2);
+       mapit_free(iter);
+
        flush_fifos();
        map_reloadnpc(true); // reload config files seeking for npcs
        script_reload();
Index: src/map/clif.c
===================================================================
--- src/map/clif.c      (revision 17312)
+++ src/map/clif.c      (working copy)
@@ -10413,7 +10413,18 @@
        clif_npc_sell_result(sd, fail);
 }
 
+/// Close out a window because the NPC is unloaded
+void clif_NpcCloseShopList(struct map_session_data *sd)
+{
+       sd->npc_shopid = 0; //Clear shop data.
+       sd->npc_shopchoice == 0;
+       if(sd->npc_shopchoice == 1)
+               clif_npc_buy_result(sd, 3);
+       else if(sd->npc_shopchoice == 2)
+               clif_npc_sell_result(sd, 1);
+}
 
+
 /// Chatroom creation request (CZ_CREATE_CHATROOM).
 /// 00d5 <packet len>.W <limit>.W <type>.B <passwd>.8B <title>.?B
 /// type:
Index: src/map/clif.h
===================================================================
--- src/map/clif.h      (revision 17312)
+++ src/map/clif.h      (working copy)
@@ -349,9 +349,6 @@
 void clif_blown(struct block_list *bl); // area
 void clif_slide(struct block_list *bl, int x, int y); // area
 void clif_fixpos(struct block_list *bl);       // area
-void clif_npcbuysell(struct map_session_data* sd, int id);     //self
-void clif_buylist(struct map_session_data *sd, struct npc_data *nd);   //self
-void clif_selllist(struct map_session_data *sd);       //self
 void clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes);  //self
 void clif_scriptnext(struct map_session_data *sd,int npcid);   //self
 void clif_scriptclose(struct map_session_data *sd, int npcid); //self
@@ -394,6 +391,11 @@
 void clif_changechatstatus(struct chat_data* cd);      // chat
 void clif_refresh(struct map_session_data *sd);        // self
 
+void clif_npcbuysell(struct map_session_data* sd, int id);
+void clif_buylist(struct map_session_data *sd, struct npc_data *nd);
+void clif_selllist(struct map_session_data *sd);
+void clif_NpcCloseShopList(struct map_session_data *sd);
+
 void clif_fame_blacksmith(struct map_session_data *sd, int points);
 void clif_fame_alchemist(struct map_session_data *sd, int points);
 void clif_fame_taekwon(struct map_session_data *sd, int points);
Index: src/map/npc.c
===================================================================
--- src/map/npc.c       (revision 17312)
+++ src/map/npc.c       (working copy)
@@ -1287,11 +1287,14 @@
        sd->state.callshop = 0;
        sd->npc_shopid = id;
 
-       if (type==0) {
+       if(type==0) {
+               sd->npc_shopchoice = 1;
                clif_buylist(sd,nd);
        } else {
+               sd->npc_shopchoice = 2;
                clif_selllist(sd);
        }
+
        return 0;
 }
Index: src/map/pc.c
===================================================================
--- src/map/pc.c        (revision 17312)
+++ src/map/pc.c        (working copy)
@@ -6584,11 +6584,14 @@
 {
        nullpo_retv(sd);
 
-       if (sd->npc_id) {
+       if (sd->npc_id || sd->npc_shopid) {
                if (sd->state.using_fake_npc) {
                        clif_clearunit_single(sd->npc_id, CLR_OUTSIGHT, sd->fd);
                        sd->state.using_fake_npc = 0;
                }
+               if(sd->npc_shopid && sd->npc_shopchoice)
+                       clif_NpcCloseShopList(sd);
+                      
                if (sd->st) {
                        if(sd->st->state == RUN){ //wait ending code execution
                            add_timer(gettick()+500,pc_close_npc_timer,sd->bl.id,flag);
Index: src/map/pc.h
===================================================================
--- src/map/pc.h        (revision 17312)
+++ src/map/pc.h        (working copy)
@@ -202,7 +202,7 @@
        unsigned short mapindex;
        unsigned char head_dir; //0: Look forward. 1: Look right, 2: Look left.
        unsigned int client_tick;
-       int npc_id,areanpc_id,npc_shopid,touching_id; //for script follow scriptoid;   ,npcid
+       int npc_id,areanpc_id,npc_shopid,touching_id,npc_shopchoice; //for script follow scriptoid;   ,npcid
        int npc_item_flag; //Marks the npc_id with which you can use items during interactions with said npc (see script command enable_itemuse)
        int npc_menu; // internal variable, used in npc menu handling
        int npc_amount;
Viewed 469 times, submitted by unknown.