• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ esm::ESMReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中esm::ESMReader的典型用法代码示例。如果您正苦于以下问题:C++ ESMReader类的具体用法?C++ ESMReader怎么用?C++ ESMReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ESMReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: addMasters

void DataFilesModel::addMasters(const QString &path)
{
    QDir dir(path);
    dir.setNameFilters(QStringList(QLatin1String("*.esp")));

    // Read the dependencies from the plugins
    foreach (const QString &path, dir.entryList()) {
        try {
            ESM::ESMReader fileReader;
            fileReader.setEncoding(mEncoding.toStdString());
            fileReader.open(dir.absoluteFilePath(path).toStdString());

            ESM::ESMReader::MasterList mlist = fileReader.getMasters();

            for (unsigned int i = 0; i < mlist.size(); ++i) {
                QString master = QString::fromStdString(mlist[i].name);

                // Add the plugin to the internal dependency map
                mDependencies[master].append(path);

                // Don't add esps
                if (master.endsWith(".esp", Qt::CaseInsensitive))
                    continue;

                QFileInfo info(dir.absoluteFilePath(master));

                EsmFile *file = new EsmFile(master);
                file->setDates(info.lastModified(), info.lastRead());

                // Add the master to the table
                if (findItem(master) == 0)
                    addFile(file);


            }

        } catch(std::runtime_error &e) {
            // An error occurred while reading the .esp
            qWarning() << "Error reading esp: " << e.what();
            continue;
        }
    }

    // See if the masters actually exist in the filesystem
    dir.setNameFilters(QStringList(QLatin1String("*.esm")));

    foreach (const QString &path, dir.entryList()) {
        QFileInfo info(dir.absoluteFilePath(path));

        if (findItem(path) == 0) {
            EsmFile *file = new EsmFile(path);
            file->setDates(info.lastModified(), info.lastRead());

            addFile(file);
        }

        // Make the master selectable
        mAvailableFiles.append(path);
    }
}
开发者ID:Gohan1989,项目名称:openmw,代码行数:60,代码来源:datafilesmodel.cpp


示例2: loadGame

void MWState::StateManager::loadGame(const std::string& filepath)
{
    for (CharacterIterator it = mCharacterManager.begin(); it != mCharacterManager.end(); ++it)
    {
        const MWState::Character& character = *it;
        for (MWState::Character::SlotIterator slotIt = character.begin(); slotIt != character.end(); ++slotIt)
        {
            const MWState::Slot& slot = *slotIt;
            if (slot.mPath == boost::filesystem::path(filepath))
            {
                loadGame(&character, slot.mPath.string());
                return;
            }
        }
    }

    // have to peek into the save file to get the player name
    ESM::ESMReader reader;
    reader.open (filepath);
    if (reader.getRecName()!=ESM::REC_SAVE)
        return; // invalid save file -> ignore
    reader.getRecHeader();
    ESM::SavedGame profile;
    profile.load (reader);
    reader.close();

    MWState::Character* character = mCharacterManager.getCurrentCharacter(true, profile.mPlayerName);
    loadGame(character, filepath);
    mTimePlayed = profile.mTimePlayed;
}
开发者ID:ChairGraveyard,项目名称:TES3MP,代码行数:30,代码来源:statemanagerimp.cpp


示例3: if

void CSMWorld::RefIdCollection::load (ESM::ESMReader& reader, bool base, UniversalId::Type type)
{
    std::string id = reader.getHNOString ("NAME");

    int index = searchId (id);

    if (reader.isNextSub ("DELE"))
    {
        reader.skipRecord();

        if (index==-1)
        {
            // deleting a record that does not exist

            // ignore it for now

            /// \todo report the problem to the user
        }
        else if (base)
        {
            mData.erase (index, 1);
        }
        else
        {
            mData.getRecord (mData.globalToLocalIndex (index)).mState = RecordBase::State_Deleted;
        }
    }
    else
    {
        if (index==-1)
        {
            // new record
            int index = mData.getAppendIndex (type);
            mData.appendRecord (type, id);

            RefIdData::LocalIndex localIndex = mData.globalToLocalIndex (index);

            mData.load (localIndex, reader, base);

            mData.getRecord (localIndex).mState =
                base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
        }
        else
        {
            // old record
            RefIdData::LocalIndex localIndex = mData.globalToLocalIndex (index);

            if (!base)
                if (mData.getRecord (localIndex).mState==RecordBase::State_Erased)
                    throw std::logic_error ("attempt to access a deleted record");

            mData.load (localIndex, reader, base);

            if (!base)
                mData.getRecord (localIndex).mState = RecordBase::State_Modified;
        }
    }
}
开发者ID:Riverwolf,项目名称:openmw,代码行数:58,代码来源:refidcollection.cpp


