mux/src/comsys.h File Reference

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

Go to the source code of this file.

Data Structures

struct  chanentry
struct  comuser
struct  channel
struct  tagComsys

Defines

#define NUM_COMSYS   500
#define MAX_CHANNEL_LEN   50
#define MAX_HEADER_LEN   100
#define MAX_TITLE_LEN   200
#define MAX_ALIAS_LEN   5
#define ALIAS_SIZE   (MAX_ALIAS_LEN+1)
#define CHANNEL_PLAYER_JOIN   (0x00000001UL)
#define CHANNEL_PLAYER_TRANSMIT   (0x00000002UL)
#define CHANNEL_PLAYER_RECEIVE   (0x00000004UL)
#define CHANNEL_OBJECT_JOIN   (0x00000010UL)
#define CHANNEL_OBJECT_TRANSMIT   (0x00000020UL)
#define CHANNEL_OBJECT_RECEIVE   (0x00000040UL)
#define CHANNEL_LOUD   (0x00000100UL)
#define CHANNEL_PUBLIC   (0x00000200UL)
#define CHANNEL_SPOOF   (0x00000400UL)
#define UNDEAD(x)   (Good_obj(x) && ((Typeof(x) != TYPE_PLAYER) || Connected(x)))

Typedefs

typedef chanentry CHANENT
typedef tagComsys comsys_t

Functions

void save_comsys (char *filename)
void load_comsys (char *filename)
void del_comsys (dbref who)
void add_comsys (comsys_t *c)
bool test_join_access (dbref player, struct channel *chan)
bool test_transmit_access (dbref player, struct channel *chan)
bool test_receive_access (dbref player, struct channel *chan)
void do_joinchannel (dbref player, struct channel *ch)
void do_comdisconnectchannel (dbref player, char *channel)
void load_channels (FILE *fp)
void purge_comsystem (void)
void save_channels (FILE *fp)
void destroy_comsys (comsys_t *c)
void sort_com_aliases (comsys_t *c)
void load_comsystem (FILE *fp)
void save_comsystem (FILE *fp)
void SendChannelMessage (dbref player, struct channel *ch, char *msgNormal, char *msgNoComtitle)
void do_comwho (dbref player, struct channel *ch)
void do_comlast (dbref player, struct channel *ch, int arg)
void do_leavechannel (dbref player, struct channel *ch)
void do_delcomchannel (dbref player, char *channel, bool bQuiet)
void do_channelnuke (dbref player)
void sort_users (struct channel *ch)
void do_comdisconnect (dbref player)
void do_comconnect (dbref player)
void do_clearcom (dbref executor, dbref caller, dbref enactor, int unused2)
void do_cheader (dbref player, char *channel, char *header)
void do_addcom (dbref executor, dbref caller, dbref enactor, int key, int nargs, char *arg1, char *arg2)
comsys_tcreate_new_comsys ()
channelselect_channel (char *channel)
comuserselect_user (struct channel *ch, dbref player)
char * get_channel_from_alias ()
bool do_comsystem (dbref who, char *cmd)
void do_chanlist (dbref executor, dbref caller, dbref enactor, int key, char *pattern)


Define Documentation

#define ALIAS_SIZE   (MAX_ALIAS_LEN+1)

Definition at line 22 of file comsys.h.

Referenced by do_addcom(), do_clearcom(), do_comconnectchannel(), do_comlist(), do_delcom(), FUNCTION(), get_channel_from_alias(), load_channels(), MakeCanonicalComAlias(), save_channels(), and sort_com_aliases().

#define CHANNEL_LOUD   (0x00000100UL)

Definition at line 126 of file comsys.h.

Referenced by do_chanlist(), do_chopen(), do_comconnectraw_notify(), do_comdisconnectraw_notify(), and do_listchannels().

#define CHANNEL_OBJECT_JOIN   (0x00000010UL)

Definition at line 123 of file comsys.h.

Referenced by do_editchannel(), do_listchannels(), and test_join_access().

