aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSubv <s.v.h21@hotmail.com>2012-08-25 11:38:33 -0500
committerSubv <s.v.h21@hotmail.com>2012-08-25 11:38:33 -0500
commitf8cc38d65a3b8bca5f93f57e7f4cf7f93df2b38b (patch)
treec308ced3dca04ccdc1b999fbba30166357f7cbbe
parent9698d295b234bcbda3a52c9a47e57f66a98e5335 (diff)
Core/Mmaps: Make the mmaps_generator multithreaded, you can specify the max number of threads that are spawned at the same time (default 3) by using "--threads x" in the command line, where x is the number of threads you want.
Core/Mmaps: Removed now useless sh script
-rw-r--r--contrib/extract/extract_data.sh162
-rw-r--r--contrib/extract/libmysql.dllbin2316288 -> 0 bytes
-rw-r--r--contrib/extract/mapextractor.exebin314368 -> 0 bytes
-rw-r--r--contrib/extract/mmaps_generator.exebin2224128 -> 0 bytes
-rw-r--r--contrib/extract/offmesh.txt3
-rw-r--r--contrib/extract/only_extract_offmesh.sh158
-rw-r--r--contrib/extract/vmap4assembler.exebin1427456 -> 0 bytes
-rw-r--r--contrib/extract/vmap4extractor.exebin321536 -> 0 bytes
-rw-r--r--src/tools/mmaps_generator/MapBuilder.cpp74
-rw-r--r--src/tools/mmaps_generator/MapBuilder.h20
-rw-r--r--src/tools/mmaps_generator/PathGenerator.cpp17
11 files changed, 78 insertions, 356 deletions
diff --git a/contrib/extract/extract_data.sh b/contrib/extract/extract_data.sh
deleted file mode 100644
index d28c7b7d7f5..00000000000
--- a/contrib/extract/extract_data.sh
+++ /dev/null
@@ -1,162 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
-#
-# This file is free software; as a special exception the author gives
-# unlimited permission to copy and/or distribute it, with or without
-# modifications, as long as this notice is preserved.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-## Expected param 1 to be 'a' for all, else ask some questions
-
-## Normal log file (if not overwritten by second param
-LOG_FILE="TrinityCoreExtractor.log"
-## Detailed log file
-DETAIL_LOG_FILE="TrinityCoreExtractor_detailed.log"
-
-## Change this to a value fitting for your sys!
-NUM_CPU="2"
-
-## ! Use below only for finetuning or if you know what you are doing !
-
-USE_MAPS="0"
-USE_VMAPS="0"
-USE_MMAPS="0"
-USE_MMAPS_OFFMESH="0"
-
-if [ "$1" = "a" ]
-then
- ## extract all
- USE_MAPS="1"
- USE_VMAPS="1"
- USE_MMAPS="1"
-else
- ## do some questioning!
- echo
- echo "Welcome to helper script to extract required dataz for TrinityCore!"
- echo "Should all dataz (dbc, maps, vmaps and mmaps be extracted? (y/n)"
- read line
- if [ "$line" = "y" ]
- then
- ## extract all
- USE_MAPS="1"
- USE_VMAPS="1"
- USE_MMAPS="1"
- else
- echo
- echo "Should dbc and maps be extracted? (y/n)"
- read line
- if [ "$line" = "y" ]; then USE_MAPS="1"; fi
-
- echo
- echo "Should vmaps be extracted? (y/n)"
- read line
- if [ "$line" = "y" ]; then USE_VMAPS="1"; fi
-
- echo
- echo "Should mmaps be extracted? (y/n)"
- echo "WARNING! This will take several hours!"
- read line
- if [ "$line" = "y" ]
- then
- USE_MMAPS="1";
- else
- echo "Only reextract offmesh tiles for mmaps?"
- read line
- if [ "$line" = "y" ]
- then
- USE_MMAPS_OFFMESH="1";
- fi
- fi
- fi
-fi
-
-## Special case: Only reextract offmesh tiles
-if [ "$USE_MMAPS_OFFMESH" = "1" ]
-then
- echo "Only extracting offmesh meshes"
- only_extract_offmesh.sh offmesh $LOG_FILE $DETAIL_LOG_FILE
- exit 0
-fi
-
-## Obtain numbe ob processes
-if [ "$USE_MMAPS" = "1" ]
-then
- echo "How many CPUs should be used for extracting mmaps? (1-4)"
- read line
- if [ "$line" -ge "1" -a "$line" -le "4" ]
- then
- NUM_CPU=$line
- else
- echo "Only number between 1 and 4 supported!"
- exit 1
- fi
-fi
-
-## Give some status
-echo "Current Settings: Extract DBCs/maps: $USE_AD, Extract vmaps: $USE_VMAPS, Extract mmaps: $USE_MMAPS on $NUM_CPU processes"
-if [ "$1" != "a" ]
-then
- echo "If you don't like this settings, interrupt with CTRL+C"
- read line
-fi
-
-echo "`date`: Start extracting dataz for TrinityCore" | tee $LOG_FILE
-
-## Handle log messages
-if [ "$USE_AD" = "1" ];
-then
- echo "DBC and map files will be extracted" | tee -a $LOG_FILE
-else
- echo "DBC and map files won't be extracted!" | tee -a $LOG_FILE
-fi
-if [ "$USE_VMAPS" = "1" ]
-then
- echo "Vmaps will be extracted" | tee -a $LOG_FILE
-else
- echo "Vmaps won't be extracted!" | tee -a $LOG_FILE
-fi
-if [ "$USE_MMAPS" = "1" ]
-then
- echo "Mmaps will be extracted with $NUM_CPU processes" | tee -a $LOG_FILE
-else
- echo "Mmaps files won't be extracted!" | tee -a $LOG_FILE
-fi
-echo | tee -a $LOG_FILE
-
-echo "`date`: Start extracting dataz for TrinityCore, DBCs/maps $USE_AD, vmaps $USE_VMAPS, mmaps $USE_MMAPS on $NUM_CPU processes" | tee $DETAIL_LOG_FILE
-echo | tee -a $DETAIL_LOG_FILE
-
-## Extract dbcs and maps
-if [ "$USE_AD" = "1" ]
-then
- echo "`date`: Start extraction of DBCs and map files..." | tee -a $LOG_FILE
- ad | tee -a $DETAIL_LOG_FILE
- echo "`date`: Extracting of DBCs and map files finished" | tee -a $LOG_FILE
- echo | tee -a $LOG_FILE
- echo | tee -a $DETAIL_LOG_FILE
-fi
-
-## Extract vmaps
-if [ "$USE_VMAPS" = "1" ]
-then
- echo "`date`: Start extraction of vmaps..." | tee -a $LOG_FILE
- vmap4extractor | tee -a $DETAIL_LOG_FILE
- echo "`date`: Extracting of vmaps finished" | tee -a $LOG_FILE
- mkdir vmaps
- echo "`date`: Start assembling of vmaps..." | tee -a $LOG_FILE
- vmap4assembler.exe buildings vmaps | tee -a $DETAIL_LOG_FILE
- echo "`date`: Assembling of vmaps finished" | tee -a $LOG_FILE
-
- echo | tee -a $LOG_FILE
- echo | tee -a $DETAIL_LOG_FILE
-fi
-
-## Extract mmaps
-if [ "$USE_MMAPS" = "1" ]
-then
- only_extract_offmesh.sh $NUM_CPU $LOG_FILE $DETAIL_LOG_FILE
-fi
diff --git a/contrib/extract/libmysql.dll b/contrib/extract/libmysql.dll
deleted file mode 100644
index 36de6064f98..00000000000
--- a/contrib/extract/libmysql.dll
+++ /dev/null
Binary files differ
diff --git a/contrib/extract/mapextractor.exe b/contrib/extract/mapextractor.exe
deleted file mode 100644
index ae6d150ba0e..00000000000
--- a/contrib/extract/mapextractor.exe
+++ /dev/null
Binary files differ
diff --git a/contrib/extract/mmaps_generator.exe b/contrib/extract/mmaps_generator.exe
deleted file mode 100644
index 8cd9ff65c26..00000000000
--- a/contrib/extract/mmaps_generator.exe
+++ /dev/null
Binary files differ
diff --git a/contrib/extract/offmesh.txt b/contrib/extract/offmesh.txt
deleted file mode 100644
index 10299a2c696..00000000000
--- a/contrib/extract/offmesh.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-0 31,59 (-14429.889648 450.344452 15.430828) (-14424.218750 444.332855 12.773965) 2.5 // booty bay dock
-562 31,20 (6234.545898 256.902100 11.075373) (6230.961914 252.127274 11.180979) 2.5 // Blade's Edge Arena
-562 31,20 (6243.081543 266.918854 11.059557) (6246.507324 271.623505 11.230524) 2.5 // Blade's Edge Arena \ No newline at end of file
diff --git a/contrib/extract/only_extract_offmesh.sh b/contrib/extract/only_extract_offmesh.sh
deleted file mode 100644
index 700626856ee..00000000000
--- a/contrib/extract/only_extract_offmesh.sh
+++ /dev/null
@@ -1,158 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
-#
-# This file is free software; as a special exception the author gives
-# unlimited permission to copy and/or distribute it, with or without
-# modifications, as long as this notice is preserved.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-## Syntax of this helper
-## First param must be number of to be used CPUs (only 1, 2, 3, 4 supported) or "offmesh" to recreate the special tiles from the OFFMESH_FILE
-## Second param can be an additional filename for storing log
-## Third param can be an addition filename for storing detailed log
-
-## Additional Parameters to be forwarded to MoveMapGen, see mmaps/readme for instructions
-PARAMS="--silent"
-
-## Already a few map extracted, and don't care anymore
-EXCLUDE_MAPS=""
-#EXCLUDE_MAPS="0 1 530 571" # example to exclude the continents
-
-## Offmesh file
-OFFMESH_FILE="offmesh.txt"
-
-## Normal log file (if not overwritten by second param
-LOG_FILE="movemap.log"
-## Detailed log file
-DETAIL_LOG_FILE="movemap_detailed.log"
-
-## ! Use below only for finetuning or if you know what you are doing !
-
-## All maps
-MAP_LIST_A="1 37 543 595 289 572 529 562 531 269 47 649 650 599 548 559 429 230 573 349 13 25 409 229 43 48 546 553 547 604 545 90 576"
-MAP_LIST_B="571 628 560 509 723 532 607 600 668 33 585 566 389 601 369 129 550 189 542 70 109 554 632 552 555 540 598 450 558 249 35 624 557"
-MAP_LIST_C="0 631 609 534 533 619 469 602 329 580 615 578 36 556 44 565 544 34 617 608 618 449 616 42 451 582 584 586 587 588 589 590 591 592"
-MAP_LIST_D="530 169 575 603 309 574 30 564 568 209 724 658 489 593 594 596 597 605 606 610 612 613 614 620 621 622 623 641 642 647 672 673 712 713 718"
-MAP_LIST_D1="209 724 658 489 606 610 612 613 614 620 621"
-MAP_LIST_D2="169 575 603 309 574 30 564 568 622 623 641 642 647 672 673 712 713 718"
-MAP_LIST_D3="530 593 594 596 597 605"
-
-badParam()
-{
- echo "ERROR! Bad arguments!"
- echo "You can (re)extract mmaps with this helper script,"
- echo "or recreate only the tiles from the offmash file"
- echo
- echo "Call with number of processes (1 - 4) to create mmaps"
- echo "Call with 'offmesh' to reextract the tiles from offmash file"
- echo
- echo "For further fine-tuning edit this helper script"
- echo
-}
-
-if [ "$#" = "3" ]
-then
- LOG_FILE=$2
- DETAIL_LOG_FILE=$3
-elif [ "$#" = "2" ]
-then
- LOG_FILE=$2
-fi
-
-# Offmesh file provided?
-OFFMESH=""
-if [ "$OFFMESH_FILE" != "" ]
-then
- if [ ! -f "$OFFMESH_FILE" ]
- then
- echo "ERROR! Offmesh file $OFFMESH_FILE could not be found."
- echo "Provide valid file or none. You need to edit the script"
- exit 1
- else
- OFFMESH="--offMeshInput $OFFMESH_FILE"
- fi
-fi
-
-# Function to process a list
-createMMaps()
-{
- for i in $@
- do
- for j in $EXCLUDE_MAPS
- do
- if [ "$i" = "$j" ]
- then
- continue 2
- fi
- done
- ./mmaps_generator $PARAMS $OFFMESH $i | tee -a $DETAIL_LOG_FILE
- echo "`date`: (Re)created map $i" | tee -a $LOG_FILE
- done
-}
-
-createHeader()
-{
- echo "`date`: Start creating mmaps_generator" | tee -a $LOG_FILE
- echo "Used params: $PARAMS $OFFMESH" | tee -a $LOG_FILE
- echo "Detailed log can be found in $DETAIL_LOG_FILE" | tee -a $LOG_FILE
- echo "Start creating mmaps_generator" | tee -a $DETAIL_LOG_FILE
- echo
- echo "Be PATIENT - This will take a long time and might also have gaps between visible changes on the console."
- echo "WAIT until you are informed that 'creating mmaps_generator' is 'finished'!"
-}
-
-# Create mmaps directory if not exist
-if [ ! -d mmaps ]
-then
- mkdir mmaps
-fi
-
-# Param control
-case "$1" in
- "1" )
- createHeader $1
- createMMaps $MAP_LIST_A $MAP_LIST_B $MAP_LIST_C $MAP_LIST_D &
- ;;
- "2" )
- createHeader $1
- createMMaps $MAP_LIST_A $MAP_LIST_D &
- createMMaps $MAP_LIST_B $MAP_LIST_C &
- ;;
- "3" )
- createHeader $1
- createMMaps $MAP_LIST_A $MAP_LIST_D1&
- createMMaps $MAP_LIST_B $MAP_LIST_D2&
- createMMaps $MAP_LIST_C $MAP_LIST_D3&
- ;;
- "4" )
- createHeader $1
- createMMaps $MAP_LIST_A &
- createMMaps $MAP_LIST_B &
- createMMaps $MAP_LIST_C &
- createMMaps $MAP_LIST_D &
- ;;
- "offmesh" )
- echo "`date`: Recreate offmeshs from file $OFFMESH_FILE" | tee -a $LOG_FILE
- echo "Recreate offmeshs from file $OFFMESH_FILE" | tee -a $DETAIL_LOG_FILE
- while read map tile line
- do
- ./mmaps_generator $PARAMS $OFFMESH $map --tile $tile | tee -a $DETAIL_LOG_FILE
- echo "`date`: Recreated $map $tile from $OFFMESH_FILE" | tee -a $LOG_FILE
- done < $OFFMESH_FILE &
- ;;
- * )
- badParam
- exit 1
- ;;
-esac
-
-wait
-
-echo | tee -a $LOG_FILE
-echo | tee -a $DETAIL_LOG_FILE
-echo "`date`: Finished creating MoveMaps" | tee -a $LOG_FILE
-echo "`date`: Finished creating MoveMaps" >> $DETAIL_LOG_FILE
diff --git a/contrib/extract/vmap4assembler.exe b/contrib/extract/vmap4assembler.exe
deleted file mode 100644
index e5331a5f70e..00000000000
--- a/contrib/extract/vmap4assembler.exe
+++ /dev/null
Binary files differ
diff --git a/contrib/extract/vmap4extractor.exe b/contrib/extract/vmap4extractor.exe
deleted file mode 100644
index 4866904d04f..00000000000
--- a/contrib/extract/vmap4extractor.exe
+++ /dev/null
Binary files differ
diff --git a/src/tools/mmaps_generator/MapBuilder.cpp b/src/tools/mmaps_generator/MapBuilder.cpp
index e47b2e5b44f..a0c40bc4392 100644
--- a/src/tools/mmaps_generator/MapBuilder.cpp
+++ b/src/tools/mmaps_generator/MapBuilder.cpp
@@ -158,13 +158,31 @@ namespace MMAP
}
/**************************************************************************/
- void MapBuilder::buildAllMaps()
+ void MapBuilder::buildAllMaps(int threads)
{
+ int running = 0;
for (TileList::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it)
{
uint32 mapID = (*it).first;
if (!shouldSkipMap(mapID))
- buildMap(mapID);
+ {
+ if (threads > 1)
+ {
+ BuilderThread* thread = new BuilderThread(this, mapID);
+ thread->activate();
+ ++running;
+ // Do not allow more than {threads} threads running at the same time
+ if (running == threads)
+ {
+ // Wait for previous threads to finish
+ ACE_Thread_Manager::instance()->wait();
+ // Reset the number of running threads
+ running = 0;
+ }
+ }
+ else
+ buildMap(mapID);
+ }
}
}
@@ -306,7 +324,7 @@ namespace MMAP
}
// now start building mmtiles for each tile
- printf("We have %u tiles. \n", (unsigned int)tiles->size());
+ printf("[Map %i] We have %u tiles. \n", mapID, (unsigned int)tiles->size());
for (set<uint32>::iterator it = tiles->begin(); it != tiles->end(); ++it)
{
uint32 tileX, tileY;
@@ -415,10 +433,10 @@ namespace MMAP
navMeshParams.maxPolys = maxPolysPerTile;
navMesh = dtAllocNavMesh();
- printf("Creating navMesh... \r");
+ printf("[Map %i] Creating navMesh...\n", mapID);
if (!navMesh->init(&navMeshParams))
{
- printf("Failed creating navmesh! \n");
+ printf("[Map %i] Failed creating navmesh! \n", mapID);
return;
}
@@ -430,7 +448,7 @@ namespace MMAP
{
dtFreeNavMesh(navMesh);
char message[1024];
- sprintf(message, "Failed to open %s for writing!\n", fileName);
+ sprintf(message, "[Map %i] Failed to open %s for writing!\n", mapID, fileName);
perror(message);
return;
}
@@ -446,9 +464,9 @@ namespace MMAP
dtNavMesh* navMesh)
{
// console output
- char tileString[10];
- sprintf(tileString, "[%02i,%02i]: ", tileX, tileY);
- printf("%s Building movemap tiles... \r", tileString);
+ char tileString[20];
+ sprintf(tileString, "[Map %03i] [%02i,%02i]: ", mapID, tileX, tileY);
+ printf("%s Building movemap tiles...\n", tileString);
IntermediateValues iv;
@@ -510,14 +528,14 @@ namespace MMAP
rcPolyMesh** pmmerge = new rcPolyMesh*[TILES_PER_MAP * TILES_PER_MAP];
if (!pmmerge)
{
- printf("%s alloc pmmerge FIALED! \r", tileString);
+ printf("%s alloc pmmerge FIALED!\n", tileString);
return;
}
rcPolyMeshDetail** dmmerge = new rcPolyMeshDetail*[TILES_PER_MAP * TILES_PER_MAP];
if (!dmmerge)
{
- printf("%s alloc dmmerge FIALED! \r", tileString);
+ printf("%s alloc dmmerge FIALED!\n", tileString);
return;
}
@@ -539,7 +557,7 @@ namespace MMAP
tile.solid = rcAllocHeightfield();
if (!tile.solid || !rcCreateHeightfield(m_rcContext, *tile.solid, tileCfg.width, tileCfg.height, tileCfg.bmin, tileCfg.bmax, tileCfg.cs, tileCfg.ch))
{
- printf("%sFailed building heightfield! \n", tileString);
+ printf("%s Failed building heightfield! \n", tileString);
continue;
}
@@ -560,33 +578,33 @@ namespace MMAP
tile.chf = rcAllocCompactHeightfield();
if (!tile.chf || !rcBuildCompactHeightfield(m_rcContext, tileCfg.walkableHeight, tileCfg.walkableClimb, *tile.solid, *tile.chf))
{
- printf("%sFailed compacting heightfield! \n", tileString);
+ printf("%s Failed compacting heightfield! \n", tileString);
continue;
}
// build polymesh intermediates
if (!rcErodeWalkableArea(m_rcContext, config.walkableRadius, *tile.chf))
{
- printf("%sFailed eroding area! \n", tileString);
+ printf("%s Failed eroding area! \n", tileString);
continue;
}
if (!rcBuildDistanceField(m_rcContext, *tile.chf))
{
- printf("%sFailed building distance field! \n", tileString);
+ printf("%s Failed building distance field! \n", tileString);
continue;
}
if (!rcBuildRegions(m_rcContext, *tile.chf, tileCfg.borderSize, tileCfg.minRegionArea, tileCfg.mergeRegionArea))
{
- printf("%sFailed building regions! \n", tileString);
+ printf("%s Failed building regions! \n", tileString);
continue;
}
tile.cset = rcAllocContourSet();
if (!tile.cset || !rcBuildContours(m_rcContext, *tile.chf, tileCfg.maxSimplificationError, tileCfg.maxEdgeLen, *tile.cset))
{
- printf("%sFailed building contours! \n", tileString);
+ printf("%s Failed building contours! \n", tileString);
continue;
}
@@ -594,14 +612,14 @@ namespace MMAP
tile.pmesh = rcAllocPolyMesh();
if (!tile.pmesh || !rcBuildPolyMesh(m_rcContext, *tile.cset, tileCfg.maxVertsPerPoly, *tile.pmesh))
{
- printf("%sFailed building polymesh! \n", tileString);
+ printf("%s Failed building polymesh! \n", tileString);
continue;
}
tile.dmesh = rcAllocPolyMeshDetail();
if (!tile.dmesh || !rcBuildPolyMeshDetail(m_rcContext, *tile.pmesh, *tile.chf, tileCfg.detailSampleDist, tileCfg .detailSampleMaxError, *tile.dmesh))
{
- printf("%sFailed building polymesh detail! \n", tileString);
+ printf("%s Failed building polymesh detail! \n", tileString);
continue;
}
@@ -627,7 +645,7 @@ namespace MMAP
iv.polyMesh = rcAllocPolyMesh();
if (!iv.polyMesh)
{
- printf("%s alloc iv.polyMesh FIALED! \r", tileString);
+ printf("%s alloc iv.polyMesh FIALED!\n", tileString);
return;
}
rcMergePolyMeshes(m_rcContext, pmmerge, nmerge, *iv.polyMesh);
@@ -635,16 +653,16 @@ namespace MMAP
iv.polyMeshDetail = rcAllocPolyMeshDetail();
if (!iv.polyMeshDetail)
{
- printf("%s alloc m_dmesh FIALED! \r", tileString);
+ printf("%s alloc m_dmesh FIALED!\n", tileString);
return;
}
rcMergePolyMeshDetails(m_rcContext, dmmerge, nmerge, *iv.polyMeshDetail);
// free things up
- delete [] pmmerge;
- delete [] dmmerge;
+ delete[] pmmerge;
+ delete[] dmmerge;
- delete [] tiles;
+ delete[] tiles;
// remove padding for extraction
for (int i = 0; i < iv.polyMesh->nverts; ++i)
@@ -736,7 +754,7 @@ namespace MMAP
continue;
}
- printf("%s Building navmesh tile... \r", tileString);
+ printf("%s Building navmesh tile...\n", tileString);
if (!dtCreateNavMeshData(&params, &navData, &navDataSize))
{
printf("%s Failed building navmesh tile! \n", tileString);
@@ -744,7 +762,7 @@ namespace MMAP
}
dtTileRef tileRef = 0;
- printf("%s Adding tile to navmesh... \r", tileString);
+ printf("%s Adding tile to navmesh...\n", tileString);
// DT_TILE_FREE_DATA tells detour to unallocate memory when the tile
// is removed via removeTile()
dtStatus dtResult = navMesh->addTile(navData, navDataSize, DT_TILE_FREE_DATA, 0, &tileRef);
@@ -761,13 +779,13 @@ namespace MMAP
if (!file)
{
char message[1024];
- sprintf(message, "Failed to open %s for writing!\n", fileName);
+ sprintf(message, "[Map %i] Failed to open %s for writing!\n", mapID, fileName);
perror(message);
navMesh->removeTile(tileRef, NULL, NULL);
continue;
}
- printf("%s Writing to file... \r", tileString);
+ printf("%s Writing to file...\n", tileString);
// write header
MmapTileHeader header;
diff --git a/src/tools/mmaps_generator/MapBuilder.h b/src/tools/mmaps_generator/MapBuilder.h
index 20789bf9bff..0c9dce05992 100644
--- a/src/tools/mmaps_generator/MapBuilder.h
+++ b/src/tools/mmaps_generator/MapBuilder.h
@@ -32,6 +32,8 @@
#include "Recast.h"
#include "DetourNavMesh.h"
+#include "ace/Task.h"
+
using namespace std;
using namespace VMAP;
@@ -80,7 +82,7 @@ namespace MMAP
void buildSingleTile(uint32 mapID, uint32 tileX, uint32 tileY);
// builds list of maps, then builds all of mmap tiles (based on the skip settings)
- void buildAllMaps();
+ void buildAllMaps(int threads);
private:
// detect maps and tiles
@@ -125,6 +127,22 @@ namespace MMAP
// build performance - not really used for now
rcContext* m_rcContext;
};
+
+ class BuilderThread : public ACE_Task<ACE_MT_SYNCH>
+ {
+ private:
+ MapBuilder* _builder;
+ uint32 _mapId;
+ public:
+ BuilderThread(MapBuilder* builder, uint32 mapId) : _builder(builder), _mapId(mapId) {}
+
+ int svc()
+ {
+ if (_builder)
+ _builder->buildMap(_mapId);
+ return 0;
+ }
+ };
}
#endif
diff --git a/src/tools/mmaps_generator/PathGenerator.cpp b/src/tools/mmaps_generator/PathGenerator.cpp
index 7d9f59ed138..45d0aff958c 100644
--- a/src/tools/mmaps_generator/PathGenerator.cpp
+++ b/src/tools/mmaps_generator/PathGenerator.cpp
@@ -71,7 +71,8 @@ bool handleArgs(int argc, char** argv,
bool &silent,
bool &bigBaseUnit,
char* &offMeshInputPath,
- char* &file)
+ char* &file,
+ int& threads)
{
char* param = NULL;
for (int i = 1; i < argc; ++i)
@@ -88,6 +89,14 @@ bool handleArgs(int argc, char** argv,
else
printf("invalid option for '--maxAngle', using default\n");
}
+ else if (strcmp(argv[i], "--threads") == 0)
+ {
+ param = argv[++i];
+ if (!param)
+ return false;
+ threads = atoi(param);
+ printf("Using %i threads to extract mmaps\n", threads);
+ }
else if (strcmp(argv[i], "--file") == 0)
{
param = argv[++i];
@@ -232,7 +241,7 @@ int finish(const char* message, int returnValue)
int main(int argc, char** argv)
{
- int mapnum = -1;
+ int threads = 3, mapnum = -1;
float maxAngle = 60.0f;
int tileX = -1, tileY = -1;
bool skipLiquid = false,
@@ -248,7 +257,7 @@ int main(int argc, char** argv)
bool validParam = handleArgs(argc, argv, mapnum,
tileX, tileY, maxAngle,
skipLiquid, skipContinents, skipJunkMaps, skipBattlegrounds,
- debugOutput, silent, bigBaseUnit, offMeshInputPath, file);
+ debugOutput, silent, bigBaseUnit, offMeshInputPath, file, threads);
if (!validParam)
return silent ? -1 : finish("You have specified invalid parameters", -1);
@@ -278,7 +287,7 @@ int main(int argc, char** argv)
else if (mapnum >= 0)
builder.buildMap(uint32(mapnum));
else
- builder.buildAllMaps();
+ builder.buildAllMaps(threads);
return silent ? 1 : finish("Movemap build is complete!", 1);
}