From 196e4be13df4be8909788b729e2f48771cd774c1 Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on Windows 11)" <rob@synchro.net>
Date: Sun, 5 Jan 2025 20:16:05 -0800
Subject: [PATCH] If the menu file download.* exists, display it before any
 download-protocol

selection menu. This allows the sysop to display additional download-file
specific instructions (e.g. http URL).

When using sendfile() to send a file *not* in a filebase, current_file will ==
nullptr and the download.* file won't be displayed.
---
 src/sbbs3/download.cpp | 2 ++
 src/sbbs3/str.cpp      | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/sbbs3/download.cpp b/src/sbbs3/download.cpp
index dfa77f8de9..8331461b58 100644
--- a/src/sbbs3/download.cpp
+++ b/src/sbbs3/download.cpp
@@ -453,7 +453,9 @@ bool sbbs_t::sendfile(file_t* f, char prot, bool autohang)
 	SAFEPRINTF2(str, "from %s %s"
 		,cfg.lib[cfg.dir[f->dir]->lib]->sname
 		,cfg.dir[f->dir]->sname);
+	current_file = f;
 	bool result = sendfile(getfilepath(&cfg, f, path), prot, str, autohang);
+	current_file = nullptr;
 	if(result == true) {
 		if(cfg.dir[f->dir]->misc&DIR_TFREE && cur_cps)
 			starttime += f->size / (ulong)cur_cps;
diff --git a/src/sbbs3/str.cpp b/src/sbbs3/str.cpp
index 8d24463b5e..0e4ff07786 100644
--- a/src/sbbs3/str.cpp
+++ b/src/sbbs3/str.cpp
@@ -1096,6 +1096,8 @@ const char* prot_menu_file[] = {
 
 char* sbbs_t::xfer_prot_menu(enum XFER_TYPE type, user_t* user, char* keys, size_t size)
 {
+	if(type == XFER_DOWNLOAD && current_file != nullptr)
+		menu("download", P_NOERROR);
 	size_t count = 0;
 	bool menu_used = menu(prot_menu_file[type], P_NOERROR);
 	if(user == nullptr)
-- 
GitLab