aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Maps/Map.cpp23
-rw-r--r--src/server/game/Maps/Map.h2
-rw-r--r--src/tools/map_extractor/System.cpp55
3 files changed, 57 insertions, 23 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index a76fa61851d..7546b298ff6 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -92,6 +92,29 @@ Map::~Map()
void Map::DiscoverGridMapFiles()
{
+ std::string tileListName = Trinity::StringFormat("%smaps/%04u.tilelist", sWorld->GetDataPath().c_str(), GetId());
+ // tile list is optional
+ if (FILE* tileList = fopen(tileListName.c_str(), "rb"))
+ {
+ u_map_magic mapMagic;
+ u_map_magic versionMagic;
+ uint32 build;
+ char tilesData[MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS];
+ if (fread(&mapMagic.asUInt, sizeof(u_map_magic), 1, tileList) == 1
+ && mapMagic.asUInt == MapMagic.asUInt
+ && fread(&versionMagic.asUInt, sizeof(u_map_magic), 1, tileList) == 1
+ && versionMagic.asUInt == MapVersionMagic.asUInt
+ && fread(&build, sizeof(build), 1, tileList) == 1
+ && fread(&tilesData[0], MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS, 1, tileList) == 1)
+ {
+ i_gridFileExists = std::bitset<MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS>(tilesData, Trinity::Containers::Size(tilesData));
+ fclose(tileList);
+ return;
+ }
+
+ fclose(tileList);
+ }
+
for (uint32 gx = 0; gx < MAX_NUMBER_OF_GRIDS; ++gx)
for (uint32 gy = 0; gy < MAX_NUMBER_OF_GRIDS; ++gy)
i_gridFileExists[gx * MAX_NUMBER_OF_GRIDS + gy] = ExistMap(GetId(), gx, gy, false);
diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h
index d1cf310262d..7fd66491168 100644
--- a/src/server/game/Maps/Map.h
+++ b/src/server/game/Maps/Map.h
@@ -91,7 +91,7 @@ struct map_fileheader
{
u_map_magic mapMagic;
u_map_magic versionMagic;
- u_map_magic buildMagic;
+ uint32 buildMagic;
uint32 areaMapOffset;
uint32 areaMapSize;
uint32 heightMapOffset;
diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp
index 8fb4e7f7a66..878cc5072a4 100644
--- a/src/tools/map_extractor/System.cpp
+++ b/src/tools/map_extractor/System.cpp
@@ -28,6 +28,7 @@
#include <CascLib.h>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
+#include <bitset>
#include <cstdio>
#include <deque>
#include <fstream>
@@ -1121,34 +1122,44 @@ void ExtractMaps(uint32 build)
printf("Extract %s (" SZFMTD "/" SZFMTD ") \n", map_ids[z].Name.c_str(), z + 1, map_ids.size());
// Loadup map grid data
ChunkedFile wdt;
- if (!wdt.loadFile(CascStorage, map_ids[z].WdtFileDataId, Trinity::StringFormat("WDT for map %u", map_ids[z].Id), false))
- continue;
-
- FileChunk* mphd = wdt.GetChunk("MPHD");
- FileChunk* main = wdt.GetChunk("MAIN");
- FileChunk* maid = wdt.GetChunk("MAID");
- for (uint32 y = 0; y < WDT_MAP_SIZE; ++y)
+ std::bitset<(WDT_MAP_SIZE) * (WDT_MAP_SIZE)> existingTiles;
+ if (wdt.loadFile(CascStorage, map_ids[z].WdtFileDataId, Trinity::StringFormat("WDT for map %u", map_ids[z].Id), false))
{
- for (uint32 x = 0; x < WDT_MAP_SIZE; ++x)
+ FileChunk* mphd = wdt.GetChunk("MPHD");
+ FileChunk* main = wdt.GetChunk("MAIN");
+ FileChunk* maid = wdt.GetChunk("MAID");
+ for (uint32 y = 0; y < WDT_MAP_SIZE; ++y)
{
- if (!(main->As<wdt_MAIN>()->adt_list[y][x].flag & 0x1))
- continue;
-
- outputFileName = Trinity::StringFormat("%s/maps/%04u_%02u_%02u.map", output_path.string().c_str(), map_ids[z].Id, y, x);
- bool ignoreDeepWater = IsDeepWaterIgnored(map_ids[z].Id, y, x);
- if (mphd && mphd->As<wdt_MPHD>()->flags & 0x200)
+ for (uint32 x = 0; x < WDT_MAP_SIZE; ++x)
{
- ConvertADT(maid->As<wdt_MAID>()->adt_files[y][x].rootADT, map_ids[z].Name, outputFileName, y, x, build, ignoreDeepWater);
- }
- else
- {
- std::string storagePath = Trinity::StringFormat("World\\Maps\\%s\\%s_%u_%u.adt", map_ids[z].Directory.c_str(), map_ids[z].Directory.c_str(), x, y);
- ConvertADT(storagePath, map_ids[z].Name, outputFileName, y, x, build, ignoreDeepWater);
+ if (!(main->As<wdt_MAIN>()->adt_list[y][x].flag & 0x1))
+ continue;
+
+ outputFileName = Trinity::StringFormat("%s/maps/%04u_%02u_%02u.map", output_path.string().c_str(), map_ids[z].Id, y, x);
+ bool ignoreDeepWater = IsDeepWaterIgnored(map_ids[z].Id, y, x);
+ if (mphd && mphd->As<wdt_MPHD>()->flags & 0x200)
+ {
+ existingTiles[y * WDT_MAP_SIZE + x] = ConvertADT(maid->As<wdt_MAID>()->adt_files[y][x].rootADT, map_ids[z].Name, outputFileName, y, x, build, ignoreDeepWater);
+ }
+ else
+ {
+ std::string storagePath = Trinity::StringFormat(R"(World\Maps\%s\%s_%u_%u.adt)", map_ids[z].Directory.c_str(), map_ids[z].Directory.c_str(), x, y);
+ existingTiles[y * WDT_MAP_SIZE + x] = ConvertADT(storagePath, map_ids[z].Name, outputFileName, y, x, build, ignoreDeepWater);
+ }
}
+
+ // draw progress bar
+ printf("Processing........................%d%%\r", (100 * (y + 1)) / WDT_MAP_SIZE);
}
+ }
- // draw progress bar
- printf("Processing........................%d%%\r", (100 * (y+1)) / WDT_MAP_SIZE);
+ if (FILE* tileList = fopen(Trinity::StringFormat("%s/maps/%04u.tilelist", output_path.string().c_str(), map_ids[z].Id).c_str(), "wb"))
+ {
+ fwrite(MAP_MAGIC, 1, strlen(MAP_MAGIC), tileList);
+ fwrite(MAP_VERSION_MAGIC, 1, strlen(MAP_VERSION_MAGIC), tileList);
+ fwrite(&build, sizeof(build), 1, tileList);
+ fwrite(existingTiles.to_string().c_str(), 1, existingTiles.size(), tileList);
+ fclose(tileList);
}
}