From b29098c74c2e67674a30a1f411e81e4cf5db8798 Mon Sep 17 00:00:00 2001
From: shennetsind <ind@henn.et>
Date: Sat, 20 Sep 2014 20:28:30 -0300
Subject: Fixed Bug 8138

@at persistency no longer sends characters to save point when starting autotrade on a nosave location.
http://hercules.ws/board/tracker/issue-8138-autotrade-teleports-char-to-the-savepoint/

Signed-off-by: shennetsind <ind@henn.et>
---
 src/map/atcommand.c | 1 +
 src/map/clif.c      | 2 +-
 src/map/pc.c        | 2 +-
 src/map/pc.h        | 2 +-
 4 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 459a4a2ee..cc6f0b20d 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -5482,6 +5482,7 @@ ACMD(autotrade) {
 		return true;
 	
 #ifdef AUTOTRADE_PERSISTENCY
+	sd->state.autotrade = 2;/** state will enter pre-save, we use it to rule out some criterias **/
 	pc->autotrade_prepare(sd);
 	
 	return false;/* we fail to not cause it to proceed on is_atcommand */
diff --git a/src/map/clif.c b/src/map/clif.c
index f673e0970..c7b0d11d0 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -10501,7 +10501,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
 	}
 
 	// if player is autotrading
-	if( dstsd->state.autotrade == 1 ) {
+	if( dstsd->state.autotrade ) {
 		char output[256];
 		sprintf(output, "%s is in autotrade mode and cannot receive whispered messages.", dstsd->status.name);
 		clif->wis_message(fd, map->wisp_server_name, output, strlen(output) + 1);
diff --git a/src/map/pc.c b/src/map/pc.c
index 25a15ce84..e28d0545a 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -585,7 +585,7 @@ int pc_makesavestatus(struct map_session_data *sd)
 		sd->status.last_point.y = sd->bl.y;
 	}
 
-	if(map->list[sd->bl.m].flag.nosave || map->list[sd->bl.m].instance_id >= 0) {
+	if( ( map->list[sd->bl.m].flag.nosave && sd->state.autotrade != 2 ) || map->list[sd->bl.m].instance_id >= 0) {
 		struct map_data *m=&map->list[sd->bl.m];
 		if(m->save.map)
 			memcpy(&sd->status.last_point,&m->save,sizeof(sd->status.last_point));
diff --git a/src/map/pc.h b/src/map/pc.h
index bec4522df..c36704b4f 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -145,7 +145,7 @@ struct map_session_data {
 		unsigned int snovice_dead_flag : 1; //Explosion spirits on death: 0 off, 1 used.
 		unsigned int abra_flag : 2; // Abracadabra bugfix by Aru
 		unsigned int autocast : 1; // Autospell flag [Inkfish]
-		unsigned int autotrade : 1;	//By Fantik
+		unsigned int autotrade : 2;	//By Fantik
 		unsigned int showdelay :1;
 		unsigned int showexp :1;
 		unsigned int showzeny :1;
-- 
cgit v1.2.3-70-g09d2