TinyMUSH 3.3
TinyMUSH Server
Loading...
Searching...
No Matches
macros.h
Go to the documentation of this file.
1
14#ifndef __MACROS_H
15#define __MACROS_H
16
22// Allocation Functions
23#define XMALLOC(s, v) __xmalloc(s, __FILE__, __LINE__, __func__, v)
24#define XNMALLOC(s) __xmalloc(s, NULL, 0, NULL, NULL)
25#define XCALLOC(n, s, v) __xcalloc(n, s, __FILE__, __LINE__, __func__, v)
26#define XNCALLOC(n, s) __xcalloc(n, s, NULL, 0, NULL, NULL)
27#define XREALLOC(p, s, v) __xrealloc((void *)(p), s, __FILE__, __LINE__, __func__, v)
28#define XNREALLOC(p, s) __xrealloc((void *)(p), s, NULL, 0, NULL, NULL)
29#define XFREE(p) __xfree((void *)(p))
30#define XHEADER(p) (MEMTRACK *)((char *)(p) - sizeof(MEMTRACK));
31
32// String Functions
33#define XASPRINTF(v, f, ...) __xasprintf(__FILE__, __LINE__, __func__, v, (const char *)(f), ##__VA_ARGS__)
34#define XAVSPRINTF(v, f, a) __xavsprintf(__FILE__, __LINE__, __func__, v, (const char *)(f), a)
35#define XNASPRINTF(f, ...) __xasprintf(NULL, 0, NULL, NULL, (const char *)(f), ##__VA_ARGS__);
36#define XSPRINTF(s, f, ...) __xsprintf((char *)(s), (const char *)(f), ##__VA_ARGS__)
37#define XSPRINTFCAT(s, f, ...) __xsprintfcat((char *)(s), (const char *)(f), ##__VA_ARGS__)
38#define XVSPRINTF(s, f, a) __xvsprintf((char *)(s), (const char *)(f), a)
39#define XSNPRINTF(s, n, f, ...) __xsnprintf((char *)(s), n, (const char *)(f), ##__VA_ARGS__)
40#define XVSNPRINTF(s, n, f, a) __xvsnprintf((char *)(s), n, (const char *)(f), a)
41#define XSTRDUP(s, v) __xstrdup((const char *)(s), __FILE__, __LINE__, __func__, v)
42#define XNSTRDUP(s) __xstrdup((const char *)(s), NULL, 0, NULL, NULL)
43#define XSTRCAT(d, s) __xstrcat((char *)(d), (const char *)(s))
44#define XSTRNCAT(d, s, n) __xstrncat((char *)(d), (const char *)(s), n)
45#define XSTRCCAT(d, c) __xstrccat((char *)(d), (const char)(c))
46#define XSTRNCCAT(d, c, n) __xstrnccat((char *)(d), (const char)(c), n)
47#define XSTRCPY(d, s) __xstrcpy((char *)(d), (const char *)(s))
48#define XSTRNCPY(d, s, n) __xstrncpy((char *)(d), (const char *)(s), n)
49#define XMEMMOVE(d, s, n) __xmemmove((void *)(d), (void *)(s), n)
50#define XMEMCPY(d, s, n) __xmemmove((void *)(d), (void *)(s), n)
51#define XMEMSET(s, c, n) __xmemset((void *)(s), c, n)
52
53// Replacement for the safe_* functions.
54#define SAFE_SPRINTF(s, p, f, ...) __xsafesprintf(s, p, f, ##__VA_ARGS__);
55
56#define SAFE_COPY_CHR(c, b, p, s) __xsafestrcatchr(b, p, c, s)
57#define SAFE_STRCATCHR(b, p, c, s) __xsafestrcatchr(b, p, c, s)
58
59#define SAFE_LB_CHR(c, b, p) __xsafestrcatchr(b, p, c, LBUF_SIZE - 1)
60#define SAFE_SB_CHR(c, b, p) __xsafestrcatchr(b, p, c, SBUF_SIZE - 1)
61#define SAFE_MB_CHR(c, b, p) __xsafestrcatchr(b, p, c, MBUF_SIZE - 1)
62
63#define SAFE_STRNCAT(b, p, s, n, z) __xsafestrncat(b, p, s, n, z);
64#define SAFE_STRCAT(b, p, s, n) (s ? __xsafestrncat(b, p, s, strlen(s), n) : 0)
65
66#define SAFE_LB_STR(s, b, p) (s ? __xsafestrncpy(b, p, s, strlen(s), LBUF_SIZE - 1) : 0)
67#define SAFE_SB_STR(s, b, p) (s ? __xsafestrncpy(b, p, s, strlen(s), SBUF_SIZE - 1) : 0)
68#define SAFE_MB_STR(s, b, p) (s ? __xsafestrncpy(b, p, s, strlen(s), MBUF_SIZE - 1) : 0)
69
70#define SAFE_CRLF(b, p) SAFE_STRCAT(b, p, "\r\n", LBUF_SIZE - 1)
71#define SAFE_ANSI_NORMAL(b, p) SAFE_STRCAT(b, p, ANSI_NORMAL, LBUF_SIZE - 1)
72#define SAFE_NOTHING(b, p) SAFE_STRCAT(b, p, "#-1", LBUF_SIZE - 1)
73#define SAFE_NOPERM(b, p) SAFE_STRCAT(b, p, "#-1 PERMISSION DENIED", LBUF_SIZE - 1)
74#define SAFE_NOMATCH(b, p) SAFE_STRCAT(b, p, "#-1 NO MATCH", LBUF_SIZE - 1)
75#define SAFE_BOOL(b, p, n) SAFE_LB_CHR(((n) ? '1' : '0'), (b), (p))
76
77#define SAFE_LTOS(d, p, n, s) __xsafeltos(d, p, n, s)
78
79// Misc Macros
80#define XGETSIZE(p) (((char *)__xfind(p)->magic - p) - sizeof(char))
81#define XCALSIZE(s, d, p) ((s - ((*p) - d)))
82#define XLTOS(n) __xasprintf(__FILE__, __LINE__, __func__, "XLTOS", "%ld", n)
83
93#define ATRNUM_BLOCK_SIZE (int)((mushstate.db_block_size - 32) / (2 * sizeof(int) + VNAME_SIZE))
94#define ATRNUM_BLOCK_BYTES (int)((ATRNUM_BLOCK_SIZE) * (2 * sizeof(int) + VNAME_SIZE))
95#define OBJECT_BLOCK_SIZE (int)((mushstate.db_block_size - 32) / (sizeof(int) + sizeof(DUMPOBJ)))
96#define OBJECT_BLOCK_BYTES (int)((OBJECT_BLOCK_SIZE) * (sizeof(int) + sizeof(DUMPOBJ)))
97#define ENTRY_NUM_BLOCKS(total, blksize) (int)(total / blksize)
98#define ENTRY_BLOCK_STARTS(blk, blksize) (int)(blk * blksize)
99#define ENTRY_BLOCK_ENDS(blk, blksize) (int)(blk * blksize) + (blksize - 1)
100
101#define Hasprivs(x) (Royalty(x) || Wizard(x))
102
103#define anum_get(x) (anum_table[(x)])
104#define anum_set(x, v) anum_table[(x)] = v
105
106#define TRUE_BOOLEXP ((BOOLEXP *)NULL)
107
108#define Location(t) db[t].location
109#define Zone(t) db[t].zone
110#define Contents(t) db[t].contents
111#define Exits(t) db[t].exits
112#define Next(t) db[t].next
113#define Link(t) db[t].link
114#define Owner(t) db[t].owner
115#define Parent(t) db[t].parent
116#define Flags(t) db[t].flags
117#define Flags2(t) db[t].flags2
118#define Flags3(t) db[t].flags3
119#define Powers(t) db[t].powers
120#define Powers2(t) db[t].powers2
121#define NameLen(t) db[t].name_length
122#define Home(t) db[t].link
123#define Dropto(t) db[t].location
124#define AccessTime(t) db[t].last_access
125#define ModTime(t) db[t].last_mod
126#define CreateTime(t) db[t].create_time
127#define VarsCount(t) db[t].vars_count
128#define StackCount(t) db[t].stack_count
129#define StructCount(t) db[t].struct_count
130#define InstanceCount(t) db[t].instance_count
131#define Time_Used(t) db[t].cpu_time_used
132
138#define s_Location(t, n) \
139 db[t].location = (n); \
140 db[t].flags3 |= DIRTY
141#define s_Zone(t, n) \
142 db[t].zone = (n); \
143 db[t].flags3 |= DIRTY
144#define s_Contents(t, n) \
145 db[t].contents = (n); \
146 db[t].flags3 |= DIRTY
147#define s_Exits(t, n) \
148 db[t].exits = (n); \
149 db[t].flags3 |= DIRTY
150#define s_Next(t, n) \
151 db[t].next = (n); \
152 db[t].flags3 |= DIRTY
153#define s_Link(t, n) \
154 db[t].link = (n); \
155 db[t].flags3 |= DIRTY
156#define s_Owner(t, n) \
157 db[t].owner = (n); \
158 db[t].flags3 |= DIRTY
159#define s_Parent(t, n) \
160 db[t].parent = (n); \
161 db[t].flags3 |= DIRTY
162#define s_Flags(t, n) \
163 db[t].flags = (n); \
164 db[t].flags3 |= DIRTY
165#define s_Flags2(t, n) \
166 db[t].flags2 = (n); \
167 db[t].flags3 |= DIRTY
168#define s_Flags3(t, n) \
169 db[t].flags3 = (n); \
170 db[t].flags3 |= DIRTY
171#define s_Powers(t, n) \
172 db[t].powers = (n); \
173 db[t].flags3 |= DIRTY
174#define s_Powers2(t, n) \
175 db[t].powers2 = (n); \
176 db[t].flags3 |= DIRTY
177#define s_AccessTime(t, n) \
178 db[t].last_access = (n); \
179 db[t].flags3 |= DIRTY
180#define s_ModTime(t, n) \
181 db[t].last_mod = (n); \
182 db[t].flags3 |= DIRTY
183#define s_CreateTime(t, n) \
184 db[t].create_time = (n); \
185 db[t].flags3 |= DIRTY
186#define s_Accessed(t) \
187 db[t].last_access = mushstate.now; \
188 db[t].flags3 |= DIRTY
189#define s_Modified(t) \
190 db[t].last_mod = mushstate.now; \
191 db[t].flags3 |= DIRTY
192#define s_Created(t) \
193 db[t].create_time = mushstate.now; \
194 db[t].flags3 |= DIRTY
195
196#define s_Clean(t) db[t].flags3 = db[t].flags3 & ~DIRTY
197#define s_NameLen(t, n) db[t].name_length = (n)
198#define s_Home(t, n) s_Link(t, n)
199#define s_Dropto(t, n) s_Location(t, n)
200#define s_VarsCount(t, n) db[t].vars_count = n;
201#define s_StackCount(t, n) db[t].stack_count = n;
202#define s_StructCount(t, n) db[t].struct_count = n;
203#define s_InstanceCount(t, n) db[t].instance_count = n;
204
205#define Dropper(thing) (Connected(Owner(thing)) && Hearer(thing))
206
211#define OBJ_HEADER_SIZE (sizeof(unsigned int) + sizeof(int))
212#define ATTR_HEADER_SIZE (sizeof(int) * 2)
213
218#define MSG_ME_ALL (MSG_ME | MSG_INV_EXITS | MSG_FWDLIST)
219#define MSG_F_CONTENTS (MSG_INV)
220#define MSG_F_UP (MSG_NBR_A | MSG_LOC_A)
221#define MSG_F_DOWN (MSG_INV_L)
226#define log_write(i, p, s, f, ...) _log_write(__FILE__, __LINE__, i, p, s, f, ##__VA_ARGS__)
227#define log_perror(p, s, e, o) _log_perror(__FILE__, __LINE__, p, s, e, o)
232#define notify(p, m, ...) notify_check(p, p, MSG_PUP_ALWAYS | MSG_ME_ALL | MSG_F_DOWN, NULL, m, ##__VA_ARGS__)
233#define notify_html(p, m, ...) notify_check(p, p, MSG_PUP_ALWAYS | MSG_ME_ALL | MSG_F_DOWN | MSG_HTML, NULL, m, ##__VA_ARGS__)
234#define notify_quiet(p, m, ...) notify_check(p, p, MSG_PUP_ALWAYS | MSG_ME, NULL, m, ##__VA_ARGS__)
235#define notify_with_cause(p, c, m, ...) notify_check(p, c, MSG_PUP_ALWAYS | MSG_ME_ALL | MSG_F_DOWN, NULL, m, ##__VA_ARGS__)
236#define notify_with_cause_html(p, c, m, ...) notify_check(p, c, MSG_PUP_ALWAYS | MSG_ME_ALL | MSG_F_DOWN | MSG_HTML, NULL, m, ##__VA_ARGS__)
237#define notify_with_cause_extra(p, c, m, f, ...) notify_check(p, c, MSG_PUP_ALWAYS | MSG_ME_ALL | MSG_F_DOWN | (f), NULL, m, ##__VA_ARGS__)
238#define notify_quiet_with_cause(p, c, m, ...) notify_check(p, c, MSG_PUP_ALWAYS | MSG_ME, NULL, m, ##__VA_ARGS__)
239#define notify_puppet(p, c, m, ...) notify_check(p, c, MSG_ME_ALL | MSG_F_DOWN, NULL, m, ##__VA_ARGS__)
240#define notify_quiet_puppet(p, c, m, ...) notify_check(p, c, MSG_ME, NULL, m, ##__VA_ARGS__)
241#define notify_all(p, c, m, ...) notify_check(p, c, MSG_ME_ALL | MSG_NBR_EXITS | MSG_F_UP | MSG_F_CONTENTS, NULL, m, ##__VA_ARGS__)
242#define notify_all_from_inside(p, c, m, ...) notify_check(p, c, MSG_ME_ALL | MSG_NBR_EXITS_A | MSG_F_UP | MSG_F_CONTENTS | MSG_S_INSIDE, NULL, m, ##__VA_ARGS__)
243#define notify_all_from_inside_speech(p, c, m, ...) notify_check(p, c, MSG_ME_ALL | MSG_NBR_EXITS_A | MSG_F_UP | MSG_F_CONTENTS | MSG_S_INSIDE | MSG_SPEECH, NULL, m, ##__VA_ARGS__)
244#define notify_all_from_inside_move(p, c, m, ...) notify_check(p, c, MSG_ME_ALL | MSG_NBR_EXITS_A | MSG_F_UP | MSG_F_CONTENTS | MSG_S_INSIDE | MSG_MOVE, NULL, m, ##__VA_ARGS__)
245#define notify_all_from_inside_html(p, c, m, ...) notify_check(p, c, MSG_ME_ALL | MSG_NBR_EXITS_A | MSG_F_UP | MSG_F_CONTENTS | MSG_S_INSIDE | MSG_HTML, NULL, m, ##__VA_ARGS__)
246#define notify_all_from_inside_html_speech(p, c, m, ...) notify_check(p, c, MSG_ME_ALL | MSG_NBR_EXITS_A | MSG_F_UP | MSG_F_CONTENTS | MSG_S_INSIDE | MSG_HTML | MSG_SPEECH, NULL, m, ##__VA_ARGS__)
247#define notify_all_from_outside(p, c, m, ...) notify_check(p, c, MSG_ME_ALL | MSG_NBR_EXITS | MSG_F_UP | MSG_F_CONTENTS | MSG_S_OUTSIDE, NULL, m, ##__VA_ARGS__)
252// #define Randomize(n) (random_range(0, (n)-1))
253#define Protect(f) (cmdp->perms & f)
254#define Invalid_Objtype(x) ((Protect(CA_LOCATION) && !Has_location(x)) || (Protect(CA_CONTENTS) && !Has_contents(x)) || (Protect(CA_PLAYER) && (Typeof(x) != TYPE_PLAYER)))
255#define test_top() ((mushstate.qfirst != NULL) ? 1 : 0)
256#define controls(p, x) Controls(p, x)
257
263#define GOD ((dbref)1)
264
324#define IS(thing, type, flag) ((Typeof(thing) == (type)) && (Flags(thing) & (flag)))
325#define Typeof(x) (Flags(x) & TYPE_MASK)
326#define God(x) ((x) == GOD)
327#define Robot(x) (isPlayer(x) && ((Flags(x) & ROBOT) != 0))
328#define Alive(x) (isPlayer(x) || (Puppet(x) && Has_contents(x)))
329#define OwnsOthers(x) ((object_types[Typeof(x)].flags & OF_OWNER) != 0)
330#define Has_location(x) ((object_types[Typeof(x)].flags & OF_LOCATION) != 0)
331#define Has_contents(x) ((object_types[Typeof(x)].flags & OF_CONTENTS) != 0)
332#define Has_exits(x) ((object_types[Typeof(x)].flags & OF_EXITS) != 0)
333#define Has_siblings(x) ((object_types[Typeof(x)].flags & OF_SIBLINGS) != 0)
334#define Has_home(x) ((object_types[Typeof(x)].flags & OF_HOME) != 0)
335#define Has_dropto(x) ((object_types[Typeof(x)].flags & OF_DROPTO) != 0)
336#define Home_ok(x) ((object_types[Typeof(x)].flags & OF_HOME) != 0)
337#define isPlayer(x) (Typeof(x) == TYPE_PLAYER)
338#define isRoom(x) (Typeof(x) == TYPE_ROOM)
339#define isExit(x) (Typeof(x) == TYPE_EXIT)
340#define isThing(x) (Typeof(x) == TYPE_THING)
341#define isGarbage(x) (Typeof(x) == TYPE_GARBAGE)
342
343#define Good_dbref(x) (((x) >= 0) && ((x) < mushstate.db_top))
344#define Good_obj(x) (Good_dbref(x) && (Typeof(x) < GOODTYPE))
345#define Good_owner(x) (Good_obj(x) && OwnsOthers(x))
346#define Good_home(x) (Good_obj(x) && Home_ok(x))
347#define Good_loc(x) (Good_obj(x) && Has_contents(x))
348
349#define Royalty(x) ((Flags(x) & ROYALTY) != 0)
350#define WizRoy(x) (Royalty(x) || Wizard(x))
351#define Staff(x) ((Flags2(x) & STAFF) != 0)
352#define Head(x) ((Flags2(x) & HEAD_FLAG) != 0)
353#define Fixed(x) ((Flags2(x) & FIXED) != 0)
354#define Uninspected(x) ((Flags2(x) & UNINSPECTED) != 0)
355#define Ansi(x) ((Flags2(x) & ANSI) != 0)
356#define Color256(x) ((Flags3(x) & COLOR256) != 0)
357#define Color24Bit(x) ((Flags3(x) & COLOR24BIT) != 0)
358#define NoBleed(x) ((Flags2(x) & NOBLEED) != 0)
359
360#define Transparent(x) ((Flags(x) & SEETHRU) != 0)
361#define Link_ok(x) (((Flags(x) & LINK_OK) != 0) && Has_contents(x))
362#define Wizard(x) ((Flags(x) & WIZARD) || ((Flags(Owner(x)) & WIZARD) && Inherits(x)))
363#define Dark(x) (((Flags(x) & DARK) != 0) && (!Alive(x) || (Wizard(x) && !mushconf.visible_wizzes) || Can_Cloak(x)))
364#define DarkMover(x) ((Wizard(x) || Can_Cloak(x)) && Dark(x))
365#define Jump_ok(x) (((Flags(x) & JUMP_OK) != 0) && Has_contents(x))
366#define Sticky(x) ((Flags(x) & STICKY) != 0)
367#define Destroy_ok(x) ((Flags(x) & DESTROY_OK) != 0)
368#define Haven(x) ((Flags(x) & HAVEN) != 0)
369#define Player_haven(x) ((Flags(Owner(x)) & HAVEN) != 0)
370#define Quiet(x) ((Flags(x) & QUIET) != 0)
371#define Halted(x) ((Flags(x) & HALT) != 0)
372#define Trace(x) ((Flags(x) & TRACE) != 0)
373#define Going(x) ((Flags(x) & GOING) != 0)
374#define Monitor(x) ((Flags(x) & MONITOR) != 0)
375#define Myopic(x) ((Flags(x) & MYOPIC) != 0)
376#define Puppet(x) ((Flags(x) & PUPPET) != 0)
377#define Chown_ok(x) ((Flags(x) & CHOWN_OK) != 0)
378#define Enter_ok(x) (((Flags(x) & ENTER_OK) != 0) && Has_location(x) && Has_contents(x))
379#define Visual(x) ((Flags(x) & VISUAL) != 0)
380#define Immortal(x) ((Flags(x) & IMMORTAL) || ((Flags(Owner(x)) & IMMORTAL) && Inherits(x)))
381#define Opaque(x) ((Flags(x) & OPAQUE) != 0)
382#define Verbose(x) ((Flags(x) & VERBOSE) != 0)
383#define Inherits(x) (((Flags(x) & INHERIT) != 0) || ((Flags(Owner(x)) & INHERIT) != 0) || ((x) == Owner(x)))
384#define Nospoof(x) ((Flags(x) & NOSPOOF) != 0)
385#define Safe(x, p) (OwnsOthers(x) || (Flags(x) & SAFE) || (mushconf.safe_unowned && (Owner(x) != Owner(p))))
386#define Control_ok(x) ((Flags2(x) & CONTROL_OK) != 0)
387#define Constant_Attrs(x) ((Flags2(x) & CONSTANT_ATTRS) != 0)
388#define Audible(x) ((Flags(x) & HEARTHRU) != 0)
389#define Terse(x) ((Flags(x) & TERSE) != 0)
390
391#define Gagged(x) ((Flags2(x) & GAGGED) != 0)
392#define Vacation(x) ((Flags2(x) & VACATION) != 0)
393#define Sending_Mail(x) ((Flags2(x) & PLAYER_MAILS) != 0)
394#define Key(x) ((Flags2(x) & KEY) != 0)
395#define Abode(x) (((Flags2(x) & ABODE) != 0) && Home_ok(x))
396#define Auditorium(x) ((Flags2(x) & AUDITORIUM) != 0)
397#define Findable(x) ((Flags2(x) & UNFINDABLE) == 0)
398#define Hideout(x) ((Flags2(x) & UNFINDABLE) != 0)
399#define Parent_ok(x) ((Flags2(x) & PARENT_OK) != 0)
400#define Light(x) ((Flags2(x) & LIGHT) != 0)
401#define Suspect(x) ((Flags2(Owner(x)) & SUSPECT) != 0)
402#define Watcher(x) ((Flags2(x) & WATCHER) != 0)
403#define Connected(x) (((Flags2(x) & CONNECTED) != 0) && (Typeof(x) == TYPE_PLAYER))
404#define Slave(x) ((Flags2(Owner(x)) & SLAVE) != 0)
405#define ParentZone(x) ((Flags2(x) & ZONE_PARENT) != 0)
406#define Stop_Match(x) ((Flags2(x) & STOP_MATCH) != 0)
407#define Has_Commands(x) ((Flags2(x) & HAS_COMMANDS) != 0)
408#define Bouncer(x) ((Flags2(x) & BOUNCE) != 0)
409#define Hidden(x) ((Flags(x) & DARK) != 0)
410#define Blind(x) ((Flags2(x) & BLIND) != 0)
411#define Redir_ok(x) ((Flags3(x) & REDIR_OK) != 0)
412#define Orphan(x) ((Flags3(x) & ORPHAN) != 0)
413#define NoDefault(x) ((Flags3(x) & NODEFAULT) != 0)
414#define Unreal(x) ((Flags3(x) & PRESENCE) != 0)
415
416#define H_Startup(x) ((Flags(x) & HAS_STARTUP) != 0)
417#define H_Fwdlist(x) ((Flags2(x) & HAS_FWDLIST) != 0)
418#define H_Listen(x) ((Flags2(x) & HAS_LISTEN) != 0)
419#define H_Redirect(x) ((Flags3(x) & HAS_REDIRECT) != 0)
420#define H_Darklock(x) ((Flags3(x) & HAS_DARKLOCK) != 0)
421#define H_Speechmod(x) ((Flags3(x) & HAS_SPEECHMOD) != 0)
422#define H_Propdir(x) ((Flags3(x) & HAS_PROPDIR) != 0)
423
424#define H_Marker0(x) ((Flags3(x) & MARK_0) != 0)
425#define H_Marker1(x) ((Flags3(x) & MARK_1) != 0)
426#define H_Marker2(x) ((Flags3(x) & MARK_2) != 0)
427#define H_Marker3(x) ((Flags3(x) & MARK_3) != 0)
428#define H_Marker4(x) ((Flags3(x) & MARK_4) != 0)
429#define H_Marker5(x) ((Flags3(x) & MARK_5) != 0)
430#define H_Marker6(x) ((Flags3(x) & MARK_6) != 0)
431#define H_Marker7(x) ((Flags3(x) & MARK_7) != 0)
432#define H_Marker8(x) ((Flags3(x) & MARK_8) != 0)
433#define H_Marker9(x) ((Flags3(x) & MARK_9) != 0)
434#define isMarkerFlag(fp) (((fp)->flagflag & FLAG_WORD3) && ((fp)->flagvalue & MARK_FLAGS))
435
436#define s_Halted(x) s_Flags((x), Flags(x) | HALT)
437#define s_Going(x) s_Flags((x), Flags(x) | GOING)
438#define s_Connected(x) s_Flags2((x), Flags2(x) | CONNECTED)
439#define c_Connected(x) s_Flags2((x), Flags2(x) & ~CONNECTED)
440#define isConnFlag(fp) (((fp)->flagflag & FLAG_WORD2) && ((fp)->flagvalue & CONNECTED))
441#define s_Has_Darklock(x) s_Flags3((x), Flags3(x) | HAS_DARKLOCK)
442#define c_Has_Darklock(x) s_Flags3((x), Flags3(x) & ~HAS_DARKLOCK)
443#define s_Trace(x) s_Flags((x), Flags(x) | TRACE)
444#define c_Trace(x) s_Flags((x), Flags(x) & ~TRACE)
445
446#define Html(x) ((Flags2(x) & HTML) != 0)
447#define s_Html(x) s_Flags2((x), Flags2(x) | HTML)
448#define c_Html(x) s_Flags2((x), Flags2(x) & ~HTML)
449
454#define Parentable(p, x) (Controls(p, x) || (Parent_ok(x) && could_doit(p, x, A_LPARENT)))
455#define OnControlLock(p, x) (check_zone(p, x))
456#define Controls(p, x) (Good_obj(x) && (!(God(x) && !God(p))) && (Control_All(p) || ((Owner(p) == Owner(x)) && (Inherits(p) || !Inherits(x))) || OnControlLock(p, x)))
457#define Cannot_Objeval(p, x) ((x == NOTHING) || God(x) || (mushconf.fascist_objeval ? !Controls(p, x) : ((Owner(x) != Owner(p)) && !Wizard(p))))
458#define Has_power(p, x) (check_access((p), powers_nametab[x].flag))
459#define Mark(x) (mushstate.markbits->chunk[(x) >> 3] |= mushconf.markdata[(x) & 7])
460#define Unmark(x) (mushstate.markbits->chunk[(x) >> 3] &= ~mushconf.markdata[(x) & 7])
461#define Marked(x) (mushstate.markbits->chunk[(x) >> 3] & mushconf.markdata[(x) & 7])
462
467#define Examinable(p, x) (((Flags(x) & VISUAL) != 0) || (See_All(p)) || (Owner(p) == Owner(x)) || OnControlLock(p, x))
468#define MyopicExam(p, x) (((Flags(x) & VISUAL) != 0) || (!Myopic(p) && (See_All(p) || (Owner(p) == Owner(x)) || OnControlLock(p, x))))
469
479#define Darkened(p, x) (Dark(x) && (!H_Darklock(x) || could_doit(p, x, A_LDARK)))
480
491#define Sees(p, x) (!Darkened(p, x) || (mushconf.see_own_dark && MyopicExam(p, x)))
492#define Sees_Always(p, x) (!Darkened(p, x) || (mushconf.see_own_dark && Examinable(p, x)))
493#define Sees_In_Dark(p, x) ((Light(x) && !Darkened(p, x)) || (mushconf.see_own_dark && MyopicExam(p, x)))
494#define Can_See(p, x, l) (!(((p) == (x)) || isExit(x) || (mushconf.dark_sleepers && isPlayer(x) && !Connected(x) && !Puppet(x))) && ((l) ? Sees(p, x) : Sees_In_Dark(p, x)) && ((!Unreal(x) || Check_Known(p, x)) && (!Unreal(p) || Check_Knows(x, p))))
495#define Can_See_Exit(p, x, l) (!Darkened(p, x) && (!(l) || Light(x)) && ((!Unreal(x) || Check_Known(p, x)) && (!Unreal(p) || Check_Knows(x, p))))
496
501#define nearby_or_control(p, t) (Good_obj(p) && Good_obj(t) && (Controls(p, t) || nearby(p, t)))
502
509#define Exit_Visible(x, p, k) (((k) & VE_LOC_XAM) || Examinable(p, x) || Light(x) || (!((k) & (VE_LOC_DARK | VE_BASE_DARK)) && !Dark(x)))
510
520#define Link_exit(p, x) ((Typeof(x) == TYPE_EXIT) && ((Location(x) == NOTHING) || Controls(p, x)))
521
528#define Linkable(p, x) (Good_obj(x) && Has_contents(x) && (Controls(p, x) || Link_ok(x) || (LinkToAny(p) && !God(x))))
529
536#define Passes_Linklock(p, x) ((LinkToAny(p) && !mushconf.wiz_obey_linklock) || could_doit(p, x, A_LLINK))
537
542#define AttrFlags(a, f) ((f) | (a)->flags)
543#define Visible_desc(p, x, a) (((a)->number != A_DESC) || mushconf.read_rem_desc || nearby(p, x))
544#define Invisible_attr(p, x, a, o, f) ((!Examinable(p, x) && (Owner(p) != o)) || ((AttrFlags(a, f) & AF_MDARK) && !Sees_Hidden_Attrs(p)) || ((AttrFlags(a, f) & AF_DARK) && !God(p)))
545#define Visible_attr(p, x, a, o, f) (((AttrFlags(a, f) & AF_VISUAL) && Visible_desc(p, x, a)) || !Invisible_attr(p, x, a, o, f))
546#define See_attr(p, x, a, o, f) (!((a)->flags & (AF_INTERNAL | AF_IS_LOCK)) && !(f & AF_STRUCTURE) && Visible_attr(p, x, a, o, f))
547#define Read_attr(p, x, a, o, f) (!((a)->flags & AF_INTERNAL) && !(f & AF_STRUCTURE) && Visible_attr(p, x, a, o, f))
548#define See_attr_all(p, x, a, o, f, y) (!((a)->flags & (AF_INTERNAL | AF_IS_LOCK)) && ((y) || !(f & AF_STRUCTURE)) && Visible_attr(p, x, a, o, f))
549#define Read_attr_all(p, x, a, o, f, y) (!((a)->flags & AF_INTERNAL) && ((y) || !(f & AF_STRUCTURE)) && Visible_attr(p, x, a, o, f))
550
560#define Set_attr(p, x, a, f) (!((a)->flags & (AF_INTERNAL | AF_IS_LOCK | AF_CONST)) && (God(p) || (!God(x) && !((f) & AF_LOCK) && !Constant_Attrs(x) && ((Controls(p, x) && !((a)->flags & (AF_WIZARD | AF_GOD)) && !((f) & (AF_WIZARD | AF_GOD))) || (Sets_Wiz_Attrs(p) && !((a)->flags & AF_GOD) && !((f) & AF_GOD))))))
561
567#define Write_attr(p, x, a, f) (!((a)->flags & (AF_INTERNAL | AF_NOCLONE)) && (God(p) || (!God(x) && !(f & AF_LOCK) && ((Controls(p, x) && !((a)->flags & (AF_WIZARD | AF_GOD)) && !((f) & (AF_WIZARD | AF_GOD))) || (Sets_Wiz_Attrs(p) && !((a)->flags & AF_GOD))))))
568
577#define Lock_attr(p, x, a, o) (God(p) || (!God(x) && !((a)->flags & (AF_INTERNAL | AF_IS_LOCK | AF_CONST)) && !Constant_Attrs(x) && (!((a)->flags & (AF_WIZARD | AF_GOD)) || (Sets_Wiz_Attrs(p) && !((a)->flags & AF_GOD))) && (Wizard(p) || (o) == Owner(p))))
578
583#define Are_Real(p, t) (!(Unreal(p) || Unreal(t)))
584#define Check_Heard(t, p) (could_doit((t), (p), A_LHEARD))
585#define Check_Noticed(t, p) (could_doit((t), (p), A_LMOVED))
586#define Check_Known(t, p) (could_doit((t), (p), A_LKNOWN))
587#define Check_Hears(p, t) (could_doit((p), (t), A_LHEARS))
588#define Check_Notices(p, t) (could_doit((p), (t), A_LMOVES))
589#define Check_Knows(p, t) (could_doit((p), (t), A_LKNOWS))
590
603#define Func_Flags(x) (((FUN *)(x)[-1])->flags)
604#define Is_Func(x) (((FUN *)fargs[-1])->flags & (x))
605#define Func_Mask(x) (((FUN *)fargs[-1])->flags & (x))
606
607#define IS_CLEAN(i) (IS(i, TYPE_GARBAGE, GOING) && (Location(i) == NOTHING) && (Contents(i) == NOTHING) && (Exits(i) == NOTHING) && (Next(i) == NOTHING) && (Owner(i) == GOD))
612#define Check_Func_Access(p, f) (check_access(p, (f)->perms) && (!((f)->xperms) || check_mod_access(p, (f)->xperms)))
617#define Eat_Spaces(x) trim_space_sep((x), &SPACE_DELIM)
676#define Too_Much_CPU() ((mushstate.cputime_now = clock()), ((mushstate.cputime_now > mushstate.cputime_base + mushconf.func_cpu_lim) && (mushstate.cputime_base + mushconf.func_cpu_lim > mushstate.cputime_base) && (mushstate.cputime_base != -1) && (mushstate.cputime_now != -1)))
677
683#define MANDFLAGS (V_LINK | V_PARENT | V_XFLAGS | V_ZONE | V_POWERS | V_3FLAGS | V_QUOTED | V_TQUOTAS | V_TIMESTAMPS | V_VISUALATTRS | V_CREATETIME)
684#define OFLAGS1 (V_GDBM | V_ATRKEY)
685#define OFLAGS2 (V_ATRNAME | V_ATRMONEY)
686#define OUTPUT_FLAGS (MANDFLAGS | OFLAGS1 | OFLAGS2)
687#define UNLOAD_OUTFLAGS (MANDFLAGS)
694#define nhashinit(h, sz) hashinit((h), (sz), HT_NUM)
695#define nhashreset(h) hashreset((h))
696#define hashfind(s, h) hashfind_generic((HASHKEY)(s), (h))
697#define nhashfind(n, h) hashfind_generic((HASHKEY)(n), (h))
698#define hashfindflags(s, h) hashfindflags_generic((HASHKEY)(s), (h))
699#define hashadd(s, d, h, f) hashadd_generic((HASHKEY)(s), (d), (h), (f))
700#define nhashadd(n, d, h) hashadd_generic((HASHKEY)(n), (d), (h), 0)
701#define hashdelete(s, h) hashdelete_generic((HASHKEY)(s), (h))
702#define nhashdelete(n, h) hashdelete_generic((HASHKEY)(n), (h))
703#define nhashflush(h, sz) hashflush((h), (sz))
704#define hashrepl(s, d, h) hashrepl_generic((HASHKEY)(s), (d), (h))
705#define nhashrepl(n, d, h) hashrepl_generic((HASHKEY)(n), (d), (h))
706#define nhashinfo(t, h) hashinfo((t), (h))
707#define hash_firstkey(h) (hash_firstkey_generic((h)).s)
708#define hash_nextkey(h) (hash_nextkey_generic((h)).s)
709#define nhashresize(h, sz) hashresize((h), (sz))
710
716#define OBLOCK_SIZE (dbref)((LBUF_SIZE - sizeof(OBLOCK *)) / sizeof(dbref))
717
723#define s_Change_Quotas(c) s_Powers((c), Powers(c) | POW_CHG_QUOTAS)
724#define s_Chown_Any(c) s_Powers((c), Powers(c) | POW_CHOWN_ANY)
725#define s_Announce(c) s_Powers((c), Powers(c) | POW_ANNOUNCE)
726#define s_Can_Boot(c) s_Powers((c), Powers(c) | POW_BOOT)
727#define s_Can_Halt(c) s_Powers((c), Powers(c) | POW_HALT)
728#define s_Control_All(c) s_Powers((c), Powers(c) | POW_CONTROL_ALL)
729#define s_Wizard_Who(c) s_Powers((c), Powers(c) | POW_WIZARD_WHO)
730#define s_See_All(c) s_Powers((c), Powers(c) | POW_EXAM_ALL)
731#define s_Find_Unfindable(c) s_Powers((c), Powers(c) | POW_FIND_UNFIND)
732#define s_Free_Money(c) s_Powers((c), Powers(c) | POW_FREE_MONEY)
733#define s_Free_Quota(c) s_Powers((c), Powers(c) | POW_FREE_QUOTA)
734#define s_Can_Hide(c) s_Powers((c), Powers(c) | POW_HIDE)
735#define s_Can_Idle(c) s_Powers((c), Powers(c) | POW_IDLE)
736#define s_Search(c) s_Powers((c), Powers(c) | POW_SEARCH)
737#define s_Long_Fingers(c) s_Powers((c), Powers(c) | POW_LONGFINGERS)
738#define s_Prog(c) s_Powers((c), Powers(c) | POW_PROG)
739#define s_Comm_All(c) s_Powers((c), Powers(c) | POW_COMM_ALL)
740#define s_See_Queue(c) s_Powers((c), Powers(c) | POW_SEE_QUEUE)
741#define s_See_Hidden(c) s_Powers((c), Powers(c) | POW_SEE_HIDDEN)
742#define s_Can_Watch(c) s_Powers((c), Powers(c) | POW_WATCH)
743#define s_Can_Poll(c) s_Powers((c), Powers(c) | POW_POLL)
744#define s_No_Destroy(c) s_Powers((c), Powers(c) | POW_NO_DESTROY)
745#define s_Guest(c) s_Powers((c), Powers(c) | POW_GUEST)
746#define s_Set_Maint_Flags(c) s_Powers((c), Powers(c) | POW_SET_MFLAGS)
747#define s_Stat_Any(c) s_Powers((c), Powers(c) | POW_STAT_ANY)
748#define s_Steal(c) s_Powers((c), Powers(c) | POW_STEAL)
749#define s_Tel_Anywhere(c) s_Powers((c), Powers(c) | POW_TEL_ANYWHR)
750#define s_Tel_Anything(c) s_Powers((c), Powers(c) | POW_TEL_UNRST)
751#define s_Unkillable(c) s_Powers((c), Powers(c) | POW_UNKILLABLE)
752#define s_Builder(c) s_Powers2((c), Powers2(c) | POW_BUILDER)
753
754#define Can_Set_Quota(c) (((Powers(c) & POW_CHG_QUOTAS) != 0) || Wizard(c))
755#define Chown_Any(c) (((Powers(c) & POW_CHOWN_ANY) != 0) || Wizard(c))
756#define Announce(c) (((Powers(c) & POW_ANNOUNCE) != 0) || Wizard(c))
757#define Can_Boot(c) (((Powers(c) & POW_BOOT) != 0) || Wizard(c))
758#define Can_Halt(c) (((Powers(c) & POW_HALT) != 0) || Wizard(c))
759#define Control_All(c) (((Powers(c) & POW_CONTROL_ALL) != 0) || Wizard(c))
760#define Wizard_Who(c) (((Powers(c) & POW_WIZARD_WHO) != 0) || WizRoy(c))
761#define See_All(c) (((Powers(c) & POW_EXAM_ALL) != 0) || WizRoy(c))
762#define Find_Unfindable(c) ((Powers(c) & POW_FIND_UNFIND) != 0)
763#define Free_Money(c) (((Powers(c) & POW_FREE_MONEY) != 0) || Immortal(c))
764#define Free_Quota(c) (((Powers(c) & POW_FREE_QUOTA) != 0) || Wizard(c))
765#define Can_Hide(c) (((Powers(c) & POW_HIDE) != 0) || Wizard(c))
766#define Can_Idle(c) (((Powers(c) & POW_IDLE) != 0) || Wizard(c))
767#define Search(c) (((Powers(c) & POW_SEARCH) != 0) || WizRoy(c))
768#define Long_Fingers(c) (((Powers(c) & POW_LONGFINGERS) != 0) || Wizard(c))
769#define Comm_All(c) (((Powers(c) & POW_COMM_ALL) != 0) || Wizard(c))
770#define See_Queue(c) (((Powers(c) & POW_SEE_QUEUE) != 0) || WizRoy(c))
771#define See_Hidden(c) (((Powers(c) & POW_SEE_HIDDEN) != 0) || WizRoy(c))
772#define Can_Watch(c) (((Powers(c) & POW_WATCH) != 0) || Wizard(c))
773#define Can_Poll(c) (((Powers(c) & POW_POLL) != 0) || Wizard(c))
774#define No_Destroy(c) (((Powers(c) & POW_NO_DESTROY) != 0) || Wizard(c))
775#define Guest(c) ((Powers(c) & POW_GUEST) != 0)
776#define Set_Maint_Flags(c) ((Powers(c) & POW_SET_MFLAGS) != 0)
777#define Stat_Any(c) ((Powers(c) & POW_STAT_ANY) != 0)
778#define Steal(c) (((Powers(c) & POW_STEAL) != 0) || Wizard(c))
779#define Tel_Anywhere(c) (((Powers(c) & POW_TEL_ANYWHR) != 0) || Tel_Anything(c))
780#define Tel_Anything(c) (((Powers(c) & POW_TEL_UNRST) != 0) || WizRoy(c))
781#define Unkillable(c) (((Powers(c) & POW_UNKILLABLE) != 0) || Immortal(c))
782#define Prog(c) (((Powers(c) & POW_PROG) != 0) || Wizard(c))
783#define Sees_Hidden_Attrs(c) (((Powers(c) & POW_MDARK_ATTR) != 0) || WizRoy(c))
784#define Sets_Wiz_Attrs(c) (((Powers(c) & POW_WIZ_ATTR) != 0) || Wizard(c))
785#define Pass_Locks(c) ((Powers(c) & POW_PASS_LOCKS) != 0)
786#define Builder(c) (((Powers2(c) & POW_BUILDER) != 0) || WizRoy(c))
787#define LinkVariable(c) (((Powers2(c) & POW_LINKVAR) != 0) || Wizard(c))
788#define LinkToAny(c) (((Powers2(c) & POW_LINKTOANY) != 0) || Wizard(c))
789#define LinkAnyHome(c) (((Powers2(c) & POW_LINKHOME) != 0) || Wizard(c))
790#define Open_Anywhere(c) ((Powers2(c) & POW_OPENANYLOC) != 0)
791#define Can_Cloak(c) ((Powers2(c) & POW_CLOAK) != 0)
792#define Can_Use_Module(c) ((Powers2(c) & POW_USE_MODULE) != 0)
793
794#define OK_To_Send(p, t) (!herekey || ((!Unreal(p) || ((key & MSG_SPEECH) && Check_Heard((t), (p))) || ((key & MSG_MOVE) && Check_Noticed((t), (p))) || ((key & MSG_PRESENCE) && Check_Known((t), (p)))) && (!Unreal(t) || ((key & MSG_SPEECH) && Check_Hears((p), (t))) || ((key & MSG_MOVE) && Check_Notices((p), (t))) || ((key & MSG_PRESENCE) && Check_Knows((p), (t))))))
795
800#define MINUTE_COUNT (LAST_MINUTE - FIRST_MINUTE + 1)
801#define HOUR_COUNT (LAST_HOUR - FIRST_HOUR + 1)
802#define DOM_COUNT (LAST_DOM - FIRST_DOM + 1)
803#define MONTH_COUNT (LAST_MONTH - FIRST_MONTH + 1)
804#define DOW_COUNT (LAST_DOW - FIRST_DOW + 1)
805
806#endif /* __MACROS_H */