#define CHANNEL_OBJECT_RECEIVE   (0x00000040UL)

Definition at line 125 of file comsys.h.

Referenced by do_editchannel(), do_listchannels(), and test_receive_access().

#define CHANNEL_OBJECT_TRANSMIT   (0x00000020UL)

Definition at line 124 of file comsys.h.

Referenced by do_editchannel(), do_listchannels(), and test_transmit_access().

#define CHANNEL_PLAYER_JOIN   (0x00000001UL)

Definition at line 120 of file comsys.h.

Referenced by do_editchannel(), do_listchannels(), and test_join_access().

#define CHANNEL_PLAYER_RECEIVE   (0x00000004UL)

Definition at line 122 of file comsys.h.

Referenced by do_editchannel(), do_listchannels(), and test_receive_access().

#define CHANNEL_PLAYER_TRANSMIT   (0x00000002UL)

Definition at line 121 of file comsys.h.

Referenced by do_editchannel(), do_listchannels(), and test_transmit_access().

#define CHANNEL_PUBLIC   (0x00000200UL)

Definition at line 127 of file comsys.h.

Referenced by do_chanlist(), do_chopen(), do_listchannels(), FUNCTION(), and load_comsystem().

#define CHANNEL_SPOOF   (0x00000400UL)

Definition at line 128 of file comsys.h.

Referenced by do_chanlist(), do_chboot(), do_chopen(), do_comconnectraw_notify(), do_comdisconnectraw_notify(), do_comtitle(), do_comwho_line(), do_delcomchannel(), do_joinchannel(), do_leavechannel(), do_listchannels(), do_processcom(), and SendChannelMessage().

#define MAX_ALIAS_LEN   5

Definition at line 21 of file comsys.h.

Referenced by MakeCanonicalComAlias().

#define MAX_CHANNEL_LEN   50

Definition at line 18 of file comsys.h.

Referenced by do_addcom(), do_channelwho(), do_comtitle(), do_createchannel(), and load_comsystem().

#define MAX_HEADER_LEN   100

Definition at line 19 of file comsys.h.

Referenced by do_cheader(), do_createchannel(), and load_comsystem().

#define MAX_TITLE_LEN   200

Definition at line 20 of file comsys.h.

Referenced by load_comsystem(), and RestrictTitleValue().

#define NUM_COMSYS   500

Definition at line 16 of file comsys.h.

Referenced by add_comsys(), del_comsys(), get_comsys(), load_comsys(), purge_comsystem(), and save_channels().

#define UNDEAD (  )     (Good_obj(x) && ((Typeof(x) != TYPE_PLAYER) || Connected(x)))

Definition at line 132 of file comsys.h.

Referenced by do_channelwho(), and do_joinchannel().


Typedef Documentation

typedef struct chanentry CHANENT

Definition at line 9 of file comsys.h.

typedef struct tagComsys comsys_t


Function Documentation

void add_comsys ( comsys_t c  ) 

Definition at line 398 of file comsys.cpp.

References comsys_table, statedata::db_top, ENDLINE, Log, mudstate, tagComsys::next, NUM_COMSYS, CLogFile::tinyprintf(), and tagComsys::who.

Referenced by get_comsys(), and load_channels().

00399 {
00400     if (c->who < 0 || c->who >= mudstate.db_top)
00401     {
00402         Log.tinyprintf("add_comsys: dbref %d out of range [0, %d)" ENDLINE, c->who, mudstate.db_top);
00403         return;
00404     }
00405 
00406     c->next = comsys_table[c->who % NUM_COMSYS];
00407     comsys_table[c->who % NUM_COMSYS] = c;
00408 }

comsys_t* create_new_comsys (  ) 

Definition at line 363 of file comsys.cpp.

References tagComsys::alias, tagComsys::channels, ISOUTOFMEMORY, tagComsys::maxchannels, MEMALLOC, tagComsys::next, NOTHING, tagComsys::numchannels, and tagComsys::who.

Referenced by get_comsys(), and load_channels().

