mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-15 15:06:44 +00:00
Merge branch 'esm4_cell_description' into 'master'
Always log something for loading and unloading ESM4 cell See merge request OpenMW/openmw!3298
This commit is contained in:
commit
b643e58e71
2 changed files with 49 additions and 20 deletions
|
@ -1,15 +1,47 @@
|
||||||
#include "cell.hpp"
|
#include "cell.hpp"
|
||||||
|
|
||||||
|
#include "esmstore.hpp"
|
||||||
|
|
||||||
|
#include "../mwbase/environment.hpp"
|
||||||
|
|
||||||
#include <components/esm3/loadcell.hpp>
|
#include <components/esm3/loadcell.hpp>
|
||||||
#include <components/esm4/loadcell.hpp>
|
#include <components/esm4/loadcell.hpp>
|
||||||
#include <components/esm4/loadwrld.hpp>
|
#include <components/esm4/loadwrld.hpp>
|
||||||
#include <components/misc/algorithm.hpp>
|
#include <components/misc/algorithm.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include <stdexcept>
|
||||||
#include "esmstore.hpp"
|
#include <string>
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
std::string getDescription(const ESM4::World& value)
|
||||||
|
{
|
||||||
|
if (!value.mEditorId.empty())
|
||||||
|
return value.mEditorId;
|
||||||
|
|
||||||
|
return value.mId.serializeText();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string getCellDescription(const ESM4::Cell& cell, const ESM4::World* world)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
|
||||||
|
if (!cell.mEditorId.empty())
|
||||||
|
result = cell.mEditorId;
|
||||||
|
else if (world != nullptr && cell.isExterior())
|
||||||
|
result = getDescription(*world);
|
||||||
|
else
|
||||||
|
result = cell.mId.serializeText();
|
||||||
|
|
||||||
|
if (cell.isExterior())
|
||||||
|
result += " (" + std::to_string(cell.mX) + ", " + std::to_string(cell.mY) + ")";
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Cell::Cell(const ESM4::Cell& cell)
|
Cell::Cell(const ESM4::Cell& cell)
|
||||||
: ESM::CellVariant(cell)
|
: ESM::CellVariant(cell)
|
||||||
, mIsExterior(!(cell.mCellFlags & ESM4::CELL_Interior))
|
, mIsExterior(!(cell.mCellFlags & ESM4::CELL_Interior))
|
||||||
|
@ -22,20 +54,24 @@ namespace MWWorld
|
||||||
, mRegion(ESM::RefId()) // Unimplemented for now
|
, mRegion(ESM::RefId()) // Unimplemented for now
|
||||||
, mId(cell.mId)
|
, mId(cell.mId)
|
||||||
, mParent(cell.mParent)
|
, mParent(cell.mParent)
|
||||||
,mMood{
|
, mWaterHeight(cell.mWaterHeight)
|
||||||
|
, mMood{
|
||||||
.mAmbiantColor = cell.mLighting.ambient,
|
.mAmbiantColor = cell.mLighting.ambient,
|
||||||
.mDirectionalColor = cell.mLighting.directional,
|
.mDirectionalColor = cell.mLighting.directional,
|
||||||
.mFogColor = cell.mLighting.fogColor,
|
.mFogColor = cell.mLighting.fogColor,
|
||||||
// TODO: use ESM4::Lighting fog parameters
|
// TODO: use ESM4::Lighting fog parameters
|
||||||
.mFogDensity = 1.f,}
|
.mFogDensity = 1.f,
|
||||||
,mWaterHeight(cell.mWaterHeight)
|
}
|
||||||
{
|
{
|
||||||
|
const ESM4::World* world = MWBase::Environment::get().getESMStore()->get<ESM4::World>().search(mParent);
|
||||||
if (isExterior())
|
if (isExterior())
|
||||||
{
|
{
|
||||||
auto& worldStore = MWBase::Environment::get().getESMStore()->get<ESM4::World>();
|
if (world == nullptr)
|
||||||
const ESM4::World* cellWorld = worldStore.find(mParent);
|
throw std::runtime_error(
|
||||||
mWaterHeight = cellWorld->mWaterLevel;
|
"Cell " + cell.mId.toDebugString() + " parent world " + mParent.toDebugString() + " is not found");
|
||||||
|
mWaterHeight = world->mWaterLevel;
|
||||||
}
|
}
|
||||||
|
mDescription = getCellDescription(cell, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cell::Cell(const ESM::Cell& cell)
|
Cell::Cell(const ESM::Cell& cell)
|
||||||
|
@ -50,26 +86,19 @@ namespace MWWorld
|
||||||
, mRegion(cell.mRegion)
|
, mRegion(cell.mRegion)
|
||||||
, mId(cell.mId)
|
, mId(cell.mId)
|
||||||
, mParent(ESM::Cell::sDefaultWorldspaceId)
|
, mParent(ESM::Cell::sDefaultWorldspaceId)
|
||||||
|
, mWaterHeight(cell.mWater)
|
||||||
|
, mDescription(cell.getDescription())
|
||||||
, mMood{
|
, mMood{
|
||||||
.mAmbiantColor = cell.mAmbi.mAmbient,
|
.mAmbiantColor = cell.mAmbi.mAmbient,
|
||||||
.mDirectionalColor = cell.mAmbi.mSunlight,
|
.mDirectionalColor = cell.mAmbi.mSunlight,
|
||||||
.mFogColor = cell.mAmbi.mFog,
|
.mFogColor = cell.mAmbi.mFog,
|
||||||
.mFogDensity = cell.mAmbi.mFogDensity,
|
.mFogDensity = cell.mAmbi.mFogDensity,
|
||||||
}
|
}
|
||||||
,mWaterHeight(cell.mWater)
|
|
||||||
{
|
{
|
||||||
if (isExterior())
|
if (isExterior())
|
||||||
mWaterHeight = -1.f;
|
mWaterHeight = -1.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Cell::getDescription() const
|
|
||||||
{
|
|
||||||
return ESM::visit(ESM::VisitOverload{
|
|
||||||
[&](const ESM::Cell& cell) { return cell.getDescription(); },
|
|
||||||
[&](const ESM4::Cell& cell) { return cell.mEditorId; },
|
|
||||||
},
|
|
||||||
*this);
|
|
||||||
}
|
|
||||||
ESM::RefId Cell::getWorldSpace() const
|
ESM::RefId Cell::getWorldSpace() const
|
||||||
{
|
{
|
||||||
if (isExterior())
|
if (isExterior())
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace MWWorld
|
||||||
const ESM::RefId& getRegion() const { return mRegion; }
|
const ESM::RefId& getRegion() const { return mRegion; }
|
||||||
std::string_view getNameId() const { return mNameID; }
|
std::string_view getNameId() const { return mNameID; }
|
||||||
std::string_view getDisplayName() const { return mDisplayname; }
|
std::string_view getDisplayName() const { return mDisplayname; }
|
||||||
std::string getDescription() const;
|
std::string_view getDescription() const { return mDescription; }
|
||||||
const MoodData& getMood() const { return mMood; }
|
const MoodData& getMood() const { return mMood; }
|
||||||
float getWaterHeight() const { return mWaterHeight; }
|
float getWaterHeight() const { return mWaterHeight; }
|
||||||
const ESM::RefId& getId() const { return mId; }
|
const ESM::RefId& getId() const { return mId; }
|
||||||
|
@ -63,9 +63,9 @@ namespace MWWorld
|
||||||
ESM::RefId mRegion;
|
ESM::RefId mRegion;
|
||||||
ESM::RefId mId;
|
ESM::RefId mId;
|
||||||
ESM::RefId mParent;
|
ESM::RefId mParent;
|
||||||
MoodData mMood;
|
|
||||||
|
|
||||||
float mWaterHeight;
|
float mWaterHeight;
|
||||||
|
std::string mDescription;
|
||||||
|
MoodData mMood;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue