1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-01 09:09:42 +00:00

Merge pull request #2890 from akortunov/position

Do not store object position, if it is the same as in CellRef
This commit is contained in:
Roman Siromakha 2020-06-08 01:12:47 +02:00 committed by GitHub
commit 27a113167c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 2 deletions

View file

@ -57,6 +57,26 @@ struct Position
};
#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>
struct FourCC
{

View file

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

View file

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