예제 #1
0
void CSMTools::ClassCheckStage::perform (int stage, std::vector<std::string>& messages)
{
    const ESM::Class& class_= mClasses.getRecord (stage).get();

    CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Class, class_.mId);

    // test for empty name and description
    if (class_.mName.empty())
        messages.push_back (id.toString() + "|" + class_.mId + " has an empty name");

    if (class_.mDescription.empty())
        messages.push_back (id.toString() + "|" + class_.mId + " has an empty description");

    // test for invalid attributes
    for (int i=0; i<2; ++i)
        if (class_.mData.mAttribute[i]==-1)
        {
            std::ostringstream stream;

            stream << id.toString() << "|Attribute #" << i << " of " << class_.mId << " is not set";

            messages.push_back (stream.str());
        }

    if (class_.mData.mAttribute[0]==class_.mData.mAttribute[1] && class_.mData.mAttribute[0]!=-1)
    {
        std::ostringstream stream;

        stream << id.toString() << "|Class lists same attribute twice";

        messages.push_back (stream.str());
    }

    // test for non-unique skill
    std::map<int, int> skills; // ID, number of occurrences

    for (int i=0; i<5; ++i)
        for (int i2=0; i2<2; ++i2)
            ++skills[class_.mData.mSkills[i][i2]];

    for (std::map<int, int>::const_iterator iter (skills.begin()); iter!=skills.end(); ++iter)
        if (iter->second>1)
        {
            std::ostringstream stream;

            stream
                << id.toString() << "|"
                << ESM::Skill::indexToId (iter->first) << " is listed more than once";

            messages.push_back (stream.str());
        }
}
예제 #2
0
void CSMTools::ScriptCheckStage::perform (int stage, std::vector<std::string>& messages)
{
    mMessages = &messages;
    mId = mData.getScripts().getId (stage);

    try
    {
        mFile = mData.getScripts().getRecord (stage).get().mId;
        std::istringstream input (mData.getScripts().getRecord (stage).get().mScriptText);

        Compiler::Scanner scanner (*this, input, mContext.getExtensions());

        Compiler::FileParser parser (*this, mContext);

        scanner.scan (parser);
    }
    catch (const Compiler::SourceException&)
    {
        // error has already been reported via error handler
    }
    catch (const std::exception& error)
    {
        std::ostringstream stream;

        CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Script, mId);

        stream << id.toString() << "|Critical compile error: " << error.what();

        messages.push_back (stream.str());
    }

    mMessages = 0;
}
예제 #3
0
void CSMTools::RaceCheckStage::performFinal (std::vector<std::string>& messages)
{
    CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Races);

    if (!mPlayable)
        messages.push_back (id.toString() + "|No playable race");
}
예제 #4
0
void CSMTools::FactionCheckStage::perform (int stage, std::vector<std::string>& messages)
{
    const CSMWorld::Record<ESM::Faction>& record = mFactions.getRecord (stage);

    if (record.isDeleted())
        return;

    const ESM::Faction& faction = record.get();

    CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Faction, faction.mId);

    // test for empty name
    if (faction.mName.empty())
        messages.push_back (id.toString() + "|" + faction.mId + " has an empty name");

    // test for invalid attributes
    if (faction.mData.mAttribute[0]==faction.mData.mAttribute[1] && faction.mData.mAttribute[0]!=-1)
    {
        std::ostringstream stream;

        stream << id.toString() << "|Faction lists same attribute twice";

        messages.push_back (stream.str());
    }

    // test for non-unique skill
    std::map<int, int> skills; // ID, number of occurrences

    for (int i=0; i<6; ++i)
        if (faction.mData.mSkills[i]!=-1)
            ++skills[faction.mData.mSkills[i]];

    for (std::map<int, int>::const_iterator iter (skills.begin()); iter!=skills.end(); ++iter)
        if (iter->second>1)
        {
            std::ostringstream stream;

            stream
                << id.toString() << "|"
                << ESM::Skill::indexToId (iter->first) << " is listed more than once";

            messages.push_back (stream.str());
        }

    /// \todo check data members that can't be edited in the table view
}
예제 #5
0
void CSMTools::ScriptCheckStage::report (const std::string& message, Type type)
{
    std::ostringstream stream;

    CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Script, mId);

    stream << id.toString() << "|";

    if (type==ErrorMessage)
        stream << "error: ";
    else
        stream << "warning: ";

    stream << message;

    mMessages->push_back (stream.str());
}
예제 #6
0
void CSMTools::RegionCheckStage::perform (int stage, std::vector<std::string>& messages)
{
    const CSMWorld::Record<ESM::Region>& record = mRegions.getRecord (stage);

    if (record.isDeleted())
        return;

    const ESM::Region& region = record.get();

    CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Region, region.mId);

    // test for empty name
    if (region.mName.empty())
        messages.push_back (id.toString() + "|" + region.mId + " has an empty name");

    /// \todo test that the ID in mSleeplist exists

    /// \todo check data members that can't be edited in the table view
}
예제 #7
0
void CSMTools::ScriptCheckStage::report (const std::string& message, const Compiler::TokenLoc& loc,
    Type type)
{
    std::ostringstream stream;

    CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Script, mId);

    stream << id.toString() << "|";

    if (type==ErrorMessage)
        stream << "error ";
    else
        stream << "warning ";

    stream
        << "script " << mFile
        << ", line " << loc.mLine << ", column " << loc.mColumn
        << " (" << loc.mLiteral << "): " << message;

    mMessages->push_back (stream.str());
}
예제 #8
0
void CSMTools::RaceCheckStage::performPerRecord (int stage, std::vector<std::string>& messages)
{
    const CSMWorld::Record<ESM::Race>& record = mRaces.getRecord (stage);

    if (record.isDeleted())
        return;

    const ESM::Race& race = record.get();

    CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Race, race.mId);

    // test for empty name and description
    if (race.mName.empty())
        messages.push_back (id.toString() + "|" + race.mId + " has an empty name");

    if (race.mDescription.empty())
        messages.push_back (id.toString() + "|" + race.mId + " has an empty description");

    // test for positive height
    if (race.mData.mHeight.mMale<=0)
        messages.push_back (id.toString() + "|male " + race.mId + " has non-positive height");

    if (race.mData.mHeight.mFemale<=0)
        messages.push_back (id.toString() + "|female " + race.mId + " has non-positive height");

    // test for non-negative weight
    if (race.mData.mWeight.mMale<0)
        messages.push_back (id.toString() + "|male " + race.mId + " has negative weight");

    if (race.mData.mWeight.mFemale<0)
        messages.push_back (id.toString() + "|female " + race.mId + " has negative weight");

    // remember playable flag
    if (race.mData.mFlags & 0x1)
        mPlayable = true;

    /// \todo check data members that can't be edited in the table view
}