示例4: if

    void IdCollection<ESXRecordT>::load (ESM::ESMReader& reader, bool base)
    {
        std::string id = reader.getHNOString ("NAME");

        if (reader.isNextSub ("DELE"))
        {
            int index = searchId (id);

            reader.skipRecord();

            if (index==-1)
            {
                // deleting a record that does not exist

                // ignore it for now

                /// \todo report the problem to the user
            }
            else if (base)
            {
                removeRows (index, 1);
            }
            else
            {
                mRecords[index].mState = RecordBase::State_Deleted;
            }
        }
        else
        {
            ESXRecordT record;
            record.mId = id;
            record.load (reader);

            int index = searchId (record.mId);

            if (index==-1)
            {
                // new record
                Record<ESXRecordT> record2;
                record2.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
                (base ? record2.mBase : record2.mModified) = record;

                appendRecord (record2);
            }
            else
            {
                // old record
                Record<ESXRecordT>& record2 = mRecords[index];

                if (base)
                    record2.mBase = record;
                else
                    record2.setModified (record);
            }
        }
    }
开发者ID:4DA,项目名称:openmw,代码行数:56,代码来源:idcollection.hpp


示例5: load

    void REFR::load(ESM::ESMReader &esm)
    {
        esm.getHNT(mRefNum.mIndex, "FRMR");

        mRefID = esm.getHNString("NAME");

        mActorData.load(esm);

        esm.getHNOT(mPos, "DATA", 24);
    }
开发者ID:A1-Triard,项目名称:openmw,代码行数:10,代码来源:importplayer.cpp


示例6: condLoad

 bool Land::condLoad(ESM::ESMReader& reader, int flags, int dataFlag, void *ptr, unsigned int size) const
 {
     if ((mDataLoaded & dataFlag) == 0 && (flags & dataFlag) != 0) {
         reader.getHExact(ptr, size);
         mDataLoaded |= dataFlag;
         return true;
     }
     reader.skipHSubSize(size);
     return false;
 }
开发者ID:Edgarins29,项目名称:openmw,代码行数:10,代码来源:loadland.cpp


示例7: readRecord

    bool ESMStore::readRecord (ESM::ESMReader& reader, uint32_t type)
    {
        switch (type)
        {
            case ESM::REC_ALCH:
            case ESM::REC_ARMO:
            case ESM::REC_BOOK:
            case ESM::REC_CLAS:
            case ESM::REC_CLOT:
            case ESM::REC_ENCH:
            case ESM::REC_SPEL:
            case ESM::REC_WEAP:
            case ESM::REC_NPC_:
            case ESM::REC_LEVI:
            case ESM::REC_LEVC:

                {
                    std::string id = reader.getHNString ("NAME");
                    mStores[type]->read (reader, id);

                    // FIXME: there might be stale dynamic IDs in mIds from an earlier savegame
                    // that really should be cleared instead of just overwritten

                    mIds[id] = type;
                }

                if (type==ESM::REC_NPC_)
                {
                    // NPC record will always be last and we know that there can be only one
                    // dynamic NPC record (player) -> We are done here with dynamic record laoding
                    setUp();

                    const ESM::NPC *player = mNpcs.find ("player");

                    if (!mRaces.find (player->mRace) ||
                        !mClasses.find (player->mClass))
                        throw std::runtime_error ("Invalid player record (race or class unavailable");
                }

                return true;

            case ESM::REC_DYNA:
                reader.getSubNameIs("COUN");
                reader.getHT(mDynamicCount);
                return true;

            default:

                return false;
        }
    }
开发者ID:Digmaster,项目名称:openmw,代码行数:51,代码来源:esmstore.cpp


示例8: read

 virtual void read(ESM::ESMReader &esm)
 {
     std::string id = esm.getHNString("NAME");
     CNTC cntc;
     cntc.load(esm);
     mContext->mContainerChanges.insert(std::make_pair(std::make_pair(cntc.mIndex,id), cntc));
 }
开发者ID:ChunHungLiu,项目名称:openmw,代码行数:7,代码来源:converter.hpp


示例9: load

    void CNTC::load(ESM::ESMReader &esm)
    {
        mIndex = 0;
        esm.getHNT(mIndex, "INDX");

        mInventory.load(esm);
    }
开发者ID:A1-Triard,项目名称:openmw,代码行数:7,代码来源:importcntc.cpp


