Example #1
0
/* Returns TRUE if this character name would be acceptable for a
 * new player.
 * Returns FALSE if it fails any checks, including being an
 * already existing character or mob, an illegal name, banned, etc.
 */
int acceptable_name(const char *name)
{
    char                                    tmp_name[20] = "\0\0\0";
    struct char_file_u                      tmp_store;
    struct char_data                        tmp_char;

    if (!valid_parse_name(name, tmp_name))
	return FALSE;
    if (check_playing(NULL, tmp_name))
	return FALSE;
    /*
     * We don't check ValidPlayer here 
     */
    if (fread_char(tmp_name, &tmp_store, &tmp_char) > -1)
	return FALSE;
    if (load_char(tmp_name, &tmp_store) > -1)
	return FALSE;
    if (already_mob_name(tmp_name))
	return FALSE;
    if (banned_name(tmp_name))
	return FALSE;

    return TRUE;
}
Example #2
0
void do_finger( CHAR_DATA *ch, char *argument )
{
    char arg[MAX_INPUT_LENGTH];
    char buf[MAX_STRING_LENGTH];
    CHAR_DATA *victim;
    FILE *fp;
    bool fOld;

    one_argument( argument, arg );

    if ( arg[0] == '\0' )
    {
	send_to_char( "Finger whom?\n\r", ch );
	return;
    }

    if ( ( victim = get_char_world( ch, arg ) ) != NULL)
    {
	if (!IS_NPC(victim))
	{
	    act( "$N is on right now!", ch, NULL, victim, TO_CHAR );
	    return;
	}
    }

    victim = new_char();
    victim->pcdata = new_pcdata();
    fOld = FALSE;
    
    sprintf( buf, "%s%s", PLAYER_DIR, capitalize( arg ) );
    if ( ( fp = fopen( buf, "r" ) ) != NULL )
    {
	int iNest;

	for ( iNest = 0; iNest < MAX_NEST; iNest++ )
	    rgObjNest[iNest] = NULL;

	fOld = TRUE;
	for ( ; ; )
	{
	    char letter;
	    char *word;

	    letter = fread_letter( fp );
	    if ( letter == '*' )
	    {
		fread_to_eol( fp );
		continue;
	    }

	    if ( letter != '#' )
	    {
		bug( "Load_char_obj: # not found.", 0 );
		break;
	    }

	    word = fread_word( fp );
	    if      ( !str_cmp( word, "PLAYER" ) ) fread_char( victim, fp );
	    else if ( !str_cmp( word, "OBJECT" ) ) break;
	    else if ( !str_cmp( word, "O"      ) ) break;
	    else if ( !str_cmp( word, "PET"    ) ) break;
	    else if ( !str_cmp( word, "END"    ) ) break;
	    else
	    {
		bug( "Load_char_obj: bad section.", 0 );
		break;
	    }
	}
	fclose( fp );
    }
    if ( !fOld )
    {
	send_to_char("No player by that name exists.\n\r",ch);
	free_pcdata(victim->pcdata);
	free_char(victim);
	return;
    }
    if ( (victim->level > LEVEL_HERO) && (victim->level > ch->level) )
    {
	send_to_char("The gods wouldn't like that.\n\r",ch);
	free_pcdata(victim->pcdata);
	free_char(victim);
	return;
    }
    sprintf(buf,"%s last logged off on %s",
	victim->name, (char *) ctime(&victim->llogoff));
    send_to_char(buf,ch);
    free_pcdata(victim->pcdata);
    free_char(victim);
    return;
}
Example #3
0
/*
 * Load a char and inventory into a new ch structure.
 */
