From 529cfec376c211c76808252457bfdb7077269878 Mon Sep 17 00:00:00 2001
From: Rob Swindell <rob@synchro.net>
Date: Wed, 19 Jan 2022 20:23:53 -0800
Subject: [PATCH] Use the progress() interval argument as the time interval

Default the progress time interval to 500 milliseconds (twice a second).

Don't specify a count/call interval in the call-sites, since we really want to use time-based progress updates now only and the default probably will work fine everywhere.
---
 src/sbbs3/bat_xfer.cpp |  2 +-
 src/sbbs3/con_out.cpp  |  4 +---
 src/sbbs3/data_ovl.cpp |  4 ++--
 src/sbbs3/sbbs.h       |  2 +-
 src/sbbs3/scandirs.cpp |  4 ++--
 src/sbbs3/scansubs.cpp | 12 ++++++------
 src/sbbs3/tmp_xfer.cpp |  2 +-
 src/sbbs3/upload.cpp   |  4 ++--
 8 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/src/sbbs3/bat_xfer.cpp b/src/sbbs3/bat_xfer.cpp
index af4f7899e3..1f7072ffd5 100644
--- a/src/sbbs3/bat_xfer.cpp
+++ b/src/sbbs3/bat_xfer.cpp
@@ -526,7 +526,7 @@ void sbbs_t::batch_upload()
 
 		uint x,y;
 		for(x=0;x<usrlibs;x++) {
-			progress(text[SearchingForDupes], x, usrlibs, 1);
+			progress(text[SearchingForDupes], x, usrlibs);
 			for(y=0;y<usrdirs[x];y++)
 				if(cfg.dir[usrdir[x][y]]->misc&DIR_DUPES
 					&& findfile(&cfg,usrdir[x][y], dirent->d_name, NULL))
diff --git a/src/sbbs3/con_out.cpp b/src/sbbs3/con_out.cpp
index c44df8a428..eeb79cd86e 100644
--- a/src/sbbs3/con_out.cpp
+++ b/src/sbbs3/con_out.cpp
@@ -1398,10 +1398,8 @@ void sbbs_t::progress(const char* text, int count, int total, int interval)
 
 	if(cfg.node_num == 0)
 		return;	// Don't output this for events
-	if((count%interval) != 0)
-		return;
 	clock_t now = msclock();
-	if(now - last_progress < 500)
+	if(now - last_progress < interval)
 		return;
 	if(text == NULL) text = "";
 	float pct = total ? ((float)count/total)*100.0F : 100.0F;
diff --git a/src/sbbs3/data_ovl.cpp b/src/sbbs3/data_ovl.cpp
index 01f50ae004..18860e6e0d 100644
--- a/src/sbbs3/data_ovl.cpp
+++ b/src/sbbs3/data_ovl.cpp
@@ -38,7 +38,7 @@
 static void ProgressLoadingMsgPtrs(void* cbdata, int count, int total)
 {
 	sbbs_t* sbbs = ((sbbs_t*)cbdata);
-	sbbs->progress(sbbs->text[LoadingMsgPtrs], count, total, 10);
+	sbbs->progress(sbbs->text[LoadingMsgPtrs], count, total);
 }
 
 /****************************************************************************/
@@ -64,7 +64,7 @@ void sbbs_t::putmsgptrs()
 static void ProgressSearchingUsers(void* cbdata, int count, int total)
 {
 	sbbs_t* sbbs = ((sbbs_t*)cbdata);
-	sbbs->progress(sbbs->text[SearchingForDupes], count, total, U_LEN*10);
+	sbbs->progress(sbbs->text[SearchingForDupes], count, total);
 }
 
 /****************************************************************************/
diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h
index 7930ab8fd5..39f6823ee7 100644
--- a/src/sbbs3/sbbs.h
+++ b/src/sbbs3/sbbs.h
@@ -847,7 +847,7 @@ public:
 	const char* term_charset(long term_supports = -1);
 	bool	update_nodeterm(void);
 	int		backfill(const char* str, float pct, int full_attr, int empty_attr);
-	void	progress(const char* str, int count, int total, int interval=1);
+	void	progress(const char* str, int count, int total, int interval = 500);
 	clock_t	last_progress = 0;
 	bool	saveline(void);
 	bool	restoreline(void);
diff --git a/src/sbbs3/scandirs.cpp b/src/sbbs3/scandirs.cpp
index 9396bffab7..70745d9a22 100644
--- a/src/sbbs3/scandirs.cpp
+++ b/src/sbbs3/scandirs.cpp
@@ -74,7 +74,7 @@ void sbbs_t::scandirs(long mode)
 	if(ch==text[DirLibKeys][1]) {
 		k=0;
 		for(i=0;i<usrdirs[curlib] && !msgabort();i++) {
-			progress(text[Scanning], i, usrdirs[curlib], (mode & FL_ULTIME) ? 10 : 1);
+			progress(text[Scanning], i, usrdirs[curlib]);
 			if(mode&FL_ULTIME	/* New-scan */
 				&& (cfg.lib[usrlib[curlib]]->offline_dir==usrdir[curlib][i]
 				|| cfg.dir[usrdir[curlib][i]]->misc&DIR_NOSCAN))
@@ -131,7 +131,7 @@ void sbbs_t::scanalldirs(long mode)
 		total_dirs += usrdirs[i];
 	for(i=d=0;i<usrlibs;i++) {
 		for(j=0;j<usrdirs[i] && !msgabort();j++,d++) {
-			progress(text[Scanning], d, total_dirs, (mode & FL_ULTIME) ? 10 : 1);
+			progress(text[Scanning], d, total_dirs);
 			if(mode&FL_ULTIME /* New-scan */
 				&& (cfg.lib[usrlib[i]]->offline_dir==usrdir[i][j]
 				|| cfg.dir[usrdir[i][j]]->misc&DIR_NOSCAN))
diff --git a/src/sbbs3/scansubs.cpp b/src/sbbs3/scansubs.cpp
index baa4a30b30..36a46d19b0 100644
--- a/src/sbbs3/scansubs.cpp
+++ b/src/sbbs3/scansubs.cpp
@@ -112,7 +112,7 @@ void sbbs_t::scansubs(long mode)
 			if((mode&SCAN_POLLS) && cfg.sub[usrsub[curgrp][i]]->misc&SUB_NOVOTING)
 				continue;
 			if(mode&SCAN_POLLS)
-				progress(text[Scanning], i, usrsubs[curgrp], 10);
+				progress(text[Scanning], i, usrsubs[curgrp]);
 			if(scanposts(usrsub[curgrp][i],mode,str))
 				break;
 			subs_scanned++;
@@ -215,7 +215,7 @@ void sbbs_t::scanallsubs(long mode)
 		}
 	for(i=0; i<total_subs && !msgabort(); i++) {
 		if(mode&SCAN_POLLS)
-			progress(text[Scanning], i, total_subs, 10);
+			progress(text[Scanning], i, total_subs);
 		if(scanposts(sub[i],mode,str))
 			break;
 	}
@@ -275,7 +275,7 @@ void sbbs_t::new_scan_ptr_cfg()
 				if(inputnstime(&t) && !(sys_status&SS_ABORT)) {
 					for(i=0, subs=0; i<usrgrps && online; i++) {
 						for(j=0;j<usrsubs[i] && online;j++) {
-							progress(text[LoadingMsgPtrs], subs++, total_subs, 10);
+							progress(text[LoadingMsgPtrs], subs++, total_subs);
 							checkline();
 							subscan[usrsub[i][j]].ptr=getmsgnum(usrsub[i][j],t);
 						}
@@ -292,7 +292,7 @@ void sbbs_t::new_scan_ptr_cfg()
 				total_subs += usrsubs[i];
 			for(i=0, subs=0; i<usrgrps; i++)
 				for(j=0;j<usrsubs[i] && online;j++) {
-					progress(text[LoadingMsgPtrs], subs++, total_subs, 10);
+					progress(text[LoadingMsgPtrs], subs++, total_subs);
 					checkline();
 					if(s == 0) {
 						subscan[usrsub[i][j]].ptr = ~0;
@@ -341,7 +341,7 @@ void sbbs_t::new_scan_ptr_cfg()
 					t=l;
 					if(inputnstime(&t) && !(sys_status&SS_ABORT)) {
 						for(j=0;j<usrsubs[i] && online;j++) {
-							progress(text[LoadingMsgPtrs], j, usrsubs[i], 10);
+							progress(text[LoadingMsgPtrs], j, usrsubs[i]);
 							checkline();
 							subscan[usrsub[i][j]].ptr=getmsgnum(usrsub[i][j],t);
 						}
@@ -354,7 +354,7 @@ void sbbs_t::new_scan_ptr_cfg()
 				if(s)
 					s&=~0x80000000L;
 				for(j=0;j<usrsubs[i] && online;j++) {
-					progress(text[LoadingMsgPtrs], j, usrsubs[i], 10);
+					progress(text[LoadingMsgPtrs], j, usrsubs[i]);
 					checkline();
 					if(s == 0) {
 						subscan[usrsub[i][j]].ptr = ~0;
diff --git a/src/sbbs3/tmp_xfer.cpp b/src/sbbs3/tmp_xfer.cpp
index b9103d0ba2..20fef6d2b4 100644
--- a/src/sbbs3/tmp_xfer.cpp
+++ b/src/sbbs3/tmp_xfer.cpp
@@ -61,7 +61,7 @@ ulong sbbs_t::create_filelist(const char *name, long mode)
 		total_dirs += usrdirs[i];
 	for(i=j=d=0;i<usrlibs;i++) {
 		for(j=0;j<usrdirs[i];j++,d++) {
-			progress(text[Scanning], d, total_dirs, 1);
+			progress(text[Scanning], d, total_dirs);
 			if(mode&FL_ULTIME /* New-scan */
 				&& (cfg.lib[usrlib[i]]->offline_dir==usrdir[i][j]
 				|| cfg.dir[usrdir[i][j]]->misc&DIR_NOSCAN))
diff --git a/src/sbbs3/upload.cpp b/src/sbbs3/upload.cpp
index b5dadfe95c..b30e3f594c 100644
--- a/src/sbbs3/upload.cpp
+++ b/src/sbbs3/upload.cpp
@@ -126,7 +126,7 @@ bool sbbs_t::uploadfile(file_t* f)
 	if(hashfile(&cfg, f)) {
 		bputs(text[SearchedForDupes]);
 		for(uint i=0, k=0; i < usrlibs; i++) {
-			progress(text[Scanning], i, usrlibs, 1);
+			progress(text[Scanning], i, usrlibs);
 			for(uint j=0; j < usrdirs[i]; j++,k++) {
 				if(cfg.dir[usrdir[i][j]]->misc&DIR_DUPES
 					&& findfile(&cfg, usrdir[i][j], /* filename: */NULL, f)) {
@@ -321,7 +321,7 @@ bool sbbs_t::upload(uint dirnum)
 		return(false); 	 /* File is already in database */
 	}
 	for(i=k=0;i<usrlibs;i++) {
-		progress(text[SearchingForDupes], i, usrlibs, 1);
+		progress(text[SearchingForDupes], i, usrlibs);
 		for(j=0;j<usrdirs[i];j++,k++) {
 			if(usrdir[i][j]==dirnum)
 				continue;	/* we already checked this dir */
-- 
GitLab