Ejemplo n.º 1
0
            ManualRef (const MWWorld::ESMStore& store, const std::string& name, const int count=1)
            {
                std::string lowerName = Misc::StringUtils::lowerCase (name);
                switch (store.find (lowerName))
                {
                    case ESM::REC_ACTI: create (store.get<ESM::Activator>(), lowerName); break;
                    case ESM::REC_ALCH: create (store.get<ESM::Potion>(), lowerName); break;
                    case ESM::REC_APPA: create (store.get<ESM::Apparatus>(), lowerName); break;
                    case ESM::REC_ARMO: create (store.get<ESM::Armor>(), lowerName); break;
                    case ESM::REC_BOOK: create (store.get<ESM::Book>(), lowerName); break;
                    case ESM::REC_CLOT: create (store.get<ESM::Clothing>(), lowerName); break;
                    case ESM::REC_CONT: create (store.get<ESM::Container>(), lowerName); break;
                    case ESM::REC_CREA: create (store.get<ESM::Creature>(), lowerName); break;
                    case ESM::REC_DOOR: create (store.get<ESM::Door>(), lowerName); break;
                    case ESM::REC_INGR: create (store.get<ESM::Ingredient>(), lowerName); break;
                    case ESM::REC_LEVC: create (store.get<ESM::CreatureLevList>(), lowerName); break;
                    case ESM::REC_LEVI: create (store.get<ESM::ItemLevList>(), lowerName); break;
                    case ESM::REC_LIGH: create (store.get<ESM::Light>(), lowerName); break;
                    case ESM::REC_LOCK: create (store.get<ESM::Lockpick>(), lowerName); break;
                    case ESM::REC_MISC: create (store.get<ESM::Miscellaneous>(), lowerName); break;
                    case ESM::REC_NPC_: create (store.get<ESM::NPC>(), lowerName); break;
                    case ESM::REC_PROB: create (store.get<ESM::Probe>(), lowerName); break;
                    case ESM::REC_REPA: create (store.get<ESM::Repair>(), lowerName); break;
                    case ESM::REC_STAT: create (store.get<ESM::Static>(), lowerName); break;
                    case ESM::REC_WEAP: create (store.get<ESM::Weapon>(), lowerName); break;

                    case 0:
                        throw std::logic_error ("failed to create manual cell ref for " + lowerName + " (unknown ID)");

                    default:
                        throw std::logic_error ("failed to create manual cell ref for " + lowerName + " (unknown type)");
                }

                mPtr.getRefData().setCount(count);
            }
Ejemplo n.º 2
0
void CellStore::loadRefs(const MWWorld::ESMStore &store, ESM::ESMReader &esm)
{
    assert (mCell);

    if (mCell->mContext.filename.empty())
        return; // this is a dynamically generated cell -> skipping.

    // Reopen the ESM reader and seek to the right position.
    mCell->restore(esm);

    ESM::CellRef ref;

    // Get each reference in turn
    while(mCell->getNextRef(esm, ref))
    {
        std::string lowerCase = Misc::StringUtils::lowerCase(ref.mRefID);

        int rec = store.find(ref.mRefID);

        ref.mRefID = lowerCase;

        /* We can optimize this further by storing the pointer to the
           record itself in store.all, so that we don't need to look it
           up again here. However, never optimize. There are infinite
           opportunities to do that later.
         */
        switch(rec)
        {
        case ESM::REC_ACTI:
            mActivators.load(ref, store);
            break;
        case ESM::REC_ALCH:
            mPotions.load(ref, store);
            break;
        case ESM::REC_APPA:
            mAppas.load(ref, store);
            break;
        case ESM::REC_ARMO:
            mArmors.load(ref, store);
            break;
        case ESM::REC_BOOK:
            mBooks.load(ref, store);
            break;
        case ESM::REC_CLOT:
            mClothes.load(ref, store);
            break;
        case ESM::REC_CONT:
            mContainers.load(ref, store);
            break;
        case ESM::REC_CREA:
            mCreatures.load(ref, store);
            break;
        case ESM::REC_DOOR:
            mDoors.load(ref, store);
            break;
        case ESM::REC_INGR:
            mIngreds.load(ref, store);
            break;
        case ESM::REC_LEVC:
            mCreatureLists.load(ref, store);
            break;
        case ESM::REC_LEVI:
            mItemLists.load(ref, store);
            break;
        case ESM::REC_LIGH:
            mLights.load(ref, store);
            break;
        case ESM::REC_LOCK:
            mLockpicks.load(ref, store);
            break;
        case ESM::REC_MISC:
            mMiscItems.load(ref, store);
            break;
        case ESM::REC_NPC_:
            mNpcs.load(ref, store);
            break;
        case ESM::REC_PROB:
            mProbes.load(ref, store);
            break;
        case ESM::REC_REPA:
            mRepairs.load(ref, store);
            break;
        case ESM::REC_STAT:
            mStatics.load(ref, store);
            break;
        case ESM::REC_WEAP:
            mWeapons.load(ref, store);
            break;

        case 0:
            std::cout << "Cell reference " + ref.mRefID + " not found!\n";
            break;
        default:
            std::cout << "WARNING: Ignoring reference '" << ref.mRefID << "' of unhandled type\n";
        }
    }
}