Fixed typo in map extractor. Patch provided by andstan.

This commit is contained in:
tomrus88 2008-12-15 00:33:32 +03:00
parent f5c4fe86e8
commit c875fd698f
4 changed files with 60 additions and 52 deletions

View file

@ -18,9 +18,10 @@ extern ArchiveSet gOpenArchives;
bool ConvertADT(char*, char*); bool ConvertADT(char*, char*);
typedef struct{ typedef struct
{
char name[64]; char name[64];
unsigned int id; uint32 id;
} map_id; } map_id;
typedef unsigned char uint8; typedef unsigned char uint8;
@ -143,7 +144,7 @@ void ReadAreaTableDBC()
size_t area_count = dbc.getRecordCount(); size_t area_count = dbc.getRecordCount();
size_t maxid = dbc.getMaxId(); size_t maxid = dbc.getMaxId();
areas = new uint16[maxid + 1]; 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) for(uint32 x = 0; x < area_count; ++x)
areas[dbc.getRecord(x).getUInt(0)] = dbc.getRecord(x).getUInt(3); areas[dbc.getRecord(x).getUInt(0)] = dbc.getRecord(x).getUInt(3);
@ -199,7 +200,7 @@ void ExtractMapsFromMpq()
ConvertADT(mpq_filename, output_filename); ConvertADT(mpq_filename, output_filename);
done++; done++;
} }
// draw progess bar // draw progress bar
printf("Processing........................%d%%\r", (100 * done) / total); printf("Processing........................%d%%\r", (100 * done) / total);
} }
} }
@ -243,7 +244,7 @@ void ExtractDBCFiles(int locale, bool basicLocale)
string filename = path; string filename = path;
filename += (iter->c_str() + strlen("DBFilesClient\\")); filename += (iter->c_str() + strlen("DBFilesClient\\"));
FILE *output=fopen(filename.c_str(), "wb"); FILE *output = fopen(filename.c_str(), "wb");
if(!output) if(!output)
{ {
printf("Can't create the output file '%s'\n", filename.c_str()); printf("Can't create the output file '%s'\n", filename.c_str());
@ -295,7 +296,7 @@ void LoadCommonMPQFiles()
if(i > 1) if(i > 1)
sprintf(ext, "-%i", i); 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)) if(FileExists(filename))
new MPQArchive(filename); new MPQArchive(filename);
} }

Binary file not shown.

View file

