aboutsummaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorLopfest <lopfest@gmail.com>2016-02-20 23:59:56 +0100
committerLopfest <lopfest@gmail.com>2016-02-20 23:59:56 +0100
commitfacdc62b433787326673a4db05aab76d75e1283f (patch)
treef76f4e3467e3fe909da8b4e5bc5962712642e493 /src/tools
parentd11eb335c996b398f4f8bdb10558dfba9af637f4 (diff)
parent716c952cb9f7bc0f75308bb4a716cdfe7de17281 (diff)
Merge remote-tracking branch 'upstream/6.x' into HEAD
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/map_extractor/System.cpp93
-rw-r--r--src/tools/map_extractor/adt.h16
-rw-r--r--src/tools/map_extractor/loadlib.cpp3
-rw-r--r--src/tools/mmaps_generator/TerrainBuilder.cpp2
4 files changed, 61 insertions, 53 deletions
diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp
index 8de3f95f68a..22a8cc72c3c 100644
--- a/src/tools/map_extractor/System.cpp
+++ b/src/tools/map_extractor/System.cpp
@@ -75,12 +75,10 @@ typedef struct
} map_id;
map_id *map_ids;
-uint16 *areas;
uint16 *LiqType;
#define MAX_PATH_LENGTH 128
char output_path[MAX_PATH_LENGTH];
char input_path[MAX_PATH_LENGTH];
-uint32 maxAreaId = 0;
// **************************************************
// Extractor options
@@ -318,35 +316,6 @@ uint32 ReadMapDBC()
return map_count;
}
-void ReadAreaTableDBC()
-{
- printf("Read AreaTable.dbc file...");
- HANDLE dbcFile;
- if (!CascOpenFile(CascStorage, "DBFilesClient\\AreaTable.dbc", CASC_LOCALE_NONE, 0, &dbcFile))
- {
- printf("Fatal error: Cannot find AreaTable.dbc in archive! %s\n", HumanReadableCASCError(GetLastError()));
- exit(1);
- }
-
- DBCFile dbc(dbcFile);
- if(!dbc.open())
- {
- printf("Fatal error: Invalid AreaTable.dbc file format!\n");
- exit(1);
- }
-
- size_t area_count = dbc.getRecordCount();
- maxAreaId = dbc.getMaxId();
- areas = new uint16[maxAreaId + 1];
- memset(areas, 0xFF, sizeof(uint16) * (maxAreaId + 1));
-
- for (uint32 x = 0; x < area_count; ++x)
- areas[dbc.getRecord(x).getUInt(0)] = dbc.getRecord(x).getUInt(3);
-
- CascCloseFile(dbcFile);
- printf("Done! (" SZFMTD " areas loaded)\n", area_count);
-}
-
void ReadLiquidTypeTableDBC()
{
printf("Read LiquidType.dbc file...");
@@ -382,7 +351,7 @@ void ReadLiquidTypeTableDBC()
// Map file format data
static char const* MAP_MAGIC = "MAPS";
-static char const* MAP_VERSION_MAGIC = "v1.5";
+static char const* MAP_VERSION_MAGIC = "v1.8";
static char const* MAP_AREA_MAGIC = "AREA";
static char const* MAP_HEIGHT_MAGIC = "MHGT";
static char const* MAP_LIQUID_MAGIC = "MLIQ";
@@ -411,9 +380,10 @@ struct map_areaHeader
uint16 gridArea;
};
-#define MAP_HEIGHT_NO_HEIGHT 0x0001
-#define MAP_HEIGHT_AS_INT16 0x0002
-#define MAP_HEIGHT_AS_INT8 0x0004
+#define MAP_HEIGHT_NO_HEIGHT 0x0001
+#define MAP_HEIGHT_AS_INT16 0x0002
+#define MAP_HEIGHT_AS_INT8 0x0004
+#define MAP_HEIGHT_HAS_FLIGHT_BOUNDS 0x0008
struct map_heightHeader
{
@@ -458,7 +428,7 @@ float selectUInt16StepStore(float maxDiff)
return 65535 / maxDiff;
}
// Temporary grid data store
-uint16 area_flags[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
+uint16 area_ids[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
float V8[ADT_GRID_SIZE][ADT_GRID_SIZE];
float V9[ADT_GRID_SIZE+1][ADT_GRID_SIZE+1];
@@ -473,14 +443,17 @@ bool liquid_show[ADT_GRID_SIZE][ADT_GRID_SIZE];
float liquid_height[ADT_GRID_SIZE+1][ADT_GRID_SIZE+1];
uint8 holes[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID][8];
-bool TransformToHighRes(uint16 holes, uint8 hiResHoles[8])
+int16 flight_box_max[3][3];
+int16 flight_box_min[3][3];
+
+bool TransformToHighRes(uint16 lowResHoles, uint8 hiResHoles[8])
{
for (uint8 i = 0; i < 8; i++)
{
for (uint8 j = 0; j < 8; j++)
{
int32 holeIdxL = (i / 2) * 4 + (j / 2);
- if (((holes >> holeIdxL) & 1) == 1)
+ if (((lowResHoles >> holeIdxL) & 1) == 1)
hiResHoles[i] |= (1 << j);
}
}
@@ -502,7 +475,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
map.buildMagic = build;
// Get area flags data
- memset(area_flags, 0xFF, sizeof(area_flags));
+ memset(area_ids, 0, sizeof(area_ids));
memset(V9, 0, sizeof(V9));
memset(V8, 0, sizeof(V8));
@@ -513,14 +486,14 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
memset(holes, 0, sizeof(holes));
bool hasHoles = false;
+ bool hasFlightBox = false;
for (std::multimap<std::string, FileChunk*>::const_iterator itr = adt.chunks.lower_bound("MCNK"); itr != adt.chunks.upper_bound("MCNK"); ++itr)
{
adt_MCNK* mcnk = itr->second->As<adt_MCNK>();
// Area data
- if (mcnk->areaid <= maxAreaId && areas[mcnk->areaid] != 0xFFFF)
- area_flags[mcnk->iy][mcnk->ix] = areas[mcnk->areaid];
+ area_ids[mcnk->iy][mcnk->ix] = mcnk->areaid;
// Height
// Height values for triangles stored in order:
@@ -728,16 +701,24 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
}
}
+ if (FileChunk* chunk = adt.GetChunk("MFBO"))
+ {
+ adt_MFBO* mfbo = chunk->As<adt_MFBO>();
+ memcpy(flight_box_max, &mfbo->max, sizeof(flight_box_max));
+ memcpy(flight_box_min, &mfbo->min, sizeof(flight_box_min));
+ hasFlightBox = true;
+ }
+
//============================================
// Try pack area data
//============================================
bool fullAreaData = false;
- uint32 areaflag = area_flags[0][0];
- for (int y=0;y<ADT_CELLS_PER_GRID;y++)
+ uint32 areaId = area_ids[0][0];
+ for (int y = 0; y < ADT_CELLS_PER_GRID; ++y)
{
- for(int x=0;x<ADT_CELLS_PER_GRID;x++)
+ for (int x = 0; x < ADT_CELLS_PER_GRID; ++x)
{
- if(area_flags[y][x]!=areaflag)
+ if (area_ids[y][x] != areaId)
{
fullAreaData = true;
break;
@@ -754,12 +735,12 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
if (fullAreaData)
{
areaHeader.gridArea = 0;
- map.areaMapSize+=sizeof(area_flags);
+ map.areaMapSize += sizeof(area_ids);
}
else
{
areaHeader.flags |= MAP_AREA_NO_AREA;
- areaHeader.gridArea = static_cast<uint16>(areaflag);
+ areaHeader.gridArea = static_cast<uint16>(areaId);
}
//============================================
@@ -819,6 +800,12 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
if (CONF_allow_float_to_int && (maxHeight - minHeight) < CONF_flat_height_delta_limit)
heightHeader.flags |= MAP_HEIGHT_NO_HEIGHT;
+ if (hasFlightBox)
+ {
+ heightHeader.flags |= MAP_HEIGHT_HAS_FLIGHT_BOUNDS;
+ map.heightMapSize += sizeof(flight_box_max) + sizeof(flight_box_min);
+ }
+
// Try store as packed in uint16 or uint8 values
if (!(heightHeader.flags & MAP_HEIGHT_NO_HEIGHT))
{
@@ -966,8 +953,8 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
outFile.write(reinterpret_cast<const char*>(&map), sizeof(map));
// Store area data
outFile.write(reinterpret_cast<const char*>(&areaHeader), sizeof(areaHeader));
- if (!(areaHeader.flags&MAP_AREA_NO_AREA))
- outFile.write(reinterpret_cast<const char*>(area_flags), sizeof(area_flags));
+ if (!(areaHeader.flags & MAP_AREA_NO_AREA))
+ outFile.write(reinterpret_cast<const char*>(area_ids), sizeof(area_ids));
// Store height data
outFile.write(reinterpret_cast<const char*>(&heightHeader), sizeof(heightHeader));
@@ -990,6 +977,12 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
}
}
+ if (heightHeader.flags & MAP_HEIGHT_HAS_FLIGHT_BOUNDS)
+ {
+ outFile.write(reinterpret_cast<char*>(flight_box_max), sizeof(flight_box_max));
+ outFile.write(reinterpret_cast<char*>(flight_box_min), sizeof(flight_box_min));
+ }
+
// Store liquid data if need
if (map.liquidMapOffset)
{
@@ -1042,7 +1035,6 @@ void ExtractMaps(uint32 build)
uint32 map_count = ReadMapDBC();
- ReadAreaTableDBC();
ReadLiquidTypeTableDBC();
std::string path = output_path;
@@ -1098,7 +1090,6 @@ void ExtractMaps(uint32 build)
}
printf("\n");
- delete[] areas;
delete[] map_ids;
}
diff --git a/src/tools/map_extractor/adt.h b/src/tools/map_extractor/adt.h
index 0c3b3780c16..bb6980507b7 100644
--- a/src/tools/map_extractor/adt.h
+++ b/src/tools/map_extractor/adt.h
@@ -219,6 +219,22 @@ struct adt_MH2O
};
+struct adt_MFBO
+{
+ union
+ {
+ uint32 fcc;
+ char fcc_txt[4];
+ };
+ uint32 size;
+ struct plane
+ {
+ int16 coords[9];
+ };
+ plane max;
+ plane min;
+};
+
#pragma pack(pop)
#endif
diff --git a/src/tools/map_extractor/loadlib.cpp b/src/tools/map_extractor/loadlib.cpp
index 39bbe5b1412..067683577f4 100644
--- a/src/tools/map_extractor/loadlib.cpp
+++ b/src/tools/map_extractor/loadlib.cpp
@@ -96,7 +96,8 @@ u_map_fcc InterestingChunks[] =
{ { 'K', 'N', 'C', 'M' } },
{ { 'T', 'V', 'C', 'M' } },
{ { 'O', 'M', 'W', 'M' } },
- { { 'Q', 'L', 'C', 'M' } }
+ { { 'Q', 'L', 'C', 'M' } },
+ { { 'O', 'B', 'F', 'M' } }
};
bool IsInterestingChunk(u_map_fcc const& fcc)
diff --git a/src/tools/mmaps_generator/TerrainBuilder.cpp b/src/tools/mmaps_generator/TerrainBuilder.cpp
index 209c047a5fe..5dd6bed30b0 100644
--- a/src/tools/mmaps_generator/TerrainBuilder.cpp
+++ b/src/tools/mmaps_generator/TerrainBuilder.cpp
@@ -80,7 +80,7 @@ struct map_liquidHeader
namespace MMAP
{
- char const* MAP_VERSION_MAGIC = "v1.5";
+ char const* MAP_VERSION_MAGIC = "v1.8";
TerrainBuilder::TerrainBuilder(bool skipLiquid) : m_skipLiquid (skipLiquid){ }
TerrainBuilder::~TerrainBuilder() { }