Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

comm.c File Reference

#include <sys/types.h>
#include <sys/time.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <signal.h>
#include <unistd.h>
#include <stdarg.h>
#include "merc.h"
#include "interp.h"
#include "recycle.h"
#include "tables.h"

Include dependency graph for comm.c:

Go to the source code of this file.

Defines

#define COPYOVER_FILE   "copyover.data"

Functions

void act_new (const char *format, CHAR_DATA *ch, const void *arg1, const void *arg2, int type, int min_pos)
void send_to_all args ((char *cch, char *argument))
void send_to_all_copyover args ((char *argument))
void stop_idling args ((CHAR_DATA *ch))
void read_from_buffer args ((DESCRIPTOR_DATA *d))
bool process_output args ((DESCRIPTOR_DATA *d, bool fPrompt))
void nanny args ((DESCRIPTOR_DATA *d, char *argument))
int main args ((int argc, char **argv))
bool check_playing args ((DESCRIPTOR_DATA *d, char *name))
bool check_reconnect args ((DESCRIPTOR_DATA *d, char *name, bool fConn))
bool check_parse_name args ((char *name))
void bugf (char *fmt,...)
void bust_a_prompt (CHAR_DATA *ch)
bool check_parse_name (char *name)
bool check_playing (DESCRIPTOR_DATA *d, char *name)
bool check_reconnect (DESCRIPTOR_DATA *d, char *name, bool fConn)
void close_socket (DESCRIPTOR_DATA *dclose)
int colour (char type, CHAR_DATA *ch, char *string)
void colourconv (char *buffer, const char *txt, CHAR_DATA *ch)
void colourconv2 (char *buffer, const char *txt)
void fix_sex (CHAR_DATA *ch)
void logf (char *fmt,...)
int main (int argc, char **argv)
void page_to_char (const char *txt, CHAR_DATA *ch)
void page_to_char_bw (const char *txt, CHAR_DATA *ch)
void printf_to_char (CHAR_DATA *ch, char *fmt,...)
void printf_to_desc (DESCRIPTOR_DATA *d, char *fmt,...)
bool process_output (DESCRIPTOR_DATA *d, bool fPrompt)
void read_from_buffer (DESCRIPTOR_DATA *d)
bool read_from_descriptor (DESCRIPTOR_DATA *d)
void send_to_all (char *chh, char *argument)
void send_to_all_copyover (char *argument)
void send_to_char (const char *txt, CHAR_DATA *ch)
void send_to_char_bw (const char *txt, CHAR_DATA *ch)
void send_to_desc (const char *txt, DESCRIPTOR_DATA *d)
void show_string (struct descriptor_data *d, char *input)
void stop_idling (CHAR_DATA *ch)
void write_to_buffer (DESCRIPTOR_DATA *d, const char *txt, int length)
bool write_to_descriptor (int desc, char *txt, int length)

Variables

int control
int Copyovercount = 3
CHAR_DATACopyoverPerson
char * CopyoverReason
time_t current_time
DESCRIPTOR_DATAd_next
DESCRIPTOR_DATAdescriptor_list
bool fCopyOver = FALSE
FILE * fpReserve
bool global_peace
bool god
bool is_building_area
bool isAreaPort
bool isCopyover
bool just_rained
bool merc_down
bool MOBtrigger = TRUE
int mud_ansicolor
int mud_ansiprompt
char * mud_ipaddress = "0.0.0.0"
int mud_telnetga
bool newlock
int port
char str_boot_time [MAX_INPUT_LENGTH]
bool wizlock


Define Documentation

#define COPYOVER_FILE   "copyover.data"
 

Definition at line 2716 of file comm.c.


Function Documentation

void act_new const char *  format,
CHAR_DATA ch,
const void *  arg1,
const void *  arg2,
int  type,
int  min_pos
 

Definition at line 2260 of file comm.c.

References bug(), can_see_obj(), colourconv(), CON_PLAYING, FALSE, char_data::in_room, IS_NPC, IS_SWITCHED, MAX_INPUT_LENGTH, MAX_STRING_LENGTH, MOBtrigger, mp_act_trigger(), MSL, char_data::next_in_room, one_argument(), room_index_data::people, PERS, send_to_char(), char_data::sex, obj_data::short_descr, TO_CHAR, TO_NOTVICT, TO_ROOM, TO_VICT, TRIG_ACT, TRUE, UPPER, URANGE, and write_to_buffer().

Referenced by do_admintalk(), do_answer(), do_auction(), do_broadcast(), do_clan_gossip(), do_clantalk(), do_gossip(), do_grats(), do_group(), do_gtell(), do_immtalk(), do_kingdomtalk(), do_music(), do_ooc(), do_oocclan_talk(), do_pray(), do_protect(), do_question(), do_quote(), do_reply(), do_rest(), do_sit(), do_sleep(), do_stand(), do_tell(), do_wake(), song_update(), and wiznet().

