From 597b88e95a23f7b5d50da00e4f29ab488fdc9219 Mon Sep 17 00:00:00 2001 From: greye Date: Tue, 18 Sep 2012 19:30:19 +0400 Subject: [PATCH] update saving AI packages --- components/esm/aipackage.cpp | 27 +++++++++++++++++++++++++++ components/esm/aipackage.hpp | 2 +- components/esm/loadcrea.cpp | 3 +++ components/esm/loadgmst.hpp | 2 -- components/esm/loadnpc.cpp | 9 +++++++++ components/esm_store/reclists.hpp | 2 +- 6 files changed, 41 insertions(+), 4 deletions(-) diff --git a/components/esm/aipackage.cpp b/components/esm/aipackage.cpp index ba07a6889..7cc9cd2e5 100644 --- a/components/esm/aipackage.cpp +++ b/components/esm/aipackage.cpp @@ -40,5 +40,32 @@ namespace ESM void AIPackageList::save(ESMWriter &esm) { + typedef std::vector::iterator PackageIter; + for (PackageIter it = mList.begin(); it != mList.end(); ++it) { + switch (it->mType) { + case AI_Wander: + esm.writeHNT("AI_W", it->mWander, sizeof(it->mWander)); + break; + + case AI_Travel: + esm.writeHNT("AI_T", it->mTravel, sizeof(it->mTravel)); + break; + + case AI_Activate: + esm.writeHNT("AI_A", it->mActivate, sizeof(it->mActivate)); + break; + + case AI_Escort: + case AI_Follow: { + const char *name = (it->mType == AI_Escort) ? "AI_E" : "AI_F"; + esm.writeHNT(name, it->mTarget, sizeof(it->mTarget)); + esm.writeHNOCString("CNDT", it->mCellName); + break; + } + + default: + break; + } + } } } diff --git a/components/esm/aipackage.hpp b/components/esm/aipackage.hpp index 1699be5ef..0efc3b61e 100644 --- a/components/esm/aipackage.hpp +++ b/components/esm/aipackage.hpp @@ -35,7 +35,7 @@ namespace ESM struct AITravel { float mX, mY, mZ; - long mUnk; + int mUnk; }; struct AITarget diff --git a/components/esm/loadcrea.cpp b/components/esm/loadcrea.cpp index 083032839..2af6aeb05 100644 --- a/components/esm/loadcrea.cpp +++ b/components/esm/loadcrea.cpp @@ -47,6 +47,9 @@ void Creature::save(ESMWriter &esm) mInventory.save(esm); mSpells.save(esm); + if (mHasAI) { + esm.writeHNT("AIDT", mAiData, sizeof(mAiData)); + } mAiPackage.save(esm); } diff --git a/components/esm/loadgmst.hpp b/components/esm/loadgmst.hpp index 18c881521..c9dc8d5c1 100644 --- a/components/esm/loadgmst.hpp +++ b/components/esm/loadgmst.hpp @@ -15,8 +15,6 @@ namespace ESM struct GameSetting : public Record { - std::string mId; - // One of these is used depending on the variable type std::string mStr; int mI; diff --git a/components/esm/loadnpc.cpp b/components/esm/loadnpc.cpp index b6e7728df..ee2833ca1 100644 --- a/components/esm/loadnpc.cpp +++ b/components/esm/loadnpc.cpp @@ -81,6 +81,15 @@ void NPC::save(ESMWriter &esm) mInventory.save(esm); mSpells.save(esm); + if (mHasAI) { + esm.writeHNT("AIDT", mAiData, sizeof(mAiData)); + } + + typedef std::vector::iterator DestIter; + for (DestIter it = mTransport.begin(); it != mTransport.end(); ++it) { + esm.writeHNT("DODT", it->mPos, sizeof(it->mPos)); + esm.writeHNOCString("DNAM", it->mCellName); + } mAiPackage.save(esm); } diff --git a/components/esm_store/reclists.hpp b/components/esm_store/reclists.hpp index 823e4258c..bf98bf1d7 100644 --- a/components/esm_store/reclists.hpp +++ b/components/esm_store/reclists.hpp @@ -226,7 +226,7 @@ namespace ESMS std::string id2 = toLower (id); X& ref = list[id2]; - ref.mId = id; + ref.setId(id); ref.load(esm); }