00364 {
00365     comsys_t *c = (comsys_t *)MEMALLOC(sizeof(comsys_t));
00366     ISOUTOFMEMORY(c);
00367 
00368     c->who         = NOTHING;
00369     c->numchannels = 0;
00370     c->maxchannels = 0;
00371     c->alias       = NULL;
00372     c->channels    = NULL;
00373     c->next        = NULL;
00374     return c;
00375 }

void del_comsys ( dbref  who  ) 

Definition at line 410 of file comsys.cpp.

References comsys_table, statedata::db_top, destroy_comsys(), ENDLINE, Log, mudstate, tagComsys::next, NUM_COMSYS, CLogFile::tinyprintf(), and tagComsys::who.

Referenced by purge_comsystem(), and ReleaseAllResources().

00411 {
00412     if (who < 0 || who >= mudstate.db_top)
00413     {
00414         Log.tinyprintf("del_comsys: dbref %d out of range [0, %d)" ENDLINE, who, mudstate.db_top);
00415         return;
00416     }
00417 
00418     comsys_t *c = comsys_table[who % NUM_COMSYS];
00419 
00420     if (c == NULL)
00421     {
00422         return;
00423     }
00424 
00425     if (c->who == who)
00426     {
00427         comsys_table[who % NUM_COMSYS] = c->next;
00428         destroy_comsys(c);
00429         return;
00430     }
00431     comsys_t *last = c;
00432     c = c->next;
00433     while (c)
00434     {
00435         if (c->who == who)
00436         {
00437             last->next = c->next;
00438             destroy_comsys(c);
00439             return;
00440         }
00441         last = c;
00442         c = c->next;
00443     }
00444 }

void destroy_comsys ( comsys_t c  ) 

Definition at line 446 of file comsys.cpp.

References tagComsys::alias, tagComsys::channels, MEMFREE, and tagComsys::numchannels.

Referenced by del_comsys().

00447 {
00448     int i;
00449 
00450     if (c->alias)
00451     {
00452         MEMFREE(c->alias);
00453         c->alias = NULL;
00454     }
00455     for (i = 0; i < c->numchannels; i++)
00456     {
00457         MEMFREE(c->channels[i]);
00458         c->channels[i] = NULL;
00459     }
00460     if (c->channels)
00461     {
00462         MEMFREE(c->channels);
00463         c->channels = NULL;
00464     }
00465     MEMFREE(c);
00466     c = NULL;
00467 }

void do_addcom ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
int  nargs,
char *  arg1,
char *  arg2 
)

Definition at line 1463 of file comsys.cpp.

References tagComsys::alias, ALIAS_SIZE, ANSI_ENDGOAL_NORMAL, ANSI_TruncateToField(), tagComsys::channels, get_comsys(), confdata::have_comsys, ISOUTOFMEMORY, MakeCanonicalComAlias(), MAX_ALIASES_PER_PLAYER, MAX_CHANNEL_LEN, tagComsys::maxchannels, MEMALLOC, MEMFREE, mudconf, tagComsys::numchannels, raw_notify(), select_channel(), test_join_access(), tprintf(), and UNUSED_PARAMETER.

Referenced by CGuests::AddToGuestChannel(), and AddToPublicChannel().

