Skip to content

Commit

Permalink
feat: chunk sorting and parsing on REFR records
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed Jan 13, 2022
1 parent 173e3ee commit 8c196f5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
18 changes: 17 additions & 1 deletion Code/es_loader/ESLoader.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "ESLoader.h"

#include <filesystem>

#include <Records/REFR.h>

namespace fs = std::filesystem;

ESLoader::ESLoader(String aDirectory)
Expand Down Expand Up @@ -64,7 +67,20 @@ void ESLoader::LoadFiles()
{
for (const auto& filename : m_esmFilenames)
{
m_standardPlugins.push_back(TESFile(filename));
if (filename.filename().string() != "Skyrim.esm")
continue;

//m_standardPlugins.push_back(TESFile(filename));
TESFile skyrimEsm(filename);

const Vector<REFR*>& refs = skyrimEsm.GetObjectReferences();

Vector<REFR::Data> refrData;
for (REFR* ref : refs)
{
refrData.push_back(ref->ParseChunks());
}
spdlog::info("refrData count: {}", refrData.size());
}
}

Expand Down
6 changes: 4 additions & 2 deletions Code/es_loader/TESFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <fstream>

#include "Records/Record.h"
#include "Records/REFR.h"

TESFile::TESFile(const std::filesystem::path& acPath)
{
Expand Down Expand Up @@ -66,8 +67,9 @@ bool TESFile::ReadGroupOrRecord(Buffer::Reader& aReader) noexcept
switch (record->GetType())
{
case FormEnum::REFR:
case FormEnum::ACHR:
m_objectReferences.push_back(record);
//case FormEnum::ACHR:
REFR* recordREFR = reinterpret_cast<REFR*>(record);
m_objectReferences[record->GetFormId()] = recordREFR;
break;
case FormEnum::CELL:
m_cells.push_back(record);
Expand Down
8 changes: 7 additions & 1 deletion Code/es_loader/TESFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <Records/Group.h>

class Record;
class REFR;

class TESFile
{
Expand All @@ -25,6 +26,11 @@ class TESFile

template<class T> Vector<T> GetRecords() noexcept;

const Vector<REFR*>& GetObjectReferences() const noexcept
{
return m_objectReferences;
}

private:
void BuildFormIdRecordMap() noexcept;
bool ReadGroupOrRecord(Buffer::Reader& aReader) noexcept;
Expand All @@ -40,6 +46,6 @@ class TESFile
uint16_t m_liteId;
};

Vector<Record*> m_objectReferences;
Map<uint32_t, REFR*> m_objectReferences;
Vector<Record*> m_cells;
};

0 comments on commit 8c196f5

Please sign in to comment.