TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
adt.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef ADT_H
20 #define ADT_H
21 
22 #include "loadlib.h"
23 
24 #define TILESIZE (533.33333f)
25 #define CHUNKSIZE ((TILESIZE) / 16.0f)
26 #define UNITSIZE (CHUNKSIZE / 8.0f)
27 
29 {
34 };
35 
36 //**************************************************************************************
37 // ADT file class
38 //**************************************************************************************
39 #define ADT_CELLS_PER_GRID 16
40 #define ADT_CELL_SIZE 8
41 #define ADT_GRID_SIZE (ADT_CELLS_PER_GRID*ADT_CELL_SIZE)
42 
43 #pragma pack(push, 1)
44 
45 //
46 // Adt file height map chunk
47 //
48 struct adt_MCVT
49 {
50  union{
52  char fcc_txt[4];
53  };
56 };
57 
58 //
59 // Adt file liquid map chunk (old)
60 //
61 struct adt_MCLQ
62 {
63  union{
65  char fcc_txt[4];
66  };
68  float height1;
69  float height2;
70  struct liquid_data{
72  float height;
74 
75  // 1<<0 - ochen
76  // 1<<1 - lava/slime
77  // 1<<2 - water
78  // 1<<6 - all water
79  // 1<<7 - dark water
80  // == 0x0F - not show liquid
82  uint8 data[84];
83 };
84 
85 //
86 // Adt file cell chunk
87 //
88 struct adt_MCNK
89 {
90  union{
92  char fcc_txt[4];
93  };
100  union
101  {
102  struct
103  {
104  uint32 offsMCVT; // height map
105  uint32 offsMCNR; // Normal vectors for each vertex
106  } offsets;
108  } union_5_3_0;
109  uint32 offsMCLY; // Texture layer definitions
110  uint32 offsMCRF; // A list of indices into the parent file's MDDF chunk
111  uint32 offsMCAL; // Alpha maps for additional texture layers
113  uint32 offsMCSH; // Shadow map for static shadows on the terrain
118  uint16 s[2];
126  uint32 offsMCLQ; // Liqid level (old)
128  float zpos;
129  float xpos;
130  float ypos;
131  uint32 offsMCCV; // offsColorValues in WotLK
134 };
135 
136 #define ADT_LIQUID_HEADER_FULL_LIGHT 0x01
137 #define ADT_LIQUID_HEADER_NO_HIGHT 0x02
138 
140 {
141  uint16 liquidType; // Index from LiquidType.dbc
151 };
152 
153 //
154 // Adt file liquid data chunk (new)
155 //
156 struct adt_MH2O
157 {
158  union{
160  char fcc_txt[4];
161  };
163 
164  struct adt_LIQUID{
169 
171  {
172  if (liquid[x][y].used && liquid[x][y].offsData1)
173  return (adt_liquid_header *)((uint8*)this + 8 + liquid[x][y].offsData1);
174  return 0;
175  }
176 
178  {
180  return 0;
181  if (h->offsData2b)
182  return (float *)((uint8*)this + 8 + h->offsData2b);
183  return 0;
184  }
185 
187  {
189  return 0;
190  if (h->offsData2b)
191  {
193  return (uint8 *)((uint8*)this + 8 + h->offsData2b);
194  return (uint8 *)((uint8*)this + 8 + h->offsData2b + (h->width+1)*(h->height+1)*4);
195  }
196  return 0;
197  }
198 
200  {
202  return 0;
203  if (h->offsData2b)
204  {
206  return (uint32 *)((uint8*)this + 8 + h->offsData2b);
207  return (uint32 *)((uint8*)this + 8 + h->offsData2b + (h->width+1)*(h->height+1)*4);
208  }
209  return 0;
210  }
211 
213  {
214  if (h->offsData2a)
215  return *((uint64 *)((uint8*)this + 8 + h->offsData2a));
216  else
217  return 0xFFFFFFFFFFFFFFFFuLL;
218  }
219 
220 };
221 
222 struct adt_MFBO
223 {
224  union
225  {
227  char fcc_txt[4];
228  };
230  struct plane
231  {
233  };
236 };
237 
238 #pragma pack(pop)
239 
240 #endif
float ypos
Definition: adt.h:130
uint32 sizeMCAL
Definition: adt.h:112
Definition: adt.h:31
Definition: adt.h:32
uint32 data2
Definition: adt.h:120
uint32 nMapObjRefs
Definition: adt.h:116
Definition: adt.h:230
char fcc_txt[4]
Definition: adt.h:65
uint32 offsMCRF
Definition: adt.h:110
plane max
Definition: adt.h:234
uint32 offsMCAL
Definition: adt.h:111
char fcc_txt[4]
Definition: adt.h:92
uint32 predTex
Definition: adt.h:122
Definition: adt.h:33
uint32 offsMCNR
Definition: adt.h:105
float height1
Definition: adt.h:68
uint32 size
Definition: adt.h:67
LiquidType
Definition: adt.h:28
union adt_MCNK::@346 union_5_3_0
uint32 offsMCCV
Definition: adt.h:131
uint16 formatFlags
Definition: adt.h:142
uint32 * getLiquidFullLightMap(adt_liquid_header *h)
Definition: adt.h:199
uint32 size
Definition: adt.h:162
uint32 ix
Definition: adt.h:96
uint32 nLayers
Definition: adt.h:98
uint32 offsMCLY
Definition: adt.h:109
uint32 offsData2a
Definition: adt.h:149
uint8 HighResHoles[8]
Definition: adt.h:107
uint32 holes
Definition: adt.h:117
Definition: adt.h:222
Definition: adt.h:156
uint32 nSndEmitters
Definition: adt.h:125
uint16 s[2]
Definition: adt.h:118
adt_liquid_header * getLiquidData(int x, int y)
Definition: adt.h:170
uint32 size
Definition: adt.h:54
uint32 data1
Definition: adt.h:119
struct adt_MCLQ::liquid_data liquid[ADT_CELL_SIZE+1][ADT_CELL_SIZE+1]
struct adt_MCNK::@346::@347 offsets
uint32 offsData2
Definition: adt.h:167
Definition: adt.h:48
uint64 getLiquidShowMap(adt_liquid_header *h)
Definition: adt.h:212
char fcc_txt[4]
Definition: adt.h:160
uint32 fcc
Definition: adt.h:226
#define ADT_LIQUID_HEADER_NO_HIGHT
Definition: adt.h:137
Definition: adt.h:61
struct adt_MH2O::adt_LIQUID liquid[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID]
uint32 offsMCVT
Definition: adt.h:104
uint32 areaid
Definition: adt.h:115
uint32 flags
Definition: adt.h:95
float height_map[(ADT_CELL_SIZE+1)*(ADT_CELL_SIZE+1)+ADT_CELL_SIZE *ADT_CELL_SIZE]
Definition: adt.h:55
#define ADT_CELLS_PER_GRID
Definition: adt.h:39
uint8 data[84]
Definition: adt.h:82
uint8 flags[ADT_CELL_SIZE][ADT_CELL_SIZE]
Definition: adt.h:81
uint32 fcc
Definition: adt.h:159
uint32 offsData1
Definition: adt.h:165
Definition: adt.h:139
uint8 yOffset
Definition: adt.h:146
float height
Definition: adt.h:72
uint32 data3
Definition: adt.h:121
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
G3D::int16 y
Definition: Vector2int16.h:38
uint16_t uint16
Definition: Define.h:151
uint32 size
Definition: adt.h:229
uint32 effectId
Definition: adt.h:133
uint8 width
Definition: adt.h:147
#define ADT_CELL_SIZE
Definition: adt.h:40
float height2
Definition: adt.h:69
uint32 nEffectDoodad
Definition: adt.h:123
uint32 offsMCLQ
Definition: adt.h:126
uint32 fcc
Definition: adt.h:91
uint32 used
Definition: adt.h:166
uint32 offsMCSE
Definition: adt.h:124
uint32 sizeMCLQ
Definition: adt.h:127
uint32 sizeMCSH
Definition: adt.h:114
#define ADT_LIQUID_HEADER_FULL_LIGHT
Definition: adt.h:136
Definition: adt.h:164
uint32 offsData2b
Definition: adt.h:150
uint16 liquidType
Definition: adt.h:141
float heightLevel2
Definition: adt.h:144
uint32 fcc
Definition: adt.h:51
float heightLevel1
Definition: adt.h:143
Definition: adt.h:30
Definition: adt.h:70
uint8_t uint8
Definition: Define.h:152
uint8 * getLiquidLightMap(adt_liquid_header *h)
Definition: adt.h:186
float xpos
Definition: adt.h:129
uint32 nDoodadRefs
Definition: adt.h:99
uint8 xOffset
Definition: adt.h:145
int16_t int16
Definition: Define.h:147
uint32 size
Definition: adt.h:94
float zpos
Definition: adt.h:128
uint32 props
Definition: adt.h:132
G3D::int16 x
Definition: Vector2int16.h:37
plane min
Definition: adt.h:235
uint32 iy
Definition: adt.h:97
uint32 offsMCSH
Definition: adt.h:113
uint32 fcc
Definition: adt.h:64
uint8 height
Definition: adt.h:148
char fcc_txt[4]
Definition: adt.h:52
int16 coords[9]
Definition: adt.h:232
char fcc_txt[4]
Definition: adt.h:227
uint32 light
Definition: adt.h:71
Definition: adt.h:88
float * getLiquidHeightMap(adt_liquid_header *h)
Definition: adt.h:177