mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-01 03:21:41 +00:00
ef906cbfa8
Currently, we use a peculiar mapping of ESM classes by their std::type_info::name. This mapping is an undefined behaviour because std::type_info::name is strictly implementation defined. It could return a non-unique value on some platforms. With this PR we use the unsigned int sRecordId of the ESM class as a more efficient lookup type that does not build on undefined behaviour. We can expect marginally faster save-game loading with these changes as well.
54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
#include "bodypart.hpp"
|
|
|
|
#include "../mwrender/renderinginterface.hpp"
|
|
#include "../mwrender/objects.hpp"
|
|
|
|
#include "../mwworld/cellstore.hpp"
|
|
|
|
namespace MWClass
|
|
{
|
|
|
|
MWWorld::Ptr BodyPart::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
|
|
{
|
|
const MWWorld::LiveCellRef<ESM::BodyPart> *ref = ptr.get<ESM::BodyPart>();
|
|
|
|
return MWWorld::Ptr(cell.insert(ref), &cell);
|
|
}
|
|
|
|
void BodyPart::insertObjectRendering(const MWWorld::Ptr &ptr, const std::string &model, MWRender::RenderingInterface &renderingInterface) const
|
|
{
|
|
if (!model.empty()) {
|
|
renderingInterface.getObjects().insertModel(ptr, model);
|
|
}
|
|
}
|
|
|
|
std::string BodyPart::getName(const MWWorld::ConstPtr &ptr) const
|
|
{
|
|
return std::string();
|
|
}
|
|
|
|
bool BodyPart::hasToolTip(const MWWorld::ConstPtr& ptr) const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
void BodyPart::registerSelf()
|
|
{
|
|
std::shared_ptr<MWWorld::Class> instance (new BodyPart);
|
|
|
|
registerClass (ESM::BodyPart::sRecordId, instance);
|
|
}
|
|
|
|
std::string BodyPart::getModel(const MWWorld::ConstPtr &ptr) const
|
|
{
|
|
const MWWorld::LiveCellRef<ESM::BodyPart> *ref = ptr.get<ESM::BodyPart>();
|
|
|
|
const std::string &model = ref->mBase->mModel;
|
|
if (!model.empty()) {
|
|
return "meshes\\" + model;
|
|
}
|
|
return "";
|
|
}
|
|
|
|
}
|