bool load_char_obj( DESCRIPTOR_DATA *d, char *name )
{
    extern char      *daPrompt;
           FILE      *fp;
	   CHAR_DATA *ch;
	   char       strsave [ MAX_INPUT_LENGTH ];
	   bool       found;
           char       sorry_player [] =
	     "********************************************************\r\n"
	     "** One or more of the critical fields in your player  **\r\n"
	     "** file were corrupted since you last played.  Please **\r\n"
	     "** contact an administrator or programmer to          **\r\n"
	     "** investigate the recovery of your characters.       **\r\n"
	     "********************************************************\r\n";
           char       sorry_object [] =
	     "********************************************************\r\n"
	     "** One or more of the critical fields in your player  **\r\n"
	     "** file were corrupted leading to the loss of one or  **\r\n"
	     "** more of your possessions.                          **\r\n"
	     "********************************************************\r\n";


    ch					= new_character( TRUE );

    d->character			= ch;
    ch->desc				= d;
    ch->name				= str_dup( name );
    ch->pcdata->prompt                  = str_dup( daPrompt );
    ch->last_note                       = 0;
    ch->act				= PLR_BLANK
					| PLR_COMBINE
					| PLR_PROMPT;
    ch->pcdata->pwd			= str_dup( "" );
    ch->pcdata->bamfin			= str_dup( "" );
    ch->pcdata->bamfout			= str_dup( "" );
    ch->pcdata->immskll			= str_dup( "" );
    ch->pcdata->title			= str_dup( "" );
    ch->pcdata->perm_str		= 13;
    ch->pcdata->perm_int		= 13; 
    ch->pcdata->perm_wis		= 13;
    ch->pcdata->perm_dex		= 13;
    ch->pcdata->perm_con		= 13;
    ch->pcdata->condition[COND_THIRST]	= 48;
    ch->pcdata->condition[COND_FULL]	= 48;
    ch->pcdata->pagelen                 = 20;

    ch->pcdata->switched                = FALSE;

    found = FALSE;
    fclose( fpReserve );

    /* parsed player file directories by Yaz of 4th Realm */
    /* decompress if .gz file exists - Thx Alander */
    sprintf( strsave, "%s%s%s%s%s", PLAYER_DIR, initial( ch->name ),
	    "/", capitalize( name ), ".gz" );
    if ( ( fp = fopen( strsave, "r" ) ) )
    {
        char       buf     [ MAX_STRING_LENGTH ];

	fclose( fp );
	sprintf( buf, "gzip -dfq %s", strsave );
	system( buf );
    }

    sprintf( strsave, "%s%s%s%s", PLAYER_DIR, initial( ch->name ),
	    "/", capitalize( name ) );
    if ( ( fp = fopen( strsave, "r" ) ) )
    {
	char buf[ MAX_STRING_LENGTH ];
	int iNest;

	for ( iNest = 0; iNest < MAX_NEST; iNest++ )
	    rgObjNest[iNest] = NULL;

	found = TRUE;
	for ( ; ; )
	{
	    char *word;
	    char  letter;
	    int   status;

	    letter = fread_letter( fp );
	    if ( letter == '*' )
	    {
		fread_to_eol( fp );
		continue;
	    }

	    if ( letter != '#' )
	    {
		bug( "Load_char_obj: # not found.", 0 );
		break;
	    }

	    word = fread_word( fp, &status );

	    if ( !str_cmp( word, "PLAYER" ) )
	    {
	        if ( fread_char ( ch, fp ) )
		{
		    sprintf( buf,
			    "Load_char_obj:  %s section PLAYER corrupt.\r\n",
			    name );
		    bug( buf, 0 );
		    write_to_buffer( d, sorry_player, 0 );

		    /* 
		     * In case you are curious,
		     * it is ok to leave ch alone for close_socket
		     * to free.
		     * We want to now kick the bad character out as
		     * what we are missing are MANDATORY fields.  -Kahn
		     */
		    SET_BIT( ch->act, PLR_DENY );
		    return TRUE;
		}
	    }
	    else if ( !str_cmp( word, "OBJECT" ) )
	    {
	        if ( !fread_obj  ( ch, fp ) )
		{
		    sprintf( buf,
			    "Load_char_obj:  %s section OBJECT corrupt.\r\n",
			    name );
		    bug( buf, 0 );
		    write_to_buffer( d, sorry_object, 0 );
		    return FALSE;
		}
	    }
	    else if ( !str_cmp( word, "END"    ) ) break;
	    else
	    {
		bug( "Load_char_obj: bad section.", 0 );
		break;
	    }
	} /* for */

	fclose( fp );
    }

    fpReserve = fopen( NULL_FILE, "r" );
    return found;
}
Example #4
0
/*
 * Load a char and inventory into a new ch structure.
 */