01472 {
01473     UNUSED_PARAMETER(caller);
01474     UNUSED_PARAMETER(enactor);
01475     UNUSED_PARAMETER(key);
01476     UNUSED_PARAMETER(nargs);
01477 
01478     if (!mudconf.have_comsys)
01479     {
01480         raw_notify(executor, "Comsys disabled.");
01481         return;
01482     }
01483     bool bValidAlias;
01484     int  nValidAlias;
01485     char *pValidAlias = MakeCanonicalComAlias(arg1, &nValidAlias, &bValidAlias);
01486     if (!bValidAlias)
01487     {
01488         raw_notify(executor, "You need to specify a valid alias.");
01489         return;
01490     }
01491     char *s = arg2;
01492     if (!*s)
01493     {
01494         raw_notify(executor, "You need to specify a channel.");
01495         return;
01496     }
01497     char channel[MAX_CHANNEL_LEN+1];
01498     char *t = channel;
01499     while (*s && ((t - channel) < MAX_CHANNEL_LEN))
01500     {
01501         if (*s != ' ')
01502             *t++ = *s++;
01503         else
01504             s++;
01505     }
01506     *t = '\0';
01507 
01508     int i, j, where;
01509     char *na;
01510     char **nc;
01511     struct channel *ch = select_channel(channel);
01512     char Buffer[MAX_CHANNEL_LEN+1];
01513     if (!ch)
01514     {
01515         int nVisualWidth;
01516         ANSI_TruncateToField(channel, sizeof(Buffer), Buffer, sizeof(Buffer), &nVisualWidth, ANSI_ENDGOAL_NORMAL);
01517         raw_notify(executor, tprintf("Channel %s does not exist yet.", Buffer));
01518         return;
01519     }
01520     if (!test_join_access(executor, ch))
01521     {
01522         raw_notify(executor, "Sorry, this channel type does not allow you to join.");
01523         return;
01524     }
01525     comsys_t *c = get_comsys(executor);
01526     if (c->numchannels >= MAX_ALIASES_PER_PLAYER)
01527     {
01528         raw_notify(executor, tprintf("Sorry, but you have reached the maximum number of aliases allowed."));
01529         return;
01530     }
01531     for (j = 0; j < c->numchannels && (strcmp(pValidAlias, c->alias + j * ALIAS_SIZE) > 0); j++)
01532     {
01533         ; // Nothing.
01534     }
01535     if (j < c->numchannels && !strcmp(pValidAlias, c->alias + j * ALIAS_SIZE))
01536     {
01537         char *p = tprintf("That alias is already in use for channel %s.", c->channels[j]);
01538         raw_notify(executor, p);
01539         return;
01540     }
01541     if (c->numchannels >= c->maxchannels)
01542     {
01543         c->maxchannels += 10;
01544 
01545         na = (char *)MEMALLOC(ALIAS_SIZE * c->maxchannels);
01546         ISOUTOFMEMORY(na);
01547         nc = (char **)MEMALLOC(sizeof(char *) * c->maxchannels);
01548         ISOUTOFMEMORY(nc);
01549 
01550         for (i = 0; i < c->numchannels; i++)
01551         {
01552             strcpy(na + i * ALIAS_SIZE, c->alias + i * ALIAS_SIZE);
01553             nc[i] = c->channels[i];
01554         }
01555         if (c->alias)
01556         {
01557             MEMFREE(c->alias);
01558             c->alias = NULL;
01559         }
01560         if (c->channels)
01561         {
01562             MEMFREE(c->channels);
01563             c->channels = NULL;
01564         }
01565         c->alias = na;
01566         c->channels = nc;
01567     }
01568     where = c->numchannels++;
01569     for (i = where; i > j; i--)
01570     {
01571         strcpy(c->alias + i * ALIAS_SIZE, c->alias + (i - 1) * ALIAS_SIZE);
01572         c->channels[i] = c->channels[i - 1];
01573     }
01574 
01575     where = j;
01576     memcpy(c->alias + where * ALIAS_SIZE, pValidAlias, nValidAlias);
01577     *(c->alias + where * ALIAS_SIZE + nValidAlias) = '\0';
01578     c->channels[where] = StringClone(channel);
01579 
01580     if (!select_user(ch, executor))
01581     {
01582         do_joinchannel(executor, ch);
01583     }
01584 
01585     raw_notify(executor, tprintf("Channel %s added with alias %s.", channel, pValidAlias));
01586 }

void do_chanlist ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
char *  pattern 
)

Definition at line 2943 of file comsys.cpp.

