Tools/mmaps_generator: Remove confusing tile X/Y coord swapping

This commit is contained in:
Shauren
2025-10-31 11:25:26 +01:00
parent 4bb1ea18bc
commit f1c7caec27
4 changed files with 28 additions and 28 deletions

View File

@@ -37,7 +37,7 @@ namespace MMAP
auto debugWrite = [&](char const* extension, auto const* data)
{
std::string fileName = Trinity::StringFormat("meshes/{:04}{:02}{:02}.{}", mapID, tileY, tileX, extension);
std::string fileName = Trinity::StringFormat("meshes/{:04}{:02}{:02}.{}", mapID, tileX, tileY, extension);
if (auto file = Trinity::make_unique_ptr_with_deleter<&::fclose>(fopen(fileName.c_str(), "wb")))
{
this->debugWrite(file.get(), data);
@@ -191,7 +191,7 @@ namespace MMAP
void IntermediateValues::generateObjFile(uint32 mapID, uint32 tileX, uint32 tileY, MeshData const& meshData)
{
std::string objFileName;
objFileName = Trinity::StringFormat("meshes/map{:04}{:02}{:02}.obj", mapID, tileY, tileX);
objFileName = Trinity::StringFormat("meshes/map{:04}{:02}{:02}.obj", mapID, tileX, tileY);
auto objFile = Trinity::make_unique_ptr_with_deleter<&::fclose>(fopen(objFileName.c_str(), "wb"));
if (!objFile)
@@ -219,7 +219,7 @@ namespace MMAP
for (std::size_t i = 0; i < allTris.size() / 3; i++)
fprintf(objFile.get(), "f %i %i %i\n", tris[i * 3] + 1, tris[i * 3 + 1] + 1, tris[i * 3 + 2] + 1);
TC_LOG_INFO("maps.mmapgen.debug", "[Map {:04}] [{:02},{:02}]: Writing debug output object file...", mapID, tileY, tileX);
TC_LOG_INFO("maps.mmapgen.debug", "[Map {:04}] [{:02},{:02}]: Writing debug output object file...", mapID, tileX, tileY);
objFileName = Trinity::StringFormat("meshes/map{:04}.map", mapID);
@@ -233,7 +233,7 @@ namespace MMAP
char b = '\0';
fwrite(&b, sizeof(char), 1, objFile.get());
objFileName = Trinity::StringFormat("meshes/map{:04}{:02}{:02}.mesh", mapID, tileY, tileX);
objFileName = Trinity::StringFormat("meshes/map{:04}{:02}{:02}.mesh", mapID, tileX, tileY);
objFile.reset(fopen(objFileName.c_str(), "wb"));
if (!objFile)
{

View File

@@ -126,12 +126,12 @@ namespace MMAP
&& fread(&versionMagic, sizeof(versionMagic), 1, tileList.get()) == 1
&& versionMagic == MapVersionMagic
&& fread(&build, sizeof(build), 1, tileList.get()) == 1
&& fread(std::data(tilesData), 64 * 64, 1, tileList.get()) == 1)
&& fread(std::data(tilesData), std::size(tilesData), 1, tileList.get()) == 1)
{
Trinity::Containers::FlatSet<uint32>& tiles = m_tiles[*mapId];
for (uint32 tileX = 0; tileX < 64; ++tileX)
for (uint32 tileY = 0; tileY < 64; ++tileY)
if (tilesData[tileX * 64 + tileY] == '1')
if (tilesData[std::size(tilesData) - 1 - (tileX * 64 + tileY)] == '1')
if (tiles.insert(VMAP::StaticMapTree::packTileID(tileX, tileY)).second)
++m_totalTiles;
}
@@ -163,7 +163,7 @@ namespace MMAP
uint32 tileX = Trinity::StringTo<uint32>(std::string_view(fileName).substr(8, 2)).value_or(0);
uint32 tileY = Trinity::StringTo<uint32>(std::string_view(fileName).substr(5, 2)).value_or(0);
uint32 tileID = VMAP::StaticMapTree::packTileID(tileY, tileX);
uint32 tileID = VMAP::StaticMapTree::packTileID(tileX, tileY);
if (tiles.insert(tileID).second)
++m_totalTiles;
@@ -561,7 +561,7 @@ namespace MMAP
/**************************************************************************/
bool MapTileBuilder::shouldSkipTile(uint32 mapID, uint32 tileX, uint32 tileY) const
{
std::string fileName = Trinity::StringFormat("mmaps/{:04}{:02}{:02}.mmtile", mapID, tileY, tileX);
std::string fileName = Trinity::StringFormat("mmaps/{:04}{:02}{:02}.mmtile", mapID, tileX, tileY);
auto file = Trinity::make_unique_ptr_with_deleter<&::fclose>(fopen(fileName.c_str(), "rb"));
if (!file)
return false;

View File

@@ -69,17 +69,17 @@ namespace MMAP
{
if (loadMap(mapID, tileX, tileY, meshData, vmapManager, ENTIRE))
{
loadMap(mapID, tileX+1, tileY, meshData, vmapManager, LEFT);
loadMap(mapID, tileX-1, tileY, meshData, vmapManager, RIGHT);
loadMap(mapID, tileX, tileY+1, meshData, vmapManager, TOP);
loadMap(mapID, tileX, tileY-1, meshData, vmapManager, BOTTOM);
loadMap(mapID, tileX, tileY+1, meshData, vmapManager, LEFT);
loadMap(mapID, tileX, tileY-1, meshData, vmapManager, RIGHT);
loadMap(mapID, tileX+1, tileY, meshData, vmapManager, TOP);
loadMap(mapID, tileX-1, tileY, meshData, vmapManager, BOTTOM);
}
}
/**************************************************************************/
bool TerrainBuilder::loadMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData& meshData, VMAP::VMapManager* vmapManager, Spot portion)
{
std::string mapFileName = Trinity::StringFormat("maps/{:04}_{:02}_{:02}.map", mapID, tileY, tileX);
std::string mapFileName = Trinity::StringFormat("maps/{:04}_{:02}_{:02}.map", mapID, tileX, tileY);
auto mapFile = Trinity::make_unique_ptr_with_deleter<&::fclose>(fopen(mapFileName.c_str(), "rb"));
if (!mapFile)
@@ -87,7 +87,7 @@ namespace MMAP
int32 parentMapId = vmapManager->getParentMapId(mapID);
while (!mapFile && parentMapId != -1)
{
mapFileName = Trinity::StringFormat("maps/{:04}_{:02}_{:02}.map", parentMapId, tileY, tileX);
mapFileName = Trinity::StringFormat("maps/{:04}_{:02}_{:02}.map", parentMapId, tileX, tileY);
mapFile.reset(fopen(mapFileName.c_str(), "rb"));
parentMapId = vmapManager->getParentMapId(parentMapId);
}
@@ -274,9 +274,9 @@ namespace MMAP
col < lheader.offsetX || col >= lheader.offsetX + lheader.width)
{
// dummy vert using invalid height
liquidVerts[(count + i) * 3 + 0] = (xoffset + col * GRID_PART_SIZE) * -1;
liquidVerts[(count + i) * 3 + 0] = (yoffset + col * GRID_PART_SIZE) * -1;
liquidVerts[(count + i) * 3 + 1] = INVALID_MAP_LIQ_HEIGHT;
liquidVerts[(count + i) * 3 + 2] = (yoffset + row * GRID_PART_SIZE) * -1;
liquidVerts[(count + i) * 3 + 2] = (xoffset + row * GRID_PART_SIZE) * -1;
continue;
}
@@ -290,9 +290,9 @@ namespace MMAP
{
row = i / V9_SIZE;
col = i % V9_SIZE;
liquidVerts[(count + i) * 3 + 0] = (xoffset + col * GRID_PART_SIZE) * -1;
liquidVerts[(count + i) * 3 + 0] = (yoffset + col * GRID_PART_SIZE) * -1;
liquidVerts[(count + i) * 3 + 1] = lheader.liquidLevel;
liquidVerts[(count + i) * 3 + 2] = (yoffset + row * GRID_PART_SIZE) * -1;
liquidVerts[(count + i) * 3 + 2] = (xoffset + row * GRID_PART_SIZE) * -1;
}
}
@@ -467,14 +467,14 @@ namespace MMAP
switch (grid)
{
case GRID_V9:
coord[0] = (xOffset + (int)(index % V9_SIZE) * GRID_PART_SIZE) * -1.f;
coord[0] = (yOffset + (int)(index % V9_SIZE) * GRID_PART_SIZE) * -1.f;
coord[1] = v[index];
coord[2] = (yOffset + (int)(index / (V9_SIZE)) * GRID_PART_SIZE) * -1.f;
coord[2] = (xOffset + (int)(index / (V9_SIZE)) * GRID_PART_SIZE) * -1.f;
break;
case GRID_V8:
coord[0] = (xOffset + (int)(index % V8_SIZE) * GRID_PART_SIZE + GRID_PART_SIZE / 2.f) * -1.f;
coord[0] = (yOffset + (int)(index % V8_SIZE) * GRID_PART_SIZE + GRID_PART_SIZE / 2.f) * -1.f;
coord[1] = v[index];
coord[2] = (yOffset + (int)(index / (V8_SIZE)) * GRID_PART_SIZE + GRID_PART_SIZE / 2.f) * -1.f;
coord[2] = (xOffset + (int)(index / (V8_SIZE)) * GRID_PART_SIZE + GRID_PART_SIZE / 2.f) * -1.f;
break;
}
}
@@ -531,9 +531,9 @@ namespace MMAP
{
// wow coords: x, y, height
// coord is mirroed about the horizontal axes
coord[0] = (xOffset + (int)(index % V9_SIZE) * GRID_PART_SIZE) * -1.f;
coord[0] = (yOffset + (int)(index % V9_SIZE) * GRID_PART_SIZE) * -1.f;
coord[1] = v[index2];
coord[2] = (yOffset + (int)(index / (V9_SIZE)) * GRID_PART_SIZE) * -1.f;
coord[2] = (xOffset + (int)(index / (V9_SIZE)) * GRID_PART_SIZE) * -1.f;
}
/**************************************************************************/

