⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adt.cpp

📁 魔兽解压DBC的一些功能代码,专门用来分解魔兽客户端所使用的代码
💻 CPP
字号:
#define _CRT_SECURE_NO_DEPRECATE

#ifdef WIN32
#include <windows.h>
#endif

#include <string.h>
#include <stdio.h>
#include <math.h>
#include <string>
#include <map>
#include <vector>
#include <set>

#include "adt.h"
#include "mpq_libmpq.h"

unsigned int iRes = 256;
extern uint16 *areas;
extern uint16 *LiqType;
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};

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(int j = 0; j < 256; ++j)
        MapLiqFlag[j] = 0;                                  // no water

    MapLiqHeight = new float[16384];
    for(int 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];

    //wmo_count = 0;
    //bool found = false;

    MH2O_presence = false;
    chunk_num = 0;
    k = 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 (int 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 && size)                    // MH2O new in WotLK
        {
            MH2O_presence = true;
            // 玟羼

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -