aboutsummaryrefslogtreecommitdiff
path: root/src/tools/map_extractor
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2014-10-19 14:02:08 +0200
committerShauren <shauren.trinity@gmail.com>2014-10-19 14:02:08 +0200
commit457c93bc4b6e5015852a6b7f5d05262b2efbd24a (patch)
tree88f8d2fb921ed1c769ac618375f0936175db4520 /src/tools/map_extractor
parentced4fc6347df53219e5b1085361824b43ad0c069 (diff)
Tools/Extractors: Updated vmap_extractor for 6.0.2
Diffstat (limited to 'src/tools/map_extractor')
-rw-r--r--src/tools/map_extractor/System.cpp75
-rw-r--r--src/tools/map_extractor/adt.h2
-rw-r--r--src/tools/map_extractor/loadlib.cpp23
-rw-r--r--src/tools/map_extractor/loadlib/loadlib.h6
4 files changed, 86 insertions, 20 deletions
diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp
index 2bb05445744..1500273a51c 100644
--- a/src/tools/map_extractor/System.cpp
+++ b/src/tools/map_extractor/System.cpp
@@ -18,9 +18,10 @@
#define _CRT_SECURE_NO_DEPRECATE
-#include <stdio.h>
+#include <cstdio>
#include <deque>
#include <list>
+#include <set>
#include <cstdlib>
#include <cstring>
@@ -262,7 +263,7 @@ uint32 ReadMapDBC()
printf("Read Map.dbc file... ");
HANDLE dbcFile;
- if (!CascOpenFile(CascStorage, "DBFilesClient\\Map.dbc", CASC_LOCALE_ALL, 0, &dbcFile))
+ if (!CascOpenFile(CascStorage, "DBFilesClient\\Map.dbc", CASC_LOCALE_NONE, 0, &dbcFile))
{
printf("Fatal error: Cannot find Map.dbc in archive!\n");
exit(1);
@@ -292,7 +293,7 @@ void ReadAreaTableDBC()
{
printf("Read AreaTable.dbc file...");
HANDLE dbcFile;
- if (!CascOpenFile(CascStorage, "DBFilesClient\\AreaTable.dbc", CASC_LOCALE_ALL, 0, &dbcFile))
+ if (!CascOpenFile(CascStorage, "DBFilesClient\\AreaTable.dbc", CASC_LOCALE_NONE, 0, &dbcFile))
{
printf("Fatal error: Cannot find AreaTable.dbc in archive!\n");
exit(1);
@@ -320,7 +321,7 @@ void ReadLiquidTypeTableDBC()
{
printf("Read LiquidType.dbc file...");
HANDLE dbcFile;
- if (!CascOpenFile(CascStorage, "DBFilesClient\\LiquidType.dbc", CASC_LOCALE_ALL, 0, &dbcFile))
+ if (!CascOpenFile(CascStorage, "DBFilesClient\\LiquidType.dbc", CASC_LOCALE_NONE, 0, &dbcFile))
{
printf("Fatal error: Cannot find LiquidType.dbc in archive!\n");
exit(1);
@@ -351,7 +352,7 @@ void ReadLiquidTypeTableDBC()
// Map file format data
static char const* MAP_MAGIC = "MAPS";
-static char const* MAP_VERSION_MAGIC = "v1.3";
+static char const* MAP_VERSION_MAGIC = "v1.4";
static char const* MAP_AREA_MAGIC = "AREA";
static char const* MAP_HEIGHT_MAGIC = "MHGT";
static char const* MAP_LIQUID_MAGIC = "MLIQ";
@@ -440,7 +441,22 @@ uint16 liquid_entry[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
uint8 liquid_flags[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
bool liquid_show[ADT_GRID_SIZE][ADT_GRID_SIZE];
float liquid_height[ADT_GRID_SIZE+1][ADT_GRID_SIZE+1];
-uint16 holes[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
+uint8 holes[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID][8];
+
+bool TransformToHighRes(uint16 holes, uint8 hiResHoles[8])
+{
+ for (uint8 i = 0; i < 8; i++)
+ {
+ for (uint8 j = 0; j < 8; j++)
+ {
+ int32 holeIdxL = (i / 2) * 4 + (j / 2);
+ if (((holes >> holeIdxL) & 1) == 1)
+ hiResHoles[i] |= (1 << j);
+ }
+ }
+
+ return *((uint64*)hiResHoles) != 0;
+}
bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/, uint32 build)
{
@@ -599,10 +615,14 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
if (!(mcnk->flags & 0x10000))
{
if (uint16 hole = mcnk->holes)
- {
- holes[mcnk->iy][mcnk->ix] = mcnk->holes;
+ if (TransformToHighRes(hole, holes[mcnk->iy][mcnk->ix]))
+ hasHoles = true;
+ }
+ else
+ {
+ memcpy(holes[mcnk->iy][mcnk->ix], mcnk->union_5_3_0.HighResHoles, sizeof(uint64));
+ if (*((uint64*)holes[mcnk->iy][mcnk->ix]) != 0)
hasHoles = true;
- }
}
}
@@ -965,6 +985,23 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
return true;
}
+void ExtractWmos(ChunkedFile& file, std::set<std::string>& wmoList)
+{
+ if (FileChunk* chunk = file.GetChunk("MWMO"))
+ {
+ file_MWMO* wmo = chunk->As<file_MWMO>();
+ if (wmo->size)
+ {
+ char* fileName = wmo->FileList;
+ while (fileName < wmo->FileList + wmo->size)
+ {
+ wmoList.insert(fileName);
+ fileName += strlen(fileName) + 1;
+ }
+ }
+ }
+}
+
void ExtractMaps(uint32 build)
{
char storagePath[1024];
@@ -981,6 +1018,8 @@ void ExtractMaps(uint32 build)
path += "/maps/";
CreateDir(path);
+ std::set<std::string> wmoList;
+
printf("Convert map files\n");
for (uint32 z = 0; z < map_count; ++z)
{
@@ -991,6 +1030,8 @@ void ExtractMaps(uint32 build)
if (!wdt.loadFile(CascStorage, storagePath, false))
continue;
+ ExtractWmos(wdt, wmoList);
+
FileChunk* chunk = wdt.GetChunk("MAIN");
for (uint32 y = 0; y < WDT_MAP_SIZE; ++y)
{
@@ -1002,6 +1043,11 @@ void ExtractMaps(uint32 build)
sprintf(storagePath, "World\\Maps\\%s\\%s_%u_%u.adt", map_ids[z].name, map_ids[z].name, x, y);
sprintf(output_filename, "%s/maps/%03u%02u%02u.map", output_path, map_ids[z].id, y, x);
ConvertADT(storagePath, output_filename, y, x, build);
+
+ sprintf(storagePath, "World\\Maps\\%s\\%s_%u_%u_obj0.adt", map_ids[z].name, map_ids[z].name, x, y);
+ ChunkedFile adtObj;
+ if (adtObj.loadFile(CascStorage, storagePath, false))
+ ExtractWmos(adtObj, wmoList);
}
// draw progress bar
@@ -1009,6 +1055,17 @@ void ExtractMaps(uint32 build)
}
}
+ if (!wmoList.empty())
+ {
+ if (FILE* wmoListFile = fopen("wmo_list.txt", "w"))
+ {
+ for (std::string const& wmo : wmoList)
+ fprintf(wmoListFile, "%s\n", wmo.c_str());
+
+ fclose(wmoListFile);
+ }
+ }
+
printf("\n");
delete[] areas;
delete[] map_ids;
diff --git a/src/tools/map_extractor/adt.h b/src/tools/map_extractor/adt.h
index 15145ccd5bf..99e74d9809b 100644
--- a/src/tools/map_extractor/adt.h
+++ b/src/tools/map_extractor/adt.h
@@ -107,7 +107,7 @@ public:
uint32 offsMCVT; // height map
uint32 offsMCNR; // Normal vectors for each vertex
} offsets;
- uint64 HighResHoles; // TODO: maybe use this?
+ uint8 HighResHoles[8];
} union_5_3_0;
uint32 offsMCLY; // Texture layer definitions
uint32 offsMCRF; // A list of indices into the parent file's MDDF chunk
diff --git a/src/tools/map_extractor/loadlib.cpp b/src/tools/map_extractor/loadlib.cpp
index 7af56d89a0c..f4829a3eb7c 100644
--- a/src/tools/map_extractor/loadlib.cpp
+++ b/src/tools/map_extractor/loadlib.cpp
@@ -95,6 +95,7 @@ u_map_fcc InterestingChunks[] = {
{ 'O', '2', 'H', 'M' },
{ 'K', 'N', 'C', 'M' },
{ 'T', 'V', 'C', 'M' },
+ { 'O', 'M', 'W', 'M' },
{ 'Q', 'L', 'C', 'M' }
};
@@ -113,10 +114,9 @@ void ChunkedFile::parseChunks()
while (ptr < GetData() + GetDataSize())
{
u_map_fcc header = *(u_map_fcc*)ptr;
- uint32 size = 0;
if (IsInterestingChunk(header))
{
- size = *(uint32*)(ptr + 4);
+ uint32 size = *(uint32*)(ptr + 4);
if (size <= data_size)
{
std::swap(header.fcc_txt[0], header.fcc_txt[3]);
@@ -126,10 +126,12 @@ void ChunkedFile::parseChunks()
chunk->parseSubChunks();
chunks.insert({ std::string(header.fcc_txt, 4), chunk });
}
- }
- // move to next chunk
- ptr += size + 8;
+ // move to next chunk
+ ptr += size + 8;
+ }
+ else
+ ++ptr;
}
}
@@ -156,10 +158,9 @@ void FileChunk::parseSubChunks()
while (ptr < data + size)
{
u_map_fcc header = *(u_map_fcc*)ptr;
- uint32 subsize = 0;
if (IsInterestingChunk(header))
{
- subsize = *(uint32*)(ptr + 4);
+ uint32 subsize = *(uint32*)(ptr + 4);
if (subsize < size)
{
std::swap(header.fcc_txt[0], header.fcc_txt[3]);
@@ -169,10 +170,12 @@ void FileChunk::parseSubChunks()
chunk->parseSubChunks();
subchunks.insert({ std::string(header.fcc_txt, 4), chunk });
}
- }
- // move to next chunk
- ptr += subsize + 8;
+ // move to next chunk
+ ptr += subsize + 8;
+ }
+ else
+ ++ptr;
}
}
diff --git a/src/tools/map_extractor/loadlib/loadlib.h b/src/tools/map_extractor/loadlib/loadlib.h
index 873aa3346b6..10d14aed114 100644
--- a/src/tools/map_extractor/loadlib/loadlib.h
+++ b/src/tools/map_extractor/loadlib/loadlib.h
@@ -72,6 +72,12 @@ struct file_MVER
uint32 ver;
};
+struct file_MWMO
+{
+ u_map_fcc fcc;
+ uint32 size;
+ char FileList[1];
+};
class FileChunk
{