mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
Public release of the DLU server code!
Have fun!
This commit is contained in:
45
thirdparty/raknet/Source/Itoa.cpp
vendored
Normal file
45
thirdparty/raknet/Source/Itoa.cpp
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
|
||||
// Fast itoa from http://www.jb.man.ac.uk/~slowe/cpp/itoa.html for Linux since it seems like Linux doesn't support this function.
|
||||
// I modified it to remove the std dependencies.
|
||||
char* Itoa( int value, char* result, int base )
|
||||
{
|
||||
// check that the base if valid
|
||||
if (base < 2 || base > 16) { *result = 0; return result; }
|
||||
char* out = result;
|
||||
int quotient = value;
|
||||
|
||||
int absQModB;
|
||||
|
||||
do {
|
||||
// KevinJ - get rid of this dependency
|
||||
//*out = "0123456789abcdef"[ std::abs( quotient % base ) ];
|
||||
absQModB=quotient % base;
|
||||
if (absQModB < 0)
|
||||
absQModB=-absQModB;
|
||||
*out = "0123456789abcdef"[ absQModB ];
|
||||
++out;
|
||||
quotient /= base;
|
||||
} while ( quotient );
|
||||
|
||||
// Only apply negative sign for base 10
|
||||
if ( value < 0 && base == 10) *out++ = '-';
|
||||
|
||||
// KevinJ - get rid of this dependency
|
||||
// std::reverse( result, out );
|
||||
*out = 0;
|
||||
|
||||
// KevinJ - My own reverse code
|
||||
char *start = result;
|
||||
char temp;
|
||||
out--;
|
||||
while (start < out)
|
||||
{
|
||||
temp=*start;
|
||||
*start=*out;
|
||||
*out=temp;
|
||||
start++;
|
||||
out--;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
Reference in New Issue
Block a user