bool LoadADT(char* filename) { MPQFile mf(filename); if(mf.isEof()) return false; mcells = new mcell; wmoc.x = 65*TILESIZE; wmoc.z = 65*TILESIZE; wmo_count = 0; bool found = false; uint8 * data = new uint8[mf.getSize()]; mf.read(data, mf.getSize()); mf.close (); fileVer * ver = (fileVer*)data; if(ver->fcc != 'MVER' || ver->ver != 18) { delete data; return false; } adt_MHDR * mhdr = (adt_MHDR*)(data+8+ver->size); if(mhdr->fcc != 'MHDR') { delete data; return false; } if(mhdr->size != sizeof(adt_MHDR)-8) { delete data; return false; } if(!mhdr->offsMCIN) { delete data; return false; } adt_MCIN * mcin = (adt_MCIN*)((uint8 *)&mhdr->pad + mhdr->offsMCIN); if(mcin->fcc != 'MCIN') { delete data; return false; } for (int j=0; j<16; j++) for (int i=0; i<16; i++) { LoadMapChunk ((MapChunkHeader*) ((uint8*)mcin + mcin->cells[j][i].offsMCNK - 84) , &(mcells->ch [i][j])); } delete data; return true; }
bool LoadADT(char* filename) { size_t size; MPQFile mf(filename); if(mf.isEof()) { //printf("No such file.\n"); return false; } mcells=new mcell; wmoc.x =65*TILESIZE; wmoc.z =65*TILESIZE; size_t mcnk_offsets[256], mcnk_sizes[256]; wmo_count=0; bool found=false; //uint32 fs=mf.getSize()-3; //while (mf.getPos()<fs) while (!mf.isEof()) { uint32 fourcc; mf.read(&fourcc,4); mf.read(&size, 4); size_t nextpos = mf.getPos() + size; switch(fourcc) { case 0x4d43494e: // MCIN { //printf("Found chunks info\n"); // mapchunk offsets/sizes for (int i=0; i<256; i++) { mf.read(&mcnk_offsets[i],4); mf.read(&mcnk_sizes[i],4); mf.seekRelative(8); } break; } case 0x4d4f4446: // MODF { /* if(size) { //printf("\nwmo count %d\n",size/64); wmo_count =size/64; for (int i=0; i<wmo_count; i++) { int id; mf.read(&id, 4); WMO *wmo = (WMO*)wmomanager.items[wmomanager.get(wmos[id])]; WMOInstance inst(wmo, mf); wmois.push_back(inst); } }*/ break; } case 0x4d574d4f: // MWMO { /* if (size) { char *buf = new char[size]; mf.read(buf, size); char *p=buf; while (p<buf+size) { std::string path(p); p+=strlen(p)+1; fixname(path); wmomanager.add(path); wmos.push_back(path); } delete[] buf; }*/ break; } case 0x4d564552: // MVER case 0x4d484452: // MHDR header case 0x4d434e4b: // MCNK case 0x4d544558: // MTEX textures (strings) case 0x4d4d4458: // MMDX m2 models (strings) case 0x4d4d4944: // MMID offsets for strings in MMDX case 0x4d574944: // MWID offsets for strings in MWMO case 0x4d444446: // MDDF case 0x4d46424f: // MFBO new in BC case 0x4d48324f: // MH2O new in WotLK case 0x4D545846: // MTXF new in WotLK break; default: { // mf.seekRelative(-3); printf("Unhandled map chunk: %u\n",fourcc); break; } } mf.seek(nextpos); } //printf("Loading chunks info\n"); // read individual map chunks for (int j=0; j<16; j++) for (int i=0; i<16; i++) { mf.seek((int)mcnk_offsets[j*16+i]); LoadMapChunk(mf,&(mcells->ch[i][j])); } /* for(uint32 t=0;t<wmo_count ;t++) { wmois[t].draw(); }*/ mf.close(); return true; }
bool LoadADT(char* filename) { size_t size; MPQFile mf(filename); if(mf.isEof()) { //printf("No such file %s\n", filename); return false; } MapLiqFlag = new uint8[256]; for(uint32 j = 0; j < 256; ++j) MapLiqFlag[j] = 0; // no water MapLiqHeight = new float[16384]; for(uint32 j = 0; j < 16384; ++j) MapLiqHeight[j] = -999999; // no water mcells = new mcell; wmoc.x = 65 * TILESIZE; wmoc.z = 65 * TILESIZE; size_t mcnk_offsets[256], mcnk_sizes[256]; chunk_num = 0; k = 0; m = 0; while (!mf.isEof()) { uint32 fourcc; mf.read(&fourcc, 4); mf.read(&size, 4); size_t nextpos = mf.getPos() + size; //if(fourcc==0x4d484452) // MHDR header //if(fourcc==0x4d564552) // MVER if(fourcc == 0x4d43494e) // MCIN { for (uint32 i = 0; i < 256; ++i) { mf.read(&mcnk_offsets[i], 4); mf.read(&mcnk_sizes[i], 4); mf.seekRelative(8); } } //if(fourcc == 0x4d544558) // MTEX textures (strings) //if(fourcc == 0x4d4d4458) // MMDX m2 models (strings) //if(fourcc == 0x4d4d4944) // MMID offsets for strings in MMDX //if(fourcc == 0x4d574d4f) // MWMO //if(fourcc == 0x4d574944) // MWID offsets for strings in MWMO //if(fourcc == 0x4d444446) // MDDF //if(fourcc == 0x4d4f4446) // MODF //if(fourcc == 0x4d48324f) // MH2O new in WotLK //if(fourcc == 0x4d46424f) // MFBO new in BC //if(fourcc == 0x4d434e4b) // MCNK //if(fourcc == 0x4d564552) // MVER //if(fourcc == 0x4d484452) // MHDR header mf.seek(nextpos); } //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) { mf.seek((int)mcnk_offsets[j * 16 + i]); LoadMapChunk(mf, &(mcells->ch[i][j])); ++chunk_num; } } mf.close(); return true; }
bool LoadADT(char* filename) { size_t size; MPQFile mf(filename); if(mf.isEof ()) { //printf("No such file.\n"); return false; } mcells=new mcell; wmoc.x =65*TILESIZE; wmoc.z =65*TILESIZE; size_t mcnk_offsets[256], mcnk_sizes[256]; wmo_count=0; bool found=false; //uint32 fs=mf.getSize ()-3; //while (mf.getPos ()<fs) while (!mf.isEof ()) { uint32 fourcc; mf.read(&fourcc,4); mf.read(&size, 4); size_t nextpos = mf.getPos () + size; if(fourcc==0x4d43494e) { // printf("Found chunks info\n"); // mapchunk offsets/sizes for (int i=0; i<256; i++) { mf.read(&mcnk_offsets[i],4); mf.read(&mcnk_sizes[i],4); mf.seekRelative(8); } //break; } else if(fourcc==0x4d4f4446) { /* if(size) { //printf("\nwmo count %d\n",size/64); wmo_count =size/64; for (int i=0; i<wmo_count; i++) { int id; mf.read(&id, 4); WMO *wmo = (WMO*)wmomanager.items[wmomanager.get(wmos[id])]; WMOInstance inst(wmo, mf); wmois.push_back(inst); } }*/ }else if(fourcc==0x4d574d4f)//mwmo { /*if (size) { char *buf = new char[size]; mf.read(buf, size); char *p=buf; while (p<buf+size) { std::string path(p); p+=strlen(p)+1; fixname(path); wmomanager.add(path); wmos.push_back(path); } delete[] buf; }*/ } // else mf.seekRelative(-3); mf.seek(nextpos); } //printf("Loading chunks info\n"); // read individual map chunks for (int j=0; j<16; j++) for (int i=0; i<16; i++) { mf.seek((int)mcnk_offsets[j*16+i]); LoadMapChunk (mf,&(mcells->ch [i][j])); } /* for(uint32 t=0;t<wmo_count ;t++) { wmois[t].draw (); }*/ mf.close (); return true; }