#include <ctype.h>
#include <sys/types.h>
#include "copyright.h"
#include "config.h"
#include "db.h"
#include "interface.h"
#include "attrs.h"
#include "match.h"
#include "externs.h"
#include "flags.h"
#include "powers.h"
#include "comsys.h"
#include "p.comsys.h"
#include "p.functions.h"
#include "create.h"
Include dependency graph for comsys.c:
Go to the source code of this file.
Functions | |
static void | do_save_com (chmsg *) |
static void | do_show_com (chmsg *) |
static void | do_comlast (dbref, struct channel *) |
static void | do_comsend (struct channel *, char *) |
static void | do_comprintf (struct channel *, char *,...) |
void | do_joinchannel (dbref, struct channel *) |
static void | do_leavechannel (dbref, struct channel *) |
static void | do_comwho (dbref, struct channel *) |
static void | do_setnewtitle (dbref, struct channel *, char *) |
void | sort_users (struct channel *) |
static int | do_test_access (dbref, long, struct channel *) |
void | init_chantab (void) |
void | send_channel (char *chan, const char *format,...) |
char * | get_channel_from_alias (dbref player, char *alias) |
void | load_comsystem (FILE *fp) |
void | save_comsystem (FILE *fp) |
void | do_processcom (dbref player, char *arg1, char *arg2) |
channel * | select_channel (char *channel) |
comuser * | select_user (struct channel *ch, dbref player) |
void | do_addcom (dbref player, dbref cause, int key, char *arg1, char *arg2) |
void | do_delcom (dbref player, dbref cause, int key, char *arg1) |
void | do_delcomchannel (dbref player, char *channel) |
void | do_createchannel (dbref player, dbref cause, int key, char *channel) |
void | do_destroychannel (dbref player, dbref cause, int key, char *channel) |
void | do_listchannels (dbref player) |
void | do_comtitle (dbref player, dbref cause, int key, char *arg1, char *arg2) |
void | do_comlist (dbref player, dbref cause, int key) |
void | do_channelnuke (dbref player) |
void | do_clearcom (dbref player, dbref cause, int key) |
void | do_allcom (dbref player, dbref cause, int key, char *arg1) |
void | do_channelwho (dbref player, dbref cause, int key, char *arg1) |
void | do_comdisconnectraw_notify (dbref player, char *chan) |
void | do_comconnectraw_notify (dbref player, char *chan) |
void | do_comconnectchannel (dbref player, char *channel, char *alias, int i) |
void | do_comdisconnect (dbref player) |
void | do_comconnect (dbref player, DESC *d) |
void | do_comdisconnectchannel (dbref player, char *channel) |
void | do_editchannel (dbref player, dbref cause, int flag, char *arg1, char *arg2) |
int | do_comsystem (dbref who, char *cmd) |
void | do_chclose (dbref player, char *chan) |
void | do_cemit (dbref player, dbref cause, int key, char *chan, char *text) |
void | do_chopen (dbref player, dbref cause, int key, char *chan, char *object) |
void | do_chloud (dbref player, char *chan) |
void | do_chsquelch (dbref player, char *chan) |
void | do_chtransparent (dbref player, char *chan) |
void | do_chopaque (dbref player, char *chan) |
void | do_chboot (dbref player, dbref cause, int key, char *channel, char *victim) |
void | do_chanobj (dbref player, char *channel, char *object) |
void | do_chanlist (dbref player, dbref cause, int key) |
void | do_chanstatus (dbref player, dbref cause, int key, char *chan) |
void | fun_cemit (char *buff, char **bufc, dbref player, dbref cause, char *fargs[], char *nfargs[], int cargs, int ncargs) |
Variables | |
static FILE * | temp_file |
static dbref | cheat_player |
Definition at line 558 of file comsys.c.
References c, CHANNEL_JOIN, comstar_add_user_to_channel(), comstar_find_channel_by_name(), do_joinchannel(), do_setnewtitle(), do_test_access(), get_commac(), confdata::have_comsys, mudconf, channel::name, notify_printf(), commac::numchannels, raw_notify(), select_channel(), select_user(), and comuser::title.
00559 { 00560 char channel[200]; 00561 char title[100]; 00562 struct channel *ch; 00563 char *s; 00564 int where; 00565 struct commac *c; 00566 00567 if(!mudconf.have_comsys) { 00568 raw_notify(player, "Comsys disabled."); 00569 return; 00570 } 00571 if(!*arg1) { 00572 raw_notify(player, "You need to specify an alias."); 00573 return; 00574 } 00575 if(!*arg2) { 00576 raw_notify(player, "You need to specify a channel."); 00577 return; 00578 } 00579 00580 s = strchr(arg2, ','); 00581 00582 if(s) { 00583 /* channelname,title */ 00584 if(s >= arg2 + 200) { 00585 raw_notify(player, "Channel name too long."); 00586 return; 00587 } 00588 strncpy(channel, arg2, s - arg2); 00589 channel[s - arg2] = '\0'; 00590 strncpy(title, s + 1, 100); 00591 title[99] = '\0'; 00592 } else { 00593 /* just channelname */ 00594 if(strlen(arg2) >= 200) { 00595 raw_notify(player, "Channel name too long."); 00596 return; 00597 } 00598 strcpy(channel, arg2); 00599 title[0] = '\0'; 00600 } 00601 00602 if(strchr(channel, ' ')) { 00603 raw_notify(player, "Channel name cannot contain spaces."); 00604 return; 00605 } 00606 00607 if(!(ch = select_channel(channel))) { 00608 notify_printf(player, "Channel %s does not exist yet.", channel); 00609 return; 00610 } 00611 if(!do_test_access(player, CHANNEL_JOIN, ch)) { 00612 raw_notify(player, 00613 "Sorry, this channel type does not allow you to join."); 00614 return; 00615 } 00616 if(select_user(ch, player)) { 00617 raw_notify(player, 00618 "Warning: you are already listed on that channel."); 00619 } 00620 c = get_commac(player); 00621 for(where = 0; where < c->numchannels && 00622 (strcasecmp(arg1, c->alias + where * 6) > 0); where++); 00623 if(where < c->numchannels && !strcasecmp(arg1, c->alias + where * 6)) { 00624 notify_printf(player, "That alias is already in use for channel %s.", 00625 c->channels[where]); 00626 return; 00627 } 00628 if(c->numchannels >= c->maxchannels) { 00629 c->maxchannels += 10; 00630 c->alias = realloc(c->alias, sizeof(char) * 6 * c->maxchannels); 00631 c->channels = realloc(c->channels, sizeof(char *) * c->maxchannels); 00632 } 00633 if(where < c->numchannels) { 00634 memmove(c->alias + 6 * (where + 1), c->alias + 6 * where, 00635 6 * (c->numchannels - where)); 00636 memmove(c->channels + where + 1, c->channels + where, 00637 sizeof(c->channels) * (c->numchannels - where)); 00638 } 00639 00640 c->numchannels++; 00641 00642 strncpy(c->alias + 6 * where, arg1, 5); 00643 c->alias[where * 6 + 5] = '\0'; 00644 c->channels[where] = strdup(ch->name); 00645 00646 do_joinchannel(player, ch); 00647 do_setnewtitle(player, ch, title); 00648 00649 if(title[0]) 00650 notify_printf(player, "Channel %s added with alias %s and title %s.", 00651 ch, arg1, title); 00652 else 00653 notify_printf(player, "Channel %s added with alias %s.", 00654 ch, arg1); 00655 }
Definition at line 959 of file comsys.c.
References c, do_processcom(), get_commac(), confdata::have_comsys, mudconf, and raw_notify().
00960 { 00961 int i; 00962 struct commac *c; 00963 00964 if(!mudconf.have_comsys) { 00965 raw_notify(player, "Comsys disabled."); 00966 return; 00967 } 00968 c = get_commac(player); 00969 00970 if((strcasecmp(arg1, "who") != 0) && (strcasecmp(arg1, "on") != 0) && 00971 (strcasecmp(arg1, "off") != 0)) { 00972 raw_notify(player, "Only options available are: on, off and who."); 00973 return; 00974 } 00975 for(i = 0; i < c->numchannels; i++) { 00976 do_processcom(player, c->channels[i], arg1); 00977 if(strcasecmp(arg1, "who") == 0) 00978 raw_notify(player, ""); 00979 } 00980 00981 }
Definition at line 1380 of file comsys.c.
References CEMIT_NOHEADER, channel::charge_who, Comm_All, do_comprintf(), do_comsend(), confdata::have_comsys, mudconf, notify_printf(), raw_notify(), and select_channel().
01381 { 01382 struct channel *ch; 01383 01384 if(!mudconf.have_comsys) { 01385 raw_notify(player, "Comsys disabled."); 01386 return; 01387 } 01388 if(!(ch = select_channel(chan))) { 01389 notify_printf(player, "Channel %s does not exist.", chan); 01390 return; 01391 } 01392 if((player != ch->charge_who) && (!Comm_All(player))) { 01393 raw_notify(player, "Permission denied."); 01394 return; 01395 } 01396 if(key == CEMIT_NOHEADER) 01397 do_comsend(ch, text); 01398 else 01399 do_comprintf(ch, "[%s] %s", chan, text); 01400 }
Definition at line 1605 of file comsys.c.
References A_DESC, alloc_mbuf, atr_pget(), channel::chan_obj, statedata::channel_htab, CHANNEL_JOIN, CHANNEL_LOUD, CHANNEL_PUBLIC, channel::charge_who, CLIST_FULL, Comm_All, do_listchannels(), do_test_access(), free_lbuf, free_mbuf, hash_firstentry(), hash_nextentry(), confdata::have_comsys, mudconf, mudstate, channel::name, Name(), NOTHING, channel::owner, raw_notify(), and channel::type.
Referenced by do_chopen().
01606 { 01607 dbref owner; 01608 struct channel *ch; 01609 int flags; 01610 char *temp; 01611 char *buf; 01612 char *atrstr; 01613 01614 if(!mudconf.have_comsys) { 01615 raw_notify(player, "Comsys disabled."); 01616 return; 01617 } 01618 flags = (int) NULL; 01619 01620 if(key & CLIST_FULL) { 01621 do_listchannels(player); 01622 return; 01623 } 01624 temp = alloc_mbuf("do_chanlist_temp"); 01625 buf = alloc_mbuf("do_chanlist_buf"); 01626 01627 raw_notify(player, "** Channel Owner Description"); 01628 01629 for(ch = (struct channel *) hash_firstentry(&mudstate.channel_htab); 01630 ch; ch = (struct channel *) hash_nextentry(&mudstate.channel_htab)) { 01631 if(Comm_All(player) || (ch->type & CHANNEL_PUBLIC) || 01632 ch->charge_who == player || (do_test_access(player, CHANNEL_JOIN, ch))) { 01633 01634 atrstr = atr_pget(ch->chan_obj, A_DESC, &owner, &flags); 01635 if((ch->chan_obj == NOTHING) || !*atrstr) 01636 sprintf(buf, "%s", "No description."); 01637 else 01638 sprintf(buf, "%-54.54s", atrstr); 01639 01640 free_lbuf(atrstr); 01641 sprintf(temp, "%c%c %-13.13s %-15.15s %-45.45s", 01642 (ch->type & (CHANNEL_PUBLIC)) ? 'P' : '-', 01643 (ch->type & (CHANNEL_LOUD)) ? 'L' : '-', ch->name, 01644 Name(ch->charge_who), buf); 01645 01646 raw_notify(player, temp); 01647 } 01648 } 01649 free_mbuf(temp); 01650 free_mbuf(buf); 01651 raw_notify(player, "-- End of list of Channels --"); 01652 }
void do_channelnuke | ( | dbref | player | ) |
Definition at line 924 of file comsys.c.
References statedata::channel_htab, channel::charge_who, hash_firstentry(), hash_nextentry(), hashdelete(), mudstate, channel::name, num_channels, channel::num_users, and channel::users.
Referenced by toast_player().
00925 { 00926 struct channel *ch; 00927 int j; 00928 00929 for(ch = (struct channel *) hash_firstentry(&mudstate.channel_htab); 00930 ch; ch = (struct channel *) hash_nextentry(&mudstate.channel_htab)) { 00931 if(ch->charge_who == player) { 00932 num_channels--; 00933 hashdelete(ch->name, &mudstate.channel_htab); 00934 00935 for(j = 0; j < ch->num_users; j++) 00936 free(ch->users[j]); 00937 free(ch->users); 00938 free(ch); 00939 } 00940 } 00941 }
Definition at line 1005 of file comsys.c.
References CHANNEL_TRANSPARENT, channel::charge_who, Comm_All, Dark, flag, free_lbuf, confdata::have_comsys, Hidden, LBUF_SIZE, mudconf, channel::name, notify_printf(), channel::num_users, comuser::on, raw_notify(), select_channel(), strip_ansi_r(), channel::type, TYPE_PLAYER, Typeof, UNDEAD, unparse_object(), channel::users, comuser::who, and Wizard_Who.
01006 { 01007 struct channel *ch; 01008 struct comuser *user; 01009 char channel[100]; 01010 int flag = 0; 01011 char *cp; 01012 int i; 01013 char ansibuffer[LBUF_SIZE]; 01014 char outputbuffer[LBUF_SIZE]; 01015 01016 if(!mudconf.have_comsys) { 01017 raw_notify(player, "Comsys disabled."); 01018 return; 01019 } 01020 cp = strchr(arg1, '/'); 01021 if(!cp) { 01022 strncpy(channel, arg1, 100); 01023 channel[99] = '\0'; 01024 } else { 01025 /* channelname/all */ 01026 if(cp - arg1 >= 100) { 01027 raw_notify(player, "Channel name too long."); 01028 return; 01029 } 01030 strncpy(channel, arg1, cp - arg1); 01031 channel[cp - arg1] = '\0'; 01032 if(*++cp == 'a') 01033 flag = 1; 01034 } 01035 01036 if(!(ch = select_channel(channel))) { 01037 notify_printf(player, "Unknown channel \"%s\".", channel); 01038 return; 01039 } 01040 if(!((Comm_All(player)) || (player == ch->charge_who))) { 01041 raw_notify(player, "You do not have permission to do that."); 01042 return; 01043 } 01044 notify_printf(player, "-- %s --", ch->name); 01045 notify_printf(player, "%-29.29s %-6.6s %-6.6s", "Name", "Status", 01046 "Player"); 01047 for(i = 0; i < ch->num_users; i++) { 01048 user = ch->users[i]; 01049 if((flag || UNDEAD(user->who)) && (!Hidden(user->who) || 01050 ((ch->type & CHANNEL_TRANSPARENT) 01051 && !Dark(user->who)) 01052 || Wizard_Who(player))) { 01053 cp = unparse_object(player, user->who, 0); 01054 strip_ansi_r(ansibuffer, cp, LBUF_SIZE); 01055 notify_printf(player, "%-29.29s %-6.6s %-6.6s", ansibuffer, 01056 ((user->on) ? "on " : "off"), 01057 (Typeof(user->who) == TYPE_PLAYER) ? "yes" : "no "); 01058 free_lbuf(cp); 01059 } 01060 } 01061 notify_printf(player, "-- %s --", ch->name); 01062 }
void do_chanobj | ( | dbref | player, | |
char * | channel, | |||
char * | object | |||
) |
Definition at line 1574 of file comsys.c.
References channel::chan_obj, channel::charge_who, Comm_All, free_lbuf, init_match(), match_everything(), match_result(), channel::name, NOTHING, notify_printf(), NOTYPE, raw_notify(), select_channel(), and unparse_object().
Referenced by do_chopen().
01575 { 01576 struct channel *ch; 01577 dbref thing; 01578 char *buff; 01579 01580 init_match(player, object, NOTYPE); 01581 match_everything(0); 01582 thing = match_result(); 01583 01584 if(!(ch = select_channel(channel))) { 01585 raw_notify(player, "That channel does not exist."); 01586 return; 01587 } 01588 if(thing == NOTHING) { 01589 ch->chan_obj = NOTHING; 01590 raw_notify(player, "Set."); 01591 return; 01592 } 01593 if(!(ch->charge_who == player) && !Comm_All(player)) { 01594 raw_notify(player, "Permission denied."); 01595 return; 01596 } 01597 ch->chan_obj = thing; 01598 buff = unparse_object(player, thing, 0); 01599 notify_printf(player, 01600 "Channel %s is now using %s as channel object.", ch->name, 01601 buff); 01602 free_lbuf(buff); 01603 }
Definition at line 1654 of file comsys.c.
References A_DESC, alloc_mbuf, channel::amount_col, atr_pget(), channel::chan_obj, CHANNEL_JOIN, CHANNEL_LOUD, CHANNEL_OBJ_MULT, CHANNEL_PL_MULT, CHANNEL_PUBLIC, CHANNEL_RECIEVE, CHANNEL_TRANSMIT, channel::charge, channel::charge_who, Comm_All, CSTATUS_FULL, free_lbuf, free_mbuf, confdata::have_comsys, MBUF_SIZE, mudconf, channel::name, Name(), NOTHING, notify_printf(), channel::num_messages, channel::num_users, channel::owner, raw_notify(), select_channel(), and channel::type.
Referenced by do_chopen().
01655 { 01656 dbref owner; 01657 struct channel *ch; 01658 int flags; 01659 char *temp; 01660 char *buf; 01661 char *atrstr; 01662 01663 if(!mudconf.have_comsys) { 01664 raw_notify(player, "Comsys disabled."); 01665 return; 01666 } 01667 01668 if(key & CSTATUS_FULL) { 01669 struct channel *ch; 01670 int perm; 01671 01672 if(!(perm = Comm_All(player))) { 01673 raw_notify(player, 01674 "Warning: Only public channels and your channels will be shown."); 01675 } 01676 raw_notify(player, 01677 "** Channel --Flags-- Obj Own Charge Balance Users Messages"); 01678 01679 if(!(ch = select_channel(chan))) { 01680 notify_printf(player, 01681 "@cstatus: Channel %s does not exist.", chan); 01682 return; 01683 } 01684 if(perm || (ch->type & CHANNEL_PUBLIC) || ch->charge_who == player) { 01685 01686 notify_printf(player, 01687 "%c%c %-20.20s %c%c%c/%c%c%c %5d %5d %8d %8d %6d %10d", 01688 (ch->type & (CHANNEL_PUBLIC)) ? 'P' : '-', 01689 (ch->type & (CHANNEL_LOUD)) ? 'L' : '-', ch->name, 01690 (ch-> 01691 type & (CHANNEL_PL_MULT * 01692 CHANNEL_JOIN)) ? 'J' : '-', 01693 (ch-> 01694 type & (CHANNEL_PL_MULT * 01695 CHANNEL_TRANSMIT)) ? 'X' : '-', 01696 (ch-> 01697 type & (CHANNEL_PL_MULT * 01698 CHANNEL_RECIEVE)) ? 'R' : '-', 01699 (ch-> 01700 type & (CHANNEL_OBJ_MULT * 01701 CHANNEL_JOIN)) ? 'j' : '-', 01702 (ch-> 01703 type & (CHANNEL_OBJ_MULT * 01704 CHANNEL_TRANSMIT)) ? 'x' : '-', 01705 (ch-> 01706 type & (CHANNEL_OBJ_MULT * 01707 CHANNEL_RECIEVE)) ? 'r' : '-', 01708 (ch->chan_obj != NOTHING) ? ch->chan_obj : -1, 01709 ch->charge_who, ch->charge, ch->amount_col, 01710 ch->num_users, ch->num_messages); 01711 } 01712 raw_notify(player, "-- End of list of Channels --"); 01713 return; 01714 } 01715 temp = alloc_mbuf("do_chanstatus_temp"); 01716 buf = alloc_mbuf("do_chanstatus_buf"); 01717 01718 raw_notify(player, "** Channel Owner Description"); 01719 if(!(ch = select_channel(chan))) { 01720 notify_printf(player, "@cstatus: Channel %s does not exist.", chan); 01721 return; 01722 } 01723 if(Comm_All(player) || (ch->type & CHANNEL_PUBLIC) || 01724 ch->charge_who == player) { 01725 01726 atrstr = atr_pget(ch->chan_obj, A_DESC, &owner, &flags); 01727 if((ch->chan_obj == NOTHING) || !*atrstr) 01728 sprintf(buf, "%s", "No description."); 01729 else 01730 sprintf(buf, "%-54.54s", atrstr); 01731 01732 free_lbuf(atrstr); 01733 snprintf(temp, MBUF_SIZE, "%c%c %-13.13s %-15.15s %-45.45s", 01734 (ch->type & (CHANNEL_PUBLIC)) ? 'P' : '-', 01735 (ch->type & (CHANNEL_LOUD)) ? 'L' : '-', ch->name, 01736 Name(ch->charge_who), buf); 01737 01738 raw_notify(player, temp); 01739 } 01740 free_mbuf(temp); 01741 free_mbuf(buf); 01742 raw_notify(player, "-- End of list of Channels --"); 01743 }
Definition at line 1526 of file comsys.c.
References channel::charge_who, Comm_All, do_comprintf(), do_delcomchannel(), confdata::have_comsys, match_thing(), mudconf, Name(), channel::name, NOTHING, notify_printf(), raw_notify(), select_channel(), select_user(), and unparse_object_numonly().
01528 { 01529 struct comuser *user; 01530 struct channel *ch; 01531 struct comuser *vu; 01532 dbref thing; 01533 01534 /* 01535 * * I sure hope it's not going to be that * 01536 * * * * * * * * long. 01537 */ 01538 01539 if(!mudconf.have_comsys) { 01540 raw_notify(player, "Comsys disabled."); 01541 return; 01542 } 01543 if(!(ch = select_channel(channel))) { 01544 raw_notify(player, "@cboot: Unknown channel."); 01545 return; 01546 } 01547 if(!(user = select_user(ch, player))) { 01548 raw_notify(player, "@cboot: You are not on that channel."); 01549 return; 01550 } 01551 if(!((ch->charge_who == player) || Comm_All(player))) { 01552 raw_notify(player, "Permission denied."); 01553 return; 01554 } 01555 thing = match_thing(player, victim); 01556 01557 if(thing == NOTHING) { 01558 return; 01559 } 01560 if(!(vu = select_user(ch, thing))) { 01561 notify_printf(player, "@cboot: %s in not on the channel.", 01562 Name(thing)); 01563 return; 01564 } 01565 /* 01566 * We should be in the clear now. :) 01567 */ 01568 do_comprintf(ch, "[%s] %s boots %s off the channel.", ch->name, 01569 unparse_object_numonly(player), unparse_object_numonly(thing)); 01570 do_delcomchannel(thing, channel); 01571 01572 }
void do_chclose | ( | dbref | player, | |
char * | chan | |||
) |
Definition at line 1362 of file comsys.c.
References CHANNEL_PUBLIC, channel::charge_who, Comm_All, notify_printf(), raw_notify(), select_channel(), and channel::type.
Referenced by do_chopen().
01363 { 01364 struct channel *ch; 01365 01366 if(!(ch = select_channel(chan))) { 01367 notify_printf(player, "@cset: Channel %s does not exist.", chan); 01368 return; 01369 } 01370 if((player != ch->charge_who) && (!Comm_All(player))) { 01371 raw_notify(player, "@cset: Permission denied."); 01372 return; 01373 } 01374 ch->type &= (~(CHANNEL_PUBLIC)); 01375 notify_printf(player, 01376 "@cset: Channel %s taken off the public listings.", chan); 01377 return; 01378 }
void do_chloud | ( | dbref | player, | |
char * | chan | |||
) |
Definition at line 1451 of file comsys.c.
References CHANNEL_LOUD, channel::charge_who, Comm_All, notify_printf(), raw_notify(), select_channel(), and channel::type.
Referenced by do_chopen().
01452 { 01453 struct channel *ch; 01454 01455 if(!(ch = select_channel(chan))) { 01456 notify_printf(player, "@cset: Channel %s does not exist.", chan); 01457 return; 01458 } 01459 if((player != ch->charge_who) && (!Comm_All(player))) { 01460 raw_notify(player, "@cset: Permission denied."); 01461 return; 01462 } 01463 ch->type |= (CHANNEL_LOUD); 01464 notify_printf(player, 01465 "@cset: Channel %s now sends connect/disconnect msgs.", 01466 chan); 01467 return; 01468 }
void do_chopaque | ( | dbref | player, | |
char * | chan | |||
) |
Definition at line 1507 of file comsys.c.
References CHANNEL_TRANSPARENT, channel::charge_who, Comm_All, notify_printf(), raw_notify(), select_channel(), and channel::type.
Referenced by do_chopen().
01508 { 01509 struct channel *ch; 01510 01511 if(!(ch = select_channel(chan))) { 01512 notify_printf(player, "@cset: Channel %s does not exist.", chan); 01513 return; 01514 } 01515 if((player != ch->charge_who) && (!Comm_All(player))) { 01516 raw_notify(player, "@cset: Permission denied."); 01517 return; 01518 } 01519 ch->type &= ~CHANNEL_TRANSPARENT; 01520 notify_printf(player, 01521 "@cset: Channel %s now does not show all listeners to everyone.", 01522 chan); 01523 return; 01524 }
Definition at line 1402 of file comsys.c.
References CHANNEL_PUBLIC, channel::charge_who, Comm_All, CSET_LIST, CSET_LOUD, CSET_OBJECT, CSET_OPAQUE, CSET_PRIVATE, CSET_QUIET, CSET_STATUS, CSET_TRANSPARENT, do_chanlist(), do_chanobj(), do_chanstatus(), do_chclose(), do_chloud(), do_chopaque(), do_chsquelch(), do_chtransparent(), confdata::have_comsys, mudconf, NOTHING, notify_printf(), raw_notify(), select_channel(), and channel::type.
01403 { 01404 struct channel *ch; 01405 01406 if(!mudconf.have_comsys) { 01407 raw_notify(player, "Comsys disabled."); 01408 return; 01409 } 01410 switch (key) { 01411 case CSET_PRIVATE: 01412 do_chclose(player, chan); 01413 return; 01414 case CSET_LOUD: 01415 do_chloud(player, chan); 01416 return; 01417 case CSET_QUIET: 01418 do_chsquelch(player, chan); 01419 return; 01420 case CSET_LIST: 01421 do_chanlist(player, NOTHING, 1); 01422 return; 01423 case CSET_OBJECT: 01424 do_chanobj(player, chan, object); 01425 return; 01426 case CSET_STATUS: 01427 do_chanstatus(player, NOTHING, 1, chan); 01428 return; 01429 case CSET_TRANSPARENT: 01430 do_chtransparent(player, chan); 01431 return; 01432 case CSET_OPAQUE: 01433 do_chopaque(player, chan); 01434 return; 01435 } 01436 01437 if(!(ch = select_channel(chan))) { 01438 notify_printf(player, "@cset: Channel %s does not exist.", chan); 01439 return; 01440 } 01441 if((player != ch->charge_who) && (!Comm_All(player))) { 01442 raw_notify(player, "@cset: Permission denied."); 01443 return; 01444 } 01445 ch->type |= (CHANNEL_PUBLIC); 01446 notify_printf(player, "@cset: Channel %s placed on the public listings.", 01447 chan); 01448 return; 01449 }
void do_chsquelch | ( | dbref | player, | |
char * | chan | |||
) |
Definition at line 1470 of file comsys.c.
References CHANNEL_LOUD, channel::charge_who, Comm_All, notify_printf(), raw_notify(), select_channel(), and channel::type.
Referenced by do_chopen().
01471 { 01472 struct channel *ch; 01473 01474 if(!(ch = select_channel(chan))) { 01475 notify_printf(player, "@cset: Channel %s does not exist.", chan); 01476 return; 01477 } 01478 if((player != ch->charge_who) && (!Comm_All(player))) { 01479 raw_notify(player, "@cset: Permission denied."); 01480 return; 01481 } 01482 ch->type &= ~(CHANNEL_LOUD); 01483 notify_printf(player, 01484 "@cset: Channel %s connect/disconnect msgs muted.", chan); 01485 return; 01486 }
void do_chtransparent | ( | dbref | player, | |
char * | chan | |||
) |
Definition at line 1488 of file comsys.c.
References CHANNEL_TRANSPARENT, channel::charge_who, Comm_All, notify_printf(), raw_notify(), select_channel(), and channel::type.
Referenced by do_chopen().
01489 { 01490 struct channel *ch; 01491 01492 if(!(ch = select_channel(chan))) { 01493 notify_printf(player, "@cset: Channel %s does not exist.", chan); 01494 return; 01495 } 01496 if((player != ch->charge_who) && (!Comm_All(player))) { 01497 raw_notify(player, "@cset: Permission denied."); 01498 return; 01499 } 01500 ch->type |= CHANNEL_TRANSPARENT; 01501 notify_printf(player, 01502 "@cset: Channel %s now shows all listeners to everyone.", 01503 chan); 01504 return; 01505 }
Definition at line 943 of file comsys.c.
References c, do_delcom(), get_commac(), confdata::have_comsys, mudconf, and raw_notify().
Referenced by toast_player().
00944 { 00945 int i; 00946 struct commac *c; 00947 00948 if(!mudconf.have_comsys) { 00949 raw_notify(player, "Comsys disabled."); 00950 return; 00951 } 00952 c = get_commac(player); 00953 00954 for(i = (c->numchannels) - 1; i > -1; --i) { 00955 do_delcom(player, player, 0, c->alias + i * 6); 00956 } 00957 }
Definition at line 1130 of file comsys.c.
References descriptor_data::addr, c, do_comconnectchannel(), do_comconnectraw_notify(), get_commac(), Name(), and send_channel().
Referenced by announce_connect().
01131 { 01132 struct commac *c; 01133 int i; 01134 char *lsite; 01135 01136 c = get_commac(player); 01137 01138 for(i = 0; i < c->numchannels; i++) { 01139 do_comconnectchannel(player, c->channels[i], c->alias, i); 01140 do_comconnectraw_notify(player, c->channels[i]); 01141 } 01142 lsite = d->addr; 01143 if(lsite && *lsite) 01144 send_channel("MUXConnections","* %s has connected from %s *", Name(player), lsite); 01145 else 01146 send_channel("MUXConnections","* %s has connected from somewhere *", Name(player)); 01147 }
void do_comconnectchannel | ( | dbref | player, | |
char * | channel, | |||
char * | alias, | |||
int | i | |||
) |
Definition at line 1094 of file comsys.c.
References notify_printf(), comuser::on_next, channel::on_users, select_channel(), select_user(), and comuser::who.
Referenced by do_comconnect().
01095 { 01096 struct channel *ch; 01097 struct comuser *user; 01098 01099 if((ch = select_channel(channel))) { 01100 for(user = ch->on_users; user && user->who != player; 01101 user = user->on_next); 01102 01103 if(!user) { 01104 if((user = select_user(ch, player))) { 01105 user->on_next = ch->on_users; 01106 ch->on_users = user; 01107 } else 01108 notify_printf(player, "Bad Comsys Alias: %s for Channel: %s", 01109 alias + i * 6, channel); 01110 } 01111 } else 01112 notify_printf(player, "Bad Comsys Alias: %s for Channel: %s", 01113 alias + i * 6, channel); 01114 }
void do_comconnectraw_notify | ( | dbref | player, | |
char * | chan | |||
) |
Definition at line 1079 of file comsys.c.
References CHANNEL_LOUD, Dark, do_comprintf(), channel::name, Name(), comuser::on, select_channel(), select_user(), and channel::type.
Referenced by do_comconnect().
01080 { 01081 struct channel *ch; 01082 struct comuser *cu; 01083 01084 if(!(ch = select_channel(chan))) 01085 return; 01086 if(!(cu = select_user(ch, player))) 01087 return; 01088 01089 if((ch->type & CHANNEL_LOUD) && (cu->on) && (!Dark(player))) { 01090 do_comprintf(ch, "[%s] %s has connected.", ch->name, Name(player)); 01091 } 01092 }
void do_comdisconnect | ( | dbref | player | ) |
Definition at line 1116 of file comsys.c.
References c, do_comdisconnectchannel(), do_comdisconnectraw_notify(), get_commac(), Name(), and send_channel().
Referenced by announce_disconnect().
01117 { 01118 int i; 01119 struct commac *c; 01120 01121 c = get_commac(player); 01122 01123 for(i = 0; i < c->numchannels; i++) { 01124 do_comdisconnectchannel(player, c->channels[i]); 01125 do_comdisconnectraw_notify(player, c->channels[i]); 01126 } 01127 send_channel("MUXConnections", "* %s has disconnected *", Name(player)); 01128 }
void do_comdisconnectchannel | ( | dbref | player, | |
char * | channel | |||
) |
Definition at line 1149 of file comsys.c.
References comuser::on_next, channel::on_users, select_channel(), and comuser::who.
Referenced by do_comdisconnect(), and do_delcomchannel().
01150 { 01151 struct comuser *user, *prevuser = NULL; 01152 struct channel *ch; 01153 01154 if(!(ch = select_channel(channel))) 01155 return; 01156 for(user = ch->on_users; user;) { 01157 if(user->who == player) { 01158 if(prevuser) 01159 prevuser->on_next = user->on_next; 01160 else 01161 ch->on_users = user->on_next; 01162 return; 01163 } else { 01164 prevuser = user; 01165 user = user->on_next; 01166 } 01167 } 01168 }
void do_comdisconnectraw_notify | ( | dbref | player, | |
char * | chan | |||
) |
Definition at line 1064 of file comsys.c.
References CHANNEL_LOUD, Dark, do_comprintf(), channel::name, Name(), comuser::on, select_channel(), select_user(), and channel::type.
Referenced by do_comdisconnect().
01065 { 01066 struct channel *ch; 01067 struct comuser *cu; 01068 01069 if(!(ch = select_channel(chan))) 01070 return; 01071 if(!(cu = select_user(ch, player))) 01072 return; 01073 01074 if((ch->type & CHANNEL_LOUD) && (cu->on) && (!Dark(player))) { 01075 do_comprintf(ch, "[%s] %s has disconnected.", ch->name, Name(player)); 01076 } 01077 }
Definition at line 263 of file comsys.c.
References cheat_player, do_show_com(), myfifo_length(), myfifo_trav_r(), channel::name, and notify_printf().
Referenced by do_processcom().
00264 { 00265 if(!myfifo_length(&ch->last_messages)) { 00266 notify_printf(player, "There haven't been any messages on %s.", 00267 ch->name); 00268 return; 00269 } 00270 cheat_player = player; 00271 myfifo_trav_r(&ch->last_messages, do_show_com); 00272 }
Definition at line 896 of file comsys.c.
References c, get_commac(), confdata::have_comsys, mudconf, notify_printf(), comuser::on, raw_notify(), select_channel(), select_user(), and comuser::title.
00897 { 00898 struct comuser *user; 00899 struct commac *c; 00900 int i; 00901 00902 if(!mudconf.have_comsys) { 00903 raw_notify(player, "Comsys disabled."); 00904 return; 00905 } 00906 c = get_commac(player); 00907 00908 raw_notify(player, 00909 "Alias Channel Title Status"); 00910 00911 for(i = 0; i < c->numchannels; i++) { 00912 if((user = select_user(select_channel(c->channels[i]), player))) { 00913 notify_printf(player, "%-9.9s %-19.19s %-39.39s %s", 00914 c->alias + i * 6, c->channels[i], 00915 user->title, (user->on ? "on" : "off")); 00916 } else { 00917 notify_printf(player, "Bad Comsys Alias: %s for Channel: %s", 00918 c->alias + i * 6, c->channels[i]); 00919 } 00920 } 00921 raw_notify(player, "-- End of comlist --"); 00922 }
static void do_comprintf | ( | struct channel * | , | |
char * | , | |||
... | ||||
) | [static] |
Definition at line 365 of file comsys.c.
References c, CHANNEL_HISTORY_LEN, CHANNEL_RECIEVE, Connected, Create, do_test_access(), In_IC_Loc(), LBUF_SIZE, mudstate, myfifo_length(), myfifo_pop(), myfifo_push(), notify, statedata::now, channel::num_messages, comuser::on, comuser::on_next, channel::on_users, raw_notify(), TYPE_PLAYER, Typeof, comuser::who, and Wizard.
Referenced by do_cemit(), do_chboot(), do_comconnectraw_notify(), do_comdisconnectraw_notify(), do_delcomchannel(), do_joinchannel(), do_leavechannel(), do_processcom(), and fun_cemit().
00366 { 00367 struct comuser *user; 00368 chmsg *c; 00369 va_list ap; 00370 char buffer[LBUF_SIZE]; 00371 memset(buffer, 0, LBUF_SIZE); 00372 va_start(ap, messfmt); 00373 vsnprintf(buffer, LBUF_SIZE-1, messfmt, ap); 00374 va_end(ap); 00375 00376 ch->num_messages++; 00377 for(user = ch->on_users; user; user = user->on_next) { 00378 if(user->on && do_test_access(user->who, CHANNEL_RECIEVE, ch) && 00379 (Wizard(user->who) || !In_IC_Loc(user->who))) { 00380 if(Typeof(user->who) == TYPE_PLAYER && Connected(user->who)) 00381 raw_notify(user->who, buffer); 00382 else 00383 notify(user->who, buffer); 00384 } 00385 } 00386 /* Also, add it to the history of channel */ 00387 if(myfifo_length(&ch->last_messages) >= CHANNEL_HISTORY_LEN) { 00388 c = myfifo_pop(&ch->last_messages); 00389 free((void *) c->msg); 00390 } else 00391 Create(c, chmsg, 1); 00392 c->msg = strdup(buffer); 00393 c->time = mudstate.now; 00394 myfifo_push(&ch->last_messages, c); 00395 }
static void do_comsend | ( | struct channel * | , | |
char * | ||||
) | [static] |
Definition at line 339 of file comsys.c.
References c, CHANNEL_HISTORY_LEN, CHANNEL_RECIEVE, Connected, Create, do_test_access(), In_IC_Loc(), mudstate, myfifo_length(), myfifo_pop(), myfifo_push(), notify, statedata::now, channel::num_messages, comuser::on, comuser::on_next, channel::on_users, raw_notify(), TYPE_PLAYER, Typeof, comuser::who, and Wizard.
Referenced by do_cemit(), and send_channel().
00340 { 00341 struct comuser *user; 00342 chmsg *c; 00343 00344 ch->num_messages++; 00345 for(user = ch->on_users; user; user = user->on_next) { 00346 if(user->on && do_test_access(user->who, CHANNEL_RECIEVE, ch) && 00347 (Wizard(user->who) || !In_IC_Loc(user->who))) { 00348 if(Typeof(user->who) == TYPE_PLAYER && Connected(user->who)) 00349 raw_notify(user->who, mess); 00350 else 00351 notify(user->who, mess); 00352 } 00353 } 00354 /* Also, add it to the history of channel */ 00355 if(myfifo_length(&ch->last_messages) >= CHANNEL_HISTORY_LEN) { 00356 c = myfifo_pop(&ch->last_messages); 00357 free((void *) c->msg); 00358 } else 00359 Create(c, chmsg, 1); 00360 c->msg = strdup(mess); 00361 c->time = mudstate.now; 00362 myfifo_push(&ch->last_messages, c); 00363 }
int do_comsystem | ( | dbref | who, | |
char * | cmd | |||
) |
Definition at line 1334 of file comsys.c.
References alloc_lbuf, do_processcom(), free_lbuf, and get_channel_from_alias().
Referenced by process_command().
01335 { 01336 char *t; 01337 char *ch; 01338 char *alias; 01339 char *s; 01340 01341 alias = alloc_lbuf("do_comsystem"); 01342 s = alias; 01343 for(t = cmd; *t && *t != ' '; *s++ = *t++) 01344 /* nothing */ ; 01345 01346 *s = '\0'; 01347 01348 if(*t) 01349 t++; 01350 01351 ch = get_channel_from_alias(who, alias); 01352 if(ch && *ch) { 01353 do_processcom(who, ch, t); 01354 free_lbuf(alias); 01355 return 0; 01356 } 01357 free_lbuf(alias); 01358 return 1; 01359 01360 }
Definition at line 865 of file comsys.c.
References do_setnewtitle(), get_channel_from_alias(), confdata::have_comsys, mudconf, notify_printf(), raw_notify(), select_channel(), and select_user().
00866 { 00867 struct channel *ch; 00868 char channel[100]; 00869 00870 if(!mudconf.have_comsys) { 00871 raw_notify(player, "Comsys disabled."); 00872 return; 00873 } 00874 if(!*arg1) { 00875 raw_notify(player, "Need an alias to do comtitle."); 00876 return; 00877 } 00878 strncpy(channel, get_channel_from_alias(player, arg1), 100); 00879 channel[99] = '\0'; 00880 00881 if(!*channel) { 00882 raw_notify(player, "Unknown alias"); 00883 return; 00884 } 00885 if((ch = select_channel(channel)) && select_user(ch, player)) { 00886 notify_printf(player, "Title set to '%s' on channel %s.", 00887 arg2, channel); 00888 do_setnewtitle(player, ch, arg2); 00889 } 00890 if(!ch) { 00891 raw_notify(player, "Invalid comsys alias, please delete."); 00892 return; 00893 } 00894 }
Definition at line 479 of file comsys.c.
References c, CHANNEL_TRANSPARENT, Connected, Dark, fetch_idle(), free_lbuf, free_sbuf, get_uptime_to_string(), God, Going, Hidden, In_IC_Loc(), channel::name, notify_printf(), comuser::on, comuser::on_next, channel::on_users, Owner, raw_notify(), channel::type, TYPE_PLAYER, Typeof, unparse_object(), comuser::who, Wizard, and Wizard_Who.
Referenced by do_processcom().
00480 { 00481 struct comuser *user; 00482 char *buff; 00483 00484 raw_notify(player, "-- Players --"); 00485 for(user = ch->on_users; user; user = user->on_next) { 00486 if(Typeof(user->who) == TYPE_PLAYER && user->on && 00487 Connected(user->who) && (!Hidden(user->who) || 00488 ((ch->type & CHANNEL_TRANSPARENT) 00489 && !Dark(user->who)) 00490 || Wizard_Who(player)) 00491 && (!In_IC_Loc(user->who) || Wizard(user->who))) { 00492 00493 int i = fetch_idle(user->who); 00494 00495 buff = unparse_object(player, user->who, 0); 00496 if(i > 30) { 00497 char *c = get_uptime_to_string(i); 00498 00499 notify_printf(player, "%s [idle %s]", buff, c); 00500 free_sbuf(c); 00501 } else 00502 notify_printf(player, "%s", buff); 00503 free_lbuf(buff); 00504 } 00505 } 00506 00507 raw_notify(player, "-- Objects --"); 00508 for(user = ch->on_users; user; user = user->on_next) { 00509 if(Typeof(user->who) != TYPE_PLAYER && user->on && 00510 !(Going(user->who) && God(Owner(user->who)))) { 00511 buff = unparse_object(player, user->who, 0); 00512 notify_printf(player, "%s", buff); 00513 free_lbuf(buff); 00514 } 00515 } 00516 notify_printf(player, "-- %s --", ch->name); 00517 }
Definition at line 751 of file comsys.c.
References channel::amount_col, CHAN_NAME_LEN, channel::chan_obj, statedata::channel_htab, channel::channel_object, channel::charge, channel::charge_who, Comm_All, comstar_compare_channel_user(), comstar_find_channel_by_name(), hashadd(), confdata::have_comsys, channel::max_users, mudconf, mudstate, channel::name, NOTHING, notify_printf(), num_channels, channel::num_messages, channel::num_users, channel::on_users, channel::owner, raw_notify(), rb_init(), select_channel(), channel::temp1, channel::temp2, channel::type, and channel::users.
00752 { 00753 struct channel *newchannel; 00754 00755 if(!mudconf.have_comsys) { 00756 raw_notify(player, "Comsys disabled."); 00757 return; 00758 } 00759 if(select_channel(channel)) { 00760 notify_printf(player, "Channel %s already exists.", channel); 00761 return; 00762 } 00763 if(!*channel) { 00764 raw_notify(player, "You must specify a channel to create."); 00765 return; 00766 } 00767 if(!(Comm_All(player))) { 00768 raw_notify(player, "You do not have permission to do that."); 00769 return; 00770 } 00771 newchannel = (struct channel *) malloc(sizeof(struct channel)); 00772 00773 strncpy(newchannel->name, channel, CHAN_NAME_LEN - 1); 00774 newchannel->name[CHAN_NAME_LEN - 1] = '\0'; 00775 newchannel->last_messages = NULL; 00776 newchannel->type = 127; 00777 newchannel->temp1 = 0; 00778 newchannel->temp2 = 0; 00779 newchannel->charge = 0; 00780 newchannel->charge_who = player; 00781 newchannel->amount_col = 0; 00782 newchannel->num_users = 0; 00783 newchannel->max_users = 0; 00784 newchannel->users = NULL; 00785 newchannel->on_users = NULL; 00786 newchannel->chan_obj = NOTHING; 00787 newchannel->num_messages = 0; 00788 00789 num_channels++; 00790 00791 hashadd(newchannel->name, (int *) newchannel, &mudstate.channel_htab); 00792 00793 notify_printf(player, "Channel %s created.", channel); 00794 }
Definition at line 676 of file comsys.c.
References c, comstar_find_channel_by_user_alias(), comstar_remove_user_from_channel(), do_delcomchannel(), get_commac(), confdata::have_comsys, mudconf, channel::name, notify_printf(), commac::numchannels, and raw_notify().
00677 { 00678 int i; 00679 struct commac *c; 00680 00681 if(!mudconf.have_comsys) { 00682 raw_notify(player, "Comsys disabled."); 00683 return; 00684 } 00685 if(!arg1) { 00686 raw_notify(player, "Need an alias to delete."); 00687 return; 00688 } 00689 c = get_commac(player); 00690 00691 for(i = 0; i < c->numchannels; i++) { 00692 if(!strcasecmp(arg1, c->alias + i * 6)) { 00693 do_delcomchannel(player, c->channels[i]); 00694 notify_printf(player, "Channel %s deleted.", c->channels[i]); 00695 free(c->channels[i]); 00696 00697 c->numchannels--; 00698 if(i < c->numchannels) { 00699 memmove(c->alias + 6 * i, c->alias + 6 * (i + 1), 00700 6 * (c->numchannels - i)); 00701 memmove(c->channels + i, c->channels + i + 1, 00702 sizeof(c->channels) * (c->numchannels - i)); 00703 } 00704 return; 00705 } 00706 } 00707 raw_notify(player, "Unable to find that alias."); 00708 }
void do_delcomchannel | ( | dbref | player, | |
char * | channel | |||
) |
Definition at line 710 of file comsys.c.
References A_ALEAVE, c, Dark, did_it(), do_comdisconnectchannel(), do_comprintf(), Name(), notify_printf(), channel::num_users, comuser::on, select_channel(), comuser::title, TYPE_THING, Typeof, channel::users, and comuser::who.
Referenced by do_chboot(), and do_delcom().
00711 { 00712 struct channel *ch; 00713 struct comuser *user; 00714 int i; 00715 00716 if(!(ch = select_channel(channel))) { 00717 notify_printf(player, "Unknown channel %s.", channel); 00718 } else { 00719 00720 /* Trigger ALEAVE of any channel objects on the channel */ 00721 for(i = ch->num_users - 1; i > 0; i--) { 00722 if(Typeof(ch->users[i]->who) == TYPE_THING) 00723 did_it(player, ch->users[i]->who, 0, NULL, 0, NULL, A_ALEAVE, 00724 (char **) NULL, 0); 00725 } 00726 00727 for(i = 0; i < ch->num_users; i++) { 00728 user = ch->users[i]; 00729 if(user->who == player) { 00730 do_comdisconnectchannel(player, channel); 00731 if(user->on && !Dark(player)) { 00732 char *c = Name(player); 00733 00734 if(c && *c) 00735 do_comprintf(ch, "[%s] %s has left this channel.", channel, c); 00736 } 00737 notify_printf(player, "You have left channel %s.", channel); 00738 00739 if(user->title) 00740 free(user->title); 00741 free(user); 00742 ch->num_users--; 00743 if(i < ch->num_users) 00744 memmove(ch->users + i, ch->users + i + 1, 00745 sizeof(ch->users) * (ch->num_users - i)); 00746 } 00747 } 00748 } 00749 }
Definition at line 796 of file comsys.c.
References channel_user::channel, statedata::channel_htab, channels, channel::charge_who, Comm_All, comstar_find_channel_by_name(), comstar_remove_user_from_channel(), hashdelete(), hashfind(), confdata::have_comsys, mudconf, mudstate, channel::name, notify_printf(), num_channels, channel::num_users, channel::owner, channel_user::player, raw_notify(), rb_delete(), rb_search(), rb_size(), SEARCH_FIRST, and channel::users.
00797 { 00798 struct channel *ch; 00799 int j; 00800 00801 if(!mudconf.have_comsys) { 00802 raw_notify(player, "Comsys disabled."); 00803 return; 00804 } 00805 ch = (struct channel *) hashfind(channel, &mudstate.channel_htab); 00806 00807 if(!ch) { 00808 notify_printf(player, "Could not find channel %s.", channel); 00809 return; 00810 } else if(!(Comm_All(player)) && (player != ch->charge_who)) { 00811 raw_notify(player, "You do not have permission to do that. "); 00812 return; 00813 } 00814 num_channels--; 00815 hashdelete(channel, &mudstate.channel_htab); 00816 00817 for(j = 0; j < ch->num_users; j++) { 00818 free(ch->users[j]); 00819 } 00820 free(ch->users); 00821 free(ch); 00822 notify_printf(player, "Channel %s destroyed.", channel); 00823 }
Definition at line 1170 of file comsys.c.
References CHANNEL_JOIN, CHANNEL_OBJ_MULT, CHANNEL_PL_MULT, CHANNEL_RECIEVE, CHANNEL_TRANSMIT, channel::charge, channel::charge_who, Comm_All, confdata::have_comsys, lookup_player(), mudconf, NOTHING, notify_printf(), raw_notify(), select_channel(), and channel::type.
01172 { 01173 char *s; 01174 struct channel *ch; 01175 int add_remove = 1; 01176 01177 if(!mudconf.have_comsys) { 01178 raw_notify(player, "Comsys disabled."); 01179 return; 01180 } 01181 if(!(ch = select_channel(arg1))) { 01182 notify_printf(player, "Unknown channel %s.", arg1); 01183 return; 01184 } 01185 if(!((Comm_All(player)) || (player == ch->charge_who))) { 01186 raw_notify(player, "Permission denied."); 01187 return; 01188 } 01189 s = arg2; 01190 if(*s == '!') { 01191 add_remove = 0; 01192 s++; 01193 } 01194 switch (flag) { 01195 case 0: 01196 if(lookup_player(player, arg2, 1) != NOTHING) { 01197 ch->charge_who = lookup_player(player, arg2, 1); 01198 raw_notify(player, "Set."); 01199 return; 01200 } else { 01201 raw_notify(player, "Invalid player."); 01202 return; 01203 } 01204 case 1: 01205 ch->charge = atoi(arg2); 01206 raw_notify(player, "Set."); 01207 return; 01208 case 3: 01209 if(strcasecmp(s, "join") == 0) { 01210 add_remove ? (ch->type |= 01211 (CHANNEL_PL_MULT * CHANNEL_JOIN)) : (ch->type &= 01212 ~ 01213 (CHANNEL_PL_MULT 01214 * 01215 CHANNEL_JOIN)); 01216 raw_notify(player, 01217 (add_remove) ? "@cpflags: Set." : 01218 "@cpflags: Cleared."); 01219 return; 01220 } 01221 if(strcasecmp(s, "receive") == 0) { 01222 add_remove ? (ch->type |= 01223 (CHANNEL_PL_MULT * CHANNEL_RECIEVE)) : (ch->type &= 01224 ~ 01225 (CHANNEL_PL_MULT 01226 * 01227 CHANNEL_RECIEVE)); 01228 raw_notify(player, 01229 (add_remove) ? "@cpflags: Set." : 01230 "@cpflags: Cleared."); 01231 return; 01232 } 01233 if(strcasecmp(s, "transmit") == 0) { 01234 add_remove ? (ch->type |= 01235 (CHANNEL_PL_MULT * CHANNEL_TRANSMIT)) : (ch->type &= 01236 ~ 01237 (CHANNEL_PL_MULT 01238 * 01239 CHANNEL_TRANSMIT)); 01240 raw_notify(player, 01241 (add_remove) ? "@cpflags: Set." : 01242 "@cpflags: Cleared."); 01243 return; 01244 } 01245 raw_notify(player, "@cpflags: Unknown Flag."); 01246 break; 01247 case 4: 01248 if(strcasecmp(s, "join") == 0) { 01249 add_remove ? (ch->type |= 01250 (CHANNEL_OBJ_MULT * CHANNEL_JOIN)) : (ch->type &= 01251 ~ 01252 (CHANNEL_OBJ_MULT 01253 * 01254 CHANNEL_JOIN)); 01255 raw_notify(player, 01256 (add_remove) ? "@coflags: Set." : 01257 "@coflags: Cleared."); 01258 return; 01259 } 01260 if(strcasecmp(s, "receive") == 0) { 01261 add_remove ? (ch->type |= 01262 (CHANNEL_OBJ_MULT * CHANNEL_RECIEVE)) : (ch->type &= 01263 ~ 01264 (CHANNEL_OBJ_MULT 01265 * 01266 CHANNEL_RECIEVE)); 01267 raw_notify(player, 01268 (add_remove) ? "@coflags: Set." : 01269 "@coflags: Cleared."); 01270 return; 01271 } 01272 if(strcasecmp(s, "transmit") == 0) { 01273 add_remove ? (ch->type |= 01274 (CHANNEL_OBJ_MULT * 01275 CHANNEL_TRANSMIT)) : (ch->type &= 01276 ~(CHANNEL_OBJ_MULT * 01277 CHANNEL_TRANSMIT)); 01278 raw_notify(player, 01279 (add_remove) ? "@coflags: Set." : 01280 "@coflags: Cleared."); 01281 return; 01282 } 01283 raw_notify(player, "@coflags: Unknown Flag."); 01284 break; 01285 } 01286 return; 01287 }
Definition at line 397 of file comsys.c.
References A_AENTER, Dark, did_it(), do_comprintf(), channel::max_users, Name(), channel::name, notify_printf(), channel::num_users, comuser::on, comuser::on_next, channel::on_users, select_user(), comuser::title, TYPE_THING, Typeof, UNDEAD, channel::users, and comuser::who.
Referenced by do_addcom(), do_processcom(), load_comsystem(), and mmdb_db_read().
00398 { 00399 struct comuser *user; 00400 int i; 00401 00402 user = select_user(ch, player); 00403 00404 if(!user) { 00405 ch->num_users++; 00406 if(ch->num_users >= ch->max_users) { 00407 ch->max_users += 10; 00408 ch->users = realloc(ch->users, sizeof(struct comuser *) * 00409 ch->max_users); 00410 memset(ch->users+(ch->num_users-1), 0, 00411 sizeof(struct comuser *)*(ch->max_users-ch->num_users)); 00412 } 00413 user = (struct comuser *) malloc(sizeof(struct comuser)); 00414 00415 for(i = ch->num_users - 1; 00416 i > 0 && ch->users[i - 1]->who > player; i--) 00417 ch->users[i] = ch->users[i - 1]; 00418 ch->users[i] = user; 00419 00420 user->who = player; 00421 user->on = 1; 00422 user->title = strdup(""); 00423 00424 if(UNDEAD(player)) { 00425 user->on_next = ch->on_users; 00426 ch->on_users = user; 00427 } 00428 } else if(!user->on) { 00429 user->on = 1; 00430 } else { 00431 notify_printf(player, "You are already on channel %s.", ch->name); 00432 return; 00433 } 00434 #if 0 00435 /* Trigger AENTER of any channel objects on the channel */ 00436 for(i = ch->num_users - 1; i > 0; i--) { 00437 if(!ch->users[i]) break; 00438 if(Typeof(ch->users[i]->who) == TYPE_THING) 00439 did_it(player, ch->users[i]->who, 0, NULL, 0, NULL, A_AENTER, 00440 (char **) NULL, 0); 00441 } 00442 #endif 00443 notify_printf(player, "You have joined channel %s.", ch->name); 00444 00445 if(!Dark(player)) { 00446 do_comprintf(ch, "[%s] %s has joined this channel.", ch->name, Name(player)); 00447 } 00448 }
Definition at line 450 of file comsys.c.
References A_ALEAVE, c, Dark, did_it(), do_comprintf(), Name(), channel::name, notify_printf(), channel::num_users, comuser::on, select_user(), TYPE_THING, Typeof, and channel::users.
Referenced by do_processcom().
00451 { 00452 struct comuser *user; 00453 int i; 00454 00455 user = select_user(ch, player); 00456 00457 if(!user) 00458 return; 00459 00460 /* Trigger ALEAVE of any channel objects on the channel */ 00461 for(i = ch->num_users - 1; i > 0; i--) { 00462 if(Typeof(ch->users[i]->who) == TYPE_THING) 00463 did_it(player, ch->users[i]->who, 0, NULL, 0, NULL, A_ALEAVE, 00464 (char **) NULL, 0); 00465 } 00466 00467 notify_printf(player, "You have left channel %s.", ch->name); 00468 00469 if((user->on) && (!Dark(player))) { 00470 char *c = Name(player); 00471 00472 if(c && *c) { 00473 do_comprintf(ch,"[%s] %s has left this channel.", ch->name, c); 00474 } 00475 } 00476 user->on = 0; 00477 }
void do_listchannels | ( | dbref | player | ) |
Definition at line 825 of file comsys.c.
References channel::amount_col, channel::chan_obj, statedata::channel_htab, CHANNEL_JOIN, CHANNEL_LOUD, CHANNEL_OBJ_MULT, CHANNEL_PL_MULT, CHANNEL_PUBLIC, CHANNEL_RECIEVE, CHANNEL_TRANSMIT, channel::charge, channel::charge_who, Comm_All, hash_firstentry(), hash_nextentry(), mudstate, channel::name, NOTHING, notify_printf(), channel::num_messages, channel::num_users, raw_notify(), and channel::type.
Referenced by do_chanlist().
00826 { 00827 struct channel *ch; 00828 int perm; 00829 00830 if(!(perm = Comm_All(player))) { 00831 raw_notify(player, 00832 "Warning: Only public channels and your channels will be shown."); 00833 } 00834 raw_notify(player, 00835 "** Channel --Flags-- Obj Own Charge Balance Users Messages"); 00836 00837 for(ch = (struct channel *) hash_firstentry(&mudstate.channel_htab); 00838 ch; ch = (struct channel *) hash_nextentry(&mudstate.channel_htab)) 00839 if(perm || (ch->type & CHANNEL_PUBLIC) 00840 || ch->charge_who == player) { 00841 00842 notify_printf(player, 00843 "%c%c %-20.20s %c%c%c/%c%c%c %5d %5d %8d %8d %6d %10d", 00844 (ch->type & (CHANNEL_PUBLIC)) ? 'P' : '-', 00845 (ch->type & (CHANNEL_LOUD)) ? 'L' : '-', ch->name, 00846 (ch->type & (CHANNEL_PL_MULT * 00847 CHANNEL_JOIN)) ? 'J' : '-', 00848 (ch->type & (CHANNEL_PL_MULT * 00849 CHANNEL_TRANSMIT)) ? 'X' : '-', 00850 (ch->type & (CHANNEL_PL_MULT * 00851 CHANNEL_RECIEVE)) ? 'R' : '-', 00852 (ch->type & (CHANNEL_OBJ_MULT * 00853 CHANNEL_JOIN)) ? 'j' : '-', 00854 (ch->type & (CHANNEL_OBJ_MULT * 00855 CHANNEL_TRANSMIT)) ? 'x' : '-', 00856 (ch->type & (CHANNEL_OBJ_MULT * 00857 CHANNEL_RECIEVE)) ? 'r' : '-', 00858 (ch->chan_obj != NOTHING) ? ch->chan_obj : -1, 00859 ch->charge_who, ch->charge, ch->amount_col, 00860 ch->num_users, ch->num_messages); 00861 } 00862 raw_notify(player, "-- End of list of Channels --"); 00863 }
void do_processcom | ( | dbref | player, | |
char * | arg1, | |||
char * | arg2 | |||
) |
Definition at line 274 of file comsys.c.
References confdata::allow_chanlurking, channel::amount_col, CHANNEL_TRANSMIT, channel::charge, channel::charge_who, do_comlast(), do_comprintf(), do_comwho(), do_joinchannel(), do_leavechannel(), do_test_access(), giveto(), Guest, In_IC_Loc(), LBUF_SIZE, confdata::many_coins, mudconf, Name(), notify_printf(), comuser::on, payfor(), raw_notify(), select_channel(), select_user(), comuser::title, and Wizard.
Referenced by do_allcom(), and do_comsystem().
00275 { 00276 struct channel *ch; 00277 struct comuser *user; 00278 00279 if((strlen(arg1) + strlen(arg2)) > LBUF_SIZE / 2) { 00280 arg2[LBUF_SIZE / 2 - strlen(arg1)] = '\0'; 00281 } 00282 if(!*arg2) { 00283 raw_notify(player, "No message."); 00284 return; 00285 } 00286 00287 if(!Wizard(player) && In_IC_Loc(player)) { 00288 raw_notify(player, "Permission denied."); 00289 return; 00290 } 00291 00292 if(!(ch = select_channel(arg1))) { 00293 notify_printf(player, "Unknown channel %s.", arg1); 00294 return; 00295 } 00296 if(!(user = select_user(ch, player))) { 00297 raw_notify(player, 00298 "You are not listed as on that channel. Delete this alias and re-add."); 00299 return; 00300 } 00301 if(!strcasecmp(arg2, "on")) { 00302 do_joinchannel(player, ch); 00303 } else if(!strcasecmp(arg2, "off")) { 00304 do_leavechannel(player, ch); 00305 } else if(!user->on && !Wizard(player) && !mudconf.allow_chanlurking) { 00306 notify_printf(player, "You must be on %s to do that.", arg1); 00307 return; 00308 } else if(!strcasecmp(arg2, "who")) { 00309 do_comwho(player, ch); 00310 } else if(!strcasecmp(arg2, "last")) { 00311 do_comlast(player, ch); 00312 } else if(!user->on) { 00313 notify_printf(player, "You must be on %s to do that.", arg1); 00314 return; 00315 } else if(!do_test_access(player, CHANNEL_TRANSMIT, ch)) { 00316 raw_notify(player, "That channel type cannot be transmitted on."); 00317 return; 00318 } else { 00319 if(!payfor(player, Guest(player) ? 0 : ch->charge)) { 00320 notify_printf(player, "You don't have enough %s.", 00321 mudconf.many_coins); 00322 return; 00323 } else { 00324 ch->amount_col += ch->charge; 00325 giveto(ch->charge_who, ch->charge); 00326 } 00327 00328 if((*arg2) == ':') 00329 do_comprintf(ch, "[%s] %s %s", arg1, Name(player), arg2 + 1); 00330 else if((*arg2) == ';') 00331 do_comprintf(ch, "[%s] %s%s", arg1, Name(player), arg2 + 1); 00332 else if(strlen(user->title)) 00333 do_comprintf(ch, "[%s] %s: <%s> %s", arg1, Name(player), user->title, arg2); 00334 else 00335 do_comprintf(ch, "[%s] %s: %s", arg1, Name(player), arg2); 00336 } 00337 }
static void do_save_com | ( | chmsg * | ) | [static] |
Definition at line 199 of file comsys.c.
References chmsg::msg, temp_file, and chmsg::time.
Referenced by save_comsystem().
Definition at line 657 of file comsys.c.
References free_lbuf, replace_string(), select_user(), and comuser::title.
Referenced by do_addcom(), and do_comtitle().
00658 { 00659 struct comuser *user; 00660 char *new; 00661 00662 user = select_user(ch, player); 00663 00664 /* Make sure there can be no embedded newlines from %r */ 00665 00666 if(!ch || !user) 00667 return; 00668 00669 new = replace_string("\r\n", "", title); 00670 if(user->title) 00671 free(user->title); 00672 user->title = strdup(new); /* strdup so we can free() safely */ 00673 free_lbuf(new); 00674 }
static void do_show_com | ( | chmsg * | ) | [static] |
Definition at line 246 of file comsys.c.
References cheat_player, LBUF_SIZE, chmsg::msg, mudstate, notify, statedata::now, and chmsg::time.
Referenced by do_comlast().
00247 { 00248 struct tm *t; 00249 int day; 00250 char buf[LBUF_SIZE]; 00251 00252 t = localtime(&mudstate.now); 00253 day = t->tm_mday; 00254 t = localtime(&d->time); 00255 if(day == t->tm_mday) { 00256 sprintf(buf, "[%02d:%02d] %s", t->tm_hour, t->tm_min, d->msg); 00257 } else 00258 sprintf(buf, "[%02d.%02d / %02d:%02d] %s", t->tm_mon + 1, 00259 t->tm_mday, t->tm_hour, t->tm_min, d->msg); 00260 notify(cheat_player, buf); 00261 }
Definition at line 1289 of file comsys.c.
References A_LENTER, A_LOCK, A_LUSE, channel::chan_obj, CHANNEL_JOIN, CHANNEL_OBJ_MULT, CHANNEL_PL_MULT, CHANNEL_RECIEVE, CHANNEL_TRANSMIT, Comm_All, could_doit(), NOTHING, channel::type, TYPE_PLAYER, and Typeof.
Referenced by do_addcom(), do_chanlist(), do_comprintf(), do_comsend(), and do_processcom().
01290 { 01291 long flag_value = access; 01292 01293 if(Comm_All(player)) 01294 return (1); 01295 01296 /* 01297 * Channel objects allow custom locks for channels. The normal 01298 * lock is used to see if they can join that channel. The 01299 * enterlock is checked to see if they can receive messages on 01300 * it. The Uselock is checked to see if they can transmit on 01301 * it. Note: These checks do not supercede the normal channel 01302 * flags. If a channel is set JOIN for players, ALL players can 01303 * join the channel, whether or not they pass the lock. Same for 01304 * all channel object locks. 01305 */ 01306 01307 if((flag_value & CHANNEL_JOIN) && !((chan->chan_obj == NOTHING) || 01308 (chan->chan_obj == 0))) { 01309 if(could_doit(player, chan->chan_obj, A_LOCK)) 01310 return (1); 01311 } 01312 if((flag_value & CHANNEL_TRANSMIT) && !((chan->chan_obj == NOTHING) || 01313 (chan->chan_obj == 0))) { 01314 if(could_doit(player, chan->chan_obj, A_LUSE)) 01315 return (1); 01316 } 01317 if((flag_value & CHANNEL_RECIEVE) && !((chan->chan_obj == NOTHING) || 01318 (chan->chan_obj == 0))) { 01319 if(could_doit(player, chan->chan_obj, A_LENTER)) 01320 return (1); 01321 } 01322 if(Typeof(player) == TYPE_PLAYER) 01323 flag_value *= CHANNEL_PL_MULT; 01324 else 01325 flag_value *= CHANNEL_OBJ_MULT; 01326 flag_value &= 0xFF; /* 01327 * Mask out CHANNEL_PUBLIC and CHANNEL_LOUD 01328 * just to be paranoid. 01329 */ 01330 01331 return (((long) chan->type & flag_value)); 01332 }
void fun_cemit | ( | char * | buff, | |
char ** | bufc, | |||
dbref | player, | |||
dbref | cause, | |||
char * | fargs[], | |||
char * | nfargs[], | |||
int | cargs, | |||
int | ncargs | |||
) |
Definition at line 1745 of file comsys.c.
References channel::charge_who, Comm_All, do_comprintf(), confdata::have_comsys, LBUF_SIZE, mudconf, safe_str, and select_channel().
01747 { 01748 struct channel *ch; 01749 static char smbuf[LBUF_SIZE]; 01750 01751 if(!(ch = select_channel(fargs[0]))) { 01752 safe_str("#-1 CHANNEL NOT FOUND", buff, bufc); 01753 return; 01754 } 01755 01756 if(!mudconf.have_comsys 01757 || (!Comm_All(player) && (player != ch->charge_who))) { 01758 safe_str("#-1 NO PERMISSION TO USE", buff, bufc); 01759 return; 01760 } 01761 01762 do_comprintf(ch, "[%s] %s", fargs[0], fargs[1]); 01763 *buff = '\0'; 01764 }
char* get_channel_from_alias | ( | dbref | player, | |
char * | alias | |||
) |
Definition at line 66 of file comsys.c.
References c, dir, and get_commac().
Referenced by do_comsystem(), and do_comtitle().
00067 { 00068 struct commac *c; 00069 int first, last, current = 0; 00070 int dir; 00071 00072 c = get_commac(player); 00073 00074 first = 0; 00075 last = c->numchannels - 1; 00076 dir = 1; 00077 00078 while (dir && (first <= last)) { 00079 current = (first + last) / 2; 00080 dir = strcasecmp(alias, c->alias + 6 * current); 00081 if(dir < 0) 00082 last = current - 1; 00083 else 00084 first = current + 1; 00085 } 00086 00087 if(!dir) 00088 return c->channels[current]; 00089 else 00090 return ""; 00091 }
void init_chantab | ( | void | ) |
Definition at line 41 of file comsys.c.
References statedata::channel_htab, HASH_FACTOR, hashinit(), and mudstate.
Referenced by main().
00042 { 00043 hashinit(&mudstate.channel_htab, 30 * HASH_FACTOR); 00044 }
void load_comsystem | ( | FILE * | fp | ) |
Definition at line 93 of file comsys.c.
References c, CHAN_NAME_LEN, statedata::channel_htab, Create, do_joinchannel(), God, Going, hashadd(), isPlayer, LBUF_SIZE, mudstate, myfifo_push(), channel::name, num_channels, comuser::on, comuser::on_next, channel::on_users, Owner, sort_users(), comuser::title, and comuser::who.
00094 { 00095 int i, j, k, dummy; 00096 int nc, new = 0; 00097 struct channel *ch; 00098 struct comuser *user; 00099 char temp[LBUF_SIZE]; 00100 char buf[8]; 00101 00102 num_channels = 0; 00103 00104 fgets(buf, sizeof(buf), fp); 00105 if(!strncmp(buf, "+V2", 3)) { 00106 new = 2; 00107 fscanf(fp, "%d\n", &nc); 00108 } else if(!strncmp(buf, "+V1", 3)) { 00109 new = 1; 00110 fscanf(fp, "%d\n", &nc); 00111 } else 00112 nc = atoi(buf); 00113 00114 num_channels = nc; 00115 00116 for(i = 0; i < nc; i++) { 00117 ch = (struct channel *) malloc(sizeof(struct channel)); 00118 00119 fscanf(fp, "%[^\n]\n", temp); 00120 00121 strncpy(ch->name, temp, CHAN_NAME_LEN); 00122 ch->name[CHAN_NAME_LEN - 1] = '\0'; 00123 ch->on_users = NULL; 00124 00125 hashadd(ch->name, (int *) ch, &mudstate.channel_htab); 00126 00127 ch->last_messages = NULL; 00128 00129 if(new) { /* V1 or higher */ 00130 00131 if(fscanf(fp, 00132 new == 00133 1 ? "%d %d %d %d %d %d %d %d\n" : 00134 "%d %d %d %d %d %d %d %d %d\n", &(ch->type), 00135 &(ch->temp1), &(ch->temp2), &(ch->charge), 00136 &(ch->charge_who), &(ch->amount_col), 00137 &(ch->num_messages), &(ch->chan_obj), &dummy) >= 9 && 00138 new > 1) { 00139 /* Do things with 'dummy' */ 00140 if(dummy > 0) { 00141 for(j = 0; j < dummy; j++) { 00142 chmsg *c; 00143 00144 fscanf(fp, "%d %[^\n]\n", &k, temp); 00145 Create(c, chmsg, 1); 00146 c->msg = strdup(temp); 00147 c->time = k; 00148 myfifo_push(&ch->last_messages, c); 00149 } 00150 } 00151 } 00152 } else { 00153 fscanf(fp, "%d %d %d %d %d %d %d %d %d %d\n", &(ch->type), 00154 &(dummy), &(ch->temp1), &(ch->temp2), &(dummy), 00155 &(ch->charge), &(ch->charge_who), &(ch->amount_col), 00156 &(ch->num_messages), &(ch->chan_obj)); 00157 } 00158 00159 fscanf(fp, "%d\n", &(ch->num_users)); 00160 ch->max_users = ch->num_users; 00161 if(ch->num_users > 0) { 00162 ch->users = (struct comuser **) 00163 calloc(ch->max_users, sizeof(struct comuser *)); 00164 00165 for(j = 0; j < ch->num_users; j++) { 00166 user = (struct comuser *) malloc(sizeof(struct comuser)); 00167 00168 ch->users[j] = user; 00169 00170 if(new) { 00171 fscanf(fp, "%d %d\n", &(user->who), &(user->on)); 00172 } else { 00173 fscanf(fp, "%d %d %d", &(user->who), &(dummy), &(dummy)); 00174 fscanf(fp, "%d\n", &(user->on)); 00175 } 00176 00177 fscanf(fp, "%[^\n]\n", temp); 00178 00179 user->title = strdup(temp + 2); 00180 00181 if(!(isPlayer(user->who)) && !(Going(user->who) && 00182 (God(Owner(user->who))))) { 00183 do_joinchannel(user->who, ch); 00184 user->on_next = ch->on_users; 00185 ch->on_users = user; 00186 } else { 00187 user->on_next = ch->on_users; 00188 ch->on_users = user; 00189 } 00190 } 00191 sort_users(ch); 00192 } else 00193 ch->users = NULL; 00194 } 00195 }
void save_comsystem | ( | FILE * | fp | ) |
Definition at line 204 of file comsys.c.
References channel::amount_col, channel::chan_obj, statedata::channel_htab, channel::charge, channel::charge_who, do_save_com(), hash_firstentry(), hash_nextentry(), isPlayer, isRobot, mudstate, myfifo_length(), myfifo_trav_r(), channel::name, num_channels, channel::num_messages, channel::num_users, comuser::on, channel::temp1, channel::temp2, temp_file, comuser::title, channel::type, channel::users, and comuser::who.
00205 { 00206 struct channel *ch; 00207 struct comuser *user; 00208 int j, k, player_users; 00209 00210 fprintf(fp, "+V2\n"); 00211 fprintf(fp, "%d\n", num_channels); 00212 for(ch = (struct channel *) hash_firstentry(&mudstate.channel_htab); 00213 ch; ch = (struct channel *) hash_nextentry(&mudstate.channel_htab)) { 00214 fprintf(fp, "%s\n", ch->name); 00215 k = myfifo_length(&ch->last_messages); 00216 /* 1 2 3 4 5 6 7 8 9 */ 00217 fprintf(fp, "%d %d %d %d %d %d %d %d %d\n", ch->type, ch->temp1, 00218 ch->temp2, ch->charge, ch->charge_who, ch->amount_col, 00219 ch->num_messages, ch->chan_obj, k); 00220 00221 if(k) { 00222 temp_file = fp; 00223 myfifo_trav_r(&ch->last_messages, do_save_com); 00224 } 00225 player_users = 0; 00226 for(j = 0; j < ch->num_users; j++) 00227 if(isPlayer(ch->users[j]->who) || isRobot(ch->users[j]->who)) 00228 player_users++; 00229 00230 fprintf(fp, "%d\n", player_users); 00231 for(j = 0; j < ch->num_users; j++) { 00232 user = ch->users[j]; 00233 if(!isPlayer(user->who) && !isRobot(user->who)) 00234 continue; 00235 fprintf(fp, "%d %d\n", user->who, user->on); 00236 if(strlen(user->title)) 00237 fprintf(fp, "t:%s\n", user->title); 00238 else 00239 fprintf(fp, "t:\n"); 00240 } 00241 } 00242 }
struct channel* select_channel | ( | char * | channel | ) |
Definition at line 519 of file comsys.c.
References statedata::channel_htab, hashfind(), and mudstate.
Referenced by do_addcom(), do_cemit(), do_channelwho(), do_chanobj(), do_chanstatus(), do_chboot(), do_chclose(), do_chloud(), do_chopaque(), do_chopen(), do_chsquelch(), do_chtransparent(), do_comconnectchannel(), do_comconnectraw_notify(), do_comdisconnectchannel(), do_comdisconnectraw_notify(), do_comlist(), do_comtitle(), do_createchannel(), do_delcomchannel(), do_editchannel(), do_processcom(), fun_cemit(), fun_clist(), fun_cobj(), fun_cwho(), and send_channel().
00520 { 00521 return (struct channel *) hashfind(channel, &mudstate.channel_htab); 00522 }
Definition at line 524 of file comsys.c.
References dir, channel::num_users, and channel::users.
Referenced by do_addcom(), do_chboot(), do_comconnectchannel(), do_comconnectraw_notify(), do_comdisconnectraw_notify(), do_comlist(), do_comtitle(), do_joinchannel(), do_leavechannel(), do_processcom(), and do_setnewtitle().
00525 { 00526 int last, current; 00527 int dir = 1, first = 0; 00528 00529 if(!ch) 00530 return NULL; 00531 00532 last = ch->num_users - 1; 00533 current = (first + last) / 2; 00534 00535 while (dir && (first <= last)) { 00536 current = (first + last) / 2; 00537 if(ch->users[current] == NULL) { 00538 last--; 00539 continue; 00540 } 00541 if(ch->users[current]->who == player) 00542 dir = 0; 00543 else if(ch->users[current]->who < player) { 00544 dir = 1; 00545 first = current + 1; 00546 } else { 00547 dir = -1; 00548 last = current - 1; 00549 } 00550 } 00551 00552 if(!dir) 00553 return ch->users[current]; 00554 else 00555 return NULL; 00556 }
void send_channel | ( | char * | chan, | |
const char * | format, | |||
... | ||||
) |
Definition at line 46 of file comsys.c.
References do_comsend(), LBUF_SIZE, and select_channel().
Referenced by announce_connect(), announce_disconnect(), do_comconnect(), do_comdisconnect(), do_fixdb(), do_kill(), do_name(), mech_sendchannel(), and process_command().
00047 { 00048 struct channel *ch; 00049 char buf[LBUF_SIZE]; 00050 char data[LBUF_SIZE]; 00051 char *newline; 00052 va_list ap; 00053 00054 if(!(ch = select_channel(chan))) 00055 return; 00056 va_start(ap, format); 00057 vsnprintf(data, LBUF_SIZE, format, ap); 00058 va_end(ap); 00059 00060 snprintf(buf, LBUF_SIZE-1, "[%s] %s", chan, data); 00061 while ((newline = strchr(buf, '\n'))) 00062 *newline = ' '; 00063 do_comsend(ch, buf); 00064 }
void sort_users | ( | struct channel * | ) |
Definition at line 983 of file comsys.c.
References channel::num_users, and channel::users.
Referenced by load_comsystem(), and mmdb_db_read().
00984 { 00985 int i; 00986 int nu; 00987 int done; 00988 struct comuser *user; 00989 00990 nu = ch->num_users; 00991 done = 0; 00992 while (!done) { 00993 done = 1; 00994 for(i = 0; i < (nu - 1); i++) { 00995 if(ch->users[i]->who > ch->users[i + 1]->who) { 00996 user = ch->users[i]; 00997 ch->users[i] = ch->users[i + 1]; 00998 ch->users[i + 1] = user; 00999 done = 0; 01000 } 01001 } 01002 } 01003 }
dbref cheat_player [static] |
FILE* temp_file [static] |