Пример #1
0
RealmDescriptor::RealmDescriptor(const std::string& realm_name, const std::string& realm_path, Clib::ConfigElem& elem) :
  name( realm_name ),
  file_path( realm_path ),
  width( elem.remove_ushort( "width" ) ),
  height( elem.remove_ushort( "height" ) ),
  uomapid( elem.remove_unsigned( "uomapid", 0 ) ),
  uodif( elem.remove_bool( "uodif", false ) ),
  num_map_patches( elem.remove_unsigned( "num_map_patches", 0 ) ),
  num_static_patches( elem.remove_unsigned( "num_static_patches", 0 ) ),
  season( elem.remove_unsigned( "season", 1 ) ),
  mapserver_type( Clib::strlower( elem.remove_string( "mapserver", "memory" ) ) ),
  grid_width(calc_grid_size(width)),
  grid_height(calc_grid_size(height))
{
}
Пример #2
0
	Mobile::NPC* add_npc( const char* npctype, unsigned short x, unsigned short y, short z )
	{
	  Clib::ConfigFile cfile;
	  Clib::ConfigElem elem;
	  if ( !Core::FindNpcTemplate( npctype, cfile, elem ) )
	  {
          throw std::runtime_error(std::string("NPC template '") + npctype + "' not found");
	  }

	  auto  npc = new Mobile::NPC( elem.remove_ushort( "OBJTYPE" ), elem );
	  elem.clear_prop( "Serial" );
	  elem.clear_prop( "X" );
	  elem.clear_prop( "Y" );
	  elem.clear_prop( "Z" );

	  elem.add_prop( "Serial", GetNextSerialNumber() );
	  elem.add_prop( "X", x );
	  elem.add_prop( "Y", y );
	  elem.add_prop( "Z", z );
	  npc->readPropertiesForNewNPC( elem );

	  objStorageManager.objecthash.Insert( npc );

	  SetCharacterWorldPosition( npc, WorldChangeReason::NpcCreate );
	  return npc;
	}
Пример #3
0
AuxService::AuxService( const Plib::Package* pkg, Clib::ConfigElem& elem ) :
  _pkg( pkg ),
  _scriptdef( elem.remove_string( "SCRIPT" ), _pkg ),
  _port( elem.remove_ushort( "PORT" ) )
{
  std::string iptext;
  while ( elem.remove_prop( "IPMATCH", &iptext ) )
  {
    auto delim = iptext.find_first_of("/");
    if (delim != std::string::npos)
    {
      std::string ipaddr_str = iptext.substr(0, delim);
      std::string ipmask_str = iptext.substr(delim + 1);
      unsigned int ipaddr = inet_addr( ipaddr_str.c_str() );
      unsigned int ipmask = inet_addr( ipmask_str.c_str() );
      _aux_ip_match.push_back( ipaddr );
      _aux_ip_match_mask.push_back( ipmask );
    }
    else
    {
      unsigned int ipaddr = inet_addr( iptext.c_str() );
      _aux_ip_match.push_back( ipaddr );
      _aux_ip_match_mask.push_back( 0xFFffFFffLu );
    }
  }
}
Пример #4
0
// Strength
// Dexterity
void load_general_entry( const Plib::Package* pkg, Clib::ConfigElem& elem )
{
  checka( elem,
          networkManager.uoclient_general.strength,
          "Strength" );
  checka( elem,
          networkManager.uoclient_general.intelligence,
          "Intelligence" );
  checka( elem,
          networkManager.uoclient_general.dexterity,
          "Dexterity" );
  checkv( elem,
          networkManager.uoclient_general.hits,
          "Hits" );
  checkv( elem,
          networkManager.uoclient_general.stamina,
          "Stamina" );
  checkv( elem,
          networkManager.uoclient_general.mana,
          "Mana" );
  //dave changed 3/15/03, support configurable max skillid
  networkManager.uoclient_general.maxskills = elem.remove_ushort( "MaxSkillID", SKILLID__HIGHEST );
  std::string temp;
  if ( elem.remove_prop( "MethodScript", &temp ) )
  {
    if ( !temp.empty() )
    {
      ExportScript* shs = new ExportScript( pkg, temp );
      if ( shs->Initialize() )
        networkManager.uoclient_general.method_script = shs;
      else
        delete shs;
    }
  }
}
Пример #5
0
UoClientListener::UoClientListener( Clib::ConfigElem& elem ) :
  port( elem.remove_ushort( "PORT" ) ),
  aosresist( elem.remove_bool( "AOSRESISTANCES", false ) ),
  sticky( elem.remove_bool( "KeepClients", false ) )

