Esempio n. 1
0
void Land::save(ESMWriter &esm) const
{
    esm.startSubRecord("INTV");
    esm.writeT(mX);
    esm.writeT(mY);
    esm.endRecord("INTV");

    esm.writeHNT("DATA", mFlags);
}
Esempio n. 2
0
 void Weapon::save(ESMWriter &esm) const
 {
     esm.writeHNCString("MODL", mModel);
     esm.writeHNOCString("FNAM", mName);
     esm.writeHNT("WPDT", mData, 32);
     esm.writeHNOCString("SCRI", mScript);
     esm.writeHNOCString("ITEX", mIcon);
     esm.writeHNOCString("ENAM", mEnchant);
 }
Esempio n. 3
0
void Probe::save(ESMWriter &esm) const
{
    esm.writeHNCString("MODL", mModel);
    esm.writeHNOCString("FNAM", mName);

    esm.writeHNT("PBDT", mData, 16);
    esm.writeHNOString("SCRI", mScript);
    esm.writeHNOCString("ITEX", mIcon);
}
Esempio n. 4
0
void Lockpick::save(ESMWriter &esm)
{
    esm.writeHNCString("MODL", mModel);
    esm.writeHNCString("FNAM", mName);

    esm.writeHNT("LKDT", mData, 16);
    esm.writeHNOString("SCRI", mScript);
    esm.writeHNOCString("ITEX", mIcon);
}
Esempio n. 5
0
void Land::LandData::save(ESMWriter &esm)
{
    if (mDataTypes & Land::DATA_VNML) {
        esm.writeHNT("VNML", mNormals, sizeof(mNormals));
    }
    if (mDataTypes & Land::DATA_VHGT) {
        VHGT offsets;
        offsets.mHeightOffset = mHeights[0] / HEIGHT_SCALE;
        offsets.mUnk1 = mUnk1;
        offsets.mUnk2 = mUnk2;

        float prevY = mHeights[0];
        int number = 0; // avoid multiplication
        for (int i = 0; i < LAND_SIZE; ++i) {
            float diff = (mHeights[number] - prevY) / HEIGHT_SCALE;
            offsets.mHeightData[number] =
                (diff >= 0) ? (int8_t) (diff + 0.5) : (int8_t) (diff - 0.5);

            float prevX = prevY = mHeights[number];
            ++number;

            for (int j = 1; j < LAND_SIZE; ++j) {
                diff = (mHeights[number] - prevX) / HEIGHT_SCALE;
                offsets.mHeightData[number] =
                    (diff >= 0) ? (int8_t) (diff + 0.5) : (int8_t) (diff - 0.5);

                prevX = mHeights[number];
                ++number;
            }
        }
        esm.writeHNT("VHGT", offsets, sizeof(VHGT));
    }
    if (mDataTypes & Land::DATA_WNAM) {
        esm.writeHNT("WNAM", mWnam, 81);
    }
    if (mDataTypes & Land::DATA_VCLR) {
        esm.writeHNT("VCLR", mColours, 3*LAND_NUM_VERTS);
    }
    if (mDataTypes & Land::DATA_VTEX) {
        static uint16_t vtex[LAND_NUM_TEXTURES];
        transposeTextureData(mTextures, vtex);
        esm.writeHNT("VTEX", vtex, sizeof(vtex));
    }
}
Esempio n. 6
0
    void NPC::save(ESMWriter &esm, bool isDeleted) const
    {
        esm.writeHNCString("NAME", mId);

        if (isDeleted)
        {
            esm.writeHNCString("DELE", "");
            return;
        }

        esm.writeHNOCString("MODL", mModel);
        esm.writeHNOCString("FNAM", mName);
        esm.writeHNCString("RNAM", mRace);
        esm.writeHNCString("CNAM", mClass);
        esm.writeHNCString("ANAM", mFaction);
        esm.writeHNCString("BNAM", mHead);
        esm.writeHNCString("KNAM", mHair);
        esm.writeHNOCString("SCRI", mScript);

        if (mNpdtType == NPC_DEFAULT)
        {
            esm.writeHNT("NPDT", mNpdt, 52);
        }
        else if (mNpdtType == NPC_WITH_AUTOCALCULATED_STATS)
        {
            NPDTstruct12 npdt12;
            npdt12.mLevel = mNpdt.mLevel;
            npdt12.mDisposition = mNpdt.mDisposition;
            npdt12.mReputation = mNpdt.mReputation;
            npdt12.mRank = mNpdt.mRank;
            npdt12.mGold = mNpdt.mGold;
            esm.writeHNT("NPDT", npdt12, 12);
        }

        esm.writeHNT("FLAG", mFlags);

        mInventory.save(esm);
        mSpells.save(esm);
        esm.writeHNT("AIDT", mAiData, sizeof(mAiData));

        mTransport.save(esm);

        mAiPackage.save(esm);
    }
