diff --git a/src/game/ChatCommands/MMapCommands.cpp b/src/game/ChatCommands/MMapCommands.cpp index 1146da321..39cdb2086 100644 --- a/src/game/ChatCommands/MMapCommands.cpp +++ b/src/game/ChatCommands/MMapCommands.cpp @@ -175,7 +175,7 @@ bool ChatHandler::HandleMmapLocCommand(char* /*args*/) int32 gx = 32 - player->GetPositionX() / SIZE_OF_GRIDS; int32 gy = 32 - player->GetPositionY() / SIZE_OF_GRIDS; - PSendSysMessage("%03u%02i%02i.mmtile", player->GetMapId(), gy, gx); + PSendSysMessage("%04u%02i%02i.mmtile", player->GetMapId(), gx, gy); PSendSysMessage("gridloc [%i,%i]", gx, gy); // calculate navmesh tile location diff --git a/src/game/WorldHandlers/GridMap.cpp b/src/game/WorldHandlers/GridMap.cpp index 06065db8a..31be70393 100644 --- a/src/game/WorldHandlers/GridMap.cpp +++ b/src/game/WorldHandlers/GridMap.cpp @@ -874,9 +874,9 @@ GridMapLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 Re */ bool GridMap::ExistMap(uint32 mapid, int gx, int gy) { - int len = sWorld.GetDataPath().length() + strlen("maps/%03u%02u%02u.map") + 1; + int len = sWorld.GetDataPath().length() + strlen("maps/%04u%02u%02u.map") + 1; char* tmp = new char[len]; - snprintf(tmp, len, (char*)(sWorld.GetDataPath() + "maps/%03u%02u%02u.map").c_str(), mapid, gx, gy); + snprintf(tmp, len, (char*)(sWorld.GetDataPath() + "maps/%04u%02u%02u.map").c_str(), mapid, (unsigned)gx, (unsigned)gy); FILE* pf = fopen(tmp, "rb"); @@ -1566,9 +1566,9 @@ GridMap* TerrainInfo::LoadMapAndVMap(const uint32 x, const uint32 y) GridMap* map = new GridMap(); // map file name - int len = sWorld.GetDataPath().length() + strlen("maps/%03u%02u%02u.map") + 1; + int len = sWorld.GetDataPath().length() + strlen("maps/%04u%02u%02u.map") + 1; char* tmp = new char[len]; - snprintf(tmp, len, (char*)(sWorld.GetDataPath() + "maps/%03u%02u%02u.map").c_str(), m_mapId, x, y); + snprintf(tmp, len, (char*)(sWorld.GetDataPath() + "maps/%04u%02u%02u.map").c_str(), m_mapId, x, y); DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "Loading map %s", tmp); if (!map->loadData(tmp)) diff --git a/src/game/WorldHandlers/MoveMap.cpp b/src/game/WorldHandlers/MoveMap.cpp index e405bc32d..dd231ef6a 100644 --- a/src/game/WorldHandlers/MoveMap.cpp +++ b/src/game/WorldHandlers/MoveMap.cpp @@ -239,9 +239,9 @@ namespace MMAP } // load and init dtNavMesh - read parameters from file - uint32 pathLen = sWorld.GetDataPath().length() + strlen("mmaps/%03i.mmap") + 1; + uint32 pathLen = sWorld.GetDataPath().length() + strlen("mmaps/%04u.mmap") + 1; char* fileName = new char[pathLen]; - snprintf(fileName, pathLen, (sWorld.GetDataPath() + "mmaps/%03i.mmap").c_str(), mapId); + snprintf(fileName, pathLen, (sWorld.GetDataPath() + "mmaps/%04u.mmap").c_str(), mapId); FILE* file = fopen(fileName, "rb"); if (!file) @@ -258,7 +258,7 @@ namespace MMAP size_t file_read = fread(¶ms, sizeof(dtNavMeshParams), 1, file); if (file_read <= 0) { - sLog.outError("MMAP:loadMapData: Failed to load mmap %03u from file %s", mapId, fileName); + sLog.outError("MMAP:loadMapData: Failed to load mmap %04u from file %s", mapId, fileName); delete[] fileName; fclose(file); return false; @@ -271,14 +271,14 @@ namespace MMAP if (dtStatusFailed(dtResult)) { dtFreeNavMesh(mesh); - sLog.outError("MMAP:loadMapData: Failed to initialize dtNavMesh for mmap %03u from file %s", mapId, fileName); + sLog.outError("MMAP:loadMapData: Failed to initialize dtNavMesh for mmap %04u from file %s", mapId, fileName); delete[] fileName; return false; } delete[] fileName; - DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:loadMapData: Loaded %03i.mmap", mapId); + DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:loadMapData: Loaded %04u.mmap", mapId); // store inside our map list MMapData* mmap_data = new MMapData(mesh); @@ -309,20 +309,20 @@ namespace MMAP uint32 packedGridPos = packTileID(x, y); if (mmap->mmapLoadedTiles.find(packedGridPos) != mmap->mmapLoadedTiles.end()) { - sLog.outError("MMAP:loadMap: Asked to load already loaded navmesh tile. %03u%02i%02i.mmtile", mapId, x, y); + sLog.outError("MMAP:loadMap: Asked to load already loaded navmesh tile. %04u%02i%02i.mmtile", mapId, x, y); return false; } - // MMap tile files follow the same swapped grid order as VMap tiles. - const int32 filenameTileX = y; - const int32 filenameTileY = x; + // MMap tile files follow the same grid order as VMap tiles. + const int32 filenameTileX = x; + const int32 filenameTileY = y; - // load this tile :: mmaps/MMMYYXX.mmtile + // load this tile :: mmaps/MMMXXYY.mmtile uint32 pathLen = sWorld.GetDataPath().length() + - strlen("mmaps/%03i%02i%02i.mmtile") + 1; + strlen("mmaps/%04u%02i%02i.mmtile") + 1; char* fileName = new char[pathLen]; snprintf(fileName, pathLen, - (sWorld.GetDataPath() + "mmaps/%03i%02i%02i.mmtile").c_str(), + (sWorld.GetDataPath() + "mmaps/%04u%02i%02i.mmtile").c_str(), mapId, filenameTileX, filenameTileY); FILE* file = fopen(fileName, "rb"); @@ -341,7 +341,7 @@ namespace MMAP if (file_read <= 0) { sLog.outError("MMAP:loadMap: Could not load mmap " - "%03u%02i%02i.mmtile", + "%04u%02i%02i.mmtile", mapId, filenameTileX, filenameTileY); fclose(file); return false; @@ -350,7 +350,7 @@ namespace MMAP if (fileHeader.mmapMagic != MMAP_MAGIC) { sLog.outError("MMAP:loadMap: Bad header in mmap " - "%03u%02i%02i.mmtile", + "%04u%02i%02i.mmtile", mapId, filenameTileX, filenameTileY); fclose(file); return false; @@ -358,7 +358,7 @@ namespace MMAP if (fileHeader.mmapVersion != MMAP_VERSION) { - sLog.outError("MMAP:loadMap: %03u%02i%02i.mmtile was built " + sLog.outError("MMAP:loadMap: %04u%02i%02i.mmtile was built " "with generator v%i, expected v%i", mapId, filenameTileX, filenameTileY, fileHeader.mmapVersion, MMAP_VERSION); @@ -373,7 +373,7 @@ namespace MMAP if (!result) { sLog.outError("MMAP:loadMap: Bad header or data in mmap " - "%03u%02i%02i.mmtile", + "%04u%02i%02i.mmtile", mapId, filenameTileX, filenameTileY); fclose(file); return false; @@ -389,7 +389,7 @@ namespace MMAP if (dtStatusFailed(dtResult)) { sLog.outError("MMAP:loadMap: Could not load " - "%03u%02i%02i.mmtile into navmesh", + "%04u%02i%02i.mmtile into navmesh", mapId, filenameTileX, filenameTileY); dtFree(data); return false; @@ -399,7 +399,7 @@ namespace MMAP ++loadedTiles; DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:loadMap: Loaded mmtile " - "%03i[%02i,%02i] into %03i[%02i,%02i]", + "%04u[%02i,%02i] into %04u[%02i,%02i]", mapId, filenameTileX, filenameTileY, mapId, header->x, header->y); return true; @@ -411,7 +411,7 @@ namespace MMAP if (loadedMMaps.find(mapId) == loadedMMaps.end()) { // file may not exist, therefore not loaded - DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMap: Asked to unload not loaded navmesh map. %03u%02i%02i.mmtile", mapId, x, y); + DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMap: Asked to unload not loaded navmesh map. %04u%02i%02i.mmtile", mapId, x, y); return false; } @@ -422,7 +422,7 @@ namespace MMAP if (mmap->mmapLoadedTiles.find(packedGridPos) == mmap->mmapLoadedTiles.end()) { // file may not exist, therefore not loaded - DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMap: Asked to unload not loaded navmesh tile. %03u%02i%02i.mmtile", mapId, x, y); + DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMap: Asked to unload not loaded navmesh tile. %04u%02i%02i.mmtile", mapId, x, y); return false; } @@ -435,14 +435,14 @@ namespace MMAP // this is technically a memory leak // if the grid is later reloaded, dtNavMesh::addTile will return error but no extra memory is used // we can not recover from this error - assert out - sLog.outError("MMAP:unloadMap: Could not unload %03u%02i%02i.mmtile from navmesh", mapId, x, y); + sLog.outError("MMAP:unloadMap: Could not unload %04u%02i%02i.mmtile from navmesh", mapId, x, y); MANGOS_ASSERT(false); } else { mmap->mmapLoadedTiles.erase(packedGridPos); --loadedTiles; - DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMap: Unloaded mmtile %03i[%02i,%02i] from %03i", mapId, x, y, mapId); + DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMap: Unloaded mmtile %04u[%02i,%02i] from %04u", mapId, x, y, mapId); return true; } @@ -454,7 +454,7 @@ namespace MMAP if (loadedMMaps.find(mapId) == loadedMMaps.end()) { // file may not exist, therefore not loaded - DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMap: Asked to unload not loaded navmesh map %03u", mapId); + DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMap: Asked to unload not loaded navmesh map %04u", mapId); return false; } @@ -467,18 +467,18 @@ namespace MMAP dtStatus dtResult = mmap->navMesh->removeTile(i->second, NULL, NULL); if (dtStatusFailed(dtResult)) { - sLog.outError("MMAP:unloadMap: Could not unload %03u%02i%02i.mmtile from navmesh", mapId, x, y); + sLog.outError("MMAP:unloadMap: Could not unload %04u%02u%02u.mmtile from navmesh", mapId, x, y); } else { --loadedTiles; - DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMap: Unloaded mmtile %03i[%02i,%02i] from %03i", mapId, x, y, mapId); + DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMap: Unloaded mmtile %04u[%02u,%02u] from %04u", mapId, x, y, mapId); } } delete mmap; loadedMMaps.erase(mapId); - DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMap: Unloaded %03i.mmap", mapId); + DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMap: Unloaded %04u.mmap", mapId); return true; } @@ -489,14 +489,14 @@ namespace MMAP if (loadedMMaps.find(mapId) == loadedMMaps.end()) { // file may not exist, therefore not loaded - DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMapInstance: Asked to unload not loaded navmesh map %03u", mapId); + DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMapInstance: Asked to unload not loaded navmesh map %04u", mapId); return false; } MMapData* mmap = loadedMMaps[mapId]; if (mmap->navMeshQueries.find(instanceId) == mmap->navMeshQueries.end()) { - DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMapInstance: Asked to unload not loaded dtNavMeshQuery mapId %03u instanceId %u", mapId, instanceId); + DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMapInstance: Asked to unload not loaded dtNavMeshQuery mapId %04u instanceId %u", mapId, instanceId); return false; } @@ -504,7 +504,7 @@ namespace MMAP dtFreeNavMeshQuery(query); mmap->navMeshQueries.erase(instanceId); - DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMapInstance: Unloaded mapId %03u instanceId %u", mapId, instanceId); + DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:unloadMapInstance: Unloaded mapId %04u instanceId %u", mapId, instanceId); return true; } @@ -536,11 +536,11 @@ namespace MMAP if (dtStatusFailed(dtResult)) { dtFreeNavMeshQuery(query); - sLog.outError("MMAP:GetNavMeshQuery: Failed to initialize dtNavMeshQuery for mapId %03u instanceId %u", mapId, instanceId); + sLog.outError("MMAP:GetNavMeshQuery: Failed to initialize dtNavMeshQuery for mapId %04u instanceId %u", mapId, instanceId); return NULL; } - DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:GetNavMeshQuery: created dtNavMeshQuery for mapId %03u instanceId %u", mapId, instanceId); + DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "MMAP:GetNavMeshQuery: created dtNavMeshQuery for mapId %04u instanceId %u", mapId, instanceId); mmap->navMeshQueries.insert(std::pair(instanceId, query)); } diff --git a/src/game/vmap/MapTree.cpp b/src/game/vmap/MapTree.cpp index dee3253e5..fbd1d99ee 100644 --- a/src/game/vmap/MapTree.cpp +++ b/src/game/vmap/MapTree.cpp @@ -162,8 +162,8 @@ namespace VMAP { std::stringstream tilefilename; tilefilename.fill('0'); - tilefilename << std::setw(3) << mapID << "_"; - tilefilename << std::setw(2) << tileY << "_" << std::setw(2) << tileX << ".vmtile"; + tilefilename << std::setw(4) << mapID << "_"; + tilefilename << std::setw(2) << tileX << "_" << std::setw(2) << tileY << ".vmtile"; return tilefilename.str(); } diff --git a/src/game/vmap/MapTree.h b/src/game/vmap/MapTree.h index df776f035..853d642fd 100644 --- a/src/game/vmap/MapTree.h +++ b/src/game/vmap/MapTree.h @@ -119,7 +119,7 @@ namespace VMAP * @param tileX The tile X coordinate. * @param tileY The tile Y coordinate. */ - static void unpackTileID(uint32 ID, uint32& tileX, uint32& tileY) { tileX = ID >> 16; tileY = ID & 0xFF; } + static void unpackTileID(uint32 ID, uint32& tileX, uint32& tileY) { tileX = ID >> 16; tileY = ID & 0xFFFF; } /** * @brief Checks if a map can be loaded. diff --git a/src/game/vmap/TileAssembler.cpp b/src/game/vmap/TileAssembler.cpp index c07554c7a..758140088 100644 --- a/src/game/vmap/TileAssembler.cpp +++ b/src/game/vmap/TileAssembler.cpp @@ -174,7 +174,7 @@ namespace VMAP // Write map tree file std::stringstream mapfilename; - mapfilename << iDestDir << "/" << std::setfill('0') << std::setw(3) << map_iter->first << ".vmtree"; + mapfilename << iDestDir << "/" << std::setfill('0') << std::setw(4) << map_iter->first << ".vmtree"; FILE* mapfile = fopen(mapfilename.str().c_str(), "wb"); if (!mapfile) { @@ -232,7 +232,7 @@ namespace VMAP uint32 nSpawns = tileEntries.count(tile->first); std::stringstream tilefilename; tilefilename.fill('0'); - tilefilename << iDestDir << "/" << std::setw(3) << map_iter->first << "_"; + tilefilename << iDestDir << "/" << std::setw(4) << map_iter->first << "_"; uint32 x, y; StaticMapTree::unpackTileID(tile->first, x, y); tilefilename << std::setw(2) << x << "_" << std::setw(2) << y << ".vmtile"; diff --git a/src/game/vmap/VMapManager2.cpp b/src/game/vmap/VMapManager2.cpp index f7f747b1d..76bcb23d8 100644 --- a/src/game/vmap/VMapManager2.cpp +++ b/src/game/vmap/VMapManager2.cpp @@ -106,7 +106,7 @@ namespace VMAP std::string VMapManager2::getMapFileName(unsigned int pMapId) { std::stringstream fname; - fname.width(3); + fname.width(4); fname << std::setfill('0') << pMapId << std::string(MAP_FILENAME_EXTENSION2); return fname.str(); }