From edc2d8335a86b9756a9778ce7cc66193c70e3edb Mon Sep 17 00:00:00 2001 From: wghost Date: Sat, 31 Jan 2015 21:12:28 +0400 Subject: [PATCH] Partial deserialization of Level object --- UObject.cpp | 29 +++++++++++++++++++++++++++++ UObject.h | 14 +++++++++++++- UObjectFactory.cpp | 8 ++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/UObject.cpp b/UObject.cpp index ae9aad9..82b796f 100644 --- a/UObject.cpp +++ b/UObject.cpp @@ -371,6 +371,10 @@ std::string UDefaultProperty::GuessArrayType(std::string ArrName) { return "ObjectProperty"; } + else if (ArrName.find("Name") != std::string::npos) + { + return "StringProperty"; + } return "None"; } @@ -852,6 +856,31 @@ std::string UMapProperty::Deserialize(std::istream& stream, UPKInfo& info) return ss.str(); } +std::string ULevel::Deserialize(std::istream& stream, UPKInfo& info) +{ + std::ostringstream ss; + ss << UObject::Deserialize(stream, info); + uint32_t pos = ((unsigned)stream.tellg() - info.GetExportEntry(ThisRef).SerialOffset); + ss << "Stream relative position (debug info): " << FormatHEX(pos) << " (" << pos << ")\n"; + ss << "ULevel:\n"; + ss << "Actors:\n"; + for (int i = 0; ; ++i) + { + UObjectReference A; + stream.read(reinterpret_cast(&A), sizeof(A)); + if (info.GetExportEntry(A).FullName.find("TheWorld.PersistentLevel") == std::string::npos && A != 0x0) + { + break; + } + Actors.push_back(A); + ss << "\t" << FormatHEX((char*)&A, sizeof(A)) << "\t//\t" << FormatHEX((uint32_t)A) << "\t//\t" << info.ObjRefToName(A) << std::endl; + } + pos = ((unsigned)stream.tellg() - info.GetExportEntry(ThisRef).SerialOffset); + ss << "Stream relative position (debug info): " << FormatHEX(pos) << " (" << pos << ")\n"; + ss << "Object unknown, can't deserialize!\n"; + return ss.str(); +} + std::string UObjectUnknown::Deserialize(std::istream& stream, UPKInfo& info) { std::ostringstream ss; diff --git a/UObject.h b/UObject.h index 5df4348..5eb0657 100644 --- a/UObject.h +++ b/UObject.h @@ -38,7 +38,8 @@ enum class GlobalType UComponentProperty = 24, UDelegateProperty = 25, UInterfaceProperty = 26, - UMapProperty = 27 + UMapProperty = 27, + ULevel = 28 }; class UBulkDataMirror @@ -455,6 +456,17 @@ class UMapProperty: public UProperty UObjectReference ValueObjRef; }; +class ULevel: public UObject +{ +public: + ULevel() { Type = GlobalType::ULevel; } + ~ULevel() {} + std::string Deserialize(std::istream& stream, UPKInfo& info); +protected: + /// database + std::vector Actors; +}; + class UObjectUnknown: public UObject { public: diff --git a/UObjectFactory.cpp b/UObjectFactory.cpp index 152c64f..48795cb 100644 --- a/UObjectFactory.cpp +++ b/UObjectFactory.cpp @@ -109,6 +109,10 @@ GlobalType UObjectFactory::NameToType(std::string name) else if (name == "TextBuffer") { return GlobalType::UTextBuffer; + } + else if (name == "Level") + { + return GlobalType::ULevel; } else { @@ -226,6 +230,10 @@ UObject* UObjectFactory::Create(GlobalType Type) else if (Type == GlobalType::UClass) { return new UClass; + } + else if (Type == GlobalType::ULevel) + { + return new ULevel; } else {