bool load_char_obj( struct descriptor_data * d, const char * name )
{
  FILE      *fp;
  struct char_data *ch;
  char       strsave [ MAX_INPUT_LENGTH ];
  bool       found;
  char       sorry_player [] =
    "********************************************************\n\r"
    "** One or more of the critical fields in your player  **\n\r"
    "** file were corrupted since you last played.  Please **\n\r"
    "** contact an administrator or programmer to          **\n\r"
    "** investigate the recovery of your characters.       **\n\r"
    "********************************************************\n\r";
  char       sorry_object [] =
    "********************************************************\n\r"
    "** One or more of the critical fields in your player  **\n\r"
    "** file were corrupted leading to the loss of one or  **\n\r"
    "** more of your possessions.                          **\n\r"
    "********************************************************\n\r";
  char       sorry_alias [] =
    "********************************************************\n\r"
    "** One or more of the critical fields in your player  **\n\r"
    "** file were corrupted leading to the loss of one or  **\n\r"
    "** more of your aliases.                              **\n\r"
    "********************************************************\n\r";
  
  ch  				= new_character( TRUE );
  
  d->character			= ch;
  GET_DESC(ch)			= d;
  ch->player.name   = str_dup( name );
  /*
  ch->pcdata->prompt                  = str_dup( daPrompt );
  ch->last_note                       = 0;
  */
  strcpy( GET_PASSWD(ch), "" );
  POOFIN(ch)			= str_dup( "" );
  POOFOUT(ch)			= str_dup( "" );
  GET_TITLE(ch)			= str_dup( "" );
  GET_STR(ch)			= 10;
  GET_ADD(ch)			= 10; 
  GET_INT(ch)			= 10; 
  GET_WIS(ch)			= 10; 
  GET_DEX(ch)			= 10; 
  GET_CON(ch)			= 10; 
  GET_CHA(ch)			= 10; 
  GET_WILL(ch)			= 10; 
  GET_COND(ch, DRUNK)	= 48;
  GET_COND(ch, FULL)	= 48;
  GET_COND(ch, THIRST)	= 48;
  GET_COND(ch, TIRED)	= 48;
  
  // ch->pcdata->switched                = FALSE;
  
  found = FALSE;
  fclose( fpReserve );
  
  /* parsed player file directories by Yaz of 4th Realm */
  /* decompress if .gz file exists - Thx Alander */
  sprintf( strsave, "%s/%s/%s%s", PLAYER_DIR,
           player_dir( GET_NAME(ch) ),
           capitalize( GET_NAME(ch) ), ".gz" );
  
    if ( ( fp = fopen( strsave, "r" ) ) ) {
      char       buf     [ MAX_STRING_LENGTH ];
      
      fclose( fp );
      sprintf( buf, "gzip -dfq %s", strsave );
      system( buf );
    }

    sprintf( strsave, "%s/%s/%s", PLAYER_DIR,
             player_dir( GET_NAME(ch) ),
             capitalize( GET_NAME(ch) ) );

    if ( ( fp = fopen( strsave, "r" ) ) ) {
	char buf[ MAX_STRING_LENGTH ];
	int iNest;

	for ( iNest = 0; iNest < MAX_NEST; iNest++ )
	    rgObjNest[iNest] = NULL;

	found = TRUE;
	for ( ; ; )
	{
	    char *word;
	    char  letter;
	    int   status;

	    letter = fread_letter( fp );
	    if ( letter == '*' )
	    {
		fread_to_eol( fp );
		continue;
	    }

	    if ( letter != '#' )
	    {
              log( "Load_char_obj: # not found." );
              break;
	    }

	    word = fread_word_stat( fp, &status );

	    if ( !str_cmp( word, "PLAYER" ) )
	    {
	        if ( fread_char ( ch, fp ) )
		{
		    sprintf( buf,
			    "Load_char_obj:  %s section PLAYER corrupt.\n\r",
			    name );
		    log( buf );
		    SEND_TO_Q( sorry_player, d );

		    /* 
		     * In case you are curious,
		     * it is ok to leave ch alone for close_socket
		     * to free.
		     * We want to now kick the bad character out as
		     * what we are missing are MANDATORY fields.  -Kahn
		     */
		    SET_BIT( PRF_FLAGS(ch), PLR_DELETED );
		    return TRUE;
		}
	    }
	    else if ( !str_cmp( word, "OBJECT" ) )
	    {
	        if ( !fread_obj_char( ch, fp ) )
		{
		    sprintf( buf,
			    "Load_char_obj:  %s section OBJECT corrupt.\n\r",
			    name );
		    log( buf );
		    SEND_TO_Q( sorry_object, d );
		    return FALSE;
		}
	    }
	    else if ( !str_cmp( word, "ALIAS"    ) ) {
              if ( !fread_alias( ch, fp ) )
              {
                sprintf( buf,
                         "Load_char_obj: %s section ALIAS corrupt.\n\r",
                         name );
                log( buf );
                SEND_TO_Q( sorry_alias, d );
                return FALSE;
              }
            }
	    else if ( !str_cmp( word, "END"    ) ) break;
	    else
	    {
		log( "Load_char_obj: bad section." );
		break;
	    }
	} /* for */

	fclose( fp );
    }

    fpReserve = fopen( NULL_FILE, "r" );

    if ( found )
      rent_adjust( d->character );
    
    return found;
}
Example #5
0
/*
 * Load a char and inventory into a new ch structure.
 */
