mostly reverts MWLua changes (#3170)

We just can no longer use the former ptr.getTypeName() as a fallback, but I do not suppose it matters. This value was an implementation defined string that usually contained a garbled mess.
Probably we should additionally refactor Lua types completely now that we have Ptr::getType(). I will leave this up to MWLua developers.
pull/3174/head
Bo Svensson 3 years ago committed by GitHub
parent 21f1cf6d86
commit d6613d3677
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,7 +23,7 @@ namespace MWLua
return std::to_string(id.mIndex) + "_" + std::to_string(id.mContentFile);
}
const static std::map<std::type_index, std::string> classNames = {
const static std::map<std::type_index, std::string_view> classNames = {
{typeid(MWClass::Activator), "Activator"},
{typeid(MWClass::Armor), "Armor"},
{typeid(MWClass::Book), "Book"},
@ -40,7 +40,7 @@ namespace MWLua
{typeid(MWClass::Weapon), "Weapon"},
};
std::string getMWClassName(const std::type_index& cls_type, std::string fallback)
std::string_view getMWClassName(const std::type_index& cls_type, std::string_view fallback)
{
auto it = classNames.find(cls_type);
if (it != classNames.end())
@ -55,13 +55,13 @@ namespace MWLua
return id == "prisonmarker" || id == "divinemarker" || id == "templemarker" || id == "northmarker";
}
std::string getMWClassName(const MWWorld::Ptr& ptr)
std::string_view getMWClassName(const MWWorld::Ptr& ptr)
{
if (ptr.getCellRef().getRefIdRef() == "player")
return "Player";
if (isMarker(ptr))
return "Marker";
return ptr.getTypeDescription();
return getMWClassName(typeid(ptr.getClass()));
}
std::string ptrToString(const MWWorld::Ptr& ptr)

@ -19,8 +19,8 @@ namespace MWLua
std::string idToString(const ObjectId& id);
std::string ptrToString(const MWWorld::Ptr& ptr);
bool isMarker(const MWWorld::Ptr& ptr);
std::string getMWClassName(const std::type_index& cls_type, std::string fallback = "Unknown");
std::string getMWClassName(const MWWorld::Ptr& ptr);
std::string_view getMWClassName(const std::type_index& cls_type, std::string_view fallback = "Unknown");
std::string_view getMWClassName(const MWWorld::Ptr& ptr);
// Holds a mapping ObjectId -> MWWord::Ptr.
class ObjectRegistry

Loading…
Cancel
Save