1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-06 11:15:33 +00:00

Fix(loadcell): Save water height regardless of value, if the user actually adjusted it

This commit is contained in:
Dave Corley 2024-02-20 07:12:42 -06:00
parent 1b431bf633
commit bb35f0366a
3 changed files with 11 additions and 1 deletions

View file

@ -996,7 +996,10 @@ namespace CSMWorld
case 5: case 5:
{ {
if (isInterior && interiorWater) if (isInterior && interiorWater)
{
cell.mWater = value.toFloat(); cell.mWater = value.toFloat();
cell.setHasWater(true);
}
else else
return; // return without saving return; // return without saving
break; break;

View file

@ -118,6 +118,7 @@ namespace ESM
bool overriding = !mName.empty(); bool overriding = !mName.empty();
bool isLoaded = false; bool isLoaded = false;
mHasAmbi = false; mHasAmbi = false;
mHasWater = false;
while (!isLoaded && esm.hasMoreSubs()) while (!isLoaded && esm.hasMoreSubs())
{ {
esm.getSubName(); esm.getSubName();
@ -133,6 +134,7 @@ namespace ESM
float waterLevel; float waterLevel;
esm.getHT(waterLevel); esm.getHT(waterLevel);
mWaterInt = false; mWaterInt = false;
mHasWater = true;
if (!std::isfinite(waterLevel)) if (!std::isfinite(waterLevel))
{ {
if (!overriding) if (!overriding)
@ -193,7 +195,7 @@ namespace ESM
// Try to avoid saving ambient information when it's unnecessary. // Try to avoid saving ambient information when it's unnecessary.
// This is to fix black lighting and flooded water // This is to fix black lighting and flooded water
// in resaved cell records that lack this information. // in resaved cell records that lack this information.
if (mWaterInt && mWater != 0) if (mHasWater)
esm.writeHNT("WHGT", mWater); esm.writeHNT("WHGT", mWater);
if (mData.mFlags & QuasiEx) if (mData.mFlags & QuasiEx)
esm.writeHNOCRefId("RGNN", mRegion); esm.writeHNOCRefId("RGNN", mRegion);
@ -323,6 +325,7 @@ namespace ESM
mData.mY = 0; mData.mY = 0;
mHasAmbi = true; mHasAmbi = true;
mHasWater = true;
mAmbi.mAmbient = 0; mAmbi.mAmbient = 0;
mAmbi.mSunlight = 0; mAmbi.mSunlight = 0;
mAmbi.mFog = 0; mAmbi.mFog = 0;

View file

@ -112,6 +112,7 @@ namespace ESM
, mHasAmbi(true) , mHasAmbi(true)
, mWater(0) , mWater(0)
, mWaterInt(false) , mWaterInt(false)
, mHasWater(false)
, mMapColor(0) , mMapColor(0)
, mRefNumCounter(0) , mRefNumCounter(0)
{ {
@ -132,6 +133,7 @@ namespace ESM
float mWater; // Water level float mWater; // Water level
bool mWaterInt; bool mWaterInt;
bool mHasWater;
int32_t mMapColor; int32_t mMapColor;
// Counter for RefNums. This is only used during content file editing and has no impact on gameplay. // Counter for RefNums. This is only used during content file editing and has no impact on gameplay.
// It prevents overwriting previous refNums, even if they were deleted. // It prevents overwriting previous refNums, even if they were deleted.
@ -163,6 +165,8 @@ namespace ESM
bool hasWater() const { return ((mData.mFlags & HasWater) != 0) || isExterior(); } bool hasWater() const { return ((mData.mFlags & HasWater) != 0) || isExterior(); }
void setHasWater(bool hasWater) { mHasWater = hasWater; }
bool hasAmbient() const { return mHasAmbi; } bool hasAmbient() const { return mHasAmbi; }
void setHasAmbient(bool hasAmbi) { mHasAmbi = hasAmbi; } void setHasAmbient(bool hasAmbi) { mHasAmbi = hasAmbi; }