2 * Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #define _CRT_SECURE_NO_DEPRECATE
24 int holetab_h
[4] = {0x1111, 0x2222, 0x4444, 0x8888};
25 int holetab_v
[4] = {0x000F, 0x00F0, 0x0F00, 0xF000};
27 bool isHole(int holes
, int i
, int j
)
31 if (testi
> 3) testi
= 3;
32 if (testj
> 3) testj
= 3;
33 return (holes
& holetab_h
[testi
] & holetab_v
[testj
]) != 0;
37 // Adt file loader class
56 // Adt file check function
58 bool ADT_file::prepareLoadedData()
61 if (!FileLoader::prepareLoadedData())
64 // Check and prepare MHDR
65 a_grid
= (adt_MHDR
*)(GetData() + 8 + version
->size
);
66 if (!a_grid
->prepareLoadedData())
69 // funny offsets calculations because there is no mapping for them and they have variable lengths
70 uint8
* ptr
= (uint8
*)a_grid
+ a_grid
->size
+ 8;
71 uint32 mcnk_count
= 0;
72 memset(cells
, 0, ADT_CELLS_PER_GRID
* ADT_CELLS_PER_GRID
* sizeof(adt_MCNK
*));
73 while (ptr
< GetData() + GetDataSize())
75 uint32 header
= *(uint32
*)ptr
;
76 uint32 size
= *(uint32
*)(ptr
+ 4);
79 cells
[mcnk_count
/ ADT_CELLS_PER_GRID
][mcnk_count
% ADT_CELLS_PER_GRID
] = (adt_MCNK
*)ptr
;
87 if (mcnk_count
!= ADT_CELLS_PER_GRID
* ADT_CELLS_PER_GRID
)
93 bool adt_MHDR::prepareLoadedData()
98 if (size
!= sizeof(adt_MHDR
) - 8)
101 // Check and prepare MCIN
102 if (offsMCIN
&& !getMCIN()->prepareLoadedData())
105 // Check and prepare MH2O
106 if (offsMH2O
&& !getMH2O()->prepareLoadedData())
112 bool adt_MCIN::prepareLoadedData()
118 for (int i
= 0; i
< ADT_CELLS_PER_GRID
; i
++)
119 for (int j
= 0; j
< ADT_CELLS_PER_GRID
; j
++)
120 if (cells
[i
][j
].offsMCNK
&& !getMCNK(i
, j
)->prepareLoadedData())
126 bool adt_MH2O::prepareLoadedData()
132 // for (int i=0; i<ADT_CELLS_PER_GRID;i++)
133 // for (int j=0; j<ADT_CELLS_PER_GRID;j++)
138 bool adt_MCNK::prepareLoadedData()
144 if (offsMCVT
&& !getMCVT()->prepareLoadedData())
147 if (offsMCLQ
&& !getMCLQ()->prepareLoadedData())
153 bool adt_MCVT::prepareLoadedData()
158 if (size
!= sizeof(adt_MCVT
) - 8)
164 bool adt_MCLQ::prepareLoadedData()