Ejemplo n.º 1
0
void load_bans(void)
{
    FILE                                   *fp = NULL;
    int                                     i;

    unload_bans();

    log_boot("- Loading banned name list from %s", BAN_FILE);
    if ((fp = fopen(BAN_FILE, "r"))) {
        banned_names_count = fread_number(fp);
	banned_names = calloc(banned_names_count, sizeof(char *));
	for (i = 0; i < banned_names_count; i++) {
            banned_names[i] = strdup(new_fread_string(fp));
	}

        log_boot("- Loading banned ip list from %s", BAN_FILE);
        banned_ips_count = fread_number(fp);
	banned_ips = calloc(banned_ips_count, sizeof(char *));
	for (i = 0; i < banned_ips_count; i++) {
            banned_ips[i] = strdup(new_fread_string(fp));
	}

        log_boot("- Loading banned name@ip list from %s", BAN_FILE);
        banned_at_count = fread_number(fp);
	banned_at_names = calloc(banned_at_count, sizeof(char *));
	banned_at_ips = calloc(banned_at_count, sizeof(char *));
	for (i = 0; i < banned_at_count; i++) {
            banned_at_names[i] = strdup(new_fread_string(fp));
            banned_at_ips[i] = strdup(new_fread_string(fp));
	}
	fclose(fp);
    }
}
Ejemplo n.º 2
0
Archivo: trivia.c Proyecto: borlak/umgw
void read_trivia(void)
{
	FILE *fp;
	TRIVIA *strivia = 0;
	HINT *hint;
	char *word;

	if((fp = fopen(TRIVIA_FILE, "r")) == 0)
	{
		bug("read_trivia: unable to open file ro reading!", 0);
		return;
	}

	while(1)
	{
		word = fread_word(fp);

		if(!str_cmp(word, "end"))
			break;

		if(!str_cmp(word, "trivia"))
		{
			strivia = alloc_perm(sizeof(*strivia));
			strivia->question = fread_string(fp);
			strivia->answer = fread_string(fp);
			strivia->character = fread_string(fp);
			strivia->winner = fread_string(fp);
			strivia->guesses = fread_number(fp);
			strivia->time = fread_number(fp);
			strivia->timeleft = fread_number(fp);
			strivia->reward = fread_number(fp);
			strivia->next = trivia_list;
			trivia_list = strivia;
			continue;
		}

		if(!str_cmp(word, "hint"))
		{
			if(!strivia)
			{
				bug("read_trivia: hint read before trivia laoded!", 0);
				exit(1);
			}

			hint = alloc_perm(sizeof(*hint));
			hint->hint = fread_string(fp);
			hint->next = strivia->hints;
			strivia->hints = hint;
			continue;
		}

		bug("read_trivia: wrong word!", 0);
		break;
	}

	return;
}
Ejemplo n.º 3
0
/* 
 * This function reads one immortal host to a file.
 * Shaddai  July 27, 1997
 */
int fread_imm_host( FILE * fp, IMMORTAL_HOST * data )
{
   const char *word;
   bool fMatch;
   int temp;

   for( ;; )
   {
      word = feof( fp ) ? "End" : fread_word( fp );
      fMatch = FALSE;

      switch ( UPPER( word[0] ) )
      {
         case 'E':
            if( !str_cmp( word, "End" ) )
               return rNONE;

         case 'H':
            KEY( "Host", data->host, fread_string_nohash( fp ) );
            break;

         case 'N':
            KEY( "Name", data->name, fread_string_nohash( fp ) );
            break;

         case 'P':
            if( !str_cmp( word, "Prefix" ) )
            {
               temp = fread_number( fp );
               if( temp )
                  data->prefix = TRUE;
               else
                  data->prefix = FALSE;
               fMatch = TRUE;
            }
            break;

         case 'S':
            if( !str_cmp( word, "Suffix" ) )
            {
               temp = fread_number( fp );
               if( temp )
                  data->suffix = TRUE;
               else
                  data->suffix = FALSE;
               fMatch = TRUE;
            }
            break;
      }
      if( !fMatch )
      {
         bug( "%s: no match: %s", __func__, word );
         fread_to_eol( fp );
      }
   }
}
Ejemplo n.º 4
0
int
fread_imm_host ( FILE *fp , IMMORTAL_HOST *data )
{
  char buf[MAX_STRING_LENGTH];
  char *word;
  bool fMatch;
  int temp;

  for ( ; ; )
  {
    word = feof (fp) ? "End" : fread_word (fp);
    fMatch = FALSE; 

    switch ( UPPER ( word[0] ) )
    {
        case 'E':
	  if ( !str_cmp( word, "End" ) )
		return rNONE;
	case 'H': 
	  KEY ("Host", data->host, fread_string_nohash (fp) );
	  break;
	case 'N':
	  KEY ("Name", data->name, fread_string_nohash ( fp ) );
	  break;
	case 'P':
	  if ( !str_cmp( word, "Prefix" ) ) 
	  {
		temp = fread_number ( fp );
		if ( temp )
			data->prefix = TRUE;
		else
			data->prefix = FALSE;
		fMatch = TRUE;
	  }	
	  break;
	case 'S':
	  if ( !str_cmp( word, "Suffix" ) ) 
	  {
		temp = fread_number ( fp );
		if ( temp )
			data->suffix = TRUE;
		else
			data->suffix = FALSE;
		fMatch = TRUE;
	  }	
	  break;
     }
     if (!fMatch)
     {
	sprintf (buf, "Fread_immortal_host: no match: %s", word );
	bug ( buf, 0 );
     }
  }
  return rNONE;
}
Ejemplo n.º 5
0
/* added for new index - 5/5/02 - Nopey */
void fread_news_type( NEWS_TYPE * type, FILE * fp )
{
   const char *word;
   bool fMatch;

   for( ;; )
   {
      word = feof( fp ) ? "End" : fread_word( fp );
      fMatch = FALSE;

      switch ( UPPER( word[0] ) )
      {
         case '*':
            fread_to_eol( fp );
            break;

         case 'C':
            KEY( "Cmd_Name", type->cmd_name, fread_string( fp ) );
            break;

         case 'E':
            if( !str_cmp( word, "END" ) )
            {
               if( !type->name )
                  type->name = STRALLOC( "Unknown" );

               return;
            }
            break;

         case 'H':
            KEY( "Header", type->header, fread_string( fp ) );
            break;

         case 'L':
            KEY( "Level", type->level, fread_number( fp ) );
            break;

         case 'N':
            KEY( "Name", type->name, fread_string( fp ) );
            break;

         case 'V':
            KEY( "Vnum", type->vnum, fread_number( fp ) );
            break;
      }

      if( !fMatch )
         bug( "fread_news_type(): no match: %s", word );
   }
}
Ejemplo n.º 6
0
void reset_colors( char_data * ch )
{
   if( !ch->isnpc(  ) )
   {
      char filename[256];

      snprintf( filename, 256, "%s%s", COLOR_DIR, "default" );
      if( exists_file( filename ) )
      {
         FILE *fp;
         int max_colors = 0;

         if( !( fp = fopen( filename, "r" ) ) )
         {
            memcpy( &ch->pcdata->colors, &default_set, sizeof( default_set ) );
            return;
         }

         while( !feof( fp ) )
         {
            char *word = fread_word( fp );

            if( !str_cmp( word, "MaxColors" ) )
            {
               max_colors = fread_number( fp );
               continue;
            }

            if( !str_cmp( word, "Colors" ) )
            {
               for( int x = 0; x < max_colors; ++x )
                  ch->pcdata->colors[x] = fread_number( fp );
               continue;
            }

            if( !str_cmp( word, "End" ) )
            {
               FCLOSE( fp );
               return;
            }
         }
         FCLOSE( fp );
         return;
      }
      else
         memcpy( &ch->pcdata->colors, &default_set, sizeof( default_set ) );
   }
   else
      log_printf( "%s: Attempting to reset NPC colors: %s", __func__, ch->short_descr );
}
Ejemplo n.º 7
0
/* Reads the actual time file from disk - Samson 1-21-99 */
void fread_timedata( FILE * fp )
{
   char *word = NULL;
   bool fMatch = FALSE;

   for( ;; )
   {
      word = feof( fp ) ? "End" : fread_word( fp );
      fMatch = FALSE;

      switch ( UPPER( word[0] ) )
      {
         case '*':
            fMatch = TRUE;
            fread_to_eol( fp );
            break;

         case 'E':
            if( !str_cmp( word, "End" ) )
               return;
            break;

         case 'P':
            KEY( "Purgetime", new_pfile_time_t, fread_number( fp ) );
            break;
      }

      if( !fMatch )
      {
         bug( "Fread_timedata: no match: %s", word );
         fread_to_eol( fp );
      }
   }
}
Ejemplo n.º 8
0
void load_wizlist(void)
{
    FILE *fp;
    WIZ_DATA *wiz_last;
 
    if ( ( fp = fopen( WIZ_FILE, "r" ) ) == NULL )
    {
        return;
    }
 
    wiz_last = NULL;
    for ( ; ; )
    {
        WIZ_DATA *pwiz;
        if ( feof(fp) )
        {
            fclose( fp );
            return;
        }
 
        pwiz = new_wiz();
 
        pwiz->name = str_dup(fread_word(fp));
	pwiz->level = fread_number(fp);
	fread_to_eol(fp);

        if (wiz_list == NULL)
	    wiz_list = pwiz;
	else
	    wiz_last->next = pwiz;
	wiz_last = pwiz;
    }
}
Ejemplo n.º 9
0
void load_bans(void)
{
    FILE *fp;
    BAN_DATA *ban_last;
 
    strcat(boot_buf,"ators.\n\r                Le");
    if ( ( fp = fopen( BAN_FILE, "r" ) ) == NULL )
        return;
 
    ban_last = NULL;
    for ( ; ; )
    {
        BAN_DATA *pban;
        if ( feof(fp) )
        {
            fclose( fp );
            return;
        }
 
        pban = new_ban();
 
        pban->name = str_dup(fread_word(fp));
	pban->level = fread_number(fp);
	pban->ban_flags = fread_flag(fp);
	fread_to_eol(fp);

        if (ban_list == NULL)
	    ban_list = pban;
	else
	    ban_last->next = pban;
	ban_last = pban;
    }
}
Ejemplo n.º 10
0
/*
 * Snarf spec proc declarations.
 */
