Re: [IDEA] Global on/off values

From: Daniel A. Koepke (dkoepke@circlemud.org)
Date: 01/12/01


yOn Fri, 12 Jan 2001, Kaun Lazaro wrote:

> ok this is basicaly what I'm using, the spell marathon is mag affects, and
> gives level * 100 hit roll and damage roll to a character, gods excluded.
> Can I make it so that the line:
> static bool enabled = FALSE;

Remove the static and put it in the file scope (this makes it a global
variable), e.g.,

  bool enabled = FALSE;

  ACMD(do_marathon)
  {
    . . .
  }

You might consider renaming it to marathon_enabled to avoid any name
conflicts.  Then inside of nanny() (and/or anywhere else you want it
accessible), near the top with the other variable declarations, you would
put:

  extern bool marathon_enabled;

to import the marathon_enabled variable from the other file.  The reason
for removing the 'static' on the declaration is because it makes things
local to the file scope.  E.g.,

  static bool marathon_enabled;

would only be accessible in the file it's in.[1]

> also if anyone wants to use it put Daniel A. Koepke and myself in your
> credits.

No credit necessary for me, but it's always appreciated.  Thank you for
being considerate of me, though, even if I was a bit critical of your
original query.

-dak

[1] If you're using a C++ compiler for your mud, avoid using 'static' to
mean local to the translation unit (file), as it is deprecated according
to ISO C++.  You may still rely upon how I originally used it, though.

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/03/01 PST