References A_DESC, alloc_mbuf, ANSI_TruncateAndPad_sbuf(), atr_pget, channel::chan_obj, chanlist_comp(), statedata::channel_htab, CHANNEL_LOUD, CHANNEL_PUBLIC, CHANNEL_SPOOF, channel::charge_who, CLIST_FULL, CLIST_HEADERS, Comm_All, Controls, do_listchannels(), free_lbuf, free_sbuf, CHashTable::GetEntryCount(), hash_firstentry(), hash_nextentry(), confdata::have_comsys, channel::header, ISOUTOFMEMORY, MAX_SUPPORTED_NUM_ENTRIES, MEMALLOC, Moniker(), mudconf, mudstate, chanlist_node::name, channel::name, NOTHING, chanlist_node::ptr, quick_wild(), raw_notify(), channel::type, and UNUSED_PARAMETER.

Referenced by do_chopen().

02950 {
02951     UNUSED_PARAMETER(caller);
02952     UNUSED_PARAMETER(enactor);
02953 
02954     if (!mudconf.have_comsys)
02955     {
02956         raw_notify(executor, "Comsys disabled.");
02957         return;
02958     }
02959     if (key & CLIST_FULL)
02960     {
02961         do_listchannels(executor);
02962         return;
02963     }
02964 
02965     dbref owner;
02966     struct channel *ch;
02967     int flags = 0;
02968     char *atrstr;
02969     char *temp = alloc_mbuf("do_chanlist_temp");
02970     char *buf = alloc_mbuf("do_chanlist_buf");
02971 
02972     if (key & CLIST_HEADERS)
02973     {
02974         raw_notify(executor, "*** Channel       Owner           Header");
02975     }
02976     else
02977     {
02978         raw_notify(executor, "*** Channel       Owner           Description");
02979     }
02980 
02981     bool bWild;
02982     if (  NULL != pattern
02983        && '\0' != *pattern)
02984     {
02985         bWild = true;
02986     }
02987     else
02988     {
02989         bWild = false;
02990     }
02991 
02992 #define MAX_SUPPORTED_NUM_ENTRIES 10000
02993 
02994     INT64 iEntryCount64 = mudstate.channel_htab.GetEntryCount();
02995     if (MAX_SUPPORTED_NUM_ENTRIES < iEntryCount64)
02996     {
02997         // Nobody should have so many channels.
02998         //
02999         iEntryCount64 = MAX_SUPPORTED_NUM_ENTRIES;
03000     }
03001     size_t entries = (size_t)iEntryCount64;
03002 
03003     struct chanlist_node* charray = (chanlist_node*)MEMALLOC(sizeof(chanlist_node)*entries);
03004     ISOUTOFMEMORY(charray);
03005 
03006     // Arrayify all the channels
03007     //
03008     size_t  actualEntries;
03009     for (  actualEntries = 0, ch = (struct channel *)hash_firstentry(&mudstate.channel_htab);
03010            ch
03011         && actualEntries < entries;
03012            ch = (struct channel *)hash_nextentry(&mudstate.channel_htab))
03013     {
03014             if (  !bWild
03015                || quick_wild(pattern, ch->name))
03016             {
03017                 charray[actualEntries].name = ch->name;
03018                 charray[actualEntries].ptr = ch;
03019                 actualEntries++;
03020             }
03021     }
03022 
03023     qsort(charray, actualEntries, sizeof(struct chanlist_node), chanlist_comp);
03024 
03025     for (size_t i = 0; i < actualEntries; i++)
03026     {
03027         ch = charray[i].ptr;
03028         if (  Comm_All(executor)
03029            || (ch->type & CHANNEL_PUBLIC)
03030            || Controls(executor, ch->charge_who))
03031         {
03032             char *pBuffer;
03033             if (key & CLIST_HEADERS)
03034             {
03035                 pBuffer = ch->header;
03036             }
03037             else
03038             {
03039                 atrstr = atr_pget(ch->chan_obj, A_DESC, &owner, &flags);
03040                 if (  NOTHING == ch->chan_obj
03041                    || !*atrstr)
03042                 {
03043                     strcpy(buf, "No description.");
03044                 }
03045                 else
03046                 {
03047                     sprintf(buf, "%-54.54s", atrstr);
03048                 }
03049                 free_lbuf(atrstr);
03050 
03051                 pBuffer = buf;
03052             }
03053 
03054             char *ownername_ansi = ANSI_TruncateAndPad_sbuf(Moniker(ch->charge_who), 15);
03055             sprintf(temp, "%c%c%c %-13.13s %s %-45.45s",
03056                 (ch->type & (CHANNEL_PUBLIC)) ? 'P' : '-',
03057                 (ch->type & (CHANNEL_LOUD)) ? 'L' : '-',
03058                 (ch->type & (CHANNEL_SPOOF)) ? 'S' : '-',
03059                 ch->name, ownername_ansi, pBuffer);
03060             free_sbuf(ownername_ansi);
03061 
03062             raw_notify(executor, temp);
03063         }
03064     }
03065     MEMFREE(charray);
03066     free_mbuf(temp);
03067     free_mbuf(buf);
03068     raw_notify(executor, "-- End of list of Channels --");
03069 }

