18414 Map&DBC Handle

Now need to use 18414 maps and dbc(only18414)
This commit is contained in:
dio85 2020-02-20 22:27:22 +00:00 committed by Antz
parent c47d66977c
commit b5b7d6e858
7 changed files with 47 additions and 37 deletions

View file

@ -4212,7 +4212,7 @@ enum TrackedAuraType
// others will not and opposite
// will only support WoW:MOP 5.4.8 client build 18414...
#define EXPECTED_MANGOSD_CLIENT_BUILD {18273, 18414, 0}
#define EXPECTED_MANGOSD_CLIENT_BUILD {18414, 0}
// max supported expansion level in mangosd
// NOTE: not set it more that supported by targeted client version with all expansions installed

View file

@ -686,9 +686,9 @@ GridMapLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 Re
bool GridMap::ExistMap(uint32 mapid, int gx, int gy)
{
int len = sWorld.GetDataPath().length() + strlen("maps/%03u%02u%02u.map") + 1;
int len = sWorld.GetDataPath().length() + strlen("maps/%04u%02u%02u.map") + 1;
char* tmp = new char[len];
snprintf(tmp, len, (char*)(sWorld.GetDataPath() + "maps/%03u%02u%02u.map").c_str(), mapid, gx, gy);
snprintf(tmp, len, (char*)(sWorld.GetDataPath() + "maps/%04u%02u%02u.map").c_str(), mapid, gx, gy);
FILE* pf = fopen(tmp, "rb");

View file

@ -100,7 +100,7 @@ namespace VMAP
{
std::stringstream tilefilename;
tilefilename.fill('0');
tilefilename << std::setw(3) << mapID << "_";
tilefilename << std::setw(4) << mapID << "_";
// tilefilename << std::setw(2) << tileX << "_" << std::setw(2) << tileY << ".vmtile";
tilefilename << std::setw(2) << tileY << "_" << std::setw(2) << tileX << ".vmtile";
return tilefilename.str();

View file

@ -63,6 +63,7 @@ namespace VMAP
//=================================================================
TileAssembler::TileAssembler(const std::string& pSrcDirName, const std::string& pDestDirName)
:iDestDir(pDestDirName), iSrcDir(pSrcDirName), iFilterMethod(NULL), iCurrentUniqueNameId(0)
{
iCurrentUniqueNameId = 0;
iFilterMethod = NULL;
@ -112,9 +113,17 @@ namespace VMAP
spawnedModelFiles.insert(entry->second.name);
}
printf("Creating map tree...\n");
printf("Creating map tree for map %u...\n", map_iter->first);
BIH pTree;
pTree.build(mapSpawns, BoundsTrait<ModelSpawn*>::getBounds);
try
{
pTree.build(mapSpawns, BoundsTrait<ModelSpawn*>::getBounds);
}
catch (std::exception& e)
{
printf("Exception ""%s"" when calling pTree.build", e.what());
return false;
}
// ===> possibly move this code to StaticMapTree class
std::map<uint32, uint32> modelNodeIdx;
@ -125,7 +134,7 @@ namespace VMAP
// write map tree file
std::stringstream mapfilename;
mapfilename << iDestDir << "/" << std::setfill('0') << std::setw(3) << map_iter->first << ".vmtree";
mapfilename << iDestDir << "/" << std::setfill('0') << std::setw(4) << map_iter->first << ".vmtree";
FILE* mapfile = fopen(mapfilename.str().c_str(), "wb");
if (!mapfile)
{
@ -183,7 +192,7 @@ namespace VMAP
uint32 nSpawns = tileEntries.count(tile->first);
std::stringstream tilefilename;
tilefilename.fill('0');
tilefilename << iDestDir << "/" << std::setw(3) << map_iter->first << "_";
tilefilename << iDestDir << "/" << std::setw(4) << map_iter->first << "_";
uint32 x, y;
StaticMapTree::unpackTileID(tile->first, x, y);
tilefilename << std::setw(2) << x << "_" << std::setw(2) << y << ".vmtile";
@ -294,6 +303,8 @@ namespace VMAP
bool TileAssembler::calculateTransformedBound(ModelSpawn& spawn)
{
std::string modelFilename = iSrcDir + "/" + spawn.name;
modelFilename.push_back('/');
modelFilename.append(spawn.name);
ModelPosition modelPosition;
modelPosition.iDir = spawn.iRot;
modelPosition.iScale = spawn.iScale;
@ -409,31 +420,21 @@ namespace VMAP
uint32 name_length, displayId;
char buff[500];
while (!feof(model_list))
while (true)
{
if (fread(&displayId, sizeof(uint32), 1, model_list) <= 0)
if (fread(&displayId, sizeof(uint32), 1, model_list) != 1)
if (feof(model_list)) // EOF flag is only set after failed reading attempt
break;
if (fread(&name_length, sizeof(uint32), 1, model_list) != 1
|| name_length >= sizeof(buff)
|| fread(&buff, sizeof(char), name_length, model_list) != name_length)
{
if (!feof(model_list))
std::cout << "\nFile '" << GAMEOBJECT_MODELS << "' seems to be corrupted" << std::endl;
break;
}
if (fread(&name_length, sizeof(uint32), 1, model_list) <= 0)
{
std::cout << "\nFile '" << GAMEOBJECT_MODELS << "' seems to be corrupted" << std::endl;
std::cout << "\nFile 'temp_gameobject_models' seems to be corrupted" << std::endl;
break;
}
if (name_length >= sizeof(buff))
{
std::cout << "\nFile '" << GAMEOBJECT_MODELS << "' seems to be corrupted" << std::endl;
break;
}
if (fread(&buff, sizeof(char), name_length, model_list) <= 0)
{
std::cout << "\nFile '" << GAMEOBJECT_MODELS << "' seems to be corrupted" << std::endl;
break;
}
fread(&buff, sizeof(char), name_length, model_list);
std::string model_name(buff, name_length);
WorldModel_Raw raw_model;
@ -476,10 +477,12 @@ namespace VMAP
}
// temporary use defines to simplify read/check code (close file and return at fail)
#define READ_OR_RETURN(V,S) if(fread((V), (S), 1, rf) != 1) { \
fclose(rf); printf("readfail, op = %i\n", readOperation); return(false); }
#define CMP_OR_RETURN(V,S) if(strcmp((V),(S)) != 0) { \
fclose(rf); printf("cmpfail, %s!=%s\n", V, S);return(false); }
#define READ_OR_RETURN(V, S) if (fread((V), (S), 1, rf) != 1) { \
fclose(rf); printf("readfail, op = %i\n", readOperation); return(false); }
#define READ_OR_RETURN_WITH_DELETE(V, S) if (fread((V), (S), 1, rf) != 1) { \
fclose(rf); printf("readfail, op = %i\n", readOperation); delete[] V; return(false); };
#define CMP_OR_RETURN(V, S) if (strcmp((V), (S)) != 0) { \
fclose(rf); printf("cmpfail, %s!=%s\n", V, S);return(false); }
bool GroupModel_Raw::Read(FILE* rf)
{
@ -520,6 +523,7 @@ namespace VMAP
if (nindexes > 0)
{
uint16* indexarray = new uint16[nindexes];
READ_OR_RETURN_WITH_DELETE(indexarray, nindexes*sizeof(uint16));
if (fread(indexarray, nindexes * sizeof(uint16), 1, rf) != 1)
{
fclose(rf);
@ -545,6 +549,12 @@ namespace VMAP
if (nvectors > 0)
{
float* vectorarray = new float[nvectors * 3];
READ_OR_RETURN_WITH_DELETE(vectorarray, nvectors*sizeof(float) * 3);
for (uint32 i = 0; i < nvectors; ++i)
{
vertexArray.push_back( Vector3(vectorarray + 3 * i) );
}
delete[] vectorarray;
if (fread(vectorarray, nvectors * sizeof(float) * 3, 1, rf) != 1)
{
fclose(rf);

View file

@ -31,8 +31,8 @@
namespace VMAP
{
const char VMAP_MAGIC[] = "VMAP_4.0"; /**< used in final vmap files */
const char RAW_VMAP_MAGIC[] = "VMAPp06"; // used in extracted vmap files with raw data
const char VMAP_MAGIC[] = "VMAP_4.3"; // used in final vmap files
const char RAW_VMAP_MAGIC[] = "VMAP043"; // used in extracted vmap files with raw data
const char GAMEOBJECT_MODELS[] = "temp_gameobject_models"; /**< TODO */
/**

View file

@ -73,7 +73,7 @@ namespace VMAP
std::string VMapManager2::getMapFileName(unsigned int pMapId)
{
std::stringstream fname;
fname.width(3);
fname.width(4);
fname << std::setfill('0') << pMapId << std::string(MAP_FILENAME_EXTENSION2);
return fname.str();
}

View file

@ -1,4 +1,4 @@
/**
/**
* MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
*
@ -103,7 +103,7 @@ float CONF_float_to_int16_limit = 2048.0f; // Max accuracy = val/65536
float CONF_flat_height_delta_limit = 0.005f; // If max - min less this value - surface is flat
float CONF_flat_liquid_delta_limit = 0.001f; // If max - min less this value - liquid surface is flat
#define MIN_SUPPORTED_BUILD 17520 // code expect mpq files and mpq content files structure for this build or later
#define MIN_SUPPORTED_BUILD 18414 // code expect mpq files and mpq content files structure for this build or later
#define EXPANSION_COUNT 4
#define WORLD_COUNT 1