mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 17:54:48 +01:00
Tools/Mapextractor: Fixed determining deep water
(cherry picked from commit 2e648f9eb9)
This commit is contained in:
@@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user