1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-21 08:39:45 +00:00

Fixed large lambdas that affected readability.

This commit is contained in:
florent.teppe 2023-02-04 17:16:42 +01:00
parent 1caed2de2a
commit f3d5f6345e

View file

@ -40,10 +40,7 @@ namespace MWWorld
const ESM::RefNum& CellRef::getOrAssignRefNum(ESM::RefNum& lastAssignedRefNum)
{
return std::visit(
RefVisit{
[&](ESM4::Reference& /*ref*/) -> const ESM::RefNum& { return emptyRefNum; },
[&](ESM::CellRef& ref) -> const ESM::RefNum& {
auto esm3Visit = [&](ESM::CellRef& ref) -> const ESM::RefNum& {
if (!ref.mRefNum.isSet())
{
// Generated RefNums have negative mContentFile
@ -60,7 +57,11 @@ namespace MWWorld
mChanged = true;
}
return ref.mRefNum;
},
};
return std::visit(
RefVisit{
[&](ESM4::Reference& /*ref*/) -> const ESM::RefNum& { return emptyRefNum; },
esm3Visit,
},
mCellRef.mVariant);
}
@ -146,14 +147,11 @@ namespace MWWorld
void CellRef::applyChargeRemainderToBeSubtracted(float chargeRemainder)
{
std::visit(RefVisit{
[&](ESM4::Reference& /*ref*/) {},
[&](ESM::CellRef& cellRef3) {
auto esm3Visit = [&](ESM::CellRef& cellRef3) {
cellRef3.mChargeIntRemainder += std::abs(chargeRemainder);
if (cellRef3.mChargeIntRemainder > 1.0f)
{
float newChargeRemainder
= (cellRef3.mChargeIntRemainder - std::floor(cellRef3.mChargeIntRemainder));
float newChargeRemainder = (cellRef3.mChargeIntRemainder - std::floor(cellRef3.mChargeIntRemainder));
if (cellRef3.mChargeInt <= static_cast<int>(cellRef3.mChargeIntRemainder))
{
cellRef3.mChargeInt = 0;
@ -164,7 +162,11 @@ namespace MWWorld
}
cellRef3.mChargeIntRemainder = newChargeRemainder;
}
},
};
std::visit(
RefVisit{
[&](ESM4::Reference& /*ref*/) {},
esm3Visit,
},
mCellRef.mVariant);
}
@ -180,7 +182,6 @@ namespace MWWorld
const std::string& CellRef::getGlobalVariable() const
{
return std::visit(RefVisit{
[&](const ESM4::Reference& /*ref*/) -> const std::string& { return emptyString; },
[&](const ESM::CellRef& ref) -> const std::string& { return ref.mGlobalVariable; },