02262 {
02263     static char *const he_she[] = { "it", "he", "she" };
02264     static char *const him_her[] = { "it", "him", "her" };
02265     static char *const his_her[] = { "its", "his", "her" };
02266 
02267     char buf[MAX_STRING_LENGTH];
02268     char fname[MAX_INPUT_LENGTH];
02269     CHAR_DATA *to;
02270     CHAR_DATA *vch = (CHAR_DATA *) arg2;
02271     OBJ_DATA *obj1 = (OBJ_DATA *) arg1;
02272     OBJ_DATA *obj2 = (OBJ_DATA *) arg2;
02273     const char *str;
02274     const char *i;
02275     char *point;
02276     char *pbuff;
02277     char buffer[MSL * 2];
02278     bool fColour = FALSE;
02279 
02280 
02281     /*
02282      * Discard null and zero-length messages.
02283      */
02284     if (format == NULL || format[0] == '\0')
02285         return;
02286 
02287     /* discard null rooms and chars */
02288     if (ch == NULL || ch->in_room == NULL)
02289         return;
02290 
02291     to = ch->in_room->people;
02292     if (type == TO_VICT)
02293     {
02294         if (vch == NULL)
02295         {
02296             bug ("Act: null vch with TO_VICT.", 0);
02297             return;
02298         }
02299 
02300         if (vch->in_room == NULL)
02301             return;
02302 
02303         to = vch->in_room->people;
02304     }
02305 
02306     for (; to != NULL; to = to->next_in_room)
02307     {
02308         if ((!IS_NPC (to) && to->desc == NULL)
02309             /*|| (IS_NPC (to) && !HAS_TRIGGER (to, TRIG_ACT))*/
02310             || to->position < min_pos)
02311             continue;
02312 
02313         if ((type == TO_CHAR) && to != ch)
02314             continue;
02315         if (type == TO_VICT && (to != vch || to == ch))
02316             continue;
02317         if (type == TO_ROOM && to == ch)
02318             continue;
02319         if (type == TO_NOTVICT && (to == ch || to == vch))
02320             continue;
02321 
02322         point = buf;
02323         str = format;
02324         while (*str != '\0')
02325         {
02326             if (*str != '$')
02327             {
02328                 *point++ = *str++;
02329                 continue;
02330             }
02331             fColour = TRUE;
02332             ++str;
02333             i = " <@@@> ";
02334 
02335             if (arg2 == NULL && *str >= 'A' && *str <= 'Z')
02336             {
02337                 bug ("Act: missing arg2 for code %d.", *str);
02338                 i = " <@@@> ";
02339             }
02340             else
02341             {
02342                 switch (*str)
02343                 {
02344                     /* Added checking of pointers to each case after
02345                      * reading about the bug on Edwin's page.
02346                      * JR -- 10/15/00
02347                      */
02348                     default:
02349                         bug ("Act: bad code %d.", *str);
02350                         i = " <@@@> ";
02351                         break;
02352                         /* Thx alex for 't' idea */
02353                     case 't':
02354                         if (arg1)
02355                             i = (char *) arg1;
02356                         else
02357                             bug("Act: bad code $t for 'arg1'",0);
02358                         break;
02359                     case 'T':
02360                         if (arg2)
02361                             i = (char *) arg2;
02362                         else
02363                             bug("Act: bad code $T for 'arg2'",0);
02364                         break;
02365                     case 'n':
02366                         if (ch && to)
02367                             i = PERS (ch, to);
02368                         else
02369                             bug("Act: bad code $n for 'ch' or 'to'",0);
02370                         break;
02371                     case 'N':
02372                         if (vch && to)
02373                             i = PERS (vch, to);
02374                         else
02375                             bug("Act: bad code $N for 'vch' or 'to'",0);
02376                         break;
02377                     case 'e':
02378                         if (ch)
02379                             i = he_she[URANGE (0, ch->sex, 2)];
02380                         else
02381                             bug("Act: bad code $e for 'ch'",0);
02382                         break;
02383                     case 'E':
02384                         if (vch)
02385                             i = he_she[URANGE (0, vch->sex, 2)];
02386                         else
02387                             bug("Act: bad code $E for 'vch'",0);
02388                         break;
02389                     case 'm':
02390                         if (ch)
02391                             i = him_her[URANGE (0, ch->sex, 2)];
02392                         else
02393                             bug("Act: bad code $m for 'ch'",0);
02394                         break;
02395                     case 'M':
02396                         if (vch)
02397                             i = him_her[URANGE (0, vch->sex, 2)];
02398                         else
02399                             bug("Act: bad code $M for 'vch'",0);
02400                         break;
02401                     case 's':
02402                         if (ch)
02403                             i = his_her[URANGE (0, ch->sex, 2)];
02404                         else
02405                             bug("Act: bad code $s for 'ch'",0);
02406                         break;
02407                     case 'S':
02408                         if (vch)
02409                             i = his_her[URANGE (0, vch->sex, 2)];
02410                         else
02411                             bug("Act: bad code $S for 'vch'",0);
02412                         break;
02413                     case 'p':
02414                         if (to && obj1)
02415                             i = can_see_obj (to, obj1)
02416                             ? obj1->short_descr : "something";
02417                         else
02418                             bug("Act: bad code $p for 'to' or 'obj1'",0);
02419                         break;
02420                     case 'P':
02421                         if (to && obj2)
02422                             i = can_see_obj (to, obj2)
02423                             ? obj2->short_descr : "something";
02424                         else
02425                             bug("Act: bad code $P for 'to' or 'obj2'",0);
02426                         break;
02427                     case 'd':
02428                         if (arg2 == NULL || ((char *) arg2)[0] == '\0')
02429                         {
02430                             i = "door";
02431                         }
02432                         else
02433                         {
02434                             one_argument ((char *) arg2, fname);
02435                             i = fname;
02436                         }
02437                         break;
02438                 }
02439             }
02440 
02441             ++str;
02442             while ((*point = *i) != '\0')
02443                 ++point, ++i;
02444         }
02445 
02446         *point++ = '\n';
02447         *point++ = '\r';
02448         *point = '\0';
02449         /* Kludge to capitalize first letter of buffer, trying
02450          * to account for { color codes. -- JR 09/09/00
02451          */
02452         if (buf[0] == 123)
02453             buf[2] = UPPER (buf[2]);
02454         else
02455             buf[0] = UPPER (buf[0]);
02456         pbuff = buffer;
02457         colourconv (pbuff, buf, to);
02458     if (IS_SWITCHED(to))
02459         send_to_char(buffer, to);
02460     else if (to->desc && (to->desc->connected == CON_PLAYING))
02461             write_to_buffer( to->desc, buffer, 0); /* changed to buffer to reflect prev. fix */
02462             //send_to_char(buffer, to);
02463         else if (MOBtrigger)
02464             mp_act_trigger (buf, to, ch, arg1, arg2, TRIG_ACT);
02465         //end_to_char(buffer, to);
02466         
02467     }
02468     return;
02469 }

