Skip to content

Commit 2423115

Browse files
committed
More VS2015 compile fixes and fixes related to sparsehash update
1 parent 7829794 commit 2423115

File tree

4 files changed

+20
-26
lines changed

4 files changed

+20
-26
lines changed

Shared/sdk/SharedUtil.FastHashMap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* Multi Theft Auto is available from http://www.multitheftauto.com/
1010
*
1111
*****************************************************************************/
12+
#pragma once
1213

1314
#if WITH_ALLOC_TRACKING
1415
#define CFastHashMap std::CMap
@@ -19,7 +20,7 @@
1920
#endif
2021

2122
#include <google/dense_hash_map>
22-
using namespace google;
23+
#undef BASE_TEMPLATE_UTIL_H_ // HACK: Sparsehash and CEF share the same include guard name (NEVER USE MACROS AS INCLUDE GUARDS)
2324

2425
#ifdef WIN32
2526
#pragma pop_macro("assert")

Shared/sdk/SharedUtil.FastHashSet.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#endif
2020

2121
#include <google/dense_hash_set>
22-
using namespace google;
2322

2423
#ifdef WIN32
2524
#pragma pop_macro("assert")

Shared/sdk/SharedUtil.HashMap.h

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,13 @@
99
* Multi Theft Auto is available from http://www.multitheftauto.com/
1010
*
1111
*****************************************************************************/
12+
#pragma once
1213

1314
#if WITH_ALLOC_TRACKING
1415
#define CHashMap CMap
1516
#else
1617

17-
#if defined(WIN32)
18-
#include <hash_map>
19-
#define HASH_MAP_TYPE stdext::hash_map
20-
#elif defined(__GNUC__) && (__GNUC__ >= 3)
21-
#include <ext/hash_map>
22-
#define HASH_MAP_TYPE __gnu_cxx::hash_map
23-
#endif
24-
18+
#include <unordered_map>
2519
#include <functional>
2620

2721
namespace SharedUtil
@@ -32,7 +26,7 @@ namespace SharedUtil
3226
// Using hash_map
3327
//
3428
template < class K, class V >
35-
class CHashMap : public HASH_MAP_TYPE < K, V >
29+
class CHashMap : public std::unordered_map < K, V >
3630
{
3731
public:
3832
};
@@ -110,23 +104,19 @@ namespace SharedUtil
110104

111105

112106
// Calculate a hash value for SString
113-
#if defined(WIN32)
114-
inline size_t hash_value ( const SString& strString )
107+
template<>
108+
struct std::hash<SString>
109+
{
110+
size_t operator()(const SString& str) const
111+
{
112+
return std::hash<std::string>()(str);
113+
}
114+
};
115+
116+
inline size_t hash_value ( const SString& strString ) // Required for sparsehash
115117
{
116118
std::hash<std::string> hashFunction;
117119
return hashFunction ( strString );
118120
}
119-
#elif defined(__GNUC__) && (__GNUC__ >= 3)
120-
namespace __gnu_cxx
121-
{
122-
template<>
123-
struct hash < SString >
124-
{
125-
size_t operator () ( const SString& strString ) const
126-
{
127-
return __stl_hash_string ( strString );
128-
}
129-
};
130-
}
131-
#endif
121+
132122
#endif // WITH_ALLOC_TRACKING

premake5.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ workspace "MTASA"
6969
libdirs {
7070
dxdir.."Lib/x86"
7171
}
72+
73+
if _ACTION == "vs2015" then
74+
defines { "_TIMESPEC_DEFINED" } -- fix pthread redefinition error, TODO: Remove when we fully moved to vs2015
75+
end
7276

7377
-- Only build the client on Windows
7478
if os.get() == "windows" then

0 commit comments

Comments
 (0)