00001
00002
00003
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
00016 #define TYPE_ROOM 0x0
00017 #define TYPE_THING 0x1
00018 #define TYPE_EXIT 0x2
00019 #define TYPE_PLAYER 0x3
00020
00021 #define TYPE_GARBAGE 0x5
00022 #define NOTYPE 0x7
00023 #define TYPE_MASK 0x7
00024
00025
00026 #define SEETHRU 0x00000008
00027 #define WIZARD 0x00000010
00028 #define LINK_OK 0x00000020
00029 #define DARK 0x00000040
00030 #define JUMP_OK 0x00000080
00031 #define STICKY 0x00000100
00032 #define DESTROY_OK 0x00000200
00033 #define HAVEN 0x00000400
00034 #define QUIET 0x00000800
00035 #define HALT 0x00001000
00036 #define TRACE 0x00002000
00037 #define GOING 0x00004000
00038 #define MONITOR 0x00008000
00039 #define MYOPIC 0x00010000
00040 #define PUPPET 0x00020000
00041 #define CHOWN_OK 0x00040000
00042 #define ENTER_OK 0x00080000
00043 #define VISUAL 0x00100000
00044 #define IMMORTAL 0x00200000
00045 #define HAS_STARTUP 0x00400000
00046 #define TM_OPAQUE 0x00800000
00047 #define VERBOSE 0x01000000
00048 #define INHERIT 0x02000000
00049 #define NOSPOOF 0x04000000
00050 #define ROBOT 0x08000000
00051 #define SAFE 0x10000000
00052 #define ROYALTY 0x20000000
00053 #define HEARTHRU 0x40000000
00054 #define TERSE 0x80000000
00055
00056
00057 #define KEY 0x00000001
00058 #define ABODE 0x00000002
00059 #define FLOATING 0x00000004
00060 #define UNFINDABLE 0x00000008
00061 #define PARENT_OK 0x00000010
00062 #define LIGHT 0x00000020
00063 #define HAS_LISTEN 0x00000040
00064 #define HAS_FWDLIST 0x00000080
00065 #define AUDITORIUM 0x00000100
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
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
00080 #define BLIND 0x08000000 // Suppress has arrived / left messages.
00081 #define SUSPECT 0x10000000
00082 #define NOACCENTS 0x20000000 // Strip accented characters.
00083 #define CONNECTED 0x40000000
00084 #define SLAVE 0x80000000
00085
00086
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
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
00117
00118 typedef struct flag_bit_entry
00119 {
00120 int flagvalue;
00121 char flaglett;
00122 int flagflag;
00123 int listperm;
00124 bool (*handler)(dbref target, dbref player, FLAG flag, int fflags,
00125 bool reset);
00126 } FLAGBITENT;
00127
00128 typedef struct flag_name_entry
00129 {
00130 char *pOrigName;
00131 bool bPositive;
00132 FLAGBITENT *fbe;
00133 char *flagname;
00134 } FLAGNAMEENT;
00135
00136 extern FLAGNAMEENT gen_flag_names[];
00137
00138
00139
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
00151 #define OF_LOCATION 0x0002
00152 #define OF_EXITS 0x0004
00153 #define OF_HOME 0x0008
00154 #define OF_DROPTO 0x0010
00155 #define OF_OWNER 0x0020
00156 #define OF_SIBLINGS 0x0040
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
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
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