Add case parameter to FormatArrayAsHex
Use upper case where needed for vanilla compatibility
This commit is contained in:
@@ -54,7 +54,7 @@ static std::string CalculateHashV1(const std::string &filename)
|
||||
fclose(f);
|
||||
|
||||
crypto_blake2b_final(&ctx, digest.data());
|
||||
return FormatArrayAsHex(digest);
|
||||
return FormatArrayAsHex(digest, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ static bool ValidateChecksum(const std::string &filename, const std::string &che
|
||||
return false;
|
||||
}
|
||||
if (calculated_hash != hash) {
|
||||
Debug(misc, 0, "Failed to validate signature: checksum mismatch for: {}", filename);
|
||||
Debug(misc, 0, "Failed to validate signature: checksum mismatch for: {}, {}, {}", filename, calculated_hash, hash);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -210,14 +210,18 @@ const char *str_fix_scc_encoded(char *str, const char *last)
|
||||
* @param data Array to format
|
||||
* @return Converted string.
|
||||
*/
|
||||
std::string FormatArrayAsHex(std::span<const byte> data)
|
||||
std::string FormatArrayAsHex(std::span<const byte> data, bool upper_case)
|
||||
{
|
||||
std::string hex_output;
|
||||
hex_output.resize(data.size() * 2);
|
||||
|
||||
char txt[3];
|
||||
for (uint i = 0; i < data.size(); ++i) {
|
||||
if (upper_case) {
|
||||
seprintf(txt, lastof(txt), "%02X", data[i]);
|
||||
} else {
|
||||
seprintf(txt, lastof(txt), "%02x", data[i]);
|
||||
}
|
||||
hex_output[i * 2] = txt[0];
|
||||
hex_output[(i * 2) + 1] = txt[1];
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@ int CDECL vseprintf(char *str, const char *last, const char *format, va_list ap)
|
||||
std::string CDECL stdstr_fmt(const char *str, ...) WARN_FORMAT(1, 2);
|
||||
std::string stdstr_vfmt(const char *str, va_list va) WARN_FORMAT(1, 0);
|
||||
|
||||
std::string FormatArrayAsHex(std::span<const byte> data);
|
||||
std::string FormatArrayAsHex(std::span<const byte> data, bool upper_case = false);
|
||||
|
||||
char *StrMakeValidInPlace(char *str, const char *last, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK) NOACCESS(2);
|
||||
[[nodiscard]] std::string StrMakeValid(std::string_view str, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK);
|
||||
|
@@ -324,7 +324,7 @@ void SurveyGrfs(nlohmann::json &survey)
|
||||
auto grfid = fmt::format("{:08x}", BSWAP32(c->ident.grfid));
|
||||
auto &grf = survey[grfid];
|
||||
|
||||
grf["md5sum"] = FormatArrayAsHex(c->ident.md5sum);
|
||||
grf["md5sum"] = FormatArrayAsHex(c->ident.md5sum, true);
|
||||
grf["status"] = c->status;
|
||||
|
||||
if ((c->palette & GRFP_GRF_MASK) == GRFP_GRF_UNSET) grf["palette"] = "unset";
|
||||
|
Reference in New Issue
Block a user