void do_channelnuke ( dbref  player  ) 

Definition at line 2090 of file comsys.cpp.

References statedata::channel_htab, channel::charge_who, hash_firstentry(), hash_nextentry(), hashdeleteLEN(), MEMFREE, mudstate, channel::name, num_channels, channel::num_users, and channel::users.

Referenced by ReleaseAllResources().

02091 {
02092     struct channel *ch;
02093     int j;
02094 
02095     for (ch = (struct channel *)hash_firstentry(&mudstate.channel_htab);
02096          ch; ch = (struct channel *)hash_nextentry(&mudstate.channel_htab))
02097     {
02098         if (player == ch->charge_who)
02099         {
02100             num_channels--;
02101             hashdeleteLEN(ch->name, strlen(ch->name), &mudstate.channel_htab);
02102 
02103             for (j = 0; j < ch->num_users; j++)
02104             {
02105                 MEMFREE(ch->users[j]);
02106                 ch->users[j] = NULL;
02107             }
02108             MEMFREE(ch->users);
02109             ch->users = NULL;
02110             MEMFREE(ch);
02111             ch = NULL;
02112         }
02113     }
02114 }

void do_cheader ( dbref  player,
char *  channel,
char *  header 
)

Definition at line 2903 of file comsys.cpp.

References ANSI_ENDGOAL_NORMAL, ANSI_TruncateToField(), channel::charge_who, Comm_All, Controls, channel::header, MAX_HEADER_LEN, NOPERM_MESSAGE, raw_notify(), RemoveSetOfCharacters(), and select_channel().

Referenced by do_chopen().

02904 {
02905     struct channel *ch = select_channel(channel);
02906     if (!ch)
02907     {
02908         raw_notify(player, "That channel does not exist.");
02909         return;
02910     }
02911     if (  !Controls(player, ch->charge_who)
02912        && !Comm_All(player))
02913     {
02914         raw_notify(player, NOPERM_MESSAGE);
02915         return;
02916     }
02917     char *p = RemoveSetOfCharacters(header, "\r\n\t");
02918 
02919     // Optimize/terminate any ANSI in the string.
02920     //
02921     char NewHeader_ANSI[MAX_HEADER_LEN+1];
02922     int nVisualWidth;
02923     int nLen = ANSI_TruncateToField(p, sizeof(NewHeader_ANSI),
02924         NewHeader_ANSI, sizeof(NewHeader_ANSI), &nVisualWidth,
02925         ANSI_ENDGOAL_NORMAL);
02926     memcpy(ch->header, NewHeader_ANSI, nLen+1);
02927 }

void do_clearcom ( dbref  executor,
dbref  caller,
dbref  enactor,
int  unused2 
)

Definition at line 2116 of file comsys.cpp.

References tagComsys::alias, ALIAS_SIZE, do_delcom(), get_comsys(), confdata::have_comsys, mudconf, tagComsys::numchannels, raw_notify(), and UNUSED_PARAMETER.

Referenced by ReleaseAllResources().

