mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +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
@ -1,15 +1,47 @@
|
||||
#include "cell.hpp"
|
||||
|
||||
#include "esmstore.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
||||
#include <components/esm3/loadcell.hpp>
|
||||
#include <components/esm4/loadcell.hpp>
|
||||
#include <components/esm4/loadwrld.hpp>
|
||||
#include <components/misc/algorithm.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "esmstore.hpp"
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
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)
|
||||
: ESM::CellVariant(cell)
|
||||
, mIsExterior(!(cell.mCellFlags & ESM4::CELL_Interior))
|
||||
@ -22,20 +54,24 @@ namespace MWWorld
|
||||
, mRegion(ESM::RefId()) // Unimplemented for now
|
||||
, mId(cell.mId)
|
||||
, mParent(cell.mParent)
|
||||
,mMood{
|
||||
, mWaterHeight(cell.mWaterHeight)
|
||||
, mMood{
|
||||
.mAmbiantColor = cell.mLighting.ambient,
|
||||
.mDirectionalColor = cell.mLighting.directional,
|
||||
.mFogColor = cell.mLighting.fogColor,
|
||||
// TODO: use ESM4::Lighting fog parameters
|
||||
.mFogDensity = 1.f,}
|
||||
,mWaterHeight(cell.mWaterHeight)
|
||||
.mFogDensity = 1.f,
|
||||
}
|
||||
{
|
||||
const ESM4::World* world = MWBase::Environment::get().getESMStore()->get<ESM4::World>().search(mParent);
|
||||
if (isExterior())
|
||||
{
|
||||
auto& worldStore = MWBase::Environment::get().getESMStore()->get<ESM4::World>();
|
||||
const ESM4::World* cellWorld = worldStore.find(mParent);
|
||||
mWaterHeight = cellWorld->mWaterLevel;
|
||||
if (world == nullptr)
|
||||
throw std::runtime_error(
|
||||
"Cell " + cell.mId.toDebugString() + " parent world " + mParent.toDebugString() + " is not found");
|
||||
mWaterHeight = world->mWaterLevel;
|
||||
}
|
||||
mDescription = getCellDescription(cell, world);
|
||||
}
|
||||
|
||||
Cell::Cell(const ESM::Cell& cell)
|
||||
@ -50,26 +86,19 @@ namespace MWWorld
|
||||
, mRegion(cell.mRegion)
|
||||
, mId(cell.mId)
|
||||
, mParent(ESM::Cell::sDefaultWorldspaceId)
|
||||
, mWaterHeight(cell.mWater)
|
||||
, mDescription(cell.getDescription())
|
||||
, mMood{
|
||||
.mAmbiantColor = cell.mAmbi.mAmbient,
|
||||
.mDirectionalColor = cell.mAmbi.mSunlight,
|
||||
.mFogColor = cell.mAmbi.mFog,
|
||||
.mFogDensity = cell.mAmbi.mFogDensity,
|
||||
}
|
||||
,mWaterHeight(cell.mWater)
|
||||
{
|
||||
if (isExterior())
|
||||
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
|
||||
{
|
||||
if (isExterior())
|
||||
|
@ -44,7 +44,7 @@ namespace MWWorld
|
||||
const ESM::RefId& getRegion() const { return mRegion; }
|
||||
std::string_view getNameId() const { return mNameID; }
|
||||
std::string_view getDisplayName() const { return mDisplayname; }
|
||||
std::string getDescription() const;
|
||||
std::string_view getDescription() const { return mDescription; }
|
||||
const MoodData& getMood() const { return mMood; }
|
||||
float getWaterHeight() const { return mWaterHeight; }
|
||||
const ESM::RefId& getId() const { return mId; }
|
||||
@ -63,9 +63,9 @@ namespace MWWorld
|
||||
ESM::RefId mRegion;
|
||||
ESM::RefId mId;
|
||||
ESM::RefId mParent;
|
||||
MoodData mMood;
|
||||
|
||||
float mWaterHeight;
|
||||
std::string mDescription;
|
||||
MoodData mMood;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user