1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-22 00:03:13 +00:00

Address remaining conversion warnings in components

This commit is contained in:
Evil Eye 2025-09-20 11:39:31 +02:00
parent a8831651bb
commit cb82d37992
9 changed files with 66 additions and 68 deletions

View file

@ -195,7 +195,7 @@ namespace DetourNavigator
TileId NavMeshDb::getMaxTileId()
{
TileId tileId{ 0 };
request(*mDb, mGetMaxTileId, &tileId, 1);
request(*mDb, mGetMaxTileId, &tileId.mValue, 1);
return tileId;
}
@ -203,7 +203,7 @@ namespace DetourNavigator
ESM::RefId worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
{
Tile result;
auto row = std::tie(result.mTileId, result.mVersion);
auto row = std::tie(result.mTileId.mValue, result.mVersion.mValue);
const std::vector<std::byte> compressedInput = Misc::compress(input);
if (&row == request(*mDb, mFindTile, &row, 1, worldspace.serializeText(), tilePosition, compressedInput))
return {};
@ -214,7 +214,7 @@ namespace DetourNavigator
ESM::RefId worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
{
TileData result;
auto row = std::tie(result.mTileId, result.mVersion, result.mData);
auto row = std::tie(result.mTileId.mValue, result.mVersion.mValue, result.mData);
const std::vector<std::byte> compressedInput = Misc::compress(input);
if (&row == request(*mDb, mGetTileData, &row, 1, worldspace.serializeText(), tilePosition, compressedInput))
return {};
@ -255,14 +255,14 @@ namespace DetourNavigator
ShapeId NavMeshDb::getMaxShapeId()
{
ShapeId shapeId{ 0 };
request(*mDb, mGetMaxShapeId, &shapeId, 1);
request(*mDb, mGetMaxShapeId, &shapeId.mValue, 1);
return shapeId;
}
std::optional<ShapeId> NavMeshDb::findShapeId(std::string_view name, ShapeType type, const Sqlite3::ConstBlob& hash)
{
ShapeId shapeId;
if (&shapeId == request(*mDb, mFindShapeId, &shapeId, 1, name, type, hash))
if (&shapeId.mValue == request(*mDb, mFindShapeId, &shapeId.mValue, 1, name, type, hash))
return {};
return shapeId;
}

View file

@ -130,11 +130,11 @@ namespace ESMTerrain
osg::ref_ptr<const LandObject> land = getLand(ESM::ExteriorCellLocation(cellX, cellY, worldspace));
const ESM::LandData* data = land ? land->getData(ESM::Land::DATA_VHGT) : nullptr;
const int landSize = ESM::getLandSize(worldspace);
int startRow = (origin.x() - cellX) * landSize;
int startColumn = (origin.y() - cellY) * landSize;
int startRow = static_cast<int>((origin.x() - cellX) * landSize);
int startColumn = static_cast<int>((origin.y() - cellY) * landSize);
int endRow = startRow + size * (landSize - 1) + 1;
int endColumn = startColumn + size * (landSize - 1) + 1;
int endRow = static_cast<int>(startRow + size * (landSize - 1) + 1);
int endColumn = static_cast<int>(startColumn + size * (landSize - 1) + 1);
if (data)
{
@ -283,8 +283,8 @@ namespace ESMTerrain
const auto handleSample = [&](std::size_t cellShiftX, std::size_t cellShiftY, std::size_t row, std::size_t col,
std::size_t vertX, std::size_t vertY) {
const int cellX = startCellX + cellShiftX;
const int cellY = startCellY + cellShiftY;
const int cellX = startCellX + static_cast<int>(cellShiftX);
const int cellY = startCellY + static_cast<int>(cellShiftY);
const std::pair cell{ cellX, cellY };
const ESM::ExteriorCellLocation cellLocation(cellX, cellY, worldspace);
@ -311,7 +311,7 @@ namespace ESMTerrain
if (heightData != nullptr)
height = heightData->getHeights()[col * cellSize + row];
if (alteration)
height += getAlteredHeight(col, row);
height += getAlteredHeight(static_cast<int>(col), static_cast<int>(row));
const std::size_t vertIndex = vertX * numVerts + vertY;
@ -325,7 +325,7 @@ namespace ESMTerrain
if (normalData != nullptr)
{
for (std::size_t i = 0; i < 3; ++i)
for (unsigned short i = 0; i < 3; ++i)
normal[i] = normalData->getNormals()[srcArrayIndex + i];
normal.normalize();
@ -333,11 +333,11 @@ namespace ESMTerrain
// Normals apparently don't connect seamlessly between cells
if (col == cellSize - 1 || row == cellSize - 1)
fixNormal(normal, cellLocation, col, row, cache);
fixNormal(normal, cellLocation, static_cast<int>(col), static_cast<int>(row), cache);
// some corner normals appear to be complete garbage (z < 0)
if ((row == 0 || row == cellSize - 1) && (col == 0 || col == cellSize - 1))
averageNormal(normal, cellLocation, col, row, cache);
averageNormal(normal, cellLocation, static_cast<int>(col), static_cast<int>(row), cache);
assert(normal.z() > 0);
@ -346,16 +346,16 @@ namespace ESMTerrain
osg::Vec4ub color(255, 255, 255, 255);
if (colourData != nullptr)
for (std::size_t i = 0; i < 3; ++i)
for (unsigned short i = 0; i < 3; ++i)
color[i] = colourData->getColors()[srcArrayIndex + i];
// Does nothing by default, override in OpenMW-CS
if (alteration)
adjustColor(col, row, heightData, color);
adjustColor(static_cast<int>(col), static_cast<int>(row), heightData, color);
// Unlike normals, colors mostly connect seamlessly between cells, but not always...
if (col == cellSize - 1 || row == cellSize - 1)
fixColour(color, cellLocation, col, row, cache);
fixColour(color, cellLocation, static_cast<int>(col), static_cast<int>(row), cache);
colours[vertIndex] = color;
};
@ -445,7 +445,7 @@ namespace ESMTerrain
unsigned char* const baseBlendmap = getOrCreateBlendmap(ESM::FormId::fromUint32(ltex.base.formId));
int starty = (static_cast<int>(sample.mDstCol) - 1) * quadSize;
int startx = sample.mDstRow * quadSize;
int startx = static_cast<int>(sample.mDstRow) * quadSize;
for (int y = std::max(0, starty + 1); y <= starty + quadSize && y < blendmapSize; ++y)
{
unsigned char* const row = baseBlendmap + (blendmapSize - y - 1) * blendmapSize;
@ -465,9 +465,9 @@ namespace ESMTerrain
{
continue;
}
int index = (blendmapSize - starty - y - 1) * blendmapSize + startx + x;
int delta = std::clamp(static_cast<int>(v.opacity * 255), 0, 255);
baseBlendmap[index] = std::max(0, baseBlendmap[index] - delta);
size_t index = static_cast<size_t>((blendmapSize - starty - y - 1) * blendmapSize + startx + x);
auto delta = static_cast<unsigned char>(std::clamp(static_cast<int>(v.opacity * 255.f), 0, 255));
baseBlendmap[index] = std::max<unsigned char>(0, baseBlendmap[index] - delta);
layerBlendmap[index] = delta;
}
}
@ -567,7 +567,7 @@ namespace ESMTerrain
float Storage::getHeightAt(const osg::Vec3f& worldPos, ESM::RefId worldspace)
{
const float cellSize = ESM::getCellSize(worldspace);
const float cellSize = static_cast<float>(ESM::getCellSize(worldspace));
int cellX = static_cast<int>(std::floor(worldPos.x() / cellSize));
int cellY = static_cast<int>(std::floor(worldPos.y() / cellSize));
@ -645,7 +645,8 @@ namespace ESMTerrain
*/
// Solve plane equation for z
return (-plane.getNormal().x() * nX - plane.getNormal().y() * nY - plane[3]) / plane.getNormal().z() * cellSize;
return static_cast<float>(
(-plane.getNormal().x() * nX - plane.getNormal().y() * nY - plane[3]) / plane.getNormal().z() * cellSize);
}
const LandObject* Storage::getLand(ESM::ExteriorCellLocation cellLocation, LandCache& cache)

View file

@ -97,8 +97,8 @@ namespace Fx
if constexpr (std::is_fundamental_v<UType>)
{
mUniform->template setValue<UType>(mValue);
range = mUniform->template getMax<UType>() - mUniform->template getMin<UType>();
min = mUniform->template getMin<UType>();
range = static_cast<float>(mUniform->template getMax<UType>() - mUniform->template getMin<UType>());
min = static_cast<float>(mUniform->template getMin<UType>());
}
else
{
@ -155,9 +155,9 @@ namespace Fx
void notifyMouseWheel(MyGUI::Widget* /*sender*/, int rel)
{
if (rel > 0)
increment(mUniform->mStep);
increment(static_cast<T>(mUniform->mStep));
else
increment(-mUniform->mStep);
increment(static_cast<T>(-mUniform->mStep));
}
void notifyMouseButtonDragged(MyGUI::Widget* /*sender*/, int left, int top, MyGUI::MouseButton id)
@ -169,15 +169,15 @@ namespace Fx
// allow finer tuning when shift is pressed
constexpr double scaling = 20.0;
T step
= MyGUI::InputManager::getInstance().isShiftPressed() ? mUniform->mStep / scaling : mUniform->mStep;
T step = static_cast<T>(
MyGUI::InputManager::getInstance().isShiftPressed() ? mUniform->mStep / scaling : mUniform->mStep);
if (step == 0)
{
if constexpr (std::is_integral_v<T>)
step = 1;
else
step = mUniform->mStep;
step = static_cast<T>(mUniform->mStep);
}
if (delta > 0)
@ -209,9 +209,9 @@ namespace Fx
void notifyButtonClicked(MyGUI::Widget* sender)
{
if (sender == mButtonDecrease)
increment(-mUniform->mStep);
increment(static_cast<T>(-mUniform->mStep));
else if (sender == mButtonIncrease)
increment(mUniform->mStep);
increment(static_cast<T>(mUniform->mStep));
}
MyGUI::Button* mButtonDecrease{ nullptr };

View file

@ -68,7 +68,7 @@ namespace LuaUtil
else
{
appendType(out, SerializedType::LONG_STRING);
appendValue<uint32_t>(out, str.size());
appendValue<uint32_t>(out, static_cast<uint32_t>(str.size()));
}
out.append(str.data(), str.size());
}
@ -83,14 +83,14 @@ namespace LuaUtil
assert(!typeName.empty() && typeName.size() <= 64);
if (typeName.size() <= 8 && dataSize < 16)
{ // Compact form: 0b1SSSSTTT. SSSS = dataSize, TTT = (typeName size - 1).
unsigned char t = CUSTOM_COMPACT_FLAG | (dataSize << 3) | (typeName.size() - 1);
auto t = static_cast<unsigned char>(CUSTOM_COMPACT_FLAG | (dataSize << 3) | (typeName.size() - 1));
out.push_back(t);
}
else
{ // Full form: 0b01TTTTTT + 32bit dataSize.
unsigned char t = CUSTOM_FULL_FLAG | (typeName.size() - 1);
auto t = static_cast<unsigned char>(CUSTOM_FULL_FLAG | (typeName.size() - 1));
out.push_back(t);
appendValue<uint32_t>(out, dataSize);
appendValue<uint32_t>(out, static_cast<uint32_t>(dataSize));
}
out.append(typeName.data(), typeName.size());
appendData(out, data, dataSize);
@ -156,8 +156,8 @@ namespace LuaUtil
{
appendType(out, SerializedType::TRANSFORM_M);
osg::Matrixf matrix = data.as<TransformM>().mM;
for (size_t i = 0; i < 4; i++)
for (size_t j = 0; j < 4; j++)
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
appendValue<double>(out, matrix(i, j));
return;
}
@ -165,7 +165,7 @@ namespace LuaUtil
{
appendType(out, SerializedType::TRANSFORM_Q);
osg::Quat quat = data.as<TransformQ>().mQ;
for (size_t i = 0; i < 4; i++)
for (int i = 0; i < 4; i++)
appendValue<double>(out, quat[i]);
return;
}
@ -304,16 +304,16 @@ namespace LuaUtil
throw std::runtime_error("Unexpected end of table during deserialization.");
case SerializedType::VEC2:
{
float x = getValue<double>(binaryData);
float y = getValue<double>(binaryData);
float x = static_cast<float>(getValue<double>(binaryData));
float y = static_cast<float>(getValue<double>(binaryData));
sol::stack::push<osg::Vec2f>(lua, osg::Vec2f(x, y));
return;
}
case SerializedType::VEC3:
{
float x = getValue<double>(binaryData);
float y = getValue<double>(binaryData);
float z = getValue<double>(binaryData);
float x = static_cast<float>(getValue<double>(binaryData));
float y = static_cast<float>(getValue<double>(binaryData));
float z = static_cast<float>(getValue<double>(binaryData));
sol::stack::push<osg::Vec3f>(lua, osg::Vec3f(x, y, z));
return;
}
@ -322,7 +322,7 @@ namespace LuaUtil
osg::Matrixf mat;
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
mat(i, j) = getValue<double>(binaryData);
mat(i, j) = static_cast<float>(getValue<double>(binaryData));
sol::stack::push<TransformM>(lua, asTransform(mat));
return;
}
@ -336,10 +336,10 @@ namespace LuaUtil
}
case SerializedType::VEC4:
{
float x = getValue<double>(binaryData);
float y = getValue<double>(binaryData);
float z = getValue<double>(binaryData);
float w = getValue<double>(binaryData);
float x = static_cast<float>(getValue<double>(binaryData));
float y = static_cast<float>(getValue<double>(binaryData));
float z = static_cast<float>(getValue<double>(binaryData));
float w = static_cast<float>(getValue<double>(binaryData));
sol::stack::push<osg::Vec4f>(lua, osg::Vec4f(x, y, z, w));
return;
}

View file

@ -28,10 +28,10 @@ namespace Misc
throw std::logic_error(std::string("Invalid hex color: ") += hex);
Color col;
col.mValue.a() = 1;
for (size_t i = 0; i < 3; i++)
for (unsigned i = 0; i < 3; i++)
{
auto sub = hex.substr(i * 2, 2);
int v = 0;
unsigned char v = 0;
auto [_, ec] = std::from_chars(sub.data(), sub.data() + sub.size(), v, 16);
if (ec != std::errc())
throw std::logic_error(std::string("Invalid hex color: ") += hex);
@ -53,7 +53,7 @@ namespace Misc
std::string Color::toHex() const
{
std::string result(6, '0');
for (size_t i = 0; i < 3; i++)
for (unsigned i = 0; i < 3; i++)
{
int b = static_cast<int>(mValue[i] * 255.0f);
char* start = result.data() + i * 2;

View file

@ -1554,8 +1554,7 @@ namespace NifOsg
const auto& uvlist = niGeometryData->mUVList;
int textureStage = 0;
for (std::vector<unsigned int>::const_iterator it = boundTextures.begin(); it != boundTextures.end();
++it, ++textureStage)
for (auto it = boundTextures.begin(); it != boundTextures.end(); ++it, ++textureStage)
{
unsigned int uvSet = *it;
if (uvSet >= uvlist.size())

View file

@ -169,10 +169,8 @@ namespace Resource
{
if (NifOsg::FlipController* flipctrl = dynamic_cast<NifOsg::FlipController*>(&ctrl))
{
for (std::vector<osg::ref_ptr<osg::Texture2D>>::iterator it = flipctrl->getTextures().begin();
it != flipctrl->getTextures().end(); ++it)
for (const osg::ref_ptr<osg::Texture2D>& tex : flipctrl->getTextures())
{
osg::Texture* tex = *it;
tex->setFilter(osg::Texture::MIN_FILTER, mMinFilter);
tex->setFilter(osg::Texture::MAG_FILTER, mMagFilter);
tex->setMaxAnisotropy(mMaxAnisotropy);

View file

@ -283,8 +283,8 @@ namespace Terrain
Storage* storage, unsigned int nodeMask, unsigned int preCompileMask, unsigned int borderMask,
int compMapResolution, float compMapLevel, float lodFactor, int vertexLodMod, float maxCompGeometrySize,
bool debugChunks, ESM::RefId worldspace, double expiryDelay)
: TerrainGrid(parent, compileRoot, resourceSystem, storage, nodeMask, worldspace, expiryDelay, preCompileMask,
borderMask)
: TerrainGrid(
parent, compileRoot, resourceSystem, storage, nodeMask, worldspace, expiryDelay, preCompileMask, borderMask)
, mViewDataMap(new ViewDataMap)
, mQuadTreeBuilt(false)
, mLodFactor(lodFactor)

View file

@ -176,14 +176,14 @@ namespace Gui
void HBox::align()
{
unsigned int count = getChildCount();
size_t hStretchedCount = 0;
const size_t count = getChildCount();
int hStretchedCount = 0;
int totalWidth = 0;
int totalHeight = 0;
std::vector<std::pair<MyGUI::IntSize, bool>> sizes;
sizes.resize(count);
for (unsigned int i = 0; i < count; ++i)
for (size_t i = 0; i < count; ++i)
{
MyGUI::Widget* w = getChildAt(i);
bool hstretch = w->getUserString("HStretch") == "true";
@ -221,7 +221,7 @@ namespace Gui
}
int curX = 0;
for (unsigned int i = 0; i < count; ++i)
for (size_t i = 0; i < count; ++i)
{
if (i == 0)
curX += mPadding;
@ -328,13 +328,13 @@ namespace Gui
void VBox::align()
{
unsigned int count = getChildCount();
size_t vStretchedCount = 0;
const size_t count = getChildCount();
int vStretchedCount = 0;
int totalHeight = 0;
int totalWidth = 0;
std::vector<std::pair<MyGUI::IntSize, bool>> sizes;
sizes.resize(count);
for (unsigned int i = 0; i < count; ++i)
for (size_t i = 0; i < count; ++i)
{
MyGUI::Widget* w = getChildAt(i);
@ -375,7 +375,7 @@ namespace Gui
}
int curY = 0;
for (unsigned int i = 0; i < count; ++i)
for (size_t i = 0; i < count; ++i)
{
if (i == 0)
curY += mPadding;