Tools/Extractors: Updated map extractor to cataclysm, enjoy new maps

This commit is contained in:
Shauren
2012-02-20 21:40:31 +01:00
parent b1e4a1b14f
commit 5ced6edbcf
3 changed files with 39 additions and 33 deletions

View File

@@ -34,8 +34,6 @@
#define OPEN_FLAGS (O_RDONLY | O_BINARY)
#endif
typedef std::list<HANDLE> Archives;
Archives WorldMpqs;
HANDLE WorldMpq = NULL;
HANDLE LocaleMpq = NULL;
@@ -430,13 +428,6 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32
if (!adt.loadFile(WorldMpq, filename))
return false;
adt_MCIN *cells = adt.a_grid->getMCIN();
if (!cells)
{
printf("Can't find cells in '%s'\n", filename);
return false;
}
memset(liquid_show, 0, sizeof(liquid_show));
memset(liquid_type, 0, sizeof(liquid_type));
@@ -451,7 +442,7 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32
{
for(int j=0;j<ADT_CELLS_PER_GRID;j++)
{
adt_MCNK * cell = cells->getMCNK(i,j);
adt_MCNK * cell = adt.cells[i][j];
uint32 areaid = cell->areaid;
if(areaid && areaid <= maxAreaId)
{
@@ -506,7 +497,7 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32
{
for(int j=0;j<ADT_CELLS_PER_GRID;j++)
{
adt_MCNK * cell = cells->getMCNK(i,j);
adt_MCNK * cell = adt.cells[i][j];
if (!cell)
continue;
// Height values for triangles stored in order:
@@ -748,7 +739,7 @@ bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x, uint32
{
for(int j=0;j<ADT_CELLS_PER_GRID;j++)
{
adt_MCNK *cell = cells->getMCNK(i, j);
adt_MCNK *cell = adt.cells[i][j];
if (!cell)
continue;
@@ -1058,7 +1049,7 @@ bool LoadLocaleMPQFile(int locale)
memset(buff, 0, sizeof(buff));
if (Builds[i] > LAST_DBC_IN_DATA_BUILD)
{
prefix = NULL;
prefix = "";
_stprintf(buff, _T("./Data/%s/wow-update-%s-%u.MPQ"), LocalesT[locale], LocalesT[locale], Builds[i]);
}
else
@@ -1071,9 +1062,6 @@ bool LoadLocaleMPQFile(int locale)
{
if (GetLastError() != ERROR_FILE_NOT_FOUND)
_tprintf(_T("Cannot open patch archive %s\n"), buff);
//SFileCloseArchive(mpq);
//err = true;
//break;
continue;
}
}
@@ -1096,14 +1084,11 @@ void LoadCommonMPQFiles()
for(int i = 1; i < count; ++i)
{
_stprintf(filename, _T("%s/Data/%s"), input_path, CONF_mpq_list[i]);
//if (FileExists(filename))
if (!SFileOpenPatchArchive(WorldMpq, filename, "", 0))
{
if (!SFileOpenPatchArchive(WorldMpq, filename, NULL, 0))
{
if (GetLastError() != ERROR_PATH_NOT_FOUND)
_tprintf(_T("Cannot open archive %s\n"), filename);
break;
}
if (GetLastError() != ERROR_PATH_NOT_FOUND)
_tprintf(_T("Cannot open archive %s\n"), filename);
break;
}
}
@@ -1113,7 +1098,7 @@ void LoadCommonMPQFiles()
memset(filename, 0, sizeof(filename));
if (Builds[i] > LAST_DBC_IN_DATA_BUILD)
{
prefix = NULL;
prefix = "";
_stprintf(filename, _T("%s/Data/wow-update-base-%u.MPQ"), input_path, Builds[i]);
}
else
@@ -1122,13 +1107,10 @@ void LoadCommonMPQFiles()
_stprintf(filename, _T("%s/Data/wow-update-%u.MPQ"), input_path, Builds[i]);
}
if (!SFileOpenPatchArchive(LocaleMpq, filename, prefix, 0))
if (!SFileOpenPatchArchive(WorldMpq, filename, prefix, 0))
{
if (GetLastError() != ERROR_PATH_NOT_FOUND)
_tprintf(_T("Cannot open patch archive %s\n"), filename);
//SFileCloseArchive(mpq);
//err = true;
//break;
continue;
}
}

View File

@@ -48,6 +48,27 @@ bool ADT_file::prepareLoadedData()
if (!a_grid->prepareLoadedData())
return false;
// funny offsets calculations because there is no mapping for them and they have variable lengths
uint8* ptr = (uint8*)a_grid + a_grid->size + 8;
uint32 mcnk_count = 0;
memset(cells, 0, ADT_CELLS_PER_GRID * ADT_CELLS_PER_GRID * sizeof(adt_MCNK*));
while (ptr < GetData() + GetDataSize())
{
uint32 header = *(uint32*)ptr;
uint32 size = *(uint32*)(ptr + 4);
if (header == 'MCNK')
{
cells[mcnk_count / ADT_CELLS_PER_GRID][mcnk_count % ADT_CELLS_PER_GRID] = (adt_MCNK*)ptr;
++mcnk_count;
}
// move to next chunk
ptr += size + 8;
}
if (mcnk_count != ADT_CELLS_PER_GRID * ADT_CELLS_PER_GRID)
return false;
return true;
}

View File

@@ -245,15 +245,18 @@ public:
//
// Adt file header chunk
//
class ADT_file;
class adt_MHDR
{
friend class ADT_file;
union{
uint32 fcc;
char fcc_txt[4];
};
uint32 size;
uint32 pad;
uint32 flags;
uint32 offsMCIN; // MCIN
uint32 offsTex; // MTEX
uint32 offsModels; // MMDX
@@ -271,9 +274,8 @@ class adt_MHDR
uint32 data5;
public:
bool prepareLoadedData();
adt_MCIN *getMCIN(){ return offsMCIN ? (adt_MCIN *)((uint8 *)&pad+offsMCIN) : NULL;}
adt_MH2O *getMH2O(){ return offsMH2O ? (adt_MH2O *)((uint8 *)&pad+offsMH2O) : NULL;}
adt_MCIN* getMCIN() { return offsMCIN ? (adt_MCIN *)((uint8 *)&flags+offsMCIN) : NULL; }
adt_MH2O* getMH2O() { return offsMH2O ? (adt_MH2O *)((uint8 *)&flags+offsMH2O) : NULL; }
};
class ADT_file : public FileLoader{
@@ -283,7 +285,8 @@ public:
~ADT_file();
void free();
adt_MHDR *a_grid;
adt_MHDR* a_grid;
adt_MCNK* cells[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
};
#endif