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