From 6741fe643ec244f0dd46535d487b83d600e019c5 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Sun, 12 May 2013 07:34:56 +0000
Subject: [PATCH] Modification to allow JS bbs.msg_* properties (and MSG_*
 @-codes) to be used in places other than just viewing a message header - for
 use in Nightfox's SlyEdit.

---
 src/sbbs3/getmsg.cpp   | 11 -----------
 src/sbbs3/readmail.cpp |  2 ++
 src/sbbs3/readmsgs.cpp |  5 ++++-
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/sbbs3/getmsg.cpp b/src/sbbs3/getmsg.cpp
index ffa3f974d8..6e0916a1a9 100644
--- a/src/sbbs3/getmsg.cpp
+++ b/src/sbbs3/getmsg.cpp
@@ -122,7 +122,6 @@ void sbbs_t::show_msghdr(smbmsg_t* msg)
 	char	*sender=NULL;
 	int 	i;
 
-	current_msg=msg;
 	attr(LIGHTGRAY);
 	if(useron.misc&CLRSCRN)
 		outchar(FF);
@@ -132,7 +131,6 @@ void sbbs_t::show_msghdr(smbmsg_t* msg)
 	sprintf(str,"%smenu/msghdr.*", cfg.text_dir);
 	if(fexist(str)) {
 		menu("msghdr");
-		current_msg=NULL;
 		return; 
 	}
 
@@ -165,16 +163,7 @@ void sbbs_t::show_msghdr(smbmsg_t* msg)
 			bprintf(text[ForwardedFrom],sender
 				,timestr(*(time32_t *)msg->hfield_dat[i])); 
 	}
-
-	/* Debug stuff
-	if(SYSOP) {
-		bprintf("\1n\1c\r\nAux  : \1h%08lX",msg->hdr.auxattr);
-		bprintf("\1n\1c\r\nNum  : \1h%lu",msg->hdr.number); 
-		}
-	*/
-
 	CRLF;
-	current_msg=NULL;
 }
 
 /****************************************************************************/
diff --git a/src/sbbs3/readmail.cpp b/src/sbbs3/readmail.cpp
index e286dc7334..f84db9106a 100644
--- a/src/sbbs3/readmail.cpp
+++ b/src/sbbs3/readmail.cpp
@@ -168,6 +168,7 @@ void sbbs_t::readmail(uint usernumber, int which)
 			"allmail" : "sentmail");
 		menu(str); 
 	}
+	current_msg=&msg;	/* For MSG_* @-codes and bbs.msg_* property values */
 	while(online && !done) {
 		action=act;
 
@@ -768,5 +769,6 @@ void sbbs_t::readmail(uint usernumber, int which)
 
 	smb_close(&smb);
 	smb_stack(&smb,SMB_STACK_POP);
+	current_msg=NULL;
 }
 
diff --git a/src/sbbs3/readmsgs.cpp b/src/sbbs3/readmsgs.cpp
index a85c7c5537..3d99ad9901 100644
--- a/src/sbbs3/readmsgs.cpp
+++ b/src/sbbs3/readmsgs.cpp
@@ -8,7 +8,7 @@
  * @format.tab-size 4		(Plain Text/Source Code File Header)			*
  * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
  *																			*
- * Copyright 2012 Rob Swindell - http://www.synchro.net/copyright.html		*
+ * Copyright 2013 Rob Swindell - http://www.synchro.net/copyright.html		*
  *																			*
  * This program is free software; you can redistribute it and/or			*
  * modify it under the terms of the GNU General Public License				*
@@ -495,6 +495,7 @@ int sbbs_t::scanposts(uint subnum, long mode, const char *find)
 		thisnode.action=NODE_RMSG;
 		putnodedat(cfg.node_num,&thisnode); 
 	}
+	current_msg=&msg;	/* For MSG_* @-codes and bbs.msg_* property values */
 	while(online && !done) {
 
 		action=NODE_RMSG;
@@ -753,6 +754,7 @@ int sbbs_t::scanposts(uint subnum, long mode, const char *find)
 					free(post);
 				smb_close(&smb);
 				smb_stack(&smb,SMB_STACK_POP);
+				current_msg=NULL;
 				return(0);
 			case 'C':   /* Continuous */
 				mode|=SCAN_CONST;
@@ -1185,6 +1187,7 @@ int sbbs_t::scanposts(uint subnum, long mode, const char *find)
 		subscan[subnum].cfg|=SUB_CFG_NSCAN;
 	smb_close(&smb);
 	smb_stack(&smb,SMB_STACK_POP);
+	current_msg=NULL;
 	return(quit);
 }
 
-- 
GitLab