{
  CalculateCryptKeys( elem.remove_string( "ENCRYPTION", "none" ), encryption );
}
Пример #6
0
/// Since the constructor is doing some wrong guessing to tell when an armor is a shield,
/// forceShield will force to consider it a shield
ArmorDesc::ArmorDesc( u32 objtype, Clib::ConfigElem& elem, const Plib::Package* pkg,
                      bool forceShield )
    : EquipDesc( objtype, elem, ARMORDESC, pkg ),
      ar( elem.remove_ushort( "AR", 0 ) ),
      zones(),
      on_hit_script( elem.remove_string( "ONHITSCRIPT", "" ), pkg, "scripts/items/" )
{
  std::string coverage;
  while ( elem.remove_prop( "COVERAGE", &coverage ) )
  {
    try
    {
      zones.insert( Mobile::zone_name_to_zone( coverage.c_str() ) );
    }
    catch ( std::runtime_error& )
    {
      fmt::Writer tmp;
      tmp.Format( "Error in Objtype 0x{:X}" ) << objtype;
      if ( pkg == NULL )
        tmp << "config/itemdesc.cfg\n";
      else
        tmp << pkg->dir() << "itemdesc.cfg\n";

      ERROR_PRINT << tmp.str();
      throw;
    }
  }

  if ( zones.empty() )
  {
    // No 'COVERAGE' entries existed.
    // default coverage based on object type/layer
    unsigned short layer = Plib::systemstate.tile[graphic].layer;
    // special case for shields - they effectively have no coverage.
    if ( !forceShield && layer != Core::LAYER_HAND1 && layer != Core::LAYER_HAND2 )
    {
      try
      {
        zones.insert( Mobile::layer_to_zone( layer ) );
      }
      catch ( std::runtime_error& )
      {
        fmt::Writer tmp;
        tmp.Format( "Error in Objtype 0x{:X}" ) << objtype;
        if ( pkg == NULL )
          tmp << "config/itemdesc.cfg\n";
        else
          tmp << pkg->dir() << "itemdesc.cfg\n";

        ERROR_PRINT << tmp.str();
        throw;
      }
    }
  }
}
Пример #7
0
void MapWriter::OpenExistingFiles(const std::string& realm_name)
{
  using std::ios;

  _realm_name = realm_name;

  std::string directory = "realm/" + _realm_name + "/";

  std::string realm_cfg_filename = directory + "realm.cfg";
  Clib::ConfigFile cf( realm_cfg_filename, "REALM" );
  Clib::ConfigElem elem;
  if ( !cf.read( elem ) )
    throw std::runtime_error("Unable to read realm from " + realm_cfg_filename);
  _width = elem.remove_ushort( "width" );
  _height = elem.remove_ushort( "height" );

  std::string filename = directory + "base.dat";
  Clib::open_file( _ofs_base, filename, ios::in | ios::out | ios::binary );


  // First-level Solids index (solidx1)
  filename = directory + "solidx1.dat";
  Clib::open_file( _ofs_solidx1, filename, ios::in | ios::out | ios::binary );

  // Second-level Solids index (solidx2)
  filename = directory + "solidx2.dat";
  Clib::open_file( _ofs_solidx2, filename, ios::in | ios::out | ios::binary );
  _ofs_solidx2.seekp( 0, ios::end );
  solidx2_offset = _ofs_solidx2.tellp();

  // Solids data (solids)
  filename = directory + "solids.dat";
  Clib::open_file( _ofs_solids, filename, ios::in | ios::out | ios::binary );
  _ofs_solids.seekp( 0, ios::end );
  solids_offset = _ofs_solids.tellp();

  // Maptile (maptile.dat)
  filename = directory + "maptile.dat";
  Clib::open_file( _ofs_maptile, filename, ios::in | ios::out | ios::binary );
  _ofs_maptile.seekp( 0, ios::end );
}
Пример #8
0
	void UCorpse::readProperties( Clib::ConfigElem& elem )
	{
	  // corpses can be the same color as mobiles
	  u16 savecolor = elem.remove_ushort( "COLOR", 0 );

	  base::readProperties( elem );

	  color = savecolor;

	  elem.remove_prop( "CorpseType", &corpsetype );
	  elem.remove_prop( "OwnerSerial", &ownerserial );
	  take_contents_to_grave = elem.remove_bool( "TakeContentsToGrave", false );
	  movable_ = false;
	}
Пример #9
0
	USpell::USpell( Clib::ConfigElem& elem, Plib::Package* pkg ) :
	  pkg_( pkg ),
	  spellid_( elem.remove_ushort( "SPELLID" ) ),
	  name_( elem.remove_string( "NAME" ) ),
	  power_words_( elem.remove_string( "POWERWORDS" ) ),
	  scriptdef_( elem.remove_string( "SCRIPT", "" ), pkg, "scripts/" )
	{
	  unsigned short action;
	  if ( elem.remove_prop( "ANIMATION", &action ) )
	  {
		if ( UACTION_IS_VALID( action ) )
		{
		  action_ = static_cast<UACTION>( action );
		}
		else
		{
		  elem.throw_error( "Animation is out of range" );
		}
	  }
	  else
	  {
		action_ = ACTION_CAST_SPELL1;
	  }

	  unsigned short circle;
	  if ( elem.remove_prop( "CIRCLE", &circle ) )
	  {
		if ( circle < 1 || circle > spellcircles.size() ||
			 spellcircles[circle - 1] == NULL )
		{
          ERROR_PRINT << "Error reading spell " << name_
            << ": Circle " << circle << " is not defined.\n";
		  throw std::runtime_error( "Config file error" );
		}

		params_ = spellcircles[circle - 1]->params;
	  }
	  else
	  {
		params_ = USpellParams( elem );
	  }

	  std::string reagent_name;
	  while ( elem.remove_prop( "Reagent", &reagent_name ) )
	  {
        unsigned int reagent = Items::get_objtype_from_string( reagent_name );

		reglist_.push_back( reagent );
	  }
	}
