1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-21 00:19:29 +02:00

Avoid boost::format that throws exception on invalid format string

This commit is contained in:
Ivan Savenko
2023-12-10 16:33:22 +02:00
parent a7c838036d
commit 999db2ed78
2 changed files with 15 additions and 3 deletions

View File

@ -168,7 +168,10 @@ DLL_LINKAGE std::string MetaString::toString() const
boost::replace_first(dst, "%d", std::to_string(numbers[nums++]));
break;
case EMessage::REPLACE_POSITIVE_NUMBER:
boost::replace_first(dst, "%+d", '+' + std::to_string(numbers[nums++]));
if (dst.find("%+d") != std::string::npos)
boost::replace_first(dst, "%+d", '+' + std::to_string(numbers[nums++]));
else
boost::replace_first(dst, "%d", std::to_string(numbers[nums++]));
break;
default:
logGlobal->error("MetaString processing error! Received message of type %d", static_cast<int>(elem));