Skip to content
Open
2 changes: 1 addition & 1 deletion src/game/ChatCommands/MMapCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/game/WorldHandlers/GridMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Comment on lines +877 to +879

FILE* pf = fopen(tmp, "rb");

Expand Down Expand Up @@ -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);
Comment thread
billy1arm marked this conversation as resolved.
DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "Loading map %s", tmp);

if (!map->loadData(tmp))
Expand Down
62 changes: 31 additions & 31 deletions src/game/WorldHandlers/MoveMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -258,7 +258,7 @@ namespace MMAP
size_t file_read = fread(&params, 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;
Expand All @@ -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);
Expand Down Expand Up @@ -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
Comment thread
billy1arm marked this conversation as resolved.
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");
Expand All @@ -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;
Expand All @@ -350,15 +350,15 @@ 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;
}

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);
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Comment thread
billy1arm marked this conversation as resolved.
return true;
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}
Expand All @@ -489,22 +489,22 @@ 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;
}

dtNavMeshQuery* query = mmap->navMeshQueries[instanceId];

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;
}
Expand Down Expand Up @@ -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<uint32, dtNavMeshQuery*>(instanceId, query));
}

Expand Down
4 changes: 2 additions & 2 deletions src/game/vmap/MapTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion src/game/vmap/MapTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/game/vmap/TileAssembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/game/vmap/VMapManager2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Loading