Skip to content

Commit

Permalink
feat: parse group headers
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed Jan 13, 2022
1 parent 1d24e96 commit 46eb291
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
16 changes: 16 additions & 0 deletions Code/es_loader/Records/Group.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

class Group
{
Group() = delete;

private:
char m_label[4];
int32_t m_groupType;
uint16_t m_formVersion;
uint16_t m_versionControl;
uint32_t m_unk;
};

static_assert(sizeof(Group) == 0x10);

7 changes: 3 additions & 4 deletions Code/es_loader/Records/Record.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ class Record
uint32_t m_dataSize;
uint32_t m_flags;
uint32_t m_formId;
uint16_t m_timestamp;
uint16_t m_versionInfo;
uint16_t m_internalVersion;
uint16_t m_unk;
uint32_t m_versionControl;
uint16_t m_formVersion;
uint16_t m_vcVersion;
};

static_assert(sizeof(Record) == 0x18);
Expand Down
19 changes: 19 additions & 0 deletions Code/es_loader/TESFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <filesystem>
#include <fstream>

#include "Records/Group.h"

TESFile::TESFile(const std::filesystem::path& acPath)
{
m_filename = acPath.filename().string();
Expand All @@ -18,6 +20,23 @@ TESFile::TESFile(const std::filesystem::path& acPath)

void TESFile::BuildFormIdRecordMap() noexcept
{
// TODO: I changed TiltedCore locally to expose GetBytePosition() publicly
Buffer::Reader reader(&m_buffer);

while (!reader.Eof())
{
uint32_t type = Serialization::ReadVarInt(reader) & 0xFFFFFFFF;
uint32_t size = Serialization::ReadVarInt(reader) & 0xFFFFFFFF;

if (type == 0x50555247) // GRUP
{
const Group* pGroup = reinterpret_cast<const Group*>(m_buffer.GetData() + reader.GetBytePosition());
}
else
{

}
}
}

template<class T>
Expand Down
2 changes: 2 additions & 0 deletions Code/es_loader/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
#include <TiltedCore/Filesystem.hpp>
#include <TiltedCore/Stl.hpp>
#include <TiltedCore/Buffer.hpp>
#include <TiltedCore/Serialization.hpp>

#include <spdlog/spdlog.h>

using namespace TiltedPhoques;
using TiltedPhoques::Serialization;

0 comments on commit 46eb291

Please sign in to comment.