Example #1
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 );
	}
Example #2
0
	NpcTemplate::NpcTemplate( const Clib::ConfigElem& elem, const Plib::Package* pkg ) :
	  intrinsic_weapon( Items::find_intrinsic_weapon( elem.rest() ) ),
	  pkg( pkg ),
	  // script( elem.read_string( "SCRIPT" ) ),
	  alignment( static_cast<ALIGNMENT>( translate( elem.read_string( "ALIGNMENT", "neutral" ), xlate_align ) ) ),
	  method_script( NULL )
	{
	  if ( pkg == NULL )
	  {
		name = elem.rest();
	  }
	  else
	  {
		if ( elem.rest()[0] == ':' )
		{
		  name = elem.rest();
		}
		else
		{
		  name = ":" + pkg->name() + ":" + elem.rest();
		}
	  }

	  if ( elem.has_prop( "MethodScript" ) )
	  {
		std::string temp = elem.read_string( "MethodScript" );
		if ( !temp.empty() )
		{
		  ExportScript* shs = new ExportScript( pkg, temp );
		  if ( shs->Initialize() )
			method_script = shs;
		  else
			delete shs;
		}
	  }
	}