TrinityCore
Loading...
Searching...
No Matches
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 "loadlib.h"
22
23#define TILESIZE (533.33333f)
24#define CHUNKSIZE ((TILESIZE) / 16.0f)
25#define UNITSIZE (CHUNKSIZE / 8.0f)
26
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 };
54public:
56
57 bool prepareLoadedData();
58};
59
60//
61// Adt file liquid map chunk (old)
62//
64{
65 union{
67 char fcc_txt[4];
68 };
69public:
71 float height1;
72 float height2;
77
78 // 1<<0 - ochen
79 // 1<<1 - lava/slime
80 // 1<<2 - water
81 // 1<<6 - all water
82 // 1<<7 - dark water
83 // == 0x0F - not show liquid
86 bool prepareLoadedData();
87};
88
89//
90// Adt file cell chunk
91//
93{
94 union{
96 char fcc_txt[4];
97 };
98public:
105 uint32 offsMCVT; // height map
106 uint32 offsMCNR; // Normal vectors for each vertex
107 uint32 offsMCLY; // Texture layer definitions
108 uint32 offsMCRF; // A list of indices into the parent file's MDDF chunk
109 uint32 offsMCAL; // Alpha maps for additional texture layers
111 uint32 offsMCSH; // Shadow map for static shadows on the terrain
124 uint32 offsMCLQ; // Liqid level (old)
126 float zpos;
127 float xpos;
128 float ypos;
129 uint32 offsMCCV; // offsColorValues in WotLK
132
133 bool prepareLoadedData();
135 {
136 if (offsMCVT)
137 return (adt_MCVT *)((uint8 *)this + offsMCVT);
138 return 0;
139 }
141 {
142 if (offsMCLQ)
143 return (adt_MCLQ *)((uint8 *)this + offsMCLQ);
144 return 0;
145 }
146};
147
148//
149// Adt file grid chunk
150//
152{
153 union{
155 char fcc_txt[4];
156 };
157public:
165
166 bool prepareLoadedData();
167 // offset from begin file (used this-84)
168 adt_MCNK *getMCNK(int x, int y)
169 {
170 if (cells[x][y].offsMCNK)
171 return (adt_MCNK *)((uint8 *)this + cells[x][y].offsMCNK - 84);
172 return 0;
173 }
174};
175
177{
178 HeightDepth = 0,
180 Depth = 2,
181};
182
201
207
208//
209// Adt file liquid data chunk (new)
210//
212{
213public:
214 union{
216 char fcc_txt[4];
217 };
219
225
226 bool prepareLoadedData();
227
229 {
230 if (liquid[x][y].used && liquid[x][y].OffsetInstances)
231 return (adt_liquid_instance *)((uint8*)this + 8 + liquid[x][y].OffsetInstances);
232 return nullptr;
233 }
234
236 {
237 if (liquid[x][y].used)
238 {
239 if (liquid[x][y].OffsetAttributes)
240 return *((adt_liquid_attributes *)((uint8*)this + 8 + liquid[x][y].OffsetAttributes));
241 return { 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF };
242 }
243 return { 0, 0 };
244 }
245
247 {
249 return 2;
250
251 return h->LiquidType;
252 }
253
254 float GetLiquidHeight(adt_liquid_instance const* h, int32 pos) const
255 {
256 if (!h->OffsetVertexData)
257 return 0.0f;
258
259 switch (h->LiquidVertexFormat)
260 {
263 return ((float const*)((uint8*)this + 8 + h->OffsetVertexData))[pos];
265 return 0.0f;
266 default:
267 break;
268 }
269
270 return 0.0f;
271 }
272
274 {
275 if (!h->OffsetVertexData)
276 return -1;
277
278 switch (h->LiquidVertexFormat)
279 {
281 return ((int8 const*)((int8 const*)this + 8 + h->OffsetVertexData + (h->GetWidth() + 1) * (h->GetHeight() + 1) * 4))[pos];
283 return 0;
285 return ((int8 const*)((uint8*)this + 8 + h->OffsetVertexData))[pos];
286 default:
287 break;
288 }
289 return 0;
290 }
291
293 {
294 if (!h->OffsetVertexData)
295 return nullptr;
296
297 switch (h->LiquidVertexFormat)
298 {
301 return nullptr;
303 return (uint16 const*)((uint8 const*)this + 8 + h->OffsetVertexData + 4 * ((h->GetWidth() + 1) * (h->GetHeight() + 1) + pos));
304 default:
305 break;
306 }
307 return nullptr;
308 }
309
311 {
312 if (h->OffsetExistsBitmap)
313 return *((uint64 *)((uint8*)this + 8 + h->OffsetExistsBitmap));
314 else
315 return 0xFFFFFFFFFFFFFFFFuLL;
316 }
317};
318
319//
320// Adt file min/max height chunk
321//
323{
324 union
325 {
327 char fcc_txt[4];
328 };
329public:
331 struct plane
332 {
334 };
337
338 bool prepareLoadedData();
339};
340
341//
342// Adt file header chunk
343//
345{
346 union{
348 char fcc_txt[4];
349 };
350public:
352
369 bool prepareLoadedData();
371 {
372 return reinterpret_cast<adt_MCIN*>(reinterpret_cast<uint8*>(&flags) + offsMCIN);
373 }
375 {
376 if (offsMH2O)
377 return reinterpret_cast<adt_MH2O*>(reinterpret_cast<uint8*>(&flags) + offsMH2O);
378 return nullptr;
379 }
381 {
382 if (flags & 1 && offsMFBO)
383 return reinterpret_cast<adt_MFBO*>(reinterpret_cast<uint8*>(&flags) + offsMFBO);
384 return nullptr;
385 }
386};
387
388class ADT_file : public FileLoader{
389public:
390 bool prepareLoadedData();
391 ADT_file();
392 ~ADT_file();
393 void free();
394
396};
397
398#pragma pack(pop)
399
400#endif
uint8_t uint8
Definition Define.h:135
int16_t int16
Definition Define.h:130
int8_t int8
Definition Define.h:131
int32_t int32
Definition Define.h:129
uint64_t uint64
Definition Define.h:132
uint16_t uint16
Definition Define.h:134
uint32_t uint32
Definition Define.h:133
#define ADT_CELL_SIZE
Definition adt.h:39
LiquidVertexFormatType
Definition adt.h:177
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
~ADT_file()
Definition adt.cpp:51
adt_MHDR * a_grid
Definition adt.h:395
ADT_file()
Definition adt.cpp:46
void free()
Definition adt.cpp:56
bool prepareLoadedData()
Definition adt.cpp:65
uint32 size
Definition adt.h:158
struct adt_MCIN::adt_CELLS cells[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID]
char fcc_txt[4]
Definition adt.h:155
adt_MCNK * getMCNK(int x, int y)
Definition adt.h:168
bool prepareLoadedData()
Definition adt.cpp:101
uint32 fcc
Definition adt.h:154
Definition adt.h:64
uint32 size
Definition adt.h:70
float height1
Definition adt.h:71
bool prepareLoadedData()
Definition adt.cpp:153
char fcc_txt[4]
Definition adt.h:67
uint8 data[84]
Definition adt.h:85
uint32 fcc
Definition adt.h:66
float height2
Definition adt.h:72
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:84
Definition adt.h:93
uint32 nEffectDoodad
Definition adt.h:121
uint32 offsMCRF
Definition adt.h:108
uint32 offsMCAL
Definition adt.h:109
uint32 sizeMCLQ
Definition adt.h:125
uint32 offsMCLY
Definition adt.h:107
adt_MCVT * getMCVT()
Definition adt.h:134
uint32 offsMCSE
Definition adt.h:122
uint32 nSndEmitters
Definition adt.h:123
float zpos
Definition adt.h:126
uint32 data2
Definition adt.h:118
uint32 holes
Definition adt.h:115
uint32 ix
Definition adt.h:101
float xpos
Definition adt.h:127
uint32 props
Definition adt.h:130
bool prepareLoadedData()
Definition adt.cpp:127
uint32 sizeMCSH
Definition adt.h:112
uint32 size
Definition adt.h:99
uint32 offsMCNR
Definition adt.h:106
adt_MCLQ * getMCLQ()
Definition adt.h:140
char fcc_txt[4]
Definition adt.h:96
uint32 data1
Definition adt.h:117
uint32 fcc
Definition adt.h:95
uint32 predTex
Definition adt.h:120
uint32 effectId
Definition adt.h:131
uint32 offsMCVT
Definition adt.h:105
uint32 data3
Definition adt.h:119
uint32 nLayers
Definition adt.h:103
uint32 iy
Definition adt.h:102
uint32 sizeMCAL
Definition adt.h:110
uint16 s[2]
Definition adt.h:116
uint32 nMapObjRefs
Definition adt.h:114
uint32 flags
Definition adt.h:100
uint32 nDoodadRefs
Definition adt.h:104
uint32 offsMCSH
Definition adt.h:111
uint32 areaid
Definition adt.h:113
uint32 offsMCLQ
Definition adt.h:124
uint32 offsMCCV
Definition adt.h:129
float ypos
Definition adt.h:128
Definition adt.h:48
float height_map[(ADT_CELL_SIZE+1) *(ADT_CELL_SIZE+1)+ADT_CELL_SIZE *ADT_CELL_SIZE]
Definition adt.h:55
bool prepareLoadedData()
Definition adt.cpp:142
uint32 fcc
Definition adt.h:50
char fcc_txt[4]
Definition adt.h:51
uint32 size
Definition adt.h:53
bool prepareLoadedData()
Definition adt.cpp:161
uint32 fcc
Definition adt.h:326
char fcc_txt[4]
Definition adt.h:327
plane min
Definition adt.h:336
uint32 size
Definition adt.h:330
plane max
Definition adt.h:335
bool prepareLoadedData()
Definition adt.cpp:115
uint16 const * GetLiquidTextureCoordMap(adt_liquid_instance const *h, int32 pos) const
Definition adt.h:292
uint32 size
Definition adt.h:218
adt_liquid_attributes GetLiquidAttributes(int32 x, int32 y) const
Definition adt.h:235
char fcc_txt[4]
Definition adt.h:216
adt_liquid_instance const * GetLiquidInstance(int32 x, int32 y) const
Definition adt.h:228
uint32 fcc
Definition adt.h:215
int8 GetLiquidDepth(adt_liquid_instance const *h, int32 pos) const
Definition adt.h:273
float GetLiquidHeight(adt_liquid_instance const *h, int32 pos) const
Definition adt.h:254
uint64 GetLiquidExistsBitmap(adt_liquid_instance const *h) const
Definition adt.h:310
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:246
uint32 flags
Definition adt.h:353
uint32 offsModelsIds
Definition adt.h:357
uint32 data2
Definition adt.h:365
uint32 size
Definition adt.h:351
adt_MFBO * getMFBO()
Definition adt.h:380
uint32 data3
Definition adt.h:366
adt_MCIN * getMCIN()
Definition adt.h:370
uint32 fcc
Definition adt.h:347
uint32 offsDoodsDef
Definition adt.h:360
adt_MH2O * getMH2O()
Definition adt.h:374
uint32 offsMH2O
Definition adt.h:363
uint32 data4
Definition adt.h:367
char fcc_txt[4]
Definition adt.h:348
uint32 offsModels
Definition adt.h:356
uint32 offsMCIN
Definition adt.h:354
uint32 offsMapObejctsIds
Definition adt.h:359
uint32 offsTex
Definition adt.h:355
uint32 data5
Definition adt.h:368
uint32 offsMapObejcts
Definition adt.h:358
uint32 offsMFBO
Definition adt.h:362
bool prepareLoadedData()
Definition adt.cpp:79
uint32 data1
Definition adt.h:364
uint32 offsObjectsDef
Definition adt.h:361
uint32 offsMCNK
Definition adt.h:160
uint32 asyncId
Definition adt.h:163
int16 coords[9]
Definition adt.h:333
uint32 OffsetAttributes
Definition adt.h:223
uint32 OffsetInstances
Definition adt.h:221
uint32 OffsetExistsBitmap
Definition adt.h:193
uint8 GetWidth() const
Definition adt.h:198
float MinHeightLevel
Definition adt.h:187
uint8 GetOffsetX() const
Definition adt.h:196
uint16 LiquidType
Definition adt.h:185
uint8 GetHeight() const
Definition adt.h:199
float MaxHeightLevel
Definition adt.h:188
LiquidVertexFormatType LiquidVertexFormat
Definition adt.h:186
uint32 OffsetVertexData
Definition adt.h:194
uint8 GetOffsetY() const
Definition adt.h:197