Here is the call graph for this function:

void send_to_all args (char *cch, char *argument)   ) 
 

void send_to_all_copyover args (char *argument)   ) 
 

void stop_idling args (CHAR_DATA *ch)   ) 
 

void read_from_buffer args (DESCRIPTOR_DATA *d)   ) 
 

bool process_output args (DESCRIPTOR_DATA *d, bool fPrompt)   ) 
 

void nanny args (DESCRIPTOR_DATA *d, char *argument)   ) 
 

int main args (int argc, char **argv)   ) 
 

bool check_playing args (DESCRIPTOR_DATA *d, char *name)   ) 
 

bool check_reconnect args (DESCRIPTOR_DATA *d, char *name, bool fConn)   ) 
 

bool check_parse_name args (char *name)   ) 
 

void bugf char *  fmt,
  ...
 

Definition at line 2762 of file comm.c.

References args, bug(), and MSL.

Referenced by fix_exits(), load_resets(), and move_vehicle_npc().

02763 {
02764     char buf[2 * MSL];
02765     va_list args;
02766     va_start (args, fmt);
02767     vsprintf (buf, fmt, args);
02768     va_end (args);
02769 
02770     bug (buf, 0);
02771 }

Here is the call graph for this function:

void bust_a_prompt CHAR_DATA ch  ) 
 

Definition at line 1481 of file comm.c.

References AFF_BLIND, AFF_INFRARED, can_see_room(), colourconv(), COMM_AFK, dir_name, EX_CLOSED, exit_data::exit_info, exp_per_level(), FALSE, IMMORTAL_PORT, IS_AFFECTED, IS_EVIL, IS_GOOD, IS_IMMORTAL, IS_NPC, IS_SET, MAX_INPUT_LENGTH, MAX_STRING_LENGTH, olc_ed_name(), olc_ed_vnum(), PLR_HOLYLIGHT, port, char_data::prompt, room_is_dark(), send_to_char(), exit_data::to_room, TRUE, exit_data::u1, and write_to_buffer().

Referenced by process_output().

01482 {
01483     char buf[MAX_STRING_LENGTH];
01484     char buf2[MAX_STRING_LENGTH];
01485     const char *str;
01486     const char *i;
01487     char *point;
01488     char *pbuff;
01489     char buffer[MAX_STRING_LENGTH * 2];
01490     char doors[MAX_INPUT_LENGTH];
01491     EXIT_DATA *pexit;
01492     bool found;
01493     const char *dir_name[] = { "N-", "E-", "S-", "W-", "U-", "D-", "Ne-", "Nw-", "Se-", "Sw" };
01494     int door;
01495     extern int port;
01496 
01497     point = buf;
01498     str = ch->prompt;
01499     if (str == NULL || str[0] == '\0')
01500     {
01501         sprintf (buf, "{p<%dhp %dm %dmv>{x %s",
01502                  ch->hit, ch->mana, ch->move, ch->prefix);
01503         send_to_char (buf, ch);
01504         return;
01505     }
01506     if (!IS_NPC(ch) && ch->desc->editor)
01507     {
01508         send_to_char("{R[{WOLC{R]{x ",ch);
01509     }
01510     if (!IS_NPC(ch) && IS_IMMORTAL(ch) && IS_SET(ch->pcdata->immortal, IMMORTAL_PORT))
01511     {
01512         
01513         sprintf(buf, "{r({cPort: {D%d{r){x ",port);
01514         send_to_char(buf,ch);
01515     }
01516         
01517 
01518     
01519     if (IS_SET (ch->comm, COMM_AFK))
01520     {
01521         send_to_char ("{p<AFK>{x ", ch);
01522         return;
01523     }
01524 
01525     while (*str != '\0')
01526     {
01527         if (*str != '%')
01528         {
01529             *point++ = *str++;
01530             continue;
01531         }
01532         ++str;
01533         switch (*str)
01534         {
01535             default:
01536                 i = " ";
01537                 break;
01538             case 'e':
01539                 found = FALSE;
01540                 doors[0] = '\0';
01541                 for (door = 0; door < 10; door++)
01542                 {
01543                     if ((pexit = ch->in_room->exit[door]) != NULL
01544                         && pexit->u1.to_room != NULL
01545                         && (can_see_room (ch, pexit->u1.to_room)
01546                             || (IS_AFFECTED (ch, AFF_INFRARED)
01547                                 && !IS_AFFECTED (ch, AFF_BLIND)))
01548                         && !IS_SET (pexit->exit_info, EX_CLOSED))
01549                     {
01550                         found = TRUE;
01551                         strcat (doors, dir_name[door]);
01552                     }
01553                 }
01554                 if (!found)
01555                     strcat (buf, "none");
01556                 sprintf (buf2, "%s", doors);
01557                 i = buf2;
01558                 break;
01559             case 'c':
01560                 sprintf (buf2, "%s", "\n\r");
01561                 i = buf2;
01562                 break;
01563             case 'h':
01564                 sprintf (buf2, "%d", ch->hit);
01565                 i = buf2;
01566                 break;
01567             case 'H':
01568                 sprintf (buf2, "%d", ch->max_hit);
01569                 i = buf2;
01570                 break;
01571             case 'm':
01572                 sprintf (buf2, "%d", ch->mana);
01573                 i = buf2;
01574                 break;
01575             case 'M':
01576                 sprintf (buf2, "%d", ch->max_mana);
01577                 i = buf2;
01578                 break;
01579             case 'v':
01580                 sprintf (buf2, "%d", ch->move);
01581                 i = buf2;
01582                 break;
01583             case 'V':
01584                 sprintf (buf2, "%d", ch->max_move);
01585                 i = buf2;
01586                 break;
01587             case 'x':
01588                 sprintf (buf2, "%d", ch->exp);
01589                 i = buf2;
01590                 break;
01591             case 'X':
01592                 sprintf (buf2, "%d", IS_NPC (ch) ? 0 :
01593                          (ch->level + 1) * exp_per_level (ch,
01594                                                           ch->pcdata->
01595                                                           points) - ch->exp);
01596                 i = buf2;
01597                 break;
01598             case 'g':
01599                 sprintf (buf2, "%ld", ch->gold);
01600                 i = buf2;
01601                 break;
01602             case 's':
01603                 sprintf (buf2, "%ld", ch->silver);
01604                 i = buf2;
01605                 break;
01606             case 'a':
01607                 if (ch->level > 9)
01608                     sprintf (buf2, "%d", ch->alignment);
01609                 else
01610                     sprintf (buf2, "%s",
01611                              IS_GOOD (ch) ? "good" : IS_EVIL (ch) ? "evil" :
01612                              "neutral");
01613                 i = buf2;
01614                 break;
01615             case 'r':
01616                 if (ch->in_room != NULL)
01617                     sprintf (buf2, "%s",
01618                              ((!IS_NPC
01619                                (ch) && IS_SET (ch->act, PLR_HOLYLIGHT))
01620                               || (!IS_AFFECTED (ch, AFF_BLIND)
01621                                   && !room_is_dark (ch->
01622                                                     in_room))) ? ch->in_room->
01623                              name : "darkness");
01624                 else
01625                     sprintf (buf2, " ");
01626                 i = buf2;
01627                 break;
01628             case 'R':
01629                 if (IS_IMMORTAL (ch) && ch->in_room != NULL)
01630                     sprintf (buf2, "%d", ch->in_room->vnum);
01631                 else
01632                     sprintf (buf2, " ");
01633                 i = buf2;
01634                 break;
01635             case 'z':
01636                 if (IS_IMMORTAL (ch) && ch->in_room != NULL)
01637                     sprintf (buf2, "%s", ch->in_room->area->name);
01638                 else
01639                     sprintf (buf2, " ");
01640                 i = buf2;
01641                 break;
01642             case '%':
01643                 sprintf (buf2, "%%");
01644                 i = buf2;
01645                 break;
01646             case 'o':
01647                 sprintf (buf2, "%s", olc_ed_name (ch));
01648                 i = buf2;
01649                 break;
01650             case 'O':
01651                 sprintf (buf2, "%s", olc_ed_vnum (ch));
01652                 i = buf2;
01653                 break;
01654         }
01655         ++str;
01656         while ((*point = *i) != '\0')
01657             ++point, ++i;
01658     }
01659     *point = '\0';
01660     pbuff = buffer;
01661     colourconv (pbuff, buf, ch);
01662     send_to_char ("{p", ch);
01663     write_to_buffer (ch->desc, buffer, 0);
01664     send_to_char ("{x", ch);
01665 
01666     if (ch->prefix[0] != '\0')
01667         write_to_buffer (ch->desc, ch->prefix, 0);
01668     return;
01669 }

Here is the call graph for this function:

bool check_parse_name char *  name  ) 
 

Definition at line 1773 of file comm.c.

References capitalize(), descriptor_data::character, clan_table, close_socket(), CON_PLAYING, descriptor_data::connected, descriptor_list, FALSE, is_exact_name(), is_name(), log_buf, LOWER, MAX_CLAN, MAX_KEY_HASH, mob_index_hash, char_data::name, descriptor_data::next, mob_index_data::next, mob_index_data::player_name, str_cmp(), str_prefix(), str_suffix(), TRUE, WIZ_LOGINS, and wiznet().

Referenced by do_rename(), and nanny().

01774 {
01775     int clan;
01776 
01777     /*
01778      * Reserved words.
01779      */
01780     if (is_exact_name (name,
01781                        "all auto immortal self someone something the you loner none"))
01782     {
01783         return FALSE;
01784     }
01785 
01786     /* check clans */
01787     for (clan = 0; clan < MAX_CLAN; clan++)
01788     {
01789         if (LOWER (name[0]) == LOWER (clan_table[clan].name[0])
01790             && !str_cmp (name, clan_table[clan].name))
01791             return FALSE;
01792     }
01793 
01794     if (str_cmp (capitalize (name), "Alander") && (!str_prefix ("Alan", name)
01795                                                    || !str_suffix ("Alander",
01796                                                                    name)))
01797         return FALSE;
01798 
01799     /*
01800      * Length restrictions.
01801      */
01802 
01803     if (strlen (name) < 2)
01804         return FALSE;
01805 
01806 #if defined(MSDOS)
01807     if (strlen (name) > 8)
01808         return FALSE;
01809 #endif
01810 
01811 #if defined(macintosh) || defined(unix)
01812     if (strlen (name) > 12)
01813         return FALSE;
01814 #endif
01815 
01816     /*
01817      * Alphanumerics only.
01818      * Lock out IllIll twits.
01819      */
01820     {
01821         char *pc;
01822         bool fIll, adjcaps = FALSE, cleancaps = FALSE;
01823         int total_caps = 0;
01824 
01825         fIll = TRUE;
01826         for (pc = name; *pc != '\0'; pc++)
01827         {
01828             if (!isalpha (*pc))
01829                 return FALSE;
01830 
01831             if (isupper (*pc))
01832             {                    /* ugly anti-caps hack */
01833                 if (adjcaps)
01834                     cleancaps = TRUE;
01835                 total_caps++;
01836                 adjcaps = TRUE;
01837             }
01838             else
01839                 adjcaps = FALSE;
01840 
01841             if (LOWER (*pc) != 'i' && LOWER (*pc) != 'l')
01842                 fIll = FALSE;
01843         }
01844 
01845         if (fIll)
01846             return FALSE;
01847 
01848         if (cleancaps
01849             || (total_caps > (strlen (name)) / 2
01850                 && strlen (name) < 3)) return FALSE;
01851     }
01852 
01853     /*
01854      * Prevent players from naming themselves after mobs.
01855      */
01856     {
01857         extern MOB_INDEX_DATA *mob_index_hash[MAX_KEY_HASH];
01858         MOB_INDEX_DATA *pMobIndex;
01859         int iHash;
01860 
01861         for (iHash = 0; iHash < MAX_KEY_HASH; iHash++)
01862         {
01863             for (pMobIndex = mob_index_hash[iHash];
01864                  pMobIndex != NULL; pMobIndex = pMobIndex->next)
01865             {
01866                 if (is_name (name, pMobIndex->player_name))
01867                     return FALSE;
01868             }
01869         }
01870     }
01871 
01872     /*
01873      * Edwin's been here too. JR -- 10/15/00
01874      * 
01875      * Check names of people playing. Yes, this is necessary for multiple
01876      * newbies with the same name (thanks Saro)
01877      */
01878     if (descriptor_list)
01879     {
01880         int count=0;
01881         DESCRIPTOR_DATA *d, *dnext;
01882 
01883         for (d = descriptor_list; d != NULL; d = dnext)
01884         {
01885             dnext=d->next;
01886             if (d->connected!=CON_PLAYING&&d->character&&d->character->name
01887                 && d->character->name[0] && !str_cmp(d->character->name,name))
01888             {
01889                 count++;
01890                 close_socket(d);
01891             }
01892         }
01893         if (count)
01894         {
01895             sprintf(log_buf,"Double newbie alert (%s)",name);
01896             wiznet(log_buf,NULL,NULL,WIZ_LOGINS,0,0);
01897 
01898             return FALSE;
01899         }
01900     }
01901 
01902     return TRUE;
01903 }

Here is the call graph for this function:

bool check_playing DESCRIPTOR_DATA d,
char *  name
 

Definition at line 1961 of file comm.c.

References descriptor_data::character, CON_BREAK_CONNECT, CON_GET_NAME, CON_GET_OLD_PASSWORD, descriptor_data::connected, descriptor_list, FALSE, char_data::name, descriptor_data::next, descriptor_data::original, str_cmp(), TRUE, and write_to_buffer().

Referenced by nanny().

01962 {
01963     DESCRIPTOR_DATA *dold;
01964 
01965     for (dold = descriptor_list; dold; dold = dold->next)
01966     {
01967         if (dold != d
01968             && dold->character != NULL
01969             && dold->connected != CON_GET_NAME
01970             && dold->connected != CON_GET_OLD_PASSWORD
01971             && !str_cmp (name, dold->original
01972                          ? dold->original->name : dold->character->name))
01973         {
01974             write_to_buffer (d, "That character is already playing.\n\r", 0);
01975             write_to_buffer (d, "Do you wish to connect anyway (Y/N)?", 0);
01976             d->connected = CON_BREAK_CONNECT;
01977             return TRUE;
01978         }
01979     }
01980 
01981     return FALSE;
01982 }

Here is the call graph for this function:

bool check_reconnect DESCRIPTOR_DATA d,
char *  name,
bool  fConn
 

Definition at line 1910 of file comm.c.

