Change FormatArrayAsHex to be uppercase by default

To match upstream
pull/695/head
Jonathan G Rennison 3 weeks ago
parent 48910a8b7d
commit 88d7be1d99

@ -1180,7 +1180,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32_t p1, uint32_t p2, uint64_
std::vector<uint8_t> buffer;
CommandSerialisationBuffer serialiser(buffer, SHRT_MAX);
aux_data->Serialise(serialiser);
aux_str = FormatArrayAsHex(buffer);
aux_str = FormatArrayAsHex(buffer, false);
}
std::string text_buf;
if (text != nullptr) {

@ -219,7 +219,7 @@ std::string GenerateCompanyPasswordHash(const std::string &password, const std::
checksum.Append(salted_password_string.data(), salted_password_string.size());
checksum.Finish(digest);
return FormatArrayAsHex(digest);
return FormatArrayAsHex(digest, false);
}
/**
@ -1375,7 +1375,7 @@ std::string NetworkGenerateRandomKeyString(uint bytes)
uint8_t *key = AllocaM(uint8_t, bytes);
RandomBytesWithFallback({ key, bytes });
return FormatArrayAsHex({key, bytes});
return FormatArrayAsHex({key, bytes}, false);
}
/** This tries to launch the network for a given OS */

@ -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 uint8_t> data, bool upper_case = false);
std::string FormatArrayAsHex(std::span<const uint8_t> data, bool upper_case = true);
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);

@ -341,7 +341,9 @@ TEST_CASE("FormatArrayAsHex")
{
CHECK(FormatArrayAsHex(std::array<uint8_t, 0>{}) == "");
CHECK(FormatArrayAsHex(std::array<uint8_t, 1>{0x12}) == "12");
CHECK(FormatArrayAsHex(std::array<uint8_t, 4>{0x13, 0x38, 0x42, 0xAF}) == "133842af");
CHECK(FormatArrayAsHex(std::array<uint8_t, 4>{0x13, 0x38, 0x42, 0xAF}) == "133842AF");
CHECK(FormatArrayAsHex(std::array<uint8_t, 4>{0x13, 0x38, 0x42, 0xAF}, true) == "133842AF");
CHECK(FormatArrayAsHex(std::array<uint8_t, 4>{0x13, 0x38, 0x42, 0xAF}, false) == "133842af");
}
TEST_CASE("ConvertHexToBytes")

Loading…
Cancel
Save