Core/Maps: Changed the way area data is stored in maps, it now uses ID field from AreaTable.dbc instead AreaBit used for exploration marker (and is not unique anymore on top of simply being stupidly confusing)
Note: Extracting maps is required (cherry picked from commit db0b8bf24e2b8eb87e6aed7b031ebe138717403d)
This commit is contained in:
1 parent
8bc477a2de
commit
bb6089bb8c
6 files changed
+32
-63
No files matched your search
@@ -2640,6 +2640,9 @@ bool AchievementMgr<T>::RequirementsSatisfied(AchievementCriteriaEntry const* ac
|
||||
if (!area)
|
||||
break;
|
||||
|
||||
if (area->exploreFlag < 0)
|
||||
continue;
|
||||
|
||||
uint32 playerIndexOffset = uint32(area->exploreFlag) / 32;
|
||||
if (playerIndexOffset >= PLAYER_EXPLORED_ZONES_SIZE)
|
||||
continue;
|
||||
|
||||
@@ -845,7 +845,7 @@ void LoadDBCStores(const std::string& dataPath)
|
||||
}
|
||||
|
||||
// Check loaded DBC files proper version
|
||||
if (!sAreaTableStore.LookupEntry(5995) || // last area (areaflag) added in 4.3.4 (15595)
|
||||
if (!sAreaTableStore.LookupEntry(5995) || // last area added in 4.3.4 (15595)
|
||||
!sCharTitlesStore.LookupEntry(287) || // last char title added in 4.3.4 (15595)
|
||||
!sGemPropertiesStore.LookupEntry(2250) || // last gem property added in 4.3.4 (15595)
|
||||
!sMapStore.LookupEntry(980) || // last map added in 4.3.4 (15595)
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "VMapFactory.h"
|
||||
|
||||
u_map_magic MapMagic = { {'M','A','P','S'} };
|
||||
u_map_magic MapVersionMagic = { {'v','1','.','3'} };
|
||||
u_map_magic MapVersionMagic = { {'v','1','.','6'} };
|
||||
u_map_magic MapAreaMagic = { {'A','R','E','A'} };
|
||||
u_map_magic MapHeightMagic = { {'M','H','G','T'} };
|
||||
u_map_magic MapLiquidMagic = { {'M','L','I','Q'} };
|
||||
|
||||
@@ -1075,6 +1075,13 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (area->exploreFlag < 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 offset = area->exploreFlag / 32;
|
||||
if (offset >= PLAYER_EXPLORED_ZONES_SIZE)
|
||||
{
|
||||
@@ -1112,6 +1119,13 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (area->exploreFlag < 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 offset = area->exploreFlag / 32;
|
||||
if (offset >= PLAYER_EXPLORED_ZONES_SIZE)
|
||||
{
|
||||
|
||||
@@ -65,11 +65,9 @@ typedef struct
|
||||
} map_id;
|
||||
|
||||
map_id *map_ids;
|
||||
uint16 *areas;
|
||||
uint16 *LiqType;
|
||||
char output_path[128] = ".";
|
||||
char input_path[128] = ".";
|
||||
uint32 maxAreaId = 0;
|
||||
|
||||
// **************************************************
|
||||
// Extractor options
|
||||
@@ -310,34 +308,6 @@ uint32 ReadMapDBC()
|
||||
return map_count;
|
||||
}
|
||||
|
||||
void ReadAreaTableDBC()
|
||||
{
|
||||
printf("Read AreaTable.dbc file...");
|
||||
HANDLE dbcFile;
|
||||
if (!SFileOpenFileEx(LocaleMpq, "DBFilesClient\\AreaTable.dbc", SFILE_OPEN_PATCHED_FILE, &dbcFile))
|
||||
{
|
||||
printf("Fatal error: Cannot find AreaTable.dbc in archive!\n");
|
||||
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];
|
||||
|
||||
for (uint32 x = 0; x < area_count; ++x)
|
||||
areas[dbc.getRecord(x).getUInt(0)] = dbc.getRecord(x).getUInt(3);
|
||||
|
||||
SFileCloseFile(dbcFile);
|
||||
printf("Done! (%u areas loaded)\n", uint32(area_count));
|
||||
}
|
||||
|
||||
void ReadLiquidTypeTableDBC()
|
||||
{
|
||||
printf("Read LiquidType.dbc file...");
|
||||
@@ -373,7 +343,7 @@ void ReadLiquidTypeTableDBC()
|
||||
|
||||
// Map file format data
|
||||
static char const* MAP_MAGIC = "MAPS";
|
||||
static char const* MAP_VERSION_MAGIC = "v1.3";
|
||||
static char const* MAP_VERSION_MAGIC = "v1.6";
|
||||
static char const* MAP_AREA_MAGIC = "AREA";
|
||||
static char const* MAP_HEIGHT_MAGIC = "MHGT";
|
||||
static char const* MAP_LIQUID_MAGIC = "MLIQ";
|
||||
@@ -449,7 +419,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];
|
||||
@@ -482,36 +452,20 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
|
||||
|
||||
// Get area flags data
|
||||
for (int i = 0; i < ADT_CELLS_PER_GRID; ++i)
|
||||
{
|
||||
for (int j = 0; j < ADT_CELLS_PER_GRID; ++j)
|
||||
{
|
||||
adt_MCNK* cell = adt.cells[i][j];
|
||||
uint32 areaid = cell->areaid;
|
||||
if (areaid && areaid <= maxAreaId)
|
||||
{
|
||||
if (areas[areaid] != 0xFFFF)
|
||||
{
|
||||
area_flags[i][j] = areas[areaid];
|
||||
continue;
|
||||
}
|
||||
area_ids[i][j] = adt.cells[i][j]->areaid;
|
||||
|
||||
printf("File: %s\nCan't find area flag for areaid %u [%d, %d].\n", filename, areaid, cell->ix, cell->iy);
|
||||
}
|
||||
|
||||
area_flags[i][j] = 0xffff;
|
||||
}
|
||||
}
|
||||
|
||||
//============================================
|
||||
// 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;
|
||||
@@ -528,12 +482,12 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
|
||||
if (fullAreaData)
|
||||
{
|
||||
areaHeader.gridArea = 0;
|
||||
map.areaMapSize+=sizeof(area_flags);
|
||||
map.areaMapSize += sizeof(area_ids);
|
||||
}
|
||||
else
|
||||
{
|
||||
areaHeader.flags |= MAP_AREA_NO_AREA;
|
||||
areaHeader.gridArea = (uint16)areaflag;
|
||||
areaHeader.gridArea = static_cast<uint16>(areaId);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -963,8 +917,8 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
|
||||
fwrite(&map, sizeof(map), 1, output);
|
||||
// Store area data
|
||||
fwrite(&areaHeader, sizeof(areaHeader), 1, output);
|
||||
if (!(areaHeader.flags&MAP_AREA_NO_AREA))
|
||||
fwrite(area_flags, sizeof(area_flags), 1, output);
|
||||
if (!(areaHeader.flags & MAP_AREA_NO_AREA))
|
||||
fwrite(area_flags, sizeof(area_ids), 1, output);
|
||||
|
||||
// Store height data
|
||||
fwrite(&heightHeader, sizeof(heightHeader), 1, output);
|
||||
@@ -1023,7 +977,6 @@ void ExtractMapsFromMpq(uint32 build)
|
||||
|
||||
uint32 map_count = ReadMapDBC();
|
||||
|
||||
ReadAreaTableDBC();
|
||||
ReadLiquidTypeTableDBC();
|
||||
|
||||
std::string path = output_path;
|
||||
@@ -1058,8 +1011,7 @@ void ExtractMapsFromMpq(uint32 build)
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
delete [] areas;
|
||||
delete [] map_ids;
|
||||
delete[] map_ids;
|
||||
}
|
||||
|
||||
bool ExtractFile(HANDLE fileInArchive, char const* filename)
|
||||
|
||||
@@ -80,7 +80,7 @@ struct map_liquidHeader
|
||||
namespace MMAP
|
||||
{
|
||||
|
||||
char const* MAP_VERSION_MAGIC = "v1.3";
|
||||
char const* MAP_VERSION_MAGIC = "v1.6";
|
||||
|
||||
TerrainBuilder::TerrainBuilder(bool skipLiquid) : m_skipLiquid (skipLiquid){ }
|
||||
TerrainBuilder::~TerrainBuilder() { }
|
||||
|
||||
Reference in new issue
Block a user