References act, char_list, descriptor_data::character, CON_PLAYING, FALSE, free_char(), free_string(), IS_NPC, LINK_DEAD, log_buf, log_string(), char_data::next, char_data::pcdata, pc_data::pwd, REMOVE_BIT, send_to_char(), str_cmp(), str_dup(), TO_ROOM, TRUE, WIZ_LINKS, and wiznet().

Referenced by nanny().

01911 {
01912     CHAR_DATA *ch;
01913 
01914     for (ch = char_list; ch != NULL; ch = ch->next)
01915     {
01916         if (!IS_NPC (ch)
01917             && (!fConn || ch->desc == NULL)
01918             && !str_cmp (d->character->name, ch->name))
01919         {
01920             if (fConn == FALSE)
01921             {
01922                 free_string (d->character->pcdata->pwd);
01923                 d->character->pcdata->pwd = str_dup (ch->pcdata->pwd);
01924             }
01925             else
01926             {
01927                 free_char (d->character);
01928                 d->character = ch;
01929                 ch->desc = d;
01930                 ch->timer = 0;
01931                 send_to_char
01932                     ("Reconnecting. Type replay to see missed tells.\n\r",
01933                      ch);
01934                 act ("$n has reconnected.", ch, NULL, NULL, TO_ROOM);
01935 
01936                 sprintf (log_buf, "%s@%s reconnected.", ch->name, d->host);
01937             //   REMOVE_BIT(ch->comm, WIZ_LD);
01938         log_string (log_buf);
01939                 wiznet ("$N groks the fullness of $S link.",
01940                         ch, NULL, WIZ_LINKS, 0, 0);
01941                 d->connected = CON_PLAYING;
01942         REMOVE_BIT(ch->link_status, LINK_DEAD);
01943                 /* Inform the character of a note in progress and the possbility
01944                  * of continuation!
01945                  */
01946 //          if (ch->pcdata->in_progress)
01947 //                  send_to_char ("You have a note in progress. Type NWRITE to continue it.\n\r", ch);
01948             }
01949             return TRUE;
01950         }
01951     }
01952 
01953     return FALSE;
01954 }

Here is the call graph for this function:

void close_socket DESCRIPTOR_DATA dclose  ) 
 

Definition at line 1069 of file comm.c.

References act, bug(), CON_NOTE_FINISH, CON_NOTE_TO, CON_PLAYING, d_next, char_data::desc, descriptor_list, FALSE, free_char(), free_descriptor(), LINK_DEAD, char_data::link_status, log_buf, log_string(), merc_down, char_data::name, descriptor_data::next, process_output(), SET_BIT, descriptor_data::snoop_by, TO_ROOM, WIZ_LINKS, wiznet(), and write_to_buffer().

Referenced by check_parse_name(), do_disconnect(), do_purge(), do_quit(), do_reboot(), do_shutdown(), handle_con_get_eye_color(), nanny(), and write_to_buffer().

01070 {
01071     CHAR_DATA *ch;
01072 
01073     if (dclose->outtop > 0)
01074         process_output (dclose, FALSE);
01075 
01076     if (dclose->snoop_by != NULL)
01077     {
01078         write_to_buffer (dclose->snoop_by,
01079                          "Your victim has left the game.\n\r", 0);
01080     }
01081 
01082     {
01083         DESCRIPTOR_DATA *d;
01084 
01085         for (d = descriptor_list; d != NULL; d = d->next)
01086         {
01087             if (d->snoop_by == dclose)
01088                 d->snoop_by = NULL;
01089         }
01090     }
01091 
01092     if ((ch = dclose->character) != NULL)
01093     {
01094         sprintf (log_buf, "Closing link to %s.", ch->name);
01095         log_string (log_buf);
01096         /* cut down on wiznet spam when rebooting */
01097         /* If ch is writing note or playing, just lose link otherwise clear char */
01098         if ((dclose->connected == CON_PLAYING && !merc_down)
01099                 || ((dclose->connected >= CON_NOTE_TO)
01100                         && (dclose->connected <= CON_NOTE_FINISH)))
01101         {
01102             act ("$n has lost $s link.", ch, NULL, NULL, TO_ROOM);
01103            //SET_BIT(ch->comm, WIZ_LD);
01104         wiznet ("Net death has claimed $N.", ch, NULL, WIZ_LINKS, 0, 0);
01105         SET_BIT(ch->link_status, LINK_DEAD);
01106             ch->desc = NULL;
01107         }
01108         else
01109         {
01110             free_char (dclose->original ? dclose->original :
01111                        dclose->character);
01112         }
01113     }
01114 
01115     if (d_next == dclose)
01116         d_next = d_next->next;
01117 
01118     if (dclose == descriptor_list)
01119     {
01120         descriptor_list = descriptor_list->next;
01121     }
01122     else
01123     {
01124         DESCRIPTOR_DATA *d;
01125 
01126         for (d = descriptor_list; d && d->next != dclose; d = d->next);
01127         if (d != NULL)
01128             d->next = dclose->next;
01129         else
01130             bug ("Close_socket: dclose not found.", 0);
01131     }
01132 
01133     close (dclose->descriptor);
01134     free_descriptor (dclose);
01135 #if defined(MSDOS) || defined(macintosh)
01136     exit (1);
01137 #endif
01138     return;
01139 }

Here is the call graph for this function:

int colour char  type,
CHAR_DATA ch,
char *  string
 

Definition at line 2472 of file comm.c.

References C_1BLINK, C_B_BLUE, C_B_CYAN, C_B_GREEN, C_B_MAGENTA, C_B_RED, C_B_WHITE, C_B_YELLOW, C_BACK, C_BLUE, C_CYAN, C_D_GREY, C_GREEN, C_MAGENTA, C_RED, C_WHITE, C_YELLOW, and CLEAR.

Referenced by all_colour(), colourconv(), page_to_char(), send_to_char(), and send_to_desc().

02473 {
02474     PC_DATA *col;
02475     char code[20];
02476     char *p = '\0';
02477 
02478     //if (ch && IS_NPC (ch))
02479       //  return (0);
02480 
02481     col = ch ? ch->pcdata : NULL;
02482 
02483     switch (type)
02484     {
02485         default:
02486             strcpy (code, CLEAR);
02487             break;
02488         case 'x':
02489             strcpy (code, CLEAR);
02490             break;
02491         case 'b':
02492             strcpy (code, C_BLUE);
02493             break;
02494         case 'c':
02495             strcpy (code, C_CYAN);
02496             break;
02497         case 'g':
02498             strcpy (code, C_GREEN);
02499             break;
02500         case 'm':
02501             strcpy (code, C_MAGENTA);
02502             break;
02503         case 'r':
02504             strcpy (code, C_RED);
02505             break;
02506         case 'w':
02507             strcpy (code, C_WHITE);
02508             break;
02509         case 'y':
02510             strcpy (code, C_YELLOW);
02511             break;
02512         case 'B':
02513             strcpy (code, C_B_BLUE);
02514             break;
02515         case 'C':
02516             strcpy (code, C_B_CYAN);
02517             break;
02518         case 'G':
02519             strcpy (code, C_B_GREEN);
02520             break;
02521         case 'M':
02522             strcpy (code, C_B_MAGENTA);
02523             break;
02524         case 'R':
02525             strcpy (code, C_B_RED);
02526             break;
02527         case 'W':
02528             strcpy (code, C_B_WHITE);
02529             break;
02530         case 'Y':
02531             strcpy (code, C_B_YELLOW);
02532             break;
02533     case 'D':
02534         strcpy (code, C_D_GREY);
02535             break;
02536     case '&':
02537         
02538             strcpy (code, C_BACK);
02539            break;
02540         case '*':
02541            //if (ch->level < 52)
02542         //{
02543     //      sprintf(code,"{*");
02544       //  }
02545         //else
02546        // {
02547             
02548         sprintf (code, "%c", '\a');
02549         //}
02550 
02551         break;
02552         case '/':
02553             strcpy (code, "\n\r");
02554             break;
02555         case '-':
02556             sprintf (code, "%c", '~');
02557             break;
02558         case '{':
02559             sprintf (code, "%c", '{');
02560             break;
02561     case '!':
02562        // if (ch->level < 52)
02563        // {
02564 //          sprintf(code, "{!");
02565 //      }
02566 //      else
02567 //      {
02568             
02569         sprintf (code, C_1BLINK);
02570 //      }
02571         break;   
02572     case '^':
02573         sprintf(code, "\x01B[1D");
02574         break;
02575     case '%':
02576         sprintf(code, "\e[1D");
02577         break;
02578 
02579 
02580 }
02581 
02582     p = code;
02583     while (*p != '\0')
02584     {
02585         *string = *p++;
02586         *++string = '\0';
02587     }
02588 
02589     return (strlen (code));
02590 }

void colourconv char *  buffer,
const char *  txt,
CHAR_DATA ch
 

Definition at line 2612 of file comm.c.

References colour(), IS_SET, and PLR_COLOUR.

Referenced by act_new(), bust_a_prompt(), and process_output().

02613 {
02614     const char *point;
02615 //  char *point;
02616         int skip = 0;
02617 
02618     if (ch && ch->desc && txt)
02619     {
02620         if (IS_SET (ch->act, PLR_COLOUR))
02621         {
02622             for (point = txt; *point; point++)
02623             {
02624                 if (*point == '{')
02625                 {
02626                     point++;
02627         
02628             if (*point != '\n') {
02629  /*                     if (ch->level < 52)
02630             {
02631                 switch (*point)
02632                 {
02633                     case '*':
02634                         continue;
02635                         break;
02636                     case '!':
02637                         continue;
02638                         break;
02639                     case '&':
02640                         continue;
02641                         break;
02642                 }
02643             }*/
02644             skip = colour (*point, ch, buffer);
02645                         while (skip-- > 0)
02646                             ++buffer;
02647                         continue;
02648                     }
02649                 }
02650                 *buffer = *point;
02651                 *++buffer = '\0';
02652             }
02653             *buffer = '\0';
02654         }
02655         else
02656         {
02657             for (point = txt; *point; point++)
02658             {
02659                 if (*point == '{')
02660                 {
02661                     point++;
02662                     continue;
02663                 }
02664                 *buffer = *point;
02665                 *++buffer = '\0';
02666             }
02667             *buffer = '\0';
02668         }
02669     }
02670     return;
02671 }

Here is the call graph for this function:

void colourconv2 char *  buffer,
const char *  txt
 

Definition at line 2591 of file comm.c.

Referenced by do_board(), do_look(), do_show_vehicles(), and do_vedit().

