|
|
@ -3,8 +3,10 @@
|
|
|
|
#include <OgreImage.h>
|
|
|
|
#include <OgreImage.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <components/esm/creaturestate.hpp>
|
|
|
|
#include <components/esm/creaturestate.hpp>
|
|
|
|
|
|
|
|
#include <components/esm/containerstate.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
#include "convertcrec.hpp"
|
|
|
|
#include "convertcrec.hpp"
|
|
|
|
|
|
|
|
#include "convertcntc.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -17,6 +19,13 @@ namespace
|
|
|
|
screenshot.save(out);
|
|
|
|
screenshot.save(out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void convertCellRef(const ESSImport::CellRef& cellref, ESM::ObjectState& objstate)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
objstate.mEnabled = cellref.mEnabled;
|
|
|
|
|
|
|
|
objstate.mPosition = cellref.mPos;
|
|
|
|
|
|
|
|
objstate.mRef.mRefNum = cellref.mRefNum;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace ESSImport
|
|
|
|
namespace ESSImport
|
|
|
@ -116,8 +125,9 @@ namespace ESSImport
|
|
|
|
ref.load (esm);
|
|
|
|
ref.load (esm);
|
|
|
|
if (esm.isNextSub("DELE"))
|
|
|
|
if (esm.isNextSub("DELE"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
// strangely this can be e.g. 52 instead of just 1,
|
|
|
|
// strangely this can be e.g. 52 instead of just 1,
|
|
|
|
std::cout << "deleted ref " << ref.mIndexedRefId << std::endl;
|
|
|
|
//std::cout << "deleted ref " << ref.mIndexedRefId << std::endl;
|
|
|
|
esm.skipHSub();
|
|
|
|
esm.skipHSub();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cellrefs.push_back(ref);
|
|
|
|
cellrefs.push_back(ref);
|
|
|
@ -155,85 +165,104 @@ namespace ESSImport
|
|
|
|
|
|
|
|
|
|
|
|
newcell.mRefs = cellrefs;
|
|
|
|
newcell.mRefs = cellrefs;
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: map by ID for exterior cells
|
|
|
|
|
|
|
|
mCells[id] = newcell;
|
|
|
|
if (cell.isExterior())
|
|
|
|
|
|
|
|
mExtCells[std::make_pair(cell.mData.mX, cell.mData.mY)] = newcell;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
mIntCells[id] = newcell;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ConvertCell::write(ESM::ESMWriter &esm)
|
|
|
|
void ConvertCell::writeCell(const Cell &cell, ESM::ESMWriter& esm)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (std::map<std::string, Cell>::const_iterator it = mCells.begin(); it != mCells.end(); ++it)
|
|
|
|
ESM::Cell esmcell = cell.mCell;
|
|
|
|
|
|
|
|
esm.startRecord(ESM::REC_CSTA);
|
|
|
|
|
|
|
|
ESM::CellState csta;
|
|
|
|
|
|
|
|
csta.mHasFogOfWar = 0;
|
|
|
|
|
|
|
|
csta.mId = esmcell.getCellId();
|
|
|
|
|
|
|
|
csta.mId.save(esm);
|
|
|
|
|
|
|
|
// TODO csta.mLastRespawn;
|
|
|
|
|
|
|
|
// shouldn't be needed if we respawn on global schedule like in original MW
|
|
|
|
|
|
|
|
csta.mWaterLevel = esmcell.mWater;
|
|
|
|
|
|
|
|
csta.save(esm);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (std::vector<CellRef>::const_iterator refIt = cell.mRefs.begin(); refIt != cell.mRefs.end(); ++refIt)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const ESM::Cell& cell = it->second.mCell;
|
|
|
|
const CellRef& cellref = *refIt;
|
|
|
|
esm.startRecord(ESM::REC_CSTA);
|
|
|
|
ESM::CellRef out;
|
|
|
|
ESM::CellState csta;
|
|
|
|
out.blank();
|
|
|
|
csta.mHasFogOfWar = 0;
|
|
|
|
|
|
|
|
csta.mId = cell.getCellId();
|
|
|
|
|
|
|
|
csta.mId.save(esm);
|
|
|
|
|
|
|
|
// TODO csta.mLastRespawn;
|
|
|
|
|
|
|
|
// shouldn't be needed if we respawn on global schedule like in original MW
|
|
|
|
|
|
|
|
csta.mWaterLevel = cell.mWater;
|
|
|
|
|
|
|
|
csta.save(esm);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (std::vector<CellRef>::const_iterator refIt = it->second.mRefs.begin(); refIt != it->second.mRefs.end(); ++refIt)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const CellRef& cellref = *refIt;
|
|
|
|
|
|
|
|
ESM::CellRef out;
|
|
|
|
|
|
|
|
out.blank();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cellref.mIndexedRefId.size() < 8)
|
|
|
|
if (cellref.mIndexedRefId.size() < 8)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::cerr << "CellRef with no index?" << std::endl;
|
|
|
|
std::cerr << "CellRef with no index?" << std::endl;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
std::stringstream stream;
|
|
|
|
std::stringstream stream;
|
|
|
|
stream << cellref.mIndexedRefId.substr(cellref.mIndexedRefId.size()-8,8);
|
|
|
|
stream << cellref.mIndexedRefId.substr(cellref.mIndexedRefId.size()-8,8);
|
|
|
|
int refIndex;
|
|
|
|
int refIndex;
|
|
|
|
stream >> refIndex;
|
|
|
|
stream >> refIndex;
|
|
|
|
|
|
|
|
|
|
|
|
out.mRefID = cellref.mIndexedRefId.substr(0,cellref.mIndexedRefId.size()-8);
|
|
|
|
out.mRefID = cellref.mIndexedRefId.substr(0,cellref.mIndexedRefId.size()-8);
|
|
|
|
|
|
|
|
|
|
|
|
std::map<std::pair<int, std::string>, CREC>::const_iterator crecIt = mContext->mCreatureChanges.find(
|
|
|
|
std::map<std::pair<int, std::string>, CREC>::const_iterator crecIt = mContext->mCreatureChanges.find(
|
|
|
|
std::make_pair(refIndex, out.mRefID));
|
|
|
|
std::make_pair(refIndex, out.mRefID));
|
|
|
|
if (crecIt != mContext->mCreatureChanges.end())
|
|
|
|
if (crecIt != mContext->mCreatureChanges.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ESM::CreatureState objstate;
|
|
|
|
ESM::CreatureState objstate;
|
|
|
|
objstate.blank();
|
|
|
|
objstate.blank();
|
|
|
|
convertACDT(cellref.mActorData.mACDT, objstate.mCreatureStats);
|
|
|
|
objstate.mRef = out;
|
|
|
|
convertCREC(crecIt->second, objstate);
|
|
|
|
convertACDT(cellref.mActorData.mACDT, objstate.mCreatureStats);
|
|
|
|
objstate.mEnabled = cellref.mEnabled;
|
|
|
|
convertCREC(crecIt->second, objstate);
|
|
|
|
objstate.mPosition = cellref.mPos;
|
|
|
|
convertCellRef(cellref, objstate);
|
|
|
|
objstate.mRef = out;
|
|
|
|
// FIXME: change save format to not require object type, instead look up it up using the RefId
|
|
|
|
objstate.mRef.mRefNum = cellref.mRefNum;
|
|
|
|
esm.writeHNT ("OBJE", ESM::REC_CREA);
|
|
|
|
// FIXME: change save format to not require object type, instead look up it up using the RefId
|
|
|
|
objstate.save(esm);
|
|
|
|
esm.writeHNT ("OBJE", ESM::REC_CREA);
|
|
|
|
continue;
|
|
|
|
objstate.save(esm);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::map<std::pair<int, std::string>, NPCC>::const_iterator npccIt = mContext->mNpcChanges.find(
|
|
|
|
std::map<std::pair<int, std::string>, NPCC>::const_iterator npccIt = mContext->mNpcChanges.find(
|
|
|
|
std::make_pair(refIndex, out.mRefID));
|
|
|
|
std::make_pair(refIndex, out.mRefID));
|
|
|
|
if (npccIt != mContext->mNpcChanges.end())
|
|
|
|
if (npccIt != mContext->mNpcChanges.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ESM::NpcState objstate;
|
|
|
|
ESM::NpcState objstate;
|
|
|
|
objstate.blank();
|
|
|
|
objstate.blank();
|
|
|
|
convertACDT(cellref.mActorData.mACDT, objstate.mCreatureStats);
|
|
|
|
objstate.mRef = out;
|
|
|
|
convertNpcData(cellref.mActorData, objstate.mNpcStats);
|
|
|
|
convertACDT(cellref.mActorData.mACDT, objstate.mCreatureStats);
|
|
|
|
convertNPCC(npccIt->second, objstate);
|
|
|
|
convertNpcData(cellref.mActorData, objstate.mNpcStats);
|
|
|
|
objstate.mEnabled = cellref.mEnabled;
|
|
|
|
convertNPCC(npccIt->second, objstate);
|
|
|
|
objstate.mPosition = cellref.mPos;
|
|
|
|
convertCellRef(cellref, objstate);
|
|
|
|
objstate.mRef = out;
|
|
|
|
esm.writeHNT ("OBJE", ESM::REC_NPC_);
|
|
|
|
objstate.mRef.mRefNum = cellref.mRefNum;
|
|
|
|
objstate.save(esm);
|
|
|
|
esm.writeHNT ("OBJE", ESM::REC_NPC_);
|
|
|
|
continue;
|
|
|
|
objstate.save(esm);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::cerr << "Can't find type for " << refIndex << " " << out.mRefID << std::endl;
|
|
|
|
std::map<std::pair<int, std::string>, CNTC>::const_iterator cntcIt = mContext->mContainerChanges.find(
|
|
|
|
|
|
|
|
std::make_pair(refIndex, out.mRefID));
|
|
|
|
|
|
|
|
if (cntcIt != mContext->mContainerChanges.end())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ESM::ContainerState objstate;
|
|
|
|
|
|
|
|
objstate.blank();
|
|
|
|
|
|
|
|
objstate.mRef = out;
|
|
|
|
|
|
|
|
convertCNTC(cntcIt->second, objstate);
|
|
|
|
|
|
|
|
convertCellRef(cellref, objstate);
|
|
|
|
|
|
|
|
esm.writeHNT ("OBJE", ESM::REC_CONT);
|
|
|
|
|
|
|
|
objstate.save(esm);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
esm.endRecord(ESM::REC_CSTA);
|
|
|
|
std::cerr << "Can't find type for " << refIndex << " " << out.mRefID << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
esm.endRecord(ESM::REC_CSTA);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ConvertCell::write(ESM::ESMWriter &esm)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (std::map<std::string, Cell>::const_iterator it = mIntCells.begin(); it != mIntCells.end(); ++it)
|
|
|
|
|
|
|
|
writeCell(it->second, esm);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (std::map<std::pair<int, int>, Cell>::const_iterator it = mExtCells.begin(); it != mExtCells.end(); ++it)
|
|
|
|
|
|
|
|
writeCell(it->second, esm);
|
|
|
|
|
|
|
|
|
|
|
|
for (std::vector<ESM::CustomMarker>::const_iterator it = mMarkers.begin(); it != mMarkers.end(); ++it)
|
|
|
|
for (std::vector<ESM::CustomMarker>::const_iterator it = mMarkers.begin(); it != mMarkers.end(); ++it)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
esm.startRecord(ESM::REC_MARK);
|
|
|
|
esm.startRecord(ESM::REC_MARK);
|
|
|
|