TrinityCore
adt.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef ADT_H
19#define ADT_H
20
21#include "Define.h"
22
23#define TILESIZE (533.33333f)
24#define CHUNKSIZE ((TILESIZE) / 16.0f)
25#define UNITSIZE (CHUNKSIZE / 8.0f)
26
28{
33};
34
35//**************************************************************************************
36// ADT file class
37//**************************************************************************************
38#define ADT_CELLS_PER_GRID 16
39#define ADT_CELL_SIZE 8
40#define ADT_GRID_SIZE (ADT_CELLS_PER_GRID*ADT_CELL_SIZE)
41
42#pragma pack(push, 1)
43
44//
45// Adt file height map chunk
46//
48{
49 union{
51 char fcc_txt[4];
52 };
55};
56
57//
58// Adt file liquid map chunk (old)
59//
61{
62 union{
64 char fcc_txt[4];
65 };
67 float height1;
68 float height2;
71 float height;
73
74 // 1<<0 - ochen
75 // 1<<1 - lava/slime
76 // 1<<2 - water
77 // 1<<6 - all water
78 // 1<<7 - dark water
79 // == 0x0F - not show liquid
82};
83
84//
85// Adt file cell chunk
86//
88{
89 union{
91 char fcc_txt[4];
92 };
99 union
100 {
101 struct
102 {
103 uint32 offsMCVT; // height map
104 uint32 offsMCNR; // Normal vectors for each vertex
108 uint32 offsMCLY; // Texture layer definitions
109 uint32 offsMCRF; // A list of indices into the parent file's MDDF chunk
110 uint32 offsMCAL; // Alpha maps for additional texture layers
112 uint32 offsMCSH; // Shadow map for static shadows on the terrain
125 uint32 offsMCLQ; // Liqid level (old)
127 float zpos;
128 float xpos;
129 float ypos;
130 uint32 offsMCCV; // offsColorValues in WotLK
133};
134
135#define ADT_LIQUID_HEADER_FULL_LIGHT 0x01
136#define ADT_LIQUID_HEADER_NO_HIGHT 0x02
137
139{
140 HeightDepth = 0,
142 Depth = 2,
144 Unk4 = 4,
145 Unk5 = 5
146};
147
149{
150 uint16 LiquidType; // Index from LiquidType.db2
151 uint16 LiquidVertexFormat; // Id from LiquidObject.db2 if >= 42
160
161 uint8 GetOffsetX() const { return LiquidVertexFormat < 42 ? OffsetX : 0; }
162 uint8 GetOffsetY() const { return LiquidVertexFormat < 42 ? OffsetY : 0; }
163 uint8 GetWidth() const { return LiquidVertexFormat < 42 ? Width : 8; }
164 uint8 GetHeight() const { return LiquidVertexFormat < 42 ? Height : 8; }
165};
166
168{
171};
172
173//
174// Adt file liquid data chunk (new)
175//
177{
178 union{
180 char fcc_txt[4];
181 };
183
189
191 {
192 if (liquid[x][y].used && liquid[x][y].OffsetInstances)
193 return (adt_liquid_instance *)((uint8*)this + 8 + liquid[x][y].OffsetInstances);
194 return nullptr;
195 }
196
198 {
199 if (liquid[x][y].used)
200 {
201 if (liquid[x][y].OffsetAttributes)
202 return *((adt_liquid_attributes *)((uint8*)this + 8 + liquid[x][y].OffsetAttributes));
203 return { 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF };
204 }
205 return { 0, 0 };
206 }
207
209 {
211 return 2;
212
213 return h->LiquidType;
214 }
215
216 float GetLiquidHeight(adt_liquid_instance const* h, int32 pos) const
217 {
218 if (!h->OffsetVertexData)
219 return 0.0f;
221 return 0.0f;
222
223 switch (GetLiquidVertexFormat(h))
224 {
228 return ((float const*)((uint8*)this + 8 + h->OffsetVertexData))[pos];
230 return 0.0f;
233 return ((float const*)((uint8*)this + 8 + h->OffsetVertexData + 4))[pos * 2];
234 default:
235 break;
236 }
237
238 return 0.0f;
239 }
240
242 {
243 if (!h->OffsetVertexData)
244 return -1;
245
246 switch (GetLiquidVertexFormat(h))
247 {
249 return ((int8 const*)((int8 const*)this + 8 + h->OffsetVertexData + (h->GetWidth() + 1) * (h->GetHeight() + 1) * 4))[pos];
251 return 0;
253 return ((int8 const*)((uint8*)this + 8 + h->OffsetVertexData))[pos];
255 return ((int8 const*)((int8 const*)this + 8 + h->OffsetVertexData + (h->GetWidth() + 1) * (h->GetHeight() + 1) * 8))[pos];
257 return ((int8 const*)((uint8*)this + 8 + h->OffsetVertexData))[pos * 8];
259 return 0;
260 default:
261 break;
262 }
263 return 0;
264 }
265
267 {
268 if (!h->OffsetVertexData)
269 return nullptr;
270
271 switch (GetLiquidVertexFormat(h))
272 {
276 return nullptr;
279 return (uint16 const*)((uint8 const*)this + 8 + h->OffsetVertexData + 4 * ((h->GetWidth() + 1) * (h->GetHeight() + 1) + pos));
281 return (uint16 const*)((uint8 const*)this + 8 + h->OffsetVertexData + 8 * ((h->GetWidth() + 1) * (h->GetHeight() + 1) + pos));
282 default:
283 break;
284 }
285 return nullptr;
286 }
287
289 {
290 if (h->OffsetExistsBitmap)
291 return *((uint64 *)((uint8*)this + 8 + h->OffsetExistsBitmap));
292 else
293 return 0xFFFFFFFFFFFFFFFFuLL;
294 }
295
297};
298
300{
301 union
302 {
304 char fcc_txt[4];
305 };
307 struct plane
308 {
310 };
313};
314
315#pragma pack(pop)
316
317#endif
uint8_t uint8
Definition: Define.h:144
int16_t int16
Definition: Define.h:139
int8_t int8
Definition: Define.h:140
int32_t int32
Definition: Define.h:138
uint64_t uint64
Definition: Define.h:141
uint16_t uint16
Definition: Define.h:143
uint32_t uint32
Definition: Define.h:142
#define ADT_CELL_SIZE
Definition: adt.h:39
LiquidVertexFormatType
Definition: adt.h:139
LiquidType
Definition: adt.h:28
@ LIQUID_TYPE_WATER
Definition: adt.h:29
@ LIQUID_TYPE_SLIME
Definition: adt.h:32
@ LIQUID_TYPE_MAGMA
Definition: adt.h:31
@ LIQUID_TYPE_OCEAN
Definition: adt.h:30
#define ADT_CELLS_PER_GRID
Definition: adt.h:38
uint32 light
Definition: adt.h:70
Definition: adt.h:61
uint32 size
Definition: adt.h:66
float height1
Definition: adt.h:67
char fcc_txt[4]
Definition: adt.h:64
uint8 data[84]
Definition: adt.h:81
uint32 fcc
Definition: adt.h:63
float height2
Definition: adt.h:68
struct adt_MCLQ::liquid_data liquid[ADT_CELL_SIZE+1][ADT_CELL_SIZE+1]
uint8 flags[ADT_CELL_SIZE][ADT_CELL_SIZE]
Definition: adt.h:80
Definition: adt.h:88
uint32 nEffectDoodad
Definition: adt.h:122
uint32 offsMCRF
Definition: adt.h:109
uint8 HighResHoles[8]
Definition: adt.h:106
uint32 offsMCAL
Definition: adt.h:110
uint32 sizeMCLQ
Definition: adt.h:126
uint32 offsMCLY
Definition: adt.h:108
uint32 offsMCSE
Definition: adt.h:123
uint32 nSndEmitters
Definition: adt.h:124
float zpos
Definition: adt.h:127
uint32 data2
Definition: adt.h:119
uint32 holes
Definition: adt.h:116
uint32 ix
Definition: adt.h:95
float xpos
Definition: adt.h:128
uint32 props
Definition: adt.h:131
uint32 sizeMCSH
Definition: adt.h:113
uint32 size
Definition: adt.h:93
uint32 offsMCNR
Definition: adt.h:104
char fcc_txt[4]
Definition: adt.h:91
struct adt_MCNK::@360::@361 offsets
uint32 data1
Definition: adt.h:118
uint32 fcc
Definition: adt.h:90
uint32 predTex
Definition: adt.h:121
uint32 effectId
Definition: adt.h:132
uint32 offsMCVT
Definition: adt.h:103
uint32 data3
Definition: adt.h:120
uint32 nLayers
Definition: adt.h:97
uint32 iy
Definition: adt.h:96
uint32 sizeMCAL
Definition: adt.h:111
uint16 s[2]
Definition: adt.h:117
union adt_MCNK::@360 union_5_3_0
uint32 nMapObjRefs
Definition: adt.h:115
uint32 flags
Definition: adt.h:94
uint32 nDoodadRefs
Definition: adt.h:98
uint32 offsMCSH
Definition: adt.h:112
uint32 areaid
Definition: adt.h:114
uint32 offsMCLQ
Definition: adt.h:125
uint32 offsMCCV
Definition: adt.h:130
float ypos
Definition: adt.h:129
Definition: adt.h:48
float height_map[(ADT_CELL_SIZE+1) *(ADT_CELL_SIZE+1)+ADT_CELL_SIZE *ADT_CELL_SIZE]
Definition: adt.h:54
uint32 fcc
Definition: adt.h:50
char fcc_txt[4]
Definition: adt.h:51
uint32 size
Definition: adt.h:53
int16 coords[9]
Definition: adt.h:309
Definition: adt.h:300
uint32 fcc
Definition: adt.h:303
char fcc_txt[4]
Definition: adt.h:304
plane min
Definition: adt.h:312
uint32 size
Definition: adt.h:306
plane max
Definition: adt.h:311
uint32 OffsetAttributes
Definition: adt.h:187
uint32 OffsetInstances
Definition: adt.h:185
Definition: adt.h:177
uint16 const * GetLiquidTextureCoordMap(adt_liquid_instance const *h, int32 pos) const
Definition: adt.h:266
uint32 size
Definition: adt.h:182
adt_liquid_attributes GetLiquidAttributes(int32 x, int32 y) const
Definition: adt.h:197
char fcc_txt[4]
Definition: adt.h:180
adt_liquid_instance const * GetLiquidInstance(int32 x, int32 y) const
Definition: adt.h:190
uint32 fcc
Definition: adt.h:179
int8 GetLiquidDepth(adt_liquid_instance const *h, int32 pos) const
Definition: adt.h:241
float GetLiquidHeight(adt_liquid_instance const *h, int32 pos) const
Definition: adt.h:216
LiquidVertexFormatType GetLiquidVertexFormat(adt_liquid_instance const *liquidInstance) const
Definition: System.cpp:444
uint64 GetLiquidExistsBitmap(adt_liquid_instance const *h) const
Definition: adt.h:288
struct adt_MH2O::adt_LIQUID liquid[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID]
uint16 GetLiquidType(adt_liquid_instance const *h) const
Definition: adt.h:208
uint64 Fishable
Definition: adt.h:169
uint8 OffsetY
Definition: adt.h:155
uint32 OffsetExistsBitmap
Definition: adt.h:158
uint8 OffsetX
Definition: adt.h:154
uint8 GetWidth() const
Definition: adt.h:163
float MinHeightLevel
Definition: adt.h:152
uint8 GetOffsetX() const
Definition: adt.h:161
uint16 LiquidType
Definition: adt.h:150
uint8 GetHeight() const
Definition: adt.h:164
float MaxHeightLevel
Definition: adt.h:153
uint8 Height
Definition: adt.h:157
uint32 OffsetVertexData
Definition: adt.h:159
uint8 GetOffsetY() const
Definition: adt.h:162
uint16 LiquidVertexFormat
Definition: adt.h:151