コード例 #1
0
ファイル: corpse.cpp プロジェクト: vitorfdl/polserver
	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;
	}
コード例 #2
0
ファイル: spells.cpp プロジェクト: Lolkauo/polserver
	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 );
	  }
	}
コード例 #3
0
ファイル: auxclient.cpp プロジェクト: gtozzi/polserver
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
ファイル: cmdlevel.cpp プロジェクト: polserver/polserver
CmdLevel::CmdLevel( Clib::ConfigElem& elem, int cmdlevelnum )
    : name( elem.rest() ), cmdlevel( static_cast<unsigned char>( cmdlevelnum ) )
{
  Clib::mklower( name );
  std::string tmp;
  while ( elem.remove_prop( "DIR", &tmp ) )
  {
    Clib::mklower( tmp );
    add_searchdir( nullptr, Clib::normalized_dir_form( tmp ) );
  }
  while ( elem.remove_prop( "ALIAS", &tmp ) )
  {
    Clib::mklower( tmp );
    aliases.push_back( tmp );
  }
}
コード例 #5
0
ファイル: uoclient.cpp プロジェクト: gtozzi/polserver
// 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;
    }
  }
}
コード例 #6
0
ファイル: resource.cpp プロジェクト: polserver/polserver
void ResourceDef::read_config( Clib::ConfigElem& elem )
{
  initial_units_ = elem.remove_ulong( "InitialUnits" );

  // start current_units at initial_units in case there's no entry in
  // RESOURCE.DAT
  current_units_ = initial_units_;

  unsigned short tmp;
  while ( elem.remove_prop( "LandTile", &tmp ) )
  {
    landtiles_.insert( tmp );
  }
  while ( elem.remove_prop( "ObjType", &tmp ) )
  {
    tiles_.insert( tmp );
  }
}
コード例 #7
0
ファイル: armor.cpp プロジェクト: JohnnyB1971/polserver
/// 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;
      }
    }
  }
}
コード例 #8
0
ファイル: vital.cpp プロジェクト: gtozzi/polserver
Vital::Vital( const Plib::Package* pkg, Clib::ConfigElem& elem ) :
  pkg( pkg ),
  name( elem.rest() ),
  aliases(),
  vitalid( 0 ),
  next( NULL ),
  get_regenrate_func( FindExportedFunction( elem, pkg, elem.remove_string( "RegenRateFunction" ), 1 ) ),
  get_maximum_func( FindExportedFunction( elem, pkg, elem.remove_string( "MaximumFunction" ), 1 ) ),
  underflow_func( NULL ),
  regen_while_dead( elem.remove_bool( "RegenWhileDead", false ) )
{
  aliases.push_back( name );
  std::string tmp;
  while ( elem.remove_prop( "Alias", &tmp ) )
    aliases.push_back( tmp );

  if ( elem.remove_prop( "UnderflowFunction", &tmp ) )
  {
    underflow_func = FindExportedFunction( elem, pkg, tmp, 2 );
  }
}
コード例 #9
0
ファイル: attribute.cpp プロジェクト: gtozzi/polserver
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 );
  }
}
コード例 #10
0
ファイル: uoclient.cpp プロジェクト: gtozzi/polserver
void checkv( Clib::ConfigElem& elem, UoClientGeneral::Mapping& mapping, const char* tag )
{
  if ( !mapping.any )
  {
    std::string name;
    if ( elem.remove_prop( tag, &name ) )
    {
      mapping.name = name;
      mapping.any = true;
      Vital* pVital = FindVital( name );
      if ( pVital )
        mapping.id = pVital->vitalid;
      else
        elem.throw_error( "Vital " + name + " not found" );
    }
  }
}
コード例 #11
0
ファイル: uoclient.cpp プロジェクト: gtozzi/polserver
void checka( Clib::ConfigElem& elem, UoClientGeneral::Mapping& mapping, const char* tag )
{
  if ( !mapping.any )
  {
    std::string name;
    if ( elem.remove_prop( tag, &name ) )
    {
      mapping.name = name;
      mapping.any = true;
      Mobile::Attribute* pAttr = Mobile::Attribute::FindAttribute( name );
      if ( pAttr )
        mapping.id = pAttr->attrid;
      else
        elem.throw_error( "Attribute " + name + " not found" );
    }
  }
}
コード例 #12
0
ファイル: cmdlevel.cpp プロジェクト: polserver/polserver
void process_package_cmds_cfg( Plib::Package* pkg )
{
  // ConfigFile cf( (pkg->dir() + "cmds.cfg").c_str(), "Commands" );
  Clib::ConfigFile cf( GetPackageCfgPath( pkg, "cmds.cfg" ).c_str(), "Commands" );
  Clib::ConfigElem elem;
  while ( cf.read( elem ) )
  {
    CmdLevel* cmdlevel = find_cmdlevel( elem.rest() );
    if ( !cmdlevel )
    {
      elem.throw_error( std::string( "Command Level " ) + elem.rest() + " not found." );
    }

    std::string tmp;
    while ( elem.remove_prop( "DIR", &tmp ) )
    {
      Clib::mklower( tmp );
      cmdlevel->add_searchdir_front( pkg, Clib::normalized_dir_form( pkg->dir() + tmp ) );
    }
  }
}
コード例 #13
0
ファイル: resource.cpp プロジェクト: polserver/polserver
void load_resource_cfg()
{
  if ( !Clib::FileExists( "regions/resource.cfg" ) )
  {
    if ( Plib::systemstate.config.loglevel > 1 )
      INFO_PRINT << "File regions/resource.cfg not found, skipping.\n";
    return;
  }

  Clib::ConfigFile cf( "regions/resource.cfg", "ResourceSystem" );
  Clib::ConfigElem elem;
  while ( cf.read( elem ) )
  {
    std::string resourcename;
    while ( elem.remove_prop( "ResourceType", &resourcename ) )
    {
      read_resource_cfg( resourcename.c_str() );
    }
  }
  if ( Plib::systemstate.config.count_resource_tiles )
    count_resource_tiles();
}