Re: [CODE] IS_CLASS function

From: Artovil (artovil@arcanerealms.org)
Date: 12/11/01


At 09:07 2001-12-11 -0500, Carlos Myers wrote:
>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.
>
>The problem I have with this is I think that will make things _harder_ to
>read and understand.
>
>Let's compare:
>
>     if (IS_MAGIC_USER(ch))
>         send_to_char("You are a magic user", ch);
>
>to:
>
>     if (IS_CLASS(ch, CLASS_MAGIC_USER))
>         send_to_char("You are a magic user", ch);
>
>Now tell me.  Which of those two arguments do you find easier to understand?
>
>Carlos

Have to reply.  Actually, I find the second version easier to understand;
which depends on what you are used to I guess.  The reason as to why the
latter macro would be good could be that he does not want to modify utils.h
AND structs.h every time he adds/removes/changes a class?  Perhaps lazy,
but it has a point, since the utils.h file is included in every large file
in the mud, and on some puters that takes ages to compile (but since he
changes both files it doesn't really matter, yes).  It's just a layout
issue I guess.

The first version requires a macro for every class, which is kind of
redundant.  The second version only requires the actual defines in
structs.h and the macro in utils.h to work, plus it is easier to do a grep
on IS_CLASS() than on every darn class there is.

I have about 10 different magic classes in my MUD, which "forced" me to
make a macro, IS_MAGI(ch) so that I could check if they were a magic user
or something else.  This is useful with checks for spells, potions, and
other things, at least for me.  That is a bad thing, since I have to change
both structs.h and utils.h whenever I decide to change the layout of my
classes (which doesn't happen very often, of course).  I'd rather have the
second version here if I could. :)

Just my two cents...

Regards,
/Torgny

--
   +---------------------------------------------------------------+
   | 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