mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-01-14 04:21:51 +00:00
chore: update all logging to use centralized logging component
This commit is contained in:
@@ -2,13 +2,14 @@
|
||||
|
||||
#include "IPakStreamManager.h"
|
||||
#include "ObjContainer/IPak/IPakTypes.h"
|
||||
#include "zlib.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <zlib.h>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
@@ -92,7 +93,7 @@ namespace
|
||||
m_stream->read(reinterpret_cast<char*>(&indexEntry), sizeof(indexEntry));
|
||||
if (m_stream->gcount() != sizeof(indexEntry))
|
||||
{
|
||||
std::cerr << std::format("Unexpected eof when trying to load index entry {}.\n", itemIndex);
|
||||
con::error("Unexpected eof when trying to load index entry {}.", itemIndex);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -115,7 +116,7 @@ namespace
|
||||
m_stream->read(reinterpret_cast<char*>(§ion), sizeof(section));
|
||||
if (m_stream->gcount() != sizeof(section))
|
||||
{
|
||||
std::cerr << "Unexpected eof when trying to load section.\n";
|
||||
con::error("Unexpected eof when trying to load section.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -143,19 +144,19 @@ namespace
|
||||
m_stream->read(reinterpret_cast<char*>(&header), sizeof(header));
|
||||
if (m_stream->gcount() != sizeof(header))
|
||||
{
|
||||
std::cerr << "Unexpected eof when trying to load header.\n";
|
||||
con::error("Unexpected eof when trying to load header.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (header.magic != ipak_consts::IPAK_MAGIC)
|
||||
{
|
||||
std::cerr << std::format("Invalid ipak magic '{:#x}'.\n", header.magic);
|
||||
con::error("Invalid ipak magic '{:#x}'.", header.magic);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (header.version != ipak_consts::IPAK_VERSION)
|
||||
{
|
||||
std::cerr << std::format("Unsupported ipak version '{}'.\n", header.version);
|
||||
con::error("Unsupported ipak version '{}'.", header.version);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -167,13 +168,13 @@ namespace
|
||||
|
||||
if (m_index_section == nullptr)
|
||||
{
|
||||
std::cerr << "IPak does not contain an index section.\n";
|
||||
con::error("IPak does not contain an index section.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_data_section == nullptr)
|
||||
{
|
||||
std::cerr << "IPak does not contain a data section.\n";
|
||||
con::error("IPak does not contain a data section.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "IPakEntryReadStream.h"
|
||||
|
||||
#include "ObjContainer/IPak/IPakTypes.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
@@ -128,7 +129,7 @@ bool IPakEntryReadStream::ValidateBlockHeader(const IPakDataBlockHeader* blockHe
|
||||
{
|
||||
if (blockHeader->countAndOffset.count > 31)
|
||||
{
|
||||
std::cerr << "IPak block has more than 31 commands: " << blockHeader->countAndOffset.count << " -> Invalid\n";
|
||||
con::error("IPak block has more than 31 commands: {} -> Invalid", blockHeader->countAndOffset.count);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -142,7 +143,7 @@ bool IPakEntryReadStream::ValidateBlockHeader(const IPakDataBlockHeader* blockHe
|
||||
// The game uses IPAK_COMMAND_SKIP as value for compressed when it intends to skip the specified amount of data
|
||||
if (blockHeader->commands[currentCommand].compressed == 0 || blockHeader->commands[currentCommand].compressed == 1)
|
||||
{
|
||||
std::cerr << "IPak block offset (" << blockHeader->countAndOffset.offset << ") is not the file head (" << m_file_head << ") -> Invalid\n";
|
||||
con::error("IPak block offset ({}) is not the file head ({}) -> Invalid", blockHeader->countAndOffset.offset, m_file_head);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -167,7 +168,7 @@ bool IPakEntryReadStream::AdjustChunkBufferWindowForBlockHeader(const IPakDataBl
|
||||
{
|
||||
if (requiredChunkCount > IPAK_CHUNK_COUNT_PER_READ)
|
||||
{
|
||||
std::cerr << "IPak block spans over more than " << IPAK_CHUNK_COUNT_PER_READ << " chunks (" << requiredChunkCount << "), which is not supported.\n";
|
||||
con::error("IPak block spans over more than {} chunks ({}), which is not supported.", IPAK_CHUNK_COUNT_PER_READ, requiredChunkCount);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -221,7 +222,7 @@ bool IPakEntryReadStream::ProcessCommand(const size_t commandSize, const int com
|
||||
|
||||
if (result != LZO_E_OK)
|
||||
{
|
||||
std::cerr << "Decompressing block with lzo failed: " << result << "!\n";
|
||||
con::error("Decompressing block with lzo failed: {}!", result);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#include "SoundBank.h"
|
||||
|
||||
#include "zlib.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <zlib.h>
|
||||
|
||||
ObjContainerRepository<SoundBank, Zone> SoundBank::Repository;
|
||||
|
||||
@@ -130,50 +131,50 @@ bool SoundBank::ReadHeader()
|
||||
m_stream->read(reinterpret_cast<char*>(&m_header), sizeof(m_header));
|
||||
if (m_stream->gcount() != sizeof(m_header))
|
||||
{
|
||||
std::cerr << "Unexpected eof when trying to load sndbank header.\n";
|
||||
con::error("Unexpected eof when trying to load sndbank header.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_header.magic != MAGIC)
|
||||
{
|
||||
std::cerr << std::format("Invalid sndbank magic 0x{:x}\n", m_header.magic);
|
||||
con::error("Invalid sndbank magic 0x{:x}", m_header.magic);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_header.version != VERSION)
|
||||
{
|
||||
std::cerr << std::format("Unsupported sndbank version {} (should be {})\n", m_header.version, VERSION);
|
||||
con::error("Unsupported sndbank version {} (should be {})", m_header.version, VERSION);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_header.entrySize != sizeof(SoundAssetBankEntry))
|
||||
{
|
||||
std::cerr << std::format("Invalid sndbank entry size 0x{:x} (should be 0x{:x})\n", m_header.entrySize, sizeof(SoundAssetBankEntry));
|
||||
con::error("Invalid sndbank entry size 0x{:x} (should be 0x{:x})", m_header.entrySize, sizeof(SoundAssetBankEntry));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_header.fileSize != m_file_size)
|
||||
{
|
||||
std::cerr << std::format("Invalid sndbank {} (header expects {})\n", m_file_size, m_header.fileSize);
|
||||
con::error("Invalid sndbank {} (header expects {})", m_file_size, m_header.fileSize);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_header.entryCount
|
||||
&& (m_header.entryOffset <= 0 || m_header.entryOffset + sizeof(SoundAssetBankEntry) * m_header.entryCount > static_cast<size_t>(m_file_size)))
|
||||
{
|
||||
std::cerr << std::format("Invalid sndbank entry offset {} (filesize is {})\n", m_header.entryOffset, m_file_size);
|
||||
con::error("Invalid sndbank entry offset {} (filesize is {})", m_header.entryOffset, m_file_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_header.checksumOffset <= 0 || m_header.checksumOffset + sizeof(SoundAssetBankChecksum) * m_header.entryCount > static_cast<size_t>(m_file_size))
|
||||
{
|
||||
std::cerr << std::format("Invalid sndbank checksum offset {} (filesize is {})\n", m_header.checksumOffset, m_file_size);
|
||||
con::error("Invalid sndbank checksum offset {} (filesize is {})", m_header.checksumOffset, m_file_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_header.dependencyCount * m_header.dependencySize > sizeof(SoundAssetBankHeader::dependencies))
|
||||
{
|
||||
std::cerr << std::format("Invalid sndbank dependency sizes (count is {}; size is {})\n", m_header.dependencyCount, m_header.dependencySize);
|
||||
con::error("Invalid sndbank dependency sizes (count is {}; size is {})", m_header.dependencyCount, m_header.dependencySize);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -202,13 +203,13 @@ bool SoundBank::ReadEntries()
|
||||
|
||||
if (m_stream->gcount() != sizeof(entry))
|
||||
{
|
||||
std::cerr << std::format("Failed to read sound bank entry at index {}\n", i);
|
||||
con::error("Failed to read sound bank entry at index {}", i);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entry.offset == 0 || entry.offset + entry.size >= m_file_size)
|
||||
{
|
||||
std::cerr << std::format("Invalid sound bank entry data offset {} (filesize is {})\n", entry.offset, m_header.fileSize);
|
||||
con::error("Invalid sound bank entry data offset {} (filesize is {})", entry.offset, m_header.fileSize);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -230,7 +231,7 @@ bool SoundBank::ReadChecksums()
|
||||
|
||||
if (m_stream->gcount() != sizeof(checksum))
|
||||
{
|
||||
std::cerr << std::format("Failed to read sound bank checksum at index {}\n", i);
|
||||
con::error("Failed to read sound bank checksum at index {}", i);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "Sound/FlacDecoder.h"
|
||||
#include "Sound/WavTypes.h"
|
||||
#include "Utils/FileUtils.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
#include <cstring>
|
||||
@@ -201,7 +202,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
std::cerr << std::format("Unable to decode .flac file for sound {}\n", filePath);
|
||||
con::error("Unable to decode .flac file for sound {}", filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -238,15 +239,14 @@ public:
|
||||
|
||||
if (!LoadFileByExtension(soundFilePath, sound, soundData, soundSize))
|
||||
{
|
||||
std::cerr << std::format("Unable to find a compatible file for sound {}\n", soundFilePath);
|
||||
con::error("Unable to find a compatible file for sound {}", soundFilePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto lastEntry = m_entries.rbegin();
|
||||
if (!sound.m_streamed && lastEntry->frameRateIndex != 6)
|
||||
{
|
||||
std::cout << std::format("WARNING: Loaded sound \"{}\" should have a framerate of 48000 but doesn't. This sound may not work on all games!\n",
|
||||
soundFilePath);
|
||||
con::warn("Loaded sound \"{}\" should have a framerate of 48000 but doesn't. This sound may not work on all games!", soundFilePath);
|
||||
}
|
||||
|
||||
SoundAssetBankChecksum checksum{};
|
||||
@@ -297,7 +297,7 @@ public:
|
||||
{
|
||||
if (!WriteEntries())
|
||||
{
|
||||
std::cerr << "An error occurred writing the sound bank entries. Please check output.\n";
|
||||
con::error("An error occurred writing the sound bank entries. Please check output.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ public:
|
||||
|
||||
if (m_current_offset > UINT32_MAX)
|
||||
{
|
||||
std::cerr << "Sound bank files must be under 4GB. Please reduce the number of sounds being written!\n";
|
||||
con::error("Sound bank files must be under 4GB. Please reduce the number of sounds being written!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user