EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Server Code Submissions (https://www.eqemulator.org/forums/forumdisplay.php?f=669)
-   -   #showstats not working under ubunto/gcc (https://www.eqemulator.org/forums/showthread.php?t=36981)

noudess 06-20-2013 12:29 PM

#showstats not working under ubunto/gcc
 
#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:

Code:

#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 : |


All times are GMT -4. The time now is 07:52 PM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.