View File

@@ -102,7 +102,7 @@ namespace MMAP
m_terrainBuilder.loadMap(mapID, tileX, tileY, meshData, vmapManager.get());
// get model data
m_terrainBuilder.loadVMap(mapID, tileY, tileX, meshData, vmapManager.get());
m_terrainBuilder.loadVMap(mapID, tileX, tileY, meshData, vmapManager.get());
// if there is no data, give up now
if (meshData.solidVerts.empty() && meshData.liquidVerts.empty())
@@ -448,7 +448,7 @@ namespace MMAP
});
// file output
std::string fileName = Trinity::StringFormat("mmaps/{:04}{:02}{:02}.mmtile", mapID, tileY, tileX);
std::string fileName = Trinity::StringFormat("mmaps/{:04}{:02}{:02}.mmtile", mapID, tileX, tileY);
auto file = Trinity::make_unique_ptr_with_deleter<&::fclose>(fopen(fileName.c_str(), "wb"));
if (!file)
{
@@ -481,8 +481,8 @@ namespace MMAP
}
// this is for width and depth
bmax[0] = (32 - int(tileX)) * GRID_SIZE;
bmax[2] = (32 - int(tileY)) * GRID_SIZE;
bmax[0] = (32 - int(tileY)) * GRID_SIZE;
bmax[2] = (32 - int(tileX)) * GRID_SIZE;
bmin[0] = bmax[0] - GRID_SIZE;
bmin[2] = bmax[2] - GRID_SIZE;
}