aboutsummaryrefslogtreecommitdiff
path: root/src/game/MapManager.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-06-18 19:27:17 -0500
committermegamage <none@none>2009-06-18 19:27:17 -0500
commita49c2982ba975a4c5dba7b1bf6a31a7c54a13c1d (patch)
treee7acd28b0fa53076221d335a9b033695f0abed2b /src/game/MapManager.cpp
parentfd73be2f1e2aa134f3b26277281411de691db04a (diff)
parent19225e8880b12bf3b72743ea253a94b52635a212 (diff)
*Merge.
*mtmap is disabled by default. To use it, define MULTI_THREAD_MAP in define.h *mtmap support is not provided for windows users. Because there is no free openmp lib for windows. If you have openmp lib and want to use openmp, you need to manually change the setting. --HG-- branch : trunk
Diffstat (limited to 'src/game/MapManager.cpp')
-rw-r--r--src/game/MapManager.cpp41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp
index ece2876cab4..0da0d003144 100644
--- a/src/game/MapManager.cpp
+++ b/src/game/MapManager.cpp
@@ -18,6 +18,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifdef MULTI_THREAD_MAP
+#include <omp.h>
+#endif
#include "MapManager.h"
#include "InstanceSaveMgr.h"
#include "Policies/SingletonImp.h"
@@ -251,12 +254,33 @@ MapManager::Update(uint32 diff)
if( !i_timer.Passed() )
return;
- for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
+#ifdef MULTI_THREAD_MAP
+ uint32 i=0;
+ MapMapType::iterator iter;
+ std::vector<Map*> update_queue(i_maps.size());
+ omp_set_num_threads(sWorld.getConfig(CONFIG_NUMTHREADS));
+ for(iter = i_maps.begin(), i=0;iter != i_maps.end(); ++iter, i++)
+ update_queue[i]=iter->second;
+/*
+ gomp in gcc <4.4 version cannot parallelise loops using random access iterators
+ so until gcc 4.4 isnt standard, we need the update_queue workaround
+*/
+#pragma omp parallel for schedule(dynamic) private(i) shared(update_queue)
+ for(int32 i = 0; i < i_maps.size(); ++i)
{
checkAndCorrectGridStatesArray(); // debugging code, should be deleted some day
+ update_queue[i]->Update(i_timer.GetCurrent());
+ sWorld.RecordTimeDiff("UpdateMap %u", update_queue[i]->GetId());
+ // sLog.outError("This is thread %d out of %d threads,updating map %u",omp_get_thread_num(),omp_get_num_threads(),iter->second->GetId());
+
+ }
+#else
+ for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
+ {
iter->second->Update(i_timer.GetCurrent());
sWorld.RecordTimeDiff("UpdateMap %u", iter->second->GetId());
}
+#endif
ObjectAccessor::Instance().Update(i_timer.GetCurrent());
sWorld.RecordTimeDiff("UpdateObjectAccessor");
@@ -269,8 +293,19 @@ MapManager::Update(uint32 diff)
void MapManager::DoDelayedMovesAndRemoves()
{
- for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
- iter->second->RelocationNotify();
+ /*
+ int i =0;
+ std::vector<Map*> update_queue(i_maps.size());
+ MapMapType::iterator iter;
+ for(iter = i_maps.begin();iter != i_maps.end(); ++iter, i++)
+ update_queue[i] = iter->second;
+
+ omp_set_num_threads(sWorld.getConfig(CONFIG_NUMTHREADS));
+
+#pragma omp parallel for schedule(dynamic) private(i) shared(update_queue)
+ for(i=0;i<i_maps.size();i++)
+ update_queue[i]->DoDelayedMovesAndRemoves();
+ */
}
bool MapManager::ExistMapAndVMap(uint32 mapid, float x,float y)