Re: Nanny function

From: Elie Rosenblum (
Date: 03/20/02

On Wed, Mar 20, 2002 at 08:59:51AM +0100, Torgny Bjers wrote:
> I agree.  Perhaps there had already been something like this planned for a
> future patch release of Circle?  It is very awkward to have a switch with
> that size.  If you want to add something inbetween two cases you have to
> read through all of nanny just to be sure that you are adding it correctly.
> If all the different cases had their code in their own functions that simply
> returned either an int or a true/false depending on the result, nanny would
> all of a sudden be a little bit prettier, and a lot easier to handle.
> Go ahead. Shoot me down. Destroy my dreams in the wink of an eye. ;)

You're on the right track. The right thing to do is have two variables
on each descriptor:
  .callback: Function pointer to a nanny type function
  .state: Used like it is now, but instead of representing full
          state, a callback can use it to represent a substate so
          each subsystem can combine multiple situations into a
          single callback.

Compatibility would be easy. By default, you still point callback at
the existing nanny function and use the existing states. Instead of
just changing states though when we used to do that, you'll have to
change callbacks and sometimes states.

This allows situations where STATE(d) is CON_PLAYING but the user is
being prompted for verification of something, for example. You could
even have a 'newbie mode' magic system with an interactive magic
menu, though that'd be kinda dumb. :)

Elie Rosenblum                 That is not dead which can eternal lie,   And with strange aeons even death may die.
Admin / Mercenary / System Programmer             - _The Necronomicon_

   | FAQ: |
   | Archives: |
   | Newbie List:   |

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