From: Ari Johnson Date: Wed, 21 Feb 2007 05:05:15 +0000 (+0000) Subject: hastype() can now take a list of types to check X-Git-Tag: 0.73~140 X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=29e682fa3bc554775ef2d93a42773303c8164aff;p=cobramush.git hastype() can now take a list of types to check --- diff --git a/game/txt/hlp/cobra_func.hlp b/game/txt/hlp/cobra_func.hlp index 28974ce..3dd6e0f 100644 --- a/game/txt/hlp/cobra_func.hlp +++ b/game/txt/hlp/cobra_func.hlp @@ -1538,10 +1538,12 @@ Continued in HELP FOREACH2 See also: orlflags(), andlflags(), orflags(), andflags() & HASTYPE() - hastype(, ) + hastype(, ) Returns 1 if the object is of the named type, otherwise 0. - Valid types are: ROOM, EXIT, PLAYER, THING, GARBAGE. + Valid types are: ROOM, EXIT, PLAYER, THING, GARBAGE. You can + test to see if the object is one of a number of types by using a space- + separated list of types. If an invalid type is given, #-1 NO SUCH TYPE is returned. & HIDDEN() hidden() diff --git a/src/fundb.c b/src/fundb.c index ba3eafa..e83efdc 100644 --- a/src/fundb.c +++ b/src/fundb.c @@ -981,40 +981,52 @@ FUNCTION(fun_hasflag) /* ARGSUSED */ FUNCTION(fun_hastype) { + char *r, *s; + int found = 0; dbref it = match_thing(executor, args[0]); if (!GoodObject(it)) { safe_str(T(e_notvis), buff, bp); return; } - switch (*args[1]) { - case 'r': - case 'R': - safe_boolean(IsRoom(it), buff, bp); - break; - case 'e': - case 'E': - safe_boolean(IsExit(it), buff, bp); - break; - case 'p': - case 'P': - safe_boolean(IsPlayer(it), buff, bp); - break; - case 't': - case 'T': - safe_boolean(IsThing(it), buff, bp); - break; - case 'd': - case 'D': - safe_boolean(IsDivision(it), buff, bp); - break; - case 'g': - case 'G': - safe_boolean(IsGarbage(it), buff, bp); - break; - default: - safe_str(T("#-1 NO SUCH TYPE"), buff, bp); - break; - }; + s = trim_space_sep(args[1], ' '); + r = split_token(&s, ' '); + do { + switch (*r) { + case 'r': + case 'R': + if (IsRoom(it)) + found = 1; + break; + case 'e': + case 'E': + if (IsExit(it)) + found = 1; + break; + case 'p': + case 'P': + if (IsPlayer(it)) + found = 1; + break; + case 't': + case 'T': + if (IsThing(it)) + found = 1; + break; + case 'g': + case 'G': + if (IsGarbage(it)) + found = 1; + break; + default: + safe_str(T("#-1 NO SUCH TYPE"), buff, bp); + return; + } + if (found) { + safe_boolean(found, buff, bp); + return; + } + } while ((r = split_token(&s, ' '))); + safe_boolean(0, buff, bp); } /* ARGSUSED */