Files
moonwell-core-vanilla/contrib/extractor/loadlib/adt.h
T
ratkosrb 9a30372093 Updates to maps, vmaps and mmaps (#303)
Credits to cmangos and trinitycore projects.

https://github.com/cmangos/mangos-classic/commit/fd6c640c6ef4afe028180e2d9b8ffc73a20ec902
https://github.com/cmangos/mangos-classic/commit/9b48da5237c90f5be471599f594ccfda4fd07eb9
https://github.com/cmangos/mangos-classic/commit/a391308caf0220f3058ccfc5ab77c3e0b0dff3df
https://github.com/cmangos/mangos-classic/commit/def10c862b818c01d947de53167d0c8ed7d81001
https://github.com/cmangos/mangos-classic/commit/46229bb28c6a4362dc4f4ee88e8bdaf962cb1d58
https://github.com/cmangos/mangos-classic/commit/2e7af8455566d7b289c8fa8b00472a9f21ca1494
https://github.com/cmangos/mangos-classic/commit/9cc773b719ddb2498ff91ae9ae90f9cea71f3528
https://github.com/cmangos/mangos-classic/commit/c1d97517b0673769bad1343a0c9f9b24d24ab738
https://github.com/cmangos/mangos-classic/commit/74b1e01542ea3ea65239d1762662134abae43f13
https://github.com/cmangos/mangos-classic/commit/5442ad1d79efc7e3442fd01fdeda9cc7f60b6b64
https://github.com/cmangos/mangos-classic/commit/bfff02bd0eb383c635bf4375695d096080d5c2e0
https://github.com/cmangos/mangos-classic/commit/8daa3ffb6687d38b0912cd19905d03328de82e61
https://github.com/cmangos/mangos-classic/commit/1ede0a03aa61a9d84a883f113baa2c32d27f1a6b
https://github.com/cmangos/mangos-classic/commit/ac5a8a60b8a54da9c3b1739307c14ca0a053f738
https://github.com/cmangos/mangos-classic/commit/48a84fbfb6c30d81fb1b7467b071a1512112d50a
https://github.com/cmangos/mangos-classic/commit/9d4bc6efa615849aa4f936d90fd3f0b40c0a64d2
https://github.com/cmangos/mangos-classic/commit/3db7b9313c52b415230a29d19ddd256d47019a4a
https://github.com/cmangos/mangos-classic/commit/866ec2d489c06c48750774198c2f1ad893c706b3
https://github.com/cmangos/mangos-classic/commit/256cbefafd46a30cc86ab284e86590a469296a14
https://github.com/cmangos/mangos-classic/commit/4b39ff359de2c5a88387634819e58b476ab05202
https://github.com/cmangos/mangos-classic/commit/c6854d16a597fbba3cc27cd8046e418c5cb33d13
https://github.com/cmangos/mangos-classic/commit/7f15528cfc745f38ac23eb4041bb756bdd44234a
https://github.com/cmangos/mangos-classic/commit/1b15fa34d3469a16c7df78a37505d9b5f2bd097e
https://github.com/cmangos/mangos-classic/commit/64a77261091b408d8dcfbbd7869c173263a23efb
https://github.com/cmangos/mangos-classic/commit/7cb695c95826aa7491416fbc285b827c3ff3ebb9
https://github.com/cmangos/mangos-classic/commit/0587095290ce956e42c2d614a83262ae756cc935
https://github.com/cmangos/mangos-classic/commit/09034fb082cca3d60a2cd25aac01a8032c1163e7
https://github.com/cmangos/mangos-classic/commit/9ae1e8bebf36bf94162379c0b4aac27bc2b99636
https://github.com/cmangos/mangos-classic/commit/be83b98f01d5f71e7464bc41c49f74ef0fde009a
https://github.com/cmangos/mangos-classic/commit/26c0877cec74c30498d553f2f933012d7a5aecb2
https://github.com/cmangos/mangos-classic/commit/1b3c8ee3c2dc90b0b0082bf2df640d48c9bcb96c
https://github.com/cmangos/mangos-classic/commit/6a96d69e839fba35d984835b43af7ca37f4b2688
https://github.com/cmangos/mangos-classic/commit/d9853f1d0e11dcd6ca65f911e38227befdcb691b
https://github.com/cmangos/mangos-classic/commit/5afd6a6fd04eec9b61e1bd604b2ef0d910f0b7c2
https://github.com/cmangos/mangos-classic/commit/c3ea0498239e86a6f310458db86ef77090e01eab
https://github.com/cmangos/mangos-classic/commit/35bc62ac2b7bf3c97e780724cc4d14b14837660c
https://github.com/cmangos/mangos-classic/commit/95fcec8517340f729af08d1397728d0552120f88
https://github.com/cmangos/mangos-classic/commit/a09d1e523b59ba33543a64660555a9e990eacfb9
https://github.com/cmangos/mangos-classic/commit/f6107dfc34fc7c2a2fb27f37678d6fc6f8b96802
https://github.com/cmangos/mangos-classic/commit/af2437976b2e5685f9a5e605d92da4088a402f48
https://github.com/cmangos/mangos-classic/commit/e0c98be3e7ea6e00dd2e23dc0d4cbbb5b308521b
https://github.com/cmangos/mangos-classic/commit/ac70b0ef1aec0425e23deca77d761dcf3e9a9a66
https://github.com/cmangos/mangos-classic/commit/0d3fd0d5b8a0710e56a56703e0d8338e33863078
https://github.com/cmangos/mangos-classic/commit/a9393d27649b15398cebaaba01ef05436c6f5ab5
https://github.com/cmangos/mangos-classic/commit/9b38ef751b83cd091267140153a1c383b7c769c4
https://github.com/cmangos/mangos-classic/commit/3208a5e7a722e6d9bd1ee8fae6fc539b55078a7f
https://github.com/TrinityCore/TrinityCore/commit/7ddbc18aafe61434971013ed6126f5666011ab43
https://github.com/TrinityCore/TrinityCore/commit/c602220e02bed1ad76c9e60064eeec5fd97bfe80
https://github.com/TrinityCore/TrinityCore/commit/5a980226497605b18f1855fa39f340c10ee9dd53
2019-11-15 14:35:02 +02:00

322 lines
8.2 KiB
C++

/*
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef ADT_H
#define ADT_H
#include "loadlib.h"
#define TILESIZE (533.33333f)
#define CHUNKSIZE ((TILESIZE) / 16.0f)
#define UNITSIZE (CHUNKSIZE / 8.0f)
enum LiquidType
{
LIQUID_TYPE_MAGMA = 0,
LIQUID_TYPE_OCEAN = 1,
LIQUID_TYPE_SLIME = 2,
LIQUID_TYPE_WATER = 3
};
//**************************************************************************************
// ADT file class
//**************************************************************************************
#define ADT_CELLS_PER_GRID 16
#define ADT_CELL_SIZE 8
#define ADT_GRID_SIZE (ADT_CELLS_PER_GRID*ADT_CELL_SIZE)
//
// Adt file height map chunk
//
class adt_MCVT
{
union
{
uint32 fcc;
char fcc_txt[4];
};
uint32 size;
public:
float height_map[(ADT_CELL_SIZE + 1) * (ADT_CELL_SIZE + 1) + ADT_CELL_SIZE * ADT_CELL_SIZE];
bool prepareLoadedData();
};
//
// Adt file liquid map chunk (old)
//
class adt_MCLQ
{
union
{
uint32 fcc;
char fcc_txt[4];
};
uint32 size;
public:
float height1;
float height2;
struct liquid_data
{
uint32 light;
float height;
} liquid[ADT_CELL_SIZE + 1][ADT_CELL_SIZE + 1];
// 1<<0 - ochen
// 1<<1 - lava/slime
// 1<<2 - water
// 1<<6 - all water
// 1<<7 - dark water
// == 0x0F - not show liquid
uint8 flags[ADT_CELL_SIZE][ADT_CELL_SIZE];
uint8 data[84];
bool prepareLoadedData();
};
//
// Adt file cell chunk
//
class adt_MCNK
{
union
{
uint32 fcc;
char fcc_txt[4];
};
uint32 size;
public:
uint32 flags;
uint32 ix;
uint32 iy;
uint32 nLayers;
uint32 nDoodadRefs;
uint32 offsMCVT; // height map
uint32 offsMCNR; // Normal vectors for each vertex
uint32 offsMCLY; // Texture layer definitions
uint32 offsMCRF; // A list of indices into the parent file's MDDF chunk
uint32 offsMCAL; // Alpha maps for additional texture layers
uint32 sizeMCAL;
uint32 offsMCSH; // Shadow map for static shadows on the terrain
uint32 sizeMCSH;
uint32 areaid;
uint32 nMapObjRefs;
uint16 holes; // locations where models pierce the heightmap
uint16 pad;
uint16 s[2];
uint32 data1;
uint32 data2;
uint32 data3;
uint32 predTex;
uint32 nEffectDoodad;
uint32 offsMCSE;
uint32 nSndEmitters;
uint32 offsMCLQ; // Liqid level (old)
uint32 sizeMCLQ; //
float zpos;
float xpos;
float ypos;
uint32 offsMCCV; // offsColorValues in WotLK
uint32 props;
uint32 effectId;
bool prepareLoadedData();
adt_MCVT* getMCVT()
{
if (offsMCVT)
return (adt_MCVT*)((uint8*)this + offsMCVT);
return 0;
}
adt_MCLQ* getMCLQ()
{
if (offsMCLQ)
return (adt_MCLQ*)((uint8*)this + offsMCLQ);
return 0;
}
};
//
// Adt file grid chunk
//
class adt_MCIN
{
union
{
uint32 fcc;
char fcc_txt[4];
};
uint32 size;
public:
struct adt_CELLS
{
uint32 offsMCNK;
uint32 size;
uint32 flags;
uint32 asyncId;
} cells[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
bool prepareLoadedData();
// offset from begin file (used this-84)
adt_MCNK* getMCNK(int x, int y)
{
if (cells[x][y].offsMCNK)
return (adt_MCNK*)((uint8*)this + cells[x][y].offsMCNK - 84);
return 0;
}
};
#define ADT_LIQUID_HEADER_FULL_LIGHT 0x01
#define ADT_LIQUID_HEADER_NO_HIGHT 0x02
struct adt_liquid_header
{
uint16 liquidType; // Index from LiquidType.dbc
uint16 formatFlags;
float heightLevel1;
float heightLevel2;
uint8 xOffset;
uint8 yOffset;
uint8 width;
uint8 height;
uint32 offsData2a;
uint32 offsData2b;
};
//
// Adt file liquid data chunk (new)
//
class adt_MH2O
{
public:
union
{
uint32 fcc;
char fcc_txt[4];
};
uint32 size;
struct adt_LIQUID
{
uint32 offsData1;
uint32 used;
uint32 offsData2;
} liquid[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
bool prepareLoadedData();
adt_liquid_header* getLiquidData(int x, int y)
{
if (liquid[x][y].used && liquid[x][y].offsData1)
return (adt_liquid_header*)((uint8*)this + 8 + liquid[x][y].offsData1);
return 0;
}
float* getLiquidHeightMap(adt_liquid_header* h)
{
if (h->formatFlags & ADT_LIQUID_HEADER_NO_HIGHT)
return 0;
if (h->offsData2b)
return (float*)((uint8*)this + 8 + h->offsData2b);
return 0;
}
uint8* getLiquidLightMap(adt_liquid_header* h)
{
if (h->formatFlags & ADT_LIQUID_HEADER_FULL_LIGHT)
return 0;
if (h->offsData2b)
{
if (h->formatFlags & ADT_LIQUID_HEADER_NO_HIGHT)
return (uint8*)((uint8*)this + 8 + h->offsData2b);
return (uint8*)((uint8*)this + 8 + h->offsData2b + (h->width + 1) * (h->height + 1) * 4);
}
return 0;
}
uint32* getLiquidFullLightMap(adt_liquid_header* h)
{
if (!(h->formatFlags & ADT_LIQUID_HEADER_FULL_LIGHT))
return 0;
if (h->offsData2b)
{
if (h->formatFlags & ADT_LIQUID_HEADER_NO_HIGHT)
return (uint32*)((uint8*)this + 8 + h->offsData2b);
return (uint32*)((uint8*)this + 8 + h->offsData2b + (h->width + 1) * (h->height + 1) * 4);
}
return 0;
}
uint64 getLiquidShowMap(adt_liquid_header* h)
{
if (h->offsData2a)
return *((uint64*)((uint8*)this + 8 + h->offsData2a));
else
return 0xFFFFFFFFFFFFFFFFLL;
}
};
//
// Adt file header chunk
//
class adt_MHDR
{
union
{
uint32 fcc;
char fcc_txt[4];
};
uint32 size;
uint32 pad;
uint32 offsMCIN; // MCIN
uint32 offsTex; // MTEX
uint32 offsModels; // MMDX
uint32 offsModelsIds; // MMID
uint32 offsMapObejcts; // MWMO
uint32 offsMapObejctsIds; // MWID
uint32 offsDoodsDef; // MDDF
uint32 offsObjectsDef; // MODF
uint32 offsMFBO; // MFBO
uint32 offsMH2O; // MH2O
uint32 data1;
uint32 data2;
uint32 data3;
uint32 data4;
uint32 data5;
public:
bool prepareLoadedData();
adt_MCIN* getMCIN() { return (adt_MCIN*)((uint8*)&pad + offsMCIN);}
adt_MH2O* getMH2O() { return offsMH2O ? (adt_MH2O*)((uint8*)&pad + offsMH2O) : 0;}
};
class ADT_file : public FileLoader
{
public:
bool prepareLoadedData();
ADT_file();
~ADT_file();
void free();
adt_MHDR* a_grid;
};
bool isHole(int holes, int i, int j);
#endif