forked from mirror/openmw-tes3mp
ESSImport: creature CellRefs work, need probing to find ref type
This commit is contained in:
parent
cbf56dbb47
commit
c8ed24cc84
5 changed files with 84 additions and 19 deletions
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include <OgreImage.h>
|
#include <OgreImage.h>
|
||||||
|
|
||||||
|
#include <components/esm/creaturestate.hpp>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -81,10 +83,68 @@ namespace ESSImport
|
||||||
ref.load (esm);
|
ref.load (esm);
|
||||||
if (esm.isNextSub("DELE"))
|
if (esm.isNextSub("DELE"))
|
||||||
std::cout << "deleted ref " << ref.mIndexedRefId << std::endl;
|
std::cout << "deleted ref " << ref.mIndexedRefId << std::endl;
|
||||||
|
cellrefs.push_back(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
newcell.mRefs = cellrefs;
|
newcell.mRefs = cellrefs;
|
||||||
mCells[id] = newcell;
|
mCells[id] = newcell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConvertCell::write(ESM::ESMWriter &esm)
|
||||||
|
{
|
||||||
|
for (std::map<std::string, Cell>::const_iterator it = mCells.begin(); it != mCells.end(); ++it)
|
||||||
|
{
|
||||||
|
const ESM::Cell& cell = it->second.mCell;
|
||||||
|
esm.startRecord(ESM::REC_CSTA);
|
||||||
|
ESM::CellState csta;
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
std::cerr << "CellRef with no index?" << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
std::stringstream stream;
|
||||||
|
stream << cellref.mIndexedRefId.substr(cellref.mIndexedRefId.size()-8,8);
|
||||||
|
int refIndex;
|
||||||
|
stream >> refIndex;
|
||||||
|
|
||||||
|
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::make_pair(refIndex, out.mRefID));
|
||||||
|
if (crecIt != mContext->mCreatureChanges.end())
|
||||||
|
{
|
||||||
|
std::cerr << "Can't' find CREC for " << refIndex << " " << out.mRefID << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ESM::CreatureState objstate;
|
||||||
|
objstate.mCount = 1;
|
||||||
|
objstate.mEnabled = cellref.mEnabled;
|
||||||
|
objstate.mHasLocals = 0;
|
||||||
|
objstate.mLocalRotation[0] = objstate.mLocalRotation[1] = objstate.mLocalRotation[2] = 0;
|
||||||
|
objstate.mPosition = cellref.mPos;
|
||||||
|
objstate.mRef = out;
|
||||||
|
objstate.mRef.mRefNum = cellref.mRefNum;
|
||||||
|
esm.writeHNT ("OBJE", ESM::REC_CREA);
|
||||||
|
objstate.save(esm);
|
||||||
|
}
|
||||||
|
|
||||||
|
esm.endRecord(ESM::REC_CSTA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,6 +153,7 @@ public:
|
||||||
{
|
{
|
||||||
mContext->mPlayer.mObject.mNpcStats.mReputation = npcc.mNPDT.mReputation;
|
mContext->mPlayer.mObject.mNpcStats.mReputation = npcc.mNPDT.mReputation;
|
||||||
}
|
}
|
||||||
|
//mContext->mNpcChanges.insert(std::make_pair(std::make_pair(npcc.mIndex,id), crec));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -230,6 +231,8 @@ public:
|
||||||
std::string id = esm.getHNString("NAME");
|
std::string id = esm.getHNString("NAME");
|
||||||
CREC crec;
|
CREC crec;
|
||||||
crec.load(esm);
|
crec.load(esm);
|
||||||
|
|
||||||
|
mContext->mCreatureChanges.insert(std::make_pair(std::make_pair(crec.mIndex,id), crec));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -243,24 +246,7 @@ class ConvertCell : public Converter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void read(ESM::ESMReader& esm);
|
virtual void read(ESM::ESMReader& esm);
|
||||||
|
virtual void write(ESM::ESMWriter& esm);
|
||||||
virtual void write(ESM::ESMWriter& esm)
|
|
||||||
{
|
|
||||||
for (std::map<std::string, Cell>::const_iterator it = mCells.begin(); it != mCells.end(); ++it)
|
|
||||||
{
|
|
||||||
const ESM::Cell& cell = it->second.mCell;
|
|
||||||
esm.startRecord(ESM::REC_CSTA);
|
|
||||||
ESM::CellState csta;
|
|
||||||
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);
|
|
||||||
esm.endRecord(ESM::REC_CSTA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Cell
|
struct Cell
|
||||||
|
|
|
@ -9,6 +9,11 @@ namespace ESSImport
|
||||||
{
|
{
|
||||||
esm.getHNT(mRefNum.mIndex, "FRMR"); // TODO: adjust RefNum
|
esm.getHNT(mRefNum.mIndex, "FRMR"); // TODO: adjust RefNum
|
||||||
|
|
||||||
|
// this is required since openmw supports more than 255 content files
|
||||||
|
int pluginIndex = (mRefNum.mIndex & 0xff000000) >> 24;
|
||||||
|
mRefNum.mContentFile = pluginIndex-1;
|
||||||
|
mRefNum.mIndex &= 0x00ffffff;
|
||||||
|
|
||||||
mIndexedRefId = esm.getHNString("NAME");
|
mIndexedRefId = esm.getHNString("NAME");
|
||||||
|
|
||||||
esm.getHNT(mACDT, "ACDT");
|
esm.getHNT(mACDT, "ACDT");
|
||||||
|
@ -22,6 +27,10 @@ namespace ESSImport
|
||||||
|
|
||||||
if (esm.isNextSub("ND3D"))
|
if (esm.isNextSub("ND3D"))
|
||||||
esm.skipHSub();
|
esm.skipHSub();
|
||||||
|
|
||||||
|
mEnabled = true;
|
||||||
|
esm.getHNOT(mEnabled, "ZNAM");
|
||||||
|
|
||||||
esm.getHNOT(mPos, "DATA", 24);
|
esm.getHNOT(mPos, "DATA", 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ namespace ESSImport
|
||||||
|
|
||||||
ESM::Position mPos;
|
ESM::Position mPos;
|
||||||
|
|
||||||
|
bool mEnabled;
|
||||||
|
|
||||||
void load(ESM::ESMReader& esm);
|
void load(ESM::ESMReader& esm);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
#ifndef OPENMW_ESSIMPORT_CONTEXT_H
|
#ifndef OPENMW_ESSIMPORT_CONTEXT_H
|
||||||
#define OPENMW_ESSIMPORT_CONTEXT_H
|
#define OPENMW_ESSIMPORT_CONTEXT_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include <components/esm/loadnpc.hpp>
|
#include <components/esm/loadnpc.hpp>
|
||||||
|
#include <components/esm/player.hpp>
|
||||||
|
|
||||||
#include "importnpcc.hpp"
|
#include "importnpcc.hpp"
|
||||||
|
#include "importcrec.hpp"
|
||||||
#include "importplayer.hpp"
|
#include "importplayer.hpp"
|
||||||
|
|
||||||
#include <components/esm/player.hpp>
|
|
||||||
|
|
||||||
namespace ESSImport
|
namespace ESSImport
|
||||||
{
|
{
|
||||||
|
@ -20,6 +24,10 @@ namespace ESSImport
|
||||||
int mDay, mMonth, mYear;
|
int mDay, mMonth, mYear;
|
||||||
float mHour;
|
float mHour;
|
||||||
|
|
||||||
|
// key <refIndex, refId>
|
||||||
|
std::map<std::pair<int, std::string>, CREC> mCreatureChanges;
|
||||||
|
std::map<std::pair<int, std::string>, NPCC> mNpcChanges;
|
||||||
|
|
||||||
Context()
|
Context()
|
||||||
{
|
{
|
||||||
mPlayer.mAutoMove = 0;
|
mPlayer.mAutoMove = 0;
|
||||||
|
|
Loading…
Reference in a new issue