diff --git a/contrib/extractor/System.cpp b/contrib/extractor/System.cpp index 3b659a4c6..85d06369f 100644 --- a/contrib/extractor/System.cpp +++ b/contrib/extractor/System.cpp @@ -18,9 +18,10 @@ extern ArchiveSet gOpenArchives; bool ConvertADT(char*, char*); -typedef struct{ +typedef struct +{ char name[64]; - unsigned int id; + uint32 id; } map_id; typedef unsigned char uint8; @@ -143,7 +144,7 @@ void ReadAreaTableDBC() size_t area_count = dbc.getRecordCount(); size_t maxid = dbc.getMaxId(); areas = new uint16[maxid + 1]; - memset(areas, 0xff, sizeof(areas)); + memset(areas, 0xff, (maxid + 1) * sizeof(uint16)); for(uint32 x = 0; x < area_count; ++x) areas[dbc.getRecord(x).getUInt(0)] = dbc.getRecord(x).getUInt(3); @@ -199,7 +200,7 @@ void ExtractMapsFromMpq() ConvertADT(mpq_filename, output_filename); done++; } - // draw progess bar + // draw progress bar printf("Processing........................%d%%\r", (100 * done) / total); } } @@ -243,7 +244,7 @@ void ExtractDBCFiles(int locale, bool basicLocale) string filename = path; filename += (iter->c_str() + strlen("DBFilesClient\\")); - FILE *output=fopen(filename.c_str(), "wb"); + FILE *output = fopen(filename.c_str(), "wb"); if(!output) { printf("Can't create the output file '%s'\n", filename.c_str()); @@ -295,7 +296,7 @@ void LoadCommonMPQFiles() if(i > 1) sprintf(ext, "-%i", i); - sprintf(filename,"%s/Data/patch%s.MPQ", input_path, ext); + sprintf(filename, "%s/Data/patch%s.MPQ", input_path, ext); if(FileExists(filename)) new MPQArchive(filename); } diff --git a/contrib/extractor/ad.exe b/contrib/extractor/ad.exe index 30d3f314d..f483f3892 100755 Binary files a/contrib/extractor/ad.exe and b/contrib/extractor/ad.exe differ diff --git a/contrib/extractor/adt.cpp b/contrib/extractor/adt.cpp index f0c3de960..dde87e5fc 100644 --- a/contrib/extractor/adt.cpp +++ b/contrib/extractor/adt.cpp @@ -15,7 +15,7 @@ #include "adt.h" #include "mpq_libmpq.h" -unsigned int iRes = 256; +uint32 iRes = 256; extern uint16 *areas; extern uint16 *LiqType; extern uint32 maxAreaId; @@ -23,7 +23,6 @@ extern uint32 maxAreaId; vec wmoc; Cell *cell; -//uint32 wmo_count; mcell *mcells; int holetab_h[4] = {0x1111, 0x2222, 0x4444, 0x8888}; int holetab_v[4] = {0x000F, 0x00F0, 0x0F00, 0xF000}; @@ -40,26 +39,23 @@ bool LoadADT(char* filename) } MapLiqFlag = new uint8[256]; - for(int j = 0; j < 256; ++j) + for(uint32 j = 0; j < 256; ++j) MapLiqFlag[j] = 0; // no water MapLiqHeight = new float[16384]; - for(int j = 0; j < 16384; ++j) + for(uint32 j = 0; j < 16384; ++j) MapLiqHeight[j] = -999999; // no water - mcells=new mcell; + mcells = new mcell; - wmoc.x =65 * TILESIZE; - wmoc.z =65 * TILESIZE; + wmoc.x = 65 * TILESIZE; + wmoc.z = 65 * TILESIZE; size_t mcnk_offsets[256], mcnk_sizes[256]; - //wmo_count = 0; - //bool found = false; - - MH2O_presence = false; chunk_num = 0; k = 0; + m = 0; while (!mf.isEof()) { uint32 fourcc; @@ -72,7 +68,7 @@ bool LoadADT(char* filename) //if(fourcc==0x4d564552) // MVER if(fourcc == 0x4d43494e) // MCIN { - for (int i = 0; i < 256; ++i) + for (uint32 i = 0; i < 256; ++i) { mf.read(&mcnk_offsets[i], 4); mf.read(&mcnk_sizes[i], 4); @@ -86,24 +82,23 @@ bool LoadADT(char* filename) //if(fourcc == 0x4d574944) // MWID offsets for strings in MWMO //if(fourcc == 0x4d444446) // MDDF //if(fourcc == 0x4d4f4446) // MODF - if(fourcc == 0x4d48324f && size) // MH2O new in WotLK + if(fourcc == 0x4d48324f) // MH2O new in WotLK { - MH2O_presence = true; // здесь надо запомнить базовую позицию в файле тк все смещения будут от него uint32 base_pos = mf.getPos(); uint32 header_pos = 0; - LiqOffsData = new MH2O_offsData; - LiqChunkData1 = new MH2O_Data1; - ChunkLiqHeight = new float[81]; - for(;chunk_num < 256; ++chunk_num) + MH2O_offsData *LiqOffsData = new MH2O_offsData; + MH2O_Data1 *LiqChunkData1 = new MH2O_Data1; + float *ChunkLiqHeight = new float[81]; + for(chunk_num = 0; chunk_num < 256; ++chunk_num) { - mf.read(LiqOffsData, 12); + mf.read(LiqOffsData, 0x0C); header_pos = mf.getPos(); if(LiqOffsData->offsData1 != 0) // если данные в Data1 о воде есть, то их надо конвертировать { // переходим по смещению из offsData1 ОТ НАЧАЛА куска mf.seek(base_pos + LiqOffsData->offsData1); - mf.read(LiqChunkData1, 24); // считываем сами данные в структуру типа MH2O_Data1 + mf.read(LiqChunkData1, 0x18); // считываем сами данные в структуру типа MH2O_Data1 // заносим данные флага для куска if(LiqType[LiqChunkData1->LiquidTypeId] == 0xffff) printf("\nCan't find Liquid type for map %s\nchunk %d\n", filename, chunk_num); @@ -132,6 +127,7 @@ bool LoadADT(char* filename) for(int j = 0; j < 81; ++j) ChunkLiqHeight[j] = -999999; // no liquid/water } + if(!(chunk_num % 16)) m = 1024 * (chunk_num / 16); // смещение по рядам кусков с перекрытием = 1024 k = m + (chunk_num % 16) * 8; // устанавливаемся на начальный индекс для заполнения ряда @@ -160,6 +156,9 @@ bool LoadADT(char* filename) //printf("Loading chunks info\n"); // read individual map chunks + chunk_num = 0; + k = 0; + m = 0; for (int j = 0; j < 16; ++j) { for (int i = 0; i < 16; ++i) @@ -245,14 +244,14 @@ inline void LoadMapChunk(MPQFile &mf, chunk *_chunk) { nextpos = mf.getPos() + 0x1C0; // size fix } - else if(fourcc == 0x4d434c51 && !MH2O_presence) // не будем учитывать если уже были данные в MH2O, перестраховка :) // MCLQ + else if(fourcc == 0x4d434c51) // не будем учитывать если уже были данные в MH2O, перестраховка :) // MCLQ { // liquid / water level char fcc1[5]; mf.read(fcc1, 4); flipcc(fcc1); fcc1[4] = 0; - ChunkLiqHeight = new float[81]; + float *ChunkLiqHeight = new float[81]; if (!strcmp(fcc1, "MCSE")) { @@ -267,9 +266,10 @@ inline void LoadMapChunk(MPQFile &mf, chunk *_chunk) mf.read(&maxheight, 4); for(int j = 0; j < 81; ++j) { - mf.read(&h, 4); - mf.read(&h, 4); - if(h > maxheight) + LiqData liq; + mf.read(&liq, 8); + + if(liq.height > maxheight) ChunkLiqHeight[j] = -999999; else ChunkLiqHeight[j] = h; @@ -283,7 +283,7 @@ inline void LoadMapChunk(MPQFile &mf, chunk *_chunk) // заполнем так же как в MH2O if(!(chunk_num % 16)) m = 1024 * (chunk_num / 16); - k = m +(chunk_num % 16) * 8; + k = m + (chunk_num % 16) * 8; for(int p = 0; p < 72; p += 9) { diff --git a/contrib/extractor/adt.h b/contrib/extractor/adt.h index 7fb8dc078..d56501c90 100644 --- a/contrib/extractor/adt.h +++ b/contrib/extractor/adt.h @@ -9,43 +9,45 @@ typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned int uint32; class Liquid; -typedef struct { +typedef struct +{ float x; float y; float z; } svec; -typedef struct { +typedef struct +{ double x; double y; double z; } vec; -typedef struct{ +typedef struct +{ vec v[3]; } triangle; -typedef struct{ - float v9[16*8+1][16*8+1]; - float v8[16*8][16*8]; +typedef struct +{ + float v9[16 * 8 + 1][16 * 8 + 1]; + float v8[16 * 8][16 * 8]; } Cell; -typedef struct{ +typedef struct +{ double v9[9][9]; double v8[8][8]; uint16 area_id; } chunk; -class WMO; -class WMOManager; -void fixname(std::string &name); - typedef struct { chunk ch[16][16]; } mcell; -struct MapChunkHeader { +struct MapChunkHeader +{ uint32 flags; uint32 ix; uint32 iy; @@ -81,13 +83,15 @@ struct MapChunkHeader { uint32 effectId; }; -typedef struct { +typedef struct +{ uint32 offsData1; uint32 used; uint32 offsData2; } MH2O_offsData; -typedef struct { +typedef struct +{ uint16 LiquidTypeId; uint16 type; float heightLevel1; @@ -100,6 +104,13 @@ typedef struct { uint32 ofsData2b; } MH2O_Data1; +typedef struct +{ + uint16 unk1; + uint16 unk2; + float height; +} LiqData; + enum LiquidType { LIQUID_TYPE_WATER = 0, @@ -110,12 +121,8 @@ enum LiquidType class MPQFile; -bool MH2O_presence; -MH2O_offsData *LiqOffsData; -MH2O_Data1 *LiqChunkData1; -float *ChunkLiqHeight, *MapLiqHeight; -uint8* MapLiqFlag; +float *MapLiqHeight; +uint8 *MapLiqFlag; uint32 k, m, chunk_num; void LoadMapChunk(MPQFile &, chunk*); -bool LoadWMO(char* filename); #endif