mirror of
https://github.com/OpenMW/openmw.git
synced 2025-11-30 16:34:30 +00:00
Support wrapped arthimetic types
This commit is contained in:
parent
71fa8c9f7d
commit
b0cf148393
2 changed files with 12 additions and 6 deletions
|
|
@ -195,7 +195,7 @@ namespace DetourNavigator
|
||||||
TileId NavMeshDb::getMaxTileId()
|
TileId NavMeshDb::getMaxTileId()
|
||||||
{
|
{
|
||||||
TileId tileId{ 0 };
|
TileId tileId{ 0 };
|
||||||
request(*mDb, mGetMaxTileId, &tileId.mValue, 1);
|
request(*mDb, mGetMaxTileId, &tileId, 1);
|
||||||
return tileId;
|
return tileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -203,7 +203,7 @@ namespace DetourNavigator
|
||||||
ESM::RefId worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
|
ESM::RefId worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
|
||||||
{
|
{
|
||||||
Tile result;
|
Tile result;
|
||||||
auto row = std::tie(result.mTileId.mValue, result.mVersion.mValue);
|
auto row = std::tie(result.mTileId, result.mVersion);
|
||||||
const std::vector<std::byte> compressedInput = Misc::compress(input);
|
const std::vector<std::byte> compressedInput = Misc::compress(input);
|
||||||
if (&row == request(*mDb, mFindTile, &row, 1, worldspace.serializeText(), tilePosition, compressedInput))
|
if (&row == request(*mDb, mFindTile, &row, 1, worldspace.serializeText(), tilePosition, compressedInput))
|
||||||
return {};
|
return {};
|
||||||
|
|
@ -214,7 +214,7 @@ namespace DetourNavigator
|
||||||
ESM::RefId worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
|
ESM::RefId worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
|
||||||
{
|
{
|
||||||
TileData result;
|
TileData result;
|
||||||
auto row = std::tie(result.mTileId.mValue, result.mVersion.mValue, result.mData);
|
auto row = std::tie(result.mTileId, result.mVersion, result.mData);
|
||||||
const std::vector<std::byte> compressedInput = Misc::compress(input);
|
const std::vector<std::byte> compressedInput = Misc::compress(input);
|
||||||
if (&row == request(*mDb, mGetTileData, &row, 1, worldspace.serializeText(), tilePosition, compressedInput))
|
if (&row == request(*mDb, mGetTileData, &row, 1, worldspace.serializeText(), tilePosition, compressedInput))
|
||||||
return {};
|
return {};
|
||||||
|
|
@ -255,14 +255,14 @@ namespace DetourNavigator
|
||||||
ShapeId NavMeshDb::getMaxShapeId()
|
ShapeId NavMeshDb::getMaxShapeId()
|
||||||
{
|
{
|
||||||
ShapeId shapeId{ 0 };
|
ShapeId shapeId{ 0 };
|
||||||
request(*mDb, mGetMaxShapeId, &shapeId.mValue, 1);
|
request(*mDb, mGetMaxShapeId, &shapeId, 1);
|
||||||
return shapeId;
|
return shapeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<ShapeId> NavMeshDb::findShapeId(std::string_view name, ShapeType type, const Sqlite3::ConstBlob& hash)
|
std::optional<ShapeId> NavMeshDb::findShapeId(std::string_view name, ShapeType type, const Sqlite3::ConstBlob& hash)
|
||||||
{
|
{
|
||||||
ShapeId shapeId;
|
ShapeId shapeId;
|
||||||
if (&shapeId.mValue == request(*mDb, mFindShapeId, &shapeId.mValue, 1, name, type, hash))
|
if (&shapeId == request(*mDb, mFindShapeId, &shapeId, 1, name, type, hash))
|
||||||
return {};
|
return {};
|
||||||
return shapeId;
|
return shapeId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ namespace Sqlite3
|
||||||
value = nullptr;
|
value = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T, class = std::enable_if_t<std::is_arithmetic_v<T>>>
|
||||||
inline auto copyColumn(sqlite3& /*db*/, sqlite3_stmt& statement, int index, int type, T& value)
|
inline auto copyColumn(sqlite3& /*db*/, sqlite3_stmt& statement, int index, int type, T& value)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
|
|
@ -116,6 +116,12 @@ namespace Sqlite3
|
||||||
+ " that does not match expected output type: SQLITE_INTEGER or SQLITE_FLOAT or SQLITE_NULL");
|
+ " that does not match expected output type: SQLITE_INTEGER or SQLITE_FLOAT or SQLITE_NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class T, class V = decltype(T::mValue), class = std::enable_if_t<std::is_arithmetic_v<V>>>
|
||||||
|
inline auto copyColumn(sqlite3& db, sqlite3_stmt& statement, int index, int type, T& value)
|
||||||
|
{
|
||||||
|
return copyColumn<V>(db, statement, index, type, value.mValue);
|
||||||
|
}
|
||||||
|
|
||||||
inline void copyColumn(sqlite3& db, sqlite3_stmt& statement, int index, int type, std::string& value)
|
inline void copyColumn(sqlite3& db, sqlite3_stmt& statement, int index, int type, std::string& value)
|
||||||
{
|
{
|
||||||
if (type != SQLITE_TEXT)
|
if (type != SQLITE_TEXT)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue