Skip to content

Commit

Permalink
feat: working es parser
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed Jan 17, 2022
1 parent 47e0441 commit ee5271e
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 24 deletions.
6 changes: 5 additions & 1 deletion Code/es_loader/ESLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ void ESLoader::LoadFiles()
{
climateData.push_back(climate.second->ParseChunks());
}
spdlog::info("refrData count: {}", climateData.size());
spdlog::info("climateData count: {}", climateData.size());
for (auto& climate : climateData)
{
spdlog::info("Climate: {}", climate.m_editorId);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions Code/es_loader/Records/CLMT.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class CLMT : Record
// EDID
String m_editorId = "";
// WLST
Chunks::WLST m_weatherList;
Chunks::WLST m_weatherList{};
// FNAM
String m_sunTexture = "";
// GNAM
String m_glareTexture = "";
//TNAM
Chunks::TNAM m_timing;
Chunks::TNAM m_timing{};
};

Data ParseChunks() noexcept;
Expand Down
2 changes: 1 addition & 1 deletion Code/es_loader/Records/CONT.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CONT : Record
// FULL
String m_name = "";
// Objects
Vector<Chunks::CNTO> m_objects;
Vector<Chunks::CNTO> m_objects{};
};

Data ParseChunks() noexcept;
Expand Down
4 changes: 3 additions & 1 deletion Code/es_loader/Records/Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ class Group
Group() = delete;

private:
char m_recordType[4];
uint32_t m_groupSize;
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);
static_assert(sizeof(Group) == 0x18);

class GroupData
{
Expand Down
3 changes: 1 addition & 2 deletions Code/es_loader/Records/REFR.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ class REFR : public Record

struct Data
{
Data() = default;
Chunks::NAME m_basicObject;
Chunks::NAME m_basicObject{};
};

Data ParseChunks() noexcept;
Expand Down
4 changes: 2 additions & 2 deletions Code/es_loader/Records/Record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ void Record::IterateChunks(const std::function<void(ChunkId, Buffer::Reader&)>&
reader.Reverse(4);
}

reader.Advance(dataSize);

// TODO: technically, you shouldn't have to copy, in theory, could just leave out the Advance() above
Buffer::Reader chunk(reader);

reader.Advance(dataSize);

aCallback(pChunk->m_chunkId, chunk);
}
}
Expand Down
1 change: 1 addition & 0 deletions Code/es_loader/TESFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ bool TESFile::ReadGroupOrRecord(Buffer::Reader& aReader) noexcept
aReader.ReadBytes(reinterpret_cast<uint8_t*>(&type), 4);
uint32_t size = 0;
aReader.ReadBytes(reinterpret_cast<uint8_t*>(&size), 4);
aReader.Reverse(8);

if (type == static_cast<uint32_t>(FormEnum::GRUP))
{
Expand Down
16 changes: 1 addition & 15 deletions Code/es_loader/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,7 @@

int main(int argc, char** argv)
{
uint32_t* ints = new uint32_t[4];
ints[0] = 0x50555247;
ints[1] = 0x8;
ints[2] = 0x41414141;
ints[2] = 0x42424242;
Buffer buffer;
buffer.Resize(0x10);
memcpy(buffer.GetWriteData(), ints, 0x10);
Buffer::Reader reader(&buffer);
uint32_t type = 0;
reader.ReadBytes(reinterpret_cast<uint8_t*>(&type), 4);
uint32_t size = 0;
reader.ReadBytes(reinterpret_cast<uint8_t*>(&size), 4);

//ESLoader loader("Data\\");
ESLoader loader("Data\\");

spdlog::info("Build file list succeeded.");

Expand Down

0 comments on commit ee5271e

Please sign in to comment.