mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Merge pull request #9242 from lioncash/disc-panic
DiscIO: Make use of fmt-capable panic alerts
This commit is contained in:
commit
93212049ac
@ -8,7 +8,6 @@
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <cinttypes>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
@ -84,7 +83,7 @@ u64 CompressedBlobReader::GetBlockCompressedSize(u64 block_num) const
|
||||
else if (block_num == m_header.num_blocks - 1)
|
||||
return m_header.compressed_data_size - start;
|
||||
else
|
||||
PanicAlert("GetBlockCompressedSize - illegal block number %i", (int)block_num);
|
||||
PanicAlertFmt("{} - illegal block number {}", __func__, block_num);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -97,7 +96,7 @@ bool CompressedBlobReader::GetBlock(u64 block_num, u8* out_ptr)
|
||||
if (offset & (1ULL << 63))
|
||||
{
|
||||
if (comp_block_size != m_header.block_size)
|
||||
PanicAlert("Uncompressed block with wrong size");
|
||||
PanicAlertFmt("Uncompressed block with wrong size");
|
||||
uncompressed = true;
|
||||
offset &= ~(1ULL << 63);
|
||||
}
|
||||
@ -108,18 +107,19 @@ bool CompressedBlobReader::GetBlock(u64 block_num, u8* out_ptr)
|
||||
m_file.Seek(offset, SEEK_SET);
|
||||
if (!m_file.ReadBytes(m_zlib_buffer.data(), comp_block_size))
|
||||
{
|
||||
PanicAlertT("The disc image \"%s\" is truncated, some of the data is missing.",
|
||||
m_file_name.c_str());
|
||||
PanicAlertFmtT("The disc image \"{}\" is truncated, some of the data is missing.", m_file_name);
|
||||
m_file.Clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
// First, check hash.
|
||||
u32 block_hash = Common::HashAdler32(m_zlib_buffer.data(), comp_block_size);
|
||||
const u32 block_hash = Common::HashAdler32(m_zlib_buffer.data(), comp_block_size);
|
||||
if (block_hash != m_hashes[block_num])
|
||||
PanicAlertT("The disc image \"%s\" is corrupt.\n"
|
||||
"Hash of block %" PRIu64 " is %08x instead of %08x.",
|
||||
m_file_name.c_str(), block_num, block_hash, m_hashes[block_num]);
|
||||
{
|
||||
PanicAlertFmtT("The disc image \"{}\" is corrupt.\n"
|
||||
"Hash of block {} is {:08x} instead of {:08x}.",
|
||||
m_file_name, block_num, block_hash, m_hashes[block_num]);
|
||||
}
|
||||
|
||||
if (uncompressed)
|
||||
{
|
||||
@ -132,7 +132,7 @@ bool CompressedBlobReader::GetBlock(u64 block_num, u8* out_ptr)
|
||||
z.avail_in = comp_block_size;
|
||||
if (z.avail_in > m_header.block_size)
|
||||
{
|
||||
PanicAlert("We have a problem");
|
||||
PanicAlertFmt("We have a problem");
|
||||
}
|
||||
z.next_out = out_ptr;
|
||||
z.avail_out = m_header.block_size;
|
||||
@ -143,12 +143,12 @@ bool CompressedBlobReader::GetBlock(u64 block_num, u8* out_ptr)
|
||||
{
|
||||
// this seem to fire wrongly from time to time
|
||||
// to be sure, don't use compressed isos :P
|
||||
PanicAlert("Failure reading block %" PRIu64 " - out of data and not at end.", block_num);
|
||||
PanicAlertFmt("Failure reading block {} - out of data and not at end.", block_num);
|
||||
}
|
||||
inflateEnd(&z);
|
||||
if (uncomp_size != m_header.block_size)
|
||||
{
|
||||
PanicAlert("Wrong block size");
|
||||
PanicAlertFmt("Wrong block size");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -276,10 +276,11 @@ bool ConvertToGCZ(BlobReader* infile, const std::string& infile_path,
|
||||
File::IOFile outfile(outfile_path, "wb");
|
||||
if (!outfile)
|
||||
{
|
||||
PanicAlertT("Failed to open the output file \"%s\".\n"
|
||||
"Check that you have permissions to write the target folder and that the media can "
|
||||
"be written.",
|
||||
outfile_path.c_str());
|
||||
PanicAlertFmtT(
|
||||
"Failed to open the output file \"{}\".\n"
|
||||
"Check that you have permissions to write the target folder and that the media can "
|
||||
"be written.",
|
||||
outfile_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -367,13 +368,13 @@ bool ConvertToGCZ(BlobReader* infile, const std::string& infile_path,
|
||||
}
|
||||
|
||||
if (result == ConversionResultCode::ReadFailed)
|
||||
PanicAlertT("Failed to read from the input file \"%s\".", infile_path.c_str());
|
||||
PanicAlertFmtT("Failed to read from the input file \"{}\".", infile_path);
|
||||
|
||||
if (result == ConversionResultCode::WriteFailed)
|
||||
{
|
||||
PanicAlertT("Failed to write the output file \"%s\".\n"
|
||||
"Check that you have enough space available on the target drive.",
|
||||
outfile_path.c_str());
|
||||
PanicAlertFmtT("Failed to write the output file \"{}\".\n"
|
||||
"Check that you have enough space available on the target drive.",
|
||||
outfile_path);
|
||||
}
|
||||
|
||||
return result == ConversionResultCode::Success;
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cinttypes>
|
||||
#include <cstring>
|
||||
#include <locale>
|
||||
#include <map>
|
||||
|
@ -146,7 +146,7 @@ bool DriveReader::ReadMultipleAlignedBlocks(u64 block_num, u64 num_blocks, u8* o
|
||||
!ReadFile(m_disc_handle, out_ptr, static_cast<DWORD>(GetSectorSize() * num_blocks),
|
||||
&bytes_read, nullptr))
|
||||
{
|
||||
PanicAlertT("Disc Read Error");
|
||||
PanicAlertFmtT("Disc Read Error");
|
||||
return false;
|
||||
}
|
||||
return bytes_read == GetSectorSize() * num_blocks;
|
||||
|
@ -49,10 +49,11 @@ bool ConvertToPlain(BlobReader* infile, const std::string& infile_path,
|
||||
File::IOFile outfile(outfile_path, "wb");
|
||||
if (!outfile)
|
||||
{
|
||||
PanicAlertT("Failed to open the output file \"%s\".\n"
|
||||
"Check that you have permissions to write the target folder and that the media can "
|
||||
"be written.",
|
||||
outfile_path.c_str());
|
||||
PanicAlertFmtT(
|
||||
"Failed to open the output file \"{}\".\n"
|
||||
"Check that you have permissions to write the target folder and that the media can "
|
||||
"be written.",
|
||||
outfile_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -89,15 +90,15 @@ bool ConvertToPlain(BlobReader* infile, const std::string& infile_path,
|
||||
const u64 sz = std::min(buffer_size, infile->GetDataSize() - inpos);
|
||||
if (!infile->Read(inpos, sz, buffer.data()))
|
||||
{
|
||||
PanicAlertT("Failed to read from the input file \"%s\".", infile_path.c_str());
|
||||
PanicAlertFmtT("Failed to read from the input file \"{}\".", infile_path);
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
if (!outfile.WriteBytes(buffer.data(), sz))
|
||||
{
|
||||
PanicAlertT("Failed to write the output file \"%s\".\n"
|
||||
"Check that you have enough space available on the target drive.",
|
||||
outfile_path.c_str());
|
||||
PanicAlertFmtT("Failed to write the output file \"{}\".\n"
|
||||
"Check that you have enough space available on the target drive.",
|
||||
outfile_path);
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <algorithm>
|
||||
#include <cinttypes>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <locale>
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cinttypes>
|
||||
#include <cstring>
|
||||
|
||||
#include <fmt/format.h>
|
||||
@ -60,7 +59,7 @@ bool NANDImporter::ReadNANDBin(const std::string& path_to_bin,
|
||||
const u64 image_size = file.GetSize();
|
||||
if (image_size != NAND_BIN_SIZE + NAND_KEYS_SIZE && image_size != NAND_BIN_SIZE)
|
||||
{
|
||||
PanicAlertT("This file does not look like a BootMii NAND backup.");
|
||||
PanicAlertFmtT("This file does not look like a BootMii NAND backup.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -273,6 +272,6 @@ void NANDImporter::ExportKeys(const std::string& nand_root)
|
||||
const std::string file_path = nand_root + "/keys.bin";
|
||||
File::IOFile file(file_path, "wb");
|
||||
if (!file.WriteBytes(m_nand_keys.data(), NAND_KEYS_SIZE))
|
||||
PanicAlertT("Unable to write to file %s", file_path.c_str());
|
||||
PanicAlertFmtT("Unable to write to file {}", file_path);
|
||||
}
|
||||
} // namespace DiscIO
|
||||
|
@ -312,11 +312,11 @@ std::vector<RedumpVerifier::PotentialMatch> RedumpVerifier::ScanDatfile(const st
|
||||
// so show a panic alert rather than just using ERROR_LOG
|
||||
|
||||
// i18n: "Serial" refers to serial numbers, e.g. RVL-RSBE-USA
|
||||
PanicAlertT("Serial and/or version data is missing from %s\n"
|
||||
"Please append \"%s\" (without the quotes) to the datfile URL when downloading\n"
|
||||
"Example: %s",
|
||||
GetPathForSystem(system).c_str(), "serial,version",
|
||||
"http://redump.org/datfile/gc/serial,version");
|
||||
PanicAlertFmtT("Serial and/or version data is missing from {}\n"
|
||||
"Please append \"{}\" (without the quotes) to the datfile URL when downloading\n"
|
||||
"Example: {}",
|
||||
GetPathForSystem(system), "serial,version",
|
||||
"http://redump.org/datfile/gc/serial,version");
|
||||
m_result = {Status::Error, Common::GetStringT("Failed to parse Redump.org data")};
|
||||
return {};
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ VolumeWii::VolumeWii(std::unique_ptr<BlobReader> reader)
|
||||
{
|
||||
// This check is normally done by ES in ES_DiVerify, but that would happen too late
|
||||
// (after allocating the buffer), so we do the check here.
|
||||
PanicAlert("Invalid TMD size");
|
||||
PanicAlertFmt("Invalid TMD size");
|
||||
return INVALID_TMD;
|
||||
}
|
||||
std::vector<u8> tmd_buffer(*tmd_size);
|
||||
|
@ -2032,10 +2032,11 @@ bool ConvertToWIAOrRVZ(BlobReader* infile, const std::string& infile_path,
|
||||
File::IOFile outfile(outfile_path, "wb");
|
||||
if (!outfile)
|
||||
{
|
||||
PanicAlertT("Failed to open the output file \"%s\".\n"
|
||||
"Check that you have permissions to write the target folder and that the media can "
|
||||
"be written.",
|
||||
outfile_path.c_str());
|
||||
PanicAlertFmtT(
|
||||
"Failed to open the output file \"{}\".\n"
|
||||
"Check that you have permissions to write the target folder and that the media can "
|
||||
"be written.",
|
||||
outfile_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2047,13 +2048,13 @@ bool ConvertToWIAOrRVZ(BlobReader* infile, const std::string& infile_path,
|
||||
chunk_size, callback);
|
||||
|
||||
if (result == ConversionResultCode::ReadFailed)
|
||||
PanicAlertT("Failed to read from the input file \"%s\".", infile_path.c_str());
|
||||
PanicAlertFmtT("Failed to read from the input file \"{}\".", infile_path);
|
||||
|
||||
if (result == ConversionResultCode::WriteFailed)
|
||||
{
|
||||
PanicAlertT("Failed to write the output file \"%s\".\n"
|
||||
"Check that you have enough space available on the target drive.",
|
||||
outfile_path.c_str());
|
||||
PanicAlertFmtT("Failed to write the output file \"{}\".\n"
|
||||
"Check that you have enough space available on the target drive.",
|
||||
outfile_path);
|
||||
}
|
||||
|
||||
if (result != ConversionResultCode::Success)
|
||||
|
@ -166,7 +166,7 @@ File::IOFile& WbfsFileReader::SeekToCluster(u64 offset, u64* available)
|
||||
}
|
||||
}
|
||||
|
||||
PanicAlert("Read beyond end of disc");
|
||||
PanicAlertFmt("Read beyond end of disc");
|
||||
if (available)
|
||||
*available = 0;
|
||||
m_files[0].file.Seek(0, SEEK_SET);
|
||||
|
Loading…
Reference in New Issue
Block a user