Re: [CODE] #define IS_CLASS

From: krenshala (krenshala@jump.net)
Date: 12/11/01


From: krenshala <krenshala@JUMP.NET>

> I am currently looking at limits.c and noticed that checks for
> a particular class are handled via IS_<CLASS>(ch) (e.g.,
> IS_CLERIC(ch)).  I also see that checks for particular AFF
> bitvectors are accomplished through the
> AFF_FLAGGED(ch,<FLAG>) function.
>
> Has anyone (aside from me :) considered coding an
> IS_CLASS(ch,<CLASS>) function that can replace the
> IS_<CLASS>(ch) functions?  I would think this make a nice
> simplification of the existing code. (I'm too tired right now
> to even attempt writing it, or I would grep for the locations
> of the various IS_<CLASS> functions and give it a try.  I've
> learned first hand what a bad idea it is to code while tired.
> Sometimes it works (sometimes REALLY well) but it's usually
> gibberish when you look at it again. <G>)

Being bored, I figured I would at least look at what kind of changes would
be required, and I have found that things are not as I thought (big suprise
there :).  While my idea is good in theory, it doesn't appear to add all
that much afer all.  :/

Looking at utils.h, it seems that my suggestion would remove four defs, add
one, and almost double the number of chars required to do the job its
already doing with teh various IF_<CLASS>(ch) routines.  I suppose that if
you had a large number of classes this might be useful as it does only
require one (1) definition in utils.h ...

BTW, assuming I'm not smoking socks or somehting, adding

    #define IS_CLASS(ch, class)  (!IS_NPC(ch) && (GET_CLASS(ch) == class))

just before

    #define OUTSIDE(ch) (!ROOM_FLAGGED((ch)->in_room, ROOM_INDOORS))

=should= work to replace the various '#define IS_<CLASS> ...' lines.
[But I take no responsibility for what might happen to your MUD if you use
my code in it.  hell, I don't take responsibility for what happens to MY mud
with my code in it :) ]

     Larry

Larry Robinson
krenshala@jump.net
:wq

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/24/03 PDT