From 2b3e62c1ef25b2a77a442dfe69f8209f25271a21 Mon Sep 17 00:00:00 2001 From: Rob Date: Thu, 17 Sep 2020 20:41:18 -0700 Subject: [PATCH] When a sysop pages a node for private chat, force that node into private chat. When a sysop wants to chat, he wants to chat right now, damnit! --- src/sbbs3/chat.cpp | 69 +++++++++++++++++++++++-------------------- src/sbbs3/getnode.cpp | 29 +++++++++++++++++- src/sbbs3/node.c | 2 ++ src/sbbs3/nodedefs.h | 1 + src/sbbs3/sbbs.h | 2 +- 5 files changed, 69 insertions(+), 34 deletions(-) diff --git a/src/sbbs3/chat.cpp b/src/sbbs3/chat.cpp index d31137dda..aabbee78c 100644 --- a/src/sbbs3/chat.cpp +++ b/src/sbbs3/chat.cpp @@ -771,7 +771,7 @@ bool sbbs_t::chan_access(uint cnum) /****************************************************************************/ /* Private split-screen (or interspersed) chat with node or local sysop */ /****************************************************************************/ -void sbbs_t::privchat(bool local) +void sbbs_t::privchat(bool forced, int node_num) { char str[128],c,*p,localbuf[5][81],remotebuf[5][81] ,localline=0,remoteline=0,localchar=0,remotechar=0 @@ -787,8 +787,8 @@ void sbbs_t::privchat(bool local) node_t node; time_t last_nodechk=0; - if(local) - n=0; + if(forced) + n = node_num; else { if(useron.rest&FLAG('C')) { @@ -808,23 +808,28 @@ void sbbs_t::privchat(bool local) bprintf(text[NodeNAlreadyInPChat],n); return; } - if((node.action!=NODE_PAGE || node.aux!=cfg.node_num) - && node.misc&NODE_POFF && !SYSOP) { - bprintf(text[CantPageNode],node.misc&NODE_ANON - ? text[UNKNOWN_USER] : username(&cfg,node.useron,tmp)); - return; - } - if(node.action!=NODE_PAGE) { - bprintf(text[PagingUser] - ,node.misc&NODE_ANON ? text[UNKNOWN_USER] : username(&cfg,node.useron,tmp) - ,node.misc&NODE_ANON ? 0 : node.useron); - sprintf(str,text[NodePChatPageMsg] - ,cfg.node_num,thisnode.misc&NODE_ANON - ? text[UNKNOWN_USER] : useron.alias); - putnmsg(&cfg,n,str); - sprintf(str,"paged %s on node %d to private chat" - ,username(&cfg,node.useron,tmp),n); - logline("C",str); + if(SYSOP && getnodedat(n, &node, true) == 0) { + node.misc |= NODE_FCHAT; + putnodedat(n, &node); + } else { + if((node.action!=NODE_PAGE || node.aux!=cfg.node_num) + && node.misc&NODE_POFF) { + bprintf(text[CantPageNode],node.misc&NODE_ANON + ? text[UNKNOWN_USER] : username(&cfg,node.useron,tmp)); + return; + } + if(node.action!=NODE_PAGE) { + bprintf(text[PagingUser] + ,node.misc&NODE_ANON ? text[UNKNOWN_USER] : username(&cfg,node.useron,tmp) + ,node.misc&NODE_ANON ? 0 : node.useron); + sprintf(str,text[NodePChatPageMsg] + ,cfg.node_num,thisnode.misc&NODE_ANON + ? text[UNKNOWN_USER] : useron.alias); + putnmsg(&cfg,n,str); + sprintf(str,"paged %s on node %d to private chat" + ,username(&cfg,node.useron,tmp),n); + logline("C",str); + } } if(getnodedat(cfg.node_num,&thisnode,true)==0) { @@ -858,14 +863,14 @@ void sbbs_t::privchat(bool local) if(getnodedat(cfg.node_num,&thisnode,true)==0) { thisnode.action=action=NODE_PCHT; thisnode.aux=n; - thisnode.misc&=~NODE_LCHAT; + thisnode.misc&=~ (NODE_LCHAT|NODE_FCHAT); putnodedat(cfg.node_num,&thisnode); } - if(!online || sys_status&SS_ABORT) + if(!online || (!forced && (sys_status&SS_ABORT))) return; - if(local) { + if(forced && n == 0) { /* If an external sysop chat event handler is installed, just run that and do nothing else */ if(user_event(EVENT_LOCAL_CHAT)) return; @@ -882,7 +887,7 @@ void sbbs_t::privchat(bool local) */ if(!(sys_status&SS_SPLITP)) { - if(local) + if(forced) bprintf(text[SysopIsHere],cfg.sys_op); else bputs(text[WelcomeToPrivateChat]); @@ -894,7 +899,7 @@ void sbbs_t::privchat(bool local) return; } - if(local) + if(forced && n == 0) sprintf(inpath,"%slchat.dab",cfg.node_dir); else sprintf(inpath,"%schat.dab",cfg.node_path[n-1]); @@ -924,7 +929,7 @@ void sbbs_t::privchat(bool local) putnodedat(cfg.node_num,&thisnode); } - if(!local) { + if(n) { // not local if(getnodedat(n,&node,true)==0) { node.misc|=NODE_RPCHT; /* Set "reset pchat flag" */ putnodedat(n,&node); /* on other node */ @@ -955,7 +960,7 @@ void sbbs_t::privchat(bool local) ansi_save(); ansi_gotoxy(1,13); remote_y=1; - bprintf(local ? local_sep : sep + bprintf(forced ? local_sep : sep ,thisnode.misc&NODE_MSGW ? 'T':' ' ,sectostr(timeleft,tmp) ,thisnode.misc&NODE_NMSG ? 'M':' '); @@ -963,7 +968,7 @@ void sbbs_t::privchat(bool local) local_y=14; } - while(online && (local || !(sys_status&SS_ABORT))) { + while(online && (forced || !(sys_status&SS_ABORT))) { lncntr=0; if(sys_status&SS_SPLITP) lbuflen=0; @@ -1007,7 +1012,7 @@ void sbbs_t::privchat(bool local) bputs("\1i_\1n"); /* Fake cursor */ ansi_save(); ansi_gotoxy(1,13); - bprintf(local ? local_sep : sep + bprintf(forced ? local_sep : sep ,thisnode.misc&NODE_MSGW ? 'T':' ' ,sectostr(timeleft,tmp) ,thisnode.misc&NODE_NMSG ? 'M':' '); @@ -1037,7 +1042,7 @@ void sbbs_t::privchat(bool local) if(sys_status&SS_SPLITP && local_y==24) { ansi_gotoxy(1,13); - bprintf(local ? local_sep : sep + bprintf(forced ? local_sep : sep ,thisnode.misc&NODE_MSGW ? 'T':' ' ,sectostr(timeleft,tmp) ,thisnode.misc&NODE_NMSG ? 'M':' '); @@ -1133,7 +1138,7 @@ void sbbs_t::privchat(bool local) if(sys_status&SS_SPLITP && remote_y==12) { CRLF; - bprintf(local ? local_sep : sep + bprintf(forced ? local_sep : sep ,thisnode.misc&NODE_MSGW ? 'T':' ' ,sectostr(timeleft,tmp) ,thisnode.misc&NODE_NMSG ? 'M':' '); @@ -1194,7 +1199,7 @@ void sbbs_t::privchat(bool local) nodesync(); } - if(!local) { + if(n != 0) { getnodedat(n,&node,0); if((node.action!=NODE_PCHT && node.action!=NODE_PAGE) || node.aux!=cfg.node_num) { diff --git a/src/sbbs3/getnode.cpp b/src/sbbs3/getnode.cpp index b38d88e5c..89e40b1c7 100644 --- a/src/sbbs3/getnode.cpp +++ b/src/sbbs3/getnode.cpp @@ -109,6 +109,18 @@ int sbbs_t::getnodedat(uint number, node_t *node, bool lockit) return(0); } +static int getpagingnode(scfg_t* cfg) +{ + for(int i = 1; i <= cfg->sys_nodes; i++) { + node_t node; + if(i == cfg->node_num) + continue; + if(getnodedat(cfg, i, &node, FALSE, NULL) == 0 && node.action == NODE_PAGE && node.aux == cfg->node_num) + return i; + } + return 0; +} + /****************************************************************************/ /* Synchronizes all the nodes knowledge of the other nodes' actions, mode, */ /* status and other flags. */ @@ -184,6 +196,19 @@ void sbbs_t::nodesync(bool clearline) privchat(true); RESTORELINE; } + + if(thisnode.misc&NODE_FCHAT) { // forced into private chat + int n = getpagingnode(&cfg); + if(n) { + SAVELINE; + privchat(true, n); + RESTORELINE; + } + if(getnodedat(cfg.node_num, &thisnode, true)==0) { + thisnode.misc &= ~NODE_FCHAT; + putnodedat(cfg.node_num, &thisnode); + } + } if(sys_status&SS_USERON && memcmp(&nodesync_user,&useron,sizeof(user_t))) { getusrdirs(); @@ -644,7 +669,7 @@ void sbbs_t::printnodedat(uint number, node_t* node) outchar(')'); } if(SYSOP && ((node->misc - &(NODE_ANON|NODE_UDAT|NODE_INTR|NODE_RRUN|NODE_EVENT|NODE_DOWN|NODE_LCHAT)) + &(NODE_ANON|NODE_UDAT|NODE_INTR|NODE_RRUN|NODE_EVENT|NODE_DOWN|NODE_LCHAT|NODE_FCHAT)) || node->status==NODE_QUIET)) { bputs(" ["); if(node->misc&NODE_ANON) @@ -663,6 +688,8 @@ void sbbs_t::printnodedat(uint number, node_t* node) outchar('D'); if(node->misc&NODE_LCHAT) outchar('C'); + if(node->misc&NODE_FCHAT) + outchar('F'); outchar(']'); } if(node->errors && SYSOP) { diff --git a/src/sbbs3/node.c b/src/sbbs3/node.c index b95966641..e23fd52e8 100644 --- a/src/sbbs3/node.c +++ b/src/sbbs3/node.c @@ -438,6 +438,8 @@ void printnodedat(int number, node_t node) putchar('D'); if(node.misc&NODE_LCHAT) putchar('C'); + if(node.misc&NODE_FCHAT) + putchar('F'); putchar(']'); } if(node.errors) printf(" %d error%c",node.errors, node.errors>1 ? 's' : '\0' ); diff --git a/src/sbbs3/nodedefs.h b/src/sbbs3/nodedefs.h index b6fc735d5..7e3a82925 100644 --- a/src/sbbs3/nodedefs.h +++ b/src/sbbs3/nodedefs.h @@ -76,6 +76,7 @@ enum node_status { /* Node Status */ #define NODE_NMSG (1<<11) /* Node message waiting (new way) */ #define NODE_EXT (1<<12) /* Extended info on node action */ #define NODE_LCHAT (1<<13) /* Being pulled into local chat */ +#define NODE_FCHAT (1<<14) /* Being forced into private chat */ enum node_action { /* Node Action */ NODE_MAIN /* Main Prompt */ diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h index 062e97471..31ff5d28d 100644 --- a/src/sbbs3/sbbs.h +++ b/src/sbbs3/sbbs.h @@ -927,7 +927,7 @@ public: void localguru(char *guru, int gurunum); bool sysop_page(void); bool guru_page(void); - void privchat(bool local=false); + void privchat(bool forced=false, int node_num=0); bool chan_access(uint cnum); int getnodetopage(int all, int telegram); -- GitLab