02117 {
02118     UNUSED_PARAMETER(unused2);
02119 
02120     if (!mudconf.have_comsys)
02121     {
02122         raw_notify(executor, "Comsys disabled.");
02123         return;
02124     }
02125     comsys_t *c = get_comsys(executor);
02126 
02127     int i;
02128     for (i = (c->numchannels) - 1; i > -1; --i)
02129     {
02130         do_delcom(executor, caller, enactor, 0, c->alias + i * ALIAS_SIZE);
02131     }
02132 }

void do_comconnect ( dbref  player  ) 

Definition at line 2349 of file comsys.cpp.

References tagComsys::alias, tagComsys::channels, do_comconnectchannel(), do_comconnectraw_notify(), get_comsys(), and tagComsys::numchannels.

Referenced by announce_connect().

02350 {
02351     comsys_t *c = get_comsys(player);
02352     int i;
02353 
02354     for (i = 0; i < c->numchannels; i++)
02355     {
02356         char *CurrentChannel = c->channels[i];
02357         bool bFound = false;
02358         int j;
02359 
02360         for (j = 0; j < i; j++)
02361         {
02362             if (strcmp(c->channels[j], CurrentChannel) == 0)
02363             {
02364                 bFound = true;
02365                 break;
02366             }
02367         }
02368 
02369         if (!bFound)
02370         {
02371             do_comconnectchannel(player, CurrentChannel, c->alias, i);
02372             do_comconnectraw_notify(player, CurrentChannel);
02373         }
02374     }
02375 }

void do_comdisconnect ( dbref  player  ) 

Definition at line 2321 of file comsys.cpp.

References tagComsys::channels, do_comdisconnectchannel(), do_comdisconnectraw_notify(), get_comsys(), and tagComsys::numchannels.

Referenced by announce_disconnect(), and ReleaseAllResources().

02322 {
02323     comsys_t *c = get_comsys(player);
02324     int i;
02325 
02326     for (i = 0; i < c->numchannels; i++)
02327     {
02328         char *CurrentChannel = c->channels[i];
02329         bool bFound = false;
02330         int j;
02331 
02332         for (j = 0; j < i; j++)
02333         {
02334             if (strcmp(c->channels[j], CurrentChannel) == 0)
02335             {
02336                 bFound = true;
02337                 break;
02338             }
02339         }
02340 
02341         if (!bFound)
02342         {
02343             do_comdisconnectchannel(player, CurrentChannel);
02344             do_comdisconnectraw_notify(player, CurrentChannel);
02345         }
02346     }
02347 }

void do_comdisconnectchannel ( dbref  player,
char *  channel 
)

Definition at line 2378 of file comsys.cpp.

References comuser::on_next, channel::on_users, select_channel(), and comuser::who.

Referenced by do_comdisconnect(), do_comwho(), and do_delcomchannel().

02379 {
02380     struct channel *ch = select_channel(channel);
02381     if (!ch)
02382     {
02383         return;
02384     }
02385 
02386     struct comuser *prevuser = NULL;
02387     struct comuser *user;
02388     for (user = ch->on_users; user;)
02389     {
02390         if (user->who == player)
02391         {
02392             if (prevuser)
02393             {
02394                 prevuser->on_next = user->on_next;
02395             }
02396             else
02397             {
02398                 ch->on_users = user->on_next;
02399             }
02400             return;
02401         }
02402         else
02403         {
02404             prevuser = user;
02405             user = user->on_next;
02406         }
02407     }
02408 }

void do_comlast ( dbref  player,
struct channel ch,
int  arg 
)

Definition at line 1304 of file comsys.cpp.

References atr_get, atr_get_info(), atr_str(), channel::chan_obj, free_lbuf, Good_obj, iMod(), MAX_RECALL_REQUEST, MIN_RECALL_REQUEST, mux_atol(), channel::num_messages, attr::number, raw_notify(), and tprintf().

Referenced by do_processcom().

