Core/Maps: Added optional *.tilelist file to map_extractor output which contains a list of existing tiles to speed up map creation in worldserver

This commit is contained in:
Shauren
2020-07-06 17:45:53 +02:00
committed by Ovahlord
parent 1ce5cc7a20
commit 0f3590ebb4
3 changed files with 50 additions and 14 deletions

View File

@@ -98,6 +98,29 @@ Map::~Map()
void Map::DiscoverGridMapFiles()
{
std::string tileListName = Trinity::StringFormat("%smaps/%03u.tilelist", sWorld->GetDataPath().c_str(), GetId());
// tile list is optional
if (FILE* tileList = fopen(tileListName.c_str(), "rb"))
{
u_map_magic mapMagic;
u_map_magic versionMagic;
uint32 build;
char tilesData[MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS];
if (fread(&mapMagic.asUInt, sizeof(u_map_magic), 1, tileList) == 1
&& mapMagic.asUInt == MapMagic.asUInt
&& fread(&versionMagic.asUInt, sizeof(u_map_magic), 1, tileList) == 1
&& versionMagic.asUInt == MapVersionMagic.asUInt
&& fread(&build, sizeof(build), 1, tileList) == 1
&& fread(&tilesData[0], MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS, 1, tileList) == 1)
{
i_gridFileExists = std::bitset<MAX_NUMBER_OF_GRIDS* MAX_NUMBER_OF_GRIDS>(tilesData, Trinity::Containers::Size(tilesData));
fclose(tileList);
return;
}
fclose(tileList);
}
for (uint32 gx = 0; gx < MAX_NUMBER_OF_GRIDS; ++gx)
for (uint32 gy = 0; gy < MAX_NUMBER_OF_GRIDS; ++gy)
i_gridFileExists[gx * MAX_NUMBER_OF_GRIDS + gy] = ExistMap(GetId(), gx, gy, false);