mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
chore: do not fail upon failure to find ipak file
This commit is contained in:
parent
9097db7d0f
commit
ca761dfdbc
@ -50,9 +50,7 @@ namespace
|
|||||||
GoTo(sizeof(IPakHeader) + sizeof(IPakSection) * SECTION_COUNT);
|
GoTo(sizeof(IPakHeader) + sizeof(IPakSection) * SECTION_COUNT);
|
||||||
AlignToChunk();
|
AlignToChunk();
|
||||||
|
|
||||||
if (!WriteDataSection())
|
WriteDataSection();
|
||||||
return false;
|
|
||||||
|
|
||||||
WriteIndexSection();
|
WriteIndexSection();
|
||||||
WriteBrandingSection();
|
WriteBrandingSection();
|
||||||
WriteFileEnding();
|
WriteFileEnding();
|
||||||
@ -142,7 +140,7 @@ namespace
|
|||||||
const auto openFile = m_search_path.Open(fileName);
|
const auto openFile = m_search_path.Open(fileName);
|
||||||
if (!openFile.IsOpen())
|
if (!openFile.IsOpen())
|
||||||
{
|
{
|
||||||
std::cerr << std::format("Could not open image for writing to IPak \"{}\"\n", fileName);
|
std::cerr << std::format("Failed to open file for ipak: {}\n", fileName);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,12 +272,12 @@ namespace
|
|||||||
m_chunk_buffer_window_start = utils::AlignToPrevious(m_current_offset, static_cast<int64_t>(ipak_consts::IPAK_CHUNK_SIZE));
|
m_chunk_buffer_window_start = utils::AlignToPrevious(m_current_offset, static_cast<int64_t>(ipak_consts::IPAK_CHUNK_SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WriteImageData(const std::string& imageName)
|
void WriteImageData(const std::string& imageName)
|
||||||
{
|
{
|
||||||
size_t imageSize;
|
size_t imageSize;
|
||||||
const auto imageData = ReadImageDataFromSearchPath(imageName, imageSize);
|
const auto imageData = ReadImageDataFromSearchPath(imageName, imageSize);
|
||||||
if (!imageData)
|
if (!imageData)
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
const auto nameHash = T6::Common::R_HashString(imageName.c_str(), 0);
|
const auto nameHash = T6::Common::R_HashString(imageName.c_str(), 0);
|
||||||
const auto dataHash = static_cast<unsigned>(crc32(0u, reinterpret_cast<const Bytef*>(imageData.get()), imageSize));
|
const auto dataHash = static_cast<unsigned>(crc32(0u, reinterpret_cast<const Bytef*>(imageData.get()), imageSize));
|
||||||
@ -297,11 +295,9 @@ namespace
|
|||||||
|
|
||||||
indexEntry.size = writtenImageSize;
|
indexEntry.size = writtenImageSize;
|
||||||
m_index_entries.emplace_back(indexEntry);
|
m_index_entries.emplace_back(indexEntry);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WriteDataSection()
|
void WriteDataSection()
|
||||||
{
|
{
|
||||||
AlignToChunk();
|
AlignToChunk();
|
||||||
m_data_section_offset = m_current_offset;
|
m_data_section_offset = m_current_offset;
|
||||||
@ -309,16 +305,11 @@ namespace
|
|||||||
|
|
||||||
m_index_entries.reserve(m_images.size());
|
m_index_entries.reserve(m_images.size());
|
||||||
|
|
||||||
const auto result = std::ranges::all_of(m_images,
|
for (const auto& imageName : m_images)
|
||||||
[this](const std::string& imageName)
|
WriteImageData(imageName);
|
||||||
{
|
|
||||||
return WriteImageData(imageName);
|
|
||||||
});
|
|
||||||
|
|
||||||
FlushBlock();
|
FlushBlock();
|
||||||
m_data_section_size = static_cast<size_t>(m_current_offset - m_data_section_offset);
|
m_data_section_size = static_cast<size_t>(m_current_offset - m_data_section_offset);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool CompareIndices(const IPakIndexEntry& entry1, const IPakIndexEntry& entry2)
|
static bool CompareIndices(const IPakIndexEntry& entry1, const IPakIndexEntry& entry2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user