diff --git a/apps/navmeshtool/navmesh.cpp b/apps/navmeshtool/navmesh.cpp index 3161192cf9..8b85029949 100644 --- a/apps/navmeshtool/navmesh.cpp +++ b/apps/navmeshtool/navmesh.cpp @@ -137,7 +137,7 @@ namespace NavMeshTool { std::lock_guard lock(mMutex); mDb.insertTile(mNextTileId, worldspace, tilePosition, TileVersion {version}, input, serialize(data)); - ++mNextTileId.t; + ++mNextTileId; } ++mInserted; report(); diff --git a/apps/openmw/mwphysics/actor.cpp b/apps/openmw/mwphysics/actor.cpp index 568da999bc..a1f5a48388 100644 --- a/apps/openmw/mwphysics/actor.cpp +++ b/apps/openmw/mwphysics/actor.cpp @@ -163,7 +163,7 @@ bool Actor::setPosition(const osg::Vec3f& position) { std::scoped_lock lock(mPositionMutex); applyOffsetChange(); - bool hasChanged = (mPosition != position && !mSkipSimulation) || mWorldPositionChanged; + bool hasChanged = (mPosition.operator!=(position) && !mSkipSimulation) || mWorldPositionChanged; if (!mSkipSimulation) { mPreviousPosition = mPosition; diff --git a/apps/openmw_test_suite/detournavigator/navmeshdb.cpp b/apps/openmw_test_suite/detournavigator/navmeshdb.cpp index a17f5132c5..f7d9327e65 100644 --- a/apps/openmw_test_suite/detournavigator/navmeshdb.cpp +++ b/apps/openmw_test_suite/detournavigator/navmeshdb.cpp @@ -156,7 +156,7 @@ namespace for (int y = -2; y <= 2; ++y) { ASSERT_EQ(mDb.insertTile(tileId, worldspace, TilePosition {x, y}, version, input, data), 1); - ++tileId.t; + ++tileId; } } const TilesPositionsRange range {TilePosition {-1, -1}, TilePosition {2, 2}}; diff --git a/apps/openmw_test_suite/openmw/options.cpp b/apps/openmw_test_suite/openmw/options.cpp index 04c209e8a4..b65da5d157 100644 --- a/apps/openmw_test_suite/openmw/options.cpp +++ b/apps/openmw_test_suite/openmw/options.cpp @@ -17,9 +17,18 @@ namespace namespace bpo = boost::program_options; - std::vector generateSupportedCharacters(std::vector&& base = {}) + template + std::string makeString(const T (&range)[size]) { - std::vector result = std::move(base); + static_assert(size > 0); + return std::string(std::begin(range), std::end(range) - 1); + } + + template + std::vector generateSupportedCharacters(Args&& ... args) + { + std::vector result; + (result.emplace_back(makeString(args)) , ...); for (int i = 1; i <= std::numeric_limits::max(); ++i) if (i != '&' && i != '"' && i != ' ' && i != '\n') result.push_back(std::string(1, i)); @@ -193,7 +202,7 @@ namespace INSTANTIATE_TEST_SUITE_P( SupportedCharacters, OpenMWOptionsFromArgumentsStrings, - ValuesIn(generateSupportedCharacters({u8"👍", u8"Ъ", u8"Ǽ", "\n"})) + ValuesIn(generateSupportedCharacters(u8"👍", u8"Ъ", u8"Ǽ", "\n")) ); TEST(OpenMWOptionsFromConfig, should_support_single_word_load_savegame_path) @@ -381,6 +390,6 @@ namespace INSTANTIATE_TEST_SUITE_P( SupportedCharacters, OpenMWOptionsFromConfigStrings, - ValuesIn(generateSupportedCharacters({u8"👍", u8"Ъ", u8"Ǽ"})) + ValuesIn(generateSupportedCharacters(u8"👍", u8"Ъ", u8"Ǽ")) ); } diff --git a/components/detournavigator/asyncnavmeshupdater.cpp b/components/detournavigator/asyncnavmeshupdater.cpp index 657befd9d7..4af229da8a 100644 --- a/components/detournavigator/asyncnavmeshupdater.cpp +++ b/components/detournavigator/asyncnavmeshupdater.cpp @@ -733,7 +733,7 @@ namespace DetourNavigator { Stats result; result.mJobs = mQueue.size(); - result.mGetTileCount = mGetTileCount.load(std::memory_order::memory_order_relaxed); + result.mGetTileCount = mGetTileCount.load(std::memory_order_relaxed); return result; } @@ -857,6 +857,6 @@ namespace DetourNavigator Log(Debug::Debug) << "Insert db tile by job " << job->mId; mDb->insertTile(mNextTileId, job->mWorldspace, job->mChangedTile, mVersion, job->mInput, serialize(*job->mGeneratedNavMeshData)); - ++mNextTileId.t; + ++mNextTileId; } } diff --git a/components/detournavigator/navmeshdb.hpp b/components/detournavigator/navmeshdb.hpp index f10a3a3288..35aaeaf677 100644 --- a/components/detournavigator/navmeshdb.hpp +++ b/components/detournavigator/navmeshdb.hpp @@ -4,14 +4,13 @@ #include "tileposition.hpp" #include +#include #include #include #include #include -#include - #include #include #include @@ -28,10 +27,10 @@ struct sqlite3_stmt; namespace DetourNavigator { - BOOST_STRONG_TYPEDEF(std::int64_t, TileId) - BOOST_STRONG_TYPEDEF(std::int64_t, TileRevision) - BOOST_STRONG_TYPEDEF(std::int64_t, TileVersion) - BOOST_STRONG_TYPEDEF(std::int64_t, ShapeId) + using TileId = Misc::StrongTypedef; + using TileRevision = Misc::StrongTypedef; + using TileVersion = Misc::StrongTypedef; + using ShapeId = Misc::StrongTypedef; struct Tile { diff --git a/components/detournavigator/navmeshdbutils.cpp b/components/detournavigator/navmeshdbutils.cpp index 71873972b9..d2379c4e53 100644 --- a/components/detournavigator/navmeshdbutils.cpp +++ b/components/detournavigator/navmeshdbutils.cpp @@ -28,7 +28,7 @@ namespace DetourNavigator const ShapeId newShapeId = nextShapeId; db.insertShape(newShapeId, name, type, hashData); Log(Debug::Verbose) << "Added " << name << " " << type << " shape to navmeshdb with id " << newShapeId; - ++nextShapeId.t; + ++nextShapeId; return newShapeId; } } diff --git a/components/misc/strongtypedef.hpp b/components/misc/strongtypedef.hpp new file mode 100644 index 0000000000..2a9e4c3a8b --- /dev/null +++ b/components/misc/strongtypedef.hpp @@ -0,0 +1,38 @@ +#ifndef OPENMW_COMPONENTS_MISC_STRONGTYPEDEF_H +#define OPENMW_COMPONENTS_MISC_STRONGTYPEDEF_H + +#include + +namespace Misc +{ + template + struct StrongTypedef + { + T mValue; + + StrongTypedef() = default; + + explicit StrongTypedef(const T& value) : mValue(value) {} + + explicit StrongTypedef(T&& value) : mValue(std::move(value)) {} + + operator const T&() const { return mValue; } + + operator T&() { return mValue; } + + StrongTypedef& operator++() + { + ++mValue; + return *this; + } + + StrongTypedef operator++(int) + { + StrongTypedef copy(*this); + operator++(); + return copy; + } + }; +} + +#endif diff --git a/components/sceneutil/mwshadowtechnique.cpp b/components/sceneutil/mwshadowtechnique.cpp index d56708e46c..1bdc0e5693 100644 --- a/components/sceneutil/mwshadowtechnique.cpp +++ b/components/sceneutil/mwshadowtechnique.cpp @@ -493,7 +493,7 @@ void MWShadowTechnique::LightData::setLightData(osg::RefMatrix* lm, const osg::L lightDir.set(-lightPos.x(), -lightPos.y(), -lightPos.z()); lightDir.normalize(); OSG_INFO<<" Directional light, lightPos="<