| 1 | /** \file mushdb.h |
|---|
| 2 | * |
|---|
| 3 | * \brief Macros for getting information about objects |
|---|
| 4 | */ |
|---|
| 5 | |
|---|
| 6 | #include "config.h" |
|---|
| 7 | #include "copyrite.h" |
|---|
| 8 | |
|---|
| 9 | #ifndef __DB_H |
|---|
| 10 | #define __DB_H |
|---|
| 11 | |
|---|
| 12 | /* Power macros */ |
|---|
| 13 | #include <stdio.h> |
|---|
| 14 | #include "flags.h" |
|---|
| 15 | |
|---|
| 16 | #define Builder(x) (command_check_byname(x, "@dig")) |
|---|
| 17 | #define Guest(x) has_power_by_name(x,"GUEST",NOTYPE) |
|---|
| 18 | #define Tel_Anywhere(x) (Hasprivs(x) || has_power_by_name(x,"TPORT_ANYWHERE",NOTYPE)) |
|---|
| 19 | #define Tel_Anything(x) (Hasprivs(x) || has_power_by_name(x,"TPORT_ANYTHING",NOTYPE)) |
|---|
| 20 | #define See_All(x) (Hasprivs(x) || has_power_by_name(x,"SEE_ALL",NOTYPE)) |
|---|
| 21 | #define Priv_Who(x) (Hasprivs(x) || has_power_by_name(x,"SEE_ALL",NOTYPE)) |
|---|
| 22 | #define Can_Hide(x) (Hasprivs(x) || has_power_by_name(x,"HIDE",NOTYPE)) |
|---|
| 23 | #define Can_Login(x) (Hasprivs(x) || has_power_by_name(x,"LOGIN",NOTYPE)) |
|---|
| 24 | #define Can_Idle(x) (Hasprivs(x) || has_power_by_name(x,"IDLE",NOTYPE)) |
|---|
| 25 | #define Long_Fingers(x) (Hasprivs(x) || has_power_by_name(x,"LONG_FINGERS",NOTYPE)) |
|---|
| 26 | #define Open_Anywhere(x) (Hasprivs(x) || has_power_by_name(x,"OPEN_ANYWHERE",NOTYPE)) |
|---|
| 27 | #define Link_Anywhere(x) (Hasprivs(x) || has_power_by_name(x,"LINK_ANYWHERE",NOTYPE)) |
|---|
| 28 | #define Can_Boot(x) (Hasprivs(x) || has_power_by_name(x,"BOOT",NOTYPE)) |
|---|
| 29 | #define Can_Nspemit(x) (Wizard(x) || has_power_by_name(x,"CAN_NSPEMIT",NOTYPE)) |
|---|
| 30 | #define Do_Quotas(x) (Wizard(x) || has_power_by_name(x,"QUOTAS",NOTYPE)) |
|---|
| 31 | #define Change_Poll(x) (Wizard(x) || has_power_by_name(x,"POLL",NOTYPE)) |
|---|
| 32 | #define HugeQueue(x) (Wizard(x) || has_power_by_name(x,"QUEUE",NOTYPE)) |
|---|
| 33 | #define LookQueue(x) (Hasprivs(x) || has_power_by_name(x,"SEE_QUEUE",NOTYPE)) |
|---|
| 34 | #define HaltAny(x) (Wizard(x) || has_power_by_name(x,"HALT",NOTYPE)) |
|---|
| 35 | #define NoPay(x) (God(x) || has_power_by_name(x,"NO_PAY",NOTYPE) || \ |
|---|
| 36 | ((!Mistrust(x) && has_power_by_name(Owner(x),"NO_PAY",NOTYPE)))) |
|---|
| 37 | #define Moneybags(x) (NoPay(x) || Hasprivs(x)) |
|---|
| 38 | #define NoQuota(x) (Hasprivs(x) || Hasprivs(Owner(x)) || \ |
|---|
| 39 | has_power_by_name(x,"NO_QUOTA",NOTYPE) || \ |
|---|
| 40 | ((!Mistrust(x) && has_power_by_name(Owner(x), "NO_QUOTA", NOTYPE)))) |
|---|
| 41 | #define NoKill(x) (Hasprivs(x) || Hasprivs(Owner(x)) || \ |
|---|
| 42 | has_power_by_name(x,"UNKILLABLE",NOTYPE) || \ |
|---|
| 43 | ((!Mistrust(x) && has_power_by_name(Owner(x),"UNKILLABLE",NOTYPE)))) |
|---|
| 44 | #define Search_All(x) (Hasprivs(x) || has_power_by_name(x,"SEARCH",NOTYPE)) |
|---|
| 45 | #define Global_Funcs(x) (Hasprivs(x) || has_power_by_name(x,"FUNCTIONS",NOTYPE)) |
|---|
| 46 | #define Create_Player(x) (Wizard(x) || has_power_by_name(x,"PLAYER_CREATE",NOTYPE)) |
|---|
| 47 | #define Can_Announce(x) (Wizard(x) || has_power_by_name(x,"ANNOUNCE",NOTYPE)) |
|---|
| 48 | #define Can_Cemit(x) (command_check_byname(x, "@cemit")) |
|---|
| 49 | |
|---|
| 50 | #define Pemit_All(x) (Wizard(x) || has_power_by_name(x,"PEMIT_ALL",NOTYPE)) |
|---|
| 51 | #define Sql_Ok(x) (Wizard(x) || has_power_by_name(x, "SQL_OK", NOTYPE)) |
|---|
| 52 | #define Can_Debit(x) (Wizard(x) || has_power_by_name(x, "DEBIT", NOTYPE)) |
|---|
| 53 | #define Many_Attribs(x) (has_power_by_name(x, "MANY_ATTRIBS", NOTYPE)) |
|---|
| 54 | #define Can_Pueblo_Send(x) (Wizard(x) || has_power_by_name(x, "PUEBLO_SEND", NOTYPE)) |
|---|
| 55 | |
|---|
| 56 | /* Permission macros */ |
|---|
| 57 | #define Can_See_Flag(p,t,f) ((!(f->perms & (F_DARK | F_MDARK | F_ODARK | F_DISABLED)) || \ |
|---|
| 58 | ((!Mistrust(p) && (Owner(p) == Owner(t))) && \ |
|---|
| 59 | !(f->perms & (F_DARK | F_MDARK | F_DISABLED))) || \ |
|---|
| 60 | (See_All(p) && !(f->perms & (F_DARK | F_DISABLED))) || \ |
|---|
| 61 | God(p))) |
|---|
| 62 | |
|---|
| 63 | /* Can p locate x? */ |
|---|
| 64 | bool unfindable(dbref); |
|---|
| 65 | #define Can_Locate(p,x) \ |
|---|
| 66 | (controls(p,x) || nearby(p,x) || See_All(p) \ |
|---|
| 67 | || (command_check_byname(p, "@whereis") && (IsPlayer(x) && !Unfind(x) \ |
|---|
| 68 | && !unfindable(Location(x))))) |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | #define Can_Examine(p,x) (controls(p,x) || See_All(p) || \ |
|---|
| 72 | (Visual(x) && eval_lock(p,x,Examine_Lock))) |
|---|
| 73 | #define can_link(p,x) (controls(p,x) || \ |
|---|
| 74 | (IsExit(x) && (Location(x) == NOTHING))) |
|---|
| 75 | |
|---|
| 76 | /* Can p link an exit to x? */ |
|---|
| 77 | #define can_link_to(p,x) \ |
|---|
| 78 | (GoodObject(x) \ |
|---|
| 79 | && (controls(p,x) || Link_Anywhere(p) || \ |
|---|
| 80 | (LinkOk(x) && eval_lock(p,x,Link_Lock))) \ |
|---|
| 81 | && (!NO_LINK_TO_OBJECT || IsRoom(x))) |
|---|
| 82 | |
|---|
| 83 | /* can p access attribute a on object x? */ |
|---|
| 84 | #define Can_Read_Attr(p,x,a) \ |
|---|
| 85 | (!AF_Internal(a) && \ |
|---|
| 86 | (See_All(p) || can_read_attr_internal((p),(x),(a)))) |
|---|
| 87 | |
|---|
| 88 | /** can p look at object x? */ |
|---|
| 89 | #define can_look_at(p, x) \ |
|---|
| 90 | (Long_Fingers(p) || nearby(p, x) || \ |
|---|
| 91 | (nearby(p, Location(x)) && \ |
|---|
| 92 | (!Opaque(Location(x)) || controls(p, Location(x)))) || \ |
|---|
| 93 | (nearby(Location(p), x) && \ |
|---|
| 94 | (!Opaque(Location(p)) || controls(p, Location(p))))) |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | #define Is_Visible_Attr(x,a) \ |
|---|
| 98 | (!AF_Internal(a) && can_read_attr_internal(NOTHING,(x),(a))) |
|---|
| 99 | |
|---|
| 100 | /* can p write attribute a on object x, assuming p may modify x? |
|---|
| 101 | * Must be (1) God, or (2) a non-internal, non-safe flag and |
|---|
| 102 | * (2a) a Wizard or (2b) a non-wizard attrib and (2b1) you own |
|---|
| 103 | * the attrib or (2b2) it's not atrlocked. |
|---|
| 104 | */ |
|---|
| 105 | #define Can_Write_Attr(p,x,a) \ |
|---|
| 106 | (can_write_attr_internal((p),(x),(a),1)) |
|---|
| 107 | #define Can_Write_Attr_Ignore_Safe(p,x,a) \ |
|---|
| 108 | (can_write_attr_internal((p),(x),(a),0)) |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | /* Can p forward a message to x (via @forwardlist)? */ |
|---|
| 112 | #define Can_Forward(p,x) \ |
|---|
| 113 | (controls(p,x) || Pemit_All(p) || \ |
|---|
| 114 | ((getlock(x, Forward_Lock) != TRUE_BOOLEXP) && \ |
|---|
| 115 | eval_lock(p, x, Forward_Lock))) |
|---|
| 116 | |
|---|
| 117 | /* Can p forward a mail message to x (via @mailforwardlist)? */ |
|---|
| 118 | #define Can_MailForward(p,x) \ |
|---|
| 119 | (IsPlayer(x) && (controls(p,x) || \ |
|---|
| 120 | ((getlock(x, MailForward_Lock) != TRUE_BOOLEXP) && \ |
|---|
| 121 | eval_lock(p, x, MailForward_Lock)))) |
|---|
| 122 | |
|---|
| 123 | /* Can from pass to's @lock/interact? */ |
|---|
| 124 | #define Pass_Interact_Lock(from,to) \ |
|---|
| 125 | (Loud(from) || eval_lock(from, to, Interact_Lock)) |
|---|
| 126 | |
|---|
| 127 | /* How many pennies can you have? */ |
|---|
| 128 | #define Max_Pennies(p) (Guest(p) ? MAX_GUEST_PENNIES : MAX_PENNIES) |
|---|
| 129 | #define Paycheck(p) (Guest(p) ? GUEST_PAY_CHECK : PAY_CHECK) |
|---|
| 130 | |
|---|
| 131 | /* DB flag macros - these should be defined whether or not the |
|---|
| 132 | * corresponding system option is defined |
|---|
| 133 | * They are successive binary numbers |
|---|
| 134 | */ |
|---|
| 135 | #define DBF_NO_CHAT_SYSTEM 0x01 |
|---|
| 136 | #define DBF_WARNINGS 0x02 |
|---|
| 137 | #define DBF_CREATION_TIMES 0x04 |
|---|
| 138 | #define DBF_NO_POWERS 0x08 |
|---|
| 139 | #define DBF_NEW_LOCKS 0x10 |
|---|
| 140 | #define DBF_NEW_STRINGS 0x20 |
|---|
| 141 | #define DBF_TYPE_GARBAGE 0x40 |
|---|
| 142 | #define DBF_SPLIT_IMMORTAL 0x80 |
|---|
| 143 | #define DBF_NO_TEMPLE 0x100 |
|---|
| 144 | #define DBF_LESS_GARBAGE 0x200 |
|---|
| 145 | #define DBF_AF_VISUAL 0x400 |
|---|
| 146 | #define DBF_VALUE_IS_COST 0x800 |
|---|
| 147 | #define DBF_LINK_ANYWHERE 0x1000 |
|---|
| 148 | #define DBF_NO_STARTUP_FLAG 0x2000 |
|---|
| 149 | #define DBF_PANIC 0x4000 |
|---|
| 150 | #define DBF_AF_NODUMP 0x8000 |
|---|
| 151 | #define DBF_SPIFFY_LOCKS 0x10000 |
|---|
| 152 | #define DBF_NEW_FLAGS 0x20000 |
|---|
| 153 | #define DBF_NEW_POWERS 0x40000 |
|---|
| 154 | #define DBF_POWERS_LOGGED 0x80000 |
|---|
| 155 | #define DBF_LABELS 0x100000 |
|---|
| 156 | #define DBF_SPIFFY_AF_ANSI 0x200000 |
|---|
| 157 | |
|---|
| 158 | /* Reboot DB flag macros - these should be defined whether or not the |
|---|
| 159 | * corresponding system option is defined |
|---|
| 160 | * They are successive binary numbers |
|---|
| 161 | */ |
|---|
| 162 | #define RDBF_SCREENSIZE 0x01 |
|---|
| 163 | #define RDBF_TTYPE 0x02 |
|---|
| 164 | #define RDBF_PUEBLO_CHECKSUM 0x04 |
|---|
| 165 | |
|---|
| 166 | #endif /* __DB_H */ |
|---|