Files
moonwell-core-vanilla/contrib/extractor/loadlib/adt.cpp
T
ratkosrb 9a30372093 Updates to maps, vmaps and mmaps (#303)
Credits to cmangos and trinitycore projects.

https://github.com/cmangos/mangos-classic/commit/fd6c640c6ef4afe028180e2d9b8ffc73a20ec902
https://github.com/cmangos/mangos-classic/commit/9b48da5237c90f5be471599f594ccfda4fd07eb9
https://github.com/cmangos/mangos-classic/commit/a391308caf0220f3058ccfc5ab77c3e0b0dff3df
https://github.com/cmangos/mangos-classic/commit/def10c862b818c01d947de53167d0c8ed7d81001
https://github.com/cmangos/mangos-classic/commit/46229bb28c6a4362dc4f4ee88e8bdaf962cb1d58
https://github.com/cmangos/mangos-classic/commit/2e7af8455566d7b289c8fa8b00472a9f21ca1494
https://github.com/cmangos/mangos-classic/commit/9cc773b719ddb2498ff91ae9ae90f9cea71f3528
https://github.com/cmangos/mangos-classic/commit/c1d97517b0673769bad1343a0c9f9b24d24ab738
https://github.com/cmangos/mangos-classic/commit/74b1e01542ea3ea65239d1762662134abae43f13
https://github.com/cmangos/mangos-classic/commit/5442ad1d79efc7e3442fd01fdeda9cc7f60b6b64
https://github.com/cmangos/mangos-classic/commit/bfff02bd0eb383c635bf4375695d096080d5c2e0
https://github.com/cmangos/mangos-classic/commit/8daa3ffb6687d38b0912cd19905d03328de82e61
https://github.com/cmangos/mangos-classic/commit/1ede0a03aa61a9d84a883f113baa2c32d27f1a6b
https://github.com/cmangos/mangos-classic/commit/ac5a8a60b8a54da9c3b1739307c14ca0a053f738
https://github.com/cmangos/mangos-classic/commit/48a84fbfb6c30d81fb1b7467b071a1512112d50a
https://github.com/cmangos/mangos-classic/commit/9d4bc6efa615849aa4f936d90fd3f0b40c0a64d2
https://github.com/cmangos/mangos-classic/commit/3db7b9313c52b415230a29d19ddd256d47019a4a
https://github.com/cmangos/mangos-classic/commit/866ec2d489c06c48750774198c2f1ad893c706b3
https://github.com/cmangos/mangos-classic/commit/256cbefafd46a30cc86ab284e86590a469296a14
https://github.com/cmangos/mangos-classic/commit/4b39ff359de2c5a88387634819e58b476ab05202
https://github.com/cmangos/mangos-classic/commit/c6854d16a597fbba3cc27cd8046e418c5cb33d13
https://github.com/cmangos/mangos-classic/commit/7f15528cfc745f38ac23eb4041bb756bdd44234a
https://github.com/cmangos/mangos-classic/commit/1b15fa34d3469a16c7df78a37505d9b5f2bd097e
https://github.com/cmangos/mangos-classic/commit/64a77261091b408d8dcfbbd7869c173263a23efb
https://github.com/cmangos/mangos-classic/commit/7cb695c95826aa7491416fbc285b827c3ff3ebb9
https://github.com/cmangos/mangos-classic/commit/0587095290ce956e42c2d614a83262ae756cc935
https://github.com/cmangos/mangos-classic/commit/09034fb082cca3d60a2cd25aac01a8032c1163e7
https://github.com/cmangos/mangos-classic/commit/9ae1e8bebf36bf94162379c0b4aac27bc2b99636
https://github.com/cmangos/mangos-classic/commit/be83b98f01d5f71e7464bc41c49f74ef0fde009a
https://github.com/cmangos/mangos-classic/commit/26c0877cec74c30498d553f2f933012d7a5aecb2
https://github.com/cmangos/mangos-classic/commit/1b3c8ee3c2dc90b0b0082bf2df640d48c9bcb96c
https://github.com/cmangos/mangos-classic/commit/6a96d69e839fba35d984835b43af7ca37f4b2688
https://github.com/cmangos/mangos-classic/commit/d9853f1d0e11dcd6ca65f911e38227befdcb691b
https://github.com/cmangos/mangos-classic/commit/5afd6a6fd04eec9b61e1bd604b2ef0d910f0b7c2
https://github.com/cmangos/mangos-classic/commit/c3ea0498239e86a6f310458db86ef77090e01eab
https://github.com/cmangos/mangos-classic/commit/35bc62ac2b7bf3c97e780724cc4d14b14837660c
https://github.com/cmangos/mangos-classic/commit/95fcec8517340f729af08d1397728d0552120f88
https://github.com/cmangos/mangos-classic/commit/a09d1e523b59ba33543a64660555a9e990eacfb9
https://github.com/cmangos/mangos-classic/commit/f6107dfc34fc7c2a2fb27f37678d6fc6f8b96802
https://github.com/cmangos/mangos-classic/commit/af2437976b2e5685f9a5e605d92da4088a402f48
https://github.com/cmangos/mangos-classic/commit/e0c98be3e7ea6e00dd2e23dc0d4cbbb5b308521b
https://github.com/cmangos/mangos-classic/commit/ac70b0ef1aec0425e23deca77d761dcf3e9a9a66
https://github.com/cmangos/mangos-classic/commit/0d3fd0d5b8a0710e56a56703e0d8338e33863078
https://github.com/cmangos/mangos-classic/commit/a9393d27649b15398cebaaba01ef05436c6f5ab5
https://github.com/cmangos/mangos-classic/commit/9b38ef751b83cd091267140153a1c383b7c769c4
https://github.com/cmangos/mangos-classic/commit/3208a5e7a722e6d9bd1ee8fae6fc539b55078a7f
https://github.com/TrinityCore/TrinityCore/commit/7ddbc18aafe61434971013ed6126f5666011ab43
https://github.com/TrinityCore/TrinityCore/commit/c602220e02bed1ad76c9e60064eeec5fd97bfe80
https://github.com/TrinityCore/TrinityCore/commit/5a980226497605b18f1855fa39f340c10ee9dd53
2019-11-15 14:35:02 +02:00

133 lines
2.4 KiB
C++

#define _CRT_SECURE_NO_DEPRECATE
#include "adt.h"
#include <string.h>
// Helper
int holetab_h[4] = {0x1111, 0x2222, 0x4444, 0x8888};
int holetab_v[4] = {0x000F, 0x00F0, 0x0F00, 0xF000};
bool isHole(int holes, int i, int j)
{
int testi = i / 2;
int testj = j / 4;
if (testi > 3) testi = 3;
if (testj > 3) testj = 3;
return (holes & holetab_h[testi] & holetab_v[testj]) != 0;
}
//
// Adt file loader class
//
ADT_file::ADT_file()
{
a_grid = 0;
}
ADT_file::~ADT_file()
{
free();
}
void ADT_file::free()
{
a_grid = 0;
FileLoader::free();
}
//
// Adt file check function
//
bool ADT_file::prepareLoadedData()
{
// Check parent
if (!FileLoader::prepareLoadedData())
return false;
// Check and prepare MHDR
a_grid = (adt_MHDR*)(GetData() + 8 + version->size);
if (!a_grid->prepareLoadedData())
return false;
return true;
}
bool adt_MHDR::prepareLoadedData()
{
if (!strncmp(fcc_txt, "MHDR", 4))
return false;
if (size != sizeof(adt_MHDR) - 8)
return false;
// Check and prepare MCIN
if (offsMCIN && !getMCIN()->prepareLoadedData())
return false;
// Check and prepare MH2O
if (offsMH2O && !getMH2O()->prepareLoadedData())
return false;
return true;
}
bool adt_MCIN::prepareLoadedData()
{
if (!strncmp(fcc_txt, "MCIN", 4))
return false;
// Check cells data
for (int i = 0; i < ADT_CELLS_PER_GRID; i++)
for (int j = 0; j < ADT_CELLS_PER_GRID; j++)
if (cells[i][j].offsMCNK && !getMCNK(i, j)->prepareLoadedData())
return false;
return true;
}
bool adt_MH2O::prepareLoadedData()
{
if (!strncmp(fcc_txt, "MH2O", 4))
return false;
// Check liquid data
// for (int i=0; i<ADT_CELLS_PER_GRID;i++)
// for (int j=0; j<ADT_CELLS_PER_GRID;j++)
return true;
}
bool adt_MCNK::prepareLoadedData()
{
if (!strncmp(fcc_txt, "MCNK", 4))
return false;
// Check height map
if (offsMCVT && !getMCVT()->prepareLoadedData())
return false;
// Check liquid data
if (offsMCLQ && !getMCLQ()->prepareLoadedData())
return false;
return true;
}
bool adt_MCVT::prepareLoadedData()
{
if (!strncmp(fcc_txt, "MCVT", 4))
return false;
if (size != sizeof(adt_MCVT) - 8)
return false;
return true;
}
bool adt_MCLQ::prepareLoadedData()
{
if (!strncmp(fcc_txt, "MCLQ", 4))
return false;
return true;
}