void load_specials( FILE *fp )
{
    for ( ; ; )
    {
	MOB_INDEX_DATA *pMobIndex;
	char letter;

	switch ( letter = fread_letter( fp ) )
	{
	default:
	    bug( "Load_specials: letter '%c' not *MS.", letter );
	    exit( 1 );

	case 'S':
	    return;

	case '*':
	    break;

	case 'M':
	    pMobIndex		= get_mob_index	( fread_number ( fp ) );
	    pMobIndex->spec_fun	= spec_lookup	( fread_word   ( fp ) );
	    if ( pMobIndex->spec_fun == 0 )
	    {
		bug( "Load_specials: 'M': vnum %d.", pMobIndex->vnum );
		exit( 1 );
	    }
	    break;
	}

	fread_to_eol( fp );
    }
}
Ejemplo n.º 11
0
void load_group( FILE *fp, struct group_type *group )
{
	int i;
	char *temp;

	group->name	= fread_string(fp);

	for ( i = 0; i < MAX_CLASS; ++i )
		group->rating[i]	= fread_number( fp );

	i = 0;

	while(TRUE)
	{
		temp = fread_string(fp);
		if ( !str_cmp( temp, "End" ) || i >= MAX_IN_GROUP )
      {
         while( i < MAX_IN_GROUP )
                group->spells[i++] = str_dup( "" );
			break;
      }
	   else
			group->spells[i++]	= temp;
	}
}
Ejemplo n.º 12
0
/*
 * Snarf a help section.
 */
