From: nveid Date: Mon, 9 Apr 2007 06:06:05 +0000 (+0000) Subject: Added xwho, xmwho, xwhoid, xmwhoid, lwhoid, mwhoid, and nwho X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=99c830c8455211a72f1fad63627489743043bfba;p=cobramush.git Added xwho, xmwho, xwhoid, xmwhoid, lwhoid, mwhoid, and nwho (cherry picked from commit e5185aeec361f5823d1a2921481d1fc24e6cfd01) --- diff --git a/game/txt/changes/0.73 b/game/txt/changes/0.73 index 2c7e9e7..7ce81af 100644 --- a/game/txt/changes/0.73 +++ b/game/txt/changes/0.73 @@ -181,4 +181,6 @@ CobraMUSH Version 0.73 * Add Speak(). [RLB] * Added namelist(). [RLB] * Added stringsecs(). [RLB] + * Added nwho(), xwho(), xmwho(), xwhoid(), xmwhoid(). [RLB] + * Added mwhoid(), lwhoid(). [RLB] diff --git a/game/txt/hlp/cobra_func.hlp b/game/txt/hlp/cobra_func.hlp index e6da2e5..dbc52f2 100644 --- a/game/txt/hlp/cobra_func.hlp +++ b/game/txt/hlp/cobra_func.hlp @@ -677,7 +677,7 @@ connection as indicated by WHO. The caller can use the function on himself, but using on any other - player requires privileged power such as Wizard, Royalty or SEE_ALL. + player requires special powers. See also: Connection Functions & SENT() @@ -2237,16 +2237,21 @@ for an object named "Test", preferring a thing over other types. function. & LWHO() lwho() + lwho() + lwhoid() - This returns a list of the dbref numbers for all currently-connected + lwho() returns a list of the dbref numbers for all currently-connected players. When mortals use this function, the dbref numbers of DARK - directors or royalty do NOT appear on the dbref list. + privileged players do NOT appear on the dbref list. If lwho() is given an argument, and used by an object that can see DARK and Hidden players, lwho() returns the output of lwho() from 's point of view. - See also: mwho() + lwohid() returns a list of objid's instead. + +See also: mwho(), xwho() + & MAP() map([/],[,][, ]) @@ -2506,11 +2511,15 @@ for an object named "Test", preferring a thing over other types. See also: anonymous attributes & MWHO() mwho() + mwhoid() This returns a list of the dbref numbers for all current-connected, non-hidden players. It's exactly the same as lwho() used by a mortal, and is suitable for use on privileged global objects who need an unprivileged who-list. + + mwhoid() gives a list of objids instead of dbrefs. + & ALIAS() alias([,]) @@ -2644,6 +2653,14 @@ for an object named "Test", preferring a thing over other types. Returns the dbref number of the object, which must be in the same room as the object executing num. +& NWHO() + nwho() + + This returns a count of all currently-connected players. When + mortals use this function, DARK privileged players are NOT counted. + +See also: lwho(), nmwho(), xwho() + & OBJ() obj() @@ -4563,6 +4580,25 @@ See also: timestring(), etimefmt() inputs is equivalent to true(1). See BOOLEAN VALUES. See also: and(), or(), not(), nor() +& XWHO() + xwho(, ) + xmwho(, ) + xwhoid(, ) + xmwhoid(, ) + + xwho() fetches or fewer player dbrefs from the list of connected + players. It is useful when the number of players connected causes lwho() + or pemits in +who $-commands to exceed buffer limits. + + It is equivalent to extract(lwho(),,). + + xmwho() is identical, except it is limited to non-DARK and non-HIDE + players. + + xwhoid() and xmwhoid() return objids instead of dbrefs. + +See also: lwho(), mwho(), nwho() + & ZEMIT() zemit(, ) nszemit(, ) diff --git a/src/bsd.c b/src/bsd.c index 39a3f01..cf2efce 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -3860,15 +3860,31 @@ visible_short_page(dbref player, const char *match) /* LWHO() function - really belongs elsewhere but needs stuff declared here */ +FUNCTION(fun_nwho) { + DESC *d; + int count = 0; + int powered = (*(called_as + 1) != 'M') && Priv_Who(executor); + + DESC_ITER_CONN(d) { + if (!Hidden(d) || (powered && CanSee(executor, d->player))) + count++; + } + safe_integer(count, buff, bp); +} + /* ARGSUSED */ FUNCTION(fun_lwho) { DESC *d; dbref victim; - int first, powered = (*called_as == 'L') && Priv_Who(executor); + int first; + int start, count; + int powered = !(strchr(called_as, 'M') != NULL) && Priv_Who(executor); + int xwho = *called_as == 'X'; + int objid = strchr(called_as, 'D') != NULL; first = 1; - if(nargs && args[0] && *args[0]) { + if(!xwho && nargs && args[0] && *args[0]) { if(!powered) { safe_str(T(e_perm), buff, bp); return; @@ -3885,14 +3901,41 @@ FUNCTION(fun_lwho) if(!Priv_Who(victim)) powered = 0; } else victim = executor; - + + if(xwho) { + if (!is_strict_integer(args[0]) || !is_strict_integer(args[1])) { + safe_str(T(e_int), buff, bp); + return; + } + + start = parse_integer(args[0]) - 1; + count = parse_integer(args[1]); + /* Reset values to be in range if they're not */ + if(start < 0) + start = 0; + if(count < 1) + count = 1; + } + DESC_ITER_CONN(d) { if (!Hidden(d) || (powered && CanSee(victim,d->player))) { + if(xwho && start) { + start--; + continue; + } else if(xwho && !count) + break; + else if(xwho && count) + count--; + if (first) first = 0; else safe_chr(' ', buff, bp); safe_dbref(d->player, buff, bp); + if(objid) { + safe_chr(':', buff, bp); + safe_integer(CreTime(d->player), buff, bp); + } } } } diff --git a/src/console.c b/src/console.c index f521202..07c9588 100644 --- a/src/console.c +++ b/src/console.c @@ -3143,6 +3143,9 @@ visible_short_page(dbref player, const char *match) /* LWHO() function - really belongs elsewhere but needs stuff declared here */ +FUNCTION(fun_nwho) { +} + /* ARGSUSED */ FUNCTION(fun_lwho) { diff --git a/src/function.c b/src/function.c index 398f040..9a20512 100644 --- a/src/function.c +++ b/src/function.c @@ -467,6 +467,7 @@ FUNTAB flist[] = { {"LVPLAYERS", fun_dbwalker, 1, 1, FN_REG}, {"LVTHINGS", fun_dbwalker, 1, 1, FN_REG}, {"LWHO", fun_lwho, 0, 1, FN_REG}, + {"LWHOID", fun_lwho, 0, 1, FN_REG}, {"MAIL", fun_mail, 0, 2, FN_REG}, {"MAILFROM", fun_mailfrom, 1, 2, FN_REG}, {"MAILSTATS", fun_mailstats, 1, 1, FN_REG}, @@ -494,6 +495,7 @@ FUNTAB flist[] = { {"MUL", fun_mul, 2, INT_MAX, FN_REG}, {"MUNGE", fun_munge, 3, 5, FN_REG}, {"MWHO", fun_lwho, 0, 0, FN_REG}, + {"MWHOID", fun_lwho, 0, 0, FN_REG}, {"NAME", fun_name, 0, 2, FN_REG}, {"NAMEGRAB", fun_namegrab, 2, 3, FN_REG}, {"NAMEGRABALL", fun_namegraball, 2, 3, FN_REG}, @@ -526,6 +528,8 @@ FUNTAB flist[] = { {"NSPEMIT", fun_pemit, 2, -2, FN_REG}, {"NSREMIT", fun_remit, 2, -2, FN_REG}, {"NSZEMIT", fun_zemit, 2, -2, FN_REG}, + {"NWHO", fun_nwho, 0, 0, FN_REG}, + {"NMWHO", fun_nwho, 0, 0, FN_REG}, {"NUM", fun_num, 1, 1, FN_REG}, {"NULL", fun_null, 1, INT_MAX, FN_REG}, {"OBJ", fun_obj, 1, 1, FN_REG}, @@ -693,6 +697,10 @@ FUNTAB flist[] = { {"XVEXITS", fun_dbwalker, 3, 3, FN_REG}, {"XVPLAYERS", fun_dbwalker, 3, 3, FN_REG}, {"XVTHINGS", fun_dbwalker, 3, 3, FN_REG}, + {"XWHO", fun_lwho, 2, 2, FN_REG}, + {"XWHOID", fun_lwho, 2, 2, FN_REG}, + {"XMWHO", fun_lwho, 2, 2, FN_REG}, + {"XMWHOID", fun_lwho, 2, 2, FN_REG}, {"ZEMIT", fun_zemit, 2, -2, FN_REG}, {"ZFUN", fun_zfun, 1, 11, FN_REG}, {"ZONE", fun_zone, 1, 2, FN_REG}, diff --git a/win32/funs.h b/win32/funs.h index 591c329..8f2cfb3 100644 --- a/win32/funs.h +++ b/win32/funs.h @@ -227,6 +227,7 @@ FUNCTION_PROTO(fun_nor); FUNCTION_PROTO(fun_not); FUNCTION_PROTO(fun_null); FUNCTION_PROTO(fun_num); +FUNCTION_PROTO(fun_nwho); FUNCTION_PROTO(fun_obj); FUNCTION_PROTO(fun_objeval); FUNCTION_PROTO(fun_objid);