2013-06-08 13:49:59 +00:00
|
|
|
#include "cellref.hpp"
|
|
|
|
|
2022-08-02 22:00:54 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2018-08-14 15:42:41 +00:00
|
|
|
#include <components/debug/debuglog.hpp>
|
2016-03-07 21:39:43 +00:00
|
|
|
|
2014-01-12 18:23:08 +00:00
|
|
|
#include "esmreader.hpp"
|
2013-06-08 13:49:59 +00:00
|
|
|
#include "esmwriter.hpp"
|
|
|
|
|
2022-04-08 15:08:18 +00:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
template <bool load>
|
|
|
|
void loadIdImpl(ESMReader& esm, bool wideRefNum, CellRef& cellRef)
|
|
|
|
{
|
|
|
|
// According to Hrnchamd, this does not belong to the actual ref. Instead, it is a marker indicating that
|
|
|
|
// the following refs are part of a "temp refs" section. A temp ref is not being tracked by the moved
|
|
|
|
// references system. Its only purpose is a performance optimization for "immovable" things. We don't need
|
|
|
|
// this, and it's problematic anyway, because any item can theoretically be moved by a script.
|
|
|
|
if (esm.isNextSub("NAM0"))
|
|
|
|
esm.skipHSub();
|
|
|
|
|
|
|
|
if constexpr (load)
|
|
|
|
{
|
|
|
|
cellRef.blank();
|
|
|
|
cellRef.mRefNum.load(esm, wideRefNum);
|
2022-10-18 07:26:55 +00:00
|
|
|
cellRef.mRefID = esm.getHNORefId("NAME");
|
2022-04-08 15:08:18 +00:00
|
|
|
|
|
|
|
if (cellRef.mRefID.empty())
|
|
|
|
Log(Debug::Warning) << "Warning: got CellRef with empty RefId in " << esm.getName() << " 0x"
|
|
|
|
<< std::hex << esm.getFileOffset();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RefNum{}.load(esm, wideRefNum);
|
|
|
|
esm.skipHNOString("NAME");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <bool load>
|
|
|
|
void loadDataImpl(ESMReader& esm, bool& isDeleted, CellRef& cellRef)
|
|
|
|
{
|
2022-11-24 19:00:15 +00:00
|
|
|
const auto getRefIdOrSkip = [&](ESM::RefId& refId) {
|
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 11:17:09 +00:00
|
|
|
if constexpr (load)
|
|
|
|
refId = esm.getRefId();
|
|
|
|
else
|
|
|
|
esm.skipHString();
|
|
|
|
};
|
|
|
|
|
2022-04-08 15:08:18 +00:00
|
|
|
const auto getHStringOrSkip = [&](std::string& value) {
|
|
|
|
if constexpr (load)
|
|
|
|
value = esm.getHString();
|
|
|
|
else
|
|
|
|
esm.skipHString();
|
|
|
|
};
|
|
|
|
|
|
|
|
const auto getHTOrSkip = [&](auto& value) {
|
|
|
|
if constexpr (load)
|
|
|
|
esm.getHT(value);
|
|
|
|
else
|
|
|
|
esm.skipHT<std::decay_t<decltype(value)>>();
|
|
|
|
};
|
|
|
|
|
|
|
|
if constexpr (load)
|
|
|
|
isDeleted = false;
|
|
|
|
|
|
|
|
bool isLoaded = false;
|
|
|
|
while (!isLoaded && esm.hasMoreSubs())
|
|
|
|
{
|
|
|
|
esm.getSubName();
|
|
|
|
switch (esm.retSubName().toInt())
|
|
|
|
{
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("UNAM"):
|
2022-04-08 15:08:18 +00:00
|
|
|
getHTOrSkip(cellRef.mReferenceBlocked);
|
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("XSCL"):
|
2022-04-08 15:08:18 +00:00
|
|
|
getHTOrSkip(cellRef.mScale);
|
|
|
|
if constexpr (load)
|
|
|
|
cellRef.mScale = std::clamp(cellRef.mScale, 0.5f, 2.0f);
|
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("ANAM"):
|
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 11:17:09 +00:00
|
|
|
getRefIdOrSkip(cellRef.mOwner);
|
2022-04-08 15:08:18 +00:00
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("BNAM"):
|
2022-04-08 15:08:18 +00:00
|
|
|
getHStringOrSkip(cellRef.mGlobalVariable);
|
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("XSOL"):
|
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 11:17:09 +00:00
|
|
|
getRefIdOrSkip(cellRef.mSoul);
|
2022-04-08 15:08:18 +00:00
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("CNAM"):
|
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 11:17:09 +00:00
|
|
|
getRefIdOrSkip(cellRef.mFaction);
|
2022-04-08 15:08:18 +00:00
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("INDX"):
|
2022-04-08 15:08:18 +00:00
|
|
|
getHTOrSkip(cellRef.mFactionRank);
|
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("XCHG"):
|
2022-04-08 15:08:18 +00:00
|
|
|
getHTOrSkip(cellRef.mEnchantmentCharge);
|
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("INTV"):
|
2022-04-08 15:08:18 +00:00
|
|
|
getHTOrSkip(cellRef.mChargeInt);
|
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("NAM9"):
|
2022-04-08 15:08:18 +00:00
|
|
|
getHTOrSkip(cellRef.mGoldValue);
|
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("DODT"):
|
2022-04-08 15:08:18 +00:00
|
|
|
getHTOrSkip(cellRef.mDoorDest);
|
|
|
|
if constexpr (load)
|
|
|
|
cellRef.mTeleport = true;
|
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("DNAM"):
|
2023-01-19 16:31:45 +00:00
|
|
|
getHStringOrSkip(cellRef.mDestCell);
|
2022-04-08 15:08:18 +00:00
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("FLTV"):
|
2022-04-08 15:08:18 +00:00
|
|
|
getHTOrSkip(cellRef.mLockLevel);
|
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("KNAM"):
|
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 11:17:09 +00:00
|
|
|
getRefIdOrSkip(cellRef.mKey);
|
2022-04-08 15:08:18 +00:00
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("TNAM"):
|
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 11:17:09 +00:00
|
|
|
getRefIdOrSkip(cellRef.mTrap);
|
2022-04-08 15:08:18 +00:00
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("DATA"):
|
2022-04-08 15:08:18 +00:00
|
|
|
if constexpr (load)
|
2022-04-10 11:35:00 +00:00
|
|
|
esm.getHTSized<24>(cellRef.mPos);
|
2022-04-08 15:08:18 +00:00
|
|
|
else
|
2022-04-10 11:35:54 +00:00
|
|
|
esm.skipHTSized<24, decltype(cellRef.mPos)>();
|
2022-04-08 15:08:18 +00:00
|
|
|
break;
|
2022-04-11 22:18:39 +00:00
|
|
|
case fourCC("NAM0"):
|
2022-04-08 15:08:18 +00:00
|
|
|
{
|
|
|
|
esm.skipHSub();
|
|
|
|
break;
|
|
|
|
}
|
2022-04-11 22:18:39 +00:00
|
|
|
case SREC_DELE:
|
2022-04-08 15:08:18 +00:00
|
|
|
esm.skipHSub();
|
|
|
|
if constexpr (load)
|
|
|
|
isDeleted = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
esm.cacheSubName();
|
|
|
|
isLoaded = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if constexpr (load)
|
|
|
|
{
|
|
|
|
if (cellRef.mLockLevel == 0 && !cellRef.mKey.empty())
|
|
|
|
{
|
|
|
|
cellRef.mLockLevel = UnbreakableLock;
|
2022-10-03 12:02:59 +00:00
|
|
|
cellRef.mTrap = ESM::RefId::sEmpty;
|
2022-04-08 15:08:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-11 22:18:39 +00:00
|
|
|
void RefNum::load(ESMReader& esm, bool wide, NAME tag)
|
2015-01-22 12:33:23 +00:00
|
|
|
{
|
|
|
|
if (wide)
|
2022-04-10 11:35:00 +00:00
|
|
|
esm.getHNTSized<8>(*this, tag);
|
2015-01-22 12:33:23 +00:00
|
|
|
else
|
2022-01-28 17:40:17 +00:00
|
|
|
esm.getHNT(mIndex, tag);
|
2015-01-22 12:33:23 +00:00
|
|
|
}
|
|
|
|
|
2022-04-11 22:18:39 +00:00
|
|
|
void RefNum::save(ESMWriter& esm, bool wide, NAME tag) const
|
2015-01-22 12:41:09 +00:00
|
|
|
{
|
2015-01-22 12:33:23 +00:00
|
|
|
if (wide)
|
2015-01-24 13:22:29 +00:00
|
|
|
esm.writeHNT(tag, *this, 8);
|
2022-09-22 18:26:05 +00:00
|
|
|
else
|
|
|
|
{
|
2021-01-22 14:48:37 +00:00
|
|
|
if (isSet() && !hasContentFile())
|
|
|
|
Log(Debug::Error) << "Generated RefNum can not be saved in 32bit format";
|
2015-04-25 07:51:31 +00:00
|
|
|
int refNum = (mIndex & 0xffffff) | ((hasContentFile() ? mContentFile : 0xff) << 24);
|
2015-01-24 13:22:29 +00:00
|
|
|
esm.writeHNT(tag, refNum, 4);
|
2022-09-22 18:26:05 +00:00
|
|
|
}
|
2015-01-22 12:41:09 +00:00
|
|
|
}
|
2015-01-22 12:33:23 +00:00
|
|
|
|
2022-04-11 22:18:39 +00:00
|
|
|
void CellRef::load(ESMReader& esm, bool& isDeleted, bool wideRefNum)
|
2015-01-19 22:29:06 +00:00
|
|
|
{
|
2015-04-29 09:36:56 +00:00
|
|
|
loadId(esm, wideRefNum);
|
2021-07-06 04:21:17 +00:00
|
|
|
loadData(esm, isDeleted);
|
2015-01-19 22:29:06 +00:00
|
|
|
}
|
|
|
|
|
2022-04-11 22:18:39 +00:00
|
|
|
void CellRef::loadId(ESMReader& esm, bool wideRefNum)
|
2014-01-12 18:23:08 +00:00
|
|
|
{
|
2022-04-08 15:08:18 +00:00
|
|
|
loadIdImpl<true>(esm, wideRefNum, *this);
|
2015-01-18 21:52:11 +00:00
|
|
|
}
|
2014-01-12 18:23:08 +00:00
|
|
|
|
2022-04-11 22:18:39 +00:00
|
|
|
void CellRef::loadData(ESMReader& esm, bool& isDeleted)
|
2015-01-18 21:52:11 +00:00
|
|
|
{
|
2022-04-08 15:08:18 +00:00
|
|
|
loadDataImpl<true>(esm, isDeleted, *this);
|
2014-01-12 18:23:08 +00:00
|
|
|
}
|
|
|
|
|
2022-04-11 22:18:39 +00:00
|
|
|
void CellRef::save(ESMWriter& esm, bool wideRefNum, bool inInventory, bool isDeleted) const
|
2013-06-08 13:49:59 +00:00
|
|
|
{
|
2015-01-22 12:33:23 +00:00
|
|
|
mRefNum.save(esm, wideRefNum);
|
2014-01-12 18:23:08 +00: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 11:17:09 +00:00
|
|
|
esm.writeHNCString("NAME", mRefID.getRefIdString());
|
2013-06-08 13:49:59 +00:00
|
|
|
|
2015-07-28 12:04:22 +00:00
|
|
|
if (isDeleted)
|
|
|
|
{
|
2021-07-06 04:57:58 +00:00
|
|
|
esm.writeHNString("DELE", "", 3);
|
2015-07-28 12:04:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-08 13:49:59 +00:00
|
|
|
if (mScale != 1.0)
|
|
|
|
{
|
2021-06-29 16:43:47 +00:00
|
|
|
esm.writeHNT("XSCL", std::clamp(mScale, 0.5f, 2.0f));
|
2013-06-08 13:49:59 +00:00
|
|
|
}
|
|
|
|
|
2020-03-17 13:12:04 +00:00
|
|
|
if (!inInventory)
|
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 11:17:09 +00:00
|
|
|
esm.writeHNOCString("ANAM", mOwner.getRefIdString());
|
2020-03-17 13:12:04 +00:00
|
|
|
|
2014-07-22 15:05:05 +00:00
|
|
|
esm.writeHNOCString("BNAM", mGlobalVariable);
|
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 11:17:09 +00:00
|
|
|
esm.writeHNOCString("XSOL", mSoul.getRefIdString());
|
2013-06-08 13:49:59 +00:00
|
|
|
|
2020-03-17 13:12:04 +00:00
|
|
|
if (!inInventory)
|
|
|
|
{
|
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 11:17:09 +00:00
|
|
|
esm.writeHNOCString("CNAM", mFaction.getRefIdString());
|
2020-03-17 13:12:04 +00:00
|
|
|
if (mFactionRank != -2)
|
2022-09-22 18:26:05 +00:00
|
|
|
{
|
2020-03-17 13:12:04 +00:00
|
|
|
esm.writeHNT("INDX", mFactionRank);
|
2022-09-22 18:26:05 +00:00
|
|
|
}
|
2020-03-17 13:12:04 +00:00
|
|
|
}
|
2013-06-08 13:49:59 +00:00
|
|
|
|
|
|
|
if (mEnchantmentCharge != -1)
|
|
|
|
esm.writeHNT("XCHG", mEnchantmentCharge);
|
|
|
|
|
2015-01-23 14:33:39 +00:00
|
|
|
if (mChargeInt != -1)
|
|
|
|
esm.writeHNT("INTV", mChargeInt);
|
2013-06-08 13:49:59 +00:00
|
|
|
|
2019-12-21 04:47:31 +00:00
|
|
|
if (mGoldValue > 1)
|
2013-06-08 13:49:59 +00:00
|
|
|
esm.writeHNT("NAM9", mGoldValue);
|
|
|
|
|
2014-06-24 22:11:25 +00:00
|
|
|
if (!inInventory && mTeleport)
|
2013-06-08 13:49:59 +00:00
|
|
|
{
|
|
|
|
esm.writeHNT("DODT", mDoorDest);
|
2023-01-19 16:31:45 +00:00
|
|
|
esm.writeHNOCString("DNAM", mDestCell);
|
2013-06-08 13:49:59 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 22:11:25 +00:00
|
|
|
if (!inInventory && mLockLevel != 0)
|
|
|
|
{
|
2015-07-16 16:52:31 +00:00
|
|
|
esm.writeHNT("FLTV", mLockLevel);
|
2014-04-23 09:19:34 +00:00
|
|
|
}
|
2013-06-08 13:49:59 +00:00
|
|
|
|
2014-01-28 12:49:59 +00:00
|
|
|
if (!inInventory)
|
Some PVS-Studio and cppcheck fixes
cppcheck:
[apps/esmtool/record.cpp:697]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[apps/esmtool/record.cpp:1126]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[apps/esmtool/record.cpp:1138]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[apps/niftest/niftest.cpp:36]: (performance) Function parameter 'filename' should be passed by reference.
[apps/niftest/niftest.cpp:41]: (performance) Function parameter 'filename' should be passed by reference.
[apps/opencs/model/prefs/boolsetting.cpp:25]: (warning) Possible leak in public function. The pointer 'mWidget' is not deallocated before it is allocated.
[apps/opencs/model/prefs/shortcuteventhandler.cpp:52]: (warning) Return value of std::remove() ignored. Elements remain in container.
[apps/openmw/mwstate/quicksavemanager.cpp:5]: (performance) Variable 'mSaveName' is assigned in constructor body. Consider performing initialization in initialization list.
PVS-Studio:
apps/opencs/model/filter/parser.cpp 582 warn V560 A part of conditional expression is always true: allowPredefined.
apps/opencs/view/world/referencecreator.cpp 67 warn V547 Expression '!errors.empty()' is always false.
apps/opencs/view/world/referencecreator.cpp 74 warn V547 Expression '!errors.empty()' is always false.
apps/opencs/view/doc/loader.cpp 170 warn V560 A part of conditional expression is always true: !completed.
apps/opencs/view/doc/loader.cpp 170 warn V560 A part of conditional expression is always true: !error.empty().
apps/opencs/model/tools/pathgridcheck.cpp 32 err V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 32, 34.
apps/opencs/model/world/refidadapterimp.cpp 1376 err V547 Expression 'subColIndex < 3' is always true.
apps/openmw/mwgui/widgets.hpp 318 warn V703 It is odd that the 'mEnableRepeat' field in derived class 'MWScrollBar' overwrites field in base class 'ScrollBar'. Check lines: widgets.hpp:318, MyGUI_ScrollBar.h:179.
apps/openmw/mwgui/widgets.hpp 319 warn V703 It is odd that the 'mRepeatTriggerTime' field in derived class 'MWScrollBar' overwrites field in base class 'ScrollBar'. Check lines: widgets.hpp:319, MyGUI_ScrollBar.h:180.
apps/openmw/mwgui/widgets.hpp 320 warn V703 It is odd that the 'mRepeatStepTime' field in derived class 'MWScrollBar' overwrites field in base class 'ScrollBar'. Check lines: widgets.hpp:320, MyGUI_ScrollBar.h:181
apps/openmw/mwmechanics/actors.cpp 1425 warn V547 Expression '!detected' is always true.
apps/openmw/mwmechanics/character.cpp 2155 err V547 Expression 'mode == 0' is always true.
apps/openmw/mwmechanics/character.cpp 1192 warn V592 The expression was enclosed by parentheses twice: ((expression)). One pair of parentheses is unnecessary or misprint is present.
apps/openmw/mwmechanics/character.cpp 521 warn V560 A part of conditional expression is always true: (idle == mIdleState).
apps/openmw/mwmechanics/pathfinding.cpp 317 err V547 Expression 'mPath.size() >= 2' is always true.
apps/openmw/mwscript/interpretercontext.cpp 409 warn V560 A part of conditional expression is always false: rank > 9.
apps/openmw/mwgui/windowbase.cpp 28 warn V560 A part of conditional expression is always true: !visible.
apps/openmw/mwgui/journalwindow.cpp 561 warn V547 Expression '!mAllQuests' is always false.
apps/openmw/mwgui/referenceinterface.cpp 18 warn V571 Recurring check. The '!mPtr.isEmpty()' condition was already verified in line 16.
apps/openmw/mwworld/scene.cpp 463 warn V547 Expression 'adjustPlayerPos' is always true.
apps/openmw/mwworld/worldimp.cpp 409 err V766 An item with the same key '"sCompanionShare"' has already been added.
apps/openmw/mwworld/cellstore.cpp 691 warn V519 The 'state.mWaterLevel' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 689, 691.
apps/openmw/mwworld/weather.cpp 1125 warn V519 The 'mResult.mParticleEffect' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 1123, 1125.
apps/openmw/mwworld/weather.cpp 1137 warn V519 The 'mResult.mParticleEffect' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 1135, 1137.
apps/wizard/unshield/unshieldworker.cpp 475 warn V728 An excessive check can be simplified. The '(A && B) || (!A && !B)' expression is equivalent to the 'bool(A) == bool(B)' expression.
apps/wizard/installationpage.cpp 163 warn V735 Possibly an incorrect HTML. The "</p" closing tag was encountered, while the "</span" tag was expected.
components/fontloader/fontloader.cpp 427 err V547 Expression 'i == 1' is always true.
components/nifosg/nifloader.cpp 282 warn V519 The 'created' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 278, 282.
components/esm/loadregn.cpp 119 err V586 The 'clear' function is called twice for deallocation of the same resource. Check lines: 112, 119.
components/esm/cellref.cpp 178 warn V581 The conditional expressions of the 'if' statements situated alongside each other are identical. Check lines: 175, 178.
components/esmterrain/storage.cpp 235 warn V560 A part of conditional expression is always true: colStart == 0.
components/esmterrain/storage.cpp 237 warn V560 A part of conditional expression is always true: rowStart == 0.
2018-04-09 15:55:16 +00: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 11:17:09 +00:00
|
|
|
esm.writeHNOCString("KNAM", mKey.getRefIdString());
|
|
|
|
esm.writeHNOCString("TNAM", mTrap.getRefIdString());
|
Some PVS-Studio and cppcheck fixes
cppcheck:
[apps/esmtool/record.cpp:697]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[apps/esmtool/record.cpp:1126]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[apps/esmtool/record.cpp:1138]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[apps/niftest/niftest.cpp:36]: (performance) Function parameter 'filename' should be passed by reference.
[apps/niftest/niftest.cpp:41]: (performance) Function parameter 'filename' should be passed by reference.
[apps/opencs/model/prefs/boolsetting.cpp:25]: (warning) Possible leak in public function. The pointer 'mWidget' is not deallocated before it is allocated.
[apps/opencs/model/prefs/shortcuteventhandler.cpp:52]: (warning) Return value of std::remove() ignored. Elements remain in container.
[apps/openmw/mwstate/quicksavemanager.cpp:5]: (performance) Variable 'mSaveName' is assigned in constructor body. Consider performing initialization in initialization list.
PVS-Studio:
apps/opencs/model/filter/parser.cpp 582 warn V560 A part of conditional expression is always true: allowPredefined.
apps/opencs/view/world/referencecreator.cpp 67 warn V547 Expression '!errors.empty()' is always false.
apps/opencs/view/world/referencecreator.cpp 74 warn V547 Expression '!errors.empty()' is always false.
apps/opencs/view/doc/loader.cpp 170 warn V560 A part of conditional expression is always true: !completed.
apps/opencs/view/doc/loader.cpp 170 warn V560 A part of conditional expression is always true: !error.empty().
apps/opencs/model/tools/pathgridcheck.cpp 32 err V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 32, 34.
apps/opencs/model/world/refidadapterimp.cpp 1376 err V547 Expression 'subColIndex < 3' is always true.
apps/openmw/mwgui/widgets.hpp 318 warn V703 It is odd that the 'mEnableRepeat' field in derived class 'MWScrollBar' overwrites field in base class 'ScrollBar'. Check lines: widgets.hpp:318, MyGUI_ScrollBar.h:179.
apps/openmw/mwgui/widgets.hpp 319 warn V703 It is odd that the 'mRepeatTriggerTime' field in derived class 'MWScrollBar' overwrites field in base class 'ScrollBar'. Check lines: widgets.hpp:319, MyGUI_ScrollBar.h:180.
apps/openmw/mwgui/widgets.hpp 320 warn V703 It is odd that the 'mRepeatStepTime' field in derived class 'MWScrollBar' overwrites field in base class 'ScrollBar'. Check lines: widgets.hpp:320, MyGUI_ScrollBar.h:181
apps/openmw/mwmechanics/actors.cpp 1425 warn V547 Expression '!detected' is always true.
apps/openmw/mwmechanics/character.cpp 2155 err V547 Expression 'mode == 0' is always true.
apps/openmw/mwmechanics/character.cpp 1192 warn V592 The expression was enclosed by parentheses twice: ((expression)). One pair of parentheses is unnecessary or misprint is present.
apps/openmw/mwmechanics/character.cpp 521 warn V560 A part of conditional expression is always true: (idle == mIdleState).
apps/openmw/mwmechanics/pathfinding.cpp 317 err V547 Expression 'mPath.size() >= 2' is always true.
apps/openmw/mwscript/interpretercontext.cpp 409 warn V560 A part of conditional expression is always false: rank > 9.
apps/openmw/mwgui/windowbase.cpp 28 warn V560 A part of conditional expression is always true: !visible.
apps/openmw/mwgui/journalwindow.cpp 561 warn V547 Expression '!mAllQuests' is always false.
apps/openmw/mwgui/referenceinterface.cpp 18 warn V571 Recurring check. The '!mPtr.isEmpty()' condition was already verified in line 16.
apps/openmw/mwworld/scene.cpp 463 warn V547 Expression 'adjustPlayerPos' is always true.
apps/openmw/mwworld/worldimp.cpp 409 err V766 An item with the same key '"sCompanionShare"' has already been added.
apps/openmw/mwworld/cellstore.cpp 691 warn V519 The 'state.mWaterLevel' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 689, 691.
apps/openmw/mwworld/weather.cpp 1125 warn V519 The 'mResult.mParticleEffect' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 1123, 1125.
apps/openmw/mwworld/weather.cpp 1137 warn V519 The 'mResult.mParticleEffect' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 1135, 1137.
apps/wizard/unshield/unshieldworker.cpp 475 warn V728 An excessive check can be simplified. The '(A && B) || (!A && !B)' expression is equivalent to the 'bool(A) == bool(B)' expression.
apps/wizard/installationpage.cpp 163 warn V735 Possibly an incorrect HTML. The "</p" closing tag was encountered, while the "</span" tag was expected.
components/fontloader/fontloader.cpp 427 err V547 Expression 'i == 1' is always true.
components/nifosg/nifloader.cpp 282 warn V519 The 'created' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 278, 282.
components/esm/loadregn.cpp 119 err V586 The 'clear' function is called twice for deallocation of the same resource. Check lines: 112, 119.
components/esm/cellref.cpp 178 warn V581 The conditional expressions of the 'if' statements situated alongside each other are identical. Check lines: 175, 178.
components/esmterrain/storage.cpp 235 warn V560 A part of conditional expression is always true: colStart == 0.
components/esmterrain/storage.cpp 237 warn V560 A part of conditional expression is always true: rowStart == 0.
2018-04-09 15:55:16 +00:00
|
|
|
}
|
2014-01-28 12:49:59 +00:00
|
|
|
|
|
|
|
if (mReferenceBlocked != -1)
|
2013-06-08 13:49:59 +00:00
|
|
|
esm.writeHNT("UNAM", mReferenceBlocked);
|
2014-01-28 12:49:59 +00:00
|
|
|
|
|
|
|
if (!inInventory)
|
|
|
|
esm.writeHNT("DATA", mPos, 24);
|
2013-06-08 13:49:59 +00:00
|
|
|
}
|
|
|
|
|
2015-01-30 14:11:27 +00:00
|
|
|
void CellRef::blank()
|
2013-06-08 13:49:59 +00:00
|
|
|
{
|
2023-01-09 09:45:07 +00:00
|
|
|
mRefNum = RefNum{};
|
2022-10-03 12:02:59 +00:00
|
|
|
mRefID = ESM::RefId::sEmpty;
|
2013-06-08 13:49:59 +00:00
|
|
|
mScale = 1;
|
2022-10-03 12:02:59 +00:00
|
|
|
mOwner = ESM::RefId::sEmpty;
|
2014-07-22 15:05:05 +00:00
|
|
|
mGlobalVariable.clear();
|
2022-10-03 12:02:59 +00:00
|
|
|
mSoul = ESM::RefId::sEmpty;
|
|
|
|
mFaction = ESM::RefId::sEmpty;
|
2014-07-22 18:03:35 +00:00
|
|
|
mFactionRank = -2;
|
2015-01-23 14:33:39 +00:00
|
|
|
mChargeInt = -1;
|
2016-12-10 02:48:56 +00:00
|
|
|
mChargeIntRemainder = 0.0f;
|
2015-01-19 11:22:51 +00:00
|
|
|
mEnchantmentCharge = -1;
|
2019-12-21 04:47:31 +00:00
|
|
|
mGoldValue = 1;
|
2023-01-19 16:31:45 +00:00
|
|
|
mDestCell.clear();
|
2013-06-08 13:49:59 +00:00
|
|
|
mLockLevel = 0;
|
2022-10-03 12:02:59 +00:00
|
|
|
mKey = ESM::RefId::sEmpty;
|
|
|
|
mTrap = ESM::RefId::sEmpty;
|
2015-01-30 14:11:27 +00:00
|
|
|
mReferenceBlocked = -1;
|
2014-06-24 22:11:25 +00:00
|
|
|
mTeleport = false;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2013-06-08 13:49:59 +00:00
|
|
|
for (int i = 0; i < 3; ++i)
|
2022-09-22 18:26:05 +00:00
|
|
|
{
|
2013-06-08 13:49:59 +00:00
|
|
|
mDoorDest.pos[i] = 0;
|
|
|
|
mDoorDest.rot[i] = 0;
|
|
|
|
mPos.pos[i] = 0;
|
|
|
|
mPos.rot[i] = 0;
|
2022-09-22 18:26:05 +00:00
|
|
|
}
|
2013-06-08 13:49:59 +00:00
|
|
|
}
|
2022-04-08 15:08:18 +00:00
|
|
|
|
2022-04-11 22:18:39 +00:00
|
|
|
void skipLoadCellRef(ESMReader& esm, bool wideRefNum)
|
2022-04-08 15:08:18 +00:00
|
|
|
{
|
|
|
|
CellRef cellRef;
|
|
|
|
loadIdImpl<false>(esm, wideRefNum, cellRef);
|
|
|
|
bool isDeleted;
|
|
|
|
loadDataImpl<false>(esm, isDeleted, cellRef);
|
|
|
|
}
|
2022-04-11 22:18:39 +00:00
|
|
|
|
|
|
|
}
|