Log in

View Full Version : #showstats not working under ubunto/gcc


noudess
06-20-2013, 12:29 PM
#showstats uses itoa extensively, and at least on my system/compiler, itoa seems to use an internal static string. About 15 fields were all displaying level instead of the stat intended.

I simply added this after the last #include in client.cpp:

#include <sstream>

inline std::string stringify(double x)
{
std::ostringstream o;
o << x;
return o.str();
}


And replaced every itoa that was being assigned into a std:;string to use stringify(value) instead of itoa(value) and it all works great. Gets rid of some compiler warnings as well.

I have too many other changes to this file to provide a diff that would be easier to use than following the above instructions. I expect some other areas could benefit from this as well.

demonstar55
06-20-2013, 01:42 PM
Since our current target compilers are VS10 and gcc 4.6, we can use the C++11 std::to_string instead. Or should be able to, I will test this today.

EDIT: apparently VS10 has implemented std::to_string in a stupid method making it rather impractical to use : |