bool load_char_obj( DESCRIPTOR_DATA *d, char *name )
{
    static PC_DATA pcdata_zero;
    char strsave[MAX_INPUT_LENGTH];
    char buf [MAX_STRING_LENGTH];
    CHAR_DATA *ch;
    FILE *fp;
    bool found;

    if ( char_free == NULL )
    {
	ch				= alloc_perm( sizeof(*ch) );
    }
    else
    {
	ch				= char_free;
	char_free			= char_free->next;
    }
    clear_char( ch );

    if ( pcdata_free == NULL )
    {
	ch->pcdata			= alloc_perm( sizeof(*ch->pcdata) );
    }
    else
    {
	ch->pcdata			= pcdata_free;
	pcdata_free			= pcdata_free->next;
    }
    *ch->pcdata				= pcdata_zero;

    d->character			= ch;
    ch->desc				= d;
    ch->name				= str_dup( name );
    ch->prompt                          = str_dup( "<%hhp %mm %vmv> " );
    ch->last_note                       = 0;
    ch->act				= PLR_BLANK
					| PLR_COMBINE
					| PLR_PROMPT;
    ch->pcdata->pwd			= str_dup( "" );
    ch->pcdata->bamfin			= str_dup( "" );
    ch->pcdata->bamfout			= str_dup( "" );
    ch->pcdata->title			= str_dup( "" );
    ch->pcdata->perm_str		= 13;
    ch->pcdata->perm_int		= 13; 
    ch->pcdata->perm_wis		= 13;
    ch->pcdata->perm_dex		= 13;
    ch->pcdata->perm_con		= 13;
    ch->pcdata->condition[COND_THIRST]	= 48;
    ch->pcdata->pagelen                 = 20;
    ch->pcdata->condition[COND_FULL]	= 48;

    found = FALSE;
    fclose( fpReserve );

    /* parsed player file directories by Yaz of 4th Realm */
    /* decompress if .gz file exists - Thx Alander */
#if !defined(macintosh) && !defined(MSDOS)
    sprintf( strsave, "%s%s%s%s%s", PLAYER_DIR, initial( ch->name ),
	    "/", capitalize( name ), ".gz" );
    if ( ( fp = fopen( strsave, "r" ) ) != NULL )
    {
	fclose( fp );
	sprintf( buf, "gzip -dfq %s", strsave );
	system( buf );
    }
#endif

#if !defined(machintosh) && !defined(MSDOS)
    sprintf( strsave, "%s%s%s%s", PLAYER_DIR, initial( ch->name ),
	    "/", capitalize( name ) );
#else
    sprintf( strsave, "%s%s", PLAYER_DIR, capitalize( name ) );
#endif
    if ( ( fp = fopen( strsave, "r" ) ) != NULL )
    {
	int iNest;

	for ( iNest = 0; iNest < MAX_NEST; iNest++ )
	    rgObjNest[iNest] = NULL;

	found = TRUE;
	for ( ; ; )
	{
	    char letter;
	    char *word;

	    letter = fread_letter( fp );
	    if ( letter == '*' )
	    {
		fread_to_eol( fp );
		continue;
	    }

	    if ( letter != '#' )
	    {
		bug( "Load_char_obj: # not found.", 0 );
		break;
	    }

	    word = fread_word( fp );
	    if      ( !str_cmp( word, "PLAYER" ) ) fread_char ( ch, fp );
	    else if ( !str_cmp( word, "OBJECT" ) ) fread_obj  ( ch, fp );
	    else if ( !str_cmp( word, "END"    ) ) break;
	    else
	    {
		bug( "Load_char_obj: bad section.", 0 );
		break;
	    }
	}
	fclose( fp );
    }

    fpReserve = fopen( NULL_FILE, "r" );
    return found;
}