Ver Fonte

Added a comment for @euphyy
Vendings are now deleted after you relogin with that account
Should fix player freezing?

Lemongrass3110 há 11 anos atrás
pai
commit
b6f60d5434
3 ficheiros alterados com 13 adições e 4 exclusões
  1. 1 0
      conf/battle/feature.conf
  2. 4 2
      src/map/atcommand.c
  3. 8 2
      src/map/chrif.c

+ 1 - 0
conf/battle/feature.conf

@@ -24,6 +24,7 @@ feature.atcommand_suggestions: off
 feature.banking: on
 
 // Autotrade persistency (Note 1)
+// Should vendors that used @autotrade be restored after a restart?
 feature.autotrade: on
 
 // In which direction should respawned autotraders look?

+ 4 - 2
src/map/atcommand.c

@@ -5654,7 +5654,9 @@ ACMD_FUNC(autotrade) {
 
 	sd->state.autotrade = 1;
 
-	if( battle_config.feature_autotrade && Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", "vendings", sd->vender_id ) != SQL_SUCCESS ){
+	if( battle_config.feature_autotrade && 
+		sd->state.vending && 
+		Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", "vendings", sd->vender_id ) != SQL_SUCCESS ){
 		Sql_ShowDebug( mmysql_handle );
 	}
 
@@ -5666,7 +5668,7 @@ ACMD_FUNC(autotrade) {
 	channel_pcquit(sd,0xF); //leave all chan
 	clif_authfail_fd(sd->fd, 15);
 	
-	chrif_save(sd,1);
+	chrif_save(sd,3);
 
 	return 0;
 }

+ 8 - 2
src/map/chrif.c

@@ -277,6 +277,7 @@ int chrif_isconnected(void) {
  * Saves character data.
  * Flag = 1: Character is quitting
  * Flag = 2: Character is changing map-servers
+ * Flag = 3: Character used @autotrade
  *------------------------------------------*/
 int chrif_save(struct map_session_data *sd, int flag) {
 	uint32 mmo_charstatus_len = 0;
@@ -292,7 +293,7 @@ int chrif_save(struct map_session_data *sd, int flag) {
 		chrif_save_bsdata(sd);
 		chrif_req_login_operation(sd->status.account_id, sd->status.name, 7, 0, 2, sd->status.bank_vault); //save Bank data
 	}
-		if ( !chrif_auth_logout(sd,flag == 1 ? ST_LOGOUT : ST_MAPCHANGE) )
+		if ( flag != 3 && !chrif_auth_logout(sd,flag == 1 ? ST_LOGOUT : ST_MAPCHANGE) )
 			ShowError("chrif_save: Failed to set up player %d:%d for proper quitting!\n", sd->status.account_id, sd->status.char_id);
 	}
 
@@ -1121,8 +1122,13 @@ int chrif_disconnectplayer(int fd) {
 	}
 
 	if (!sd->fd) { //No connection
-		if (sd->state.autotrade)
+		if (sd->state.autotrade){
+			if( sd->state.vending ){
+				vending_closevending(sd);
+			}
+
 			map_quit(sd); //Remove it.
+		}
 		//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;