mirror of
https://github.com/glest/glest-source.git
synced 2025-08-09 09:56:30 +02:00
- attempt to rollback change that causes game differences on different platforms
This commit is contained in:
@@ -63,16 +63,16 @@ inline T truncateDecimal(const T &value, int precision=6) {
|
|||||||
|
|
||||||
// See if we can avoid using an int64 for speed
|
// See if we can avoid using an int64 for speed
|
||||||
// To avoid stupid VC++ compiler error: illegal token on right side of '::'
|
// To avoid stupid VC++ compiler error: illegal token on right side of '::'
|
||||||
#ifdef WIN32
|
//#ifdef WIN32
|
||||||
#undef max
|
//#undef max
|
||||||
#endif
|
//#endif
|
||||||
static int MAX_INT_VALUE = numeric_limits<int>::max();
|
// static int MAX_INT_VALUE = numeric_limits<int>::max();
|
||||||
if((T)value * (T)precNum <= MAX_INT_VALUE) {
|
// if((T)value * (T)precNum <= MAX_INT_VALUE) {
|
||||||
int resultInt = (int)((T)value * (T)precNum);
|
// int resultInt = (int)((T)value * (T)precNum);
|
||||||
T result = (T)resultInt / precNum;
|
// T result = (T)resultInt / precNum;
|
||||||
//printf("=======================\nvalue = %.10f\nresultInt: %d\nprecision: %d\nbecame: %.10f\n----------\n",value,resultInt,precision,result);
|
// //printf("=======================\nvalue = %.10f\nresultInt: %d\nprecision: %d\nbecame: %.10f\n----------\n",value,resultInt,precision,result);
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Must use an int64 since the result is large
|
// Must use an int64 since the result is large
|
||||||
int64 resultInt = (int64)((T)value * (T)precNum);
|
int64 resultInt = (int64)((T)value * (T)precNum);
|
||||||
|
@@ -33,8 +33,8 @@ bool strToUInt(const string &s, uint32 *i);
|
|||||||
bool strToFloat(const string &s, float *f);
|
bool strToFloat(const string &s, float *f);
|
||||||
|
|
||||||
string boolToStr(bool b);
|
string boolToStr(bool b);
|
||||||
string uIntToStr(const uint64 &value);
|
string uIntToStr(const uint64 value);
|
||||||
string intToStr(const int64 &value);
|
string intToStr(const int64 value);
|
||||||
string intToHex(int i);
|
string intToHex(int i);
|
||||||
string floatToStr(float f,int precsion=2);
|
string floatToStr(float f,int precsion=2);
|
||||||
string doubleToStr(double f,int precsion=2);
|
string doubleToStr(double f,int precsion=2);
|
||||||
|
@@ -133,27 +133,27 @@ string boolToStr(bool b) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string intToStr(const int64 &value) {
|
string intToStr(const int64 value) {
|
||||||
char str[strSize]="";
|
char str[strSize]="";
|
||||||
static int MAX_INT_VALUE = std::numeric_limits<int>::max();
|
// static int MAX_INT_VALUE = std::numeric_limits<int>::max();
|
||||||
if(value <= MAX_INT_VALUE) {
|
// if(value <= MAX_INT_VALUE) {
|
||||||
snprintf(str, strSize-1, "%d", (int)value);
|
// snprintf(str, strSize-1, "%d", (int)value);
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
snprintf(str, strSize-1, "%lld", (long long int)value);
|
snprintf(str, strSize-1, "%lld", (long long int)value);
|
||||||
}
|
// }
|
||||||
return (str[0] != '\0' ? str : "");
|
return (str[0] != '\0' ? str : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
string uIntToStr(const uint64 &value) {
|
string uIntToStr(const uint64 value) {
|
||||||
char str[strSize]="";
|
char str[strSize]="";
|
||||||
static unsigned int MAX_UNSIGNED_INT_VALUE = std::numeric_limits<unsigned int>::max();
|
// static unsigned int MAX_UNSIGNED_INT_VALUE = std::numeric_limits<unsigned int>::max();
|
||||||
if(value <= MAX_UNSIGNED_INT_VALUE) {
|
// if(value <= MAX_UNSIGNED_INT_VALUE) {
|
||||||
snprintf(str, strSize-1, "%u", (int)value);
|
// snprintf(str, strSize-1, "%u", (int)value);
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
snprintf(str, strSize-1, "%llu", (long long unsigned int)value);
|
snprintf(str, strSize-1, "%llu", (long long unsigned int)value);
|
||||||
}
|
// }
|
||||||
return (str[0] != '\0' ? str : "");
|
return (str[0] != '\0' ? str : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user