01305 {
01306     if (!Good_obj(ch->chan_obj))
01307     {
01308         raw_notify(player, "Channel does not have an object.");
01309         return;
01310     }
01311     dbref aowner;
01312     int aflags;
01313     dbref obj = ch->chan_obj;
01314     int logmax = MAX_RECALL_REQUEST;
01315     ATTR *pattr = atr_str("MAX_LOG");
01316     if (  pattr
01317        && (atr_get_info(obj, pattr->number, &aowner, &aflags)))
01318     {
01319         char *maxbuf = atr_get(obj, pattr->number, &aowner, &aflags);
01320         logmax = mux_atol(maxbuf);
01321         free_lbuf(maxbuf);
01322     }
01323     if (logmax < 1)
01324     {
01325         raw_notify(player, "Channel does not log.");
01326         return;
01327     }
01328     if (arg < MIN_RECALL_REQUEST)
01329     {
01330         arg = MIN_RECALL_REQUEST;
01331     }
01332     if (arg > logmax)
01333     {
01334         arg = logmax;
01335     }
01336 
01337     char *message;
01338     int histnum = ch->num_messages - arg;
01339 
01340     raw_notify(player, "-- Begin Comsys Recall --");
01341     for (int count = 0; count < arg; count++)
01342     {
01343         histnum++;
01344         pattr = atr_str(tprintf("HISTORY_%d", iMod(histnum, logmax)));
01345         if (pattr)
01346         {
01347             message = atr_get(obj, pattr->number, &aowner, &aflags);
01348             raw_notify(player, message);
01349             free_lbuf(message);
01350         }
01351     }
01352     raw_notify(player, "-- End Comsys Recall --");
01353 }

bool do_comsystem ( dbref  who,
char *  cmd 
)

Definition at line 2610 of file comsys.cpp.

References alloc_lbuf, do_processcom(), free_lbuf, get_channel_from_alias(), and LBUF_SIZE.

Referenced by process_command().

02611 {
02612     char *t;
02613     char *alias = alloc_lbuf("do_comsystem");
02614     char *s = alias;
02615     for (t = cmd; *t && *t != ' ' && s < alias + LBUF_SIZE; *s++ = *t++)
02616     {
02617         ; // Nothing.
02618     }
02619 
02620     *s = '\0';
02621 
02622     if (*t)
02623     {
02624         t++;
02625     }
02626 
02627     char *ch = get_channel_from_alias(who, alias);
02628     if (  ch[0] != '\0'
02629        && t[0] != '\0')
02630     {
02631         do_processcom(who, ch, t);
02632         free_lbuf(alias);
02633         return false;
02634     }
02635     else
02636     {
02637         free_lbuf(alias);
02638     }
02639     return true;
02640 }

void do_comwho ( dbref  player,
struct channel ch 
)

Definition at line 1260 of file comsys.cpp.

References comuser::bUserIsOn, Connected, do_comdisconnectchannel(), do_comwho_line(), God, Going, Hidden, isPlayer, channel::name, comuser::on_next, channel::on_users, Owner, raw_notify(), See_Hidden, tprintf(), comuser::who, and Wizard_Who.

Referenced by do_processcom().

01261 {
01262     struct comuser *user;
01263 
01264     raw_notify(player, "-- Players --");
01265     for (user = ch->on_users; user; user = user->on_next)
01266     {
01267         if (isPlayer(user->who))
01268         {
01269             if (  Connected(user->who)
01270                && (  !Hidden(user->who)
01271                   || Wizard_Who(player)
01272                   || See_Hidden(player)))
01273             {
01274                 if (user->bUserIsOn)
01275                 {
01276                     do_comwho_line(player, ch, user);
01277                 }
01278             }
01279             else if (!Hidden(user->who))
01280             {
01281                 do_comdisconnectchannel(user->who, ch->name);
01282             }
01283         }
01284     }
01285     raw_notify(player, "-- Objects --");
01286     for (user = ch->on_users; user; user = user->on_next)
01287     {
01288         if (!isPlayer(user->who))
01289         {
01290             if