@ -15,7 +15,7 @@
#include "adt.h" #include "adt.h"
#include "mpq_libmpq.h" #include "mpq_libmpq.h"
unsigned int iRes = 256; uint32 iRes = 256;
extern uint16 *areas; extern uint16 *areas;
extern uint16 *LiqType; extern uint16 *LiqType;
extern uint32 maxAreaId; extern uint32 maxAreaId;
@ -23,7 +23,6 @@ extern uint32 maxAreaId;
vec wmoc; vec wmoc;
Cell *cell; Cell *cell;
//uint32 wmo_count;
mcell *mcells; mcell *mcells;
int holetab_h[4] = {0x1111, 0x2222, 0x4444, 0x8888}; int holetab_h[4] = {0x1111, 0x2222, 0x4444, 0x8888};
int holetab_v[4] = {0x000F, 0x00F0, 0x0F00, 0xF000}; int holetab_v[4] = {0x000F, 0x00F0, 0x0F00, 0xF000};
@ -40,26 +39,23 @@ bool LoadADT(char* filename)
} }
MapLiqFlag = new uint8[256]; MapLiqFlag = new uint8[256];
for(int j = 0; j < 256; ++j) for(uint32 j = 0; j < 256; ++j)
MapLiqFlag[j] = 0; // no water MapLiqFlag[j] = 0; // no water
MapLiqHeight = new float[16384]; MapLiqHeight = new float[16384];
for(int j = 0; j < 16384; ++j) for(uint32 j = 0; j < 16384; ++j)
MapLiqHeight[j] = -999999; // no water MapLiqHeight[j] = -999999; // no water
mcells=new mcell; mcells = new mcell;
wmoc.x =65 * TILESIZE; wmoc.x = 65 * TILESIZE;
wmoc.z =65 * TILESIZE; wmoc.z = 65 * TILESIZE;
size_t mcnk_offsets[256], mcnk_sizes[256]; size_t mcnk_offsets[256], mcnk_sizes[256];
//wmo_count = 0;
//bool found = false;
MH2O_presence = false;
chunk_num = 0; chunk_num = 0;
k = 0; k = 0;
m = 0;
while (!mf.isEof()) while (!mf.isEof())
{ {
uint32 fourcc; uint32 fourcc;
@ -72,7 +68,7 @@ bool LoadADT(char* filename)
//if(fourcc==0x4d564552) // MVER //if(fourcc==0x4d564552) // MVER
if(fourcc == 0x4d43494e) // MCIN 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_offsets[i], 4);
mf.read(&mcnk_sizes[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 == 0x4d574944) // MWID offsets for strings in MWMO
//if(fourcc == 0x4d444446) // MDDF //if(fourcc == 0x4d444446) // MDDF
//if(fourcc == 0x4d4f4446) // MODF //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 base_pos = mf.getPos();
uint32 header_pos = 0; uint32 header_pos = 0;
LiqOffsData = new MH2O_offsData; MH2O_offsData *LiqOffsData = new MH2O_offsData;
LiqChunkData1 = new MH2O_Data1; MH2O_Data1 *LiqChunkData1 = new MH2O_Data1;
ChunkLiqHeight = new float[81]; float *ChunkLiqHeight = new float[81];
for(;chunk_num < 256; ++chunk_num) for(chunk_num = 0; chunk_num < 256; ++chunk_num)
{ {
mf.read(LiqOffsData, 12); mf.read(LiqOffsData, 0x0C);
header_pos = mf.getPos(); header_pos = mf.getPos();
if(LiqOffsData->offsData1 != 0) // åñëè äàííûå â Data1 î âîäå åñòü, òî èõ íàäî êîíâåðòèðîâàòü if(LiqOffsData->offsData1 != 0) // åñëè äàííûå â Data1 î âîäå åñòü, òî èõ íàäî êîíâåðòèðîâàòü
{ {
// ïåðåõîäèì ïî ñìåùåíèþ èç offsData1 ÎÒ ÍÀ×ÀËÀ êóñêà // ïåðåõîäèì ïî ñìåùåíèþ èç offsData1 ÎÒ ÍÀ×ÀËÀ êóñêà
mf.seek(base_pos + LiqOffsData->offsData1); mf.seek(base_pos + LiqOffsData->offsData1);
mf.read(LiqChunkData1, 24); // ñ÷èòûâàåì ñàìè äàííûå â ñòðóêòóðó òèïà MH2O_Data1 mf.read(LiqChunkData1, 0x18); // ñ÷èòûâàåì ñàìè äàííûå â ñòðóêòóðó òèïà MH2O_Data1
// çàíîñèì äàííûå ôëàãà äëÿ êóñêà // çàíîñèì äàííûå ôëàãà äëÿ êóñêà
if(LiqType[LiqChunkData1->LiquidTypeId] == 0xffff) if(LiqType[LiqChunkData1->LiquidTypeId] == 0xffff)
printf("\nCan't find Liquid type for map %s\nchunk %d\n", filename, chunk_num); 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) for(int j = 0; j < 81; ++j)
ChunkLiqHeight[j] = -999999; // no liquid/water ChunkLiqHeight[j] = -999999; // no liquid/water
} }
if(!(chunk_num % 16)) if(!(chunk_num % 16))
m = 1024 * (chunk_num / 16); // ñìåùåíèå ïî ðÿäàì êóñêîâ ñ ïåðåêðûòèåì = 1024 m = 1024 * (chunk_num / 16); // ñìåùåíèå ïî ðÿäàì êóñêîâ ñ ïåðåêðûòèåì = 1024
k = m + (chunk_num % 16) * 8; // óñòàíàâëèâàåìñÿ íà íà÷àëüíûé èíäåêñ äëÿ çàïîëíåíèÿ ðÿäà k = m + (chunk_num % 16) * 8; // óñòàíàâëèâàåìñÿ íà íà÷àëüíûé èíäåêñ äëÿ çàïîëíåíèÿ ðÿäà
@ -160,6 +156,9 @@ bool LoadADT(char* filename)
//printf("Loading chunks info\n"); //printf("Loading chunks info\n");
// read individual map chunks // read individual map chunks
chunk_num = 0;
k = 0;
m = 0;
for (int j = 0; j < 16; ++j) for (int j = 0; j < 16; ++j)
{ {
for (int i = 0; i < 16; ++i) for (int i = 0; i < 16; ++i)
@ -245,14 +244,14 @@ inline void LoadMapChunk(MPQFile &mf, chunk *_chunk)
{ {
nextpos = mf.getPos() + 0x1C0; // size fix nextpos = mf.getPos() + 0x1C0; // size fix
} }
else if(fourcc == 0x4d434c51 && !MH2O_presence) // íå áóäåì ó÷èòûâàòü åñëè óæå áûëè äàííûå â MH2O, ïåðåñòðàõîâêà :) // MCLQ else if(fourcc == 0x4d434c51) // íå áóäåì ó÷èòûâàòü åñëè óæå áûëè äàííûå â MH2O, ïåðåñòðàõîâêà :) // MCLQ
{ {
// liquid / water level // liquid / water level
char fcc1[5]; char fcc1[5];
mf.read(fcc1, 4); mf.read(fcc1, 4);
flipcc(fcc1); flipcc(fcc1);
fcc1[4] = 0; fcc1[4] = 0;
ChunkLiqHeight = new float[81]; float *ChunkLiqHeight = new float[81];
if (!strcmp(fcc1, "MCSE")) if (!strcmp(fcc1, "MCSE"))
{ {
@ -267,9 +266,10 @@ inline void LoadMapChunk(MPQFile &mf, chunk *_chunk)
mf.read(&maxheight, 4); mf.read(&maxheight, 4);
for(int j = 0; j < 81; ++j) for(int j = 0; j < 81; ++j)
{ {
mf.read(&h, 4); LiqData liq;
mf.read(&h, 4); mf.read(&liq, 8);
if(h > maxheight)
if(liq.height > maxheight)
ChunkLiqHeight[j] = -999999; ChunkLiqHeight[j] = -999999;
else else
ChunkLiqHeight[j] = h; ChunkLiqHeight[j] = h;
@ -283,7 +283,7 @@ inline void LoadMapChunk(MPQFile &mf, chunk *_chunk)
// çàïîëíåì òàê æå êàê â MH2O // çàïîëíåì òàê æå êàê â MH2O
if(!(chunk_num % 16)) if(!(chunk_num % 16))
m = 1024 * (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) for(int p = 0; p < 72; p += 9)
{ {

View file

@ -9,43 +9,45 @@ typedef unsigned char uint8;
typedef unsigned short uint16; typedef unsigned short uint16;
typedef unsigned int uint32; typedef unsigned int uint32;
class Liquid; class Liquid;
typedef struct { typedef struct
{
float x; float x;
float y; float y;
float z; float z;
} svec; } svec;
typedef struct { typedef struct
{
double x; double x;
double y; double y;
double z; double z;
} vec; } vec;
typedef struct{ typedef struct
{
vec v[3]; vec v[3];
} triangle; } triangle;
typedef struct{ typedef struct
float v9[16*8+1][16*8+1]; {
float v8[16*8][16*8]; float v9[16 * 8 + 1][16 * 8 + 1];
float v8[16 * 8][16 * 8];
} Cell; } Cell;
typedef struct{ typedef struct
{
double v9[9][9]; double v9[9][9];
double v8[8][8]; double v8[8][8];
uint16 area_id; uint16 area_id;
} chunk; } chunk;
class WMO;
class WMOManager;
void fixname(std::string &name);
typedef struct typedef struct
{ {
chunk ch[16][16]; chunk ch[16][16];
} mcell; } mcell;
struct MapChunkHeader { struct MapChunkHeader
{
uint32 flags; uint32 flags;
uint32 ix; uint32 ix;
uint32 iy; uint32 iy;
@ -81,13 +83,15 @@ struct MapChunkHeader {
uint32 effectId; uint32 effectId;
}; };
typedef struct { typedef struct
{
uint32 offsData1; uint32 offsData1;
uint32 used; uint32 used;
uint32 offsData2; uint32 offsData2;
} MH2O_offsData; } MH2O_offsData;
typedef struct { typedef struct
{
uint16 LiquidTypeId; uint16 LiquidTypeId;
uint16 type; uint16 type;
float heightLevel1; float heightLevel1;
@ -100,6 +104,13 @@ typedef struct {
uint32 ofsData2b; uint32 ofsData2b;
} MH2O_Data1; } MH2O_Data1;
typedef struct
{
uint16 unk1;
uint16 unk2;
float height;
} LiqData;
enum LiquidType enum LiquidType
{ {
LIQUID_TYPE_WATER = 0, LIQUID_TYPE_WATER = 0,
@ -110,12 +121,8 @@ enum LiquidType
class MPQFile; class MPQFile;
bool MH2O_presence; float *MapLiqHeight;
MH2O_offsData *LiqOffsData; uint8 *MapLiqFlag;
MH2O_Data1 *LiqChunkData1;
float *ChunkLiqHeight, *MapLiqHeight;
uint8* MapLiqFlag;
uint32 k, m, chunk_num; uint32 k, m, chunk_num;
void LoadMapChunk(MPQFile &, chunk*); void LoadMapChunk(MPQFile &, chunk*);
bool LoadWMO(char* filename);
#endif #endif