2014-05-25 14:13:07 +02:00
|
|
|
#include "cellref.hpp"
|
|
|
|
|
2022-01-22 22:44:02 +01:00
|
|
|
#include <cassert>
|
2021-01-22 15:48:37 +01:00
|
|
|
|
|
|
|
#include <components/debug/debuglog.hpp>
|
2023-04-10 14:30:25 +02:00
|
|
|
#include <components/esm/refid.hpp>
|
2023-02-22 15:57:59 +01:00
|
|
|
#include <components/esm3/loadcell.hpp>
|
2022-01-22 15:58:41 +01:00
|
|
|
#include <components/esm3/objectstate.hpp>
|
2023-04-10 14:30:25 +02:00
|
|
|
#include <components/esm4/loadrefr.hpp>
|
2014-05-25 14:13:07 +02:00
|
|
|
|
2023-04-10 14:30:25 +02:00
|
|
|
#include <apps/openmw/mwbase/environment.hpp>
|
|
|
|
#include <apps/openmw/mwbase/world.hpp>
|
2023-06-17 22:25:47 +02:00
|
|
|
#include <apps/openmw/mwmechanics/spellutil.hpp>
|
2023-04-10 14:30:25 +02:00
|
|
|
#include <apps/openmw/mwworld/esmstore.hpp>
|
2023-02-19 17:42:37 +01:00
|
|
|
|
2014-05-25 14:13:07 +02:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
2023-01-27 19:40:45 +01:00
|
|
|
CellRef::CellRef(const ESM::CellRef& ref)
|
|
|
|
: mCellRef(ESM::ReferenceVariant(ref))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CellRef::CellRef(const ESM4::Reference& ref)
|
|
|
|
: mCellRef(ESM::ReferenceVariant(ref))
|
|
|
|
{
|
2023-01-28 18:57:55 +01:00
|
|
|
}
|
2023-01-27 19:40:45 +01:00
|
|
|
|
2023-01-28 18:57:55 +01:00
|
|
|
const ESM::RefNum& CellRef::getRefNum() const
|
|
|
|
{
|
2023-02-04 18:45:53 +01:00
|
|
|
return std::visit(ESM::VisitOverload{
|
2023-04-20 00:25:42 +02:00
|
|
|
[&](const ESM4::Reference& ref) -> const ESM::RefNum& { return ref.mId; },
|
2023-01-29 19:18:50 +01:00
|
|
|
[&](const ESM::CellRef& ref) -> const ESM::RefNum& { return ref.mRefNum; },
|
|
|
|
},
|
2023-01-28 18:57:55 +01:00
|
|
|
mCellRef.mVariant);
|
2023-01-27 19:40:45 +01:00
|
|
|
}
|
2014-05-25 14:13:07 +02:00
|
|
|
|
2021-01-22 15:48:37 +01:00
|
|
|
const ESM::RefNum& CellRef::getOrAssignRefNum(ESM::RefNum& lastAssignedRefNum)
|
|
|
|
{
|
2023-04-07 02:14:32 +02:00
|
|
|
ESM::RefNum& refNum = std::visit(ESM::VisitOverload{
|
2023-04-20 00:25:42 +02:00
|
|
|
[&](ESM4::Reference& ref) -> ESM::RefNum& { return ref.mId; },
|
2023-04-07 02:14:32 +02:00
|
|
|
[&](ESM::CellRef& ref) -> ESM::RefNum& { return ref.mRefNum; },
|
|
|
|
},
|
|
|
|
mCellRef.mVariant);
|
|
|
|
if (!refNum.isSet())
|
|
|
|
{
|
|
|
|
// Generated RefNums have negative mContentFile
|
|
|
|
assert(lastAssignedRefNum.mContentFile < 0);
|
|
|
|
lastAssignedRefNum.mIndex++;
|
|
|
|
if (lastAssignedRefNum.mIndex == 0) // mIndex overflow, so mContentFile should be changed
|
2023-02-04 17:16:42 +01:00
|
|
|
{
|
2023-04-07 02:14:32 +02:00
|
|
|
if (lastAssignedRefNum.mContentFile > std::numeric_limits<int32_t>::min())
|
|
|
|
lastAssignedRefNum.mContentFile--;
|
|
|
|
else
|
|
|
|
Log(Debug::Error) << "RefNum counter overflow in CellRef::getOrAssignRefNum";
|
2023-02-04 17:16:42 +01:00
|
|
|
}
|
2023-04-07 02:14:32 +02:00
|
|
|
refNum = lastAssignedRefNum;
|
|
|
|
mChanged = true;
|
|
|
|
}
|
|
|
|
return refNum;
|
2021-01-22 15:48:37 +01:00
|
|
|
}
|
|
|
|
|
2023-04-23 20:37:28 +02:00
|
|
|
void CellRef::setRefNum(ESM::RefNum refNum)
|
2014-07-29 15:55:58 +02:00
|
|
|
{
|
2023-02-04 18:45:53 +01:00
|
|
|
std::visit(ESM::VisitOverload{
|
2023-04-23 20:37:28 +02:00
|
|
|
[&](ESM4::Reference& ref) { ref.mId = refNum; },
|
|
|
|
[&](ESM::CellRef& ref) { ref.mRefNum = refNum; },
|
2023-01-29 19:18:50 +01:00
|
|
|
},
|
2023-01-28 18:57:55 +01:00
|
|
|
mCellRef.mVariant);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const std::string emptyString = "";
|
|
|
|
|
2023-02-19 17:42:37 +01:00
|
|
|
ESM::Position CellRef::getDoorDest() const
|
2023-01-28 18:57:55 +01:00
|
|
|
{
|
2023-02-19 17:42:37 +01:00
|
|
|
|
2023-02-19 19:19:11 +01:00
|
|
|
return std::visit(ESM::VisitOverload{
|
|
|
|
[&](const ESM4::Reference& ref) { return ref.mDoor.destPos; },
|
|
|
|
[&](const ESM::CellRef& ref) -> ESM::Position { return ref.mDoorDest; },
|
|
|
|
},
|
2023-02-19 17:42:37 +01:00
|
|
|
mCellRef.mVariant);
|
|
|
|
}
|
|
|
|
|
|
|
|
ESM::RefId CellRef::getDestCell() const
|
|
|
|
{
|
|
|
|
auto esm3Visit = [&](const ESM::CellRef& ref) -> ESM::RefId {
|
|
|
|
if (!ref.mDestCell.empty())
|
|
|
|
{
|
|
|
|
return ESM::RefId::stringRefId(ref.mDestCell);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-05-27 01:18:17 +02:00
|
|
|
const auto cellPos = ESM::positionToExteriorCellLocation(ref.mDoorDest.pos[0], ref.mDoorDest.pos[1]);
|
2023-05-12 12:04:04 +02:00
|
|
|
return ESM::RefId::esm3ExteriorCell(cellPos.mX, cellPos.mY);
|
2023-02-19 17:42:37 +01:00
|
|
|
}
|
|
|
|
};
|
2023-04-10 14:30:25 +02:00
|
|
|
auto esm4Visit = [&](const ESM4::Reference& ref) -> ESM::RefId {
|
|
|
|
if (ref.mDoor.destDoor.isZeroOrUnset())
|
2023-02-20 23:18:05 +01:00
|
|
|
return ESM::RefId();
|
2023-04-10 14:30:25 +02:00
|
|
|
const ESM4::Reference* refDest
|
2023-04-20 21:07:53 +02:00
|
|
|
= MWBase::Environment::get().getESMStore()->get<ESM4::Reference>().searchStatic(ref.mDoor.destDoor);
|
2023-04-10 14:30:25 +02:00
|
|
|
if (refDest)
|
|
|
|
return refDest->mParent;
|
2023-02-20 23:18:05 +01:00
|
|
|
return ESM::RefId();
|
2023-04-10 14:30:25 +02:00
|
|
|
};
|
2023-02-19 17:42:37 +01:00
|
|
|
|
2023-04-10 14:30:25 +02:00
|
|
|
return std::visit(ESM::VisitOverload{ esm3Visit, esm4Visit }, mCellRef.mVariant);
|
2014-07-29 15:55:58 +02:00
|
|
|
}
|
|
|
|
|
2014-05-25 14:13:07 +02:00
|
|
|
void CellRef::setScale(float scale)
|
|
|
|
{
|
2023-01-28 18:57:55 +01:00
|
|
|
if (scale != getScale())
|
2014-05-25 14:13:07 +02:00
|
|
|
{
|
|
|
|
mChanged = true;
|
2023-01-28 18:57:55 +01:00
|
|
|
std::visit([scale](auto&& ref) { ref.mScale = scale; }, mCellRef.mVariant);
|
2014-05-25 14:13:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CellRef::setPosition(const ESM::Position& position)
|
|
|
|
{
|
|
|
|
mChanged = true;
|
2023-01-28 18:57:55 +01:00
|
|
|
std::visit([&position](auto&& ref) { ref.mPos = position; }, mCellRef.mVariant);
|
|
|
|
}
|
|
|
|
|
|
|
|
float CellRef::getEnchantmentCharge() const
|
|
|
|
{
|
2023-02-04 18:45:53 +01:00
|
|
|
return std::visit(ESM::VisitOverload{
|
2023-01-29 19:18:50 +01:00
|
|
|
[&](const ESM4::Reference& /*ref*/) { return 0.f; },
|
|
|
|
[&](const ESM::CellRef& ref) { return ref.mEnchantmentCharge; },
|
|
|
|
},
|
2023-01-28 18:57:55 +01:00
|
|
|
mCellRef.mVariant);
|
2014-05-25 14:13:07 +02:00
|
|
|
}
|
|
|
|
|
2023-06-17 22:25:47 +02:00
|
|
|
float CellRef::getNormalizedEnchantmentCharge(const ESM::Enchantment& enchantment) const
|
2018-10-25 16:09:07 +03:00
|
|
|
{
|
2023-06-17 22:25:47 +02:00
|
|
|
const int maxCharge = MWMechanics::getEnchantmentCharge(enchantment);
|
2018-10-25 16:09:07 +03:00
|
|
|
if (maxCharge == 0)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2023-01-28 18:57:55 +01:00
|
|
|
else if (getEnchantmentCharge() == -1)
|
2018-10-25 16:09:07 +03:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-01-28 18:57:55 +01:00
|
|
|
return getEnchantmentCharge() / static_cast<float>(maxCharge);
|
2018-10-25 16:09:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-25 14:13:07 +02:00
|
|
|
void CellRef::setEnchantmentCharge(float charge)
|
|
|
|
{
|
2023-01-28 18:57:55 +01:00
|
|
|
if (charge != getEnchantmentCharge())
|
2014-05-25 14:13:07 +02:00
|
|
|
{
|
|
|
|
mChanged = true;
|
2023-01-28 18:57:55 +01:00
|
|
|
|
2023-02-04 18:45:53 +01:00
|
|
|
std::visit(ESM::VisitOverload{
|
2023-01-29 19:18:50 +01:00
|
|
|
[&](ESM4::Reference& /*ref*/) {},
|
|
|
|
[&](ESM::CellRef& ref) { ref.mEnchantmentCharge = charge; },
|
|
|
|
},
|
2023-01-28 18:57:55 +01:00
|
|
|
mCellRef.mVariant);
|
2014-05-25 14:13:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CellRef::setCharge(int charge)
|
|
|
|
{
|
2023-02-04 18:45:53 +01:00
|
|
|
std::visit(ESM::VisitOverload{
|
2023-01-29 19:18:50 +01:00
|
|
|
[&](ESM4::Reference& /*ref*/) {},
|
|
|
|
[&](ESM::CellRef& ref) { ref.mChargeInt = charge; },
|
|
|
|
},
|
2023-01-28 18:57:55 +01:00
|
|
|
mCellRef.mVariant);
|
2015-01-23 15:33:39 +01:00
|
|
|
}
|
|
|
|
|
2016-12-09 19:48:56 -07:00
|
|
|
void CellRef::applyChargeRemainderToBeSubtracted(float chargeRemainder)
|
|
|
|
{
|
2023-02-04 17:16:42 +01:00
|
|
|
auto esm3Visit = [&](ESM::CellRef& cellRef3) {
|
|
|
|
cellRef3.mChargeIntRemainder += std::abs(chargeRemainder);
|
|
|
|
if (cellRef3.mChargeIntRemainder > 1.0f)
|
|
|
|
{
|
|
|
|
float newChargeRemainder = (cellRef3.mChargeIntRemainder - std::floor(cellRef3.mChargeIntRemainder));
|
|
|
|
if (cellRef3.mChargeInt <= static_cast<int>(cellRef3.mChargeIntRemainder))
|
|
|
|
{
|
|
|
|
cellRef3.mChargeInt = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cellRef3.mChargeInt -= static_cast<int>(cellRef3.mChargeIntRemainder);
|
|
|
|
}
|
|
|
|
cellRef3.mChargeIntRemainder = newChargeRemainder;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
std::visit(
|
2023-02-04 18:45:53 +01:00
|
|
|
ESM::VisitOverload{
|
2023-02-04 17:16:42 +01:00
|
|
|
[&](ESM4::Reference& /*ref*/) {},
|
|
|
|
esm3Visit,
|
|
|
|
},
|
2023-01-28 18:57:55 +01:00
|
|
|
mCellRef.mVariant);
|
2016-12-09 19:48:56 -07:00
|
|
|
}
|
|
|
|
|
2015-01-23 15:33:39 +01:00
|
|
|
void CellRef::setChargeFloat(float charge)
|
|
|
|
{
|
2023-02-04 18:45:53 +01:00
|
|
|
std::visit(ESM::VisitOverload{
|
2023-01-29 19:18:50 +01:00
|
|
|
[&](ESM4::Reference& /*ref*/) {},
|
|
|
|
[&](ESM::CellRef& ref) { ref.mChargeFloat = charge; },
|
|
|
|
},
|
2023-01-28 18:57:55 +01:00
|
|
|
mCellRef.mVariant);
|
|
|
|
}
|
2023-01-27 19:40:45 +01:00
|
|
|
|
2023-01-28 18:57:55 +01:00
|
|
|
const std::string& CellRef::getGlobalVariable() const
|
|
|
|
{
|
2023-02-04 18:45:53 +01:00
|
|
|
return std::visit(ESM::VisitOverload{
|
2023-01-29 19:18:50 +01:00
|
|
|
[&](const ESM4::Reference& /*ref*/) -> const std::string& { return emptyString; },
|
|
|
|
[&](const ESM::CellRef& ref) -> const std::string& { return ref.mGlobalVariable; },
|
|
|
|
},
|
2023-01-28 18:57:55 +01:00
|
|
|
mCellRef.mVariant);
|
2014-05-25 14:13:07 +02:00
|
|
|
}
|
|
|
|
|
2015-02-04 21:18:43 +01:00
|
|
|
void CellRef::resetGlobalVariable()
|
|
|
|
{
|
2023-01-28 18:57:55 +01:00
|
|
|
if (!getGlobalVariable().empty())
|
2015-02-04 21:18:43 +01:00
|
|
|
{
|
|
|
|
mChanged = true;
|
2023-02-04 18:45:53 +01:00
|
|
|
std::visit(ESM::VisitOverload{
|
2023-01-29 19:18:50 +01:00
|
|
|
[&](ESM4::Reference& /*ref*/) {},
|
|
|
|
[&](ESM::CellRef& ref) { ref.mGlobalVariable.erase(); },
|
|
|
|
},
|
2023-01-28 18:57:55 +01:00
|
|
|
mCellRef.mVariant);
|
2015-02-04 21:18:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-20 22:00:45 +01:00
|
|
|
void CellRef::setFactionRank(int factionRank)
|
|
|
|
{
|
2023-01-28 18:57:55 +01:00
|
|
|
if (factionRank != getFactionRank())
|
2014-12-20 22:00:45 +01:00
|
|
|
{
|
|
|
|
mChanged = true;
|
2023-01-28 18:57:55 +01:00
|
|
|
std::visit([&](auto&& ref) { ref.mFactionRank = factionRank; }, mCellRef.mVariant);
|
2014-12-20 22:00:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
void CellRef::setOwner(const ESM::RefId& owner)
|
2014-05-25 14:13:07 +02:00
|
|
|
{
|
2023-01-28 18:57:55 +01:00
|
|
|
if (owner != getOwner())
|
2014-05-25 14:13:07 +02:00
|
|
|
{
|
2023-02-04 18:45:53 +01:00
|
|
|
std::visit(ESM::VisitOverload{
|
2023-01-29 19:18:50 +01:00
|
|
|
[&](ESM4::Reference& /*ref*/) {},
|
|
|
|
[&](ESM::CellRef& ref) { ref.mOwner = owner; },
|
|
|
|
},
|
2023-01-28 18:57:55 +01:00
|
|
|
mCellRef.mVariant);
|
2014-05-25 14:13:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
void CellRef::setSoul(const ESM::RefId& soul)
|
2014-05-25 14:13:07 +02:00
|
|
|
{
|
2023-01-28 18:57:55 +01:00
|
|
|
if (soul != getSoul())
|
2014-05-25 14:13:07 +02:00
|
|
|
{
|
|
|
|
mChanged = true;
|
2023-02-04 18:45:53 +01:00
|
|
|
std::visit(ESM::VisitOverload{
|
2023-01-29 19:18:50 +01:00
|
|
|
[&](ESM4::Reference& /*ref*/) {},
|
|
|
|
[&](ESM::CellRef& ref) { ref.mSoul = soul; },
|
|
|
|
},
|
2023-01-28 18:57:55 +01:00
|
|
|
mCellRef.mVariant);
|
2014-05-25 14:13:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
void CellRef::setFaction(const ESM::RefId& faction)
|
2014-05-25 14:13:07 +02:00
|
|
|
{
|
2023-01-28 18:57:55 +01:00
|
|
|
if (faction != getFaction())
|
2014-05-25 14:13:07 +02:00
|
|
|
{
|
|
|
|
mChanged = true;
|
2023-02-04 18:45:53 +01:00
|
|
|
std::visit(ESM::VisitOverload{
|
2023-01-29 19:18:50 +01:00
|
|
|
[&](ESM4::Reference& /*ref*/) {},
|
|
|
|
[&](ESM::CellRef& ref) { ref.mFaction = faction; },
|
|
|
|
},
|
2023-01-28 18:57:55 +01:00
|
|
|
mCellRef.mVariant);
|
2014-05-25 14:13:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CellRef::setLockLevel(int lockLevel)
|
|
|
|
{
|
2023-01-28 18:57:55 +01:00
|
|
|
if (lockLevel != getLockLevel())
|
2014-05-25 14:13:07 +02:00
|
|
|
{
|
|
|
|
mChanged = true;
|
2023-01-28 18:57:55 +01:00
|
|
|
std::visit([&](auto&& ref) { ref.mLockLevel = lockLevel; }, mCellRef.mVariant);
|
2014-05-25 14:13:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-17 20:30:37 +02:00
|
|
|
void CellRef::lock(int lockLevel)
|
|
|
|
{
|
2023-06-08 20:10:32 +02:00
|
|
|
setLockLevel(lockLevel);
|
|
|
|
setLocked(true);
|
2019-09-17 20:30:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CellRef::unlock()
|
|
|
|
{
|
2023-06-08 20:10:32 +02:00
|
|
|
setLockLevel(-getLockLevel());
|
|
|
|
setLocked(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CellRef::isLocked() const
|
|
|
|
{
|
|
|
|
return std::visit([](auto&& ref) { return ref.mIsLocked; }, mCellRef.mVariant);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CellRef::setLocked(bool locked)
|
|
|
|
{
|
|
|
|
std::visit([=](auto&& ref) { ref.mIsLocked = locked; }, mCellRef.mVariant);
|
2019-09-17 20:30:37 +02:00
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
void CellRef::setTrap(const ESM::RefId& trap)
|
2014-05-25 14:13:07 +02:00
|
|
|
{
|
2023-01-28 18:57:55 +01:00
|
|
|
if (trap != getTrap())
|
2014-05-25 14:13:07 +02:00
|
|
|
{
|
|
|
|
mChanged = true;
|
2023-02-04 18:45:53 +01:00
|
|
|
std::visit(ESM::VisitOverload{
|
2023-01-29 19:18:50 +01:00
|
|
|
[&](ESM4::Reference& /*ref*/) {},
|
|
|
|
[&](ESM::CellRef& ref) { ref.mTrap = trap; },
|
|
|
|
},
|
2023-01-28 18:57:55 +01:00
|
|
|
mCellRef.mVariant);
|
2014-05-25 14:13:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-13 07:37:32 +00:00
|
|
|
void CellRef::setKey(const ESM::RefId& key)
|
|
|
|
{
|
|
|
|
if (key != getKey())
|
|
|
|
{
|
|
|
|
mChanged = true;
|
|
|
|
std::visit(ESM::VisitOverload{
|
|
|
|
[&](ESM4::Reference& /*ref*/) {},
|
|
|
|
[&](ESM::CellRef& ref) { ref.mKey = key; },
|
|
|
|
},
|
|
|
|
mCellRef.mVariant);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-25 14:13:07 +02:00
|
|
|
void CellRef::setGoldValue(int value)
|
|
|
|
{
|
2023-01-28 18:57:55 +01:00
|
|
|
if (value != getGoldValue())
|
2014-05-25 14:13:07 +02:00
|
|
|
{
|
|
|
|
mChanged = true;
|
2023-02-04 18:45:53 +01:00
|
|
|
std::visit(ESM::VisitOverload{
|
2023-01-29 19:18:50 +01:00
|
|
|
[&](ESM4::Reference& /*ref*/) {},
|
|
|
|
[&](ESM::CellRef& ref) { ref.mGoldValue = value; },
|
|
|
|
},
|
2023-01-28 18:57:55 +01:00
|
|
|
mCellRef.mVariant);
|
2014-05-25 14:13:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CellRef::writeState(ESM::ObjectState& state) const
|
|
|
|
{
|
2023-02-04 18:45:53 +01:00
|
|
|
std::visit(ESM::VisitOverload{
|
2023-01-29 19:18:50 +01:00
|
|
|
[&](const ESM4::Reference& /*ref*/) {},
|
|
|
|
[&](const ESM::CellRef& ref) { state.mRef = ref; },
|
|
|
|
},
|
2023-01-28 19:21:13 +01:00
|
|
|
mCellRef.mVariant);
|
2014-05-25 14:13:07 +02:00
|
|
|
}
|
|
|
|
}
|