Adds a utilities.h file for general-purpose, well, utilities.
One of these is an overload for sprintf() which provides a std::string parameter for output.
I changed our used-everywhere temporary strbuf variable from a fixed 4096-byte char array to std::string.
Something we may want to discuss is whether the signature should remain as the C-style void sprintf(out_param, in_param, ...) or switch to std::string sprintf(in_param, ...) instead.
The advantage of returning the string would allow us to change:
// from this:
sprintf(strbuf, "%3d>", t1.mhp);
Draw.print_font(double_buffer, b + 96, 56, strbuf, FNORMAL);
// to this:
Draw.print_font(double_buffer, b + 96, 56, sprintf("%3d>", t1.mhp), FNORMAL);
I did not do that in this PR because sprintf(strbuf, ...) is used everywhere and I wanted to keep the number of changed files to a minimum until we decided on the above.
Adds a
utilities.h
file for general-purpose, well, utilities.sprintf()
which provides astd::string
parameter for output.strbuf
variable from a fixed 4096-bytechar
array tostd::string
.Something we may want to discuss is whether the signature should remain as the C-style
void sprintf(out_param, in_param, ...)
or switch tostd::string sprintf(in_param, ...)
instead.The advantage of returning the string would allow us to change:
I did not do that in this PR because
sprintf(strbuf, ...)
is used everywhere and I wanted to keep the number of changed files to a minimum until we decided on the above.