From 39d09590772232aef1db0f68c391598b4e3ec7da Mon Sep 17 00:00:00 2001
From: Rob <rob@synchro.net>
Date: Sat, 10 Oct 2020 15:03:57 -0700
Subject: [PATCH] Fix NDX file creation when votes are included in QWK packets

When both Indexes (NDX files) and vote messages are included in a QWK packet (an unexpected, but valid combination), the "Record number" stored in NDX files for subs with votes would be incorrect as it did not increment when a vote message (with no body text) was added to the messages.dat file.

Reported by user that was trying to use MultiMail to read a QWK packet that included both votes and indexes and "IgnoreNDX: No" in their .mmailrc file.
---
 src/sbbs3/pack_qwk.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/sbbs3/pack_qwk.cpp b/src/sbbs3/pack_qwk.cpp
index 4c946c091f..ebb3035699 100644
--- a/src/sbbs3/pack_qwk.cpp
+++ b/src/sbbs3/pack_qwk.cpp
@@ -389,8 +389,8 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
 				size=msgtoqwk(&msg, qwk, mode|QM_REPLYTO, &smb, /* confnum: */0, hdrs);
 				smb_unlockmsghdr(&smb,&msg);
 				smb_freemsgmem(&msg);
+				msgndx++;
 				if(ndx && size) {
-					msgndx++;
 					f=ltomsbin(msgndx); 	/* Record number */
 					ch=0;					/* Sub number, not used */
 					if(personal) {
@@ -529,8 +529,8 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
 					size=msgtoqwk(&msg, qwk, mode, &smb, conf, hdrs, voting);
 					smb_unlockmsghdr(&smb,&msg);
 
+					msgndx++;
 					if(ndx && size) {
-						msgndx++;
 						f=ltomsbin(msgndx); 	/* Record number */
 						ch=0;					/* Sub number, not used */
 						if(personal
-- 
GitLab