• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ clib::ConfigElem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中clib::ConfigElem的典型用法代码示例。如果您正苦于以下问题:C++ ConfigElem类的具体用法?C++ ConfigElem怎么用?C++ ConfigElem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ConfigElem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: load_circle_data

	void load_circle_data()
	{
	  if ( !Clib::FileExists( "config/circles.cfg" ) )
	  {
		if ( config.loglevel > 1 )
		  INFO_PRINT << "File config/circles not found, skipping.\n";
		return;
	  }

      Clib::ConfigFile cf( "config/circles.cfg", "Circle" );
      Clib::ConfigElem elem;

	  while ( cf.read( elem ) )
	  {
		int index = strtoul( elem.rest(), NULL, 0 ) - 1;
		if ( index < 0 || index >= 100 )
		{
          ERROR_PRINT << "Error in CIRCLES.CFG: Circle must fall between 1 and 100\n";
		  throw std::runtime_error( "Config file error" );
		}

		spellcircles.resize( index + 1, NULL );

		if ( spellcircles[index] != NULL )
		{
          ERROR_PRINT << "Error in CIRCLES.CFG: Circle " << index + 1 << " is multiply defined.\n";
		  throw std::runtime_error( "Config file error" );
		}

		spellcircles[index] = new SpellCircle( elem );
	  }
	}
开发者ID:Lolkauo,项目名称:polserver,代码行数:32,代码来源:spells.cpp


示例2: create_intrinsic_shield_from_npctemplate

/// Creates a new intrinic shield for an NPC template and returns it
/// @param elem: The conig element defining the NPC
/// @param pkg: The package
/// @returns The created shield or NULL if none is defined in the template
UArmor* create_intrinsic_shield_from_npctemplate( Clib::ConfigElem& elem, const Plib::Package* pkg )
{
  std::string tmp;
  if ( elem.remove_prop( "Shield", &tmp ) )
  {
    // Construct an ArmorTemplate for this NPC template.
    Clib::ConfigElem shieldelem;
    shieldelem.set_rest( elem.rest() );
    shieldelem.set_source( elem );
    shieldelem.add_prop( "Objtype", "0xFFFF" );
    shieldelem.add_prop( "Graphic", "1" );
    shieldelem.add_prop( "SaveOnExit", "0" );
    shieldelem.add_prop( "AR", tmp.c_str() );

    if ( elem.remove_prop( "ShieldMaxHp", &tmp ) )
      shieldelem.add_prop( "MaxHP", tmp.c_str() );
    else
      shieldelem.add_prop( "MaxHP", "1" );

    if ( elem.remove_prop( "ShieldOnHitScript", &tmp ) )
      shieldelem.add_prop( "OnHitScript", tmp.c_str() );

    while ( elem.remove_prop("ShieldCProp", &tmp) )
      shieldelem.add_prop( "CProp", tmp.c_str() );

    return create_intrinsic_shield( elem.rest(), shieldelem, pkg );
  }
  else
  {
    return NULL;
  }
}
开发者ID:gtozzi,项目名称:polserver,代码行数:36,代码来源:armor.cpp


示例3: load_general_entry

// 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;
    }
  }
}
开发者ID:gtozzi,项目名称:polserver,代码行数:37,代码来源:uoclient.cpp


示例4: read_bannedips_config

	void read_bannedips_config( bool initial_load )
	{
	  if ( !initial_load )
	  {
		Core::networkManager.banned_ips.clear();
	  }
	  if ( !Clib::FileExists( "config/bannedips.cfg" ) )
		return;

	  Clib::ConfigFile cf( "config/bannedips.cfg" );
	  Clib::ConfigElem elem;

	  while ( cf.read( elem ) )
	  {
		IPRule CurrentEntry;
		std::string iptext = elem.remove_string( "IPMatch" );
		std::string::size_type 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);
		  CurrentEntry.ipMatch = inet_addr( ipaddr_str.c_str() );
		  CurrentEntry.ipMask = inet_addr( ipmask_str.c_str() );
		  Core::networkManager.banned_ips.push_back( CurrentEntry );
		}
		else
		{
          std::string ipmask_str = "255.255.255.255";
		  CurrentEntry.ipMatch = inet_addr( iptext.c_str() );
		  CurrentEntry.ipMask = inet_addr( ipmask_str.c_str() );
		  Core::networkManager.banned_ips.push_back( CurrentEntry );
		}
	  }
	}
开发者ID:byterj,项目名称:POL_099b,代码行数:34,代码来源:bannedips.cpp


示例5: while

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 );
    }
  }
}
开发者ID:gtozzi,项目名称:polserver,代码行数:26,代码来源:auxclient.cpp


示例6: inited

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." );
      }
    }
  }
}
开发者ID:polserver,项目名称:polserver,代码行数:32,代码来源:uoskills.cpp


示例7: port

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 );
}
开发者ID:gtozzi,项目名称:polserver,代码行数:8,代码来源:uoclient.cpp


示例8: load_uoclient_entry

void load_uoclient_entry( const Plib::Package* pkg, Clib::ConfigElem& elem )
{
  if ( elem.type_is( "general" ) )
    load_general_entry( pkg, elem );
  else if ( elem.type_is( "protocol" ) )
    load_protocol_entry( pkg, elem );
  else if ( elem.type_is( "listener" ) )
    load_listener_entry( pkg, elem );
}
开发者ID:gtozzi,项目名称:polserver,代码行数:9,代码来源:uoclient.cpp


