diff --git a/apps/opencs/model/world/nestedcoladapterimp.cpp b/apps/opencs/model/world/nestedcoladapterimp.cpp index 13ae821a77..ea3a3bde26 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.cpp +++ b/apps/opencs/model/world/nestedcoladapterimp.cpp @@ -996,7 +996,10 @@ namespace CSMWorld case 5: { if (isInterior && interiorWater) + { cell.mWater = value.toFloat(); + cell.setHasWater(true); + } else return; // return without saving break; diff --git a/components/esm3/loadcell.cpp b/components/esm3/loadcell.cpp index 5b8521f9a1..f550c190cb 100644 --- a/components/esm3/loadcell.cpp +++ b/components/esm3/loadcell.cpp @@ -118,6 +118,7 @@ namespace ESM bool overriding = !mName.empty(); bool isLoaded = false; mHasAmbi = false; + mHasWater = false; while (!isLoaded && esm.hasMoreSubs()) { esm.getSubName(); @@ -133,6 +134,7 @@ namespace ESM float waterLevel; esm.getHT(waterLevel); mWaterInt = false; + mHasWater = true; if (!std::isfinite(waterLevel)) { if (!overriding) @@ -193,7 +195,7 @@ namespace ESM // Try to avoid saving ambient information when it's unnecessary. // This is to fix black lighting and flooded water // in resaved cell records that lack this information. - if (mWaterInt && mWater != 0) + if (mHasWater) esm.writeHNT("WHGT", mWater); if (mData.mFlags & QuasiEx) esm.writeHNOCRefId("RGNN", mRegion); @@ -323,6 +325,7 @@ namespace ESM mData.mY = 0; mHasAmbi = true; + mHasWater = true; mAmbi.mAmbient = 0; mAmbi.mSunlight = 0; mAmbi.mFog = 0; diff --git a/components/esm3/loadcell.hpp b/components/esm3/loadcell.hpp index bfabdd58f9..d54ba9573a 100644 --- a/components/esm3/loadcell.hpp +++ b/components/esm3/loadcell.hpp @@ -112,6 +112,7 @@ namespace ESM , mHasAmbi(true) , mWater(0) , mWaterInt(false) + , mHasWater(false) , mMapColor(0) , mRefNumCounter(0) { @@ -132,6 +133,7 @@ namespace ESM float mWater; // Water level bool mWaterInt; + bool mHasWater; int32_t mMapColor; // 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. @@ -163,6 +165,8 @@ namespace ESM bool hasWater() const { return ((mData.mFlags & HasWater) != 0) || isExterior(); } + void setHasWater(bool hasWater) { mHasWater = hasWater; } + bool hasAmbient() const { return mHasAmbi; } void setHasAmbient(bool hasAmbi) { mHasAmbi = hasAmbi; }