02592 {
02593    const char *point;
02594 //  char *point;
02595             for (point = txt; *point; point++)
02596             {
02597                 if (*point == '{')
02598                 {
02599                     point++;
02600                     continue;
02601                 }
02602                 *buffer = *point;
02603                 *++buffer = '\0';
02604             }
02605             //*buffer = '\0';
02606         
02607     
02608     return;
02609 }

void fix_sex CHAR_DATA ch  ) 
 

Definition at line 2254 of file comm.c.

References IS_NPC, and pc_data::true_sex.

02255 {
02256     if (ch->sex < 0 || ch->sex > 2)
02257         ch->sex = IS_NPC (ch) ? 0 : ch->pcdata->true_sex;
02258 }

void logf char *  fmt,
  ...
 

Definition at line 1759 of file comm.c.

References args, log_string(), and MSL.

Referenced by add_vehicle(), boot_fail(), delete_vehicle(), do_help(), load_area(), load_mobprogs(), load_vehicles(), main(), reset_room(), save_vehicles(), strspace_alloc(), strspace_size_default(), strspace_size_increment(), strspace_size_read(), and strspace_size_set().

01760 {
01761     char buf[2 * MSL];
01762     va_list args;
01763     va_start (args, fmt);
01764     vsprintf (buf, fmt, args);
01765     va_end (args);
01766 
01767     log_string (buf);
01768 }

Here is the call graph for this function:

int main int  argc,
char **  argv
 

Definition at line 372 of file comm.c.

References boot_db(), control, current_time, FALSE, fCopyOver, fpReserve, is_number(), log_string(), logf(), mud_ipaddress, port, save_clan_data(), save_disabled(), save_game_conf(), save_kingdom_data(), str_boot_time, and TRUE.

00373 {
00374     struct timeval now_time;
00375     
00376 
00377     /*
00378      * Memory debugging if needed.
00379      */
00380 #if defined(MALLOC_DEBUG)
00381     malloc_debug (2);
00382 #endif
00383 
00384     /*
00385      * Init time.
00386      */
00387     gettimeofday (&now_time, NULL);
00388     current_time = (time_t) now_time.tv_sec;
00389     strcpy (str_boot_time, ctime (&current_time));
00390 
00391     /*
00392      * Macintosh console initialization.
00393      */
00394 #if defined(macintosh)
00395     console_options.nrows = 31;
00396     cshow (stdout);
00397     csetmode (C_RAW, stdin);
00398     cecho2file ("log file", 1, stderr);
00399 #endif
00400 
00401     /*
00402      * Reserve one channel for our use.
00403      */
00404     if ((fpReserve = fopen (NULL_FILE, "r")) == NULL)
00405     {
00406         perror (NULL_FILE);
00407         exit (1);
00408     }
00409 
00410     /*
00411      * Get the port number.
00412      */
00413     port = 4000;
00414     if (argc > 1)
00415     {
00416         if (!is_number (argv[1]))
00417         {
00418             fprintf (stderr, "Usage: %s [port #]\n", argv[0]);
00419             exit (1);
00420         }
00421         else if ((port = atoi (argv[1])) <= 1024)
00422         {
00423             fprintf (stderr, "Port number must be above 1024.\n");
00424             exit (1);
00425         }
00426 
00427         /* Are we recovering from a copyover? */
00428         if (argv[2] && argv[2][0])
00429         {
00430             logf("We're copyovering?");
00431         fCopyOver = TRUE;
00432             control = atoi (argv[3]);
00433         }
00434         else
00435             fCopyOver = FALSE;
00436 
00437     }
00438     logf("port: %d", port);
00439 
00440     /*
00441      * Run the game.
00442      */
00443 #if defined(macintosh) || defined(MSDOS)
00444     qmconfig_read(); /* Here because it fits, no conflicts with Linux placement -- JR 05/06/01 */
00445     boot_db ();
00446     log_string ("Merc is ready to rock.");
00447     game_loop_mac_msdos ();
00448 #endif
00449 
00450 #if defined(unix)
00451 
00452     qmconfig_read(); /* Here so we can set the IP adress. -- JR 05/06/01 */
00453     if (!fCopyOver)
00454         control = init_socket (port);
00455 
00456     boot_db ();
00457     //send_to_all_copyover("Loading webserver ");
00458     //nit_web(80);
00459     //send_to_all_copyover("Done.(Non-functional)\n\r");
00460     logf ("ROM is ready to rock on port %d (%s).", port, mud_ipaddress);
00461 
00462     if (fCopyOver)
00463         copyover_recover ();
00464 
00465     game_loop_unix (control);
00466     save_kingdom_data();
00467     save_clan_data();
00468     save_game_conf();
00469     save_disabled();
00470     close (control);
00471 #endif
00472 
00473     /*
00474      * That's all, folks.
00475      */
00476     log_string ("Normal termination of game.");
00477     exit (0);
00478     return 0;
00479 }

Here is the call graph for this function:

void page_to_char const char *  txt,
CHAR_DATA ch
 

Definition at line 2140 of file comm.c.

References alloc_mem(), colour(), IS_SET, MAX_STRING_LENGTH, PLR_COLOUR, send_to_char(), and show_string().

Referenced by ban_site(), do_alist(), do_cshow(), do_find_bad_object(), do_help(), do_kcshow(), do_mfind(), do_mpdump(), do_mwhere(), do_ofind(), do_owhere(), do_permit(), do_pipe(),