本文整理汇总了C++中clib::ConfigElem::throw_error方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigElem::throw_error方法的具体用法?C++ ConfigElem::throw_error怎么用?C++ ConfigElem::throw_error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clib::ConfigElem
的用法示例。
在下文中一共展示了ConfigElem::throw_error方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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." );
}
}
}
}
示例2: runtime_error
USpell::USpell( Clib::ConfigElem& elem, Plib::Package* pkg ) :
pkg_( pkg ),
spellid_( elem.remove_ushort( "SPELLID" ) ),
name_( elem.remove_string( "NAME" ) ),
power_words_( elem.remove_string( "POWERWORDS" ) ),
scriptdef_( elem.remove_string( "SCRIPT", "" ), pkg, "scripts/" )
{
unsigned short action;
if ( elem.remove_prop( "ANIMATION", &action ) )
{
if ( UACTION_IS_VALID( action ) )
{
action_ = static_cast<UACTION>( action );
}
else
{
elem.throw_error( "Animation is out of range" );
}
}
else
{
action_ = ACTION_CAST_SPELL1;
}
unsigned short circle;
if ( elem.remove_prop( "CIRCLE", &circle ) )
{
if ( circle < 1 || circle > spellcircles.size() ||
spellcircles[circle - 1] == NULL )
{
ERROR_PRINT << "Error reading spell " << name_
<< ": Circle " << circle << " is not defined.\n";
throw std::runtime_error( "Config file error" );
}
params_ = spellcircles[circle - 1]->params;
}
else
{
params_ = USpellParams( elem );
}
std::string reagent_name;
while ( elem.remove_prop( "Reagent", &reagent_name ) )
{
unsigned int reagent = Items::get_objtype_from_string( reagent_name );
reglist_.push_back( reagent );
}
}
示例3: readfrom
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 );
}
示例4: load_skill_entry
void load_skill_entry( const Plib::Package* pkg, Clib::ConfigElem& elem )
{
UOSkill uoskill( pkg, elem );
if ( uoskill.skillid >= gamestate.uo_skills.size() )
gamestate.uo_skills.resize( uoskill.skillid + 1 );
if ( gamestate.uo_skills[uoskill.skillid].inited )
{
elem.throw_error( "UOSkill " + fmt::FormatInt( uoskill.skillid ).str() +
" already defined by " + gamestate.uo_skills[uoskill.skillid].pkg->desc() );
}
gamestate.uo_skills[uoskill.skillid] = uoskill;
}
示例5: 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 );
}
示例6: 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" );
}
}
}
示例7: checka
void checka( 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;
Mobile::Attribute* pAttr = Mobile::Attribute::FindAttribute( name );
if ( pAttr )
mapping.id = pAttr->attrid;
else
elem.throw_error( "Attribute " + name + " not found" );
}
}
}
示例8: load_attribute_entry
void load_attribute_entry( const Plib::Package* pkg, Clib::ConfigElem& elem )
{
auto attr = new Attribute( pkg, elem );
const Attribute* existing = Attribute::FindAttribute( attr->name );
if ( existing )
{
elem.throw_error( "Attribute " + attr->name + " already defined by "
+ existing->pkg->desc() );
}
attr->attrid = static_cast<unsigned int>( Core::gamestate.attributes.size() );
if ( !Core::gamestate.attributes.empty() )
Core::gamestate.attributes.back()->next = attr;
Core::gamestate.attributes.push_back( attr );
for ( unsigned i = 0; i < attr->aliases.size(); ++i )
{
Core::gamestate.attributes_byname[attr->aliases[i]] = attr;
}
}
示例9: load_vital_entry
void load_vital_entry( const Plib::Package* pkg, Clib::ConfigElem& elem )
{
Vital* vital = new Vital( pkg, elem );
const Vital* existing = FindVital( vital->name );
if ( existing )
{
elem.throw_error( "Vital " + vital->name + " already defined by "
+ existing->pkg->desc() );
}
vital->vitalid = static_cast<unsigned int>( gamestate.vitals.size() );
if ( !gamestate.vitals.empty() )
gamestate.vitals.back()->next = vital;
gamestate.vitals.push_back( vital );
for ( unsigned i = 0; i < vital->aliases.size(); ++i )
{
gamestate.vitals_byname[vital->aliases[i]] = vital;
}
}
示例10: 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 ) );
}
}
}