Esempio n. 7
0
void Book::save(ESMWriter &esm) const
{
    esm.writeHNCString("MODL", mModel);
    esm.writeHNOCString("FNAM", mName);
    esm.writeHNT("BKDT", mData, 20);
    esm.writeHNOCString("SCRI", mScript);
    esm.writeHNOCString("ITEX", mIcon);
    esm.writeHNOString("TEXT", mText);
    esm.writeHNOCString("ENAM", mEnchant);
}
Esempio n. 8
0
void Creature::save(ESMWriter &esm) const
{
    esm.writeHNCString("MODL", mModel);
    esm.writeHNOCString("CNAM", mOriginal);
    esm.writeHNOCString("FNAM", mName);
    esm.writeHNOCString("SCRI", mScript);
    esm.writeHNT("NPDT", mData, 96);
    esm.writeHNT("FLAG", mFlags);
    if (mScale != 1.0) {
        esm.writeHNT("XSCL", mScale);
    }

    mInventory.save(esm);
    mSpells.save(esm);
    if (mHasAI) {
        esm.writeHNT("AIDT", mAiData, sizeof(mAiData));
    }
    mAiPackage.save(esm);
}
Esempio n. 9
0
void MagicEffect::save(ESMWriter &esm) const
{
    esm.writeHNT("INDX", mIndex);

    esm.writeHNT("MEDT", mData, 36);

    esm.writeHNOCString("ITEX", mIcon);
    esm.writeHNOCString("PTEX", mParticle);
    esm.writeHNOCString("BSND", mBoltSound);
    esm.writeHNOCString("CSND", mCastSound);
    esm.writeHNOCString("HSND", mHitSound);
    esm.writeHNOCString("ASND", mAreaSound);

    esm.writeHNOCString("CVFX", mCasting);
    esm.writeHNOCString("BVFX", mBolt);
    esm.writeHNOCString("HVFX", mHit);
    esm.writeHNOCString("AVFX", mArea);

    esm.writeHNOString("DESC", mDescription);
}
Esempio n. 10
0
void ESM::Header::save (ESMWriter &esm)
{
    if (mFormat>0)
        esm.writeHNT ("FORM", mFormat);

    esm.startSubRecord("HEDR");
    esm.writeT(mData.version);
    esm.writeT(mData.type);
    esm.writeFixedSizeString(mData.author.toString(), 32);
    esm.writeFixedSizeString(mData.desc.toString(), 256);
    esm.writeT(mData.records);
    esm.endRecord("HEDR");

    for (std::vector<Header::MasterData>::iterator iter = mMaster.begin();
         iter != mMaster.end(); ++iter)
    {
        esm.writeHNCString ("MAST", iter->name);
        esm.writeHNT ("DATA", iter->size);
    }
}
Esempio n. 11
0
    void MagicBoltState::save(ESMWriter &esm) const
    {
        BaseProjectileState::save(esm);

        esm.writeHNString ("SPEL", mSpellId);
        esm.writeHNString ("SRCN", mSourceName);
        mEffects.save(esm);
        esm.writeHNT ("SPED", mSpeed);
        esm.writeHNT ("STCK", mStack);
        esm.writeHNString ("SOUN", mSound);
    }
