Skip to content

Commit

Permalink
feat: store cell records
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed Jan 13, 2022
1 parent 8242b22 commit 8b4021d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Code/es_loader/Records/Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ static_assert(sizeof(Group) == 0x10);
class GroupData
{
public:
Vector<const void*> m_fields;
Vector<const void*> m_subGroups;
};

27 changes: 27 additions & 0 deletions Code/es_loader/Records/Record.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@ enum class FormEnum : uint32_t
GRUP = 0x50555247,
REFR = 0x52464552,
ACHR = 0x52484341,
CELL = 0x4C4C4543,
};

class Record
{
public:
enum FLAGS
{
kMasterFile = 1,
kCompressed = 0x40000,
kIgnored = 0x1000,
kIsMarker = 0x800000,
};

Record() = delete;

[[nodiscard]] FormEnum GetType() const noexcept
Expand All @@ -30,6 +39,24 @@ class Record
return m_flags;
}

[[nodiscard]] bool Compressed() const noexcept
{
return (m_flags & FLAGS::kCompressed) != 0;
}
[[nodiscard]] bool Ignored() const noexcept
{
return (m_flags & FLAGS::kIgnored) != 0;
}
[[nodiscard]] bool Master() const noexcept
{
return (m_flags & FLAGS::kMasterFile) != 0;
}

[[nodiscard]] bool DefaultForm() const noexcept
{
return m_formId - 1 <= 0x7FE;
}

private:
FormEnum m_formType;
uint32_t m_dataSize;
Expand Down
7 changes: 5 additions & 2 deletions Code/es_loader/TESFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ bool TESFile::ReadGroupOrRecord(Buffer::Reader& aReader) noexcept

while (aReader.GetBytePosition() < endOfGroup)
{
const uint8_t* field = m_buffer.GetData() + aReader.GetBytePosition();
const uint8_t* subGroup = m_buffer.GetData() + aReader.GetBytePosition();
if (ReadGroupOrRecord(aReader))
{
data.m_fields.push_back(field);
data.m_subGroups.push_back(subGroup);
}
}

Expand All @@ -69,6 +69,9 @@ bool TESFile::ReadGroupOrRecord(Buffer::Reader& aReader) noexcept
case FormEnum::ACHR:
m_objectReferences.push_back(record);
break;
case FormEnum::CELL:
m_cells.push_back(record);
break;
}

aReader.Advance(sizeof(Record) + size);
Expand Down
1 change: 1 addition & 0 deletions Code/es_loader/TESFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ class TESFile
};

Vector<Record*> m_objectReferences;
Vector<Record*> m_cells;
};

0 comments on commit 8b4021d

Please sign in to comment.