Fix loads of warnings

These weren't detected due to https://gitlab.com/OpenMW/openmw/-/issues/7882, but now they are, so they can be fixed.
This commit is contained in:
AnyOldName3 2025-07-24 00:20:05 +01:00
parent 52b785f726
commit be54521cfa
13 changed files with 12 additions and 18 deletions

View File

@ -723,7 +723,7 @@ namespace ESM
TEST_P(Esm3SaveLoadRecordTest, landShouldNotChange)
{
LandRecordData data;
std::iota(data.mHeights.begin(), data.mHeights.end(), 1);
std::iota(data.mHeights.begin(), data.mHeights.end(), 1.0f);
std::for_each(data.mHeights.begin(), data.mHeights.end(), [](float& v) { v *= Land::sHeightScale; });
data.mMinHeight = *std::min_element(data.mHeights.begin(), data.mHeights.end());
data.mMaxHeight = *std::max_element(data.mHeights.begin(), data.mHeights.end());

View File

@ -249,7 +249,7 @@ namespace ESSImport
{
ESM::InventoryState& invState = mContext->mPlayer.mObject.mInventory;
for (size_t i = 0; i < invState.mItems.size(); ++i)
for (uint32_t i = 0; i < static_cast<uint32_t>(invState.mItems.size()); ++i)
{
// FIXME: in case of conflict (multiple items with this refID) use the already equipped one?
if (invState.mItems[i].mRef.mRefID == refr.mActorData.mSelectedEnchantItem)

View File

@ -201,8 +201,8 @@ namespace NavMeshTool
{
if (!land.has_value() || osg::Vec2i(land->mX, land->mY) != cellPosition
|| (land->mDataTypes & ESM::Land::DATA_VHGT) == 0)
return { HeightfieldPlane{ ESM::Land::DEFAULT_HEIGHT }, ESM::Land::DEFAULT_HEIGHT,
ESM::Land::DEFAULT_HEIGHT };
return { HeightfieldPlane{ static_cast<float>(ESM::Land::DEFAULT_HEIGHT) },
static_cast<float>(ESM::Land::DEFAULT_HEIGHT), static_cast<float>(ESM::Land::DEFAULT_HEIGHT) };
ESM::Land::LandData& landData = *landDatas.emplace_back(std::make_unique<ESM::Land::LandData>());
land->loadData(ESM::Land::DATA_VHGT, landData);

View File

@ -625,8 +625,6 @@ bool CSMWorld::ConstInfoSelectWrapper::conditionIsAlwaysTrue(
default:
throw std::logic_error("InfoCondition: operator can not be used to compare");
}
return false;
}
template <typename T1, typename T2>
@ -651,8 +649,6 @@ bool CSMWorld::ConstInfoSelectWrapper::conditionIsNeverTrue(
default:
throw std::logic_error("InfoCondition: operator can not be used to compare");
}
return false;
}
QVariant CSMWorld::ConstInfoSelectWrapper::getValue() const

View File

@ -753,7 +753,6 @@ void CSMWorld::RefIdCollection::cloneRecord(
bool CSMWorld::RefIdCollection::touchRecord(const ESM::RefId& id)
{
throw std::runtime_error("RefIdCollection::touchRecord is unimplemented");
return false;
}
void CSMWorld::RefIdCollection::appendRecord(std::unique_ptr<RecordBase> record, UniversalId::Type type)

View File

@ -154,7 +154,7 @@ namespace MWRender
float mLoopStopTime = 0;
float mStopTime = 0;
std::shared_ptr<float> mTime = std::make_shared<float>(0);
std::shared_ptr<float> mTime = std::make_shared<float>(0.0f);
float mSpeedMult = 1;
bool mPlaying = false;

View File

@ -58,8 +58,6 @@ namespace MWRender
default:
return false;
}
return false;
}
void Pathgrid::addCell(const MWWorld::CellStore* store)

View File

@ -34,7 +34,7 @@
namespace
{
const int sLoudnessFPS = 20; // loudness values per second of audio
const float sLoudnessFPS = 20.0f; // loudness values per second of audio
ALCenum checkALCError(ALCdevice* device, const char* func, int line)
{

View File

@ -54,8 +54,9 @@ void MWWorld::InventoryStore::storeEquipmentState(
inventory.mEquipmentSlots[static_cast<uint32_t>(index)] = i;
}
// I'm not sure if the narrowing cast below is safe, but I think it'd break the save format if I widen the destination type
if (mSelectedEnchantItem.getType() != -1 && mSelectedEnchantItem->getBase() == &ref)
inventory.mSelectedEnchantItem = index;
inventory.mSelectedEnchantItem = static_cast<uint32_t>(index);
}
void MWWorld::InventoryStore::readEquipmentState(

View File

@ -55,7 +55,7 @@ namespace LuaUtil
// Find duplicates; only the last occurrence will be used (unless `sMerge` flag is used).
// Search for duplicates is case insensitive.
std::vector<bool> skip(cfg.mScripts.size(), false);
for (size_t i = 0; i < cfg.mScripts.size(); ++i)
for (int i = 0; i < static_cast<int>(mScripts.size()); ++i)
{
const ESM::LuaScriptCfg& script = cfg.mScripts[i];
bool global = script.mFlags & ESM::LuaScriptCfg::sGlobal;

View File

@ -1683,7 +1683,7 @@ namespace NifOsg
if (hasColors)
colors.emplace_back(elem.mVertColor[0], elem.mVertColor[1], elem.mVertColor[2], elem.mVertColor[3]);
if (hasUV)
uvlist.emplace_back(halfToFloat(elem.mUV[0]), 1.0 - halfToFloat(elem.mUV[1]));
uvlist.emplace_back(halfToFloat(elem.mUV[0]), 1.0f - halfToFloat(elem.mUV[1]));
}
if (!vertices.empty())

View File

@ -346,7 +346,7 @@ namespace SceneUtil
std::map<BoneWeights, VertexList> influencesToVertices;
for (size_t i = 0; i < influences.size(); i++)
influencesToVertices[influences[i]].emplace_back(i);
influencesToVertices[influences[i]].emplace_back(static_cast<VertexList::value_type>(i));
mData->mInfluences.reserve(influencesToVertices.size());
mData->mInfluences.assign(influencesToVertices.begin(), influencesToVertices.end());

View File

@ -43,7 +43,7 @@ namespace
// blendmap, apparently.
matrix.preMultTranslate(osg::Vec3f(1.0f / blendmapScale / 4.0f, 1.0f / blendmapScale / 4.0f, 0.f));
texMat = mTexMatMap.insert(std::make_pair(blendmapScale, new osg::TexMat(matrix))).first;
texMat = mTexMatMap.insert(std::make_pair(static_cast<float>(blendmapScale), new osg::TexMat(matrix))).first;
}
return texMat->second;
}