Re: [NEWBIE][CODE] Flags

From: Admin of The Keep (
Date: 10/12/96

On Sat, 12 Oct 1996, Søren Peter skou wrote:

> Hi all..
> Simple question, how to put in more flags??
> I've just toyed around to see if it's possible or how it is.. but I
> can't find any docs that describe how to do it.. Anyone who would like
> to guide me through it? (or at least tell me how to put in the flag.. :)

  Look at the start of structs.h, that's where room flags are defined.
  All flags that are of any consequence are in structs.h, just do a search
  for the start of it (ROOM_, MOB_, PLR_, PRF_, the ITEM_ will turn up
  several different types of defines).

  Flags are just defines.  In the current Circle setup (the (almost) most
  portable way), flags are defined as 'int' or 'long' (both are 32-bits),
  meaning that you can only have 32 bits (one flag is one bit).  A flag is
  defined as (1 << <bit pos>).  It'd be preferable to change all the flag
  variable to 'unsigned int' or 'unsigned long' so you are assured all 32
  bits properly.  If you are using GCC 2.7..x, 'long long' will give you 64

  For instance, to create a flag, PRF_NOFOLLOW (to stop people from
  walking up and following someone w/o warning) you'd put:

    #define PRF_NOFOLLOW 	(1 << xx) /* Won't permit followers 	*/

  Replacing 'xx' with the next availible bit pos (0-31).  Then you will
  want to add the name of the flag to constants.c (search for, once again,
  the prefix to the flag, in this case, PRF).  Add the name of the flag
  to the list before the "\n" (which terminates the array for CircleMUD's
  search_block function).  For instance:

      "NOFOLLOW",	/* ADD THIS */

  After that the rest is in the implementation of the flag's use.  For
  instance, with PRF_NOFOLLOW we'll want to create a no-follow toggle
  so we add that to do_gen_tog and the command to the array:

    In interpreter.h find where it has SCMD_AUTOEXIT, etc. and add one
    more define like: '#define SCMD_NOFOLLOW <xx>'  With <xx> being the
    next availible number (not a flag, do NOT do 1 << <xx>).  Then in
    interpreter.c find the 'n' section and put:

    { "nofollow"	, do_gen_tog, POS_DEAD, 0, SCMD_NOFOLLOW },

    Into the list (with whatever presedence you want it to have).  Next
    go do_gen_tog (in act.other.c?) and add the neccessary strings and
    'case' statement (as shown).  Note that the strings are in the order
    of the SCMD_s, so you're new one will always go last (there's no "\n"
    delimiting it).  Just follow the examples there and you should be

  Good luck,

  "Forgive me father, for I am sin."

| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   |

This archive was generated by hypermail 2b30 : 12/18/00 PST