1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-30 16:20:21 +00:00

Merge branch 'fix_msvc_warnings' into 'master'

Fix msvc warnings

See merge request OpenMW/openmw!2071
This commit is contained in:
AnyOldName3 2022-07-01 23:02:09 +00:00
commit fdd920ed72
14 changed files with 64 additions and 61 deletions

View File

@ -78,7 +78,7 @@ namespace
const std::map<TilePosition, ChangeType> changedTiles {{TilePosition {0, 0}, ChangeType::add}};
updater.post(mAgentBounds, navMeshCacheItem, mPlayerTile, mWorldspace, changedTiles);
updater.wait(mListener, WaitConditionType::allJobsDone);
EXPECT_NE(navMeshCacheItem->lockConst()->getImpl().getTileRefAt(0, 0, 0), 0);
EXPECT_NE(navMeshCacheItem->lockConst()->getImpl().getTileRefAt(0, 0, 0), 0u);
}
TEST_F(DetourNavigatorAsyncNavMeshUpdaterTest, repeated_post_should_lead_to_cache_hit)
@ -150,7 +150,7 @@ namespace
serialize(mSettings.mRecast, mAgentBounds, *recastMesh, objects));
ASSERT_TRUE(tile.has_value());
EXPECT_EQ(tile->mTileId, 1);
EXPECT_EQ(tile->mVersion, navMeshVersion);
EXPECT_EQ(tile->mVersion, navMeshFormatVersion);
}
TEST_F(DetourNavigatorAsyncNavMeshUpdaterTest, post_when_writing_to_db_disabled_should_not_write_tiles)
@ -240,12 +240,12 @@ namespace
const std::map<TilePosition, ChangeType> changedTilesAdd {{TilePosition {0, 0}, ChangeType::add}};
updater.post(mAgentBounds, navMeshCacheItem, mPlayerTile, mWorldspace, changedTilesAdd);
updater.wait(mListener, WaitConditionType::allJobsDone);
ASSERT_NE(navMeshCacheItem->lockConst()->getImpl().getTileRefAt(0, 0, 0), 0);
ASSERT_NE(navMeshCacheItem->lockConst()->getImpl().getTileRefAt(0, 0, 0), 0u);
const std::map<TilePosition, ChangeType> changedTilesRemove {{TilePosition {0, 0}, ChangeType::remove}};
const TilePosition playerTile(100, 100);
updater.post(mAgentBounds, navMeshCacheItem, playerTile, mWorldspace, changedTilesRemove);
updater.wait(mListener, WaitConditionType::allJobsDone);
EXPECT_EQ(navMeshCacheItem->lockConst()->getImpl().getTileRefAt(0, 0, 0), 0);
EXPECT_EQ(navMeshCacheItem->lockConst()->getImpl().getTileRefAt(0, 0, 0), 0u);
}
TEST_F(DetourNavigatorAsyncNavMeshUpdaterTest, should_stop_writing_to_db_when_size_limit_is_reached)

View File

