本文整理汇总了C++中clib::ConfigElem::rest方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigElem::rest方法的具体用法?C++ ConfigElem::rest怎么用?C++ ConfigElem::rest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clib::ConfigElem
的用法示例。
在下文中一共展示了ConfigElem::rest方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: 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 );
}
}
示例3: 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." );
}
}
}
}
示例4: 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", "" ) )
{}
示例5: read_region_data
void read_region_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" );
}
std::string regionname = elem.remove_string( "Name" );
ResourceRegion* rgn = rd->getregion( regionname );
if ( rgn == nullptr )
{
ERROR_PRINT << "Error reading RESOURCE.DAT: Unable to find region " << regionname
<< " in resource " << elem.rest() << "\n";
throw std::runtime_error( "Data file error" );
}
rgn->read_data( elem );
}
示例6: process_package_cmds_cfg
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 ) );
}
}
}
示例7: 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;
}
}
示例8: pkg
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;
}
}
}
示例9: 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 );
}
}
示例10: load_system_hooks
void load_system_hooks()
{
/*
system_hooks.clear();
while (!export_scripts.empty())
{
delete export_scripts.back();
export_scripts.pop_back();
}
*/
for ( Plib::Packages::const_iterator citr = Plib::systemstate.packages.begin( ); citr != Plib::systemstate.packages.end( ); ++citr )
{
Plib::Package* pkg = ( *citr );
//string fname = pkg->dir() + "syshook.cfg";
std::string fname = Plib::GetPackageCfgPath(pkg, "syshook.cfg");
if ( Clib::FileExists( fname.c_str() ) )
{
Clib::ConfigFile cf( fname.c_str( ), "SystemHookScript" );
Clib::ConfigElem elem;
while ( cf.read( elem ) )
{
ExportScript* shs = new ExportScript( pkg, elem.rest() );
if ( shs->Initialize() )
{
gamestate.export_scripts.push_back( shs );
std::string hookname, exfuncname;
while ( elem.remove_first_prop( &hookname, &exfuncname ) )
{
if ( exfuncname.empty() )
exfuncname = hookname;
hook( shs, hookname, exfuncname );
}
}
else
{
delete shs;
}
}
}
}
}
示例11: pkg
Vital::Vital( const Plib::Package* pkg, Clib::ConfigElem& elem ) :
pkg( pkg ),
name( elem.rest() ),
aliases(),
vitalid( 0 ),
next( NULL ),
get_regenrate_func( FindExportedFunction( elem, pkg, elem.remove_string( "RegenRateFunction" ), 1 ) ),
get_maximum_func( FindExportedFunction( elem, pkg, elem.remove_string( "MaximumFunction" ), 1 ) ),
underflow_func( NULL ),
regen_while_dead( elem.remove_bool( "RegenWhileDead", false ) )
{
aliases.push_back( name );
std::string tmp;
while ( elem.remove_prop( "Alias", &tmp ) )
aliases.push_back( tmp );
if ( elem.remove_prop( "UnderflowFunction", &tmp ) )
{
underflow_func = FindExportedFunction( elem, pkg, tmp, 2 );
}
}
示例12: pkg
Attribute::Attribute( const Plib::Package* pkg, Clib::ConfigElem& elem ) :
pkg( pkg ),
name( elem.rest() ),
attrid( 0 ),
aliases(),
next( NULL ),
getintrinsicmod_func( nullptr ),
delay_seconds( elem.remove_ushort( "DELAY", 0 ) ),
unhides( elem.remove_bool( "UNHIDES", true ) ),
disable_core_checks( elem.remove_bool( "DisableCoreChecks", false ) ),
default_cap( elem.remove_ushort( "DefaultCap", Core::settingsManager.ssopt.default_attribute_cap ) ),
script_( elem.remove_string( "SCRIPT", "" ), pkg, "scripts/skills/" )
{
aliases.push_back( name );
std::string tmp;
while ( elem.remove_prop( "Alias", &tmp ) )
aliases.push_back( tmp );
if ( elem.remove_prop( "GetIntrinsicModFunction", &tmp ) )
{
getintrinsicmod_func = Core::FindExportedFunction( elem, pkg, tmp, 1 );
}
}
示例13: read_npc_templates
void read_npc_templates( Plib::Package* pkg )
{
std::string filename = GetPackageCfgPath( pkg, "npcdesc.cfg" );
if ( !Clib::FileExists( filename ) )
return;
Clib::ConfigFile cf( filename.c_str() );
Clib::ConfigElem elem;
while ( cf.read( elem ) )
{
if ( elem.type_is( "NpcTemplate" ) )
{
// first determine the NPC template name.
std::string namebase;
const char* rest = elem.rest();
if ( rest != NULL && *rest != '\0' )
{
namebase = rest;
}
else
{
namebase = elem.remove_string( "TemplateName" );
}
std::string descname;
if ( pkg != NULL )
{
descname = ":" + pkg->name() + ":" + namebase;
elem.set_rest( descname.c_str() );
}
else
descname = namebase;
gamestate.npc_template_elems[descname] = NpcTemplateElem( cf, elem );
}
}
}
示例14: FindNpcTemplate
// FIXME inefficient. Templates should be read in once, and reused.
bool FindNpcTemplate( const char* template_name, Clib::ConfigFile& cf, Clib::ConfigElem& elem )
{
try
{
const Plib::Package* pkg;
std::string npctemplate;
if ( !Plib::pkgdef_split( template_name, NULL, &pkg, &npctemplate ) )
return false;
std::string filename =
Plib::GetPackageCfgPath( const_cast<Plib::Package*>( pkg ), "npcdesc.cfg" );
cf.open( filename.c_str() );
while ( cf.read( elem ) )
{
if ( !elem.type_is( "NpcTemplate" ) )
continue;
std::string orig_rest = elem.rest();
if ( pkg != NULL )
{
std::string newrest = ":" + pkg->name() + ":" + npctemplate;
elem.set_rest( newrest.c_str() );
}
const char* rest = elem.rest();
if ( rest != NULL && *rest != '\0' )
{
if ( stricmp( orig_rest.c_str(), npctemplate.c_str() ) == 0 )
return true;
}
else
{
std::string tname = elem.remove_string( "TemplateName" );
if ( stricmp( tname.c_str(), npctemplate.c_str() ) == 0 )
return true;
}
}
return false;
}
catch ( const char* msg )
{
ERROR_PRINT << "NPC Creation (" << template_name << ") Failed: " << msg << "\n";
}
catch ( std::string& str )
{
ERROR_PRINT << "NPC Creation (" << template_name << ") Failed: " << str << "\n";
} // egcs has some trouble realizing 'exception' should catch
catch ( std::runtime_error& re ) // runtime_errors, so...
{
ERROR_PRINT << "NPC Creation (" << template_name << ") Failed: " << re.what() << "\n";
}
catch ( std::exception& ex )
{
ERROR_PRINT << "NPC Creation (" << template_name << ") Failed: " << ex.what() << "\n";
}
#ifndef WIN32
catch ( ... )
{
}
#endif
return false;
}