mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-31 21:45:33 +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:
parent
525ce2f042
commit
4c0045b418
3 changed files with 25 additions and 4 deletions
|
@ -56,7 +56,7 @@ void Store<ESM::Cell>::load(ESM::ESMReader &esm, const std::string &id)
|
|||
// copy list into new cell
|
||||
cell->mContextList = oldcell->mContextList;
|
||||
// have new cell replace old cell
|
||||
*oldcell = *cell;
|
||||
ESM::Cell::merge(oldcell, cell);
|
||||
} else
|
||||
mInt[idLower] = *cell;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ void Store<ESM::Cell>::load(ESM::ESMReader &esm, const std::string &id)
|
|||
}
|
||||
cell->mMovedRefs = oldcell->mMovedRefs;
|
||||
// have new cell replace old cell
|
||||
*oldcell = *cell;
|
||||
ESM::Cell::merge(oldcell, cell);
|
||||
} else
|
||||
mExt[std::make_pair(cell->mData.mX, cell->mData.mY)] = *cell;
|
||||
}
|
||||
|
|
|
@ -47,9 +47,13 @@ void Cell::load(ESMReader &esm, bool saveContext)
|
|||
esm.getHT(waterl);
|
||||
mWater = (float) waterl;
|
||||
mWaterInt = true;
|
||||
mHasWaterLevelRecord = true;
|
||||
}
|
||||
else if (esm.isNextSub("WHGT"))
|
||||
{
|
||||
esm.getHT(mWater);
|
||||
mHasWaterLevelRecord = true;
|
||||
}
|
||||
|
||||
// Quasi-exterior cells have a region (which determines the
|
||||
// weather), pure interior cells have ambient lighting
|
||||
|
@ -94,7 +98,7 @@ void Cell::save(ESMWriter &esm) const
|
|||
esm.writeHNT("DATA", mData, 12);
|
||||
if (mData.mFlags & Interior)
|
||||
{
|
||||
if (mWater != -1) {
|
||||
if (mHasWaterLevelRecord) {
|
||||
if (mWaterInt) {
|
||||
int water =
|
||||
(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.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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,10 @@ struct Cell
|
|||
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
|
||||
// cells it is optional.
|
||||
|
@ -90,6 +93,7 @@ struct Cell
|
|||
DATAstruct mData;
|
||||
AMBIstruct mAmbi;
|
||||
float mWater; // Water level
|
||||
bool mHasWaterLevelRecord;
|
||||
bool mWaterInt;
|
||||
int mMapColor;
|
||||
int mNAM0;
|
||||
|
|
Loading…
Reference in a new issue