src/p.comsys.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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)
channelselect_channel (char *channel)
comuserselect_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_chanstatus (dbref player, dbref cause, int key, char *chan)
void do_chanlist (dbref player, dbref cause, int key)


Function Documentation

void do_addcom ( dbref  player,
dbref  cause,
int  key,
char *  arg1,
char *  arg2 
)

Definition at line 235 of file comstar.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.

00235                                                                            {
00236     struct channel *channel = NULL;
00237     if(!mudconf.have_comsys) {
00238         raw_notify(player, "Comsys disabled.");
00239         return;
00240     }
00241 
00242     if(!arg1 || !*arg1) {
00243         raw_notify(player, "You need to specify an alias.");
00244         return;
00245     }
00246 
00247     if(!arg2 || !*arg2) {
00248         raw_notify(player, "You need to specify a channel.");
00249         return;
00250     }
00251     
00252     channel = comstar_find_channel_by_name(arg2);
00253     if(!channel) {
00254         raw_notify(player, "Sorry, Channel does not exist.");
00255         return;
00256     }
00257 
00258     if(!comstar_add_user_to_channel(arg2, arg1, player)) {
00259         raw_notify(player, "Operation failed due to invalid argument.");
00260         return;
00261     }
00262     raw_notify(player, "Operation succeeded.");
00263     return;
00264 }

void do_allcom ( dbref  player,
dbref  cause,
int  key,
char *  arg1 
)

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 }

void do_cemit ( dbref  player,
dbref  cause,
int  key,
char *  chan,
char *  text 
)

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 }

void do_chanlist ( dbref  player,
dbref  cause,
int  key 
)

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, Name(), channel::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 }

void do_channelwho ( dbref  player,
dbref  cause,
int  key,
char *  arg1 
)

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 }

void do_chanstatus ( dbref  player,
dbref  cause,
int  key,
char *  chan 
)

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, Name(), channel::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 }

void do_chboot ( dbref  player,
dbref  cause,
int  key,
char *  channel,
char *  victim 
)

Definition at line 1526 of file comsys.c.

References channel::charge_who, Comm_All, do_comprintf(), do_delcomchannel(), confdata::have_comsys, match_thing(), mudconf, channel::name, 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 }

void do_chopen ( dbref  player,
dbref  cause,
int  key,
char *  chan,
char *  object 
)

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 }

void do_clearcom ( dbref  player,
dbref  cause,
int  key 
)

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 }

void do_comconnect ( dbref  player,
DESC d 
)

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(), Name(), channel::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(), Name(), channel::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 }

void do_comlist ( dbref  player,
dbref  cause,
int  key 
)

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 }

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 }

void do_comtitle ( dbref  player,
dbref  cause,
int  key,
char *  arg1,
char *  arg2 
)

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 }

void do_createchannel ( dbref  player,
dbref  cause,
int  key,
char *  channel 
)

Definition at line 168 of file comstar.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.

00168                                                                           {
00169     struct channel *newchannel = NULL;
00170 
00171     if(!mudconf.have_comsys) {
00172         raw_notify(player, "Comsys disabled.");
00173         return;
00174     }
00175     if(comstar_find_channel_by_name(channame)) {
00176         notify_printf(player, "Channel %s already exists.", channame);
00177         return;
00178     }
00179     if(!channame || !*channame) {
00180         raw_notify(player, "You must specify a channel to create.");
00181         return;
00182     }
00183     if(!(Comm_All(player))) {
00184         raw_notify(player, "You do not have permission to do that.");
00185         return;
00186     }
00187     if(strlen(channame) > (CHAN_NAME_LEN-1)) {
00188         raw_notify(player, "Name too long.");
00189         return;
00190     }
00191     newchannel = (struct channel *) malloc(sizeof(struct channel));
00192     memset(newchannel, 0, sizeof(struct channel));
00193 
00194     strncpy(newchannel->name, channame, CHAN_NAME_LEN - 1);
00195 
00196     newchannel->type = 127;
00197     newchannel->owner = player;
00198     newchannel->channel_object = NOTHING;
00199     newchannel->users = rb_init(comstar_compare_channel_user, NULL);
00200     notify_printf(player, "Channel %s created.", channame);
00201 }

void do_delcom ( dbref  player,
dbref  cause,
int  key,
char *  arg1 
)

Definition at line 266 of file comstar.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().

00266                                                                {
00267     struct channel *channel = NULL;
00268 
00269     if(!mudconf.have_comsys) {
00270         raw_notify(player, "Comsys disabled.");
00271         return;
00272     }
00273     if(!arg1 || !*arg1) {
00274         raw_notify(player, "Need an alias to delete.");
00275         return;
00276     }
00277 
00278     channel = comstar_find_channel_by_user_alias(player, arg1);
00279     if(!channel) {
00280         raw_notify(player, "Channel alias does not exist.");
00281         return;
00282     }
00283 
00284     if(!comstar_remove_user_from_channel(channel->name, player)) {
00285         raw_notify(player, "Operation failed due to invalid argument.");
00286         return;
00287     }
00288 
00289     raw_notify(player, "Operation succeeded.");
00290     return;
00291 }

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 }

void do_destroychannel ( dbref  player,
dbref  cause,
int  key,
char *  channel 
)

Definition at line 203 of file comstar.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.

00203                                                                            {
00204     struct channel *channel = NULL;
00205 
00206     if(!mudconf.have_comsys) {
00207         raw_notify(player, "Comsys disabled.");
00208         return;
00209     }
00210     if(!channame || !*channame) {
00211         raw_notify(player, "No argument supplied.");
00212         return;
00213     }
00214     channel = comstar_find_channel_by_name(channame);
00215 
00216     if(!channel) {
00217         notify_printf(player, "Could not find channel %s.", channel);
00218         return;
00219     } else if(!(Comm_All(player)) && (player != channel->owner)) {
00220         raw_notify(player, "You do not have permission to do that. ");
00221         return;
00222     }
00223     while(rb_size(channel->users) > 1) {
00224         struct channel_user *channel_user = NULL;
00225         channel_user = rb_search(channel->users, SEARCH_FIRST, NULL);
00226         if(!channel_user) break;
00227         if(!comstar_remove_user_from_channel(channel->name, channel_user->player))
00228             break;
00229     }
00230     rb_delete(channels, channame);
00231     memset(channel, 0, sizeof(struct channel));
00232     free(channel);
00233 }

void do_editchannel ( dbref  player,
dbref  cause,
int  flag,
char *  arg1,
char *  arg2 
)

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 }

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 }

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 }

struct comuser* select_user ( struct channel ch,
dbref  player 
)

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 }


Generated on Mon May 28 04:25:47 2007 for BattletechMUX by  doxygen 1.4.7