示例9: Region

	JusticeRegion::JusticeRegion( Clib::ConfigElem& elem, RegionId id ) :
	  Region( elem, id ),
	  guarded_( elem.remove_bool( "Guarded", false ) ),
	  nocombat_( elem.remove_bool( "NoCombat", false ) ),
	  region_name_( elem.rest() ),
	  entertext_( elem.remove_string( "EnterText", "" ) ),
	  leavetext_( elem.remove_string( "LeaveText", "" ) ),
	  enter_script_( elem.remove_string( "EnterScript", "" ) ),
	  leave_script_( elem.remove_string( "LeaveScript", "" ) )
	{}
开发者ID:byterj,项目名称:POL_099b,代码行数:10,代码来源:guardrgn.cpp


示例10: EquipDesc

/// 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;
      }
    }
  }
}
开发者ID:JohnnyB1971,项目名称:polserver,代码行数:57,代码来源:armor.cpp


示例11: read_global_data

void read_global_data( Clib::ConfigElem& elem )
{
  ResourceDef* rd = find_resource_def( elem.rest() );
  if ( rd == nullptr )
  {
    ERROR_PRINT << "Error reading RESOURCE.DAT: Unable to find resource type " << elem.rest()
                << "\n";
    throw std::runtime_error( "Data file error" );
  }

  rd->read_data( elem );
}
开发者ID:polserver,项目名称:polserver,代码行数:12,代码来源:resource.cpp


示例12: Region

/// Resource Management
ResourceRegion::ResourceRegion( Clib::ConfigElem& elem, RegionId id )
    : Region( elem, id ),
      tilecount_( 0 ),

      units_per_area_( elem.remove_ulong( "UnitsPerArea" ) ),
      seconds_per_regrow_( elem.remove_ulong( "SecondsPerRegrow" ) ),
      last_regen_( poltime() ),

      capacity_( elem.remove_ulong( "Capacity" ) ),
      units_( 0 )

{
}
开发者ID:polserver,项目名称:polserver,代码行数:14,代码来源:resource.cpp


示例13: readProperties

	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;
	}
开发者ID:vitorfdl,项目名称:polserver,代码行数:14,代码来源:corpse.cpp


示例14: read_multidefs

	void read_multidefs()
	{
      Clib::ConfigFile cf( "config/multis.cfg", "BOAT HOUSE STAIRS" );
      Clib::ConfigElem elem;
	  while ( cf.read( elem ) )
	  {
		u16 multiid = static_cast<u16>( strtoul( elem.rest(), NULL, 0 ) );

		MultiDef* mdef = new MultiDef( elem, multiid );
		mdef->init();

		multidef_buffer.multidefs_by_multiid[mdef->multiid] = mdef;
	  }
	}
开发者ID:AlessandroMamusa,项目名称:polserver,代码行数:14,代码来源:multidef.cpp


示例15: writeto

	void Account::writeto( Clib::ConfigElem& elem ) const
	{
	  elem.add_prop( "Name", name_.c_str() );

	  //dave 6/5/3 don't write cleartext unless configured to
	  if ( Plib::systemstate.config.retain_cleartext_passwords && !password_.empty( ) )
		elem.add_prop( "Password", password_.c_str() );

	  elem.add_prop( "PasswordHash", passwordhash_.c_str() );

	  elem.add_prop( "Enabled", ( (unsigned int)( enabled_ ? 1 : 0 ) ) );
	  elem.add_prop( "Banned", ( (unsigned int)( banned_ ? 1 : 0 ) ) );

	  if ( !default_privs_.empty() )
	  {
		elem.add_prop( "DefaultPrivs", default_privs_.extract().c_str() );
	  }
	  if ( default_cmdlevel_ )
	  {
		elem.add_prop( "DefaultCmdLevel", Core::gamestate.cmdlevels[default_cmdlevel_].name.c_str( ) );
	  }
	  if ( uo_expansion_ )
	  {
		elem.add_prop( "UOExpansion", uo_expansion().c_str() );
	  }
	  props_.printProperties( elem );
	}
开发者ID:AlessandroMamusa,项目名称:polserver,代码行数:27,代码来源:account.cpp


示例16: add_npc

	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;
	}
开发者ID:AlessandroMamusa,项目名称:polserver,代码行数:26,代码来源:testenv.cpp


示例17: Load

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 );
}
开发者ID:gtozzi,项目名称:polserver,代码行数:15,代码来源:realmdescriptor.cpp


示例18: set_watch_vars

void set_watch_vars()
{
  Clib::ConfigFile cf;
  Clib::ConfigElem elem;
  if ( Clib::FileExists( "config/watch.cfg" ) )
  {
    cf.open( "config/watch.cfg" );
    cf.readraw( elem );
  }
  else if ( Plib::systemstate.config.loglevel > 1 )
    INFO_PRINT << "File config/watch.cfg not found, skipping.\n";

  settingsManager.watch.combat = elem.remove_bool( "COMBAT", false );
  settingsManager.watch.profile_scripts = elem.remove_bool( "ProfileScripts", false );
}
开发者ID:JohnnyB1971,项目名称:polserver,代码行数:15,代码来源:settings.cpp


示例19: name

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 );
  }
}
开发者ID:polserver,项目名称:polserver,代码行数:16,代码来源:cmdlevel.cpp


示例20: checkv

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" );
    }
  }
}
开发者ID:gtozzi,项目名称:polserver,代码行数:17,代码来源:uoclient.cpp



注:本文中的clib::ConfigElem类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ client::Context类代码示例发布时间:2022-05-31
下一篇:
C++ clang::Token类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap