aboutsummaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/CMakeLists.txt2
-rw-r--r--src/shared/Util.cpp56
2 files changed, 57 insertions, 1 deletions
diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt
index b271e2b9545..de73967546b 100644
--- a/src/shared/CMakeLists.txt
+++ b/src/shared/CMakeLists.txt
@@ -21,7 +21,7 @@ SET(shared_STAT_SRCS
WorldPacket.h
SystemConfig.h
)
-
+add_definitions(-fopenmp)
add_library(shared STATIC ${shared_STAT_SRCS})
target_link_libraries(
shared
diff --git a/src/shared/Util.cpp b/src/shared/Util.cpp
index ac57fc3c9e9..354568c778f 100644
--- a/src/shared/Util.cpp
+++ b/src/shared/Util.cpp
@@ -28,6 +28,60 @@
typedef ACE_TSS<MTRand> MTRandTSS;
static MTRandTSS mtRand;
+#ifdef MULTI_THREAD_MAP
+
+int32 irand (int32 min, int32 max)
+{
+ int32 result;
+#pragma omp critical (mtrand)
+{
+ result = int32 (mtRand->randInt (max - min)) + min;
+}
+ return result;
+}
+
+uint32 urand (uint32 min, uint32 max)
+{
+ uint32 result;
+#pragma omp critical (mtrand)
+{
+ result = mtRand->randInt (max - min) + min;
+}
+ return result;
+}
+
+int32 rand32 ()
+{
+ int32 result;
+#pragma omp critical (mtrand)
+{
+ result = mtRand->randInt ();
+}
+ return result;
+}
+
+double rand_norm(void)
+{
+ double result;
+#pragma omp critical (mtrand)
+{
+ result = mtRand->randExc ();
+}
+ return result;
+}
+
+double rand_chance (void)
+{
+ double result;
+#pragma omp critical (mtrand)
+{
+ result = mtRand->randExc (100.0);
+}
+ return result;
+}
+
+#else
+
int32 irand (int32 min, int32 max)
{
return int32 (mtRand->randInt (max - min)) + min;
@@ -53,6 +107,8 @@ double rand_chance (void)
return mtRand->randExc (100.0);
}
+#endif
+
Tokens StrSplit(const std::string &src, const std::string &sep)
{
Tokens r;