|
47 | 47 | #include "OutdoorPvP/OutdoorPvP.h" |
48 | 48 | #include "World/WorldState.h" |
49 | 49 |
|
| 50 | +#include "MotionGenerators/MoveMap.h" |
| 51 | + |
50 | 52 | #include "Entities/ItemEnchantmentMgr.h" |
51 | 53 | #include "Loot/LootMgr.h" |
52 | 54 |
|
@@ -6476,6 +6478,69 @@ void ObjectMgr::LoadAreatriggerLocales() |
6476 | 6478 | sLog.outString(); |
6477 | 6479 | } |
6478 | 6480 |
|
| 6481 | +void ObjectMgr::GenerateZoneAndAreaIds() |
| 6482 | +{ |
| 6483 | + WorldDatabase.DirectExecute("TRUNCATE creature_zone"); |
| 6484 | + WorldDatabase.DirectExecute("TRUNCATE gameobject_zone"); |
| 6485 | + |
| 6486 | + std::string baseCreature = "INSERT INTO creature_zone(Guid, ZoneId, AreaId) VALUES"; |
| 6487 | + int i = 0; |
| 6488 | + int total = 0; |
| 6489 | + std::string query = ""; |
| 6490 | + for (auto& data : mCreatureDataMap) |
| 6491 | + { |
| 6492 | + CreatureData const& creature = data.second; |
| 6493 | + uint32 zoneId, areaId; |
| 6494 | + TerrainInfo* info = sTerrainMgr.LoadTerrain(creature.mapid); |
| 6495 | + MMAP::MMapFactory::createOrGetMMapManager()->loadMapInstance(sWorld.GetDataPath(), creature.mapid, 0); |
| 6496 | + CellPair p = MaNGOS::ComputeCellPair(creature.posX, creature.posY); |
| 6497 | + Cell cell(p); |
| 6498 | + GridPair gp(cell.GridX(), cell.GridY()); |
| 6499 | + int gx = (MAX_NUMBER_OF_GRIDS - 1) - gp.x_coord; |
| 6500 | + int gy = (MAX_NUMBER_OF_GRIDS - 1) - gp.y_coord; |
| 6501 | + info->LoadMapAndVMap(gx, gy); |
| 6502 | + info->GetZoneAndAreaId(zoneId, areaId, creature.posX, creature.posY, creature.posZ); |
| 6503 | + |
| 6504 | + query += "(" + std::to_string(data.first) + "," + std::to_string(zoneId) + "," + std::to_string(areaId) + "),"; |
| 6505 | + ++i; ++total; |
| 6506 | + if (i >= 100) |
| 6507 | + { |
| 6508 | + std::string finalQuery = baseCreature + query; |
| 6509 | + finalQuery[finalQuery.length() - 1] = ';'; |
| 6510 | + WorldDatabase.DirectExecute(finalQuery.c_str()); |
| 6511 | + query = ""; |
| 6512 | + i = 0; |
| 6513 | + } |
| 6514 | + } |
| 6515 | + |
| 6516 | + std::string baseGo = "INSERT INTO gameobject_zone(Guid, ZoneId, AreaId) VALUES"; |
| 6517 | + for (auto& data : mGameObjectDataMap) |
| 6518 | + { |
| 6519 | + GameObjectData const& go = data.second; |
| 6520 | + uint32 zoneId, areaId; |
| 6521 | + TerrainInfo* info = sTerrainMgr.LoadTerrain(go.mapid); |
| 6522 | + MMAP::MMapFactory::createOrGetMMapManager()->loadMapInstance(sWorld.GetDataPath(), go.mapid, 0); |
| 6523 | + CellPair p = MaNGOS::ComputeCellPair(go.posX, go.posY); |
| 6524 | + Cell cell(p); |
| 6525 | + GridPair gp(cell.GridX(), cell.GridY()); |
| 6526 | + int gx = (MAX_NUMBER_OF_GRIDS - 1) - gp.x_coord; |
| 6527 | + int gy = (MAX_NUMBER_OF_GRIDS - 1) - gp.y_coord; |
| 6528 | + info->LoadMapAndVMap(gx, gy); |
| 6529 | + info->GetZoneAndAreaId(zoneId, areaId, go.posX, go.posY, go.posZ + 1); |
| 6530 | + |
| 6531 | + query += "(" + std::to_string(data.first) + "," + std::to_string(zoneId) + "," + std::to_string(areaId) + "),"; |
| 6532 | + ++i; ++total; |
| 6533 | + if (i >= 100) |
| 6534 | + { |
| 6535 | + std::string finalQuery = baseGo + query; |
| 6536 | + finalQuery[finalQuery.length() - 1] = ';'; |
| 6537 | + WorldDatabase.DirectExecute(finalQuery.c_str()); |
| 6538 | + query = ""; |
| 6539 | + i = 0; |
| 6540 | + } |
| 6541 | + } |
| 6542 | +} |
| 6543 | + |
6479 | 6544 | // not very fast function but it is called only once a day, or on starting-up |
6480 | 6545 | /// @param serverUp true if the server is already running, false when the server is started |
6481 | 6546 | void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) |
|
0 commit comments