| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
#ifndef __FLAGS_H |
|---|
| 7 |
#define __FLAGS_H |
|---|
| 8 |
|
|---|
| 9 |
#include "mushtype.h" |
|---|
| 10 |
#include "ptab.h" |
|---|
| 11 |
|
|---|
| 12 |
typedef struct flag_info FLAG; |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
struct flag_info { |
|---|
| 19 |
const char *name; |
|---|
| 20 |
char letter; |
|---|
| 21 |
int type; |
|---|
| 22 |
int bitpos; |
|---|
| 23 |
uint32_t perms; |
|---|
| 24 |
uint32_t negate_perms; |
|---|
| 25 |
}; |
|---|
| 26 |
|
|---|
| 27 |
typedef struct flag_alias FLAG_ALIAS; |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
struct flag_alias { |
|---|
| 33 |
const char *alias; |
|---|
| 34 |
const char *realname; |
|---|
| 35 |
}; |
|---|
| 36 |
|
|---|
| 37 |
typedef struct flagspace FLAGSPACE; |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
struct flagspace { |
|---|
| 44 |
const char *name; |
|---|
| 45 |
PTAB *tab; |
|---|
| 46 |
FLAG **flags; |
|---|
| 47 |
int flagbits; |
|---|
| 48 |
FLAG *flag_table; |
|---|
| 49 |
FLAG_ALIAS *flag_alias_table; |
|---|
| 50 |
}; |
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
extern int has_flag_in_space_by_name(const char *ns, dbref thing, |
|---|
| 55 |
const char *flag, int type); |
|---|
| 56 |
#define has_flag_by_name(x,y,z) has_flag_in_space_by_name("FLAG",x,y,z) |
|---|
| 57 |
#define has_power_by_name(x,y,z) has_flag_in_space_by_name("POWER",x,y,z) |
|---|
| 58 |
extern const char *unparse_flags(dbref thing, dbref player); |
|---|
| 59 |
extern const char *flag_description(dbref player, dbref thing); |
|---|
| 60 |
extern int sees_flag(const char *ns, dbref privs, dbref thing, |
|---|
| 61 |
const char *name); |
|---|
| 62 |
extern void set_flag(dbref player, dbref thing, const char *flag, int negate, |
|---|
| 63 |
int hear, int listener); |
|---|
| 64 |
extern void set_power(dbref player, dbref thing, const char *flag, int negate); |
|---|
| 65 |
extern const char *power_description(dbref player, dbref thing); |
|---|
| 66 |
extern int flaglist_check(const char *ns, dbref player, dbref it, |
|---|
| 67 |
const char *fstr, int type); |
|---|
| 68 |
extern int flaglist_check_long(const char *ns, dbref player, dbref it, |
|---|
| 69 |
const char *fstr, int type); |
|---|
| 70 |
extern FLAG *match_flag(const char *name); |
|---|
| 71 |
extern FLAG *match_power(const char *name); |
|---|
| 72 |
extern const char *show_command_flags(object_flag_type flags, |
|---|
| 73 |
object_flag_type powers); |
|---|
| 74 |
extern void twiddle_flag_internal(const char *ns, dbref thing, const char *flag, |
|---|
| 75 |
int negate); |
|---|
| 76 |
extern object_flag_type new_flag_bitmask(const char *ns); |
|---|
| 77 |
extern object_flag_type clone_flag_bitmask(const char *ns, |
|---|
| 78 |
object_flag_type given); |
|---|
| 79 |
extern void copy_flag_bitmask(const char *ns, object_flag_type dest, |
|---|
| 80 |
object_flag_type given); |
|---|
| 81 |
extern void destroy_flag_bitmask(object_flag_type bitmask); |
|---|
| 82 |
extern void set_flag_bitmask(object_flag_type bitmask, int bit); |
|---|
| 83 |
extern void clear_flag_bitmask(object_flag_type bitmask, int bit); |
|---|
| 84 |
extern int has_bit(object_flag_type bitmask, int bitpos); |
|---|
| 85 |
extern int has_all_bits(const char *ns, object_flag_type source, |
|---|
| 86 |
object_flag_type bitmask); |
|---|
| 87 |
extern int null_flagmask(const char *ns, object_flag_type source); |
|---|
| 88 |
extern int has_any_bits(const char *ns, object_flag_type source, |
|---|
| 89 |
object_flag_type bitmask); |
|---|
| 90 |
extern object_flag_type string_to_bits(const char *ns, const char *str); |
|---|
| 91 |
extern const char *bits_to_string(const char *ns, object_flag_type bitmask, |
|---|
| 92 |
dbref privs, dbref thing); |
|---|
| 93 |
extern void flag_write_all(FILE *, const char *); |
|---|
| 94 |
extern void flag_read_all(FILE *, const char *); |
|---|
| 95 |
extern int type_from_old_flags(long old_flags); |
|---|
| 96 |
extern object_flag_type flags_from_old_flags(const char *ns, long old_flags, |
|---|
| 97 |
long old_toggles, int type); |
|---|
| 98 |
extern FLAG *add_flag_generic(const char *ns, const char *name, |
|---|
| 99 |
const char letter, int type, int perms, |
|---|
| 100 |
int negate_perms); |
|---|
| 101 |
#define add_flag(n,l,t,p,x) add_flag_generic("FLAG",n,l,t,p,x) |
|---|
| 102 |
#define add_power(n,l,t,p,x) add_flag_generic("POWER",n,l,t,p,x) |
|---|
| 103 |
extern int alias_flag_generic(const char *ns, const char *name, |
|---|
| 104 |
const char *alias); |
|---|
| 105 |
#define alias_flag(n,a) alias_flag_generic("FLAG",n,a); |
|---|
| 106 |
#define alias_power(n,a) alias_flag_generic("POWER",n,a); |
|---|
| 107 |
extern void do_list_flags(const char *ns, dbref player, const char *arg, int lc, |
|---|
| 108 |
const char *label); |
|---|
| 109 |
extern char *list_all_flags(const char *ns, const char *name, dbref privs, |
|---|
| 110 |
int which); |
|---|
| 111 |
extern void do_flag_info(const char *ns, dbref player, const char *name); |
|---|
| 112 |
extern void do_flag_delete(const char *ns, dbref player, const char *name); |
|---|
| 113 |
extern void do_flag_disable(const char *ns, dbref player, const char *name); |
|---|
| 114 |
extern void do_flag_alias(const char *ns, dbref player, const char *name, |
|---|
| 115 |
const char *alias); |
|---|
| 116 |
extern void do_flag_enable(const char *ns, dbref player, const char *name); |
|---|
| 117 |
extern void do_flag_restrict(const char *ns, dbref player, const char *name, |
|---|
| 118 |
char *args_right[]); |
|---|
| 119 |
extern void do_flag_type(const char *ns, dbref player, const char *name, |
|---|
| 120 |
char *type_string); |
|---|
| 121 |
extern void do_flag_add(const char *ns, dbref player, const char *name, |
|---|
| 122 |
char *args_right[]); |
|---|
| 123 |
extern void do_flag_letter(const char *ns, dbref player, const char *name, |
|---|
| 124 |
const char *letter); |
|---|
| 125 |
extern const char *power_to_string(int pwr); |
|---|
| 126 |
extern void decompile_flags_generic(dbref player, dbref thing, const char *name, |
|---|
| 127 |
const char *ns, const char *command, |
|---|
| 128 |
const char *prefix); |
|---|
| 129 |
#define decompile_flags(p,t,n,r) decompile_flags_generic(p,t,n,"FLAG","@set",r) |
|---|
| 130 |
#define decompile_powers(p,t,n,r) decompile_flags_generic(p,t,n,"POWER","@power",r) |
|---|
| 131 |
|
|---|
| 132 |
#define twiddle_flag_bitmask(bm,b,neg) (neg ? clear_flag_bitmask(bm,b) : \ |
|---|
| 133 |
set_flag_bitmask(bm,b)) |
|---|
| 134 |
#define has_all_flags_by_mask(x,bm) has_all_bits("FLAG",Flags(x),bm) |
|---|
| 135 |
#define has_any_flags_by_mask(x,bm) has_any_bits("FLAG",Flags(x),bm) |
|---|
| 136 |
#define has_all_powers_by_mask(x,bm) has_all_bits("POWER",Powers(x),bm) |
|---|
| 137 |
#define has_any_powers_by_mask(x,bm) has_any_bits("POWER",Powers(x),bm) |
|---|
| 138 |
#define twiddle_flag(n,thing,f,negate) \ |
|---|
| 139 |
do { \ |
|---|
| 140 |
if (n->tab == &ptab_flag) { \ |
|---|
| 141 |
twiddle_flag_bitmask(Flags(thing),f->bitpos,negate); \ |
|---|
| 142 |
} else { \ |
|---|
| 143 |
twiddle_flag_bitmask(Powers(thing),f->bitpos,negate); \ |
|---|
| 144 |
} } while (0) |
|---|
| 145 |
#define set_flag_internal(t,f) twiddle_flag_internal("FLAG",t,f,0) |
|---|
| 146 |
#define clear_flag_internal(t,f) twiddle_flag_internal("FLAG",t,f,1) |
|---|
| 147 |
#define set_power_internal(t,f) twiddle_flag_internal("POWER",t,f,0) |
|---|
| 148 |
#define clear_power_internal(t,f) twiddle_flag_internal("POWER",t,f,1) |
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
#define TYPE_ROOM 0x1 |
|---|
| 155 |
#define TYPE_THING 0x2 |
|---|
| 156 |
#define TYPE_EXIT 0x4 |
|---|
| 157 |
#define TYPE_PLAYER 0x8 |
|---|
| 158 |
#define TYPE_GARBAGE 0x10 |
|---|
| 159 |
#define TYPE_MARKED 0x20 |
|---|
| 160 |
#define NOTYPE 0xFFFF |
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
#define F_ANY 0x10U |
|---|
| 169 |
#define F_INHERIT 0x20U |
|---|
| 170 |
#define F_OWNED 0x40U |
|---|
| 171 |
#define F_ROYAL 0x80U |
|---|
| 172 |
#define F_WIZARD 0x100U |
|---|
| 173 |
#define F_GOD 0x200U |
|---|
| 174 |
#define F_INTERNAL 0x400U |
|---|
| 175 |
#define F_DARK 0x800U |
|---|
| 176 |
#define F_MDARK 0x1000U |
|---|
| 177 |
#define F_ODARK 0x2000U |
|---|
| 178 |
#define F_DISABLED 0x4000U |
|---|
| 179 |
#define F_LOG 0x8000U |
|---|
| 180 |
|
|---|
| 181 |
#define F_MAX 0x00800000U |
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
#define F_REF_MASK 0xFF000000U |
|---|
| 187 |
#define F_REF_NOT 0x00FFFFFFU |
|---|
| 188 |
#define FLAG_REF(r) (((r) & F_REF_MASK) >> 30) |
|---|
| 189 |
#define ZERO_FLAG_REF(r) ((r) & F_REF_NOT) |
|---|
| 190 |
#define INCR_FLAG_REF(r) ((r) + (1 << 30)) |
|---|
| 191 |
#define DECR_FLAG_REF(r) ((r) - (1 << 30)) |
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 |
#define CAN_BUILD 0x10 |
|---|
| 199 |
#define TEL_ANYWHERE 0x20 |
|---|
| 200 |
#define TEL_OTHER 0x40 |
|---|
| 201 |
#define SEE_ALL 0x80 |
|---|
| 202 |
#define NO_PAY 0x100 |
|---|
| 203 |
#define CHAT_PRIVS 0x200 |
|---|
| 204 |
#define CAN_HIDE 0x400 |
|---|
| 205 |
#define LOGIN_ANYTIME 0x800 |
|---|
| 206 |
#define UNLIMITED_IDLE 0x1000 |
|---|
| 207 |
#define LONG_FINGERS 0x2000 |
|---|
| 208 |
#define CAN_BOOT 0x4000 |
|---|
| 209 |
#define CHANGE_QUOTAS 0x8000 |
|---|
| 210 |
#define SET_POLL 0x10000 |
|---|
| 211 |
#define HUGE_QUEUE 0x20000 |
|---|
| 212 |
#define PS_ALL 0x40000 |
|---|
| 213 |
#define HALT_ANYTHING 0x80000 |
|---|
| 214 |
#define SEARCH_EVERYTHING 0x100000 |
|---|
| 215 |
#define GLOBAL_FUNCS 0x200000 |
|---|
| 216 |
#define CREATE_PLAYER 0x400000 |
|---|
| 217 |
#define IS_GUEST 0x800000 |
|---|
| 218 |
#define CAN_WALL 0x1000000 |
|---|
| 219 |
#define CEMIT 0x2000000 |
|---|
| 220 |
#define UNKILLABLE 0x4000000 |
|---|
| 221 |
#define PEMIT_ALL 0x8000000 |
|---|
| 222 |
#define NO_QUOTA 0x10000000 |
|---|
| 223 |
#define LINK_ANYWHERE 0x20000000 |
|---|
| 224 |
#define OPEN_ANYWHERE 0x40000000 |
|---|
| 225 |
#define CAN_NSPEMIT 0x80000000 |
|---|
| 226 |
|
|---|
| 227 |
|
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
#define CAN_DEBUG 0x4000000 |
|---|
| 231 |
#define IMMORTAL 0x100 |
|---|
| 232 |
#endif |
|---|