Skip to content

Commit

Permalink
Partial deserialization of Level object
Browse files Browse the repository at this point in the history
  • Loading branch information
wghost committed Jan 31, 2015
1 parent 1fea26b commit edc2d83
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
29 changes: 29 additions & 0 deletions UObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down Expand Up @@ -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<char*>(&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;
Expand Down
14 changes: 13 additions & 1 deletion UObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ enum class GlobalType
UComponentProperty = 24,
UDelegateProperty = 25,
UInterfaceProperty = 26,
UMapProperty = 27
UMapProperty = 27,
ULevel = 28
};

class UBulkDataMirror
Expand Down Expand Up @@ -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<UObjectReference> Actors;
};

class UObjectUnknown: public UObject
{
public:
Expand Down
8 changes: 8 additions & 0 deletions UObjectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit edc2d83

Please sign in to comment.