Skip to content

Commit 9b2cf0f

Browse files
sbx320ccw808
authored andcommitted
Removed preprocessor macros for VS08 compatibility
Changed some functions to C++11 variants rather than using #ifdefs to determine compiler
1 parent 43fac81 commit 9b2cf0f

File tree

6 files changed

+12
-48
lines changed

6 files changed

+12
-48
lines changed

MTA10_Server/dbconmy/CDatabaseConnectionMySql.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ bool CDatabaseConnectionMySql::QueryInternal ( const SString& strQuery, CRegistr
340340
case SQLITE_NULL:
341341
break;
342342
case SQLITE_INTEGER:
343-
cell.nVal = atoi64 ( inData );
343+
cell.nVal = std::atoll ( inData );
344344
break;
345345
case SQLITE_FLOAT:
346346
cell.fVal = (float)atof ( inData );

Shared/sdk/CMatrix_Pad.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "CMatrix.h"
1717

1818
/**
19-
* CVector Structure used internally by GTA.
19+
* CMatrix Structure used internally by GTA.
2020
*/
2121
class CMatrix_Padded
2222
{

Shared/sdk/Common.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
#define MAX_SERVER_ELEMENTS 131072
3131
#define MAX_CLIENT_ELEMENTS 131072
3232

33-
#if (MAX_SERVER_ELEMENTS&(MAX_SERVER_ELEMENTS-1)) != 0
34-
#error MAX_SERVER_ELEMENTS "Macro must be power of 2"
35-
#endif
33+
// Make sure MAX_SERVER_ELEMENTS are a power of two
34+
static_assert( ( MAX_SERVER_ELEMENTS&( MAX_SERVER_ELEMENTS - 1 ) ) == 0, "MAX_SERVER_ELEMENTS must be a power of 2" );
35+
3636

3737
// ElementID structure
3838
struct ElementID

Shared/sdk/SharedUtil.Defines.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,13 @@
9898
#endif
9999

100100
#ifdef _MSC_VER
101-
#define atoi64 _atoi64
102101
#define PRId64 "I64d"
103102
#define PRIx64 "I64x"
104103
#else
105-
#define atoi64 std::atoll
106104
#define PRId64 "lld"
107105
#define PRIx64 "llx"
108106
#endif
109107

110-
#if defined(WIN32)
111-
#if _MSC_VER <= 1500
112-
// VS08 does not have isnan, but _isnan
113-
#include <float.h>
114-
#define isnan _isnan
115-
#endif
116-
#endif
117-
118108
//
119109
// Macro for counting the number of elements in a static array
120110
//

Shared/sdk/SharedUtil.HashMap.h

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#define HASH_MAP_TYPE __gnu_cxx::hash_map
2323
#endif
2424

25+
#include <functional>
2526

2627
namespace SharedUtil
2728
{
@@ -109,36 +110,9 @@ namespace SharedUtil
109110

110111

111112
// Calculate a hash value for SString
112-
#if defined(WIN32)
113-
#if _MSC_VER <= 1500
114-
inline size_t hash_value ( const SString& strString )
115-
{
116-
const char *_Ptr = strString.c_str ();
117-
return ( stdext::_Hash_value ( _Ptr, _Ptr + strString.size () ) );
118-
}
119-
120-
#else
121-
#include <functional>
122-
inline size_t hash_value(const SString& strString)
123-
{
124-
std::hash<std::string> hashFunction;
125-
return hashFunction( strString );
126-
}
127-
#endif
128-
#elif defined(__GNUC__) && (__GNUC__ >= 3)
129-
130-
namespace __gnu_cxx
131-
{
132-
template<>
133-
struct hash < SString >
134-
{
135-
size_t operator () ( const SString& strString ) const
136-
{
137-
return __stl_hash_string ( strString );
138-
}
139-
};
140-
}
141-
142-
#endif
143-
113+
inline size_t hash_value ( const SString& strString )
114+
{
115+
std::hash<std::string> hashFunction;
116+
return hashFunction ( strString );
117+
}
144118
#endif // WITH_ALLOC_TRACKING

Shared/sdk/SharedUtil.Misc.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ SString SharedUtil::GetPostUpdateConnect( void )
345345
CArgMap argMap;
346346
argMap.SetFromString( strPostUpdateConnect );
347347
SString strHost = argMap.Get( "host" );
348-
time_t timeThen = (time_t)atoi64( argMap.Get( "time" ) );
348+
time_t timeThen = (time_t)std::atoll( argMap.Get( "time" ) );
349349

350350
// Expire after 5 mins
351351
double seconds = difftime( time( NULL ), timeThen );

0 commit comments

Comments
 (0)