Esempio n. 12
0
void ESM::GlobalScript::save (ESMWriter &esm) const
{
    esm.writeHNString ("NAME", mId);

    mLocals.save (esm);

    if (mRunning)
        esm.writeHNT ("RUN_", mRunning);

    esm.writeHNOString ("TARG", mTargetId);
}
Esempio n. 13
0
void Faction::save(ESMWriter &esm) const
{
    esm.writeHNOCString("FNAM", mName);

    for (int i = 0; i < 10; i++)
    {
        if (mRanks[i].empty())
            break;

        esm.writeHNString("RNAM", mRanks[i], 32);
    }

    esm.writeHNT("FADT", mData, 240);

    for (std::map<std::string, int>::const_iterator it = mReactions.begin(); it != mReactions.end(); ++it)
    {
        esm.writeHNString("ANAM", it->first);
        esm.writeHNT("INTV", it->second);
    }
}
Esempio n. 14
0
    void LevelledListBase::save(ESMWriter &esm, bool isDeleted) const
    {
        esm.writeHNCString("NAME", mId);

        if (isDeleted)
        {
            esm.writeHNCString("DELE", "");
            return;
        }

        esm.writeHNT("DATA", mFlags);
        esm.writeHNT("NNAM", mChanceNone);
        esm.writeHNT<int>("INDX", mList.size());

        for (std::vector<LevelItem>::const_iterator it = mList.begin(); it != mList.end(); ++it)
        {
            esm.writeHNCString(mRecName, it->mId);
            esm.writeHNT("INTV", it->mLevel);
        }
    }
Esempio n. 15
0
void Faction::save(ESMWriter &esm)
{
    esm.writeHNCString("FNAM", mName);
    
    for (int i = 0; i < 10; i++)
    {
        if (mRanks[i].empty())
            break;

        esm.writeHNString("RNAM", mRanks[i], 32);
    }

    esm.writeHNT("FADT", mData, 240);
    
    for (std::vector<Reaction>::iterator it = mReactions.begin(); it != mReactions.end(); ++it)
    {
        esm.writeHNString("ANAM", it->mFaction);
        esm.writeHNT("INTV", it->mReaction);
    }
}
Esempio n. 16
0
    void NPC::save(ESMWriter &esm, bool isDeleted) const
    {
        esm.writeHNCString("NAME", mId);

        if (isDeleted)
        {
            esm.writeHNCString("DELE", "");
            return;
        }

        esm.writeHNOCString("MODL", mModel);
        esm.writeHNOCString("FNAM", mName);
        esm.writeHNCString("RNAM", mRace);
        esm.writeHNCString("CNAM", mClass);
        esm.writeHNCString("ANAM", mFaction);
        esm.writeHNCString("BNAM", mHead);
        esm.writeHNCString("KNAM", mHair);
        esm.writeHNOCString("SCRI", mScript);

        if (mNpdtType == NPC_DEFAULT)
            esm.writeHNT("NPDT", mNpdt52, 52);
        else if (mNpdtType == NPC_WITH_AUTOCALCULATED_STATS)
            esm.writeHNT("NPDT", mNpdt12, 12);

        esm.writeHNT("FLAG", mFlags);

        mInventory.save(esm);
        mSpells.save(esm);
        if (mAiData.mHello != 0
            || mAiData.mFight != 0
            || mAiData.mFlee != 0
            || mAiData.mAlarm != 0
            || mAiData.mServices != 0)
        {
            esm.writeHNT("AIDT", mAiData, sizeof(mAiData));
        }

        mTransport.save(esm);

        mAiPackage.save(esm);
    }
Esempio n. 17
0
void Cell::save(ESMWriter &esm) const
{
    esm.writeHNT("DATA", mData, 12);
    if (mData.mFlags & Interior)
    {
        if (mWater != -1) {
            if (mWaterInt) {
                int water =
                    (mWater >= 0) ? (int) (mWater + 0.5) : (int) (mWater - 0.5);
                esm.writeHNT("INTV", water);
            } else {
                esm.writeHNT("WHGT", mWater);
            }
        }

        if (mData.mFlags & QuasiEx)
            esm.writeHNOCString("RGNN", mRegion);
        else
            esm.writeHNT("AMBI", mAmbi, 16);
    }
    else
    {
        esm.writeHNOCString("RGNN", mRegion);
        if (mMapColor != 0)
            esm.writeHNT("NAM5", mMapColor);
    }

    if (mNAM0 != 0)
        esm.writeHNT("NAM0", mNAM0);
}
Esempio n. 18
0
void ESM::ObjectState::save (ESMWriter &esm, bool inInventory) const
{
    mRef.save (esm, true, inInventory);

    if (mHasLocals)
    {
        esm.writeHNT ("HLOC", mHasLocals);
        mLocals.save (esm);
    }

    if (!mEnabled && !inInventory)
        esm.writeHNT ("ENAB", mEnabled);

    if (mCount!=1)
        esm.writeHNT ("COUN", mCount);

    if (!inInventory)
        esm.writeHNT ("POS_", mPosition, 24);

    if (mFlags != 0)
        esm.writeHNT ("FLAG", mFlags);

    if (!mHasCustomState)
        esm.writeHNT ("HCUS", false);
}
Esempio n. 19
0
    void Enchantment::save(ESMWriter &esm, bool isDeleted) const
    {
        esm.writeHNCString("NAME", mId);

        if (isDeleted)
        {
            esm.writeHNCString("DELE", "");
            return;
        }

        esm.writeHNT("ENDT", mData, 16);
        mEffects.save(esm);
    }
