mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
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.
This commit is contained in:
parent
21f1cf6d86
commit
d6613d3677
@ -23,7 +23,7 @@ namespace MWLua
|
|||||||
return std::to_string(id.mIndex) + "_" + std::to_string(id.mContentFile);
|
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::Activator), "Activator"},
|
||||||
{typeid(MWClass::Armor), "Armor"},
|
{typeid(MWClass::Armor), "Armor"},
|
||||||
{typeid(MWClass::Book), "Book"},
|
{typeid(MWClass::Book), "Book"},
|
||||||
@ -40,7 +40,7 @@ namespace MWLua
|
|||||||
{typeid(MWClass::Weapon), "Weapon"},
|
{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);
|
auto it = classNames.find(cls_type);
|
||||||
if (it != classNames.end())
|
if (it != classNames.end())
|
||||||
@ -55,13 +55,13 @@ namespace MWLua
|
|||||||
return id == "prisonmarker" || id == "divinemarker" || id == "templemarker" || id == "northmarker";
|
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")
|
if (ptr.getCellRef().getRefIdRef() == "player")
|
||||||
return "Player";
|
return "Player";
|
||||||
if (isMarker(ptr))
|
if (isMarker(ptr))
|
||||||
return "Marker";
|
return "Marker";
|
||||||
return ptr.getTypeDescription();
|
return getMWClassName(typeid(ptr.getClass()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ptrToString(const MWWorld::Ptr& ptr)
|
std::string ptrToString(const MWWorld::Ptr& ptr)
|
||||||
|
@ -19,8 +19,8 @@ namespace MWLua
|
|||||||
std::string idToString(const ObjectId& id);
|
std::string idToString(const ObjectId& id);
|
||||||
std::string ptrToString(const MWWorld::Ptr& ptr);
|
std::string ptrToString(const MWWorld::Ptr& ptr);
|
||||||
bool isMarker(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_view getMWClassName(const std::type_index& cls_type, std::string_view fallback = "Unknown");
|
||||||
std::string getMWClassName(const MWWorld::Ptr& ptr);
|
std::string_view getMWClassName(const MWWorld::Ptr& ptr);
|
||||||
|
|
||||||
// Holds a mapping ObjectId -> MWWord::Ptr.
|
// Holds a mapping ObjectId -> MWWord::Ptr.
|
||||||
class ObjectRegistry
|
class ObjectRegistry
|
||||||
|
Loading…
Reference in New Issue
Block a user