From b5b7d6e858e9356d0a91510284c00d4583ff9aa8 Mon Sep 17 00:00:00 2001 From: dio85 Date: Thu, 20 Feb 2020 22:27:22 +0000 Subject: [PATCH] 18414 Map&DBC Handle Now need to use 18414 maps and dbc(only18414) --- src/game/Server/SharedDefines.h | 2 +- src/game/WorldHandlers/GridMap.cpp | 4 +- src/game/vmap/MapTree.cpp | 2 +- src/game/vmap/TileAssembler.cpp | 66 +++++++++++-------- src/game/vmap/VMapDefinitions.h | 4 +- src/game/vmap/VMapManager2.cpp | 2 +- .../map-extractor/System.cpp | 4 +- 7 files changed, 47 insertions(+), 37 deletions(-) diff --git a/src/game/Server/SharedDefines.h b/src/game/Server/SharedDefines.h index ddd58dab9..cfa1dd12f 100644 --- a/src/game/Server/SharedDefines.h +++ b/src/game/Server/SharedDefines.h @@ -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 diff --git a/src/game/WorldHandlers/GridMap.cpp b/src/game/WorldHandlers/GridMap.cpp index a64584f9e..6c20b40db 100644 --- a/src/game/WorldHandlers/GridMap.cpp +++ b/src/game/WorldHandlers/GridMap.cpp @@ -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"); diff --git a/src/game/vmap/MapTree.cpp b/src/game/vmap/MapTree.cpp index 4e1e21b3b..bf6b171af 100644 --- a/src/game/vmap/MapTree.cpp +++ b/src/game/vmap/MapTree.cpp @@ -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(); diff --git a/src/game/vmap/TileAssembler.cpp b/src/game/vmap/TileAssembler.cpp index 6600f596c..616acda6b 100644 --- a/src/game/vmap/TileAssembler.cpp +++ b/src/game/vmap/TileAssembler.cpp @@ -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::getBounds); + try + { + pTree.build(mapSpawns, BoundsTrait::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 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); diff --git a/src/game/vmap/VMapDefinitions.h b/src/game/vmap/VMapDefinitions.h index 35526b078..1701b99e9 100644 --- a/src/game/vmap/VMapDefinitions.h +++ b/src/game/vmap/VMapDefinitions.h @@ -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 */ /** diff --git a/src/game/vmap/VMapManager2.cpp b/src/game/vmap/VMapManager2.cpp index 3a029a7f9..743d53ab3 100644 --- a/src/game/vmap/VMapManager2.cpp +++ b/src/game/vmap/VMapManager2.cpp @@ -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(); } diff --git a/src/tools/Extractor_projects/map-extractor/System.cpp b/src/tools/Extractor_projects/map-extractor/System.cpp index c9dc5d110..cc143a778 100644 --- a/src/tools/Extractor_projects/map-extractor/System.cpp +++ b/src/tools/Extractor_projects/map-extractor/System.cpp @@ -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