Skip to content
Snippets Groups Projects
Commit 60c6c7e3 authored by rswindell's avatar rswindell
Browse files

progress() now accepts an 'interval' argument (default: 1), which determines

how "frequent" the progress meter/percentage displayed is updated.
Most uses of this function are now using a interval of 10 so that fast-running
searches aren't now "slow" due to the progress display.
parent d7770e12
No related branches found
No related tags found
No related merge requests found
......@@ -656,10 +656,12 @@ int sbbs_t::backfill(const char* instr, float pct, int full_attr, int empty_attr
return len;
}
void sbbs_t::progress(const char* text, int count, int total)
void sbbs_t::progress(const char* text, int count, int total, int interval)
{
char str[128];
if((count%interval) != 0)
return;
if(text == NULL) text = "";
float pct = ((float)count/total)*100.0F;
SAFEPRINTF2(str, "[ %-8s %4.1f%% ]", text, pct);
......
......@@ -675,7 +675,7 @@ public:
void cursor_right(int count=1);
long term_supports(long cmp_flags=0);
int backfill(const char* str, float pct, int full_attr, int empty_attr);
void progress(const char* str, int count, int total);
void progress(const char* str, int count, int total, int interval=1);
/* getstr.cpp */
size_t getstr_offset;
......
......@@ -89,7 +89,7 @@ void sbbs_t::scandirs(long mode)
if(ch=='L') {
k=0;
for(i=0;i<usrdirs[curlib] && !msgabort();i++) {
progress("Scanning", i, usrdirs[curlib]);
progress("Scanning", i, usrdirs[curlib], 10);
if(mode&FL_ULTIME /* New-scan */
&& (cfg.lib[usrlib[curlib]]->offline_dir==usrdir[curlib][i]
|| cfg.dir[usrdir[curlib][i]]->misc&DIR_NOSCAN))
......@@ -149,7 +149,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("Scanning", d, total_dirs);
progress("Scanning", d, total_dirs, 10);
if(mode&FL_ULTIME /* New-scan */
&& (cfg.lib[usrlib[i]]->offline_dir==usrdir[i][j]
|| cfg.dir[usrdir[i][j]]->misc&DIR_NOSCAN))
......
......@@ -123,7 +123,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("Scanning", i, usrsubs[curgrp]);
progress("Scanning", i, usrsubs[curgrp], 10);
if(scanposts(usrsub[curgrp][i],mode,str))
break;
subs_scanned++;
......@@ -224,7 +224,7 @@ void sbbs_t::scanallsubs(long mode)
}
for(i=0; i<total_subs && !msgabort(); i++) {
if(mode&SCAN_POLLS)
progress("Scanning", i, total_subs);
progress("Scanning", i, total_subs, 10);
if(scanposts(sub[i],mode,str))
break;
}
......@@ -282,7 +282,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);
progress(text[LoadingMsgPtrs], subs++, total_subs, 10);
checkline();
subscan[usrsub[i][j]].ptr=getmsgnum(usrsub[i][j],t);
}
......@@ -299,7 +299,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);
progress(text[LoadingMsgPtrs], subs++, total_subs, 10);
checkline();
getlastmsg(usrsub[i][j],&l,0);
if(s>(long)l)
......@@ -343,7 +343,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]);
progress(text[LoadingMsgPtrs], j, usrsubs[i], 10);
checkline();
subscan[usrsub[i][j]].ptr=getmsgnum(usrsub[i][j],t);
}
......@@ -356,7 +356,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]);
progress(text[LoadingMsgPtrs], j, usrsubs[i], 10);
checkline();
getlastmsg(usrsub[i][j],&l,0);
if(s>(long)l)
......
......@@ -1163,9 +1163,11 @@ uint DLLCALL userdatdupe(scfg_t* cfg, uint usernumber, uint offset, uint datlen
l=((long)usernumber) * U_LEN;
else
l=0;
if(progress != NULL)
progress(cbdata, l, length);
for(;l<length;l+=U_LEN) {
if(progress != NULL)
progress(cbdata, l, length);
progress(cbdata, l, length, U_LEN*10);
if(usernumber && l/U_LEN==(long)usernumber-1)
continue;
lseek(file,l+offset,SEEK_SET);
......@@ -3039,7 +3041,7 @@ BOOL DLLCALL getmsgptrs(scfg_t* cfg, user_t* user, subscan_t* subscan, void (*pr
length=(long)filelength(file);
for(i=0;i<cfg->total_subs;i++) {
if(progress != NULL)
progress(cbdata, i, cfg->total_subs);
progress(cbdata, i, cfg->total_subs, 10);
if(length>=(cfg->sub[i]->ptridx+1)*10L) {
fseek(stream,(long)cfg->sub[i]->ptridx*10L,SEEK_SET);
fread(&subscan[i].ptr,sizeof(subscan[i].ptr),1,stream);
......@@ -3127,7 +3129,7 @@ BOOL DLLCALL initmsgptrs(scfg_t* cfg, subscan_t* subscan, unsigned days, void (*
for(i=0;i<cfg->total_subs;i++) {
if(progress != NULL)
progress(cbdata, i, cfg->total_subs);
progress(cbdata, i, cfg->total_subs, 10);
if(days == 0) {
/* This value will be "fixed" (changed to the last msg) when saving */
subscan[i].ptr = ~0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment