region.h

Go to the documentation of this file.
00001 /*      SCCS Id: @(#)region.h   3.4     2002/10/15      */
00002 /* Copyright (c) 1996 by Jean-Christophe Collet                   */
00003 /* NetHack may be freely redistributed.  See license for details. */
00004 
00005 #ifndef REGION_H
00006 #define REGION_H
00007 
00008 /* generic callback function */
00009 
00010 typedef boolean FDECL((*callback_proc), (genericptr_t, genericptr_t));
00011 
00012 /*
00013  * Overload the old player_inside field with two values, coded in such
00014  * a way as to retain compatibility with 3.4.0 save and bones files;
00015  * this relies on the fact that nethack's `boolean' is really stored
00016  * in a `char' (or bigger type) rather than in a single bit.
00017  *
00018  * 3.4.1 save and bones files will be correct.
00019  * 3.4.0 save files restored under 3.4.1 will be correct.
00020  * 3.4.0 bones files used with 3.4.1 will continue to have the minor
00021  *       3.4.0 bug of falsely claiming that the current game's hero is
00022  *       responsible for the dead former hero's stinking clouds.
00023  */
00024 #define REG_HERO_INSIDE 1
00025 #define REG_NOT_HEROS   2
00026 #define hero_inside(r)  ((unsigned)(r)->player_flags & REG_HERO_INSIDE)
00027 #define heros_fault(r)  (!((unsigned)(r)->player_flags & REG_NOT_HEROS))
00028 #define set_hero_inside(r)      ((r)->player_flags |= REG_HERO_INSIDE)
00029 #define clear_hero_inside(r)    ((r)->player_flags &= ~REG_HERO_INSIDE)
00030 #define set_heros_fault(r)      ((r)->player_flags &= ~REG_NOT_HEROS)
00031 #define clear_heros_fault(r)    ((r)->player_flags |= REG_NOT_HEROS)
00032 
00033 typedef struct {
00034   NhRect bounding_box;          /* Bounding box of the region */
00035   NhRect *rects;                /* Rectangles composing the region */
00036   short  nrects;                /* Number of rectangles  */
00037   boolean attach_2_u;           /* Region attached to player ? */
00038   unsigned int attach_2_m;      /* Region attached to monster ? */
00039   /*struct obj *attach_2_o;*/   /* Region attached to object ? UNUSED YET */
00040   const char* enter_msg;        /* Message when entering */
00041   const char* leave_msg;        /* Message when leaving */
00042   short  ttl;                   /* Time to live. -1 is forever */
00043   short expire_f;               /* Function to call when region's ttl expire */
00044   short can_enter_f;            /* Function to call to check wether the player
00045                                    can, or can not, enter the region */
00046   short enter_f;                /* Function to call when the player enters*/
00047   short can_leave_f;            /* Function to call to check wether the player
00048                                    can, or can not, leave the region */
00049   short leave_f;                /* Function to call when the player leaves */
00050   short inside_f;               /* Function to call every turn if player's
00051                                    inside */
00052   boolean player_flags; /* (see above) */
00053   unsigned int* monsters;       /* Monsters currently inside this region */
00054   short n_monst;                /* Number of monsters inside this region */
00055   short max_monst;              /* Maximum number of monsters that can be
00056                                    listed without having to grow the array */
00057 #define MONST_INC       5
00058 
00059   /* Should probably do the same thing about objects */
00060 
00061   boolean visible;              /* Is the region visible ? */
00062   int glyph;                    /* Which glyph to use if visible */
00063   genericptr_t arg;             /* Optional user argument (Ex: strength of
00064                                    force field, damage of a fire zone, ...*/
00065 } NhRegion;
00066 
00067 #endif /* REGION_H */