Esempio n. 20
0
    void Clothing::save(ESMWriter &esm) const
    {
        esm.writeHNCString("MODL", mModel);
        esm.writeHNOCString("FNAM", mName);
        esm.writeHNT("CTDT", mData, 12);

        esm.writeHNOCString("SCRI", mScript);
        esm.writeHNOCString("ITEX", mIcon);

        mParts.save(esm);

        esm.writeHNOCString("ENAM", mEnchant);
    }
Esempio n. 21
0
void ESM::Player::save (ESMWriter &esm) const
{
    mObject.save (esm);

    mCellId.save (esm);

    esm.writeHNT ("LKEP", mLastKnownExteriorPosition, 12);

    if (mHasMark)
    {
        esm.writeHNT ("MARK", mMarkedPosition, 24);
        mMarkedCell.save (esm);
    }

    if (mAutoMove)
        esm.writeHNT ("AMOV", mAutoMove);

    esm.writeHNString ("SIGN", mBirthsign);

    esm.writeHNT ("CURD", mCurrentCrimeId);
    esm.writeHNT ("PAYD", mPayedCrimeId);
}
Esempio n. 22
0
void ESM::VariantIntegerData::write (ESMWriter& esm, Variant::Format format, VarType type) const
{
    if (type!=VT_Short && type!=VT_Long && type!=VT_Int)
        throw std::logic_error ("not an integer type");

    if (format==Variant::Format_Global)
    {
        if (type==VT_Short || type==VT_Long)
        {
            float value = mValue;
            esm.writeHNString ("FNAM", type==VT_Short ? "s" : "l");
            esm.writeHNT ("FLTV", value);
        }
        else
            throw std::runtime_error ("unsupported global variable integer type");
    }
    else if (format==Variant::Format_Gmst || format==Variant::Format_Info)
    {
        if (type!=VT_Int)
        {
            std::ostringstream stream;
            stream
                << "unsupported " <<(format==Variant::Format_Gmst ? "gmst" : "info")
                << " variable integer type";
            throw std::runtime_error (stream.str());
        }

        esm.writeHNT ("INTV", mValue);
    }
    else if (format==Variant::Format_Local)
    {
        if (type==VT_Short)
            esm.writeHNT ("STTV", (short)mValue);
        else if (type == VT_Int)
            esm.writeHNT ("INTV", mValue);
        else
            throw std::runtime_error("unsupported local variable integer type");
    }
}
Esempio n. 23
0
    void Spell::save(ESMWriter &esm, bool isDeleted) const
    {
        esm.writeHNCString("NAME", mId);

        if (isDeleted)
        {
            esm.writeHNCString("DELE", "");
            return;
        }

        esm.writeHNOCString("FNAM", mName);
        esm.writeHNT("SPDT", mData, 12);
        mEffects.save(esm);
    }
Esempio n. 24
0
    void Class::save(ESMWriter &esm, bool isDeleted) const
    {
        esm.writeHNCString("NAME", mId);

        if (isDeleted)
        {
            esm.writeHNCString("DELE", "");
            return;
        }

        esm.writeHNOCString("FNAM", mName);
        esm.writeHNT("CLDT", mData, 60);
        esm.writeHNOString("DESC", mDescription);
    }