示例10: while

void Store<ESM::Cell>::handleMovedCellRefs(ESM::ESMReader& esm, ESM::Cell* cell)
{
    //Handling MovedCellRefs, there is no way to do it inside loadcell
    while (esm.isNextSub("MVRF")) {
        ESM::CellRef ref;
        ESM::MovedCellRef cMRef;
        cell->getNextMVRF(esm, cMRef);

        MWWorld::Store<ESM::Cell> &cStore = const_cast<MWWorld::Store<ESM::Cell>&>(mEsmStore->get<ESM::Cell>());
        ESM::Cell *cellAlt = const_cast<ESM::Cell*>(cStore.searchOrCreate(cMRef.mTarget[0], cMRef.mTarget[1]));

        // Get regular moved reference data. Adapted from CellStore::loadRefs. Maybe we can optimize the following
        //  implementation when the oher implementation works as well.
        bool deleted = false;
        cell->getNextRef(esm, ref, deleted);

        // Add data required to make reference appear in the correct cell.
        // We should not need to test for duplicates, as this part of the code is pre-cell merge.
        cell->mMovedRefs.push_back(cMRef);
        // But there may be duplicates here!
        ESM::CellRefTracker::iterator iter = std::find(cellAlt->mLeasedRefs.begin(), cellAlt->mLeasedRefs.end(), ref.mRefNum);
        if (iter == cellAlt->mLeasedRefs.end())
          cellAlt->mLeasedRefs.push_back(ref);
        else
          *iter = ref;
    }
}
开发者ID:PLkolek,项目名称:openmw,代码行数:27,代码来源:store.cpp


示例11: if

    void IdCollection<ESXRecordT, IdAccessorT>::load (ESM::ESMReader& reader, bool base)
    {
        std::string id = reader.getHNOString ("NAME");

        if (reader.isNextSub ("DELE"))
        {
            int index = Collection<ESXRecordT, IdAccessorT>::searchId (id);

            reader.skipRecord();

            if (index==-1)
            {
                // deleting a record that does not exist

                // ignore it for now

                /// \todo report the problem to the user
            }
            else if (base)
            {
                Collection<ESXRecordT, IdAccessorT>::removeRows (index, 1);
            }
            else
            {
                Record<ESXRecordT> record = Collection<ESXRecordT, IdAccessorT>::getRecord (index);
                record.mState = RecordBase::State_Deleted;
                this->setRecord (index, record);
            }
        }
        else
        {
            ESXRecordT record;

            int index = this->searchId (id);

            if (index==-1)
                IdAccessorT().getId (record) = id;
            else
            {
                record = this->getRecord (index).get();
            }

            record.load (reader);

            load (record, base, index);
        }
    }
开发者ID:Allxere,项目名称:openmw,代码行数:47,代码来源:idcollection.hpp


示例12: readRecord

    bool ESMStore::readRecord (ESM::ESMReader& reader, uint32_t type)
    {
        switch (type)
        {
            case ESM::REC_ALCH:
            case ESM::REC_ARMO:
            case ESM::REC_BOOK:
            case ESM::REC_CLAS:
            case ESM::REC_CLOT:
            case ESM::REC_ENCH:
            case ESM::REC_SPEL:
            case ESM::REC_WEAP:
            case ESM::REC_NPC_:
            case ESM::REC_LEVI:
            case ESM::REC_LEVC:

                {
                    mStores[type]->read (reader);
                }

                if (type==ESM::REC_NPC_)
                {
                    // NPC record will always be last and we know that there can be only one
                    // dynamic NPC record (player) -> We are done here with dynamic record loading
                    setUp();

                    const ESM::NPC *player = mNpcs.find ("player");

                    if (!mRaces.find (player->mRace) ||
                        !mClasses.find (player->mClass))
                        throw std::runtime_error ("Invalid player record (race or class unavailable");
                }

                return true;

            case ESM::REC_DYNA:
                reader.getSubNameIs("COUN");
                reader.getHT(mDynamicCount);
                return true;

            default:

                return false;
        }
    }
开发者ID:GrimKriegor,项目名称:openmw-tes3mp,代码行数:45,代码来源:esmstore.cpp


示例13: while