void load_helps( FILE *fp )
{
    HELP_DATA *pHelp;

    for ( ; ; )
    {
	pHelp		= alloc_perm( sizeof(*pHelp) );
	pHelp->level	= fread_number( fp );
	pHelp->keyword	= fread_string( fp );
	if ( pHelp->keyword[0] == '$' )
	    break;
	pHelp->text	= fread_string( fp );

	if ( !str_cmp( pHelp->keyword, "greeting" ) )
	    help_greeting = pHelp->text;

	if ( help_first == NULL )
	    help_first = pHelp;
	if ( help_last  != NULL )
	    help_last->next = pHelp;

	help_last	= pHelp;
	pHelp->next	= NULL;
	top_help++;
    }

    return;
}
Ejemplo n.º 13
0
void load_changes(void)
{
    FILE *fp;
    int i;

    totChanges = 0;
    if ( !(fp = fopen( CHANGES_FILE, "r")) )
    {
        bug( "Could not open Changes File for reading.", 0 );
        return;
    }

    fscanf( fp, "%d\n", &maxChanges );

    /* Use malloc so we can realloc later on */
    changes_table = malloc( sizeof( CHANGE_DATA) * (maxChanges+1) );

    for( i = 0; i < maxChanges; i++ )
    {
        totChanges++;
        changes_table[i].change = fread_string( fp );
        changes_table[i].coder = fread_string( fp );
        changes_table[i].date = fread_string( fp );
        changes_table[i].mudtime = fread_number( fp );
    }
    changes_table[maxChanges].coder = str_dup("");
    fclose(fp);
    return;                                                 /* just return */
}
Ejemplo n.º 14
0
/* Read in an individual holiday */
void fread_day( HOLIDAY_DATA * day, FILE * fp )
{
   const char *word;
   bool fMatch;

   for( ;; )
   {
      word = feof( fp ) ? "End" : fread_word( fp );
      fMatch = FALSE;

      switch ( UPPER( word[0] ) )
      {
         case '*':
            fMatch = TRUE;
            fread_to_eol( fp );
            break;

         case 'A':
            KEY( "Announce", day->announce, fread_string_nohash( fp ) );
            break;

         case 'D':
            KEY( "Day", day->day, fread_number( fp ) );
            break;

         case 'E':
            if( !str_cmp( word, "End" ) )
            {
               if( !day->announce )
                  day->announce = str_dup( "Today is a holiday, but who the hell knows which one." );
               return;
            }
            break;

         case 'M':
            KEY( "Month", day->month, fread_number( fp ) );
            break;

         case 'N':
            KEY( "Name", day->name, fread_string_nohash( fp ) );
            break;
      }

      if( !fMatch )
         bug( "fread_day: no match: %s", word );
   }
}
Ejemplo n.º 15
0
void load_materials(void) {
	bool fMatch;

	closeReserve();
	FILE *fp = fopen(MATERIAL_FILE, "r");
	if(!fp) return; // no materials to load.

	while(true)
	{
		const char *word  = feof( fp ) ? "End" : fread_word( fp );
		fMatch = FALSE;

		if(!str_cmp(word, "End")) {
			break;
		}

		if(!str_cmp(word, "MAT")) {
			MAT_TYPE *mat = new_mat();

			while(true) {
				word = feof( fp ) ? "End" : fread_word(fp);
				if(!str_cmp(word, "End")) {
					bug(Format("Prematurely reached end of materials data file; data corrupted!"), 0);
					fclose(fp);
					openReserve();
					return;
				}
				bool finished = false;
				switch ( UPPER(word[0]) )
				{
				case '*':
					fMatch = TRUE;
					fread_to_eol( fp );
					break;
				case 'E':
					if(!str_cmp(word, "ENDMAT")) {

						mat->next = mat_list;
						mat_list = mat;

						matValue++;
						finished = true;
						break;
					}
				case 'V':
					KEY("VAL",	mat->assignedValue, fread_number(fp) );
					break;
				case 'N':
					KEYS( "NAME",		mat->name,		fread_string(fp) );
					break;
				}
				if(finished)
					break;
			}
		}
	}
	fclose(fp);
	openReserve();
}
Ejemplo n.º 16
0
void reset_colors( CHAR_DATA * ch )
{
   int x;

   if( !IS_NPC( ch ) )
   {
      char filename[256];
      FILE *fp;
      int max_colors = 0;

      snprintf( filename, 256, "%s%s", COLOR_DIR, "default" );
      if( !( fp = fopen( filename, "r" ) ) )
      {
         memcpy( &ch->colors, &default_set, sizeof( default_set ) );
         return;
      }
      while( !feof( fp ) )
      {
         char *word = fread_word( fp );
         if( !str_cmp( word, "MaxColors" ) )
         {
            int temp = fread_number( fp );
            max_colors = UMIN( temp, MAX_COLORS );
            continue;
         }
         if( !str_cmp( word, "Colors" ) )
         {
            for( x = 0; x < max_colors; ++x )
               ch->colors[x] = fread_number( fp );
            fread_to_eol( fp );
            continue;
         }
         if( !str_cmp( word, "End" ) )
         {
            fclose( fp );
            fp = NULL;
            return;
         }
      }
      fclose( fp );
      fp = NULL;
      return;
   }
   else
      log_printf( "%s: Attempting to reset NPC colors: %s", __func__, ch->short_descr );
}
Ejemplo n.º 17
0
void read_exits( FILE* fp, room_data* room, int vnum )
{
  exit_data*    exit;
  char        letter;

  for( ; ; ) {
    if( ( letter = fread_letter( fp ) ) != 'D' )
      break;

    exit = add_exit( room, fread_number( fp ) );

    exit->name        = fread_string( fp, MEM_EXIT );
    exit->keywords    = fread_string( fp, MEM_EXIT );
    exit->exit_info   = fread_number( fp );
    exit->key         = fread_number( fp );
    exit->to_room     = (room_data*) fread_number( fp );
    exit->strength    = fread_number( fp );
    exit->light       = fread_number( fp );
    exit->size        = fread_number( fp );

    if( exit->direction < 0 || exit->direction > 6 ) 
      panic( "Fread_rooms: vnum %d has bad door number.", vnum );
    }

  ungetc( letter, fp );
}
Ejemplo n.º 18
0
/* Snarf a MOBprogram section from the area file.
 */
bool load_mobprogs( FILE *fp )
{
    MOB_INDEX_DATA *iMob;
    MPROG_DATA     *original;
    MPROG_DATA     *working;
    char            letter;
    int             value;
    int		  stat;
    bool            koniec = FALSE;

    while ( !koniec )
    {
	letter = fread_letter( fp );
	switch ( letter )
	{
	    default:
		cbug( "Load_mobprogs: bad command '%c'.", letter );
		return TRUE;
	    case 'S':
	    case 's':
		fread_to_eol( fp );
		koniec = TRUE;
		break;
	    case '*':
		fread_to_eol( fp );
		break;
	    case 'M':
	    case 'm':
		value = fread_number( fp, &stat );
		if ( ( iMob = get_mob_index( value ) ) == NULL )
		{
		    cbug( "Load_mobprogs: vnum %d doesnt exist", value );
		    return TRUE;
		}

		/* Go to the end of the prog command list if other commands
		   exist */
		if ( ( original = iMob->mobprogs ) )
		    for ( ; original->next != NULL; original = original->next )
			;

		working = new_mprog( );
		if ( original )
		    original->next = working;
		else
		    iMob->mobprogs = working;
		working = mprog_file_read( fread_word( fp, &stat, TRUE ), working, iMob, 0 );
		if ( !working )
		    return TRUE;
		working->next = NULL;
		fread_to_eol( fp );
		break;
	}
    }

    return FALSE;
}
Ejemplo n.º 19
0
affect_data *fread_fuss_affect( FILE * fp, const char *word )
{
   int pafmod;

   affect_data *paf = new affect_data;
   paf->location = APPLY_NONE;
   paf->type = -1;
   paf->duration = -1;
   paf->bit = 0;
   paf->modifier = 0;
   paf->rismod.reset(  );

   if( !strcmp( word, "Affect" ) )
   {
      paf->type = fread_number( fp );
   }
   else
   {
      int sn;

      sn = skill_lookup( fread_word( fp ) );
      if( sn < 0 )
         bug( "%s: unknown skill.", __func__ );
      else
         paf->type = sn;
   }

   paf->duration = fread_number( fp );
   pafmod = fread_number( fp );
   paf->location = fread_number( fp );
   fread_bitvector( fp ); // Bit conversions don't take for this.

   if( paf->location == APPLY_WEAPONSPELL
       || paf->location == APPLY_WEARSPELL
       || paf->location == APPLY_STRIPSN || paf->location == APPLY_REMOVESPELL || paf->location == APPLY_RECURRINGSPELL )
      paf->modifier = slot_lookup( pafmod );
   else
      paf->modifier = pafmod;

   ++top_affect;
   return paf;
}
Ejemplo n.º 20
0
void load_disabled(  )
{
   FILE *fp;
   DISABLED_DATA *disabled;
   CMDTYPE *cmd;
   char *word;

   fp = fopen( DISABLE_FILE, "r" );

   if( !fp )
   {
      bug( "Unable to open disabled commands list." );
      return;
   }

   for( ;; )
   {
      word = fread_word( fp );

      if( !str_cmp( word, "End" ) )
         break;

      cmd = find_command( word );
      if( !cmd )
      {
         bug( "Unknown command in disabled list." );
         fread_number( fp );
         fread_word( fp );
         continue;
      }

      CREATE( disabled, DISABLED_DATA, 1 );
      disabled->command = cmd;
      disabled->level = fread_number( fp );
      disabled->who = STRALLOC( fread_word( fp ) );
      disabled->next = first_disabled;
      first_disabled = disabled;
   }

   fclose( fp );
}
Ejemplo n.º 21
0
/* Reads the actual time file from disk - Samson 1-21-99 */
void fread_timedata( FILE * fp )
{
   const char *word;
   bool fMatch = FALSE;

   for( ;; )
   {
      word = feof( fp ) ? "End" : fread_word( fp );
      fMatch = FALSE;

      switch ( UPPER( word[0] ) )
      {
         case '*':
            fMatch = TRUE;
            fread_to_eol( fp );
            break;

         case 'E':
            if( !str_cmp( word, "End" ) )
               return;
            break;

         case 'M':
            KEY( "Mhour", time_info.hour, fread_number( fp ) );
            KEY( "Mday", time_info.day, fread_number( fp ) );
            KEY( "Mmonth", time_info.month, fread_number( fp ) );
            KEY( "Myear", time_info.year, fread_number( fp ) );
            break;
         /* Uncomment if you have Samson's Pfile Cleanup Snippet installed.
		 case 'P':
            KEY( "Purgetime", new_pfile_time_t, fread_number( fp ) );
            break; */
      }

      if( !fMatch )
      {
         bug( "Fread_timedata: no match: %s", word );
         fread_to_eol( fp );
      }
   }
}
Ejemplo n.º 22
0
void load_helps( void )
{
  help_data*  help;
  FILE*         fp;
  int          pos;

  echo( "Loading Help ...\n\r" );

  help_list = NULL;
  max_help  = 0;

  fp = open_file( HELP_FILE, "r" );

  if( strcmp( fread_word( fp ), "#HELPS" ) ) 
    panic( "Load_helps: missing header" );

  for( ; ; ) {
    help           = new help_data;
    help->level[0] = fread_number( fp );
    help->level[1] = fread_number( fp );
    help->category = fread_number( fp );
    help->name     = fread_string( fp, MEM_HELP );

    if( *help->name == '$' ) {
      delete help;
      break;
      }

    help->text     = fread_string( fp, MEM_HELP );
    help->immortal = fread_string( fp, MEM_HELP );  

    pos = pntr_search( help_list, max_help, help->name );

    if( pos < 0 )
      pos = -pos-1;

    insert( help_list, max_help, help, pos );
    }

  fclose( fp );
}
Ejemplo n.º 23
0
void
read_damages (void)
{
  FILE *df;
  char buf[1000];
  int lastmark= 0;
  bzero (&dmsg, sizeof (dmsg));
  if ((df = fopen ("dam.dat", "r")) == NULL)
    {

      damt.kick_dam = str_dup ("o+2d/4m40+k/2");
      write_damages ();
    }
  for (;;)
    {
      strcpy (buf, fread_word (df));
      if (!str_cmp (buf, "END"))
	break;
      if (!str_cmp (buf, "Kickd"))
	damt.kick_dam = str_dup (fread_word (df));
      if (!str_prefix ("#", buf))
	{
	  fread_to_eol (df);
	  continue;
	}
      if (!str_cmp (buf, "GENERIC"))
	{
	  dmsg.generic_range[lastmark][0] = fread_number (df);
	  dmsg.generic_range[lastmark][1] = fread_number (df);
	  dmsg.generic_percent[lastmark][0] = fread_number (df);
	  dmsg.generic_percent[lastmark][1] = fread_number (df);
	  fread_to_eol (df);
	  dmsg.gen_m[lastmark] = fread_string_eol (df);
	  dmsg.gen_m1[lastmark] = fread_string_eol (df);
	  dmsg.gen_m2[lastmark]= fread_string_eol (df);
	  lastmark++;
	}
    }
  fclose (df);
  return;
}
Ejemplo n.º 24
0
/*
 * Snarf a shop section.
 */
void load_shops( FILE *fp )
{
    SHOP_DATA *pShop;

    for ( ; ; )
    {
	MOB_INDEX_DATA *pMobIndex;
	int iTrade;

	pShop			= alloc_perm( sizeof(*pShop) );
	pShop->keeper		= fread_number( fp );
	if ( pShop->keeper == 0 )
	    break;
	for ( iTrade = 0; iTrade < MAX_TRADE; iTrade++ )
	    pShop->buy_type[iTrade]	= fread_number( fp );
	pShop->profit_buy	= fread_number( fp );
	pShop->profit_sell	= fread_number( fp );
	pShop->open_hour	= fread_number( fp );
	pShop->close_hour	= fread_number( fp );
				  fread_to_eol( fp );
	pMobIndex		= get_mob_index( pShop->keeper );
	pMobIndex->pShop	= pShop;

	if ( shop_first == NULL )
	    shop_first = pShop;
	if ( shop_last  != NULL )
	    shop_last->next = pShop;

	shop_last	= pShop;
	pShop->next	= NULL;
	top_shop++;
    }

    return;
}
Ejemplo n.º 25
0
void load_pkfile()
{
        FILE * fp = fopen(PKRANK_FILE,"r");
	if (fp)
	{
		PKINFO_TYPE * pkholder;
		char * tmp = fread_string(fp);
		while (strcmp(tmp,"END"))
		{
			PKINFO_TYPE * pk = alloc_perm(sizeof(*pk));
			pk->character = str_dup(tmp);
			bug("Read: %s",pk->character);
			pk->pk_count = fread_number(fp);
			bug("Read: %d",pk->pk_count);
			pk->pk_death_count = fread_number(fp);
			bug("Read: %d",pk->pk_death_count);
			if (pkranks == NULL)
			{
				pkranks = pk;
				pkholder = pk;
				pk->next = NULL;
			}
			else;
			{
				pkholder->next = pk;
				pkholder = pk;
				pk->next = NULL;

			}
			tmp = fread_string(fp);
		}		
	}
	else
	{
		pkranks = NULL;
		fp = fopen(PKRANK_FILE,"w");
		fprintf(fp,"END~\n");
		fclose(fp);
	}
}
Ejemplo n.º 26
0
/* Read in an individual slaytype */
void fread_slay( SLAY_DATA * slay, FILE * fp )
{
   const char *word;
   bool fMatch;

   for( ;; )
   {
      word = feof( fp ) ? "End" : fread_word( fp );
      fMatch = FALSE;

      switch ( UPPER( word[0] ) )
      {
         case '*':
            fMatch = TRUE;
            fread_to_eol( fp );
            break;

         case 'C':
            KEY( "Cmessage", slay->cmsg, fread_string( fp ) );
            KEY( "Color", slay->color, fread_number( fp ) );
            break;

         case 'E':
            if( !str_cmp( word, "End" ) )
            {
               if( !slay->owner )
                  slay->owner = STRALLOC( "Any" );
               return;
            }
            break;

         case 'O':
            KEY( "Owner", slay->owner, fread_string( fp ) );
            break;

         case 'R':
            KEY( "Rmessage", slay->rmsg, fread_string( fp ) );
            break;

         case 'T':
            KEY( "Type", slay->type, fread_string( fp ) );
            break;

         case 'V':
            KEY( "Vmessage", slay->vmsg, fread_string( fp ) );
            break;
      }

      if( !fMatch )
         bug( "Fread_slay: no match: %s", word );
   }
}
Ejemplo n.º 27
0
void 
read_command_levels (void)
{
  COMMAND *c;
  FILE *fp;
  char b[200];

  if ((fp = fopen ("commands.dat", "r")) == NULL)
    return;
  for (;;)
    {
      strcpy (b, fread_word (fp));
      if (!str_cmp (b, "END"))
	break;
      if (!str_cmp (b, "LINK"))
	{
	  char t[200];
	  strcpy (b, fread_word (fp));
	  if ((c = clookup (b)) == NULL)
	    {
	      fread_to_eol (fp);
	      continue;
	    }
	  strcpy (t, fread_word (fp));
	  add_to_list (t, c->do_fun, c->position, c->level, c->log, c->help);
	  fprintf (stderr, "Created dynamic command link from '%s' to '%s'.\n", b, t);
	  continue;
	}
      if ((c = clookup (b)) == NULL)
	{
	  fread_number (fp);
	  continue;
	}
      c->level = fread_number (fp);
    }

  fclose (fp);
  return;
}
Ejemplo n.º 28
0
/*
 * Legge un numero negativo da un file
 * E' incluso lo zero
 */
int fread_negative( MUD_FILE *fp )
{
	int num;

	num = fread_number( fp );
	if ( num > 0 )
	{
		send_log( fp, LOG_FREAD, "fread_positive: numero acquisito positivo: %d", num );
		if ( fBootDb )
			exit( EXIT_FAILURE );
	}

	return num;
}
Ejemplo n.º 29
0
void load_pkstore()
{
    int nNum;
    FILE *fp;
    if ((fp = fopen("../txt/pkstore.txt", "r")) == NULL)
    {
        log_string("Fatal Error: pkstore.txt not found! Making one!");
        save_pkstore();
        return;
    }
    pkstore_table.sStoreName = fread_string ( fp );
    for ( nNum = 0; nNum < 10; nNum++ )
    {
        pkstore_table.sItem[nNum] = str_dup(fread_string( fp ));
        pkstore_table.sItemDescriptions[nNum] = str_dup(fread_string( fp ));
        pkstore_table.nItemVnum[nNum] = fread_number( fp );
        pkstore_table.nItemPk[nNum] = fread_number( fp );
        pkstore_table.nItemQp[nNum] = fread_number( fp );
        pkstore_table.nItemDe[nNum] = fread_number( fp );
        pkstore_table.nItemBought[nNum] = fread_number( fp );
    }
    fclose(fp);
}
Ejemplo n.º 30
0
/*
 * Loads the ban file from the system directory.
 */
void load_bans(void)
{
    FILE *fp;
    BAN_DATA *ban_last;

    if ((fp = fopen(BAN_FILE, "r")) == NULL)
    {
        global.last_boot_result = MISSING;
        log_string("STATUS: No ban file available to load in the system directory.");
        return;
    }

    ban_last = NULL;
    for (;;)
    {
        BAN_DATA *pban;
        if (feof(fp))
        {
            if (global.last_boot_result == UNKNOWN)
            {
                global.last_boot_result = SUCCESS;
            }

            fclose(fp);
            return;
        }

        pban = new_ban();

        pban->name = str_dup(fread_word(fp));
        pban->level = fread_number(fp);
        pban->ban_flags = fread_flag(fp);
        fread_to_eol(fp);

        if (ban_list == NULL)
        {
            ban_list = pban;
        }
        else
        {
            ban_last->next = pban;
        }
        ban_last = pban;
    }

    if (global.last_boot_result == UNKNOWN)
        global.last_boot_result = SUCCESS;

} // end load_bans