From 30e6bcad3c18d649335f3c10c786d52edf890598 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Sun, 1 Apr 2018 00:44:49 +0200 Subject: [PATCH] Tools/Mapextractor: Removed fatigue from Vashj'ir --- src/tools/map_extractor/System.cpp | 51 +++++++++----- src/tools/map_extractor/adt.h | 108 +++++++++++++++++------------ 2 files changed, 99 insertions(+), 60 deletions(-) diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp index e318a71e4e..c8afdf0a4b 100644 --- a/src/tools/map_extractor/System.cpp +++ b/src/tools/map_extractor/System.cpp @@ -103,7 +103,7 @@ int CONF_extract = EXTRACT_MAP | EXTRACT_DBC | EXTRACT_CAMERA; // This option allow limit minimum height to some value (Allow save some memory) bool CONF_allow_height_limit = true; -float CONF_use_minHeight = -500.0f; +float CONF_use_minHeight = -2000.0f; // This option allow use float to int conversion bool CONF_allow_float_to_int = true; @@ -525,7 +525,7 @@ LiquidVertexFormatType adt_MH2O::GetLiquidVertexFormat(adt_liquid_instance const return static_cast(-1); } -bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/, uint32 build) +bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/, uint32 build, bool ignoreDeepWater) { ADT_file adt; @@ -778,7 +778,7 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/, if (liquid->flags[y][x] != 0x0F) { liquid_show[cy][cx] = true; - if (liquid->flags[y][x] & (1<<7)) + if (!ignoreDeepWater && liquid->flags[y][x] & (1<<7)) liquid_flags[i][j] |= MAP_LIQUID_TYPE_DARK_WATER; ++count; } @@ -829,14 +829,16 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/, 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; @@ -850,7 +852,7 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/, 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 (!ignoreDeepWater && 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: @@ -862,19 +864,15 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/, 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++) { - 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(); 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++; } } @@ -1052,6 +1050,24 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/, return true; } +bool IsDeepWaterIgnored(uint32 mapId, uint32 x, uint32 y) +{ + if (mapId != 0) + return false; + + // GRID(39, 24) || GRID(39, 25) || GRID(39, 26) || + // GRID(40, 24) || GRID(40, 25) || GRID(40, 26) || + //GRID(41, 18) || GRID(41, 19) || GRID(41, 20) || GRID(41, 21) || GRID(41, 22) || GRID(41, 23) || GRID(41, 24) || GRID(41, 25) || GRID(41, 26) || + //GRID(42, 18) || GRID(42, 19) || GRID(42, 20) || GRID(42, 21) || GRID(42, 22) || GRID(42, 23) || GRID(42, 24) || GRID(42, 25) || GRID(42, 26) || + //GRID(43, 18) || GRID(43, 19) || GRID(43, 20) || GRID(43, 21) || GRID(43, 22) || GRID(43, 23) || GRID(43, 24) || GRID(43, 25) || GRID(43, 26) || + //GRID(44, 18) || GRID(44, 19) || GRID(44, 20) || GRID(44, 21) || GRID(44, 22) || GRID(44, 23) || GRID(44, 24) || GRID(44, 25) || GRID(44, 26) || + //GRID(45, 18) || GRID(45, 19) || GRID(45, 20) || GRID(45, 21) || GRID(45, 22) || GRID(45, 23) || GRID(45, 24) || GRID(45, 25) || GRID(45, 26) || + //GRID(46, 18) || GRID(46, 19) || GRID(46, 20) || GRID(46, 21) || GRID(46, 22) || GRID(46, 23) || GRID(46, 24) || GRID(46, 25) || GRID(46, 26) + + // Vashj'ir grids completely ignore fatigue + return (x >= 39 && x <= 40 && y >= 24 && y <= 26) || (x >= 41 && x <= 46 && y >= 18 && y <= 26); +} + void ExtractMapsFromMpq(uint32 build) { char mpq_filename[1024]; @@ -1089,7 +1105,8 @@ void ExtractMapsFromMpq(uint32 build) sprintf(mpq_filename, "World\\Maps\\%s\\%s_%u_%u.adt", map_ids[z].name, map_ids[z].name, x, y); sprintf(output_filename, "%s/maps/%03u%02u%02u.map", output_path, map_ids[z].id, y, x); - ConvertADT(mpq_filename, output_filename, y, x, build); + bool ignoreDeepWater = IsDeepWaterIgnored(map_ids[z].id, y, x); + ConvertADT(mpq_filename, output_filename, y, x, build, ignoreDeepWater); } // draw progress bar diff --git a/src/tools/map_extractor/adt.h b/src/tools/map_extractor/adt.h index d2d6cc7544..d71ee143dd 100644 --- a/src/tools/map_extractor/adt.h +++ b/src/tools/map_extractor/adt.h @@ -47,13 +47,13 @@ enum LiquidType // class adt_MCVT { - union{ + union { uint32 fcc; char fcc_txt[4]; }; uint32 size; public: - float height_map[(ADT_CELL_SIZE+1)*(ADT_CELL_SIZE+1)+ADT_CELL_SIZE*ADT_CELL_SIZE]; + float height_map[(ADT_CELL_SIZE + 1)*(ADT_CELL_SIZE + 1) + ADT_CELL_SIZE * ADT_CELL_SIZE]; bool prepareLoadedData(); }; @@ -63,7 +63,7 @@ public: // class adt_MCLQ { - union{ + union { uint32 fcc; char fcc_txt[4]; }; @@ -71,10 +71,10 @@ public: uint32 size; float height1; float height2; - struct liquid_data{ + struct liquid_data { uint32 light; float height; - } liquid[ADT_CELL_SIZE+1][ADT_CELL_SIZE+1]; + } liquid[ADT_CELL_SIZE + 1][ADT_CELL_SIZE + 1]; // 1<<0 - ochen // 1<<1 - lava/slime @@ -92,7 +92,7 @@ public: // class adt_MCNK { - union{ + union { uint32 fcc; char fcc_txt[4]; }; @@ -151,13 +151,13 @@ public: // class adt_MCIN { - union{ + union { uint32 fcc; char fcc_txt[4]; }; public: uint32 size; - struct adt_CELLS{ + struct adt_CELLS { uint32 offsMCNK; uint32 size; uint32 flags; @@ -179,12 +179,12 @@ public: enum class LiquidVertexFormatType : uint16 { - HeightDepth = 0, - HeightTextureCoord = 1, - Depth = 2, + HeightDepth = 0, + HeightTextureCoord = 1, + Depth = 2, HeightDepthTextureCoord = 3, - Unk4 = 4, - Unk5 = 5 + Unk4 = 4, + Unk5 = 5 }; struct adt_liquid_instance @@ -199,6 +199,17 @@ struct adt_liquid_instance uint8 Height; uint32 OffsetExistsBitmap; uint32 OffsetVertexData; + + uint8 GetOffsetX() const { return LiquidVertexFormat < 42 ? OffsetX : 0; } + uint8 GetOffsetY() const { return LiquidVertexFormat < 42 ? OffsetY : 0; } + uint8 GetWidth() const { return LiquidVertexFormat < 42 ? Width : 8; } + uint8 GetHeight() const { return LiquidVertexFormat < 42 ? Height : 8; } +}; + +struct adt_liquid_attributes +{ + uint64 Fishable; + uint64 Deep; }; // @@ -207,13 +218,13 @@ struct adt_liquid_instance class adt_MH2O { public: - union{ + union { uint32 fcc; char fcc_txt[4]; }; uint32 size; - struct adt_LIQUID{ + struct adt_LIQUID { uint32 OffsetInstances; uint32 used; uint32 OffsetAttributes; @@ -228,6 +239,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) @@ -237,17 +259,17 @@ public: switch (GetLiquidVertexFormat(h)) { - case LiquidVertexFormatType::HeightDepth: - case LiquidVertexFormatType::HeightTextureCoord: - case LiquidVertexFormatType::HeightDepthTextureCoord: - return ((float const*)((uint8*)this + 8 + h->OffsetVertexData))[pos]; - case LiquidVertexFormatType::Depth: - return 0.0f; - case LiquidVertexFormatType::Unk4: - case LiquidVertexFormatType::Unk5: - return ((float const*)((uint8*)this + 8 + h->OffsetVertexData + 4))[pos * 2]; - default: - break; + case LiquidVertexFormatType::HeightDepth: + case LiquidVertexFormatType::HeightTextureCoord: + case LiquidVertexFormatType::HeightDepthTextureCoord: + return ((float const*)((uint8*)this + 8 + h->OffsetVertexData))[pos]; + case LiquidVertexFormatType::Depth: + return 0.0f; + case LiquidVertexFormatType::Unk4: + case LiquidVertexFormatType::Unk5: + return ((float const*)((uint8*)this + 8 + h->OffsetVertexData + 4))[pos * 2]; + default: + break; } return 0.0f; @@ -261,13 +283,13 @@ public: switch (GetLiquidVertexFormat(h)) { 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: return ((int8 const*)((uint8*)this + 8 + h->OffsetVertexData))[pos]; case LiquidVertexFormatType::HeightDepthTextureCoord: - return ((int8 const*)((int8 const*)this + 8 + h->OffsetVertexData + (h->Width + 1) * (h->Height + 1) * 8))[pos]; + return ((int8 const*)((int8 const*)this + 8 + h->OffsetVertexData + (h->GetWidth() + 1) * (h->GetHeight() + 1) * 8))[pos]; case LiquidVertexFormatType::Unk4: return ((int8 const*)((uint8*)this + 8 + h->OffsetVertexData))[pos * 8]; case LiquidVertexFormatType::Unk5: @@ -285,17 +307,17 @@ public: switch (GetLiquidVertexFormat(h)) { - case LiquidVertexFormatType::HeightDepth: - case LiquidVertexFormatType::Depth: - case LiquidVertexFormatType::Unk4: - return nullptr; - case LiquidVertexFormatType::HeightTextureCoord: - case LiquidVertexFormatType::HeightDepthTextureCoord: - return (uint16 const*)((uint8 const*)this + 8 + h->OffsetVertexData + 4 * ((h->Width + 1) * (h->Height + 1) + pos)); - case LiquidVertexFormatType::Unk5: - return (uint16 const*)((uint8 const*)this + 8 + h->OffsetVertexData + 8 * ((h->Width + 1) * (h->Height + 1) + pos)); - default: - break; + case LiquidVertexFormatType::HeightDepth: + case LiquidVertexFormatType::Depth: + case LiquidVertexFormatType::Unk4: + return nullptr; + case LiquidVertexFormatType::HeightTextureCoord: + case LiquidVertexFormatType::HeightDepthTextureCoord: + return (uint16 const*)((uint8 const*)this + 8 + h->OffsetVertexData + 4 * ((h->GetWidth() + 1) * (h->GetHeight() + 1) + pos)); + case LiquidVertexFormatType::Unk5: + return (uint16 const*)((uint8 const*)this + 8 + h->OffsetVertexData + 8 * ((h->GetWidth() + 1) * (h->GetHeight() + 1) + pos)); + default: + break; } return nullptr; } @@ -319,7 +341,7 @@ class adt_MHDR { friend class ADT_file; - union{ + union { uint32 fcc; char fcc_txt[4]; }; @@ -343,11 +365,11 @@ public: uint32 data4; uint32 data5; bool prepareLoadedData(); - adt_MCIN* getMCIN() { return offsMCIN ? (adt_MCIN *)((uint8 *)&flags+offsMCIN) : nullptr; } - adt_MH2O* getMH2O() { return offsMH2O ? (adt_MH2O *)((uint8 *)&flags+offsMH2O) : nullptr; } + adt_MCIN* getMCIN() { return offsMCIN ? (adt_MCIN *)((uint8 *)&flags + offsMCIN) : nullptr; } + adt_MH2O* getMH2O() { return offsMH2O ? (adt_MH2O *)((uint8 *)&flags + offsMH2O) : nullptr; } }; -class ADT_file : public FileLoader{ +class ADT_file : public FileLoader { public: bool prepareLoadedData(); ADT_file();