Ejemplo n.º 1
0
int
process_output (DESCRIPTOR_DATA * t)
{
  char i[MAX_STRING_LENGTH + 1];

  if (!t->prompt_mode && !t->connected && t->edit_index == -1)
    if (write_to_descriptor (t, "\r\n") < 0)
      return (-1);

  /* Cycle thru output queue */
  while (get_from_q (&t->output, i))
    {
      if (t->snoop.snoop_by && t->snoop.snoop_by->desc != NULL
	  && !IS_NPC (t->snoop.snoop_by))
	{
	  write_to_q ("% ", &t->snoop.snoop_by->desc->output);
	  write_to_q (i, &t->snoop.snoop_by->desc->output);
	}
      if (write_to_descriptor (t, i))
	return (-1);
    }

  if (!t->connected && !(t->character && !IS_NPC (t->character) &&
			 GET_FLAG (t->character, FLAG_COMPACT)))
    if (IS_SET (t->edit_mode, MODE_DONE_EDITING) && t->edit_index == -1)
      if (write_to_descriptor (t, "\r\n") < 0)
	return (-1);

  return (1);
}
Ejemplo n.º 2
0
void shutdown_wgrace( char * info)
{
    char buf[MAX_INPUT_LENGTH];
    DESCRIPTOR_DATA *d;

    for ( d = descriptor_list; d ; d = d->next )
	if( d->character && IS_IMMORTAL(d->character) && d->connected == CON_PLAYING )
	{
	    sprintf(buf,"\n\r ****************************************************\n\r");
	    write_to_descriptor (d, buf, 0);
			sprintf(buf,"Zabugowana komenda: %s, poprzednia: %s\n\r", last_command ? last_command : "nie wiadomo", previous_command ? previous_command: "nie ustawiono" );
	    write_to_descriptor (d, buf, 0);

	    if( info )
	    {
		sprintf(buf," **  Signal: %s \n\r", info);
		write_to_descriptor (d, buf, 0);
	    }
	    sprintf(buf," ****************************************************\n\r");
	    write_to_descriptor (d, buf, 0);
	    save_char_obj( d->character, FALSE, FALSE );
	}

    if(!supermob)
	init_supermob();

    free_string(supermob->name);
    supermob->name=str_dup("*** SYSTEM ***");
    do_copyover (supermob,"now");
    return;
}
Ejemplo n.º 3
0
/*
* Shows random names simialiar to the do_randomnames command but formatted for
* the login screen.
*/
void show_random_names(DESCRIPTOR_DATA *d)
{
    int row = 0;
    int col = 0;

    show_menu_top(d);
    show_menu_header("Random Names", d);
    write_to_descriptor(d->descriptor, BLANK_MENU_LINE, d);

    for (row = 0; row < 8; row++)
    {
        write_to_descriptor(d->descriptor, "{w   |    {g", d);

        // Since the random function returns a static char we have to use it in
        // separate calls.

        for (col = 0; col < 4; col++)
        {
            writef(d, "%-16s", generate_random_name());
        }

        write_to_descriptor(d->descriptor, "{w    |\r\n", d);
    }

    show_menu_bottom(d);

    return;
}
Ejemplo n.º 4
0
void do_dthink(struct char_data *ch, char *argument, int cmd)
{
  char buf[MAX_INPUT_LENGTH], mudname[MAX_INPUT_LENGTH];
  struct descriptor_data *d;
  int i;
  
  
  one_argument(argument, mudname);
  if ((i=matchmud(mudname))!=UNDEFINED)
    {
      argument = one_argument(argument, mudname);
      if ((i=getmud(ch, mudname, TRUE))==UNDEFINED)
	return;
    };
  
  while(isspace(*argument)) argument++;
  if (!*argument)
    {
      msg("Sure you have something to think!", ch);
      return;
    };
  
  if (!dimd_credit(ch, 1+1*(i==UNDEFINED)))
    return;
  
  if (i!=UNDEFINED)
    {
      if (IS_SET(muds[i].flags, DD_NOTHINK))
	{
	  msg("They are no longer listening to remote thinks.", ch);
	  return;
	};
      
      sprintf(buf, "^%s^%s^%d^*^%s\n\r",
	      PER(ch), GET_KEYNAME(ch), GetMaxLevel(ch), argument);
      write_to_descriptor(muds[i].desc, buf);
    }
  else
    {
      sprintf(buf, "^%s^%s^%d^*g^%s\n\r",
	      PER(ch), GET_KEYNAME(ch), GetMaxLevel(ch), argument);
      for(i=0; muds[i].address; i++)
	if (IS_SET(muds[i].flags, DD_VERIFIED)
	    && !IS_SET(muds[i].flags, DD_NOTHINK))
	  write_to_descriptor(muds[i].desc, buf);
#if USE_COLOR      
      sprintf(buf, "$kW$n $kLdimension thinks, '%s'", argument);
#else
      sprintf(buf, "$n dimension thinks, '%s'", argument);
#endif      
      for(d = descriptor_list; d; d = d->next)
	if (!d->connected && d->character != ch
	    && GetMaxLevel(d->character) >= DEMIGOD)
	  cact(buf, FALSE, ch, 0, d->character, TO_VICT, CLR_THINK);
    };
}
Ejemplo n.º 5
0
/*
* Sends the greeting on login.
*/
void show_greeting(DESCRIPTOR_DATA *d)
{
    extern char *help_greeting;

    if (help_greeting[0] == '.')
    {
        write_to_descriptor(d->descriptor, help_greeting + 1, d);
    }
    else
    {
        write_to_descriptor(d->descriptor, help_greeting, d);
    }
}
Ejemplo n.º 6
0
bool compressStart(DESCRIPTOR_DATA *d, unsigned char telopt)
{
    z_stream *s;

    if (d->out_compress)
        return TRUE;

    //    bug("Starting compression for descriptor %d", d->descriptor);

    s = (z_stream *)malloc(sizeof(*s));
    d->out_compress_buf = (unsigned char *)malloc(COMPRESS_BUF_SIZE);

    s->next_in = NULL;
    s->avail_in = 0;

    s->next_out = d->out_compress_buf;
    s->avail_out = COMPRESS_BUF_SIZE;

    s->zalloc = zlib_alloc;
    s->zfree  = zlib_free;
    s->opaque = NULL;

    if (deflateInit(s, 9) != Z_OK)
    {
        free(d->out_compress_buf);
        free(s);
        return FALSE;
    }

    if (telopt == TELOPT_COMPRESS)
        write_to_descriptor(d, enable_compress, 0);
    else if (telopt == TELOPT_COMPRESS2)
        write_to_descriptor(d, enable_compress2, 0);
    //    else
    //        bug("compressStart: bad TELOPT passed");

    d->compressing = telopt;
    d->out_compress = s;

    /*    if ( d->character )
        {
        if ( telopt == 85 && !IS_SET(d->character->config,CONFIG_COMPRESS))
                SET_BIT(d->character->config,CONFIG_COMPRESS);
        if ( telopt == 86 && !IS_SET(d->character->config,CONFIG_COMPRESS2))
                SET_BIT(d->character->config,CONFIG_COMPRESS2);
        }*/
    return TRUE;
}
Ejemplo n.º 7
0
bool compressStart( DESCRIPTOR_DATA * d )
{
   z_stream *s;

   if( d->mccp->out_compress )
      return TRUE;

   CREATE( s, z_stream, 1 );
   CREATE( d->mccp->out_compress_buf, unsigned char, COMPRESS_BUF_SIZE );

   s->next_in = NULL;
   s->avail_in = 0;

   s->next_out = d->mccp->out_compress_buf;
   s->avail_out = COMPRESS_BUF_SIZE;

   s->zalloc = Z_NULL;
   s->zfree = Z_NULL;
   s->opaque = NULL;

   if( deflateInit( s, 9 ) != Z_OK )
   {
      DISPOSE( d->mccp->out_compress_buf );
      DISPOSE( s );
      return FALSE;
   }

   write_to_descriptor( d, (const char *)start_compress2_str, 0 );

   d->can_compress = TRUE;
   d->mccp->out_compress = s;

   return TRUE;
}
Ejemplo n.º 8
0
void do_dtell(struct char_data *ch, char *argument, int cmd)
{
  char name[MAX_INPUT_LENGTH], mudname[MAX_INPUT_LENGTH],
  buf[MAX_STRING_LENGTH];
  int i;
  /*
    for (i=0;i<MAX_MOBOBJ;i++)
    {
    sprintf(buf,"%s has pos %d",mob_index[i].name, mob_index[i].pos);
    slog(buf);
    }*/
  argument = one_argument(argument, name);
  argument = one_argument(argument, mudname);
  
  if ((i=getmud(ch, mudname, TRUE))==UNDEFINED)
    return;
  
  while(isspace(*argument)) argument++;
  if (!*argument)
    {
      msg("Surely you have SOMETHING to say ... ?", ch);
      return;
    };
  
  if (!dimd_credit(ch, 1))
    return;
  
  sprintf(buf, "^%s^%s^%d^t^%s^%s\n\r",
	  PER(ch), GET_KEYNAME(ch), GetMaxLevel(ch), name, argument);
  write_to_descriptor(muds[i].desc, buf);
}
Ejemplo n.º 9
0
/* Jump to x,y with direct write to port - for updates that won't
   trigger a new prompt */
void
gotoxy_dir (CHAR_DATA * ch, int x, int y)
{
  char tt[50];
  sprintf (tt, "\x1B[%d;%df", y, x);
  write_to_descriptor (ch->desc->descriptor, tt, 0);
  return;
}
Ejemplo n.º 10
0
	/* internal code sends data to a mud for various tasks */
void dimd_broadcast(char *buf)
{
  int i;
  
  
  for(i=0; muds[i].address; i++)
    if (IS_SET(muds[i].flags, DD_VERIFIED))
      write_to_descriptor(muds[i].desc, buf);
}
Ejemplo n.º 11
0
void wave(int sock, char *text, int port)
{
    int                                     s;

    if ((s = new_connection(sock, port)) < 0)
	return;

    write_to_descriptor(s, text);
    close(s);
}
Ejemplo n.º 12
0
void write_to_descriptor_printf( DESCRIPTOR_DATA *d, const char *fmt, ... )
{
    char                    buf[MAX_STRING_LENGTH * 2];
    va_list                 args;

    va_start( args, fmt );
    vsprintf( buf, fmt, args );
    va_end( args );

    write_to_descriptor( d, buf, strlen( buf ) );
}
Ejemplo n.º 13
0
/*
 * Sends a header of the menu that is centered.
 */
void show_menu_header(char *caption, DESCRIPTOR_DATA *d)
{
    char buf[MAX_STRING_LENGTH];
    char buf2[MAX_STRING_LENGTH];
    char center_text[MAX_STRING_LENGTH];

    sprintf(buf, "{w \\_|%%s|\r\n");
    sprintf(center_text, "{W-=-=-=-=-=-=))) %s: {W%s {w(((=-=-=-=-=-=-{w", settings.mud_name, caption);
    sprintf(center_text, "%s", center_string_padded(center_text, 73));

    sprintf(buf2, buf, center_text);
    write_to_descriptor(d->descriptor, buf2, d);
}
Ejemplo n.º 14
0
void do_dwho(struct char_data *ch, char *argument, int cmd)
{
  char buf[MAX_INPUT_LENGTH];
  int i;
  
  
  argument = one_argument(argument, buf);
  if ((i=getmud(ch, buf, TRUE))==UNDEFINED)
    return;
  
  if (!dimd_credit(ch, 2))
    return;
  
  while(isspace(*argument)) argument++;
  sprintf(buf, "^%s^%s^%d^w^%s\n\r",
	  PER(ch), GET_KEYNAME(ch), GetMaxLevel(ch), argument);
  write_to_descriptor(muds[i].desc, buf);
}
Ejemplo n.º 15
0
bool answer_a_mud(void)
{
  int desc, size, mud;
  struct sockaddr_in sock;
  char buf[1024], host[100];
  
  
  if ((desc = new_connection(dimd_s)) < 0)
    return FALSE;
  
  if ((maxdesc+1) >= avail_descs)
    {
      write_to_descriptor(desc, "Sorry, the game is full.");
      close(desc);
      return FALSE;
    }
  else
    if (desc > maxdesc)
      maxdesc = desc;
  
  
  size = sizeof(sock);
  if (getpeername(desc, (struct sockaddr *) &sock, &size) < 0)
    {
      perror("getpeername");
      *host = '\0';
    }
    else  printhost(&sock.sin_addr, host); 
   
  for(mud=0; muds[mud].address; mud++) 
    if (!str_cmp(host, muds[mud].address))
      break;
  
  if (!muds[mud].address)
    {
      write_to_descriptor(desc, "Sorry, I don't recognize your address.");
      close(desc);
      sprintf(buf,"DIMD requestor[%s](%d) was refused -- couldn't recognize.", host,mud);
      DIMDLOG(buf);
      return FALSE;
    };
  
  if (IS_SET(muds[mud].flags, DD_CONNECTED))
    {
      write_to_descriptor(desc, "We are already connected to your mud.");
      close(desc);
      sprintf(buf, "%s[%s] tried to open a SECOND DIMD connection.",
	      muds[mud].formalname, muds[mud].address);
      DIMDLOG(buf);
      return FALSE;
    };
  
  if (IS_SET(muds[mud].flags, DD_REFUSE))
    {
      write_to_descriptor(desc, "We are not accepting connections from your mud at the moment.");
      close(desc);
      sprintf(buf, "%s[%s] tried to connect but is being refused.",
	      muds[mud].formalname, muds[mud].address);
      DIMDLOG(buf);
      return FALSE;
    };
  
  muds[mud].desc = desc;
  strcpy(muds[mud].host, host);
  muds[mud].output.head = NULL;
  muds[mud].input.head = NULL;
  *muds[mud].buf = 0;
  muds[mud].flags |= DD_CONNECTED;
  *muds[mud].pcname = 0;
  
  sprintf(buf, "DIMD connection established with %s[%s].",
	  muds[mud].formalname, host);
  DIMDLOG(buf);
  
  return TRUE;
}
Ejemplo n.º 16
0
void dimd_loop(void)
{
  int	  i, fromlevel, fromgodlevel;
  fd_set  input_set, output_set, exc_set;
  static char
    buf[MAX_STRING_LENGTH], extra[MAX_STRING_LENGTH],
    fromname[MAX_INPUT_LENGTH], fromkeyname[MAX_INPUT_LENGTH],
    dcommand[MAX_INPUT_LENGTH], toname[MAX_INPUT_LENGTH], *scan;
  struct  char_data *vict;
  char    comm[MAX_INPUT_LENGTH];
  struct  timeval null_time;
  struct  descriptor_data *d;
  
  
  switch (dimd_state) {
    /****************************************************************/
  case DIMD_OPENING:
    if ((dimd_local_mud=getlocalmud())==UNDEFINED)
      {
	DIMDLOG("Couldn't figure out what this mud's name is!  DIMD NOT opened.");
	dimd_state = DIMD_CLOSED;
	dimd_on = FALSE;
	return;
      };
    
    dimd_port = DIMD_PORT;
    dimd_s=init_socket(dimd_port);
    DIMDLOG("DIMD port opened.");
    
    for(i=0; muds[i].address; i++)
      if (IS_SET(muds[i].flags, DD_AUTOTRY))
	call_a_mud(i);
    
    dimd_state = DIMD_OPEN;
    break;
    
    /****************************************************************/
  case DIMD_OPEN:
    
    null_time.tv_sec = 0;
    null_time.tv_usec = 0;
    
    FD_ZERO(&input_set);
    FD_ZERO(&output_set);
    FD_ZERO(&exc_set);
    FD_SET(dimd_s, &input_set);
    for(i=0; muds[i].address; i++)
      if (IS_SET(muds[i].flags, DD_CONNECTED))
	{
	  FD_SET(muds[i].desc, &input_set);
	  FD_SET(muds[i].desc, &exc_set);
	  FD_SET(muds[i].desc, &output_set);
	};
    
    if (select(maxdesc + 1, &input_set, &output_set, &exc_set, &null_time) < 0)
      {
	perror("Tell select poll");
	return;
      };
    
    
    /* Respond to whatever might be happening */
    
    /* New connection? */
    if (FD_ISSET(dimd_s, &input_set))
      if (!answer_a_mud())
	perror("New connection");
    
    for(i=0; muds[i].address; i++)
      if (IS_SET(muds[i].flags, DD_CONNECTED))
	{
	  if (FD_ISSET(muds[i].desc, &exc_set))
	    {
	      FD_CLR(muds[i].desc, &input_set);
	      FD_CLR(muds[i].desc, &output_set);
	      hangup_on_a_mud(i);
	    };
	};
    
    for(i=0; muds[i].address; i++)
      if (IS_SET(muds[i].flags, DD_CONNECTED))
	{
	  if (FD_ISSET(muds[i].desc, &input_set))
	    if (process_dimd_input(i) < 0) 
	      hangup_on_a_mud(i);
	};
    
    for(i=0; muds[i].address; i++)
      if (IS_SET(muds[i].flags, DD_CONNECTED))
	{
	  while(get_from_q(&muds[i].input, comm))
	    {
	      if (!IS_SET(muds[i].flags, DD_VERIFIED))
		{
		  if (str_cmp(comm, DIMD_PASSWORD))
		    {
		      sprintf(buf, "The mud is located at port %d.\n\r",
			      dimd_port-2);
		      write_to_descriptor(muds[i].desc, buf);
		      sprintf(buf, "%s[%s]'s server didn't know our password.",
			      muds[i].formalname, muds[i].host);
		      DIMDLOG(buf);
		      hangup_on_a_mud(i);
		      break;
		    };
		  
		  SET_BIT(muds[i].flags, DD_VERIFIED);
		  break;
		};
	      
	      if (*comm != '^')
		{
		  if (!(vict=get_char(muds[i].pcname)))
		    {
		      sprintf(buf,
			      "DIMD stream for unknown player %s rejected.",
			      muds[i].pcname);
		      DIMDLOG(buf);
		      DIMDLOG(comm);
		    }
		  else
		    msg(comm, vict);
		  
		  continue;
		};
	      
	      scan = comm+1;
	      scan = one_dimd_argument(scan, fromname);
	      scan = one_dimd_argument(scan, fromkeyname);
	      scan = one_dimd_argument(scan, buf);
	      fromlevel = atoi(buf);
	      if (!*fromname || !*fromkeyname || !fromlevel)
		{
		  write_to_descriptor(muds[i].desc, "Your server isn't working properly.");
		  sprintf(buf, "%s[%s] didn't supply PC names or level.",
			  muds[i].formalname, muds[i].host);
		  DIMDLOG(buf);
		  hangup_on_a_mud(i);
		  break;
		};
	      
	      if (fromlevel < muds[i].min_level)
		sprintf(buf, "You must be at least %d level to use DIMD on %s.",
			muds[i].min_level, muds[i].formalname);
	      else {
		fromgodlevel = (fromlevel-muds[i].immort_level)
		  * muds[i].immort_level_mult;
		scan = one_lc_dimd_argument(scan, dcommand);
		switch(*dcommand)
		  {
		  case '#':
		    strcpy(muds[i].pcname, fromkeyname);
		    continue;
		    
		  case 'a':
		    switch(*(dcommand+1))
		      {
		      case 'g':
			sprintf(buf, "%s is now accepting remote gossips.",
				muds[i].formalname);
			REMOVE_BIT(muds[i].flags, DD_NOGOSSIP);
			break;
			
		      case 'm':
			sprintf(buf, "%s is now accepting remote muses.",
				muds[i].formalname);
			REMOVE_BIT(muds[i].flags, DD_NOMUSE);
			break;
			
		      case 't':
			sprintf(buf, "%s is now accepting remote thinks.",
				muds[i].formalname);
			REMOVE_BIT(muds[i].flags, DD_NOTHINK);
			break;
			
		      default:
			sprintf(buf, "Unknown accept command from %s.",
				muds[i].formalname);
		      };
		    DIMDLOG(buf);
		    continue;
		    
		  case 'r':
		    switch(*(dcommand+1))
		      {
		      case 'g':
			sprintf(buf, "%s is now refusing remote gossips.",
				muds[i].formalname);
			SET_BIT(muds[i].flags, DD_NOGOSSIP);
			break;
			
		      case 'm':
			sprintf(buf, "%s is now refusing remote muses.",
				muds[i].formalname);
			SET_BIT(muds[i].flags, DD_NOMUSE);
			break;
			
		      case 't':
			sprintf(buf, "%s is now refusing remote thinks.",
				muds[i].formalname);
			SET_BIT(muds[i].flags, DD_NOTHINK);
			break;
			
		      default:
			sprintf(buf, "Unknown refuse command from %s.",
				muds[i].formalname);
		      };
		    DIMDLOG(buf);
		    continue;
		    
		  case 'w':
		    sprintf(buf, "Who request from %s at %s served.",
			    fromname, muds[i].formalname);
		    DIMDLOG(buf);
/*
		    construct_who_list(buf, 39, NULL, fromgodlevel, scan);
*/		    
		    break;
		    
		  case 't':
	            scan = one_lc_dimd_argument(scan, toname);
		    while(isspace(*scan)) scan++;
		    
	            if (!(vict = get_char(toname))
			|| !dimd_can_see(fromgodlevel, vict))
		      strcpy(buf, "No char by that name.");
	            else
		      {
#if USE_COLOR
			sprintf(buf, "$kW%s $kMfrom $kW%s $kMtells you '%s'.",
				fromname, muds[i].formalname, scan);
#else
			sprintf(buf, "%s from %s tells you '%s'.",
				fromname, muds[i].formalname, scan);
#endif				
			cmsg(buf, vict, CLR_TELL);
			if (IS_SET(vict->pc->comm, COMM_AFK))
#if USE_COLOR
			  sprintf(buf, "$kMYou tell $kW%s$kM (who is AFK), '%s'",
				  PER(vict), scan);
#else
			  sprintf(buf, "You tell %s (who is AFK), '%s'",
				  PER(vict), scan);

#endif				  
			else
#if USE_COLOR
			  sprintf(buf, "$kMYou tell $kW%s$kM, '%s'",
				  PER(vict), scan);
#else
			  sprintf(buf, "You tell %s, '%s'",
				  PER(vict), scan);
#endif				  
		      };
		    break;
		    
		  case 'g':
		    if (!dimd_gossip)
		      {
			write_to_descriptor(muds[i].desc, "^DIMD^DIMD^110^rg\n\r");
			sprintf(buf, "%s is no longer accepting remote gossips.", muds[dimd_local_mud].formalname);
			break;
		      };
		    if (*(dcommand+1)=='g')
#if USE_COLOR
		      sprintf(buf, "$kW%s $kYfrom $kW%s $kYdimension gossips, '%s'",
			      fromname, muds[i].formalname, scan);
#else
		      sprintf(buf, "%s from %s dimension gossips, '%s'",
			      fromname, muds[i].formalname, scan);
#endif			      
		    else
#if USE_COLOR
		      sprintf(buf, "$kW%s $kYfrom $kW%s $kYgossips, '%s'",
			      fromname, muds[i].formalname, scan);
#else
		      sprintf(buf, "%s from %s gossips, '%s'",
			      fromname, muds[i].formalname, scan);
#endif			      
		    
		    for(d = descriptor_list; d; d = d->next)
		      if (!d->connected
			  && !IS_SET(d->character->pc->comm, COMM_NOGOSSIP)
			  && !check_soundproof(d->character))
			cmsg(buf, d->character, CLR_GOSSIP);
		    
#if USE_COLOR
		    sprintf(buf, "$kYYou gossip on $kW%s$kY, '%s'",
			    muds[dimd_local_mud].formalname, scan);
#else
		    sprintf(buf, "You gossip on %s, '%s'",
			    muds[dimd_local_mud].formalname, scan);

#endif			    
		    break;
		    
		  case 'm':
		    if (!dimd_muse)
		      {
			write_to_descriptor(muds[i].desc, "^DIMD^DIMD^110^rm\n\r");
			sprintf(buf, "%s is no longer accepting remote muses.", muds[dimd_local_mud].formalname);
			break;
		      };
		    
		    if (*(dcommand+1)=='g')
#if USE_COLOR
		      sprintf(buf, "$kW%s $kLfrom $kW%s $kLdimension muses, '%s'",
			      fromname, muds[i].formalname, scan);
#else
		      sprintf(buf, "%s from %s dimension muses, '%s'",
			      fromname, muds[i].formalname, scan);
#endif			      
		    else
#if USE_COLOR
		      sprintf(buf, "$kW%s $kLfrom $kW%s $kLmuses, '%s'",
			      fromname, muds[i].formalname, scan);
#else
		      sprintf(buf, "%s from %s muses, '%s'",
			      fromname, muds[i].formalname, scan);
#endif			      
		    for(d = descriptor_list; d; d = d->next)
		      if (!d->connected
			  && GetMaxLevel(d->character) >= LOW_IMMORTAL
			  && !IS_SET(d->character->pc->comm, COMM_NOMUSE))
			cmsg(buf, d->character, CLR_MUSE);
		    
#if USE_COLOR
		    sprintf(buf, "$kLYou muse on $kW%s$kL, '%s'",
			    muds[dimd_local_mud].formalname, scan);
#else
		    sprintf(buf, "You muse on %s, '%s'",
			    muds[dimd_local_mud].formalname, scan);
#endif
		    break;
		    
		  case '*':
		    if (!dimd_think)
		      {
			write_to_descriptor(muds[i].desc, "^DIMD^DIMD^110^rt\n\r");
			sprintf(buf, "%s is no longer accepting remote thinks.", muds[dimd_local_mud].formalname);
			break;
		      };
		    if (*(dcommand+1)=='g')
#if USE_COLOR
		      sprintf(buf, "$kW%s $kLfrom $kW%s $kLdimension thinks, '%s'",
			      fromname, muds[i].formalname, scan);
#else
		      sprintf(buf, "%s from %s dimension thinks, '%s'",
			      fromname, muds[i].formalname, scan);

#endif			      
		    else
#if USE_COLOR
		      sprintf(buf, "$kW%s $kLfrom $kW%s $kLthinks, '%s'",
			      fromname, muds[i].formalname, scan);
#else
		      sprintf(buf, "%s from %s thinks, '%s'",
			      fromname, muds[i].formalname, scan);

#endif			      
		    for(d = descriptor_list; d; d = d->next)
		      if (!d->connected
			  && GetMaxLevel(d->character) >= DEMIGOD
			  && !IS_SET(d->character->pc->comm, COMM_NOMUSE))
			cmsg(buf, d->character, CLR_THINK);
		    
#if USE_COLOR
		    sprintf(buf, "$kLYou think on $kW%s$kL, '%s'",
			    muds[dimd_local_mud].formalname, scan);
#else
		    sprintf(buf, "You think on %s, '%s'",
			    muds[dimd_local_mud].formalname, scan);

#endif			    
		    break;
		    
		  default:
#if USE_COLOR
		    sprintf(buf, "$kW%s $kRfrom $kW%s $kRissued invalid command '%s'.",
			    fromname, muds[i].formalname, dcommand);
#else
		    sprintf(buf, "%s from %s issued invalid command '%s'.",
			    fromname, muds[i].formalname, dcommand);
#endif			    
		    DIMDLOG(buf);
#if USE_COLOR
		    strcpy(buf, "$k+BRYour server isn't functioning properly.");
#else
		    strcpy(buf, "Your server isn't functioning properly.");
#endif		    
		  };
	      };
Ejemplo n.º 17
0
/*
 * Show's the bottom porition of the menu
 */
void show_menu_bottom(DESCRIPTOR_DATA *d)
{
    write_to_descriptor(d->descriptor, BLANK_MENU_LINE, d);
    write_to_descriptor(d->descriptor, "{w / |  -==================================================================-  |\r\n", d);
    write_to_descriptor(d->descriptor, "{w \\/________________________________________________________________________/{x\r\n", d);
}
Ejemplo n.º 18
0
/*
 * Show's the top portion of the menu
 */
void show_menu_top(DESCRIPTOR_DATA *d)
{
    write_to_descriptor(d->descriptor, "{w  _________________________________________________________________________\r\n", d);
    write_to_descriptor(d->descriptor, "{w /`                                                                        \\\r\n", d);
}
Ejemplo n.º 19
0
ErrnoError DescriptorHolder::Write(const char* data, size_t size, size_t* nwrite_out) {
  DCHECK(IsValid());
  return write_to_descriptor(fd_, data, size, nwrite_out);
}
Ejemplo n.º 20
0
/*
* Shows who is logged into the mud from the login menu.
*/
void show_login_who(DESCRIPTOR_DATA *d)
{
    char buf[MAX_STRING_LENGTH];
    DESCRIPTOR_DATA *dl;
    int col = 0;
    int count = 0;
    int total_count = 0;
    bool end_row = TRUE;

    show_menu_top(d);
    show_menu_header("Online Players", d);
    write_to_descriptor(d->descriptor, BLANK_MENU_LINE, d);
    write_to_descriptor(d->descriptor, "{w   |                            {G( {WImmortals {G){w                               |\r\n", d);
    write_to_descriptor(d->descriptor, BLANK_MENU_LINE, d);

    for (dl = descriptor_list; dl != NULL; dl = dl->next)
    {
        CHAR_DATA *ch;

        if (dl->connected != CON_PLAYING)
        {
            continue;
        }

        ch = (dl->original != NULL) ? dl->original : dl->character;

        if (!IS_IMMORTAL(ch) || ch->invis_level >= LEVEL_HERO || ch->incog_level >= LEVEL_HERO)
        {
            continue;
        }

        count++;
        col++;

        // Start a row?
        if (end_row)
        {
            write_to_descriptor(d->descriptor, "{w   |    ", d);
            end_row = FALSE;
        }

        sprintf(buf, "{g%-16s{x", ch->name);
        write_to_descriptor(d->descriptor, buf, d);

        // End a row?
        if (col % 4 == 0)
        {
            write_to_descriptor(d->descriptor, "{w|\r\n", d);
            end_row = TRUE;
        }
    }

    // Fill out the rest of the last row if it wasn't a full row
    while (col % 4 != 0)
    {
        write_to_descriptor(d->descriptor, "                ", d);
        col++;
    }

    if (count > 0 && end_row == FALSE)
    {
        // End that row
        write_to_descriptor(d->descriptor, "    {w|\r\n", d);
        write_to_descriptor(d->descriptor, BLANK_MENU_LINE, d);
    }
    else if (count > 0 && end_row == TRUE)
    {
        write_to_descriptor(d->descriptor, BLANK_MENU_LINE, d);
    }

    // Display if there are no immortals online.
    if (count == 0)
    {
        write_to_descriptor(d->descriptor, "{w   |    * {CThere are no immortals currently online.{w                          |\r\n", d);
        write_to_descriptor(d->descriptor, BLANK_MENU_LINE, d);
    }

    write_to_descriptor(d->descriptor, "{w   |                             {G( {WMortals {G){w                                |\r\n", d);
    write_to_descriptor(d->descriptor, BLANK_MENU_LINE, d);

    total_count += count;

    // The characters playing
    end_row = TRUE;
    count = 0;
    col = 0;

    for (dl = descriptor_list; dl != NULL; dl = dl->next)
    {
        CHAR_DATA *ch;

        if (dl->connected != CON_PLAYING)
        {
            continue;
        }

        ch = (dl->original != NULL) ? dl->original : dl->character;

        if (IS_IMMORTAL(ch))
        {
            continue;
        }

        count++;
        col++;

        // Start a row?
        if (end_row)
        {
            write_to_descriptor(d->descriptor, "{w   |    ", d);
            end_row = FALSE;
        }

        sprintf(buf, "{g%-16s{x", ch->name);
        write_to_descriptor(d->descriptor, buf, d);

        // End a row?
        if (col % 4 == 0)
        {
            write_to_descriptor(d->descriptor, "    {w|\r\n", d);
            end_row = TRUE;
        }

    }

    // Fill out the rest of the last row if it wasn't a full row
    while (col % 4 != 0)
    {
        write_to_descriptor(d->descriptor, "                ", d);
        col++;
    }

    if (count > 0 && end_row == FALSE)
    {
        // End that row
        write_to_descriptor(d->descriptor, "    {w|\r\n", d);
        write_to_descriptor(d->descriptor, BLANK_MENU_LINE, d);
    }
    else if (count > 0 && end_row == TRUE)
    {
        write_to_descriptor(d->descriptor, BLANK_MENU_LINE, d);
    }

    // Display if there are no mortals online.
    if (count == 0)
    {
        write_to_descriptor(d->descriptor, "{w   |    * {CThere are no mortals currently online.{w                            |\r\n", d);
        write_to_descriptor(d->descriptor, BLANK_MENU_LINE, d);
    }

    total_count += count;

    if (total_count > 0)
    {
        sprintf(buf, "{w   |    Total Players Online: %-3d                                           |\r\n", total_count);
        write_to_descriptor(d->descriptor, buf, d);
    }

    show_menu_bottom(d);

    return;
}
Ejemplo n.º 21
0
/*
* Show the credits to the login screen, this is a little hacky.  I would prefer to use the
* help system but it's tooled for CH's and down the line (in the string pager) has issues
* with descriptors on a a straight conversion of page_to_char.
*/
void show_login_credits(DESCRIPTOR_DATA *d)
{
    int space = 0;
    int x = 0;

    show_menu_top(d);
    show_menu_header("Credits", d);
    write_to_descriptor(d->descriptor, BLANK_MENU_LINE, d);

    // This line should dynamically space up to a version number
    writef(d, "{w   |    {G*{x {WDark Cloud{w %s (1998-2019)", VERSION);

    space = 43 - strlen(VERSION);

    for (x = 0; x < space; x++)
    {
        write_to_descriptor(d->descriptor, " ", d);
    }

    write_to_descriptor(d->descriptor, "|\r\n", d);

    write_to_descriptor(d->descriptor, "{w   |    {G*{x {WROM 2.4{w (1993-1998)                                               |\r\n", d);
    write_to_descriptor(d->descriptor, "{w   |          Russ Taylor, Gabrielle Taylor, Brian Moore                    |\r\n", d);
    write_to_descriptor(d->descriptor, "{w   |    {G*{x {WMerc DikuMud{w (1991-1993)                                          |\r\n", d);
    write_to_descriptor(d->descriptor, "{w   |          Michael Chastain, Michael Quan, Mitchel Tse                   |\r\n", d);

    write_to_descriptor(d->descriptor, "{w   |    {G*{x {WDikuMud{w (1993-1998)                                               |\r\n", d);
    write_to_descriptor(d->descriptor, "{w   |          Katja Nyboe, Tom Madsen, Hans Henrik Staerfeldt,              |\r\n", d);
    write_to_descriptor(d->descriptor, "{w   |          Michael Seifert, Sebastian Hammer                             |\r\n", d);

    write_to_descriptor(d->descriptor, BLANK_MENU_LINE, d);
    write_to_descriptor(d->descriptor, "{w   |    {G*{w Detailed additional credits can be viewed in game via the         |\r\n", d);
    write_to_descriptor(d->descriptor, "{w   |      credits command.  These additional credits include the names of   |\r\n", d);
    write_to_descriptor(d->descriptor, "{w   |      many who have contributed through the mud community over the      |\r\n", d);
    write_to_descriptor(d->descriptor, "{w   |      years where those contributions have been used here.              |\r\n", d);

    show_menu_bottom(d);

    return;
}
Ejemplo n.º 22
0
void send_mssp_data( DESCRIPTOR_DATA *d )
{
    if ( !d ) {
        bug( "%s: NULL d", __FUNCTION__ );
        return;
    }

    write_to_descriptor( d, "\r\nMSSP-REPLY-START\r\n", 0 );

    mssp_reply( d, "HOSTNAME", "%s", mssp_info->hostname );
    mssp_reply( d, "PORT", "%d", port );
    mssp_reply( d, "UPTIME", "%d", ( int ) mud_start_time );
    mssp_reply( d, "PLAYERS", "%d", player_count(  ) );
    mssp_reply( d, "CODEBASE", "%s", codebase );
    mssp_reply( d, "CONTACT", "%s", mssp_info->contact );
    mssp_reply( d, "CREATED", "%d", mssp_info->created );
    mssp_reply( d, "ICON", "%s", mssp_info->icon );
    mssp_reply( d, "LANGUAGE", "%s", mssp_info->language );
    mssp_reply( d, "LOCATION", "%s", mssp_info->location );
    mssp_reply( d, "MINIMUM AGE", "%d", mssp_info->minAge );
    mssp_reply( d, "NAME", "%s", sysdata.mud_name );
    mssp_reply( d, "WEBSITE", "%s", mssp_info->website );
    mssp_reply( d, "FAMILY", "%s", mssp_info->family );
    mssp_reply( d, "GENRE", "%s", mssp_info->genre );
    mssp_reply( d, "GAMEPLAY", "%s", mssp_info->gamePlay );
    mssp_reply( d, "GAMESYSTEM", "%s", mssp_info->gameSystem );
    mssp_reply( d, "INTERMUD", "%s", mssp_info->intermud );
    mssp_reply( d, "STATUS", "%s", mssp_info->status );
    mssp_reply( d, "SUBGENRE", "%s", mssp_info->subgenre );
    mssp_reply( d, "AREAS", "%d", top_area );
    mssp_reply( d, "HELPFILES", "%d", top_help );
    mssp_reply( d, "MOBILES", "%d", top_mob_index );
    mssp_reply( d, "OBJECTS", "%d", top_obj_index );
    mssp_reply( d, "ROOMS", "%d", top_room );
    mssp_reply( d, "RESETS", "%d", top_reset );
//   mssp_reply( d, "MUDPROGS", "%d", top_prog );
    mssp_reply( d, "CLASSES", "%d", MAX_CLASS );
    mssp_reply( d, "LEVELS", "%d", MAX_LEVEL );
    mssp_reply( d, "RACES", "%d", MAX_RACE );
    // mssp_reply( d, "SKILLS", "%d", num_skills );
    mssp_reply( d, "WORLDS", "%d", mssp_info->worlds );
    mssp_reply( d, "ANSI", "%d", mssp_info->ansi );
    mssp_reply( d, "MCCP", "%d", mssp_info->mccp );
    mssp_reply( d, "MCP", "%d", mssp_info->mcp );
    mssp_reply( d, "MSP", "%d", mssp_info->msp );
    mssp_reply( d, "SSL", "%d", mssp_info->ssl );
    mssp_reply( d, "MXP", "%d", mssp_info->mxp );
    mssp_reply( d, "PUEBLO", "%d", mssp_info->pueblo );
    mssp_reply( d, "VT100", "%d", mssp_info->vt100 );
    mssp_reply( d, "XTERM 256 COLORS", "%d", mssp_info->xterm256 );
    mssp_reply( d, "PAY TO PLAY", "%d", mssp_info->pay2play );
    mssp_reply( d, "PAY FOR PERKS", "%d", mssp_info->pay4perks );
    mssp_reply( d, "HIRING BUILDERS", "%d", mssp_info->hiringBuilders );
    mssp_reply( d, "HIRING CODERS", "%d", mssp_info->hiringCoders );
    mssp_reply( d, "ADULT MATERIAL", "%d", mssp_info->adultMaterial );
    mssp_reply( d, "MULTICLASSING", "%d", mssp_info->multiclassing );
    mssp_reply( d, "NEWBIE FRIENDLY", "%d", mssp_info->newbieFriendly );
    mssp_reply( d, "PLAYER CITIES", "%d", mssp_info->playerCities );
    mssp_reply( d, "PLAYER CLANSS", "%d", mssp_info->playerClans );
    mssp_reply( d, "PLAYER CRAFTING", "%d", mssp_info->playerCrafting );
    mssp_reply( d, "PLAYER GUILDS", "%d", mssp_info->playerGuilds );
    mssp_reply( d, "EQUIPMENT SYSTEM", "%s", mssp_info->equipmentSystem );
    mssp_reply( d, "MULTIPLAYING", "%s", mssp_info->multiplaying );
    mssp_reply( d, "PLAYERKILLING", "%s", mssp_info->playerKilling );
    mssp_reply( d, "QUEST SYSTEM", "%s", mssp_info->questSystem );
    mssp_reply( d, "ROLEPLAYING", "%s", mssp_info->roleplaying );
    mssp_reply( d, "TRAINING SYSTEM", "%s", mssp_info->trainingSystem );
    mssp_reply( d, "WORLD ORIGINALITY", "%s", mssp_info->worldOriginality );
    write_to_descriptor( d, "MSSP-REPLY-END\r\n", 0 );
}
Ejemplo n.º 23
0
/* Recover from a hotboot - load players */
void hotboot_recover( void )
{
   DESCRIPTOR_DATA *d = NULL;
   FILE *fp;
   char name[100];
   char host[MAX_STRING_LENGTH];
   int desc, room, dport, idle, dcompress, maxp = 0;
   bool fOld;

   fp = fopen( HOTBOOT_FILE, "r" );

   if( !fp )   /* there are some descriptors open which will hang forever then ? */
   {
      perror( "hotboot_recover: fopen" );
      bug( "%s", "Hotboot file not found. Exitting." );
      exit( 1 );
   }

   unlink( HOTBOOT_FILE ); /* In case something crashes - doesn't prevent reading */
   for( ;; )
   {
      d = NULL;

      fscanf( fp, "%d %d %d %d %d %s %s\n", &dcompress, &desc, &room, &dport, &idle, name, host );

      if( desc == -1 || feof( fp ) )
         break;

      if( !str_cmp( name, "maxp" ) || !str_cmp( host, "maxp" ) )
      {
         maxp = idle;
         continue;
      }

      /*
       * Write something, and check if it goes error-free 
       */
      if( !write_to_descriptor_old( desc, "\r\nThe Force swirls around you.\r\n", 0 ) )
      {
         close( desc ); /* nope */
         continue;
      }

      CREATE( d, DESCRIPTOR_DATA, 1 );
      CREATE( d->mccp, MCCP, 1 );
      d->next = NULL;
      d->descriptor = desc;
      d->connected = CON_GET_NAME;
      d->outsize = 2000;
      d->idle = 0;
      d->lines = 0;
      d->scrlen = 24;
      d->newstate = 0;
      d->prevcolor = 0x08;
      d->ifd = -1;
      d->ipid = -1;

      CREATE( d->outbuf, char, d->outsize );

      d->host = STRALLOC( host );
      d->port = dport;
      d->idle = idle;
#ifdef MCCP
      if( dcompress )
         write_to_buffer( d, compress2_on_str_2, 0 );
#endif
      LINK( d, first_descriptor, last_descriptor, next, prev );
      d->connected = CON_COPYOVER_RECOVER;   /* negative so close_socket will cut them off */
//      d->can_compress = dcompress;
//      if( d->can_compress )
//         compressStart( d );

      /*
       * Now, find the pfile 
       */
      fOld = load_char_obj( d, name, FALSE, TRUE );

      if( !fOld ) /* Player file not found?! */
      {
         write_to_descriptor( d, "\r\nSomehow, your character was lost during hotboot. Contact the immortals ASAP.\r\n", 0 );
         close_socket( d, FALSE );
      }
      else  /* ok! */
      {
         write_to_descriptor( d, "Suddenly, you remember nothing as the Force continues into the Galaxy.\r\n", 0 );
         d->character->in_room = get_room_index( room );
         if( !d->character->in_room )
            d->character->in_room = get_room_index( ROOM_VNUM_TEMPLE );

         /*
          * Insert in the char_list 
          */
         LINK( d->character, first_char, last_char, next, prev );

         char_to_room( d->character, d->character->in_room );
         act( AT_MAGIC, "You appear in a swirl of the Force!", d->character, NULL, NULL, TO_CHAR );
         act( AT_MAGIC, "$n appears in a swrrl of the Force!", d->character, NULL, NULL, TO_ROOM );
         d->connected = CON_PLAYING;
         if( ++num_descriptors > sysdata.maxplayers )
            sysdata.maxplayers = num_descriptors;
#ifdef AUTO_AUTH
         check_auth_state( d->character );   /* new auth */
#endif
      }
   }
   FCLOSE( fp );
   if( maxp > sysdata.maxplayers )
      sysdata.maxplayers = maxp;
   log_string( "Hotboot recovery complete." );
   return;
}
Ejemplo n.º 24
0
ErrnoError DescriptorHolder::WriteBuffer(const char_buffer_t& data, size_t* nwrite_out) {
  DCHECK(IsValid());
  return write_to_descriptor(fd_, data.data(), data.size(), nwrite_out);
}
Ejemplo n.º 25
0
/* Recover from a hotreboot - load players */
void hotreboot_recover()
{
	DESCRIPTOR_DATA *d;
	FILE *fp;
	char name[100];
	char host[MSL];
	long desc;
	bool fOld;

	fp = fopen(HOTREBOOT_FILE, "r");

	if(!fp)			/* there are some descriptors open which will hang forever then ? */
	{
		perror("hotreboot_recover:fopen");
		exit(1);
	}

/*	unlink (HOTREBOOT_FILE);  In case something crashes - doesn't prevent reading	*/

	for(;;)
	{
		fscanf(fp, "%li %s %s\n", &desc, name, host);
		if(desc == -1)
			break;

		/* Write something, and check if it goes error-free */
		if(!write_to_descriptor(desc, "\n\rRestoring from hotreboot...\n\r", 0))
		{
#ifdef WIN32
			closesocket(desc);

#else /*  */
			close(desc);	/* nope */
#endif /*  */
			continue;
		}

		d = alloc_perm(sizeof(DESCRIPTOR_DATA));
		init_descriptor(d, desc);	/* set up various stuff */

		d->host = str_dup(host);
		d->next = descriptor_list;
		descriptor_list = d;
		d->connected = CON_HOTREBOOT_RECOVER;	/* -15, so close_socket frees the char */


		/* Now, find the pfile */

		fOld = load_char_obj(d, name);

		if(!fOld)	/* Player file not found?! */
		{
			write_to_descriptor(desc, "\n\rSomehow, your character was lost in the hotreboot. Reconnect\n\r",
					    0);
			close_socket2(d, FALSE);
		}
		else		/* ok! */
		{
			/* Just In Case */
			if(!d->character->in_room)
				d->character->in_room = get_room_index(ROOM_VNUM_TEMPLE);

			/* Insert in the char_list */
			d->character->next = char_list;
			char_list = d->character;

			char_to_room(d->character, d->character->in_room);
			do_look(d->character, "");
			act("$n appears from the netherworld!", d->character, 0, 0, TO_ROOM);
			d->connected = CON_PLAYING;
		}

	}

	fclose(fp);
	olduptime = get_olduptime();

}
Ejemplo n.º 26
0
/*
* Renders the current login menu to the player.
*/
void show_login_menu(DESCRIPTOR_DATA *d)
{
    int x = 0;

    // This probably shouldn't happen but better safe than sorry on a high run method.
    if (d == NULL)
    {
        return;
    }

    char buf[MAX_STRING_LENGTH];
    bool ban_newbie = check_ban(d->host, BAN_NEWBIES);
    bool ban_all = check_ban(d->host, BAN_ALL);

    // The login menu header
    write_to_descriptor(d->descriptor, "\r\n", d);
    show_menu_top(d);
    show_menu_header("Login Menu", d);
    write_to_descriptor(d->descriptor, BLANK_MENU_LINE, d);

    // Column 1.1 - Create a new character option.  The option is disabled if the game is wizlocked
    // newlocked, if their host is banned all together or if they are newbie banned.
    if (settings.wizlock || settings.newlock || ban_newbie || ban_all)
    {
        sprintf(buf, "{w   |    {w({DN{w){Dew Character{x                                                     |\r\n");
    }
    else
    {
        sprintf(buf, "{w   |    {w(%sN{w)%sew Character{x                                                     |\r\n",
            settings.login_menu_light_color,
            settings.login_menu_dark_color);
    }

    write_to_descriptor(d->descriptor, buf, d);

    // Column 2.1 - Play existing character, the login option is disabled if the player is banned or the game is wizlocked.
    if (ban_all || settings.wizlock)
    {
        sprintf(buf, "{w   |    {w({DP{w){Dlay Existing Character{x                                           |\r\n");
    }
    else
    {
        sprintf(buf, "{w   |    {w(%sP{w)%slay Existing Character{x                                           |\r\n",
            settings.login_menu_light_color,
            settings.login_menu_dark_color);
    }

    write_to_descriptor(d->descriptor, buf, d);

    // Column 3.1 - Who is currently online
    if (settings.login_who_list_enabled)
    {
        sprintf(buf, "{w   |    {w(%sW{w)%sho is on now?{w                                                    |\r\n",
            settings.login_menu_light_color,
            settings.login_menu_dark_color);

        write_to_descriptor(d->descriptor, buf, d);
    }

    // Column 4.1 - Random name generator
    sprintf(buf, "{w   |    {w(%sR{w)%sandom Name Generator{w                                             |\r\n",
        settings.login_menu_light_color,
        settings.login_menu_dark_color);

    write_to_descriptor(d->descriptor, buf, d);

    // Column 5.1 - Credits
    sprintf(buf, "{w   |    {w(%sC{w)%sredits{w                                                           |\r\n",
        settings.login_menu_light_color,
        settings.login_menu_dark_color);

    write_to_descriptor(d->descriptor, buf, d);

    // Column 6.1 & 6.2 - Quit and System Time
    sprintf(buf, "{w   |    {w(%sQ{w)%suit{w                                                              |\r\n",
        settings.login_menu_light_color,
        settings.login_menu_dark_color);

    write_to_descriptor(d->descriptor, buf, d);

    // Column 7.1 - Prompt
    write_to_descriptor(d->descriptor, BLANK_MENU_LINE, d);
    sprintf(buf, "{w   |     {WYour selection? {w->                                                 |\r\n");
    write_to_descriptor(d->descriptor, buf, d);

    show_menu_bottom(d);

    // Since we've wrapped the menu in an ASCII graphic that looks like a parchment, we'll need to
    // reposition the cursor to move up to "Your selection? ->".. then after the selection we'll
    // need to move the cursor back down before displaying whatever we're going to display.

    // Move up 4 rows, then to the right 28
    sprintf(buf, "%s%s%s%s", UP, UP, UP, UP);

    // Move to the right 28
    for (x = 0; x < 28; x++)
    {
        strcat(buf, RIGHT);
    }

    write_to_descriptor(d->descriptor, buf, d);

    return;
}
Ejemplo n.º 27
0
void do_hotreboot(CHAR_DATA * ch, char *argument)
{
	FILE *fp;
	DESCRIPTOR_DATA *d, *d_next;
	char buf[100], buf2[100], buf3[100];

	fp = fopen(HOTREBOOT_FILE, "w");

	if(!fp)
	{
		send_to_char("hotreboot file not writeable, aborted.\n\r", ch);
		fpReserve = fopen(NULL_FILE, "r");
		perror("do_hotreboot:fopen");
		return;
	}

	if(argument && !str_cmp(argument,"INFINITE LOOP!"))
	{
		sprintf(buf, "[HotReboot by Godwars - Infinite Loop!]\n\r");
	}
	if(argument && argument[0] != '\0')
	{
		sprintf(buf, "[HotReboot by Godwars - Crash!]\n\r");
	}
	else
	{
		do_restore(ch, "all");
		prepare_players();
		write_kingdoms();
		sprintf(buf, "[HotReboot by %s - You will automatically reconnect]\n\r", ch->name);
	}

	/* For each playing descriptor, save its state */
	for(d = descriptor_list; d; d = d_next)
	{
		CHAR_DATA *och = CH(d);

		d_next = d->next;	/* We delete from the list , so need to save this */

		if(!d->character || d->connected != CON_PLAYING || och->level == 1)	/* drop those logging on */
		{
			write_to_descriptor(d->descriptor, "\n\rSorry, we are rebooting. Come back in a few minutes.\n\r",
					    0);
			close_socket2(d, FALSE);	/* throw'em out */
		}
		else
		{
			fprintf(fp, "%li %s %s\n", d->descriptor, och->name, d->host);
			save_char_obj(och);
			write_to_descriptor(d->descriptor, buf, 0);
		}
	}

	fprintf(fp, "-1\n\n");
	fclose(fp);

	if((fp = fopen(OLDUPTIME_FILE, "w")) != 0)
	{
		fprintf(fp, "%.0f\n", get_uptime());
		fclose(fp);
	}
	else
	{
		unlink(OLDUPTIME_FILE);
	}

	fclose(fpReserve);

	/* exec - descriptors are inherited */

	sprintf(buf, "%li", port);
	sprintf(buf2, "%li", control);
	sprintf(buf3, "%li", rebootnum);
#ifndef WIN32
	execl(EXE_FILE, "Merc", buf, "hotreboot", buf2, buf3, (char *) 0);
#endif
	/* Failed - sucessful exec will not return */

	perror("do_hotreboot: execl");
	send_to_char("hotreboot FAILED!\n\r", ch);

	/* Here you might want to reopen fpReserve */
	fpReserve = fopen(NULL_FILE, "r");
}
Ejemplo n.º 28
0
void mssp_start(DESCRIPTOR_DATA * t)
{char buf[1024]; int i;

#if 0
const char mssp_str[] = {IAC,SB,MSSP,
	MSSP_VAR,'P','L','A','Y','E','R','S',MSSP_VAL,'0',
	MSSP_VAR,'N','A','M','E',MSSP_VAL,'V','i','r','t','u','s','t','a','n',' ','M','U','D',
	IAC,SE,'\0'};
#endif

i=sprintf(buf,
"%c%c%c%cPLAYERS%c%i%cNAME%cZerkalo MUD%cUPTIME%c%li%cCRAWL_DELAY%c-1\
%cHOSTNAME%czerkalo.kharkov.org\
%cPORT%c4000\
%cPORT%c4000\
%cCODEBASE%cCircleMUD/Byliny\
%cCONTACT%[email protected]\
%cCREATED%c2012\
%cIP%c217.12.220.191\
%cLANGUAGE%cRussian\
%cLOCATION%cUkraine\
%cMINIMUM AGE%c0\
%cWEBSITE%chttp://zerkalo.kharkov.org\
%cFAMILY%cDikuMUD\
%cAREAS%c%i\
%cMOBILES%c%i\
%cOBJECTS%c%i\
%cROOMS%c%i\
%cCLASSES%c15\
%cRACES%c6\
%cANSI%c1\
%cMCCP%c1\
%cMCP%c0\
%cMSP%c0\
%cMXP%c0\
%cPUEBLO%c0\
%cHIRING BUILDERS%c1\
%cPLAYER CLANS%c1\
%cWORLD ORIGINALITY%c1\
%c%c",
IAC,SB,MSSP,MSSP_VAR,MSSP_VAL,total_players,MSSP_VAR,MSSP_VAL,MSSP_VAR,MSSP_VAL,(long int)boot_time,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,99 /*statistic_zones*/,
MSSP_VAR,MSSP_VAL,1662 /*statistic_mobs*/,
MSSP_VAR,MSSP_VAL,912 /*statistic_objs*/,
MSSP_VAR,MSSP_VAL,3599 /*statistic_rooms*/,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
MSSP_VAR,MSSP_VAL,
IAC,SE);

// printf("MSSP total_players %i\n",total_players);

write_to_descriptor(t->descriptor, buf, strlen(buf));
}
Ejemplo n.º 29
0
/*  Warm reboot stuff, gotta make sure to thank Erwin for this :) */
void do_hotboot( CHAR_DATA * ch, const char *argument )
{
   FILE *fp;
   CHAR_DATA *victim = NULL;
   DESCRIPTOR_DATA *d, *de_next;
   char buf[100], buf2[100], buf3[100];
   extern int control;
   int count = 0;
   bool found = FALSE;

   for( d = first_descriptor; d; d = d->next )
   {
      if( ( d->connected == CON_PLAYING
            || d->connected == CON_EDITING )
          && ( victim = d->character ) != NULL && !IS_NPC( victim )
          && victim->in_room && victim->fighting && victim->top_level >= 1 && victim->top_level <= MAX_LEVEL )
      {
         found = TRUE;
         count++;
      }
   }

   if( found )
   {
      ch_printf( ch, "Cannot hotboot at this time. There are %d combats in progress.\r\n", count );
      return;
   }

   found = FALSE;
   for( d = first_descriptor; d; d = d->next )
   {
      if( d->connected == CON_EDITING && d->character )
      {
         found = TRUE;
         break;
      }
   }

   if( found )
   {
      send_to_char( "Cannot hotboot at this time. Someone is using the line editor.\r\n", ch );
      return;
   }

   sprintf( log_buf, "Hotboot initiated by %s.", ch->name );
   log_string( log_buf );

   fp = fopen( HOTBOOT_FILE, "w" );

   if( !fp )
   {
      send_to_char( "Hotboot file not writeable, aborted.\r\n", ch );
      bug( "Could not write to hotboot file: %s. Hotboot aborted.", HOTBOOT_FILE );
      perror( "do_copyover:fopen" );
      return;
   }

   /*
    * And this one here will save the status of all objects and mobs in the game.
    * * This really should ONLY ever be used here. The less we do stuff like this the better.
    */
   save_world( ch );

#ifdef OLC_SHUTTLE
   {
      SHUTTLE_DATA *tshuttle;

      for( tshuttle = first_shuttle; tshuttle; tshuttle = tshuttle->next )
         save_shuttle( tshuttle );
   }
#endif

   log_string( "Saving player files and connection states...." );
   if( ch && ch->desc )
      write_to_descriptor( ch->desc, "\033[0m", 0 );
   sprintf( buf, "\r\nYou feel a great disturbance in the Force." );
   /*
    * For each playing descriptor, save its state 
    */
   for( d = first_descriptor; d; d = de_next )
   {
      CHAR_DATA *och = CH( d );

      de_next = d->next;   /* We delete from the list , so need to save this */
      if( !d->character || d->connected < CON_PLAYING )  /* drop those logging on */
      {
         write_to_descriptor( d, "\r\nSorry, we are rebooting. Come back in a few minutes.\r\n", 0 );
         close_socket( d, FALSE );  /* throw'em out */
      }
      else
      {
/* 			For test purposes
			flush_buffer(d, TRUE);*/
         fprintf( fp, "%d %d %d %d %d %s %s\n", d->can_compress, d->descriptor, och->in_room->vnum, d->port, d->idle, och->name, d->host );
         /*
          * One of two places this gets changed 
          */
         och->pcdata->hotboot = TRUE;
         save_char_obj( och );
         write_to_descriptor( d, buf, 0 );
         compressEnd( d );
      }
   }

   fprintf( fp, "%s", "-1" );
   FCLOSE( fp );

#ifdef IMC
   imc_hotboot(  );
#endif

   /*
    * added this in case there's a need to debug the contents of the various files 
    */
   if( argument && !str_cmp( argument, "debug" ) )
   {
      log_string( "Hotboot debug - Aborting before execl" );
      return;
   }

   log_string( "Executing hotboot...." );

   /*
    * exec - descriptors are inherited 
    */
   snprintf( buf, 100, "%d", port );
   snprintf( buf2, 100, "%d", control );
#ifdef IMC
   if( this_imcmud )
      snprintf( buf3, 100, "%d", this_imcmud->desc );
   else
      strncpy( buf3, "-1", 100 );
#else
   strncpy( buf3, "-1", 100 );
#endif

   dlclose( sysdata.dlHandle );
   execl( EXE_FILE, "swreality", buf, "hotboot", buf2, buf3, ( char * )NULL );

   /*
    * Failed - sucessful exec will not return 
    */
   perror( "do_hotboot: execl" );
   sysdata.dlHandle = dlopen( NULL, RTLD_LAZY );
   if( !sysdata.dlHandle )
   {
	bug( "%s", "FATAL ERROR: Unable to reopen system executable handle!" );
	exit( 1 );
   }
   bug( "%s", "Hotboot execution failed!!" );
   send_to_char( "Hotboot FAILED!\r\n", ch );
}
Ejemplo n.º 30
0
int
process_input (DESCRIPTOR_DATA * t)
{
  int sofar;
  int thisround;
  int begin;
  int squelch;
  int i;
  int k;
  int flag;
  char tmp[MAX_STRING_LENGTH + 100];
  char buffer[MAX_STRING_LENGTH + 100];

  sofar = 0;
  flag = 0;
  begin = strlen (t->buf);

  /* Read in some stuff */
  do
    {
      if ((thisround = read (t->hSocketFD, t->buf + begin + sofar,
			     MAX_INPUT_LENGTH - (begin + sofar) - 1)) > 0)
	sofar += thisround;
      else if (thisround < 0)
	if (errno != EWOULDBLOCK)
	  {
	    return -1;
	  }
	else
	  break;
      else
	{
	  return -1;
	}
    }
  while (!ISNEWL (*(t->buf + begin + sofar - 1)));

  *(t->buf + begin + sofar) = 0;

  if (!IS_SET (t->edit_mode, MODE_DONE_EDITING))
    {
      ve_process (t, t->buf);	/* Editor subsystem call */
      *t->buf = '\0';		/* This may cause some data to be lost if */
      return (0);		/* chars are typed after @ & before processing */
    }

  /* if no newline is contained in input, return without proc'ing */
  for (i = begin; !ISNEWL (*(t->buf + i)); i++)
    if (!*(t->buf + i))
      return (0);

  /* input contains 1 or more newlines; process the stuff */
  for (i = 0, k = 0; *(t->buf + i);)
    {
      if (!ISNEWL (*(t->buf + i)) && !(flag = (k >= (MAX_INPUT_LENGTH - 2))))
	if (*(t->buf + i) == '\b')	/* backspace */
	  if (k)		/* more than one char ? */
	    {
	      i++;
	    }
	  else
	    i++;		/* no or just one char.. Skip backsp */
	else
	  /* KILLER CDR:  $$ problem here. */
	if (isascii (*(t->buf + i)) && isprint (*(t->buf + i)))
	  {
	    *(tmp + k) = *(t->buf + i);

	    k++;
	    i++;
	  }
	else
	  i++;
      else
	{
	  *(tmp + k) = 0;
	  if (*tmp == '!')
	    strcpy (tmp, t->last_input);
	  else
	    strcpy (t->last_input, tmp);

	  write_to_q (tmp, &t->input);

	  if (t->snoop.snoop_by && t->snoop.snoop_by->desc != NULL
	      && !IS_NPC (t->snoop.snoop_by))
	    {
	      write_to_q ("% ", &t->snoop.snoop_by->desc->output);
	      write_to_q (tmp, &t->snoop.snoop_by->desc->output);
	      write_to_q ("\n\r", &t->snoop.snoop_by->desc->output);
	    }

	  if (flag)
	    {
	      sprintf (buffer, "Line too long. Truncated to:\n\r%s\n\r", tmp);
	      if (write_to_descriptor (t, buffer) < 0)
		return (-1);

	      /* skip the rest of the line */
	      for (; !ISNEWL (*(t->buf + i)); i++);
	    }

	  /* find end of entry */
	  for (; ISNEWL (*(t->buf + i)); i++);

	  /* squelch the entry from the buffer */
	  for (squelch = 0;; squelch++)
	    if ((*(t->buf + squelch) = *(t->buf + i + squelch)) == '\0')
	      break;
	  k = 0;
	  i = 0;
	}
    }

  return (1);
}