diff --git a/src/settings.cpp b/src/settings.cpp --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1135,14 +1135,11 @@ static void GRFSaveConfig(IniFile &ini, const GRFConfig *c; for (c = list; c != nullptr; c = c->next) { - /* Hex grfid (4 bytes in nibbles), "|", hex md5sum (16 bytes in nibbles), "|", file system path. */ - char key[4 * 2 + 1 + 16 * 2 + 1 + MAX_PATH]; char params[512]; GRFBuildParamList(params, c, lastof(params)); - char *pos = key + seprintf(key, lastof(key), "%08X|", BSWAP32(c->ident.grfid)); - pos = md5sumToString(pos, lastof(key), c->ident.md5sum); - seprintf(pos, lastof(key), "|%s", c->filename); + std::string key = fmt::format("{:08X}|{}|{}", BSWAP32(c->ident.grfid), + MD5SumToString(c->ident.md5sum), c->filename); group->GetItem(key, true)->SetValue(params); } }