diff options
-rw-r--r-- | src/tools/mmaps_generator/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/tools/mmaps_generator/MapBuilder.cpp | 67 | ||||
-rw-r--r-- | src/tools/mmaps_generator/MapBuilder.h | 61 | ||||
-rw-r--r-- | src/tools/mmaps_generator/PathCommon.h | 23 | ||||
-rw-r--r-- | src/tools/mmaps_generator/PathGenerator.cpp | 1 |
5 files changed, 37 insertions, 118 deletions
diff --git a/src/tools/mmaps_generator/CMakeLists.txt b/src/tools/mmaps_generator/CMakeLists.txt index c0268680657..f38ecc5144d 100644 --- a/src/tools/mmaps_generator/CMakeLists.txt +++ b/src/tools/mmaps_generator/CMakeLists.txt @@ -12,7 +12,6 @@ file(GLOB_RECURSE mmap_gen_sources *.cpp *.h) set(mmap_gen_Includes ${CMAKE_BINARY_DIR} - ${ACE_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/dep/libmpq ${CMAKE_SOURCE_DIR}/dep/zlib ${CMAKE_SOURCE_DIR}/dep/bzip2 @@ -22,6 +21,7 @@ set(mmap_gen_Includes ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour/Include ${CMAKE_SOURCE_DIR}/src/server/shared + ${CMAKE_SOURCE_DIR}/src/server/shared/Utilities ${CMAKE_SOURCE_DIR}/src/server/game/Conditions ${CMAKE_SOURCE_DIR}/src/server/collision ${CMAKE_SOURCE_DIR}/src/server/collision/Management @@ -45,7 +45,6 @@ target_link_libraries(mmaps_generator g3dlib Recast Detour - ${ACE_LIBRARY} ${BZIP2_LIBRARIES} ${ZLIB_LIBRARIES} ) diff --git a/src/tools/mmaps_generator/MapBuilder.cpp b/src/tools/mmaps_generator/MapBuilder.cpp index 131041e0cd2..fdd8a7d177a 100644 --- a/src/tools/mmaps_generator/MapBuilder.cpp +++ b/src/tools/mmaps_generator/MapBuilder.cpp @@ -27,7 +27,6 @@ #include "DetourCommon.h" #include "DisableMgr.h" -#include <ace/OS_NS_unistd.h> uint32 GetLiquidFlags(uint32 /*liquidType*/) { return 0; } namespace DisableMgr @@ -168,38 +167,40 @@ namespace MMAP /**************************************************************************/ void MapBuilder::buildAllMaps(int threads) { - std::vector<BuilderThread*> _threads; - BuilderThreadPool* pool = threads > 0 ? new BuilderThreadPool() : NULL; - - m_tiles.sort([](MapTiles a, MapTiles b) - { - return a.m_tiles->size() > b.m_tiles->size(); - }); - - for (TileList::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) - { - uint32 mapID = it->m_mapId; - if (!shouldSkipMap(mapID)) - { - if (threads > 0) - pool->Enqueue(new MapBuildRequest(mapID)); - else - buildMap(mapID); - } - } - - for (int i = 0; i < threads; ++i) - _threads.push_back(new BuilderThread(this, pool->Queue())); - - // Free memory - for (std::vector<BuilderThread*>::iterator _th = _threads.begin(); _th != _threads.end(); ++_th) - { - (*_th)->wait(); - delete *_th; - } - - delete pool; +// TODO fix that shit +// std::vector<BuilderThread*> _threads; +// +// BuilderThreadPool* pool = threads > 0 ? new BuilderThreadPool() : NULL; +// +// m_tiles.sort([](MapTiles a, MapTiles b) +// { +// return a.m_tiles->size() > b.m_tiles->size(); +// }); +// +// for (TileList::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) +// { +// uint32 mapID = it->m_mapId; +// if (!shouldSkipMap(mapID)) +// { +// if (threads > 0) +// pool->Enqueue(new MapBuildRequest(mapID)); +// else +// buildMap(mapID); +// } +// } +// +// for (int i = 0; i < threads; ++i) +// _threads.push_back(new BuilderThread(this, pool->Queue())); +// +// // Free memory +// for (std::vector<BuilderThread*>::iterator _th = _threads.begin(); _th != _threads.end(); ++_th) +// { +// (*_th)->wait(); +// delete *_th; +// } +// +// delete pool; } /**************************************************************************/ @@ -349,7 +350,7 @@ namespace MMAP void MapBuilder::buildMap(uint32 mapID) { #ifndef __APPLE__ - printf("[Thread %u] Building map %03u:\n", uint32(ACE_Thread::self()), mapID); + //printf("[Thread %u] Building map %03u:\n", uint32(ACE_Thread::self()), mapID); #endif std::set<uint32>* tiles = getTileList(mapID); diff --git a/src/tools/mmaps_generator/MapBuilder.h b/src/tools/mmaps_generator/MapBuilder.h index 08b87324d01..c9ea03190a8 100644 --- a/src/tools/mmaps_generator/MapBuilder.h +++ b/src/tools/mmaps_generator/MapBuilder.h @@ -30,10 +30,6 @@ #include "Recast.h" #include "DetourNavMesh.h" -#include <ace/Task.h> -#include <ace/Activation_Queue.h> -#include <ace/Method_Request.h> - using namespace VMAP; // G3D namespace typedefs conflicts with ACE typedefs @@ -143,63 +139,6 @@ namespace MMAP // build performance - not really used for now rcContext* m_rcContext; }; - - class MapBuildRequest : public ACE_Method_Request - { - public: - MapBuildRequest(uint32 mapId) : _mapId(mapId) {} - - virtual int call() - { - /// @ Actually a creative way of unabstracting the class and returning a member variable - return (int)_mapId; - } - - private: - uint32 _mapId; - }; - - class BuilderThread : public ACE_Task_Base - { - private: - MapBuilder* _builder; - ACE_Activation_Queue* _queue; - - public: - BuilderThread(MapBuilder* builder, ACE_Activation_Queue* queue) : _builder(builder), _queue(queue) { activate(); } - - int svc() - { - /// @ Set a timeout for dequeue attempts (only used when the queue is empty) as it will never get populated after thread starts - ACE_Time_Value timeout(5); - ACE_Method_Request* request = NULL; - while ((request = _queue->dequeue(&timeout)) != NULL) - { - _builder->buildMap(request->call()); - delete request; - request = NULL; - } - - return 0; - } - }; - - class BuilderThreadPool - { - public: - BuilderThreadPool() : _queue(new ACE_Activation_Queue()) {} - ~BuilderThreadPool() { _queue->queue()->close(); delete _queue; } - - void Enqueue(MapBuildRequest* request) - { - _queue->enqueue(request); - } - - ACE_Activation_Queue* Queue() { return _queue; } - - private: - ACE_Activation_Queue* _queue; - }; } #endif diff --git a/src/tools/mmaps_generator/PathCommon.h b/src/tools/mmaps_generator/PathCommon.h index a035bea3b6f..8285fef74f2 100644 --- a/src/tools/mmaps_generator/PathCommon.h +++ b/src/tools/mmaps_generator/PathCommon.h @@ -21,9 +21,8 @@ #include <string> #include <vector> -#include <ace/OS_NS_sys_time.h> -#include "Define.h" +#include "Common.h" #ifndef _WIN32 #include <stddef.h> @@ -135,26 +134,6 @@ namespace MMAP return LISTFILE_OK; } - - inline uint32 getMSTime() - { - static const ACE_Time_Value ApplicationStartTime = ACE_OS::gettimeofday(); - return (ACE_OS::gettimeofday() - ApplicationStartTime).msec(); - } - - inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime) - { - // getMSTime() have limited data range and this is case when it overflow in this tick - if (oldMSTime > newMSTime) - return (0xFFFFFFFF - oldMSTime) + newMSTime; - else - return newMSTime - oldMSTime; - } - - inline uint32 GetMSTimeDiffToNow(uint32 oldMSTime) - { - return getMSTimeDiff(oldMSTime, getMSTime()); - } } #endif diff --git a/src/tools/mmaps_generator/PathGenerator.cpp b/src/tools/mmaps_generator/PathGenerator.cpp index d88ab8ca16d..3e2025dace8 100644 --- a/src/tools/mmaps_generator/PathGenerator.cpp +++ b/src/tools/mmaps_generator/PathGenerator.cpp @@ -18,6 +18,7 @@ #include "PathCommon.h" #include "MapBuilder.h" +#include "Timer.h" using namespace MMAP; |