1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-02 07:11:33 +00:00
openmw/components/esm/cellcommon.cpp
florent.teppe 0018bcf7de Should make cellvariant safer to use.
Hopefully clang tidy agrees.
2023-01-26 22:37:32 +01:00

31 lines
763 B
C++

#include <components/esm/cellcommon.hpp>
#include <components/esm3/loadcell.hpp>
#include <components/esm4/loadcell.hpp>
namespace ESM
{
const ESM::CellCommon* CellVariant::getCommon() const
{
auto cell3 = getEsm3();
if (isEsm4())
return &getEsm4();
else
return &getEsm3();
}
const ESM4::Cell& CellVariant::getEsm4() const
{
auto cell4 = std::get<0>(mVariant);
if (!cell4)
throw std::runtime_error("invalid variant acess");
return *cell4;
}
const ESM::Cell& CellVariant::getEsm3() const
{
auto cell = std::get<1>(mVariant);
if (!cell)
throw std::runtime_error("invalid variant acess");
return *cell;
}
}