示例#1
0
UOSkill::UOSkill( const Package* pkg, ConfigElem& elem ) :
    inited(true),
        skillid( strtoul( elem.rest(), NULL, 10 ) ),
    attributename(elem.remove_string( "Attribute", "" )),
    pAttr(NULL),
    pkg(pkg)
{
    if (skillid < 0 || 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 = FindAttribute( attributename );
        if (!pAttr)
        {
            if (required)
            {
                elem.throw_error( "Attribute " 
                                    + tostring(attributename)
                                    + " not found." );
            }
            else
            {
                elem.warn( "Attribute " 
                                    + tostring(attributename)
                                    + " not found." );
            }
        }
    }
}
示例#2
0
bool ConfigSection::matches( const ConfigElem& elem )
{
  if( elem.type_is( _sectname.c_str() ) )
  {
    if( _found && ( _flags & CST_UNIQUE ) )
    {
      elem.throw_error( "Section type " + _sectname + " found more than once" );
    }
    _found = true;
    return true;
  }
  else
  {
    return false;
  }
}
示例#3
0
void load_skill_entry( const Package* pkg, ConfigElem& elem )
{
    UOSkill uoskill( pkg, elem );

    if ( uoskill.skillid >= uo_skills.size() )
        uo_skills.resize( uoskill.skillid+1 );
    
    if ( uo_skills[uoskill.skillid].inited )
    {
        elem.throw_error( "UOSkill "
                            + tostring(uoskill.skillid) 
                            + " already defined by " 
                            + uo_skills[uoskill.skillid].pkg->desc() );
    }
    
    uo_skills[ uoskill.skillid ] = uoskill;
}