mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-26 20:02:25 +01:00
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 db0b8bf24e)
# Conflicts:
# src/server/game/Achievements/AchievementMgr.cpp
# src/server/game/Chat/Chat.cpp
# src/server/game/Conditions/ConditionMgr.cpp
# src/server/game/DataStores/DBCStores.cpp
# src/server/game/DataStores/DBCStores.h
# src/server/game/DataStores/DBCfmt.h
# src/server/game/Entities/Player/Player.cpp
# src/server/game/Globals/ObjectMgr.cpp
# src/server/game/Handlers/BattleGroundHandler.cpp
# src/server/game/Handlers/MiscHandler.cpp
# src/server/game/Maps/Map.cpp
# src/server/game/Spells/Spell.cpp
# src/server/game/Spells/SpellEffects.cpp
# src/server/scripts/Commands/cs_go.cpp
# src/server/scripts/Commands/cs_group.cpp
# src/server/scripts/Commands/cs_lookup.cpp
# src/server/scripts/Commands/cs_misc.cpp
# src/tools/map_extractor/System.cpp
# src/tools/mmaps_generator/TerrainBuilder.cpp
This commit is contained in:
@@ -42,12 +42,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
|
||||
@@ -231,30 +229,6 @@ uint32 ReadMapDBC()
|
||||
return map_count;
|
||||
}
|
||||
|
||||
void ReadAreaTableDBC()
|
||||
{
|
||||
printf("Read AreaTable.dbc file...");
|
||||
DBCFile dbc("DBFilesClient\\AreaTable.dbc");
|
||||
|
||||
if(!dbc.open())
|
||||
{
|
||||
printf("Fatal error: Invalid AreaTable.dbc file format!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
size_t area_count = dbc.getRecordCount();
|
||||
size_t maxid = dbc.getMaxId();
|
||||
areas = new uint16[maxid + 1];
|
||||
memset(areas, 0xff, (maxid + 1) * sizeof(uint16));
|
||||
|
||||
for(uint32 x = 0; x < area_count; ++x)
|
||||
areas[dbc.getRecord(x).getUInt(0)] = dbc.getRecord(x).getUInt(3);
|
||||
|
||||
maxAreaId = dbc.getMaxId();
|
||||
|
||||
printf("Done! (" SZFMTD " areas loaded)\n", area_count);
|
||||
}
|
||||
|
||||
void ReadLiquidTypeTableDBC()
|
||||
{
|
||||
printf("Read LiquidType.dbc file...");
|
||||
@@ -282,7 +256,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";
|
||||
@@ -358,7 +332,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];
|
||||
@@ -397,34 +371,20 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
map.buildMagic = build;
|
||||
|
||||
// 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 = cells->getMCNK(i,j);
|
||||
uint32 areaid = cell->areaid;
|
||||
if(areaid && areaid <= maxAreaId)
|
||||
{
|
||||
if(areas[areaid] != 0xffff)
|
||||
{
|
||||
area_flags[i][j] = areas[areaid];
|
||||
continue;
|
||||
}
|
||||
printf("File: %s\nCan't find area flag for areaid %u [%d, %d].\n", inputPath.c_str(), areaid, cell->ix, cell->iy);
|
||||
}
|
||||
area_flags[i][j] = 0xffff;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < ADT_CELLS_PER_GRID; i++)
|
||||
for (int j = 0; j < ADT_CELLS_PER_GRID; j++)
|
||||
area_ids[i][j] = cells->getMCNK(i, j)->areaid;
|
||||
|
||||
//============================================
|
||||
// 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;
|
||||
@@ -441,12 +401,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);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -875,8 +835,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));
|
||||
@@ -935,7 +895,6 @@ void ExtractMapsFromMpq(uint32 build)
|
||||
|
||||
uint32 map_count = ReadMapDBC();
|
||||
|
||||
ReadAreaTableDBC();
|
||||
ReadLiquidTypeTableDBC();
|
||||
|
||||
std::string path = output_path;
|
||||
@@ -972,8 +931,7 @@ void ExtractMapsFromMpq(uint32 build)
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
delete [] areas;
|
||||
delete [] map_ids;
|
||||
delete[] map_ids;
|
||||
}
|
||||
|
||||
bool ExtractFile( char const* mpq_name, std::string const& filename )
|
||||
|
||||
Reference in New Issue
Block a user