Пример #1
0
/* Load the channel file */
void load_mudchannels( void )
{
   mud_channel *channel = nullptr;
   int filever = 0;
   ifstream stream;

   log_string( "Loading channels..." );

   chanlist.clear(  );

   stream.open( CHANNEL_FILE );
   if( !stream.is_open(  ) )
   {
      log_string( "No channel file found." );
      return;
   }

   do
   {
      string key, value;
      char buf[MIL];

      stream >> key;
      stream.getline( buf, MIL );
      value = buf;

      strip_lspace( key );
      strip_tilde( value );
      strip_lspace( value );

      if( key.empty(  ) )
         continue;

      if( key == "#VERSION" )
         filever = atoi( value.c_str(  ) );
      else if( key == "#CHANNEL" )
         channel = new mud_channel;
      else if( key == "ChanName" )
         channel->name = value;
      else if( key == "ChanColorname" )
         channel->colorname = value;
      else if( key == "ChanLevel" )
         channel->level = atoi( value.c_str(  ) );
      else if( key == "ChanType" )
         channel->type = atoi( value.c_str(  ) );
      else if( key == "ChanFlags" )
      {
         if( filever < 1 )
            channel->flags = atoi( value.c_str(  ) );
         else
            flag_string_set( value, channel->flags, chan_flags );
      }
      else if( key == "End" )
         chanlist.push_back( channel );
      else
         log_printf( "%s: Bad line in channel file: %s %s", __func__, key.c_str(  ), value.c_str(  ) );
   }
   while( !stream.eof(  ) );
   stream.close(  );
}
Пример #2
0
void load_ships( void )
{
   ifstream stream;
   ship_data *ship;

   shiplist.clear(  );

   stream.open( SHIP_FILE );
   if( !stream.is_open(  ) )
   {
      bug( "%s: Unable to open ships file.", __FUNCTION__ );
      return;
   }

   do
   {
      string key, value;
      char buf[MIL];

      stream >> key;
      stream.getline( buf, MIL );
      value = buf;

      strip_lspace( key );
      strip_lspace( value );
      strip_tilde( value );

      if( key.empty(  ) )
         continue;

      if( key == "#SHIP" )
         ship = new ship_data;
      else if( key == "Name" )
         ship->name = value;
      else if( key == "Owner" )
         ship->owner = value;
      else if( key == "Flags" )
         flag_string_set( value, ship->flags, ship_flags );
      else if( key == "Vnum" )
         ship->vnum = atoi( value.c_str(  ) );
      else if( key == "Room" )
         ship->room = atoi( value.c_str(  ) );
      else if( key == "Type" )
      {
         ship->type = get_shiptype( value );

         ship->type = URANGE( SHIP_NONE, ship->type, SHIP_WARSHIP );
      }
      else if( key == "Hull" )
         ship->hull = atoi( value.c_str(  ) );
      else if( key == "Max_hull" )
         ship->max_hull = atoi( value.c_str(  ) );
      else if( key == "Fuel" )
         ship->fuel = atoi( value.c_str(  ) );
      else if( key == "Max_fuel" )
         ship->max_fuel = atoi( value.c_str(  ) );
      else if( key == "Coordinates" )
      {
         string coord;

         value = one_argument( value, coord );
         ship->cmap = atoi( coord.c_str(  ) );

         value = one_argument( value, coord );
         ship->mx = atoi( coord.c_str(  ) );

         ship->my = atoi( value.c_str(  ) );
      }
      else if( key == "End" )
         shiplist.push_back( ship );
      else
         log_printf( "%s: Bad line in ships file: %s %s", __FUNCTION__, key.c_str(  ), value.c_str(  ) );
   }
   while( !stream.eof(  ) );
   stream.close(  );
}