Пример #10
0
Attribute::Attribute( const Plib::Package* pkg, Clib::ConfigElem& elem ) :
  pkg( pkg ),
  name( elem.rest() ),
  attrid( 0 ),
  aliases(),
  next( NULL ),
  getintrinsicmod_func( nullptr ),
  delay_seconds( elem.remove_ushort( "DELAY", 0 ) ),
  unhides( elem.remove_bool( "UNHIDES", true ) ),
  disable_core_checks( elem.remove_bool( "DisableCoreChecks", false ) ),
  default_cap( elem.remove_ushort( "DefaultCap", Core::settingsManager.ssopt.default_attribute_cap ) ),
  script_( elem.remove_string( "SCRIPT", "" ), pkg, "scripts/skills/" )
{
  aliases.push_back( name );
  std::string tmp;
  while ( elem.remove_prop( "Alias", &tmp ) )
    aliases.push_back( tmp );

  if ( elem.remove_prop( "GetIntrinsicModFunction", &tmp ) )
  {
    getintrinsicmod_func = Core::FindExportedFunction( elem, pkg, tmp, 1 );
  }
}
Пример #11
0
int UoToolMain::main()
{
  const std::vector<std::string> binArgs = programArgs();

  /**********************************************
   * show help
   **********************************************/
  if (binArgs.size() == 1)
  {
    showHelp();
    return 0; // return "okay"
  }

  /**********************************************
   * TODO: rework the following cruft from former uotool.cpp
   **********************************************/
  Clib::ConfigFile cf( "pol.cfg" );
  Clib::ConfigElem elem;

  cf.readraw( elem );

  Plib::systemstate.config.uo_datafile_root = elem.remove_string( "UoDataFileRoot" );
  Plib::systemstate.config.uo_datafile_root = Clib::normalized_dir_form( Plib::systemstate.config.uo_datafile_root );

  unsigned short max_tile = elem.remove_ushort( "MaxTileID", UOBJ_DEFAULT_MAX );

  if ( max_tile != UOBJ_DEFAULT_MAX && max_tile != UOBJ_SA_MAX && max_tile != UOBJ_HSA_MAX )
    Plib::systemstate.config.max_tile_id = UOBJ_DEFAULT_MAX;
  else
    Plib::systemstate.config.max_tile_id = max_tile;

  std::string argvalue = binArgs[1];
  if ( argvalue[0] == '/' || argvalue[0] == ':' )
  {
    Plib::systemstate.config.uo_datafile_root = argvalue;
    if (binArgs.size() < 3)
    {
      showHelp();
      return 0;
    }
    argvalue = binArgs[2];
  }

  std::transform(argvalue.begin(), argvalue.end(), argvalue.begin(), ::tolower);

  if ( argvalue == "tiledump" )
  {
    return UoTool::tiledump( s_argc, s_argv );
  }
  else if ( argvalue == "vertile" )
  {
    return UoTool::vertile();
  }
  else if ( argvalue == "verlandtile" )
  {
    return UoTool::verlandtile();
  }
  else if ( argvalue == "landtilehist" )
  {
    return UoTool::landtilehist();
  }
  else if ( argvalue == "flagsearch" )
  {
    return UoTool::flagsearch( s_argc, s_argv );
  }
  else if ( argvalue == "landtileflagsearch" )
  {
    return UoTool::landtileflagsearch( s_argc, s_argv );
  }
  else if ( argvalue == "loschange" )
  {
    return UoTool::loschange( s_argc, s_argv );
  }
  else if ( argvalue == "rawdump" )
  {
    return UoTool::rawdump( s_argc, s_argv );
  }
  else if ( argvalue == "ctable" )
  {
    return UoTool::print_ctable();
  }
  else if ( argvalue == "sndlist" )
  {
    return UoTool::print_sndlist();
  }
  else if ( argvalue == "statics" )
  {
    return UoTool::print_statics();
  }
  else if ( argvalue == "verdata" )
  {
    return UoTool::print_verdata_info();
  }
  else if ( argvalue == "multis" )
  {
    return UoTool::print_multis();
  }
  else if ( argvalue == "water" )
  {
    return UoTool::print_water_data();
  }
  else if ( argvalue == "newstatics" )
  {
    return Core::write_pol_static_files( "main" );
  }
  else if ( argvalue == "staticsmax" )
  {
    Core::open_uo_data_files();
    Core::staticsmax();
    return 0;
  }
  else if ( argvalue == "watersearch" )
  {
    return UoTool::water_search();
  }
  else if ( argvalue == "zhist" )
  {
    return UoTool::z_histogram();
  }
  else if ( argvalue == "staticshist" )
  {
    return UoTool::statics_histogram();
  }
  else if ( argvalue == "writedungmap" )
  {
    return UoTool::write_polmap();
  }
  else if ( argvalue == "writekeys" )
  {
    INFO_PRINT << "Keys written to current.key\n";
    return 0;
  }
  else if ( argvalue == "mapdump" )
  {
    return UoTool::mapdump( s_argc, s_argv );
  }
  else if ( argvalue == "contour" )
  {
    return UoTool::contour();
  }
  else if ( argvalue == "findlandtile" )
  {
    return UoTool::findlandtile( s_argc - 1, s_argv + 1 );
  }
  else if ( argvalue == "findlandtileflags" )
  {
    return UoTool::findlandtileflags( s_argc - 1, s_argv + 1 );
  }
  else if ( argvalue == "findgraphic" )
  {
    return UoTool::findgraphic( s_argc - 1, s_argv + 1 );
  }
  else if ( argvalue == "defragstatics" )
  {
    return UoTool::defragstatics( s_argc - 1, s_argv + 1 );
  }
  else if ( argvalue == "formatdesc" )
  {
    return UoTool::format_description( s_argc - 1, s_argv + 1 );
  }
  else if ( argvalue == "checkmultis" )
  {
    return UoTool::checkmultis();
  }

  showHelp();
  return 0;
}
Пример #12
0
	USpellParams::USpellParams( Clib::ConfigElem& elem ) :
	  manacost( elem.remove_ushort( "MANA" ) ),
	  difficulty( elem.remove_ushort( "DIFFICULTY" ) ),
	  pointvalue( elem.remove_ushort( "POINTVALUE" ) ),
	  delay( elem.remove_ushort( "DELAY" ) )
	{}
