mirror of https://github.com/OpenTTD/OpenTTD.git
Cleanup: remove MD5SumToString in lieu of FormatArrayAsHex
This commit is contained in:
parent
d9a04ba446
commit
acec34a0fe
|
@ -1899,7 +1899,7 @@ static void OutputContentState(const ContentInfo *const ci)
|
|||
static const char * const states[] = { "Not selected", "Selected", "Dep Selected", "Installed", "Unknown" };
|
||||
static const TextColour state_to_colour[] = { CC_COMMAND, CC_INFO, CC_INFO, CC_WHITE, CC_ERROR };
|
||||
|
||||
IConsolePrint(state_to_colour[ci->state], "{}, {}, {}, {}, {:08X}, {}", ci->id, types[ci->type - 1], states[ci->state], ci->name, ci->unique_id, MD5SumToString(ci->md5sum));
|
||||
IConsolePrint(state_to_colour[ci->state], "{}, {}, {}, {}, {:08X}, {}", ci->id, types[ci->type - 1], states[ci->state], ci->name, ci->unique_id, FormatArrayAsHex(ci->md5sum));
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConContent)
|
||||
|
|
|
@ -109,7 +109,7 @@ void Gamelog::Reset()
|
|||
static void AddGrfInfo(std::back_insert_iterator<std::string> &output_iterator, uint32_t grfid, const MD5Hash *md5sum, const GRFConfig *gc)
|
||||
{
|
||||
if (md5sum != nullptr) {
|
||||
fmt::format_to(output_iterator, "GRF ID {:08X}, checksum {}", BSWAP32(grfid), MD5SumToString(*md5sum));
|
||||
fmt::format_to(output_iterator, "GRF ID {:08X}, checksum {}", BSWAP32(grfid), FormatArrayAsHex(*md5sum));
|
||||
} else {
|
||||
fmt::format_to(output_iterator, "GRF ID {:08X}", BSWAP32(grfid));
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ std::string GenerateUid(std::string_view subject)
|
|||
checksum.Append(coding_string.c_str(), coding_string.length());
|
||||
checksum.Finish(digest);
|
||||
|
||||
return MD5SumToString(digest);
|
||||
return FormatArrayAsHex(digest);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -197,7 +197,7 @@ std::string GenerateCompanyPasswordHash(const std::string &password, const std::
|
|||
checksum.Append(salted_password_string.data(), salted_password_string.size());
|
||||
checksum.Finish(digest);
|
||||
|
||||
return MD5SumToString(digest);
|
||||
return FormatArrayAsHex(digest);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -666,7 +666,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS(P
|
|||
const GRFConfig *f = FindGRFConfig(c.grfid, FGCM_EXACT, &c.md5sum);
|
||||
if (f == nullptr) {
|
||||
/* We do not know this GRF, bail out of initialization */
|
||||
Debug(grf, 0, "NewGRF {:08X} not found; checksum {}", BSWAP32(c.grfid), MD5SumToString(c.md5sum));
|
||||
Debug(grf, 0, "NewGRF {:08X} not found; checksum {}", BSWAP32(c.grfid), FormatArrayAsHex(c.md5sum));
|
||||
ret = NETWORK_RECV_STATUS_NEWGRF_MISMATCH;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -365,7 +365,7 @@ class NetworkContentListWindow : public Window, ContentCallback {
|
|||
if (!first) url.push_back(',');
|
||||
first = false;
|
||||
|
||||
fmt::format_to(std::back_inserter(url), "{:08X}:{}", ci->unique_id, MD5SumToString(ci->md5sum));
|
||||
fmt::format_to(std::back_inserter(url), "{:08X}:{}", ci->unique_id, FormatArrayAsHex(ci->md5sum));
|
||||
}
|
||||
} else {
|
||||
url += "do=searchtext&q=";
|
||||
|
|
|
@ -268,7 +268,7 @@ static void SurveyGrfs(nlohmann::json &survey)
|
|||
auto grfid = fmt::format("{:08x}", BSWAP32(c->ident.grfid));
|
||||
auto &grf = survey[grfid];
|
||||
|
||||
grf["md5sum"] = MD5SumToString(c->ident.md5sum);
|
||||
grf["md5sum"] = FormatArrayAsHex(c->ident.md5sum);
|
||||
grf["status"] = c->status;
|
||||
|
||||
if ((c->palette & GRFP_GRF_MASK) == GRFP_GRF_UNSET) grf["palette"] = "unset";
|
||||
|
|
|
@ -481,7 +481,7 @@ GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig)
|
|||
* same grfid, as it most likely is compatible */
|
||||
f = FindGRFConfig(c->ident.grfid, FGCM_COMPATIBLE, nullptr, c->version);
|
||||
if (f != nullptr) {
|
||||
Debug(grf, 1, "NewGRF {:08X} ({}) not found; checksum {}. Compatibility mode on", BSWAP32(c->ident.grfid), c->filename, MD5SumToString(c->ident.md5sum));
|
||||
Debug(grf, 1, "NewGRF {:08X} ({}) not found; checksum {}. Compatibility mode on", BSWAP32(c->ident.grfid), c->filename, FormatArrayAsHex(c->ident.md5sum));
|
||||
if (!HasBit(c->flags, GCF_COMPATIBLE)) {
|
||||
/* Preserve original_md5sum after it has been assigned */
|
||||
SetBit(c->flags, GCF_COMPATIBLE);
|
||||
|
@ -494,7 +494,7 @@ GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig)
|
|||
}
|
||||
|
||||
/* No compatible grf was found, mark it as disabled */
|
||||
Debug(grf, 0, "NewGRF {:08X} ({}) not found; checksum {}", BSWAP32(c->ident.grfid), c->filename, MD5SumToString(c->ident.md5sum));
|
||||
Debug(grf, 0, "NewGRF {:08X} ({}) not found; checksum {}", BSWAP32(c->ident.grfid), c->filename, FormatArrayAsHex(c->ident.md5sum));
|
||||
|
||||
c->status = GCS_NOT_FOUND;
|
||||
res = GLC_NOT_FOUND;
|
||||
|
|
|
@ -105,7 +105,7 @@ static void ShowNewGRFInfo(const GRFConfig *c, const Rect &r, bool show_params)
|
|||
}
|
||||
|
||||
/* Prepare and draw MD5 sum */
|
||||
tmp = MD5SumToString(c->ident.md5sum);
|
||||
tmp = FormatArrayAsHex(c->ident.md5sum);
|
||||
SetDParamStr(0, tmp);
|
||||
tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_MD5SUM);
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ static void WriteSavegameInfo(const char *name)
|
|||
if (_load_check_data.HasNewGrfs()) {
|
||||
for (GRFConfig *c = _load_check_data.grfconfig; c != nullptr; c = c->next) {
|
||||
fmt::format_to(std::back_inserter(message), "{:08X} {} {}\n", c->ident.grfid,
|
||||
MD5SumToString(HasBit(c->flags, GCF_COMPATIBLE) ? c->original_md5sum : c->ident.md5sum), c->filename);
|
||||
FormatArrayAsHex(HasBit(c->flags, GCF_COMPATIBLE) ? c->original_md5sum : c->ident.md5sum), c->filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -389,11 +389,11 @@ static void CDECL HandleSavegameLoadCrash(int signum)
|
|||
if (HasBit(c->flags, GCF_COMPATIBLE)) {
|
||||
const GRFIdentifier *replaced = _gamelog.GetOverriddenIdentifier(c);
|
||||
fmt::format_to(std::back_inserter(message), "NewGRF {:08X} (checksum {}) not found.\n Loaded NewGRF \"{}\" (checksum {}) with same GRF ID instead.\n",
|
||||
BSWAP32(c->ident.grfid), MD5SumToString(c->original_md5sum), c->filename, MD5SumToString(replaced->md5sum));
|
||||
BSWAP32(c->ident.grfid), FormatArrayAsHex(c->original_md5sum), c->filename, FormatArrayAsHex(replaced->md5sum));
|
||||
}
|
||||
if (c->status == GCS_NOT_FOUND) {
|
||||
fmt::format_to(std::back_inserter(message), "NewGRF {:08X} ({}) not found; checksum {}.\n",
|
||||
BSWAP32(c->ident.grfid), c->filename, MD5SumToString(c->ident.md5sum));
|
||||
BSWAP32(c->ident.grfid), c->filename, FormatArrayAsHex(c->ident.md5sum));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -320,7 +320,7 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user
|
|||
fmt::format_to(std::back_inserter(message), "Graphics set: {} ({})\n", BaseGraphics::GetUsedSet()->name, BaseGraphics::GetUsedSet()->version);
|
||||
message += "NewGRFs:\n";
|
||||
for (const GRFConfig *c = _game_mode == GM_MENU ? nullptr : _grfconfig; c != nullptr; c = c->next) {
|
||||
fmt::format_to(std::back_inserter(message), "{:08X} {} {}\n", BSWAP32(c->ident.grfid), MD5SumToString(c->ident.md5sum), c->filename);
|
||||
fmt::format_to(std::back_inserter(message), "{:08X} {} {}\n", BSWAP32(c->ident.grfid), FormatArrayAsHex(c->ident.md5sum), c->filename);
|
||||
}
|
||||
message += "\nCompanies:\n";
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
|
|
|
@ -1140,7 +1140,7 @@ static void GRFSaveConfig(IniFile &ini, const char *grpname, const GRFConfig *li
|
|||
GRFBuildParamList(params, c, lastof(params));
|
||||
|
||||
std::string key = fmt::format("{:08X}|{}|{}", BSWAP32(c->ident.grfid),
|
||||
MD5SumToString(c->ident.md5sum), c->filename);
|
||||
FormatArrayAsHex(c->ident.md5sum), c->filename);
|
||||
group->GetItem(key, true)->SetValue(params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -613,17 +613,6 @@ int CDECL seprintf(char *str, const char *last, const char *format, ...)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert the md5sum to a hexadecimal string representation
|
||||
* @param md5sum the md5sum itself
|
||||
* @return the string representation of the md5sum.
|
||||
*/
|
||||
std::string MD5SumToString(const MD5Hash &md5sum)
|
||||
{
|
||||
return FormatArrayAsHex(md5sum);
|
||||
}
|
||||
|
||||
|
||||
/* UTF-8 handling routines */
|
||||
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "core/bitmath_func.hpp"
|
||||
#include "core/span_type.hpp"
|
||||
#include "string_type.h"
|
||||
#include "3rdparty/md5/md5.h"
|
||||
|
||||
char *strecat(char *dst, const char *src, const char *last) NOACCESS(3);
|
||||
char *strecpy(char *dst, const char *src, const char *last) NOACCESS(3);
|
||||
|
@ -91,8 +90,6 @@ static inline size_t ttd_strnlen(const char *str, size_t maxlen)
|
|||
return t - str;
|
||||
}
|
||||
|
||||
std::string MD5SumToString(const MD5Hash &md5sum);
|
||||
|
||||
bool IsValidChar(WChar key, CharSetFilter afilter);
|
||||
|
||||
size_t Utf8Decode(WChar *c, const char *s);
|
||||
|
|
Loading…
Reference in New Issue