Skip to content
Snippets Groups Projects
Commit 3a0825c6 authored by rswindell's avatar rswindell
Browse files

Created sbbs_t::count_nodes() which just returns the number of "in-use" nodes,

optionally including the current (your) node.
New @-codes:
"ANODES" (active-nodes count), aliases: "ANODE" and "AN"
"ONODES" (other-active-nodes count), aliases: "ONODE" and "ON"

Make "NN" an alias for "NODE" and "TN" and alias for "TNODE".
Add "TNODES" alias for "TNODE" as well, for symmetry.
parent 578a5d75
Branches
Tags
No related merge requests found
...@@ -321,15 +321,22 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen, long* pmode) ...@@ -321,15 +321,22 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen, long* pmode)
if(!strcmp(sp,"LOCATION")) if(!strcmp(sp,"LOCATION"))
return(cfg.sys_location); return(cfg.sys_location);
if(!strcmp(sp,"NODE")) { if(strcmp(sp,"NODE") == 0 || strcmp(sp,"NN") == 0) {
safe_snprintf(str,maxlen,"%u",cfg.node_num); safe_snprintf(str,maxlen,"%u",cfg.node_num);
return(str); return(str);
} }
if(strcmp(sp, "TNODES") == 0 || strcmp(sp, "TNODE") == 0 || strcmp(sp, "TN") == 0) {
if(!strcmp(sp,"TNODE")) {
safe_snprintf(str,maxlen,"%u",cfg.sys_nodes); safe_snprintf(str,maxlen,"%u",cfg.sys_nodes);
return(str); return(str);
} }
if(strcmp(sp, "ANODES") == 0 || strcmp(sp, "ANODE") == 0 || strcmp(sp, "AN") == 0) {
safe_snprintf(str, maxlen, "%u", count_nodes(/* self: */true));
return str;
}
if(strcmp(sp, "ONODES") == 0 || strcmp(sp, "ONODE") == 0 || strcmp(sp, "ON") == 0) {
safe_snprintf(str, maxlen, "%u", count_nodes(/* self: */false));
return str;
}
if(strcmp(sp, "PAGER") == 0) if(strcmp(sp, "PAGER") == 0)
return (thisnode.misc&NODE_POFF) ? text[Off] : text[On]; return (thisnode.misc&NODE_POFF) ? text[Off] : text[On];
......
...@@ -661,3 +661,20 @@ void sbbs_t::printnodedat(uint number, node_t* node) ...@@ -661,3 +661,20 @@ void sbbs_t::printnodedat(uint number, node_t* node)
attr(LIGHTGRAY); attr(LIGHTGRAY);
CRLF; CRLF;
} }
uint sbbs_t::count_nodes(bool self)
{
uint count = 0;
for(int i=1; i<=cfg.sys_nodes && i<=cfg.sys_lastnode; i++) {
node_t node;
if(getnodedat(i, &node, false) != 0)
continue;
if(!self && i==cfg.node_num)
continue;
if(node.status != NODE_INUSE)
continue;
count++;
}
return count;
}
...@@ -819,6 +819,7 @@ public: ...@@ -819,6 +819,7 @@ public:
void nodesync(bool clearline = false); void nodesync(bool clearline = false);
user_t nodesync_user; user_t nodesync_user;
bool nodesync_inside; bool nodesync_inside;
uint count_nodes(bool self = true);
/* putnode.cpp */ /* putnode.cpp */
int putnodedat(uint number, node_t * node); int putnodedat(uint number, node_t * node);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment