mux/src/flags.h

Go to the documentation of this file.
00001 // flags.h -- Object flags.
00002 //
00003 // $Id: flags.h,v 1.10 2006/01/07 21:48:00 sdennis Exp $
00004 //
00005 
00006 #include "copyright.h"
00007 
00008 #ifndef __FLAGS_H
00009 #define __FLAGS_H
00010 
00011 #define FLAG_WORD1    0x0 // 1st word of flags.
00012 #define FLAG_WORD2    0x1 // 2nd word of flags.
00013 #define FLAG_WORD3    0x2 // 3rd word of flags.
00014 
00015 /* Object types */
00016 #define TYPE_ROOM     0x0
00017 #define TYPE_THING    0x1
00018 #define TYPE_EXIT     0x2
00019 #define TYPE_PLAYER   0x3
00020 /* Empty */
00021 #define TYPE_GARBAGE  0x5
00022 #define NOTYPE        0x7
00023 #define TYPE_MASK     0x7
00024 
00025 /* First word of flags */
00026 #define SEETHRU      0x00000008  /* Can see through to the other side */
00027 #define WIZARD       0x00000010  /* gets automatic control */
00028 #define LINK_OK      0x00000020  /* anybody can link to this room */
00029 #define DARK         0x00000040  /* Don't show contents or presence */
00030 #define JUMP_OK      0x00000080  /* Others may @tel here */
00031 #define STICKY       0x00000100  /* Object goes home when dropped */
00032 #define DESTROY_OK   0x00000200  /* Others may @destroy */
00033 #define HAVEN        0x00000400  /* No killing here, or no pages */
00034 #define QUIET        0x00000800  /* Prevent 'feelgood' messages */
00035 #define HALT         0x00001000  /* object cannot perform actions */
00036 #define TRACE        0x00002000  /* Generate evaluation trace output */
00037 #define GOING        0x00004000  /* object is available for recycling */
00038 #define MONITOR      0x00008000  /* Process ^x:action listens on obj? */
00039 #define MYOPIC       0x00010000  /* See things as nonowner/nonwizard */
00040 #define PUPPET       0x00020000  /* Relays ALL messages to owner */
00041 #define CHOWN_OK     0x00040000  /* Object may be @chowned freely */
00042 #define ENTER_OK     0x00080000  /* Object may be ENTERed */
00043 #define VISUAL       0x00100000  /* Everyone can see properties */
00044 #define IMMORTAL     0x00200000  /* Object can't be killed */
00045 #define HAS_STARTUP  0x00400000  /* Load some attrs at startup */
00046 #define TM_OPAQUE    0x00800000  /* Can't see inside */
00047 #define VERBOSE      0x01000000  /* Tells owner everything it does. */
00048 #define INHERIT      0x02000000  /* Gets owner's privs. (i.e. Wiz) */
00049 #define NOSPOOF      0x04000000  /* Report originator of all actions. */
00050 #define ROBOT        0x08000000  /* Player is a ROBOT */
00051 #define SAFE         0x10000000  /* Need /override to @destroy */
00052 #define ROYALTY      0x20000000  /* Sees like a wiz, but ca't modify */
00053 #define HEARTHRU     0x40000000  /* Can hear out of this obj or exit */
00054 #define TERSE        0x80000000  /* Only show room name on look */
00055 
00056 /* Second word of flags */
00057 #define KEY          0x00000001  /* No puppets */
00058 #define ABODE        0x00000002  /* May @set home here */
00059 #define FLOATING     0x00000004  /* Inhibit Floating room.. msgs */
00060 #define UNFINDABLE   0x00000008  /* Cant loc() from afar */
00061 #define PARENT_OK    0x00000010  /* Others may @parent to me */
00062 #define LIGHT        0x00000020  /* Visible in dark places */
00063 #define HAS_LISTEN   0x00000040  /* Internal: LISTEN attr set */
00064 #define HAS_FWDLIST  0x00000080  /* Internal: FORWARDLIST attr set */
00065 #define AUDITORIUM   0x00000100  /* Should we check the SpeechLock? */
00066 #define ANSI         0x00000200
00067 #define HEAD_FLAG    0x00000400
00068 #define FIXED        0x00000800
00069 #define UNINSPECTED  0x00001000
00070 #define NO_COMMAND   0x00002000
00071 #define CKEEPALIVE   0x00004000  /* User receives keepalives from the MUX */
00072 #define NOBLEED      0x00008000
00073 #define STAFF        0x00010000
00074 #define HAS_DAILY    0x00020000
00075 #define GAGGED       0x00040000
00076 #define OPEN_OK      0x00080000  // You can open exits from here if you pass the openlock.
00077 #define VACATION     0x01000000
00078 #define PLAYER_MAILS 0x02000000
00079 #define HTML         0x04000000  /* Player supports HTML */
00080 #define BLIND        0x08000000  // Suppress has arrived / left messages.
00081 #define SUSPECT      0x10000000  /* Report some activities to wizards */
00082 #define NOACCENTS    0x20000000  // Strip accented characters.
00083 #define CONNECTED    0x40000000  /* Player is connected */
00084 #define SLAVE        0x80000000  /* Disallow most commands */
00085 
00086 // Third word of flags
00087 //
00088 #if defined(WOD_REALMS) || defined(REALITY_LVLS)
00089 #define OBF          0x00000001      // Obfuscate Flag
00090 #define HSS          0x00000002      // Auspex/Heightened Senses Flag
00091 #define UMBRA        0x00000004      // Umbra, UMBRADESC
00092 #define SHROUD       0x00000008      // Shroud, WRAITHDESC
00093 #define MATRIX       0x00000010      // Matrix, MATRIXDESC
00094 #define MEDIUM       0x00000020
00095 #define DEAD         0x00000040
00096 #define FAE          0x00000080      // Fae, FAEDESC
00097 #define CHIMERA      0x00000100      // Fae, FAEDESC
00098 #define PEERING      0x00000200      // Means the a looker is seeing a
00099                                      // different realm than they are in.
00100 #endif // WOD_REALMS
00101 
00102 #define SITEMON      0x00000400      // Sitemonitor Flag
00103 #define CMDCHECK     0x00000800      // Has @icmd set
00104 #define MARK_0       0x00400000      // User-defined flags.
00105 #define MARK_1       0x00800000
00106 #define MARK_2       0x01000000
00107 #define MARK_3       0x02000000
00108 #define MARK_4       0x04000000
00109 #define MARK_5       0x08000000
00110 #define MARK_6       0x10000000
00111 #define MARK_7       0x20000000
00112 #define MARK_8       0x40000000
00113 #define MARK_9       0x80000000
00114 
00115 /* ---------------------------------------------------------------------------
00116  * FLAGENT: Information about object flags.
00117  */
00118 typedef struct flag_bit_entry
00119 {
00120     int  flagvalue;         // Which bit in the object is the flag.
00121     char flaglett;          // Flag letter for listing.
00122     int  flagflag;          // Ctrl flags for this flag.
00123     int  listperm;          // Who sees this flag when set.
00124     bool (*handler)(dbref target, dbref player, FLAG flag, int fflags,
00125         bool reset);         // Handler for setting/clearing this flag.
00126 } FLAGBITENT;
00127 
00128 typedef struct flag_name_entry
00129 {
00130     char *pOrigName;        // Original name of flag.
00131     bool bPositive;         // Flag sense.
00132     FLAGBITENT *fbe;        // Which bit is this associated with?
00133     char *flagname;         // Name of the flag.
00134 } FLAGNAMEENT;
00135 
00136 extern FLAGNAMEENT gen_flag_names[];
00137 
00138 /* ---------------------------------------------------------------------------
00139  * OBJENT: Fundamental object types
00140  */
00141 
00142 typedef struct object_entry {
00143     const char *name;
00144     char    lett;
00145     int perm;
00146     int flags;
00147 } OBJENT;
00148 extern OBJENT object_types[8];
00149 
00150 #define OF_CONTENTS 0x0001      /* Object has contents: Contents() */
00151 #define OF_LOCATION 0x0002      /* Object has a location: Location() */
00152 #define OF_EXITS    0x0004      /* Object has exits: Exits() */
00153 #define OF_HOME     0x0008      /* Object has a home: Home() */
00154 #define OF_DROPTO   0x0010      /* Object has a dropto: Dropto() */
00155 #define OF_OWNER    0x0020      /* Object can own other objects */
00156 #define OF_SIBLINGS 0x0040      /* Object has siblings: Next() */
00157 
00158 typedef struct flagset
00159 {
00160     FLAG  word[3];
00161 } FLAGSET;
00162 
00163 extern void init_flagtab(void);
00164 extern void display_flagtab(dbref);
00165 extern void flag_set(dbref, dbref, char *, int);
00166 extern char *flag_description(dbref, dbref);
00167 extern char *decode_flags(dbref, FLAGSET *);
00168 extern bool has_flag(dbref, dbref, char *);
00169 extern char *unparse_object(dbref, dbref, bool);
00170 extern char *unparse_object_numonly(dbref);
00171 extern bool convert_flags(dbref, char *, FLAGSET *, FLAG *);
00172 extern void decompile_flags(dbref, dbref, char *);
00173 extern char *MakeCanonicalFlagName
00174 (
00175     const char *pName,
00176     int *pnName,
00177     bool *pbValid
00178 );
00179 
00180 #define GOD ((dbref) 1)
00181 
00182 /* ---------------------- Object Permission/Attribute Macros */
00183 /* Typeof(X)            - What object type is X */
00184 /* God(X)               - Is X player #1 */
00185 /* Robot(X)             - Is X a robot player */
00186 /* Wizard(X)            - Does X have wizard privs */
00187 /* Immortal(X)          - Is X unkillable */
00188 /* Dark(X)              - Is X dark */
00189 /* Floating(X)          - Prevent 'disconnected room' msgs for room X */
00190 /* Quiet(X)             - Should 'Set.' messages et al from X be disabled */
00191 /* Verbose(X)           - Should owner receive all commands executed? */
00192 /* Trace(X)             - Should owner receive eval trace output? */
00193 /* Player_haven(X)      - Is the owner of X no-page */
00194 /* Haven(X)             - Is X no-kill(rooms) or no-page(players) */
00195 /* Halted(X)            - Is X halted (not allowed to run commands)? */
00196 /* Suspect(X)           - Is X someone the wizzes should keep an eye on */
00197 /* Slave(X)             - Should X be prevented from db-changing commands */
00198 /* Safe(X,P)            - Does P need the /OVERRIDE switch to @destroy X? */
00199 /* Monitor(X)           - Should we check for ^xxx:xxx listens on player? */
00200 /* Terse(X)             - Should we only show the room name on a look? */
00201 /* Myopic(X)            - Should things as if we were nonowner/nonwiz */
00202 /* Audible(X)           - Should X forward messages? */
00203 /* Findroom(X)          - Can players in room X be found via @whereis? */
00204 /* Unfindroom(X)        - Is @whereis blocked for players in room X? */
00205 /* Findable(X)          - Can @whereis find X */
00206 /* Unfindable(X)        - Is @whereis blocked for X */
00207 /* No_robots(X)         - Does X disallow robot players from using */
00208 /* Has_location(X)      - Is X something with a location (ie plyr or obj) */
00209 /* Has_home(X)          - Is X something with a home (ie plyr or obj) */
00210 /* Has_contents(X)      - Is X something with contents (ie plyr/obj/room) */
00211 /* Good_dbref(X)        - Is X inside the DB? */
00212 /* Good_obj(X)          - Is X inside the DB and have a valid type? */
00213 /* Good_owner(X)        - Is X a good owner value? */
00214 /* Going(X)             - Is X marked GOING? */
00215 /* Inherits(X)          - Does X inherit the privs of its owner */
00216 /* Examinable(P,X)      - Can P look at attribs of X */
00217 /* MyopicExam(P,X)      - Can P look at attribs of X (obeys MYOPIC) */
00218 /* Controls(P,X)        - Can P force X to do something */
00219 /* Abode(X)             - Is X an ABODE room */
00220 /* Link_exit(P,X)       - Can P link from exit X */
00221 /* Linkable(P,X)        - Can P link to X */
00222 /* Mark(x)              - Set marked flag on X */
00223 /* Unmark(x)            - Clear marked flag on X */
00224 /* Marked(x)            - Check marked flag on X */
00225 /* See_attr(P,X.A,O,F)  - Can P see text attr A on X if attr has owner O */
00226 /* KeepAlive(x)         - Does the user want keepalives? */
00227 
00228 #define Typeof(x)           (Flags(x) & TYPE_MASK)
00229 #define God(x)              ((x) == GOD)
00230 #define Robot(x)            (isPlayer(x) && ((Flags(x) & ROBOT) != 0))
00231 #define OwnsOthers(x)       ((object_types[Typeof(x)].flags & OF_OWNER) != 0)
00232 #define Has_location(x)     ((object_types[Typeof(x)].flags & OF_LOCATION) != 0)
00233 #define Has_contents(x)     ((object_types[Typeof(x)].flags & OF_CONTENTS) != 0)
00234 #define Has_exits(x)        ((object_types[Typeof(x)].flags & OF_EXITS) != 0)
00235 #define Has_siblings(x)     ((object_types[Typeof(x)].flags & OF_SIBLINGS) != 0)
00236 #define Has_home(x)         ((object_types[Typeof(x)].flags & OF_HOME) != 0)
00237 #define Has_dropto(x)       ((object_types[Typeof(x)].flags & OF_DROPTO) != 0)
00238 #define Home_ok(x)          ((object_types[Typeof(x)].flags & OF_HOME) != 0)
00239 #define isPlayer(x)         (Typeof(x) == TYPE_PLAYER)
00240 #define isRoom(x)           (Typeof(x) == TYPE_ROOM)
00241 #define isExit(x)           (Typeof(x) == TYPE_EXIT)
00242 #define isThing(x)          (Typeof(x) == TYPE_THING)
00243 #define isGarbage(x)        (Typeof(x) == TYPE_GARBAGE)
00244 
00245 #define Good_dbref(x)       (((x) >= 0) && ((x) < mudstate.db_top))
00246 #define Good_obj(x)         (Good_dbref(x) && (Typeof(x) < TYPE_GARBAGE))
00247 #define Good_owner(x)       (Good_obj(x) && OwnsOthers(x))
00248 
00249 #define Staff(x)            (Wizard(x) || Royalty(x) || ((Flags2(x) & STAFF) != 0))
00250 #define Royalty(x)          ((Flags(x) & ROYALTY) || \
00251                             ((Flags(Owner(x)) & ROYALTY) && Inherits(x)))
00252 #define WizRoy(x)           (Royalty(x) || Wizard(x))
00253 #define Head(x)             ((Flags2(x) & HEAD_FLAG) != 0)
00254 #define Fixed(x)            ((Flags2(x) & FIXED) != 0)
00255 #define Uninspected(x)      ((Flags2(x) & UNINSPECTED) != 0)
00256 #define Ansi(x)             ((Flags2(x) & ANSI) != 0)
00257 #define NoAccents(x)        ((Flags2(x) & NOACCENTS) != 0)
00258 #define No_Command(x)       ((Flags2(x) & NO_COMMAND) != 0)
00259 #define NoBleed(x)          ((Flags2(x) & NOBLEED) != 0)
00260 #define KeepAlive(x)        ((Flags2(x) & CKEEPALIVE) != 0)
00261 
00262 #define Transparent(x)      ((Flags(x) & SEETHRU) != 0)
00263 #define Link_ok(x)          (((Flags(x) & LINK_OK) != 0) && Has_contents(x))
00264 #define Open_ok(x)          (((Flags2(x) & OPEN_OK) != 0) && Has_exits(x))
00265 #define Wizard(x)           ((Flags(x) & WIZARD) || \
00266                             ((Flags(Owner(x)) & WIZARD) && Inherits(x)))
00267 #define Dark(x)             (((Flags(x) & DARK) != 0) && (Wizard(x) || \
00268                             !(isPlayer(x) || (Puppet(x) && Has_contents(x)))))
00269 #define Jump_ok(x)          (((Flags(x) & JUMP_OK) != 0) && Has_contents(x))
00270 #define Sticky(x)           ((Flags(x) & STICKY) != 0)
00271 #define Destroy_ok(x)       ((Flags(x) & DESTROY_OK) != 0)
00272 #define Haven(x)            ((Flags(x) & HAVEN) != 0)
00273 #define Player_haven(x)     ((Flags(Owner(x)) & HAVEN) != 0)
00274 #define Quiet(x)            ((Flags(x) & QUIET) != 0)
00275 #define Halted(x)           ((Flags(x) & HALT) != 0)
00276 #define Trace(x)            ((Flags(x) & TRACE) != 0)
00277 #define Going(x)            ((Flags(x) & GOING) != 0)
00278 #define Monitor(x)          ((Flags(x) & MONITOR) != 0)
00279 #define Myopic(x)           ((Flags(x) & MYOPIC) != 0)
00280 #define Puppet(x)           ((Flags(x) & PUPPET) != 0)
00281 #define Chown_ok(x)         ((Flags(x) & CHOWN_OK) != 0)
00282 #define Enter_ok(x)         (((Flags(x) & ENTER_OK) != 0) && \
00283                             Has_location(x) && Has_contents(x))
00284 #define Immortal(x)         ((Flags(x) & IMMORTAL) || \
00285                             ((Flags(Owner(x)) & IMMORTAL) && Inherits(x)))
00286 #define Opaque(x)           ((Flags(x) & TM_OPAQUE) != 0)
00287 #define Verbose(x)          ((Flags(x) & VERBOSE) != 0)
00288 #define Inherits(x)         (((Flags(x) & INHERIT) != 0) || \
00289                             ((Flags(Owner(x)) & INHERIT) != 0) || \
00290                             ((x) == Owner(x)))
00291 #define Nospoof(x)          ((Flags(x) & NOSPOOF) != 0)
00292 #define Safe(x,p)           (OwnsOthers(x) || (Flags(x) & SAFE) || \
00293                             (mudconf.safe_unowned && (Owner(x) != Owner(p))))
00294 #define Audible(x)          ((Flags(x) & HEARTHRU) != 0)
00295 #define Terse(x)            ((Flags(x) & TERSE) != 0)
00296 
00297 #define Gagged(x)           ((Flags2(x) & GAGGED) != 0)
00298 #define Vacation(x)         ((Flags2(x) & VACATION) != 0)
00299 #define Key(x)              ((Flags2(x) & KEY) != 0)
00300 #define Abode(x)            (((Flags2(x) & ABODE) != 0) && Home_ok(x))
00301 #define Auditorium(x)       ((Flags2(x) & AUDITORIUM) != 0)
00302 #define Floating(x)         ((Flags2(x) & FLOATING) != 0)
00303 #define Findable(x)         ((Flags2(x) & UNFINDABLE) == 0)
00304 #define Hideout(x)          ((Flags2(x) & UNFINDABLE) != 0)
00305 #define Parent_ok(x)        ((Flags2(x) & PARENT_OK) != 0)
00306 #define Light(x)            ((Flags2(x) & LIGHT) != 0)
00307 #define Suspect(x)          ((Flags2(Owner(x)) & SUSPECT) != 0)
00308 #define Connected(x)        (((Flags2(x) & CONNECTED) != 0) && \
00309                             (Typeof(x) == TYPE_PLAYER))
00310 #define Slave(x)            ((Flags2(Owner(x)) & SLAVE) != 0)
00311 #define Hidden(x)           ((Flags(x) & DARK) != 0)
00312 #define Blind(x)            ((Flags2(x) & BLIND) != 0)
00313 
00314 #define H_Startup(x)        ((Flags(x) & HAS_STARTUP) != 0)
00315 #define H_Fwdlist(x)        ((Flags2(x) & HAS_FWDLIST) != 0)
00316 #define H_Listen(x)         ((Flags2(x) & HAS_LISTEN) != 0)
00317 
00318 #define s_Halted(x)         s_Flags((x), FLAG_WORD1, Flags(x) | HALT)
00319 #define s_Going(x)          s_Flags((x), FLAG_WORD1, Flags(x) | GOING)
00320 #define s_Connected(x)      s_Flags((x), FLAG_WORD2, Flags2(x) | CONNECTED)
00321 #define c_Connected(x)      s_Flags((x), FLAG_WORD2, Flags2(x) & ~CONNECTED)
00322 #define SiteMon(x)          ((Flags3(x) & SITEMON) != 0)
00323 #define CmdCheck(x)         ((Flags3(x) & CMDCHECK) != 0)
00324 #if defined(WOD_REALMS) || defined(REALITY_LVLS)
00325 #define isObfuscate(x)        ((Flags3(x) & OBF) != 0)
00326 #define isHeightenedSenses(x) ((Flags3(x) & HSS) != 0)
00327 #define isUmbra(x)            ((Flags3(x) & UMBRA) != 0)
00328 #define isShroud(x)           ((Flags3(x) & SHROUD) != 0)
00329 #define isMatrix(x)           ((Flags3(x) & MATRIX) != 0)
00330 #define isMedium(x)           ((Flags3(x) & MEDIUM) != 0)
00331 #define isDead(x)             ((Flags3(x) & DEAD) != 0)
00332 #define isFae(x)              ((Flags3(x) & FAE) != 0)
00333 #define isChimera(x)          ((Flags3(x) & CHIMERA) != 0)
00334 #define isPeering(x)          ((Flags3(x) & PEERING) != 0)
00335 #endif // WOD_REALMS
00336 
00337 
00338 #define Parentable(p,x)     (Controls(p,x) || \
00339                             (Parent_ok(x) && could_doit(p,x,A_LPARENT)))
00340 
00341 #define Examinable(p,x)     (((Flags(x) & VISUAL) != 0) || \
00342                             (See_All(p)) || \
00343                             (Owner(p) == Owner(x)) || \
00344                             (check_zone(p,x)))
00345 
00346 #define MyopicExam(p,x)     (((Flags(x) & VISUAL) != 0) || \
00347                             (!Myopic(p) && (See_All(p) || \
00348                             (Owner(p) == Owner(x)) || \
00349                             (check_zone(p,x)))))
00350 
00351 #define Controls(p,x)       (Good_obj(x) && \
00352                             (!(God(x) && !God(p))) && \
00353                             (Control_All(p) || \
00354                             ((Owner(p) == Owner(x)) && \
00355                             (Inherits(p) || !Inherits(x))) || \
00356                             (check_zone(p,x))))
00357 
00358 #define Mark(x)             (mudstate.markbits->chunk[(x)>>3] |= \
00359                             mudconf.markdata[(x)&7])
00360 #define Unmark(x)           (mudstate.markbits->chunk[(x)>>3] &= \
00361                             ~mudconf.markdata[(x)&7])
00362 #define Marked(x)           ((mudstate.markbits->chunk[(x)>>3] & \
00363                             mudconf.markdata[(x)&7]) ? true : false)
00364 #define Mark_all(i)         {for ((i)=0; (i)<((mudstate.db_top+7)>>3); (i)++) \
00365                             mudstate.markbits->chunk[i]=0xFFU;}
00366 #define Unmark_all(i)       {for ((i)=0; (i)<((mudstate.db_top+7)>>3); (i)++) \
00367                             mudstate.markbits->chunk[i]=0x0;}
00368 #define Link_exit(p,x)      ((Typeof(x) == TYPE_EXIT) && \
00369                             ((Location(x) == NOTHING) || Controls(p,x)))
00370 #define Linkable(p,x)       (Good_obj(x) && Has_contents(x) && \
00371                             (((Flags(x) & LINK_OK) != 0) || Controls(p,x)))
00372 #define See_attr(p,x,a)     (!((a)->flags & AF_IS_LOCK) && bCanReadAttr(p,x,a,false))
00373 #define See_attr_explicit(p,x,a,o,f) (!((a)->flags & (AF_INTERNAL|AF_IS_LOCK)) && \
00374                             (((f) & AF_VISUAL) || (Owner(p) == (o)) && \
00375                             !((a)->flags & (AF_DARK|AF_MDARK))))
00376 
00377 #define Has_power(p,x)      (check_access((p),powers_nametab[x].flag))
00378 #define Html(x)             ((Flags2(x) & HTML) != 0)
00379 #define s_Html(x)           s_Flags((x), FLAG_WORD2, Flags2(x) | HTML)
00380 
00381 #endif // !__FLAGS_H

Generated on Mon May 28 04:40:09 2007 for MUX by  doxygen 1.4.7