479 memset(
V9, 0,
sizeof(
V9));
480 memset(
V8, 0,
sizeof(
V8));
488 bool hasHoles =
false;
489 bool hasFlightBox =
false;
491 for (std::multimap<std::string, FileChunk*>::const_iterator itr = adt.
chunks.lower_bound(
"MCNK"); itr != adt.
chunks.upper_bound(
"MCNK"); ++itr)
528 int cy = mcnk->
iy * ADT_CELL_SIZE +
y;
531 int cx = mcnk->
ix * ADT_CELL_SIZE +
x;
543 int cy = mcnk->
iy * ADT_CELL_SIZE +
y;
546 int cx = mcnk->
ix * ADT_CELL_SIZE +
x;
547 V9[cy][cx] += mcvt->
height_map[y*(ADT_CELL_SIZE * 2 + 1) + x];
553 int cy = mcnk->
iy * ADT_CELL_SIZE +
y;
556 int cx = mcnk->
ix * ADT_CELL_SIZE +
x;
557 V8[cy][cx] += mcvt->
height_map[y*(ADT_CELL_SIZE * 2 + 1) + ADT_CELL_SIZE + 1 + x];
571 int cy = mcnk->
iy * ADT_CELL_SIZE +
y;
574 int cx = mcnk->
ix * ADT_CELL_SIZE +
x;
575 if (liquid->
flags[y][x] != 0x0F)
578 if (liquid->
flags[y][x] & (1 << 7))
586 if (c_flag & (1 << 2))
591 if (c_flag & (1 << 3))
596 if (c_flag & (1 << 4))
603 fprintf(stderr,
"Wrong liquid detect in MCLQ chunk");
607 int cy = mcnk->
iy * ADT_CELL_SIZE +
y;
610 int cx = mcnk->
ix * ADT_CELL_SIZE +
x;
618 if (!(mcnk->
flags & 0x10000))
646 for (
int y = 0; y < h->
height; y++)
648 int cy = i * ADT_CELL_SIZE + y + h->
yOffset;
649 for (
int x = 0; x < h->
width; x++)
651 int cx = j * ADT_CELL_SIZE + x + h->
xOffset;
669 printf(
"\nCan't find Liquid type %u for map %s\nchunk %d,%d\n", h->
liquidType, inputPath.c_str(), i, j);
681 printf(
"Wrong liquid detect in MH2O chunk");
685 for (
int y = 0; y <= h->
height; y++)
687 int cy = i * ADT_CELL_SIZE + y + h->
yOffset;
688 for (
int x = 0; x <= h->
width; x++)
690 int cx = j * ADT_CELL_SIZE + x + h->
xOffset;
715 bool fullAreaData =
false;
716 uint32 areaId = area_ids[0][0];
721 if (area_ids[y][x] != areaId)
734 areaHeader.
flags = 0;
749 float maxHeight = -20000;
750 float minHeight = 20000;
756 if (maxHeight < h) maxHeight = h;
757 if (minHeight > h) minHeight = h;
765 if (maxHeight < h) maxHeight = h;
766 if (minHeight > h) minHeight = h;
792 heightHeader.
flags = 0;
796 if (maxHeight == minHeight)
816 float diff = maxHeight - minHeight;
858 bool fullType =
false;
875 if (type == 0 && !fullType)
883 int minX = 255, minY = 255;
884 int maxX = 0, maxY = 0;
893 if (minX > x) minX =
x;
894 if (maxX < x) maxX =
x;
895 if (minY > y) minY =
y;
896 if (maxY < y) maxY =
y;
898 if (maxHeight < h) maxHeight = h;
899 if (minHeight > h) minHeight = h;
908 liquidHeader.
flags = 0;
912 liquidHeader.
width = maxX - minX + 1 + 1;
913 liquidHeader.
height = maxY - minY + 1 + 1;
916 if (maxHeight == minHeight)
946 std::ofstream outFile(outputPath, std::ofstream::out | std::ofstream::binary);
949 printf(
"Can't create the output file '%s'\n", outputPath.c_str());
953 outFile.write(reinterpret_cast<const char*>(&map),
sizeof(map));
955 outFile.write(reinterpret_cast<const char*>(&areaHeader),
sizeof(areaHeader));
957 outFile.write(reinterpret_cast<const char*>(area_ids),
sizeof(area_ids));
960 outFile.write(reinterpret_cast<const char*>(&heightHeader),
sizeof(heightHeader));
975 outFile.write(reinterpret_cast<const char*>(
V9),
sizeof(
V9));
976 outFile.write(reinterpret_cast<const char*>(
V8),
sizeof(
V8));
989 outFile.write(reinterpret_cast<const char*>(&liquidHeader),
sizeof(liquidHeader));
998 for (
int y = 0; y < liquidHeader.
height; y++)
1005 outFile.write(reinterpret_cast<const char*>(
holes), map.
holesSize);
float ypos
Definition: adt.h:130
plane max
Definition: adt.h:234
#define ADT_GRID_SIZE
Definition: adt.h:41
union adt_MCNK::@346 union_5_3_0
FileChunk * GetChunk(std::string const &name)
Definition: loadlib.cpp:140
std::multimap< std::string, FileChunk * > chunks
Definition: loadlib.h:96
FMT_API int fprintf(std::FILE *f, CStringRef format, ArgList args)
uint32 ix
Definition: adt.h:96
uint8 HighResHoles[8]
Definition: adt.h:107
uint32 holes
Definition: adt.h:117
uint16_t uint16
Definition: g3dmath.h:166
adt_liquid_header * getLiquidData(int x, int y)
Definition: adt.h:170
struct adt_MCLQ::liquid_data liquid[ADT_CELL_SIZE+1][ADT_CELL_SIZE+1]
uint64 getLiquidShowMap(adt_liquid_header *h)
Definition: adt.h:212
uint32 areaid
Definition: adt.h:115
uint32 flags
Definition: adt.h:95
float height_map[(ADT_CELL_SIZE+1)*(ADT_CELL_SIZE+1)+ADT_CELL_SIZE *ADT_CELL_SIZE]
Definition: adt.h:55
#define ADT_CELLS_PER_GRID
Definition: adt.h:39
uint8 flags[ADT_CELL_SIZE][ADT_CELL_SIZE]
Definition: adt.h:81
float height
Definition: adt.h:72
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
G3D::int16 y
Definition: Vector2int16.h:38
uint16_t uint16
Definition: Define.h:151
#define ADT_CELL_SIZE
Definition: adt.h:40
uint8_t uint8
Definition: g3dmath.h:164
uint32 sizeMCLQ
Definition: adt.h:127
uint8_t uint8
Definition: Define.h:152
uint8 * getLiquidLightMap(adt_liquid_header *h)
Definition: adt.h:186
#define const
Definition: zconf.h:217
G3D::int16 x
Definition: Vector2int16.h:37
plane min
Definition: adt.h:235
uint32 iy
Definition: adt.h:97
bool loadFile(HANDLE mpq, std::string const &fileName, bool log=true)
Definition: loadlib.cpp:36
void printf(BasicWriter< Char > &w, BasicCStringRef< Char > format, ArgList args)
Definition: format.h:3083
float * getLiquidHeightMap(adt_liquid_header *h)
Definition: adt.h:177