TrinityCore
Loading...
Searching...
No Matches
adt.cpp
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#define _CRT_SECURE_NO_DEPRECATE
19
20#include "adt.h"
21
22// Helper
23int holetab_h[4] = { 0x1111, 0x2222, 0x4444, 0x8888 };
24int holetab_v[4] = { 0x000F, 0x00F0, 0x0F00, 0xF000 };
25
26u_map_fcc MHDRMagic = { { 'R','D','H','M' } };
27u_map_fcc MCINMagic = { { 'N','I','C','M' } };
28u_map_fcc MH2OMagic = { { 'O','2','H','M' } };
29u_map_fcc MCNKMagic = { { 'K','N','C','M' } };
30u_map_fcc MCVTMagic = { { 'T','V','C','M' } };
31u_map_fcc MCLQMagic = { { 'Q','L','C','M' } };
32u_map_fcc MFBOMagic = { { 'O','B','F','M' } };
33
34bool isHole(int holes, int i, int j)
35{
36 int testi = i / 2;
37 int testj = j / 4;
38 if(testi > 3) testi = 3;
39 if(testj > 3) testj = 3;
40 return (holes & holetab_h[testi] & holetab_v[testj]) != 0;
41}
42
43//
44// Adt file loader class
45//
47{
48 a_grid = 0;
49}
50
52{
53 free();
54}
55
57{
58 a_grid = 0;
60}
61
62//
63// Adt file check function
64//
66{
67 // Check parent
69 return false;
70
71 // Check and prepare MHDR
74 return false;
75
76 return true;
77}
78
80{
81 if (fcc != MHDRMagic.fcc)
82 return false;
83
84 if (size != sizeof(adt_MHDR) - 8)
85 return false;
86
87 // Check and prepare MCIN
89 return false;
90
91 // Check and prepare MH2O
93 return false;
94
95 if (offsMFBO && flags & 1 && !getMFBO()->prepareLoadedData())
96 return false;
97
98 return true;
99}
100
102{
103 if (fcc != MCINMagic.fcc)
104 return false;
105
106 // Check cells data
107 for (int i=0; i<ADT_CELLS_PER_GRID;i++)
108 for (int j=0; j<ADT_CELLS_PER_GRID;j++)
109 if (cells[i][j].offsMCNK && !getMCNK(i,j)->prepareLoadedData())
110 return false;
111
112 return true;
113}
114
116{
117 if (fcc != MH2OMagic.fcc)
118 return false;
119
120 // Check liquid data
121// for (int i=0; i<ADT_CELLS_PER_GRID;i++)
122// for (int j=0; j<ADT_CELLS_PER_GRID;j++)
123
124 return true;
125}
126
128{
129 if (fcc != MCNKMagic.fcc)
130 return false;
131
132 // Check height map
134 return false;
135 // Check liquid data
137 return false;
138
139 return true;
140}
141
143{
144 if (fcc != MCVTMagic.fcc)
145 return false;
146
147 if (size != sizeof(adt_MCVT)-8)
148 return false;
149
150 return true;
151}
152
154{
155 if (fcc != MCLQMagic.fcc)
156 return false;
157
158 return true;
159}
160
162{
163 return fcc == MFBOMagic.fcc;
164}
uint16 holes[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID]
Definition System.cpp:346
int holetab_v[4]
Definition adt.cpp:24
u_map_fcc MCVTMagic
Definition adt.cpp:30
u_map_fcc MFBOMagic
Definition adt.cpp:32
u_map_fcc MCLQMagic
Definition adt.cpp:31
bool isHole(int holes, int i, int j)
Definition adt.cpp:34
u_map_fcc MCINMagic
Definition adt.cpp:27
int holetab_h[4]
Definition adt.cpp:23
u_map_fcc MCNKMagic
Definition adt.cpp:29
u_map_fcc MH2OMagic
Definition adt.cpp:28
u_map_fcc MHDRMagic
Definition adt.cpp:26
#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
file_MVER * version
Definition loadlib.h:56
virtual void free()
Definition loadlib.cpp:76
virtual bool prepareLoadedData()
Definition loadlib.cpp:65
uint8 * GetData()
Definition loadlib.h:53
struct adt_MCIN::adt_CELLS cells[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID]
adt_MCNK * getMCNK(int x, int y)
Definition adt.h:168
bool prepareLoadedData()
Definition adt.cpp:101
uint32 fcc
Definition adt.h:154
bool prepareLoadedData()
Definition adt.cpp:153
uint32 fcc
Definition adt.h:66
adt_MCVT * getMCVT()
Definition adt.h:134
bool prepareLoadedData()
Definition adt.cpp:127
adt_MCLQ * getMCLQ()
Definition adt.h:140
uint32 fcc
Definition adt.h:95
uint32 offsMCVT
Definition adt.h:105
uint32 offsMCLQ
Definition adt.h:124
Definition adt.h:48
bool prepareLoadedData()
Definition adt.cpp:142
uint32 fcc
Definition adt.h:50
uint32 size
Definition adt.h:53
bool prepareLoadedData()
Definition adt.cpp:161
uint32 fcc
Definition adt.h:326
bool prepareLoadedData()
Definition adt.cpp:115
uint32 fcc
Definition adt.h:215
uint32 flags
Definition adt.h:353
uint32 size
Definition adt.h:351
adt_MFBO * getMFBO()
Definition adt.h:380
adt_MCIN * getMCIN()
Definition adt.h:370
uint32 fcc
Definition adt.h:347
adt_MH2O * getMH2O()
Definition adt.h:374
uint32 offsMH2O
Definition adt.h:363
uint32 offsMCIN
Definition adt.h:354
uint32 offsMFBO
Definition adt.h:362
bool prepareLoadedData()
Definition adt.cpp:79
uint32 size
Definition loadlib.h:44
uint32 fcc
Definition loadlib.h:32