Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Tools/GMSInfo/include/BinaryWalker.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace ReGlacier

public:
virtual ~IBaseStreamWalker() noexcept = default;
IBaseStreamWalker() = default;
IBaseStreamWalker(size_t size, size_t offset);

IBaseStreamWalker(const IBaseStreamWalker& copy);
Expand Down Expand Up @@ -104,9 +105,10 @@ namespace ReGlacier
class BinaryWalker final : public IBaseStreamWalker
{
private:
uint8_t* m_buffer;
uint8_t* m_buffer { nullptr };

public:
BinaryWalker() = default;
BinaryWalker(uint8_t* buffer, size_t size);

BinaryWalker(const BinaryWalker& copy) noexcept;
Expand Down Expand Up @@ -184,9 +186,10 @@ namespace ReGlacier
if (!m_buffer || m_offset + sizeof(T) * size >= m_size)
throw std::out_of_range { "Unable to read buffer. Not enough bytes" };

std::memcpy(buffer, m_buffer + (sizeof(T) * size), size);
const size_t offset = sizeof(T) * size;
std::memcpy(buffer, m_buffer + m_offset, offset);

m_offset += (sizeof(T) * size);
m_offset += offset;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion Tools/GMSInfo/include/GMS/GMS.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ namespace ReGlacier
void PrintInfo() override;

[[nodiscard]] const std::vector<std::string>& GetExcludedAnimations() const;
[[nodiscard]] const std::vector<GMSLinkRef>& GetLinkReferences() const;
[[nodiscard,deprecated("Not working, please, use geoms instead of it")]] const std::vector<GMSLinkRef>& GetLinkReferences() const;
[[nodiscard]] const std::vector<GMSComposedInfoHolder>& GetGeoms() const;

[[nodiscard]] std::unique_ptr<uint8_t[]> GetUncompressedBuffer(unsigned int& uncompressedSize);
private:
Expand Down
32 changes: 32 additions & 0 deletions Tools/GMSInfo/include/PRP/DebugPRPVisitor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include <PRP/IPRPVisitor.h>

namespace ReGlacier
{
class DebugPRPVisitor final : public IPRPVisitor
{
public:
void Visit_BeginArray(uint32_t capacity) override;
void Visit_EndArray() override;
void Visit_BeginObject() override;
void Visit_EndObject() override;
void Visit_Container(uint32_t) override;
void Visit_Bitfield(uint32_t) override;
void Visit_Bool(bool value) override;
void Visit_Char(char ch) override;
void Visit_I8(uint8_t result) override;
void Visit_I16(uint16_t result) override;
void Visit_I32(uint32_t result) override;
void Visit_F32(float result) override;
void Visit_F64(double result) override;
void Visit_String(const std::string& result) override;
void Visit_RawBuffer(const std::shared_ptr<uint8_t[]>& buffer, size_t& bufferSize) override;
void Visit_StringArray(const std::vector<std::string>& stringArray) override;
void Visit_StringOrArray(const std::string& s) override;
void Visit_StringOrArray(uint32_t v) override;
void Visit_SkipMark() override;
void Visit_EndOfStream() override;
void Visit_UnknownTag(uint8_t byte) override;
};
}
35 changes: 35 additions & 0 deletions Tools/GMSInfo/include/PRP/IPRPVisitor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

#include <PRP/PRP_ETag_Helpers.h>
#include <PRP/PRPWalker.h>

namespace ReGlacier
{
class IPRPVisitor
{
public:
virtual ~IPRPVisitor() = default;

virtual void Visit_BeginArray(uint32_t capacity) = 0;
virtual void Visit_EndArray() = 0;
virtual void Visit_BeginObject() = 0;
virtual void Visit_EndObject() = 0;
virtual void Visit_Container(uint32_t) = 0;
virtual void Visit_Bitfield(uint32_t) = 0;
virtual void Visit_Bool(bool value) = 0;
virtual void Visit_Char(char ch) = 0;
virtual void Visit_I8(uint8_t result) = 0;
virtual void Visit_I16(uint16_t result) = 0;
virtual void Visit_I32(uint32_t result) = 0;
virtual void Visit_F32(float result) = 0;
virtual void Visit_F64(double result) = 0;
virtual void Visit_String(const std::string& result) = 0;
virtual void Visit_RawBuffer(const std::shared_ptr<uint8_t[]>& buffer, size_t& bufferSize) = 0;
virtual void Visit_StringArray(const std::vector<std::string>& stringArray) = 0;
virtual void Visit_StringOrArray(const std::string& s) = 0;
virtual void Visit_StringOrArray(uint32_t v) = 0;
virtual void Visit_SkipMark() = 0;
virtual void Visit_EndOfStream() = 0;
virtual void Visit_UnknownTag(uint8_t byte) = 0;
};
}
17 changes: 5 additions & 12 deletions Tools/GMSInfo/include/PRP/PRP.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#pragma once

#include <IGameEntity.h>
#include <PRP/PRPTreeNode.h>

#include <PRP/PRPTypes.h>

#include <BinaryWalker.h>
#include <BinaryWalkerADL.h>

#include <string>
#include <vector>

namespace ReGlacier
{
struct DictNode;

class PRP : public IGameEntity
{
public:
Expand All @@ -20,14 +22,5 @@ namespace ReGlacier

bool Load() override;
void PrintInfo() override;

private:
void TryToDecompileEntities(std::unique_ptr<uint8_t[]>&& buffer, size_t bufferSize);

private:
int m_keysCount { 0 };
int m_valuesOffset { 0 };
std::vector<std::string> m_keys {};
PRPTreeNode* m_tree { nullptr };
};
}
29 changes: 29 additions & 0 deletions Tools/GMSInfo/include/PRP/PRPADL.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include <PRP/PRPTypes.h>

#include <BinaryWalker.h>
#include <BinaryWalkerADL.h>

namespace ReGlacier
{
template <>
struct BinaryWalkerADL<SPRP>
{
static void Read(const BinaryWalker& binaryWalker, SPRP& value)
{
binaryWalker.ReadArray<char>(&value.magic[0], SPRP::kMagicSize);
value.bIsRaw = static_cast<bool>(binaryWalker.ReadUInt8());
value.bFlags = binaryWalker.ReadUInt32();
value.__Unknown__ = binaryWalker.ReadUInt32();
value.totalKeysCount = binaryWalker.ReadUInt32();
value.dataOffset = binaryWalker.ReadUInt32();
}

static void Write(BinaryWalker& binaryWalker, const SPRP& value)
{
spdlog::error("NOT IMPLEMENTED");
assert(false);
}
};
}
47 changes: 0 additions & 47 deletions Tools/GMSInfo/include/PRP/PRPTreeNode.h

This file was deleted.

49 changes: 39 additions & 10 deletions Tools/GMSInfo/include/PRP/PRPTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,40 @@

namespace ReGlacier
{
#pragma pack(push, 1)
struct SPRP
{
static constexpr size_t kMagicSize = 0xE;

char magic[kMagicSize]; //0x0
bool bIsRaw; //0xE
uint32_t bFlags; //0xF
uint32_t __Unknown__; //0x13;
uint32_t totalKeysCount; //0x17
uint32_t dataOffset; //0x1B
};
#pragma pack(pop)

using PRPToken = uint32_t;

struct ZToken
{
static constexpr PRPToken Void = 0x0FFFFFFFF;
static constexpr PRPToken Unknown = 0x0FFFFFFFE;
static constexpr PRPToken Joker = 0x0FFFFFFFD;
};

enum EPropertyType : unsigned int
{
Type_14 = 0xE,
Type_10 = 0xA,
Type_9 = 0x9,
Type_8 = 0x8,
Type_7 = 0x7,
Type_2 = 0x2,
Type_1 = 0x1
};

enum PRP_ETag : uint8_t
{
TAG_Array = 0x1,
Expand All @@ -20,6 +54,8 @@ namespace ReGlacier
TAG_Float64 = 0xB,
TAG_String = 0xC,
TAG_RawData = 0xD,
TAG_StringOrArray_E = 0xE,
TAG_StringArray = 0xF,
TAG_Bitfield = 0x10,
TAG_EndArray = 0x7C,
TAG_SkipMark = 0x7D,
Expand All @@ -38,16 +74,9 @@ namespace ReGlacier
TAG_NamedFloat64 = 0x8B,
TAG_NamedString = 0x8C,
TAG_NamedRawData = 0x8D,
TAG_StringOrArray_8E = 0x8E,
TAG_NameBitfield = 0x8F,
TAG_UNKNOWN, //14,16-123,128,142
NO_TAG
};

struct PRP_ETag_Helpers
{
static PRP_ETag FromByte(uint8_t byte);
static std::string_view ToString(PRP_ETag tag);
static bool IsTagIncreaseDepthLevel(PRP_ETag tag);
static bool IsTagDecreateDepthLevel(PRP_ETag tag);
TAG_UNKNOWN, //16-123,128,142
NO_TAG,
};
}
Loading