mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-28 16:09:43 +00:00
Make sure Vec2iRefId is trivially copyable on GCC 11.3
std::pair<int, int> isn't trivially copyable on some compilers so a specific struct is defined, it's an int pair, but it should be recognised by GCC 11.3 as trivially copyable Vec2iRefId => ESM3ExteriorCellRefId more explcit name and use mX,mY instead of pair renamed files and enum
This commit is contained in:
parent
53b14c8b42
commit
d782d37ee2
18 changed files with 109 additions and 112 deletions
|
@ -60,7 +60,7 @@ namespace ESSImport
|
|||
, mHour(0.f)
|
||||
, mNextActorId(0)
|
||||
{
|
||||
mPlayer.mCellId = ESM::Cell::generateIdForExteriorCell(0, 0);
|
||||
mPlayer.mCellId = ESM::RefId::esm3ExteriorCell(0, 0);
|
||||
mPlayer.mLastKnownExteriorPosition[0] = mPlayer.mLastKnownExteriorPosition[1]
|
||||
= mPlayer.mLastKnownExteriorPosition[2] = 0.0f;
|
||||
mPlayer.mHasMark = 0;
|
||||
|
|
|
@ -73,7 +73,7 @@ void CSMWorld::RefCollection::load(ESM::ESMReader& reader, int cellIndex, bool b
|
|||
// Autocalculate the cell index from coordinates first
|
||||
std::pair<int, int> index = ref.getCellIndex();
|
||||
|
||||
ref.mCell = ESM::RefId::vec2i(index);
|
||||
ref.mCell = ESM::RefId::esm3ExteriorCell(index.first, index.second);
|
||||
|
||||
// Handle non-base moved references
|
||||
if (!base && isMoved)
|
||||
|
@ -89,7 +89,7 @@ void CSMWorld::RefCollection::load(ESM::ESMReader& reader, int cellIndex, bool b
|
|||
if (index.first != mref.mTarget[0] || index.second != mref.mTarget[1])
|
||||
{
|
||||
ESM::RefId indexCell = ref.mCell;
|
||||
ref.mCell = ESM::RefId::vec2i({ mref.mTarget[0], mref.mTarget[1] });
|
||||
ref.mCell = ESM::RefId::esm3ExteriorCell(mref.mTarget[0], mref.mTarget[1]);
|
||||
|
||||
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Cell, mCells.getId(cellIndex));
|
||||
messages.add(id, "The position of the moved reference " + ref.mRefID.toDebugString() + " (cell " + indexCell.toDebugString() + ")"
|
||||
|
|
|
@ -1109,7 +1109,7 @@ namespace MWGui
|
|||
|
||||
void MapWindow::setGlobalMapMarkerTooltip(MyGUI::Widget* markerWidget, int x, int y)
|
||||
{
|
||||
ESM::RefId cellRefId = ESM::Cell::generateIdForExteriorCell(x, y);
|
||||
ESM::RefId cellRefId = ESM::RefId::esm3ExteriorCell(x, y);
|
||||
CustomMarkerCollection::RangeType markers = mCustomMarkers.getMarkers(cellRefId);
|
||||
std::vector<std::string> destNotes;
|
||||
for (CustomMarkerCollection::ContainerType::const_iterator it = markers.first; it != markers.second; ++it)
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace MWWorld
|
|||
else
|
||||
{
|
||||
const osg::Vec2i index = positionToCellIndex(ref.mDoorDest.pos[0], ref.mDoorDest.pos[1]);
|
||||
return ESM::Cell::generateIdForExteriorCell(index.x(), index.y());
|
||||
return ESM::RefId::esm3ExteriorCell(index.x(), index.y());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -379,7 +379,7 @@ namespace MWWorld
|
|||
pos.rot[2] = 0;
|
||||
|
||||
osg::Vec2i exteriorCellPos = positionToCellIndex(pos.pos[0], pos.pos[1]);
|
||||
ESM::RefId cellId = ESM::Cell::generateIdForExteriorCell(exteriorCellPos.x(), exteriorCellPos.y());
|
||||
ESM::RefId cellId = ESM::RefId::esm3ExteriorCell(exteriorCellPos.x(), exteriorCellPos.y());
|
||||
mWorldScene->changeToExteriorCell(cellId, pos, true);
|
||||
}
|
||||
}
|
||||
|
@ -984,7 +984,7 @@ namespace MWWorld
|
|||
}
|
||||
removeContainerScripts(getPlayerPtr());
|
||||
osg::Vec2i exteriorCellPos = positionToCellIndex(position.pos[0], position.pos[1]);
|
||||
ESM::RefId cellId = ESM::Cell::generateIdForExteriorCell(exteriorCellPos.x(), exteriorCellPos.y());
|
||||
ESM::RefId cellId = ESM::RefId::esm3ExteriorCell(exteriorCellPos.x(), exteriorCellPos.y());
|
||||
mWorldScene->changeToExteriorCell(cellId, position, adjustPlayerPos, changeEvent);
|
||||
addContainerScripts(getPlayerPtr(), getPlayerPtr().getCell());
|
||||
mRendering->getCamera()->instantTransition();
|
||||
|
|
|
@ -226,9 +226,9 @@ MWWorld::CellStore* MWWorld::WorldModel::getInterior(std::string_view name)
|
|||
|
||||
struct VisitorCellIdIsESM3Ext
|
||||
{
|
||||
bool operator()(const ESM::Vec2iRefId& id)
|
||||
bool operator()(const ESM::ESM3ExteriorCellRefId& id)
|
||||
{
|
||||
coordOut = { id.getValue().first, id.getValue().second };
|
||||
coordOut = { id.getX(), id.getY() };
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -448,7 +448,7 @@ namespace
|
|||
refId = RecordType::indexToRefId(index);
|
||||
else if constexpr (std::is_same_v<RecordType, ESM::Cell>)
|
||||
{
|
||||
refId = ESM::Cell::generateIdForExteriorCell(0, 0);
|
||||
refId = ESM::RefId::esm3ExteriorCell(0, 0);
|
||||
}
|
||||
else
|
||||
refId = ESM::StringRefId(stringId);
|
||||
|
|
|
@ -91,7 +91,7 @@ add_component_dir(esm attr common defs esmcommon records util luascripts format
|
|||
generatedrefid
|
||||
indexrefid
|
||||
serializerefid
|
||||
vec2irefid
|
||||
esm3exteriorcellrefid
|
||||
)
|
||||
|
||||
add_component_dir(fx pass technique lexer widgets stateupdater)
|
||||
|
|
26
components/esm/esm3exteriorcellrefid.cpp
Normal file
26
components/esm/esm3exteriorcellrefid.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include "esm3exteriorcellrefid.hpp"
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
std::string ESM3ExteriorCellRefId::toString() const
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "# " << mY << ", " << mY;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::string ESM3ExteriorCellRefId::toDebugString() const
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << *this;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& stream, ESM3ExteriorCellRefId value)
|
||||
{
|
||||
return stream << "Vec2i{" << value.mX << "," << value.mY << '}';
|
||||
}
|
||||
}
|
55
components/esm/esm3exteriorcellrefid.hpp
Normal file
55
components/esm/esm3exteriorcellrefid.hpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
#ifndef OPENMW_COMPONENTS_ESM_ESM3EXTERIORCELLREFID_HPP
|
||||
#define OPENMW_COMPONENTS_ESM_ESM3EXTERIORCELLREFID_HPP
|
||||
|
||||
#include <functional>
|
||||
#include <iosfwd>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class ESM3ExteriorCellRefId
|
||||
{
|
||||
public:
|
||||
constexpr ESM3ExteriorCellRefId() = default;
|
||||
|
||||
constexpr explicit ESM3ExteriorCellRefId(int32_t x, int32_t y) noexcept
|
||||
: mX(x)
|
||||
, mY(y)
|
||||
{
|
||||
}
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
std::string toDebugString() const;
|
||||
|
||||
int32_t getX() const { return mX; }
|
||||
int32_t getY() const { return mY; }
|
||||
|
||||
constexpr bool operator==(ESM3ExteriorCellRefId rhs) const noexcept { return mX == rhs.mX && mY == rhs.mY; }
|
||||
|
||||
constexpr bool operator<(ESM3ExteriorCellRefId rhs) const noexcept { return mX < rhs.mX && mY < rhs.mY; }
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& stream, ESM3ExteriorCellRefId value);
|
||||
|
||||
friend struct std::hash<ESM3ExteriorCellRefId>;
|
||||
|
||||
private:
|
||||
int32_t mX = 0;
|
||||
int32_t mY = 0;
|
||||
};
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <>
|
||||
struct hash<ESM::ESM3ExteriorCellRefId>
|
||||
{
|
||||
std::size_t operator()(ESM::ESM3ExteriorCellRefId value) const noexcept
|
||||
{
|
||||
return (53 + std::hash<int32_t>{}(value.mX)) * 53 + std::hash<int32_t>{}(value.mY);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
#include <components/misc/notnullptr.hpp>
|
||||
|
||||
#include "esm3exteriorcellrefid.hpp"
|
||||
#include "formidrefid.hpp"
|
||||
#include "generatedrefid.hpp"
|
||||
#include "indexrefid.hpp"
|
||||
#include "stringrefid.hpp"
|
||||
#include "vec2irefid.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ namespace ESM
|
|||
FormId = 3,
|
||||
Generated = 4,
|
||||
Index = 5,
|
||||
Vec2i = 6,
|
||||
ESM3ExteriorCell = 6,
|
||||
};
|
||||
|
||||
// RefId is used to represent an Id that identifies an ESM record. These Ids can then be used in
|
||||
|
@ -72,7 +72,7 @@ namespace ESM
|
|||
// identified by index (i.e. ESM3 SKIL).
|
||||
static RefId index(RecNameInts recordType, std::uint32_t value) { return RefId(IndexRefId(recordType, value)); }
|
||||
|
||||
static RefId vec2i(std::pair<int32_t, int32_t> value) { return RefId(Vec2iRefId(value)); }
|
||||
static RefId esm3ExteriorCell(int32_t x, int32_t y) { return RefId(ESM3ExteriorCellRefId(x, y)); }
|
||||
|
||||
constexpr RefId() = default;
|
||||
|
||||
|
@ -101,7 +101,7 @@ namespace ESM
|
|||
{
|
||||
}
|
||||
|
||||
constexpr RefId(Vec2iRefId value) noexcept
|
||||
constexpr RefId(ESM3ExteriorCellRefId value) noexcept
|
||||
: mValue(value)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
#include "vec2irefid.hpp"
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
std::string Vec2iRefId::toString() const
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "# " << mValue.first << ", " << mValue.second;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::string Vec2iRefId::toDebugString() const
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << *this;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& stream, Vec2iRefId value)
|
||||
{
|
||||
return stream << "Vec2i{" << value.mValue.first << "," << value.mValue.second << '}';
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
#ifndef OPENMW_COMPONENTS_ESM_VEC2IREFID_HPP
|
||||
#define OPENMW_COMPONENTS_ESM_VEC2IREFID_HPP
|
||||
|
||||
#include <functional>
|
||||
#include <iosfwd>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class Vec2iRefId
|
||||
{
|
||||
public:
|
||||
constexpr Vec2iRefId() = default;
|
||||
|
||||
constexpr explicit Vec2iRefId(std::pair<int32_t, int32_t> value) noexcept
|
||||
: mValue(value)
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<int32_t, int32_t> getValue() const { return mValue; }
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
std::string toDebugString() const;
|
||||
|
||||
constexpr bool operator==(Vec2iRefId rhs) const noexcept { return mValue == rhs.mValue; }
|
||||
|
||||
constexpr bool operator<(Vec2iRefId rhs) const noexcept { return mValue < rhs.mValue; }
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& stream, Vec2iRefId value);
|
||||
|
||||
friend struct std::hash<Vec2iRefId>;
|
||||
|
||||
private:
|
||||
std::pair<int32_t, int32_t> mValue = std::pair<int32_t, int32_t>(0, 0);
|
||||
};
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <>
|
||||
struct hash<ESM::Vec2iRefId>
|
||||
{
|
||||
std::size_t operator()(ESM::Vec2iRefId value) const noexcept
|
||||
{
|
||||
return (53 + std::hash<int32_t>{}(value.mValue.first)) * 53 + std::hash<int32_t>{}(value.mValue.second);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -50,11 +50,11 @@ namespace ESM
|
|||
out.mIndex = { 0, 0 };
|
||||
return out;
|
||||
}
|
||||
CellId operator()(const ESM::Vec2iRefId& id)
|
||||
CellId operator()(const ESM::ESM3ExteriorCellRefId& id)
|
||||
{
|
||||
CellId out;
|
||||
out.mPaged = true;
|
||||
out.mIndex = { id.getValue().first, id.getValue().second };
|
||||
out.mIndex = { id.getX(), id.getY() };
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace ESM
|
|||
cellId.load(*this);
|
||||
if (cellId.mPaged)
|
||||
{
|
||||
return ESM::Cell::generateIdForExteriorCell(cellId.mIndex.mX, cellId.mIndex.mY);
|
||||
return ESM::RefId::esm3ExteriorCell(cellId.mIndex.mX, cellId.mIndex.mY);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -491,12 +491,12 @@ namespace ESM
|
|||
getExact(&index, sizeof(std::uint32_t));
|
||||
return RefId::index(recordType, index);
|
||||
}
|
||||
case RefIdType::Vec2i:
|
||||
case RefIdType::ESM3ExteriorCell:
|
||||
{
|
||||
std::pair<int32_t, int32_t> vec2i;
|
||||
getExact(&vec2i.first, sizeof(std::int32_t));
|
||||
getExact(&vec2i.second, sizeof(std::int32_t));
|
||||
return RefId::vec2i(vec2i);
|
||||
int32_t x, y;
|
||||
getExact(&x, sizeof(std::int32_t));
|
||||
getExact(&y, sizeof(std::int32_t));
|
||||
return RefId::esm3ExteriorCell(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,11 +62,11 @@ namespace ESM
|
|||
mWriter.writeT(v.getValue());
|
||||
}
|
||||
|
||||
void operator()(Vec2iRefId v) const
|
||||
void operator()(ESM3ExteriorCellRefId v) const
|
||||
{
|
||||
mWriter.writeT(RefIdType::Vec2i);
|
||||
mWriter.writeT(v.getValue().first);
|
||||
mWriter.writeT(v.getValue().second);
|
||||
mWriter.writeT(RefIdType::ESM3ExteriorCell);
|
||||
mWriter.writeT(v.getX());
|
||||
mWriter.writeT(v.getY());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -64,11 +64,6 @@ namespace ESM
|
|||
return mId;
|
||||
}
|
||||
|
||||
ESM::RefId Cell::generateIdForExteriorCell(int x, int y)
|
||||
{
|
||||
return ESM::RefId::vec2i({ x, y });
|
||||
}
|
||||
|
||||
ESM::RefId Cell::generateIdForCell(bool exterior, std::string_view cellName, int x, int y)
|
||||
{
|
||||
if (!exterior)
|
||||
|
@ -77,7 +72,7 @@ namespace ESM
|
|||
}
|
||||
else
|
||||
{
|
||||
return generateIdForExteriorCell(x, y);
|
||||
return ESM::RefId::esm3ExteriorCell(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -193,7 +193,6 @@ namespace ESM
|
|||
|
||||
const ESM::RefId& updateId();
|
||||
|
||||
static ESM::RefId generateIdForExteriorCell(int x, int y);
|
||||
static ESM::RefId generateIdForCell(bool exterior, std::string_view cellName, int x, int y);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue