Do not store object position, if it is the same as in CellRef

pull/578/head
Andrei Kortunov 5 years ago
parent 3b1c717ab9
commit 75e7a3e8b1

@ -57,6 +57,26 @@ struct Position
}; };
#pragma pack(pop) #pragma pack(pop)
bool inline operator== (const Position& left, const Position& right) noexcept
{
return left.pos[0] == right.pos[0] &&
left.pos[1] == right.pos[1] &&
left.pos[2] == right.pos[2] &&
left.rot[0] == right.rot[0] &&
left.rot[1] == right.rot[1] &&
left.rot[2] == right.rot[2];
}
bool inline operator!= (const Position& left, const Position& right) noexcept
{
return left.pos[0] != right.pos[0] ||
left.pos[1] != right.pos[1] ||
left.pos[2] != right.pos[2] ||
left.rot[0] != right.rot[0] ||
left.rot[1] != right.rot[1] ||
left.rot[2] != right.rot[2];
}
template <int a, int b, int c, int d> template <int a, int b, int c, int d>
struct FourCC struct FourCC
{ {

@ -26,6 +26,7 @@ void ESM::ObjectState::load (ESMReader &esm)
mCount = 1; mCount = 1;
esm.getHNOT (mCount, "COUN"); esm.getHNOT (mCount, "COUN");
mPosition = mRef.mPos;
esm.getHNOT (mPosition, "POS_", 24); esm.getHNOT (mPosition, "POS_", 24);
if (esm.isNextSub("LROT")) if (esm.isNextSub("LROT"))
@ -61,7 +62,7 @@ void ESM::ObjectState::save (ESMWriter &esm, bool inInventory) const
if (mCount!=1) if (mCount!=1)
esm.writeHNT ("COUN", mCount); esm.writeHNT ("COUN", mCount);
if (!inInventory) if (!inInventory && mPosition != mRef.mPos)
esm.writeHNT ("POS_", mPosition, 24); esm.writeHNT ("POS_", mPosition, 24);
if (mFlags != 0) if (mFlags != 0)

@ -4,7 +4,7 @@
#include "esmwriter.hpp" #include "esmwriter.hpp"
unsigned int ESM::SavedGame::sRecordId = ESM::REC_SAVE; unsigned int ESM::SavedGame::sRecordId = ESM::REC_SAVE;
int ESM::SavedGame::sCurrentFormat = 11; int ESM::SavedGame::sCurrentFormat = 12;
void ESM::SavedGame::load (ESMReader &esm) void ESM::SavedGame::load (ESMReader &esm)
{ {

Loading…
Cancel
Save