mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 04:45:33 +00:00
Add NAME and DELE handling to Cell record
(cherry picked from commit b667338a8f
)
This commit is contained in:
parent
8c77cafc35
commit
7dc0c9138f
2 changed files with 18 additions and 8 deletions
|
@ -12,6 +12,7 @@
|
|||
#include "esmwriter.hpp"
|
||||
#include "defs.hpp"
|
||||
#include "cellid.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -54,10 +55,17 @@ namespace ESM
|
|||
|
||||
void Cell::load(ESMReader &esm, bool saveContext)
|
||||
{
|
||||
loadName(esm);
|
||||
loadData(esm);
|
||||
loadCell(esm, saveContext);
|
||||
}
|
||||
|
||||
void Cell::loadName(ESMReader &esm)
|
||||
{
|
||||
mName = esm.getHNString("NAME");
|
||||
mIsDeleted = readDeleSubRecord(esm);
|
||||
}
|
||||
|
||||
void Cell::loadCell(ESMReader &esm, bool saveContext)
|
||||
{
|
||||
mRefNumCounter = 0;
|
||||
|
@ -105,13 +113,6 @@ void Cell::loadCell(ESMReader &esm, bool saveContext)
|
|||
|
||||
void Cell::loadData(ESMReader &esm)
|
||||
{
|
||||
// Ignore this for now, it might mean we should delete the entire
|
||||
// cell?
|
||||
// TODO: treat the special case "another plugin moved this ref, but we want to delete it"!
|
||||
if (esm.isNextSub("DELE")) {
|
||||
esm.skipHSub();
|
||||
}
|
||||
|
||||
esm.getHNT(mData, "DATA", 12);
|
||||
}
|
||||
|
||||
|
@ -124,6 +125,12 @@ void Cell::postLoad(ESMReader &esm)
|
|||
|
||||
void Cell::save(ESMWriter &esm) const
|
||||
{
|
||||
esm.writeHNCString("NAME", mName);
|
||||
if (mIsDeleted)
|
||||
{
|
||||
writeDeleSubRecord(esm);
|
||||
}
|
||||
|
||||
esm.writeHNT("DATA", mData, 12);
|
||||
if (mData.mFlags & Interior)
|
||||
{
|
||||
|
@ -147,7 +154,7 @@ void Cell::save(ESMWriter &esm) const
|
|||
esm.writeHNT("NAM5", mMapColor);
|
||||
}
|
||||
|
||||
if (mRefNumCounter != 0)
|
||||
if (mRefNumCounter != 0 && !mIsDeleted)
|
||||
esm.writeHNT("NAM0", mRefNumCounter);
|
||||
}
|
||||
|
||||
|
|
|
@ -112,11 +112,14 @@ struct Cell
|
|||
CellRefTracker mLeasedRefs;
|
||||
MovedCellRefTracker mMovedRefs;
|
||||
|
||||
bool mIsDeleted;
|
||||
|
||||
void postLoad(ESMReader &esm);
|
||||
|
||||
// This method is left in for compatibility with esmtool. Parsing moved references currently requires
|
||||
// passing ESMStore, bit it does not know about this parameter, so we do it this way.
|
||||
void load(ESMReader &esm, bool saveContext = true); // Load everything (except references)
|
||||
void loadName(ESMReader &esm); // Load NAME and checks for DELE
|
||||
void loadData(ESMReader &esm); // Load DATAstruct only
|
||||
void loadCell(ESMReader &esm, bool saveContext = true); // Load everything, except DATAstruct and references
|
||||
|
||||
|
|
Loading…
Reference in a new issue