Пример #13
0
int UoConvertMain::main()
{
  const std::vector<std::string>& binArgs = programArgs();

  /**********************************************
   * show help
   **********************************************/
  if ( binArgs.size() == 1 )
  {
    showHelp();
    return 0;  // return "okay"
  }

  /**********************************************
   * TODO: rework the following cruft from former uoconvert.cpp
   **********************************************/
  Plib::systemstate.config.max_tile_id = UOBJ_DEFAULT_MAX;  // default
  std::string argvalue = programArgsFindEquals( "uodata=", "" );
  if ( !argvalue.empty() )
  {
    Plib::systemstate.config.uo_datafile_root = argvalue;
    Plib::systemstate.config.uo_datafile_root =
        Clib::normalized_dir_form( Plib::systemstate.config.uo_datafile_root );
  }
  else
  {
    INFO_PRINT << "Reading pol.cfg.\n";
    Clib::ConfigFile cf( "pol.cfg" );
    Clib::ConfigElem elem;

    cf.readraw( elem );
    Plib::systemstate.config.uo_datafile_root = elem.remove_string( "UoDataFileRoot" );
    Plib::systemstate.config.uo_datafile_root =
        Clib::normalized_dir_form( Plib::systemstate.config.uo_datafile_root );

    unsigned short max_tile = elem.remove_ushort( "MaxTileID", UOBJ_DEFAULT_MAX );

    if ( max_tile == UOBJ_DEFAULT_MAX || max_tile == UOBJ_SA_MAX || max_tile == UOBJ_HSA_MAX )
      Plib::systemstate.config.max_tile_id = max_tile;
  }

  unsigned short max_tile =
      static_cast<unsigned short>( programArgsFindEquals( "maxtileid=", UOBJ_DEFAULT_MAX, true ) );
  if ( max_tile == UOBJ_DEFAULT_MAX || max_tile == UOBJ_SA_MAX || max_tile == UOBJ_HSA_MAX )
    Plib::systemstate.config.max_tile_id = max_tile;


  std::string main_cfg = "uoconvert.cfg";
  if ( Clib::FileExists( main_cfg.c_str() ) )
  {
    std::string temp;
    Clib::ConfigElem elem;
    INFO_PRINT << "Reading uoconvert.cfg.\n";
    Clib::ConfigFile cf_main( main_cfg.c_str() );
    while ( cf_main.read( elem ) )
    {
      if ( elem.type_is( "MultiTypes" ) )
      {
        temp = elem.remove_string( "Boats" );
        ISTRINGSTREAM is_boats( temp );
        std::string graphicnum;
        while ( is_boats >> graphicnum )
          UoConvert::BoatTypes.insert( strtoul( graphicnum.c_str(), NULL, 0 ) );

        temp = elem.remove_string( "Houses" );
        ISTRINGSTREAM is_houses( temp );
        while ( is_houses >> graphicnum )
          UoConvert::HouseTypes.insert( strtoul( graphicnum.c_str(), NULL, 0 ) );

        temp = elem.remove_string( "Stairs" );
        ISTRINGSTREAM is_stairs( temp );
        while ( is_stairs >> graphicnum )
          UoConvert::StairTypes.insert( strtoul( graphicnum.c_str(), NULL, 0 ) );
      }
      else if ( elem.type_is( "LOSOptions" ) )