aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tools/map_extractor/System.cpp25
-rw-r--r--src/tools/map_extractor/adt.h26
2 files changed, 35 insertions, 16 deletions
diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp
index 5769175fa8a..e3ec5741b8d 100644
--- a/src/tools/map_extractor/System.cpp
+++ b/src/tools/map_extractor/System.cpp
@@ -679,14 +679,16 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
if (!h)
continue;
+ adt_liquid_attributes attrs = h2o->GetLiquidAttributes(i, j);
+
int32 count = 0;
uint64 existsMask = h2o->GetLiquidExistsBitmap(h);
- for (int32 y = 0; y < h->Height; y++)
+ for (int32 y = 0; y < h->GetHeight(); y++)
{
- int32 cy = i * ADT_CELL_SIZE + y + h->OffsetY;
- for (int32 x = 0; x < h->Width; x++)
+ int32 cy = i * ADT_CELL_SIZE + y + h->GetOffsetY();
+ for (int32 x = 0; x < h->GetWidth(); x++)
{
- int32 cx = j * ADT_CELL_SIZE + x + h->OffsetX;
+ int32 cx = j * ADT_CELL_SIZE + x + h->GetOffsetX();
if (existsMask & 1)
{
liquid_show[cy][cx] = true;
@@ -700,7 +702,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
switch (LiquidTypes.at(h->LiquidType).SoundBank)
{
case LIQUID_TYPE_WATER: liquid_flags[i][j] |= MAP_LIQUID_TYPE_WATER; break;
- case LIQUID_TYPE_OCEAN: liquid_flags[i][j] |= MAP_LIQUID_TYPE_OCEAN; break;
+ case LIQUID_TYPE_OCEAN: liquid_flags[i][j] |= MAP_LIQUID_TYPE_OCEAN; if (attrs.Deep) liquid_flags[i][j] |= MAP_LIQUID_TYPE_DARK_WATER; break;
case LIQUID_TYPE_MAGMA: liquid_flags[i][j] |= MAP_LIQUID_TYPE_MAGMA; break;
case LIQUID_TYPE_SLIME: liquid_flags[i][j] |= MAP_LIQUID_TYPE_SLIME; break;
default:
@@ -712,18 +714,13 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
printf("Wrong liquid detect in MH2O chunk");
int32 pos = 0;
- for (int32 y = 0; y <= h->Height; y++)
+ for (int32 y = 0; y <= h->GetHeight(); y++)
{
- int cy = i * ADT_CELL_SIZE + y + h->OffsetY;
- for (int32 x = 0; x <= h->Width; x++)
+ int cy = i * ADT_CELL_SIZE + y + h->GetOffsetY();
+ for (int32 x = 0; x <= h->GetWidth(); x++)
{
- int32 cx = j * ADT_CELL_SIZE + x + h->OffsetX;
+ int32 cx = j * ADT_CELL_SIZE + x + h->GetOffsetX();
liquid_height[cy][cx] = h2o->GetLiquidHeight(h, pos);
-
- // Dark water detect
- if (liquid_flags[i][j] & MAP_LIQUID_TYPE_OCEAN && h2o->GetLiquidDepth(h, pos) == -1)
- liquid_flags[i][j] |= MAP_LIQUID_TYPE_DARK_WATER;
-
pos++;
}
}
diff --git a/src/tools/map_extractor/adt.h b/src/tools/map_extractor/adt.h
index 9f1144de572..fc8fa1c39a8 100644
--- a/src/tools/map_extractor/adt.h
+++ b/src/tools/map_extractor/adt.h
@@ -193,6 +193,17 @@ struct adt_liquid_instance
uint8 Height;
uint32 OffsetExistsBitmap;
uint32 OffsetVertexData;
+
+ uint8 GetOffsetX() const { return OffsetX; }
+ uint8 GetOffsetY() const { return OffsetY; }
+ uint8 GetWidth() const { return Width; }
+ uint8 GetHeight() const { return Height; }
+};
+
+struct adt_liquid_attributes
+{
+ uint64 Fishable;
+ uint64 Deep;
};
//
@@ -222,6 +233,17 @@ public:
return nullptr;
}
+ adt_liquid_attributes GetLiquidAttributes(int32 x, int32 y) const
+ {
+ if (liquid[x][y].used)
+ {
+ if (liquid[x][y].OffsetAttributes)
+ return *((adt_liquid_attributes *)((uint8*)this + 8 + liquid[x][y].OffsetAttributes));
+ return { 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF };
+ }
+ return { 0, 0 };
+ }
+
float GetLiquidHeight(adt_liquid_instance const* h, int32 pos) const
{
if (!h->OffsetVertexData)
@@ -249,7 +271,7 @@ public:
switch (h->LiquidVertexFormat)
{
case LiquidVertexFormatType::HeightDepth:
- return ((int8 const*)((int8 const*)this + 8 + h->OffsetVertexData + (h->Width + 1) * (h->Height + 1) * 4))[pos];
+ return ((int8 const*)((int8 const*)this + 8 + h->OffsetVertexData + (h->GetWidth() + 1) * (h->GetHeight() + 1) * 4))[pos];
case LiquidVertexFormatType::HeightTextureCoord:
return 0;
case LiquidVertexFormatType::Depth:
@@ -271,7 +293,7 @@ public:
case LiquidVertexFormatType::Depth:
return nullptr;
case LiquidVertexFormatType::HeightTextureCoord:
- return (uint16 const*)((uint8 const*)this + 8 + h->OffsetVertexData + 4 * ((h->Width + 1) * (h->Height + 1) + pos));
+ return (uint16 const*)((uint8 const*)this + 8 + h->OffsetVertexData + 4 * ((h->GetWidth() + 1) * (h->GetHeight() + 1) + pos));
default:
break;
}