Re: Using player.name in handler.c...

From: Welcor (welcor@dune.net)
Date: 01/21/02


----- Original Message -----
From: "Vladimir Nano" <nano.vladimir@SLSP.SK>


> Hallo:-)
> I'm using bpl18 and now i'm adding masks.
> When player wears mask, he is masked and nobody knows his name. (only
gods)
> Now i want to change functions in handler.c: get_char_room(),
> get_player_room(), ....
> In these functions is used i->player.name. Why? I think GET_NAME() macro
is
> usable.
> What do You think about it?
>
From utils.h:

#define GET_NAME(ch)    (IS_NPC(ch) ? \
    (ch)->player.short_descr : GET_PC_NAME(ch))

In other words; if you were checking on GET_NAME() instead, you'd find
mobs based on their shortdesc instead of their alias list.

I'd suggest you use a slightly different approach, adding a 'orig_name'
variable to the player struct, and using that whenever you output the
name to someone who is high enough level, etc.

<pseudocode>
in char_data (player_data):
char *orig_name;

in utils.h redefine:
#define GET_PC_NAME(ch, viewer) (((viewer) && \
     (GET_LEVEL(viewer)>LVL_IMMORT || viewer==ch)) ? \
     (ch)->player.orig_name : (ch)->player.name)

#define GET_NAME(ch, viewer) (IS_NPC(ch) ? \
    (ch)->player.short_descr : GET_PC_NAME(ch, viewer))

Change all of the occurrences of GET_NAME(blah) to GET_NAME(blah, blah)

Setup orig_name in interpreter.c:

(ch)->player.orig_name = str_dup((ch)->player.name);
if (PLR_FLAGGED(ch, PLR_MASKED)) {
  free(ch->player.name);
  (ch)->player.name = str_dup("Some masked name");
}

Remember to free() the memory when removing/wearing the mask,
and in free_char()

</pseudocode>

I hope this helps a bit.

Welcor

--
   +---------------------------------------------------------------+
   | 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/25/03 PDT