QSet<QString> CellNameLoader::getCellNames(QStringList &contentPaths)
{
    QSet<QString> cellNames;
    ESM::ESMReader esmReader;

    // Loop through all content files
    for (auto &contentPath : contentPaths) {
        esmReader.open(contentPath.toStdString());

        // Loop through all records
        while(esmReader.hasMoreRecs())
        {
            ESM::NAME recordName = esmReader.getRecName();
            esmReader.getRecHeader();

            if (isCellRecord(recordName)) {
                QString cellName = getCellName(esmReader);
                if (!cellName.isEmpty()) {
                    cellNames.insert(cellName);
                }
            }

            // Stop loading content for this record and continue to the next
            esmReader.skipRecord();
        }
    }

    return cellNames;
}
开发者ID:Allofich,项目名称:openmw,代码行数:29,代码来源:cellnameloader.cpp


示例14: if

void CSMWorld::InfoCollection::load (ESM::ESMReader& reader, bool base, const ESM::Dialogue& dialogue)
{
    std::string id = Misc::StringUtils::lowerCase (dialogue.mId) + "#" +
        reader.getHNOString ("INAM");

    if (reader.isNextSub ("DELE"))
    {
        int index = searchId (id);

        reader.skipRecord();

        if (index==-1)
        {
            // deleting a record that does not exist

            // ignore it for now

            /// \todo report the problem to the user
        }
        else if (base)
        {
            removeRows (index, 1);
        }
        else
        {
            Record<Info> record = getRecord (index);
            record.mState = RecordBase::State_Deleted;
            setRecord (index, record);
        }
    }
    else
    {
        Info record;
        record.mTopicId = dialogue.mId;
        record.mId = id;
        record.load (reader);

        load (record, base);
    }
}
开发者ID:Kleptoid,项目名称:openmw,代码行数:40,代码来源:infocollection.cpp


示例15: loadData

    void Land::loadData(int flags) const
    {
        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mMutex);

        // Try to load only available data
        flags = flags & mDataTypes;
        // Return if all required data is loaded
        if ((mDataLoaded & flags) == flags) {
            return;
        }
        // Create storage if nothing is loaded
        if (mLandData == NULL) {
            mLandData = new LandData;
            mLandData->mDataTypes = mDataTypes;
        }

        ESM::ESMReader reader;
        reader.restoreContext(mContext);

        if (reader.isNextSub("VNML")) {
            condLoad(reader, flags, DATA_VNML, mLandData->mNormals, sizeof(mLandData->mNormals));
        }

        if (reader.isNextSub("VHGT")) {
            static VHGT vhgt;
            if (condLoad(reader, flags, DATA_VHGT, &vhgt, sizeof(vhgt))) {
                float rowOffset = vhgt.mHeightOffset;
                for (int y = 0; y < LAND_SIZE; y++) {
                    rowOffset += vhgt.mHeightData[y * LAND_SIZE];

                    mLandData->mHeights[y * LAND_SIZE] = rowOffset * HEIGHT_SCALE;

                    float colOffset = rowOffset;
                    for (int x = 1; x < LAND_SIZE; x++) {
                        colOffset += vhgt.mHeightData[y * LAND_SIZE + x];
                        mLandData->mHeights[x + y * LAND_SIZE] = colOffset * HEIGHT_SCALE;
                    }
                }
                mLandData->mUnk1 = vhgt.mUnk1;
                mLandData->mUnk2 = vhgt.mUnk2;
            }
        }

        if (reader.isNextSub("WNAM")) {
            condLoad(reader, flags, DATA_WNAM, mLandData->mWnam, 81);
        }
        if (reader.isNextSub("VCLR"))
            condLoad(reader, flags, DATA_VCLR, mLandData->mColours, 3 * LAND_NUM_VERTS);
        if (reader.isNextSub("VTEX")) {
            static uint16_t vtex[LAND_NUM_TEXTURES];
            if (condLoad(reader, flags, DATA_VTEX, vtex, sizeof(vtex))) {
                LandData::transposeTextureData(vtex, mLandData->mTextures);
            }
        }
    }
开发者ID:Edgarins29,项目名称:openmw,代码行数:55,代码来源:loadland.cpp


示例16: printRaw

void printRaw(ESM::ESMReader &esm)
{
    while(esm.hasMoreRecs())
    {
        ESM::NAME n = esm.getRecName();
        std::cout << "Record: " << n.toString() << std::endl;
        esm.getRecHeader();
        while(esm.hasMoreSubs())
        {
            uint64_t offs = esm.getOffset();
            esm.getSubName();
            esm.skipHSub();
            n = esm.retSubName();
            std::cout << "    " << n.toString() << " - " << esm.getSubSize()
                 << " bytes @ 0x" << std::hex << offs << "\n";
        }
    }
}
开发者ID:eroen,项目名称:openmw,代码行数:18,代码来源:esmtool.cpp


示例17:

void MWState::Character::addSlot (const boost::filesystem::path& path, const std::string& game)
{
    Slot slot;
    slot.mPath = path;
    slot.mTimeStamp = boost::filesystem::last_write_time (path);

    ESM::ESMReader reader;
    reader.open (slot.mPath.string());

    if (reader.getRecName()!=ESM::REC_SAVE)
        return; // invalid save file -> ignore

    reader.getRecHeader();

    slot.mProfile.load (reader);

    if (Misc::StringUtils::lowerCase (slot.mProfile.mContentFiles.at (0))!=
        Misc::StringUtils::lowerCase (game))
        return; // this file is for a different game -> ignore

    mSlots.push_back (slot);
}
开发者ID:Allofich,项目名称:openmw,代码行数:22,代码来源:character.cpp


示例18:

void CSMTools::FinishMergedDocumentStage::perform (int stage, CSMDoc::Messages& messages)
{
    // We know that the content file list contains at least two entries and that the first one
    // does exist on disc (otherwise it would have been impossible to initiate a merge on that
    // document).
    boost::filesystem::path path = mState.mSource.getContentFiles()[0];

    ESM::ESMReader reader;
    reader.setEncoder (&mEncoder);
    reader.open (path.string());

    CSMWorld::MetaData source;
    source.mId = "sys::meta";
    source.load (reader);

    CSMWorld::MetaData target = mState.mTarget->getData().getMetaData();

    target.mAuthor = source.mAuthor;
    target.mDescription = source.mDescription;

    mState.mTarget->getData().setMetaData (target);

    mState.mCompleted = true;
}
开发者ID:Allofich,项目名称:openmw,代码行数:24,代码来源:mergestages.cpp


示例19: addPlugins

void DataFilesModel::addPlugins(const QString &path)
{
    QDir dir(path);
    dir.setNameFilters(QStringList(QLatin1String("*.esp")));

    foreach (const QString &path, dir.entryList()) {
        QFileInfo info(dir.absoluteFilePath(path));
        EsmFile *file = new EsmFile(path);

        try {
            ESM::ESMReader fileReader;
            ToUTF8::Utf8Encoder encoder (ToUTF8::calculateEncoding(mEncoding.toStdString()));
            fileReader.setEncoder(&encoder);
            fileReader.open(dir.absoluteFilePath(path).toStdString());

            ESM::ESMReader::MasterList mlist = fileReader.getMasters();
            QStringList masters;

            for (unsigned int i = 0; i < mlist.size(); ++i) {
                QString master = QString::fromStdString(mlist[i].name);
                masters.append(master);

                // Add the plugin to the internal dependency map
                mDependencies[master].append(path);
            }

            file->setAuthor(QString::fromStdString(fileReader.getAuthor()));
            file->setSize(info.size());
            file->setDates(info.lastModified(), info.lastRead());
            file->setVersion(fileReader.getFVer());
            file->setPath(info.absoluteFilePath());
            file->setMasters(masters);
            file->setDescription(QString::fromStdString(fileReader.getDesc()));


            // Put the file in the table
            addFile(file);
        } catch(std::runtime_error &e) {
            // An error occurred while reading the .esp
            qWarning() << "Error reading esp: " << e.what();
            continue;
        }

    }
}
开发者ID:JordanMilne,项目名称:openmw,代码行数:45,代码来源:datafilesmodel.cpp


示例20: callback

bool MWWorld::Cells::readRecord (ESM::ESMReader& reader, uint32_t type,
    const std::map<int, int>& contentFileMap)
{
    if (type==ESM::REC_CSTA)
    {
        ESM::CellState state;
        state.mId.load (reader);

        CellStore *cellStore = 0;

        try
        {
            cellStore = getCell (state.mId);
        }
        catch (...)
        {
            // silently drop cells that don't exist anymore
            std::cerr << "Dropping state for cell " << state.mId.mWorldspace << " (cell no longer exists)" << std::endl;
            reader.skipRecord();
            return true;
        }

        state.load (reader);
        cellStore->loadState (state);

        if (state.mHasFogOfWar)
            cellStore->readFog(reader);

        if (cellStore->getState()!=CellStore::State_Loaded)
            cellStore->load ();

        GetCellStoreCallback callback(*this);

        cellStore->readReferences (reader, contentFileMap, &callback);

        return true;
    }

    return false;
}
开发者ID:A1-Triard,项目名称:openmw,代码行数:40,代码来源:cells.cpp



注:本文中的esm::ESMReader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ esm::ESMWriter类代码示例发布时间:2022-05-31
下一篇:
C++ errormessage::FileLocation类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap