Ver código fonte

Follow up to 4af46ba and e8b9cf0
* Ensures all instances of players disconnecting from the server has their shop removed.

aleos89 8 anos atrás
pai
commit
baa91f834c
4 arquivos alterados com 12 adições e 13 exclusões
  1. 2 6
      src/map/chrif.c
  2. 2 7
      src/map/clif.c
  3. 7 0
      src/map/map.c
  4. 1 0
      src/map/pc.h

+ 2 - 6
src/map/chrif.c

@@ -1173,13 +1173,9 @@ int chrif_disconnectplayer(int fd) {
 		return -1;
 	}
 
-	if (sd->state.vending)
-		vending_closevending(sd);
-	else if (sd->state.buyingstore)
-		buyingstore_close(sd);
-
 	if (!sd->fd) {
-		map_quit(sd);
+		if (sd->state.autotrade)
+			map_quit(sd);
 		//Else we don't remove it because the char should have a timer to remove the player because it force-quit before,
 		//and we don't want them kicking their previous instance before the 10 secs penalty time passes. [Skotlex]
 		return 0;

+ 2 - 7
src/map/clif.c

@@ -8944,13 +8944,8 @@ void clif_GM_kick(struct map_session_data *sd, struct map_session_data *tsd)
 
 	fd = tsd->fd;
 
-	if (sd) {
-		// Close vending/buyingstore
-		if (tsd->state.vending)
-			vending_closevending(tsd);
-		else if (tsd->state.buyingstore)
-			buyingstore_close(tsd);
-	}
+	if (sd == NULL)
+		tsd->state.keepshop = true;
 
 	if (fd > 0)
 		clif_authfail_fd(fd, 15);

+ 7 - 0
src/map/map.c

@@ -1958,6 +1958,13 @@ void map_deliddb(struct block_list *bl)
 int map_quit(struct map_session_data *sd) {
 	int i;
 
+	if (sd->state.keepshop == false) { // Close vending/buyingstore
+		if (sd->state.vending)
+			vending_closevending(sd);
+		else if (sd->state.buyingstore)
+			buyingstore_close(sd);
+	}
+
 	if(!sd->state.active) { //Removing a player that is not active.
 		struct auth_node *node = chrif_search(sd->status.account_id);
 		if (node && node->char_id == sd->status.char_id &&

+ 1 - 0
src/map/pc.h

@@ -260,6 +260,7 @@ struct map_session_data {
 		bool ignoretimeout; // Prevent the SECURE_NPCTIMEOUT function from closing current script.
 		unsigned int workinprogress : 2; // See clif.h::e_workinprogress
 		bool pc_loaded; // Ensure inventory data and status data is loaded before we calculate player stats
+		bool keepshop; // Whether shop data should be removed when the player disconnects
 	} state;
 	struct {
 		unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;