예제 #1
0
UOSkill::UOSkill( const Plib::Package* pkg, Clib::ConfigElem& elem )
    : inited( true ),
      skillid( strtoul( elem.rest(), nullptr, 10 ) ),
      attributename( elem.remove_string( "Attribute", "" ) ),
      pAttr( nullptr ),
      pkg( pkg )
{
  if ( skillid >= 500 )
    elem.throw_error( "SkillID must be < 500" );

  if ( !attributename.empty() )
  {
    bool required = false;
    if ( attributename[0] == '+' )
    {
      required = true;
      attributename = attributename.substr( 1, std::string::npos );
    }
    pAttr = Mobile::Attribute::FindAttribute( attributename );
    if ( !pAttr )
    {
      if ( required )
      {
        elem.throw_error( "Attribute " + attributename + " not found." );
      }
      else
      {
        elem.warn( "Attribute " + attributename + " not found." );
      }
    }
  }
}
예제 #2
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 );
	  }
	}
예제 #3
0
	void Account::readfrom( Clib::ConfigElem& elem )
	{
	  if ( elem.has_prop( "Password" ) )
	  {
        std::string temppass = elem.remove_string("Password");
		if ( Plib::systemstate.config.retain_cleartext_passwords )
		{
		  password_ = temppass;
		}
		if ( !Clib::MD5_Encrypt( name_ + temppass, passwordhash_ ) )	//MD5
		  elem.throw_error( "Failed to encrypt password for " + name_ );
		Plib::systemstate.accounts_txt_dirty = true;
	  }
	  else if ( elem.has_prop( "PasswordHash" ) )
	  {
		passwordhash_ = elem.remove_string( "PasswordHash" );
	  }
	  else
		elem.throw_error( "Failed password reads for account " + name_ );

	  enabled_ = elem.remove_bool( "ENABLED", true );
	  banned_ = elem.remove_bool( "BANNED", false );
	  uo_expansion_ = convert_uo_expansion( elem.remove_string( "UOExpansion", "T2A" ) );

	  default_privs_.readfrom( elem.remove_string( "DefaultPrivs", "" ) );

	  std::string cmdaccstr = elem.remove_string( "DefaultCmdLevel", "player" );
	  Core::CmdLevel* cmdlevel_search = Core::find_cmdlevel( cmdaccstr.c_str( ) );
	  if ( cmdlevel_search != NULL )
		default_cmdlevel_ = cmdlevel_search->cmdlevel;
	  else
		elem.throw_error( "Didn't understand cmdlevel of '" + cmdaccstr + "'" );

	  props_.clear();
	  props_.readProperties( elem );
	}
예제 #4
0
void load_skill_entry( const Plib::Package* pkg, Clib::ConfigElem& elem )
{
  UOSkill uoskill( pkg, elem );

  if ( uoskill.skillid >= gamestate.uo_skills.size() )
    gamestate.uo_skills.resize( uoskill.skillid + 1 );

  if ( gamestate.uo_skills[uoskill.skillid].inited )
  {
    elem.throw_error( "UOSkill " + fmt::FormatInt( uoskill.skillid ).str() +
                      " already defined by " + gamestate.uo_skills[uoskill.skillid].pkg->desc() );
  }

  gamestate.uo_skills[uoskill.skillid] = uoskill;
}
예제 #5
0
RealmDescriptor RealmDescriptor::Load(const std::string& realm_name, const std::string& realm_path)
{
  std::string realm_cfg_filename;
  if ( realm_path == "" )
    realm_cfg_filename = "realm/" + realm_name + "/realm.cfg";
  else
    realm_cfg_filename = realm_path + "/realm.cfg";

  Clib::ConfigFile cf( realm_cfg_filename, "REALM" );
  Clib::ConfigElem elem;
  if ( !cf.read( elem ) )
    elem.throw_error( "Unable to read configuration file " + realm_cfg_filename );

  return RealmDescriptor( realm_name, realm_path, elem );
}
예제 #6
0
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" );
    }
  }
}
예제 #7
0
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" );
    }
  }
}
예제 #8
0
void load_attribute_entry( const Plib::Package* pkg, Clib::ConfigElem& elem )
{
  auto attr = new Attribute( pkg, elem );

  const Attribute* existing = Attribute::FindAttribute( attr->name );
  if ( existing )
  {
    elem.throw_error( "Attribute " + attr->name + " already defined by "
                      + existing->pkg->desc() );
  }
  attr->attrid = static_cast<unsigned int>( Core::gamestate.attributes.size() );
  if ( !Core::gamestate.attributes.empty() )
    Core::gamestate.attributes.back()->next = attr;
  Core::gamestate.attributes.push_back( attr );
  for ( unsigned i = 0; i < attr->aliases.size(); ++i )
  {
    Core::gamestate.attributes_byname[attr->aliases[i]] = attr;
  }
}
예제 #9
0
파일: vital.cpp 프로젝트: gtozzi/polserver
void load_vital_entry( const Plib::Package* pkg, Clib::ConfigElem& elem )
{
  Vital* vital = new Vital( pkg, elem );

  const Vital* existing = FindVital( vital->name );
  if ( existing )
  {
    elem.throw_error( "Vital " + vital->name + " already defined by "
                      + existing->pkg->desc() );
  }
  vital->vitalid = static_cast<unsigned int>( gamestate.vitals.size() );
  if ( !gamestate.vitals.empty() )
    gamestate.vitals.back()->next = vital;
  gamestate.vitals.push_back( vital );

  for ( unsigned i = 0; i < vital->aliases.size(); ++i )
  {
    gamestate.vitals_byname[vital->aliases[i]] = vital;
  }
}
예제 #10
0
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 ) );
    }
  }
}