Esempio n. 25
0
    void SpellState::save(ESMWriter &esm) const
    {
        for (TContainer::const_iterator it = mSpells.begin(); it != mSpells.end(); ++it)
        {
            esm.writeHNString("SPEL", it->first);

            const std::map<const int, float>& random = it->second;
            for (std::map<const int, float>::const_iterator rIt = random.begin(); rIt != random.end(); ++rIt)
            {
                esm.writeHNT("INDX", rIt->first);
                esm.writeHNT("RAND", rIt->second);
            }
        }

        for (std::map<std::string, TimeStamp>::const_iterator it = mUsedPowers.begin(); it != mUsedPowers.end(); ++it)
        {
            esm.writeHNString("USED", it->first);
            esm.writeHNT("TIME", it->second);
        }

        if (!mSelectedSpell.empty())
            esm.writeHNString("SLCT", mSelectedSpell);
    }
Esempio n. 26
0
void ESM::DebugProfile::save (ESMWriter& esm, bool isDeleted) const
{
    esm.writeHNCString ("NAME", mId);

    if (isDeleted)
    {
        esm.writeHNCString("DELE", "");
        return;
    }

    esm.writeHNCString ("DESC", mDescription);
    esm.writeHNCString ("SCRP", mScriptText);
    esm.writeHNT ("FLAG", mFlags);
}
Esempio n. 27
0
    void AiSequence::save(ESMWriter &esm) const
    {
        for (std::vector<AiPackageContainer>::const_iterator it = mPackages.begin(); it != mPackages.end(); ++it)
        {
            esm.writeHNT ("AIPK", it->mType);
            switch (it->mType)
            {
            case Ai_Wander:
                static_cast<const AiWander*>(it->mPackage)->save(esm);
                break;
            case Ai_Travel:
                static_cast<const AiTravel*>(it->mPackage)->save(esm);
                break;
            case Ai_Escort:
                static_cast<const AiEscort*>(it->mPackage)->save(esm);
                break;
            case Ai_Follow:
                static_cast<const AiFollow*>(it->mPackage)->save(esm);
                break;
            case Ai_Activate:
                static_cast<const AiActivate*>(it->mPackage)->save(esm);
                break;
            case Ai_Combat:
                static_cast<const AiCombat*>(it->mPackage)->save(esm);
                break;
            case Ai_Pursue:
                static_cast<const AiPursue*>(it->mPackage)->save(esm);
                break;

            default:
                break;
            }
        }

        esm.writeHNT ("LAST", mLastAiPackage);
    }
Esempio n. 28
0
void MagicEffect::save(ESMWriter &esm)
{
    esm.writeHNT("INDX", mIndex);

    mData.mFlags &= 0xe00;
    esm.writeHNT("MEDT", mData, 36);
    if (mIndex>=0 && mIndex<NumberOfHardcodedFlags) {
        mData.mFlags |= HardcodedFlags[mIndex];
    }

    esm.writeHNOCString("ITEX", mIcon);
    esm.writeHNOCString("PTEX", mParticle);
    esm.writeHNOCString("BSND", mBoltSound);
    esm.writeHNOCString("CSND", mCastSound);
    esm.writeHNOCString("HSND", mHitSound);
    esm.writeHNOCString("ASND", mAreaSound);
    
    esm.writeHNOCString("CVFX", mCasting);
    esm.writeHNOCString("BVFX", mBolt);
    esm.writeHNOCString("HVFX", mHit);
    esm.writeHNOCString("AVFX", mArea);
    
    esm.writeHNOString("DESC", mDescription);
}
Esempio n. 29
0
    void Race::save(ESMWriter &esm, bool isDeleted) const
    {
        esm.writeHNCString("NAME", mId);

        if (isDeleted)
        {
            esm.writeHNCString("DELE", "");
            return;
        }

        esm.writeHNOCString("FNAM", mName);
        esm.writeHNT("RADT", mData, 140);
        mPowers.save(esm);
        esm.writeHNOString("DESC", mDescription);
    }
Esempio n. 30
0
    void Apparatus::save(ESMWriter &esm, bool isDeleted) const
    {
        esm.writeHNCString("NAME", mId);

        if (isDeleted)
        {
            esm.writeHNCString("DELE", "");
            return;
        }

        esm.writeHNCString("MODL", mModel);
        esm.writeHNCString("FNAM", mName);
        esm.writeHNT("AADT", mData, 16);
        esm.writeHNOCString("SCRI", mScript);
        esm.writeHNCString("ITEX", mIcon);
    }