NetPlayClient: Use fmt::join for MD5Sum
This commit is contained in:
parent
301bc49efe
commit
3d5b46615c
|
@ -2465,7 +2465,6 @@ bool NetPlayClient::DoAllPlayersHaveGame()
|
||||||
|
|
||||||
static std::string MD5Sum(const std::string& file_path, std::function<bool(int)> report_progress)
|
static std::string MD5Sum(const std::string& file_path, std::function<bool(int)> report_progress)
|
||||||
{
|
{
|
||||||
std::string output_string;
|
|
||||||
std::vector<u8> data(8 * 1024 * 1024);
|
std::vector<u8> data(8 * 1024 * 1024);
|
||||||
u64 read_offset = 0;
|
u64 read_offset = 0;
|
||||||
mbedtls_md5_context ctx;
|
mbedtls_md5_context ctx;
|
||||||
|
@ -2479,7 +2478,7 @@ static std::string MD5Sum(const std::string& file_path, std::function<bool(int)>
|
||||||
{
|
{
|
||||||
size_t read_size = std::min(static_cast<u64>(data.size()), game_size - read_offset);
|
size_t read_size = std::min(static_cast<u64>(data.size()), game_size - read_offset);
|
||||||
if (!file->Read(read_offset, read_size, data.data()))
|
if (!file->Read(read_offset, read_size, data.data()))
|
||||||
return output_string;
|
return "";
|
||||||
|
|
||||||
mbedtls_md5_update_ret(&ctx, data.data(), read_size);
|
mbedtls_md5_update_ret(&ctx, data.data(), read_size);
|
||||||
read_offset += read_size;
|
read_offset += read_size;
|
||||||
|
@ -2487,17 +2486,14 @@ static std::string MD5Sum(const std::string& file_path, std::function<bool(int)>
|
||||||
int progress =
|
int progress =
|
||||||
static_cast<int>(static_cast<float>(read_offset) / static_cast<float>(game_size) * 100);
|
static_cast<int>(static_cast<float>(read_offset) / static_cast<float>(game_size) * 100);
|
||||||
if (!report_progress(progress))
|
if (!report_progress(progress))
|
||||||
return output_string;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<u8, 16> output;
|
std::array<u8, 16> output;
|
||||||
mbedtls_md5_finish_ret(&ctx, output.data());
|
mbedtls_md5_finish_ret(&ctx, output.data());
|
||||||
|
|
||||||
// Convert to hex
|
// Convert to hex
|
||||||
for (u8 n : output)
|
return fmt::format("{:02x}", fmt::join(output, ""));
|
||||||
output_string += fmt::format("{:02x}", n);
|
|
||||||
|
|
||||||
return output_string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetPlayClient::ComputeMD5(const SyncIdentifier& sync_identifier)
|
void NetPlayClient::ComputeMD5(const SyncIdentifier& sync_identifier)
|
||||||
|
|
Loading…
Reference in New Issue