| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
#ifndef __EXTCHAT_H |
|---|
| 42 |
#define __EXTCHAT_H |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
#include "boolexp.h" |
|---|
| 46 |
#include "bufferq.h" |
|---|
| 47 |
|
|---|
| 48 |
#define CU_TITLE_LEN 80 |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
struct chanuser { |
|---|
| 55 |
dbref who; |
|---|
| 56 |
privbits type; |
|---|
| 57 |
char title[CU_TITLE_LEN]; |
|---|
| 58 |
struct chanuser *next; |
|---|
| 59 |
}; |
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
#define CU_QUIET 0x1 |
|---|
| 63 |
#define CU_HIDE 0x2 |
|---|
| 64 |
#define CU_GAG 0x4 |
|---|
| 65 |
#define CU_DEFAULT_FLAGS 0x0 |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
#define CB_CHECKQUIET 0x1 |
|---|
| 69 |
#define CB_NOSPOOF 0x2 |
|---|
| 70 |
#define CB_PRESENCE 0x4 |
|---|
| 71 |
|
|---|
| 72 |
#define CUdbref(u) ((u)->who) |
|---|
| 73 |
#define CUtype(u) ((u)->type) |
|---|
| 74 |
#define CUtitle(u) ((u)->title) |
|---|
| 75 |
#define CUnext(u) ((u)->next) |
|---|
| 76 |
#define Chanuser_Quiet(u) (CUtype(u) & CU_QUIET) |
|---|
| 77 |
#define Chanuser_Hide(u) ((CUtype(u) & CU_HIDE) || (IsPlayer(CUdbref(u)) && hidden(CUdbref(u)))) |
|---|
| 78 |
#define Chanuser_Gag(u) (CUtype(u) & CU_GAG) |
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
#define CHAN_NAME_LEN 31 |
|---|
| 82 |
#define CHAN_TITLE_LEN 256 |
|---|
| 83 |
|
|---|
| 84 |
* This structure represents a MUSH chat channel. Channels are organized |
|---|
| 85 |
* into a sorted linked list. |
|---|
| 86 |
*/ |
|---|
| 87 |
struct channel { |
|---|
| 88 |
char name[CHAN_NAME_LEN]; |
|---|
| 89 |
char title[CHAN_TITLE_LEN]; |
|---|
| 90 |
privbits type; |
|---|
| 91 |
int cost; |
|---|
| 92 |
dbref creator; |
|---|
| 93 |
int num_users; |
|---|
| 94 |
int max_users; |
|---|
| 95 |
struct chanuser *users; |
|---|
| 96 |
unsigned long int num_messages; |
|---|
| 97 |
boolexp joinlock; |
|---|
| 98 |
boolexp speaklock; |
|---|
| 99 |
boolexp modifylock; |
|---|
| 100 |
boolexp seelock; |
|---|
| 101 |
boolexp hidelock; |
|---|
| 102 |
struct channel *next; |
|---|
| 103 |
BUFFERQ *bufferq; |
|---|
| 104 |
}; |
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
struct chanlist { |
|---|
| 111 |
CHAN *chan; |
|---|
| 112 |
struct chanlist *next; |
|---|
| 113 |
}; |
|---|
| 114 |
|
|---|
| 115 |
#define Chanlist(x) ((struct chanlist *)get_objdata(x, "CHANNELS")) |
|---|
| 116 |
#define s_Chanlist(x, y) set_objdata(x, "CHANNELS", (void *)y) |
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
struct na_cpass { |
|---|
| 120 |
CHANUSER *u; |
|---|
| 121 |
bool checkquiet; |
|---|
| 122 |
}; |
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
#define CHANNEL_PLAYER 0x1U |
|---|
| 127 |
#define CHANNEL_OBJECT 0x2U |
|---|
| 128 |
#define CHANNEL_DISABLED 0x4U |
|---|
| 129 |
#define CHANNEL_QUIET 0x8U |
|---|
| 130 |
#define CHANNEL_ADMIN 0x10U |
|---|
| 131 |
#define CHANNEL_WIZARD 0x20U |
|---|
| 132 |
#define CHANNEL_CANHIDE 0x40U |
|---|
| 133 |
#define CHANNEL_OPEN 0x80U |
|---|
| 134 |
#define CHANNEL_NOTITLES 0x100U |
|---|
| 135 |
#define CHANNEL_NONAMES 0x200U |
|---|
| 136 |
#define CHANNEL_NOCEMIT 0x400U |
|---|
| 137 |
#define CHANNEL_INTERACT 0x800U |
|---|
| 138 |
#define CHANNEL_DEFAULT_FLAGS (CHANNEL_PLAYER) |
|---|
| 139 |
#define CL_JOIN 0x1 |
|---|
| 140 |
#define CL_SPEAK 0x2 |
|---|
| 141 |
#define CL_MOD 0x4 |
|---|
| 142 |
#define CL_SEE 0x8 |
|---|
| 143 |
#define CL_HIDE 0x10 |
|---|
| 144 |
#define CHANNEL_COST (options.chan_cost) |
|---|
| 145 |
#define MAX_PLAYER_CHANS (options.max_player_chans) |
|---|
| 146 |
#define MAX_CHANNELS (options.max_channels) |
|---|
| 147 |
|
|---|
| 148 |
#define ChanName(c) ((c)->name) |
|---|
| 149 |
#define ChanType(c) ((c)->type) |
|---|
| 150 |
#define ChanTitle(c) ((c)->title) |
|---|
| 151 |
#define ChanCreator(c) ((c)->creator) |
|---|
| 152 |
#define ChanCost(c) ((c)->cost) |
|---|
| 153 |
#define ChanNumUsers(c) ((c)->num_users) |
|---|
| 154 |
#define ChanMaxUsers(c) ((c)->max_users) |
|---|
| 155 |
#define ChanUsers(c) ((c)->users) |
|---|
| 156 |
#define ChanNext(c) ((c)->next) |
|---|
| 157 |
#define ChanNumMsgs(c) ((c)->num_messages) |
|---|
| 158 |
#define ChanJoinLock(c) ((c)->joinlock) |
|---|
| 159 |
#define ChanSpeakLock(c) ((c)->speaklock) |
|---|
| 160 |
#define ChanModLock(c) ((c)->modifylock) |
|---|
| 161 |
#define ChanSeeLock(c) ((c)->seelock) |
|---|
| 162 |
#define ChanHideLock(c) ((c)->hidelock) |
|---|
| 163 |
#define ChanBufferQ(c) ((c)->bufferq) |
|---|
| 164 |
#define Channel_Quiet(c) (ChanType(c) & CHANNEL_QUIET) |
|---|
| 165 |
#define Channel_Open(c) (ChanType(c) & CHANNEL_OPEN) |
|---|
| 166 |
#define Channel_Object(c) (ChanType(c) & CHANNEL_OBJECT) |
|---|
| 167 |
#define Channel_Player(c) (ChanType(c) & CHANNEL_PLAYER) |
|---|
| 168 |
#define Channel_Disabled(c) (ChanType(c) & CHANNEL_DISABLED) |
|---|
| 169 |
#define Channel_Wizard(c) (ChanType(c) & CHANNEL_WIZARD) |
|---|
| 170 |
#define Channel_Admin(c) (ChanType(c) & CHANNEL_ADMIN) |
|---|
| 171 |
#define Channel_CanHide(c) (ChanType(c) & CHANNEL_CANHIDE) |
|---|
| 172 |
#define Channel_NoTitles(c) (ChanType(c) & CHANNEL_NOTITLES) |
|---|
| 173 |
#define Channel_NoNames(c) (ChanType(c) & CHANNEL_NONAMES) |
|---|
| 174 |
#define Channel_NoCemit(c) (ChanType(c) & CHANNEL_NOCEMIT) |
|---|
| 175 |
#define Channel_Interact(c) (ChanType(c) & CHANNEL_INTERACT) |
|---|
| 176 |
#define Chan_Ok_Type(c,o) \ |
|---|
| 177 |
((IsPlayer(o) && Channel_Player(c)) || \ |
|---|
| 178 |
(IsThing(o) && Channel_Object(c))) |
|---|
| 179 |
#define Chan_Can(p,t) \ |
|---|
| 180 |
(!(t & CHANNEL_DISABLED) && (!(t & CHANNEL_WIZARD) || Wizard(p)) && \ |
|---|
| 181 |
(!(t & CHANNEL_ADMIN) || Hasprivs(p) || (has_power_by_name(p,"CHAT_PRIVS",NOTYPE)))) |
|---|
| 182 |
|
|---|
| 183 |
#define Chan_Can_Priv(p,t) (Wizard(p) || Chan_Can(p,t)) |
|---|
| 184 |
#define Chan_Can_Access(c,p) (Chan_Can(p,ChanType(c))) |
|---|
| 185 |
#define Chan_Can_Join(c,p) \ |
|---|
| 186 |
(Chan_Can_Access(c,p) && \ |
|---|
| 187 |
(eval_chan_lock(c,p, CLOCK_JOIN))) |
|---|
| 188 |
#define Chan_Can_Speak(c,p) \ |
|---|
| 189 |
(Chan_Can_Access(c,p) && \ |
|---|
| 190 |
(eval_chan_lock(c,p, CLOCK_SPEAK))) |
|---|
| 191 |
#define Chan_Can_Cemit(c,p) \ |
|---|
| 192 |
(!Channel_NoCemit(c) && Chan_Can_Speak(c,p)) |
|---|
| 193 |
#define Chan_Can_Modify(c,p) \ |
|---|
| 194 |
(Wizard(p) || (ChanCreator(c) == (p)) || \ |
|---|
| 195 |
(!Guest(p) && Chan_Can_Access(c,p) && \ |
|---|
| 196 |
(eval_chan_lock(c,p, CLOCK_MOD)))) |
|---|
| 197 |
#define Chan_Can_See(c,p) \ |
|---|
| 198 |
(Hasprivs(p) || See_All(p) || (Chan_Can_Access(c,p) && \ |
|---|
| 199 |
(eval_chan_lock(c,p, CLOCK_SEE)))) |
|---|
| 200 |
#define Chan_Can_Hide(c,p) \ |
|---|
| 201 |
(Can_Hide(p) || (Channel_CanHide(c) && Chan_Can_Access(c,p) && \ |
|---|
| 202 |
(eval_chan_lock(c,p, CLOCK_HIDE)))) |
|---|
| 203 |
#define Chan_Can_Nuke(c,p) (Wizard(p) || (ChanCreator(c) == (p))) |
|---|
| 204 |
#define Chan_Can_Decomp(c,p) (See_All(p) || (ChanCreator(c) == (p))) |
|---|
| 205 |
|
|---|
| 206 |
|
|---|
| 207 |
|
|---|
| 208 |
|
|---|
| 209 |
enum cmatch_type { CMATCH_NONE, CMATCH_EXACT, CMATCH_PARTIAL, CMATCH_AMBIG }; |
|---|
| 210 |
#define CMATCHED(i) (((i) == CMATCH_EXACT) | ((i) == CMATCH_PARTIAL)) |
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 |
extern int num_channels; |
|---|
| 214 |
extern void WIN32_CDECL channel_chat |
|---|
| 215 |
(CHAN *channel, dbref player, int flags, const char *message, char type, |
|---|
| 216 |
const char *fmt, ...) |
|---|
| 217 |
__attribute__ ((__format__(__printf__, 6, 7))); |
|---|
| 218 |
extern CHANUSER *onchannel(dbref who, CHAN *c); |
|---|
| 219 |
extern void init_chatdb(void); |
|---|
| 220 |
extern int load_chatdb(FILE * fp); |
|---|
| 221 |
extern int save_chatdb(FILE * fp); |
|---|
| 222 |
extern void do_cemit |
|---|
| 223 |
(dbref player, const char *name, const char *msg, int flags); |
|---|
| 224 |
extern void do_chan_user_flags |
|---|
| 225 |
(dbref player, char *name, const char *isyn, int flag, int silent); |
|---|
| 226 |
extern void do_chan_wipe(dbref player, const char *name); |
|---|
| 227 |
extern void do_chan_lock |
|---|
| 228 |
(dbref player, const char *name, const char *lockstr, int whichlock); |
|---|
| 229 |
extern void do_chan_what(dbref player, const char *partname); |
|---|
| 230 |
extern void do_chan_desc(dbref player, const char *name, const char *title); |
|---|
| 231 |
extern void do_chan_title(dbref player, const char *name, const char *title); |
|---|
| 232 |
extern void do_chan_recall(dbref player, const char *name, char *lineinfo[], |
|---|
| 233 |
int quiet); |
|---|
| 234 |
extern void do_chan_buffer(dbref player, const char *name, const char *lines); |
|---|
| 235 |
extern void init_chat(void); |
|---|
| 236 |
extern void do_channel |
|---|
| 237 |
(dbref player, const char *name, const char *target, const char *com); |
|---|
| 238 |
extern void do_chat(dbref player, CHAN *chan, const char *arg1); |
|---|
| 239 |
extern void do_chan_admin |
|---|
| 240 |
(dbref player, char *name, const char *perms, int flag); |
|---|
| 241 |
extern enum cmatch_type find_channel(const char *p, CHAN **chan, dbref player); |
|---|
| 242 |
extern enum cmatch_type find_channel_partial(const char *p, CHAN **chan, |
|---|
| 243 |
dbref player); |
|---|
| 244 |
extern void do_channel_list(dbref player, const char *partname); |
|---|
| 245 |
extern int do_chat_by_name |
|---|
| 246 |
(dbref player, const char *name, const char *msg, int source); |
|---|
| 247 |
extern void do_chan_decompile(dbref player, const char *name, int brief); |
|---|
| 248 |
extern void do_chan_chown(dbref player, const char *name, const char *newowner); |
|---|
| 249 |
extern const char *channel_description(dbref player); |
|---|
| 250 |
|
|---|
| 251 |
enum clock_type { CLOCK_JOIN, CLOCK_SPEAK, CLOCK_SEE, CLOCK_HIDE, CLOCK_MOD }; |
|---|
| 252 |
extern int eval_chan_lock(CHAN *c, dbref p, enum clock_type type); |
|---|
| 253 |
|
|---|
| 254 |
|
|---|
| 255 |
enum chan_match_type { |
|---|
| 256 |
PMATCH_ALL, |
|---|
| 257 |
PMATCH_OFF, |
|---|
| 258 |
PMATCH_ON |
|---|
| 259 |
}; |
|---|
| 260 |
|
|---|
| 261 |
|
|---|
| 262 |
#endif |
|---|