本文整理汇总了C++中clib::ConfigElem类的典型用法代码示例。如果您正苦于以下问题:C++ ConfigElem类的具体用法?C++ ConfigElem怎么用?C++ ConfigElem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigElem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 );
}
}
示例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;
}
}
示例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;
}
}
}
示例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 );
}
}
}
示例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 );
}
}
}
示例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." );
}
}
}
}
示例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 );
}
示例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 );
}
示例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", "" ) )
{}
示例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;
}
}
}
}
示例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 );
}
示例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 )
{
}
示例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;
}
示例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;
}
}
示例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 );
}