@ -338,10 +338,10 @@ namespace
AreaType_ground, mSource, mObjectTransform
);
const auto recastMesh = std::move(builder).create(mGeneration, mRevision);
EXPECT_THAT(recastMesh->getMesh().getVertices(), Pointwise(FloatNear(1e-5), std::vector<float>({
0, -4.24264049530029296875, 4.44089209850062616169452667236328125e-16,
0, -3.535533905029296875, -0.707106769084930419921875,
0, -3.535533905029296875, 0.707106769084930419921875,
EXPECT_THAT(recastMesh->getMesh().getVertices(), Pointwise(FloatNear(1e-5f), std::vector<float>({
0, -4.24264049530029296875f, 4.44089209850062616169452667236328125e-16f,
0, -3.535533905029296875f, -0.707106769084930419921875f,
0, -3.535533905029296875f, 0.707106769084930419921875f,
}))) << recastMesh->getMesh().getVertices();
EXPECT_EQ(recastMesh->getMesh().getIndices(), std::vector<int>({1, 2, 0}));
EXPECT_EQ(recastMesh->getMesh().getAreaTypes(), std::vector<AreaType>({AreaType_ground}));
@ -363,10 +363,10 @@ namespace
AreaType_ground, mSource, mObjectTransform
);
const auto recastMesh = std::move(builder).create(mGeneration, mRevision);
EXPECT_THAT(recastMesh->getMesh().getVertices(), Pointwise(FloatNear(1e-5), std::vector<float>({
-4.24264049530029296875, 0, 4.44089209850062616169452667236328125e-16,
-3.535533905029296875, 0, -0.707106769084930419921875,
-3.535533905029296875, 0, 0.707106769084930419921875,
EXPECT_THAT(recastMesh->getMesh().getVertices(), Pointwise(FloatNear(1e-5f), std::vector<float>({
-4.24264049530029296875f, 0, 4.44089209850062616169452667236328125e-16f,
-3.535533905029296875f, 0, -0.707106769084930419921875f,
-3.535533905029296875f, 0, 0.707106769084930419921875f,
}))) << recastMesh->getMesh().getVertices();
EXPECT_EQ(recastMesh->getMesh().getIndices(), std::vector<int>({1, 2, 0}));
EXPECT_EQ(recastMesh->getMesh().getAreaTypes(), std::vector<AreaType>({AreaType_ground}));
@ -388,10 +388,10 @@ namespace
AreaType_ground, mSource, mObjectTransform
);
const auto recastMesh = std::move(builder).create(mGeneration, mRevision);
EXPECT_THAT(recastMesh->getMesh().getVertices(), Pointwise(FloatNear(1e-5), std::vector<float>({
-1.41421353816986083984375, -1.1102230246251565404236316680908203125e-16, 0,
1.1102230246251565404236316680908203125e-16, -1.41421353816986083984375, 0,
1.41421353816986083984375, 1.1102230246251565404236316680908203125e-16, 0,
EXPECT_THAT(recastMesh->getMesh().getVertices(), Pointwise(FloatNear(1e-5f), std::vector<float>({
-1.41421353816986083984375f, -1.1102230246251565404236316680908203125e-16f, 0,
1.1102230246251565404236316680908203125e-16f, -1.41421353816986083984375f, 0,
1.41421353816986083984375f, 1.1102230246251565404236316680908203125e-16f, 0,
}))) << recastMesh->getMesh().getVertices();
EXPECT_EQ(recastMesh->getMesh().getIndices(), std::vector<int>({2, 0, 1}));
EXPECT_EQ(recastMesh->getMesh().getAreaTypes(), std::vector<AreaType>({AreaType_ground}));

View File

@ -236,7 +236,7 @@ namespace
{
sol::table data = LuaUtil::deserialize(lua.lua_state(), loadedCfg.mScripts[1].mRefs[1].mInitializationData, &serializer);
ESM::RefNum adjustedRef = data["fargoth"].get<ESM::RefNum>();
EXPECT_EQ(adjustedRef.mIndex, 128964);
EXPECT_EQ(adjustedRef.mIndex, 128964u);
EXPECT_EQ(adjustedRef.mContentFile, 2);
}
}

View File

@ -33,7 +33,7 @@ namespace
EXPECT_EQ(serialized.size(), 10); // version, type, 8 bytes value
sol::object value = LuaUtil::deserialize(lua, serialized);
ASSERT_TRUE(value.is<double>());
EXPECT_FLOAT_EQ(value.as<double>(), 3.14);
EXPECT_DOUBLE_EQ(value.as<double>(), 3.14);
}
TEST(LuaSerializationTest, Boolean)
@ -183,7 +183,7 @@ namespace
EXPECT_EQ(t.get<bool>("ab"), true);
EXPECT_EQ(t.get<sol::table>("nested").get<int>("aa"), 2);
EXPECT_EQ(t.get<sol::table>("nested").get<std::string>("bb"), "something");
EXPECT_FLOAT_EQ(t.get<sol::table>("nested").get<double>(5), -0.5);
EXPECT_DOUBLE_EQ(t.get<sol::table>("nested").get<double>(5), -0.5);
EXPECT_EQ(t.get<osg::Vec2f>(1), osg::Vec2f(1, 2));
EXPECT_EQ(t.get<osg::Vec2f>(2), osg::Vec2f(2, 1));
}

View File

@ -172,12 +172,12 @@ namespace
lua.open_libraries(sol::lib::base, sol::lib::math, sol::lib::string);
lua["util"] = LuaUtil::initUtilPackage(lua);
lua.safe_script("v = util.vector2(1, 0):rotate(math.rad(120))");
EXPECT_FLOAT_EQ(get<float>(lua, "v.x"), -0.5);
EXPECT_FLOAT_EQ(get<float>(lua, "v.y"), 0.86602539);
EXPECT_FLOAT_EQ(get<float>(lua, "util.normalizeAngle(math.pi * 10 + 0.1)"), 0.1);
EXPECT_FLOAT_EQ(get<float>(lua, "util.clamp(0.1, 0, 1.5)"), 0.1);
EXPECT_FLOAT_EQ(get<float>(lua, "v.x"), -0.5f);
EXPECT_FLOAT_EQ(get<float>(lua, "v.y"), 0.86602539f);
EXPECT_FLOAT_EQ(get<float>(lua, "util.normalizeAngle(math.pi * 10 + 0.1)"), 0.1f);
EXPECT_FLOAT_EQ(get<float>(lua, "util.clamp(0.1, 0, 1.5)"), 0.1f);
EXPECT_FLOAT_EQ(get<float>(lua, "util.clamp(-0.1, 0, 1.5)"), 0);
EXPECT_FLOAT_EQ(get<float>(lua, "util.clamp(2.1, 0, 1.5)"), 1.5);
EXPECT_FLOAT_EQ(get<float>(lua, "util.clamp(2.1, 0, 1.5)"), 1.5f);
lua.safe_script("t = util.makeReadOnly({x = 1})");
EXPECT_FLOAT_EQ(get<float>(lua, "t.x"), 1);
EXPECT_ERROR(lua.safe_script("t.y = 2"), "userdata value");

View File

@ -31,24 +31,24 @@ TEST_F(EndiannessTest, test_swap_endianness_inplace2)
uint16_t fortytwo = 0x0042;
Misc::swapEndiannessInplace(zero);
EXPECT_EQ(zero, 0x0000);
EXPECT_EQ(zero, 0x0000u);
Misc::swapEndiannessInplace(zero);
EXPECT_EQ(zero, 0x0000);
EXPECT_EQ(zero, 0x0000u);
Misc::swapEndiannessInplace(ffff);
EXPECT_EQ(ffff, 0xFFFF);
EXPECT_EQ(ffff, 0xFFFFu);
Misc::swapEndiannessInplace(ffff);
EXPECT_EQ(ffff, 0xFFFF);
EXPECT_EQ(ffff, 0xFFFFu);
Misc::swapEndiannessInplace(n12);
EXPECT_EQ(n12, 0x0201);
EXPECT_EQ(n12, 0x0201u);
Misc::swapEndiannessInplace(n12);
EXPECT_EQ(n12, 0x0102);
EXPECT_EQ(n12, 0x0102u);
Misc::swapEndiannessInplace(fortytwo);
EXPECT_EQ(fortytwo, 0x4200);
EXPECT_EQ(fortytwo, 0x4200u);
Misc::swapEndiannessInplace(fortytwo);
EXPECT_EQ(fortytwo, 0x0042);
EXPECT_EQ(fortytwo, 0x0042u);
}
TEST_F(EndiannessTest, test_swap_endianness_inplace4)
@ -58,19 +58,19 @@ TEST_F(EndiannessTest, test_swap_endianness_inplace4)
uint32_t ffff = 0xFFFFFFFF;
Misc::swapEndiannessInplace(zero);
EXPECT_EQ(zero, 0x00000000);
EXPECT_EQ(zero, 0x00000000u);
Misc::swapEndiannessInplace(zero);
EXPECT_EQ(zero, 0x00000000);
EXPECT_EQ(zero, 0x00000000u);
Misc::swapEndiannessInplace(n1234);
EXPECT_EQ(n1234, 0x04030201);
EXPECT_EQ(n1234, 0x04030201u);
Misc::swapEndiannessInplace(n1234);
EXPECT_EQ(n1234, 0x01020304);
EXPECT_EQ(n1234, 0x01020304u);
Misc::swapEndiannessInplace(ffff);
EXPECT_EQ(ffff, 0xFFFFFFFF);
EXPECT_EQ(ffff, 0xFFFFFFFFu);
Misc::swapEndiannessInplace(ffff);
EXPECT_EQ(ffff, 0xFFFFFFFF);
EXPECT_EQ(ffff, 0xFFFFFFFFu);
}
TEST_F(EndiannessTest, test_swap_endianness_inplace8)
@ -80,19 +80,19 @@ TEST_F(EndiannessTest, test_swap_endianness_inplace8)
uint64_t ffff = 0xFFFF'FFFF'FFFF'FFFF;
Misc::swapEndiannessInplace(zero);
EXPECT_EQ(zero, 0x0000'0000'0000'0000);
EXPECT_EQ(zero, 0x0000'0000'0000'0000u);
Misc::swapEndiannessInplace(zero);
EXPECT_EQ(zero, 0x0000'0000'0000'0000);
EXPECT_EQ(zero, 0x0000'0000'0000'0000u);
Misc::swapEndiannessInplace(ffff);
EXPECT_EQ(ffff, 0xFFFF'FFFF'FFFF'FFFF);
EXPECT_EQ(ffff, 0xFFFF'FFFF'FFFF'FFFFu);
Misc::swapEndiannessInplace(ffff);
EXPECT_EQ(ffff, 0xFFFF'FFFF'FFFF'FFFF);
EXPECT_EQ(ffff, 0xFFFF'FFFF'FFFF'FFFFu);
Misc::swapEndiannessInplace(n1234);
EXPECT_EQ(n1234, 0x0807'0605'0403'0201);
EXPECT_EQ(n1234, 0x0807'0605'0403'0201u);
Misc::swapEndiannessInplace(n1234);
EXPECT_EQ(n1234, 0x0102'0304'0506'0708);
EXPECT_EQ(n1234, 0x0102'0304'0506'0708u);
}
TEST_F(EndiannessTest, test_swap_endianness_inplace_float)

View File

@ -24,7 +24,7 @@ namespace
std::uint32_t result = 0;
const TestFormat<Mode::Read> format;
binaryReader(format, result);
EXPECT_EQ(result, 42);
EXPECT_EQ(result, 42u);
}
TEST(DetourNavigatorSerializationBinaryReaderTest, shouldReadArithmeticTypeRangeValue)

View File

@ -92,7 +92,7 @@ namespace DetourNavigator
{
if (db == nullptr)
return nullptr;
return std::make_unique<DbWorker>(updater, std::move(db), TileVersion(navMeshVersion),
return std::make_unique<DbWorker>(updater, std::move(db), TileVersion(navMeshFormatVersion),
settings.mRecast, settings.mWriteToNavMeshDb);
}
@ -483,7 +483,7 @@ namespace DetourNavigator
std::unique_ptr<PreparedNavMeshData> preparedNavMeshData;
bool generatedNavMeshData = false;
if (job.mCachedTileData.has_value() && job.mCachedTileData->mVersion == navMeshVersion)
if (job.mCachedTileData.has_value() && job.mCachedTileData->mVersion == navMeshFormatVersion)
{
preparedNavMeshData = std::make_unique<PreparedNavMeshData>();
if (deserialize(job.mCachedTileData->mData, *preparedNavMeshData))

View File

@ -73,7 +73,7 @@ namespace DetourNavigator
std::vector<std::byte> input = serialize(mSettings.mRecast, mAgentBounds, *recastMesh, objects);
const std::optional<NavMeshTileInfo> info = consumer->find(mWorldspace, mTilePosition, input);
if (info.has_value() && info->mVersion == navMeshVersion)
if (info.has_value() && info->mVersion == navMeshFormatVersion)
{
consumer->identity(mWorldspace, mTilePosition, info->mTileId);
ignore.mConsumer = nullptr;
@ -86,9 +86,9 @@ namespace DetourNavigator
return;
if (info.has_value())
consumer->update(mWorldspace, mTilePosition, info->mTileId, navMeshVersion, *data);
consumer->update(mWorldspace, mTilePosition, info->mTileId, navMeshFormatVersion, *data);
else
consumer->insert(mWorldspace, mTilePosition, navMeshVersion, input, *data);
consumer->insert(mWorldspace, mTilePosition, navMeshFormatVersion, input, *data);
ignore.mConsumer = nullptr;
}

View File

@ -53,7 +53,7 @@ namespace DetourNavigator
std::uint64_t mMaxDbFileSize = 0;
};
inline constexpr std::int64_t navMeshVersion = 2;
inline constexpr std::int64_t navMeshFormatVersion = 2;
RecastSettings makeRecastSettingsFromSettingsManager();

View File

@ -128,11 +128,11 @@ void ConfigurationManager::readConfiguration(bpo::variables_map& variables,
auto composingVariables = separateComposingVariables(variables, description);
for (auto& [k, v] : *it)
{
auto it = variables.find(k);
if (it == variables.end())
auto variable = variables.find(k);
if (variable == variables.end())
variables.insert({k, v});
else if (it->second.defaulted())
it->second = v;
else if (variable->second.defaulted())
variable->second = v;
}
mergeComposingVariables(variables, composingVariables, description);
}

View File

@ -71,7 +71,8 @@ KeyframeController::KeyframeController()
}
KeyframeController::KeyframeController(const KeyframeController &copy, const osg::CopyOp &copyop)
: SceneUtil::KeyframeController(copy, copyop)
: osg::Object(copy, copyop)
, SceneUtil::KeyframeController(copy)
, SceneUtil::NodeCallback<KeyframeController, NifOsg::MatrixTransform*>(copy, copyop)
, mRotations(copy.mRotations)
, mXRotations(copy.mXRotations)

View File

@ -17,9 +17,8 @@ namespace SceneUtil
public:
KeyframeController() {}
KeyframeController(const KeyframeController& copy, const osg::CopyOp& copyop)
: osg::Object(copy, copyop)
, SceneUtil::Controller(copy) {}
KeyframeController(const KeyframeController& copy)
: SceneUtil::Controller(copy) {}
virtual osg::Vec3f getTranslation(float time) const { return osg::Vec3f(); }

View File

@ -68,8 +68,11 @@ namespace SceneUtil
traverse( node );
}
OsgAnimationController::OsgAnimationController(const OsgAnimationController &copy, const osg::CopyOp &copyop) : SceneUtil::KeyframeController(copy, copyop), SceneUtil::NodeCallback<OsgAnimationController>(copy, copyop)
, mEmulatedAnimations(copy.mEmulatedAnimations)
OsgAnimationController::OsgAnimationController(const OsgAnimationController &copy, const osg::CopyOp &copyop)
: osg::Object(copy, copyop)
, SceneUtil::KeyframeController(copy)
, SceneUtil::NodeCallback<OsgAnimationController>(copy, copyop)
, mEmulatedAnimations(copy.mEmulatedAnimations)
{
mLinker = nullptr;
for (const auto& mergedAnimationTrack : copy.mMergedAnimationTracks)