libeuropa/io/pak: Rename ReadData_Impl() to better reflect its purpose

Also remove the `version` field from `pak::Reader`. It was never actually used.
This commit is contained in:
Lily Tsuru 2025-01-16 02:23:52 -05:00
parent 3d41ba7e6c
commit ab496ed4aa
2 changed files with 7 additions and 11 deletions

View file

@ -42,21 +42,18 @@ namespace europa::io::pak {
MapType& GetFiles(); MapType& GetFiles();
const MapType& GetFiles() const; const MapType& GetFiles() const;
// implement in cpp later, lazy and just wanna get this out :vvv
const structs::PakHeaderVariant& GetHeader() const { const structs::PakHeaderVariant& GetHeader() const {
return header; return header;
} }
private: private:
template <class T> template <class T>
void ReadData_Impl(); void ReadHeaderAndTOCImpl();
std::istream& stream; std::istream& stream;
bool invalid { false }; bool invalid { false };
structs::PakVersion version;
structs::PakHeaderVariant header {}; structs::PakHeaderVariant header {};
MapType files; MapType files;
}; };

View file

@ -23,7 +23,7 @@ namespace europa::io::pak {
} }
template <class T> template <class T>
void Reader::ReadData_Impl() { void Reader::ReadHeaderAndTOCImpl() {
auto header_type = impl::ReadStreamType<T>(stream); auto header_type = impl::ReadStreamType<T>(stream);
if(!header_type.Valid()) { if(!header_type.Valid()) {
@ -41,9 +41,8 @@ namespace europa::io::pak {
auto filename = impl::ReadPString(stream); auto filename = impl::ReadPString(stream);
auto file = File {}; auto file = File {};
if constexpr(std::is_same_v<T, structs::PakHeader_V5>) { if constexpr(std::is_same_v<T, structs::PakHeader_V5>) {
// Version 5 supports sector aligned packages which have an additional field in them // Version 5 supports sector aligned packages, which have an additional field in them
// so we need to handle it here // (the start LBA of the file), so we need to handle that here.
// (not feeling quite as hot about all the crazy template magic here anymore)
if(header_type.sectorAlignedFlag) { if(header_type.sectorAlignedFlag) {
file.InitWithExistingTocEntry(impl::ReadStreamType<typename T::TocEntry_SectorAligned>(stream)); file.InitWithExistingTocEntry(impl::ReadStreamType<typename T::TocEntry_SectorAligned>(stream));
} else { } else {
@ -65,13 +64,13 @@ namespace europa::io::pak {
switch(commonHeader.version) { switch(commonHeader.version) {
case structs::PakVersion::Ver3: case structs::PakVersion::Ver3:
ReadData_Impl<structs::PakHeader_V3>(); ReadHeaderAndTOCImpl<structs::PakHeader_V3>();
break; break;
case structs::PakVersion::Ver4: case structs::PakVersion::Ver4:
ReadData_Impl<structs::PakHeader_V4>(); ReadHeaderAndTOCImpl<structs::PakHeader_V4>();
break; break;
case structs::PakVersion::Ver5: case structs::PakVersion::Ver5:
ReadData_Impl<structs::PakHeader_V5>(); ReadHeaderAndTOCImpl<structs::PakHeader_V5>();
break; break;
default: default:
return; return;