1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-29 13:20:35 +00:00

Bug #1109: Do not reset water level when loading a plugin with no water level record (for real this time)

This commit is contained in:
scrawl 2014-01-18 21:11:12 +01:00
parent 525ce2f042
commit 4c0045b418
3 changed files with 25 additions and 4 deletions

View File

@ -56,7 +56,7 @@ void Store<ESM::Cell>::load(ESM::ESMReader &esm, const std::string &id)
// copy list into new cell // copy list into new cell
cell->mContextList = oldcell->mContextList; cell->mContextList = oldcell->mContextList;
// have new cell replace old cell // have new cell replace old cell
*oldcell = *cell; ESM::Cell::merge(oldcell, cell);
} else } else
mInt[idLower] = *cell; mInt[idLower] = *cell;
} }
@ -83,7 +83,7 @@ void Store<ESM::Cell>::load(ESM::ESMReader &esm, const std::string &id)
} }
cell->mMovedRefs = oldcell->mMovedRefs; cell->mMovedRefs = oldcell->mMovedRefs;
// have new cell replace old cell // have new cell replace old cell
*oldcell = *cell; ESM::Cell::merge(oldcell, cell);
} else } else
mExt[std::make_pair(cell->mData.mX, cell->mData.mY)] = *cell; mExt[std::make_pair(cell->mData.mX, cell->mData.mY)] = *cell;
} }

View File

@ -47,9 +47,13 @@ void Cell::load(ESMReader &esm, bool saveContext)
esm.getHT(waterl); esm.getHT(waterl);
mWater = (float) waterl; mWater = (float) waterl;
mWaterInt = true; mWaterInt = true;
mHasWaterLevelRecord = true;
} }
else if (esm.isNextSub("WHGT")) else if (esm.isNextSub("WHGT"))
{
esm.getHT(mWater); esm.getHT(mWater);
mHasWaterLevelRecord = true;
}
// Quasi-exterior cells have a region (which determines the // Quasi-exterior cells have a region (which determines the
// weather), pure interior cells have ambient lighting // weather), pure interior cells have ambient lighting
@ -94,7 +98,7 @@ void Cell::save(ESMWriter &esm) const
esm.writeHNT("DATA", mData, 12); esm.writeHNT("DATA", mData, 12);
if (mData.mFlags & Interior) if (mData.mFlags & Interior)
{ {
if (mWater != -1) { if (mHasWaterLevelRecord) {
if (mWaterInt) { if (mWaterInt) {
int water = int water =
(mWater >= 0) ? (int) (mWater + 0.5) : (int) (mWater - 0.5); (mWater >= 0) ? (int) (mWater + 0.5) : (int) (mWater - 0.5);
@ -301,4 +305,17 @@ bool Cell::getNextMVRF(ESMReader &esm, MovedCellRef &mref)
mAmbi.mFog = 0; mAmbi.mFog = 0;
mAmbi.mFogDensity = 0; mAmbi.mFogDensity = 0;
} }
void Cell::merge(Cell *original, Cell *modified)
{
float waterLevel = original->mWater;
if (modified->mHasWaterLevelRecord)
{
waterLevel = modified->mWater;
}
// else: keep original water level, instead of resetting to 0
*original = *modified;
original->mWater = waterLevel;
}
} }

View File

@ -77,7 +77,10 @@ struct Cell
float mFogDensity; float mFogDensity;
}; };
Cell() : mWater(-1) {} Cell() : mWater(0), mHasWaterLevelRecord(false) {}
/// Merge \a modified into \a original
static void merge (Cell* original, Cell* modified);
// Interior cells are indexed by this (it's the 'id'), for exterior // Interior cells are indexed by this (it's the 'id'), for exterior
// cells it is optional. // cells it is optional.
@ -90,6 +93,7 @@ struct Cell
DATAstruct mData; DATAstruct mData;
AMBIstruct mAmbi; AMBIstruct mAmbi;
float mWater; // Water level float mWater; // Water level
bool mHasWaterLevelRecord;
bool mWaterInt; bool mWaterInt;
int mMapColor; int mMapColor;
int mNAM0; int mNAM0;