52#include <boost/heap/fibonacci_heap.hpp>
53#include <unordered_set>
65#define DEFAULT_GRID_EXPIRY 300
66#define MAX_GRID_LOAD_TIME 50
67#define MAX_CREATURE_ATTACK_RADIUS (45.0f * sWorld->getRate(RATE_CREATURE_AGGRO))
77struct RespawnListContainer : boost::heap::fibonacci_heap<RespawnInfoWithHandle*, boost::heap::compare<CompareRespawnInfo>>
85 RespawnListContainer::handle_type
handle;
114 FILE* pf = fopen(fileName.c_str(),
"rb");
118 TC_LOG_ERROR(
"maps",
"Map file '{}' does not exist!", fileName);
119 TC_LOG_ERROR(
"maps",
"Please place MAP-files (*.map) in the appropriate directory ({}), or correct the DataDir setting in your worldserver.conf file.", (
sWorld->GetDataPath()+
"maps/"));
124 if (fread(&header,
sizeof(header), 1, pf) == 1)
127 TC_LOG_ERROR(
"maps",
"Map file '{}' is from an incompatible map version (%.*s v{}), %.*s v{} is expected. Please pull your source, recompile tools and recreate maps using the updated mapextractor, then replace your old map files with new files. If you still have problems search on forum for error TCE00018.",
142 if (vmgr->isMapLoadingEnabled())
145 std::string name = vmgr->getDirFileName(mapid, gx, gy);
151 TC_LOG_ERROR(
"maps",
"VMap file '{}' does not exist", (
sWorld->GetDataPath() +
"vmaps/" + name));
152 TC_LOG_ERROR(
"maps",
"Please place VMAP files (*.vmtree and *.vmtile) in the vmap directory ({}), or correct the DataDir setting in your worldserver.conf file.", (
sWorld->GetDataPath() +
"vmaps/"));
155 TC_LOG_ERROR(
"maps",
"VMap file '{}' couldn't be loaded", (
sWorld->GetDataPath() +
"vmaps/" + name));
156 TC_LOG_ERROR(
"maps",
"This is because the version of the VMap file and the version of this module are different, please re-extract the maps with the tools compiled with this module.");
173 TC_LOG_DEBUG(
"mmaps.tiles",
"MMAP loaded name:{}, id:{}, x:{}, y:{} (mmap rep.: x:{}, y:{})",
GetMapName(),
GetId(), gx, gy, gx, gy);
175 TC_LOG_WARN(
"mmaps.tiles",
"Could not load MMAP name:{}, id:{}, x:{}, y:{} (mmap rep.: x:{}, y:{})",
GetMapName(),
GetId(), gx, gy, gx, gy);
184 switch (vmapLoadResult)
187 TC_LOG_DEBUG(
"maps",
"VMAP loaded name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})",
GetMapName(),
GetId(), gx, gy, gx, gy);
190 TC_LOG_ERROR(
"maps",
"Could not load VMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})",
GetMapName(),
GetId(), gx, gy, gx, gy);
193 TC_LOG_DEBUG(
"maps",
"Ignored VMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})",
GetMapName(),
GetId(), gx, gy, gx, gy);
220 TC_LOG_DEBUG(
"maps",
"Unloading previously loaded map {} before reloading.",
GetId());
232 if (!
GridMaps[gx][gy]->loadData(fileName.c_str()))
233 TC_LOG_ERROR(
"maps",
"Error loading map file: \n {}\n", fileName);
273_creatureToMoveLock(false), _gameObjectsToMoveLock(false), _dynamicObjectsToMoveLock(false),
274i_mapEntry(
sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode), i_InstanceId(InstanceId),
277m_activeNonPlayersIter(m_activeNonPlayers.end()), _transportsUpdateIter(_transports.end()),
314 if (obj->IsStoredInWorldObjectGridContainer())
487 std::lock_guard<std::mutex> lock(
_gridLock);
592 Cell cell(cellCoord);
633 if (obj->IsInWorld())
636 obj->UpdateObjectVisibility(
true);
647 TC_LOG_ERROR(
"maps",
"Map::Add: Object {} has invalid coordinates X:{} Y:{} grid cell [{}:{}]", obj->GetGUID().ToString(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.
x_coord, cellCoord.
y_coord);
651 Cell cell(cellCoord);
652 if (obj->isActiveObject())
657 TC_LOG_DEBUG(
"maps",
"Object {} enters grid[{}, {}]", obj->GetGUID().ToString(), cell.
GridX(), cell.
GridY());
665 if (obj->isActiveObject())
670 obj->SetIsNewObject(
true);
671 obj->UpdateObjectVisibilityOnCreate();
672 obj->SetIsNewObject(
false);
698 if (itr->GetSource()->GetTransport() != obj)
704 itr->GetSource()->SendDirectMessage(&packet);
741 Visit(cell, gridVisitor);
742 Visit(cell, worldVisitor);
750 if (oldZone == newZone)
756 ASSERT(oldZoneCount,
"A player left zone %u (went to %u) - but there were no players in the zone!", oldZone, newZone);
774 session->
Update(t_diff, updater);
817 std::vector<Unit*> toVisit;
821 toVisit.push_back(unit);
822 for (
Unit* unit : toVisit)
827 std::unordered_set<Unit*> toVisit;
828 for (std::pair<uint32, AuraApplication*> pair : player->
GetAppliedAuras())
830 if (
Unit* caster = pair.second->GetBase()->GetCaster())
832 toVisit.insert(caster);
834 for (
Unit* unit : toVisit)
839 std::vector<Unit*> toVisit;
843 if (!summonGuid.IsEmpty())
846 toVisit.push_back(unit);
848 for (
Unit* unit : toVisit)
891 zoneInfo.second.DefaultWeather.reset();
918 iter->GetSource()->ResetAllNotifies();
958 Visit(cell, grid_object_relocation);
959 Visit(cell, world_object_relocation);
995 Visit(cell, grid_notifier);
996 Visit(cell, world_notifier);
1010 bool const inWorld = player->
IsInWorld();
1030 obj->RemoveFromWorld();
1032 if (obj->isActiveObject())
1036 obj->DestroyForNearbyPlayers();
1038 obj->RemoveFromGrid();
1059 if (itr->GetSource()->GetTransport() != obj)
1060 itr->GetSource()->SendDirectMessage(&packet);
1065 TransportsContainer::iterator itr =
_transports.find(obj);
1086 Cell new_cell(x, y);
1088 player->
Relocate(x, y, z, orientation);
1094 TC_LOG_DEBUG(
"maps",
"Player {} relocation grid[{}, {}]cell[{}, {}]->grid[{}, {}]cell[{}, {}]", player->
GetName(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1113 Cell new_cell(x, y);
1121 #ifdef TRINITY_DEBUG
1122 TC_LOG_DEBUG(
"maps",
"Creature {} added to moving list from grid[{}, {}]cell[{}, {}] to grid[{}, {}]cell[{}, {}].", creature->
GetGUID().
ToString(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1145 ASSERT(integrity_check == old_cell);
1146 Cell new_cell(x, y);
1155 TC_LOG_DEBUG(
"maps",
"GameObject {} added to moving list from grid[{}, {}]cell[{}, {}] to grid[{}, {}]cell[{}, {}].", go->
GetGUID().
ToString(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1162 go->
Relocate(x, y, z, orientation);
1171 ASSERT(integrity_check == old_cell);
1179 ASSERT(integrity_check == old_cell);
1180 Cell new_cell(x, y);
1189 TC_LOG_DEBUG(
"maps",
"GameObject {} added to moving list from grid[{}, {}]cell[{}, {}] to grid[{}, {}]cell[{}, {}].", dynObj->
GetGUID().
ToString(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1196 dynObj->
Relocate(x, y, z, orientation);
1204 ASSERT(integrity_check == old_cell);
1373 if (dynObj->
FindMap() !=
this)
1415 TC_LOG_DEBUG(
"maps",
"Creature {} moved in grid[{}, {}] from cell[{}, {}] to cell[{}, {}].", c->
GetGUID().
ToString(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
CellX(), new_cell.
CellY());
1437 TC_LOG_DEBUG(
"maps",
"Active creature {} moved from grid[{}, {}]cell[{}, {}] to grid[{}, {}]cell[{}, {}].", c->
GetGUID().
ToString(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1452 #ifdef TRINITY_DEBUG
1453 TC_LOG_DEBUG(
"maps",
"Creature {} moved from grid[{}, {}]cell[{}, {}] to grid[{}, {}]cell[{}, {}].", c->
GetGUID().
ToString(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1464 #ifdef TRINITY_DEBUG
1465 TC_LOG_DEBUG(
"maps",
"Creature {} attempted to move from grid[{}, {}]cell[{}, {}] to unloaded grid[{}, {}]cell[{}, {}].", c->
GetGUID().
ToString(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1479 TC_LOG_DEBUG(
"maps",
"GameObject {} moved in grid[{}, {}] from cell[{}, {}] to cell[{}, {}].", go->
GetGUID().
ToString(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
CellX(), new_cell.
CellY());
1501 TC_LOG_DEBUG(
"maps",
"Active GameObject {} moved from grid[{}, {}]cell[{}, {}] to grid[{}, {}]cell[{}, {}].", go->
GetGUID().
ToString(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1514 TC_LOG_DEBUG(
"maps",
"GameObject {} moved from grid[{}, {}]cell[{}, {}] to grid[{}, {}]cell[{}, {}].", go->
GetGUID().
ToString(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1526 TC_LOG_DEBUG(
"maps",
"GameObject {} attempted to move from grid[{}, {}]cell[{}, {}] to unloaded grid[{}, {}]cell[{}, {}].", go->
GetGUID().
ToString(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1540 TC_LOG_DEBUG(
"maps",
"DynamicObject {} moved in grid[{}, {}] from cell[{}, {}] to cell[{}, {}].", go->
GetGUID().
ToString(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
CellX(), new_cell.
CellY());
1562 TC_LOG_DEBUG(
"maps",
"Active DynamicObject {} moved from grid[{}, {}]cell[{}, {}] to grid[{}, {}]cell[{}, {}].", go->
GetGUID().
ToString(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1575 TC_LOG_DEBUG(
"maps",
"DynamicObject {} moved from grid[{}, {}]cell[{}, {}] to grid[{}, {}]cell[{}, {}].", go->
GetGUID().
ToString(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1587 TC_LOG_DEBUG(
"maps",
"DynamicObject {} attempted to move from grid[{}, {}]cell[{}, {}] to unloaded grid[{}, {}]cell[{}, {}].", go->
GetGUID().
ToString(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
GridX(), new_cell.
GridY(), new_cell.
CellX(), new_cell.
CellY());
1594 float resp_x, resp_y, resp_z, resp_o;
1596 Cell resp_cell(resp_x, resp_y);
1606 TC_LOG_DEBUG(
"maps",
"Creature {} moved from grid[{}, {}]cell[{}, {}] to respawn grid[{}, {}]cell[{}, {}].", c->
GetGUID().
ToString(), c->
GetCurrentCell().
GridX(), c->
GetCurrentCell().
GridY(), c->
GetCurrentCell().
CellX(), c->
GetCurrentCell().
CellY(), resp_cell.
GridX(), resp_cell.
GridY(), resp_cell.
CellX(), resp_cell.
CellY());
1612 c->
Relocate(resp_x, resp_y, resp_z, resp_o);
1625 float resp_x, resp_y, resp_z, resp_o;
1627 Cell resp_cell(resp_x, resp_y);
1634 TC_LOG_DEBUG(
"maps",
"GameObject {} moved from grid[{}, {}]cell[{}, {}] to respawn grid[{}, {}]cell[{}, {}].", go->
GetGUID().
ToString(), go->
GetCurrentCell().
GridX(), go->
GetCurrentCell().
GridY(), go->
GetCurrentCell().
CellX(), go->
GetCurrentCell().
CellY(), resp_cell.
GridX(), resp_cell.
GridY(), resp_cell.
CellX(), resp_cell.
CellY());
1640 go->
Relocate(resp_x, resp_y, resp_z, resp_o);
1724 TC_LOG_DEBUG(
"maps",
"Unloading grid[{}, {}] for map {} finished", x, y,
GetId());
1734 Player* player = itr->GetSource();
1738 TC_LOG_ERROR(
"maps",
"Map::UnloadAll: player {} is still in map {} during unload, this should not happen!", player->
GetName(),
GetId());
1763 RemoveFromMap<Transport>(transport,
true);
1768 for (
Corpse* corpse : cellCorpsePair.second)
1770 corpse->RemoveFromWorld();
1823 FILE* in = fopen(filename,
"rb");
1827 if (fread(&header,
sizeof(header), 1, in) != 1)
1845 TC_LOG_ERROR(
"maps",
"Error loading map height data\n");
1852 TC_LOG_ERROR(
"maps",
"Error loading map liquids data\n");
1859 TC_LOG_ERROR(
"maps",
"Error loading map holes data\n");
1867 TC_LOG_ERROR(
"maps",
"Map file '{}' is from an incompatible map version (%.*s v{}), %.*s v{} is expected. Please pull your source, recompile tools and recreate maps using the updated mapextractor, then replace your old map files with new files. If you still have problems search on forum for error TCE00018.",
1897 fseek(in, offset, SEEK_SET);
1915 fseek(in, offset, SEEK_SET);
1945 m_V9 =
new float [129*129];
1946 m_V8 =
new float [128*128];
1947 if (fread(
m_V9,
sizeof(
float), 129*129, in) != 129*129 ||
1948 fread(
m_V8,
sizeof(
float), 128*128, in) != 128*128)
1958 std::array<int16, 9> maxHeights;
1959 std::array<int16, 9> minHeights;
1960 if (fread(maxHeights.data(),
sizeof(
int16), maxHeights.size(), in) != maxHeights.size() ||
1961 fread(minHeights.data(),
sizeof(
int16), minHeights.size(), in) != minHeights.size())
1964 static uint32 constexpr indices[8][3] =
1976 static float constexpr boundGridCoords[9][2] =
1979 { 0.0f, -266.66666f },
1980 { 0.0f, -533.33331f },
1981 { -266.66666f, 0.0f },
1982 { -266.66666f, -266.66666f },
1983 { -266.66666f, -533.33331f },
1984 { -533.33331f, 0.0f },
1985 { -533.33331f, -266.66666f },
1986 { -533.33331f, -533.33331f }
1990 for (
uint32 quarterIndex = 0; quarterIndex < 8; ++quarterIndex)
1992 G3D::Vector3(boundGridCoords[indices[quarterIndex][0]][0], boundGridCoords[indices[quarterIndex][0]][1], minHeights[indices[quarterIndex][0]]),
1993 G3D::Vector3(boundGridCoords[indices[quarterIndex][1]][0], boundGridCoords[indices[quarterIndex][1]][1], minHeights[indices[quarterIndex][1]]),
1994 G3D::Vector3(boundGridCoords[indices[quarterIndex][2]][0], boundGridCoords[indices[quarterIndex][2]][1], minHeights[indices[quarterIndex][2]])
2004 fseek(in, offset, SEEK_SET);
2038 if (fseek(in, offset, SEEK_SET) != 0)
2042 if (fread(
_holes,
sizeof(
uint16), 16 * 16, in) != 16 * 16)
2055 int lx = (int)x & 15;
2056 int ly = (int)y & 15;
2080 if (
isHole(x_int, y_int))
2105 float h1 =
m_V9[(x_int)*129 + y_int];
2106 float h2 =
m_V9[(x_int+1)*129 + y_int];
2107 float h5 = 2 *
m_V8[x_int*128 + y_int];
2115 float h1 =
m_V9[x_int*129 + y_int ];
2116 float h3 =
m_V9[x_int*129 + y_int+1];
2117 float h5 = 2 *
m_V8[x_int*128 + y_int];
2128 float h2 =
m_V9[(x_int+1)*129 + y_int ];
2129 float h4 =
m_V9[(x_int+1)*129 + y_int+1];
2130 float h5 = 2 *
m_V8[x_int*128 + y_int];
2138 float h3 =
m_V9[(x_int)*129 + y_int+1];
2139 float h4 =
m_V9[(x_int+1)*129 + y_int+1];
2140 float h5 = 2 *
m_V8[x_int*128 + y_int];
2147 return a * x + b * y + c;
2165 if (
isHole(x_int, y_int))
2175 int32 h1 = V9_h1_ptr[ 0];
2176 int32 h2 = V9_h1_ptr[129];
2185 int32 h1 = V9_h1_ptr[0];
2186 int32 h3 = V9_h1_ptr[1];
2198 int32 h2 = V9_h1_ptr[129];
2199 int32 h4 = V9_h1_ptr[130];
2208 int32 h3 = V9_h1_ptr[ 1];
2209 int32 h4 = V9_h1_ptr[130];
2235 if (
isHole(x_int, y_int))
2245 int32 h1 = V9_h1_ptr[ 0];
2246 int32 h2 = V9_h1_ptr[129];
2255 int32 h1 = V9_h1_ptr[0];
2256 int32 h3 = V9_h1_ptr[1];
2268 int32 h2 = V9_h1_ptr[129];
2269 int32 h4 = V9_h1_ptr[130];
2278 int32 h3 = V9_h1_ptr[ 1];
2279 int32 h4 = V9_h1_ptr[130];
2295 int cellRow = row / 8;
2296 int cellCol = col / 8;
2297 int holeRow = row % 8 / 2;
2298 int holeCol = (col - (cellCol * 8)) / 2;
2319 if (doubleGridY & 1)
2321 if (doubleGridX & 1)
2322 quarterIndex = 4 + (gx <= gy);
2326 else if (doubleGridX & 1)
2329 quarterIndex = gx > gy;
2331 G3D::Ray ray = G3D::Ray::fromOriginAndDirection(G3D::Vector3(gx, gy, 0.0f), G3D::Vector3::unitZ());
2369 int idx=(x_int>>3)*16 + (y_int>>3);
2375 uint32 liqTypeIdx = liquidEntry->SoundBank;
2380 uint32 overrideLiquid = area->LiquidTypeID[liquidEntry->SoundBank];
2381 if (!overrideLiquid && area->ParentAreaID)
2385 overrideLiquid = area->LiquidTypeID[liquidEntry->SoundBank];
2390 entry = overrideLiquid;
2391 liqTypeIdx = liq->SoundBank;
2396 type |= 1 << liqTypeIdx;
2403 if (ReqLiquidType && !(*ReqLiquidType & type))
2421 if (liquid_level < ground_level || z < ground_level)
2427 data->
entry = entry;
2429 data->
level = liquid_level;
2434 float delta = liquid_level - z;
2436 if (delta > collisionHeight)
2473 return std::max<float>(liquid_status.
level, ground_z);
2477 return liquid_status.
level;
2484float Map::GetHeight(
float x,
float y,
float z,
bool checkVMap ,
float maxSearchDist )
const
2490 mapHeight = gridHeight;
2510 if (vmapHeight > mapHeight || std::fabs(mapHeight - z) > std::fabs(vmapHeight - z))
2525 return gmap->getHeight(x, y);
2533 return grid->getMinHeight(x, y);
2540 return (mogpFlags & 0x2000) != 0;
2554 if (hasVmapAreaInfo)
2561 else if (hasDynamicAreaInfo)
2566 if (hasVmapAreaInfo || hasDynamicAreaInfo)
2571 float mapHeight = gmap->getHeight(x, y);
2573 if (z + 2.0f > mapHeight && mapHeight > check_z)
2584 int32 adtId, rootId, groupId;
2586 bool hasVmapArea =
GetAreaInfo(phaseMask, x, y, vmapZ, mogpFlags, adtId, rootId, groupId);
2592 gridAreaId = gmap->getArea(x, y);
2593 gridMapHeight = gmap->getHeight(x, y);
2603 areaId = wmoEntry->AreaTableID;
2606 areaId = gridAreaId;
2609 areaId = gridAreaId;
2621 if (area->ParentAreaID)
2622 return area->ParentAreaID;
2629 areaid = zoneid =
GetAreaId(phaseMask, x, y, z);
2631 if (area->ParentAreaID)
2632 zoneid = area->ParentAreaID;
2640 bool useGridLiquid =
true;
2655 uint32 liquidFlagType = 0;
2657 liquidFlagType = liq->SoundBank;
2663 uint32 overrideLiquid = area->LiquidTypeID[liquidFlagType];
2664 if (!overrideLiquid && area->ParentAreaID)
2668 overrideLiquid = area->LiquidTypeID[liquidFlagType];
2674 liquidFlagType = liq->SoundBank;
2686 float delta = vmapData.
liquidInfo->level - z;
2689 if (delta > collisionHeight)
2704 ZLiquidStatus map_result = gmap->GetLiquidStatus(x, y, z, ReqLiquidType, &map_data, collisionHeight);
2712 map_data.
entry = 15;
2737 gridAreaId = gmap->
getArea(x, y);
2741 bool useGridLiquid =
true;
2746 data.
floorZ = gridMapHeight;
2752 wmoData = &vmapData;
2777 if (wmoEntry->
Flags & 4)
2779 else if (wmoEntry->
Flags & 2)
2784 data.
areaId = gridAreaId;
2792 data.
areaId = gridAreaId;
2807 if (
GetId() == 530 && liquidType == 2)
2810 uint32 liquidFlagType = 0;
2812 liquidFlagType = liquidData->SoundBank;
2814 if (liquidType && liquidType < 21 && areaEntry)
2821 overrideLiquid = zoneEntry->
LiquidTypeID[liquidFlagType];
2826 liquidType = overrideLiquid;
2827 liquidFlagType = overrideData->SoundBank;
2835 data.
liquidInfo->type_flags = 1 << liquidFlagType;
2837 float delta = wmoData->
liquidInfo->level - z;
2838 if (delta > collisionHeight)
2840 else if (delta > 0.0f)
2842 else if (delta > -0.1f)
2848 if (gmap && useGridLiquid)
2854 if (
GetId() == 530 && gridMapLiquid.
entry == 2)
2855 gridMapLiquid.
entry = 15;
2865 return gmap->getLiquidLevel(x, y);
2881bool Map::getObjectHitPos(
uint32 phasemask,
float x1,
float y1,
float z1,
float x2,
float y2,
float z2,
float& rx,
float& ry,
float& rz,
float modifyDist)
2883 G3D::Vector3 startPos(x1, y1, z1);
2884 G3D::Vector3 dstPos(x2, y2, z2);
2886 G3D::Vector3 resultPos;
2898 LiquidData* liquid_ptr = data ? data : &liquid_status;
2911 if (xy_cell != cur_cell)
2913 TC_LOG_DEBUG(
"maps",
"Creature {} X: {} Y: {} ({}) is in grid[{}, {}]cell[{}, {}] instead of grid[{}, {}]cell[{}, {}]",
2939 transport->BuildCreateUpdateBlockForPlayer(&data, player);
2958 for (Transport::PassengerSet::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end(); ++itr)
2960 (*itr)->BuildCreateUpdateBlockForPlayer(&data, player);
2972 (*i)->BuildCreateUpdateBlockForPlayer(&transData, player);
2988 (*i)->BuildOutOfRangeUpdateBlock(&transData);
3002 TC_LOG_ERROR(
"maps",
"map::setNGrid() Invalid grid coordinates found: {}, {}!", x, y);
3022 for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
3024 iter->second.BuildPacket(&packet);
3025 iter->first->SendDirectMessage(&packet);
3037 ASSERT(data,
"Invalid respawn info with type %u, spawnID %u in respawn queue.", info->
type, info->
spawnId);
3047 bool alreadyExists =
false;
3056 for (
auto it = range.first; it != range.second; ++it)
3064 alreadyExists =
true;
3072 alreadyExists =
true;
3086 ? ObjectGuid::Create<HighGuid::GameObject>(info->
entry, info->
spawnId)
3087 : ObjectGuid::Create<HighGuid::Unit>(info->
entry, info->
spawnId);
3092 if (linkedTime == std::numeric_limits<time_t>::max())
3093 respawnTime = linkedTime;
3094 else if (
sObjectMgr->GetLinkedRespawnGuid(thisGUID) == thisGUID)
3095 respawnTime = now +
WEEK;
3097 respawnTime = std::max<time_t>(now, linkedTime) +
urand(5, 15);
3116 std::vector<WorldObject*> toUnload;
3121 toUnload.push_back(pair.second);
3125 toUnload.push_back(pair.second);
3134 return toUnload.size();
3150 auto it = bySpawnIdMap.find(info.
spawnId);
3151 if (it != bySpawnIdMap.end())
3159 ASSERT(bySpawnIdMap.find(info.
spawnId) == bySpawnIdMap.end(),
"Insertion of respawn info with id (%u,%u) into spawn id map failed - state desync.",
uint32(info.
type), info.
spawnId);
3166 bySpawnIdMap.emplace(ri->
spawnId, ri);
3172 data.reserve(data.size() + map.size());
3173 for (
auto const& pair : map)
3174 data.push_back(pair.second);
3188 auto it = map.find(spawnId);
3189 if (it == map.end())
3210 auto range = spawnMap.equal_range(info->
spawnId);
3211 auto it = std::find_if(range.first, range.second, [info](RespawnInfoMap::value_type
const& pair) { return (pair.second == info); });
3212 ASSERT(it != range.second,
"Respawn stores inconsistent for map %u, spawnid %u (type %u)",
GetId(), info->
spawnId,
uint32(info->
type));
3245 if (!obj->
LoadFromDB(spawnId,
this,
true,
true))
3267 if (now < next->respawnTime)
3305 ASSERT(now < next->respawnTime);
3343 uint32 const playerCount = it->second;
3347 if (adjustFactor >= 1.0)
3350 if (respawnDelay <= timeMinimum)
3353 respawnDelay = std::max<uint32>(ceil(respawnDelay * adjustFactor), timeMinimum);
3387 TC_LOG_ERROR(
"maps",
"Tried to spawn non-existing (or system) spawn group {} on map {}. Blocked.", groupId,
GetId());
3393 std::vector<SpawnData const*> toSpawn;
3394 for (
auto& pair :
sObjectMgr->GetSpawnMetadataForGroup(groupId))
3399 if (force || ignoreRespawn)
3435 if (!creature->
LoadFromDB(data->spawnId,
this,
true, force))
3437 else if (spawnedObjects)
3438 spawnedObjects->push_back(creature);
3444 if (!gameobject->
LoadFromDB(data->spawnId,
this,
true))
3446 else if (spawnedObjects)
3447 spawnedObjects->push_back(gameobject);
3451 ABORT_MSG(
"Invalid spawn type %u with spawnId %u",
uint32(data->type), data->spawnId);
3463 TC_LOG_ERROR(
"maps",
"Tried to despawn non-existing (or system) spawn group {} on map {}. Blocked.", groupId,
GetId());
3467 for (
auto const& pair :
sObjectMgr->GetSpawnMetadataForGroup(groupId))
3471 if (deleteRespawnTimes)
3486 TC_LOG_ERROR(
"maps",
"Tried to set non-existing (or system) spawn group {} to {} on map {}. Blocked.", groupId, state ?
"active" :
"inactive",
GetId());
3500 TC_LOG_ERROR(
"maps",
"Tried to query state of non-existing spawn group {} on map {}.", groupId,
GetId());
3513 itr =
_guidGenerators.insert(std::make_pair(high, std::make_unique<ObjectGuidGenerator>(high))).first;
3515 return *itr->second;
3554 GridInfo* info = i->GetSource()->getGridInfoRef();
3582 else if (itr->second != on)
3594 bool on = itr->second;
3602 SwitchGridContainers<Creature>(obj->
ToCreature(), on);
3605 SwitchGridContainers<GameObject>(obj->
ToGameObject(), on);
3649 TC_LOG_ERROR(
"maps",
"Non-grid object (TypeId: {}) is in grid object remove list, ignored.", obj->
GetTypeId());
3663 if (!itr->GetSource()->IsGameMaster())
3671 itr->GetSource()->SendDirectMessage(data);
3677 bool foundPlayerToSend =
false;
3681 Player* player = ref.GetSource();
3685 (team == 0 || player->
GetTeam() == team))
3688 foundPlayerToSend =
true;
3692 return foundPlayerToSend;
3704 cell_min.
dec_x(cell_range);
3705 cell_min.
dec_y(cell_range);
3706 cell_max.
inc_x(cell_range);
3707 cell_max.
inc_y(cell_range);
3711 Player* player = iter->GetSource();
3740 if (
Creature* creature = obj->
ToCreature(); !creature->IsPet() && creature->GetSpawnId())
3742 respawnLocation.emplace();
3743 creature->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
3749 respawnLocation.emplace();
3750 gameObject->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
3757 if (respawnLocation)
3765 TC_LOG_ERROR(
"maps",
"Active object {} added to grid[{}, {}] but spawn grid[{}, {}] was not loaded.",
3779 if (
Creature* creature = obj->
ToCreature(); !creature->IsPet() && creature->GetSpawnId())
3781 respawnLocation.emplace();
3782 creature->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
3788 respawnLocation.emplace();
3789 gameObject->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
3796 if (respawnLocation)
3804 TC_LOG_ERROR(
"maps",
"Active object {} removed from grid[{}, {}] but spawn grid[{}, {}] was not loaded.",
3823 :
Map(id, expiry, InstanceId, SpawnMode, _parent),
3824 m_resetAfterUnload(false), m_unloadWhenEmpty(false),
3825 i_data(nullptr), i_script_id(0), i_script_team(InstanceTeam)
3878 if (playerBind->perm && playerBind->save)
3895 std::lock_guard<std::mutex> lock(
_mapLock);
3921 if (playerBind && playerBind->
perm)
3924 if (playerBind->
save != mapSave)
3926 TC_LOG_ERROR(
"maps",
"InstanceMap::Add: player {} {} is permanently bound to instance {} {}, {}, {}, {}, {}, {} but he is being put into instance {} {}, {}, {}, {}, {}, {}", player->
GetName(), player->
GetGUID().
ToString(),
GetMapName(), playerBind->
save->
GetMapId(), playerBind->
save->
GetInstanceId(),
static_cast<uint32>(playerBind->
save->
GetDifficulty()), playerBind->
save->
GetPlayerCount(), playerBind->
save->
GetGroupCount(), playerBind->
save->
CanReset(),
GetMapName(), mapSave->
GetMapId(), mapSave->
GetInstanceId(),
static_cast<uint32>(mapSave->
GetDifficulty()), mapSave->
GetPlayerCount(), mapSave->
GetGroupCount(), mapSave->
CanReset());
3936 if (playerBind && playerBind->
save != mapSave)
3938 TC_LOG_ERROR(
"maps",
"InstanceMap::Add: player {} {} is being put into instance {} {}, {}, {}, {}, {}, {} but he is in group {} and is bound to instance {}, {}, {}, {}, {}, {}!", player->
GetName(), player->
GetGUID().
ToString(),
GetMapName(), mapSave->
GetMapId(), mapSave->
GetInstanceId(),
static_cast<uint32>(mapSave->
GetDifficulty()), mapSave->
GetPlayerCount(), mapSave->
GetGroupCount(), mapSave->
CanReset(), group->
GetLeaderGUID().
ToString(), playerBind->
save->
GetMapId(), playerBind->
save->
GetInstanceId(),
static_cast<uint32>(playerBind->
save->
GetDifficulty()), playerBind->
save->
GetPlayerCount(), playerBind->
save->
GetGroupCount(), playerBind->
save->
CanReset());
3940 TC_LOG_ERROR(
"maps",
"InstanceMap::Add: the group is bound to the instance {} {}, {}, {}, {}, {}, {}",
GetMapName(), groupBind->
save->
GetMapId(), groupBind->
save->
GetInstanceId(),
static_cast<uint32>(groupBind->
save->
GetDifficulty()), groupBind->
save->
GetPlayerCount(), groupBind->
save->
GetGroupCount(), groupBind->
save->
CanReset());
3950 if (groupBind->
save != mapSave)
3952 TC_LOG_ERROR(
"maps",
"InstanceMap::Add: player {} {} is being put into instance {}, {}, {} but he is in group {} which is bound to instance {}, {}, {}!", player->
GetName(), player->
GetGUID().
ToString(), mapSave->
GetMapId(), mapSave->
GetInstanceId(),
static_cast<uint32>(mapSave->
GetDifficulty()), group->
GetLeaderGUID().
ToString(), groupBind->
save->
GetMapId(), groupBind->
save->
GetInstanceId(),
static_cast<uint32>(groupBind->
save->
GetDifficulty()));
3954 if (groupBind->
save)
3962 if (groupBind->
perm)
4056 Field* fields = result->Fetch();
4057 std::string data = fields[0].
GetString();
4084 itr->GetSource()->SendResetFailedNotify(
GetId());
4088 bool doUnload =
true;
4098 itr->GetSource()->m_InstanceValid =
false;
4144 Player* player = itr->GetSource();
4150 if (bind && bind->
perm)
4154 TC_LOG_ERROR(
"maps",
"Player ({}, Name: {}) is in instance map (Name: {}, Entry: {}, Difficulty: {}, ID: {}) that is being bound, but already has a save for the map on ID {}!", player->
GetGUID().
ToString(), player->
GetName(),
GetMapName(), save->
GetMapId(),
static_cast<uint32>(save->
GetDifficulty()), save->
GetInstanceId(), bind->
save->
GetInstanceId());
4156 else if (!bind->
save)
4158 TC_LOG_ERROR(
"maps",
"Player ({}, Name: {}) is in instance map (Name: {}, Entry: {}, Difficulty: {}, ID: {}) that is being bound, but already has a bind (without associated save) for the map!", player->
GetGUID().
ToString(), player->
GetName(),
GetMapName(), save->
GetMapId(),
static_cast<uint32>(save->
GetDifficulty()), save->
GetInstanceId());
4171 if (group->GetLeaderGUID() == player->
GetGUID())
4172 group->BindToInstance(save,
true);
4193 itr->GetSource()->SendInstanceResetWarning(
GetId(), itr->GetSource()->GetDifficulty(
IsRaid()), timeLeft,
false);
4206 TC_LOG_ERROR(
"maps",
"InstanceMap::SetResetSchedule: cannot turn schedule {}, there is no save information for instance (map [id: {}, name: {}], instance id: {}, difficulty: {})",
4308 return mapDiff ? mapDiff->
resetTime : 0;
4314 :
Map(id, expiry, InstanceId, spawnMode, _parent), m_bg(nullptr)
4357 std::lock_guard<std::mutex> lock(
_mapLock);
4382 if (
Player* player = itr->GetSource())
4383 if (!player->IsBeingTeleportedFar())
4384 player->TeleportTo(player->GetBattlegroundEntryPoint());
4405 if (bounds.first == bounds.second)
4408 std::unordered_multimap<uint32, Creature*>::const_iterator creatureItr = std::find_if(bounds.first, bounds.second, [](Map::CreatureBySpawnIdContainer::value_type
const& pair)
4410 return pair.second->IsAlive();
4413 return creatureItr != bounds.second ? creatureItr->second : bounds.first->second;
4419 if (bounds.first == bounds.second)
4422 std::unordered_multimap<uint32, GameObject*>::const_iterator creatureItr = std::find_if(bounds.first, bounds.second, [](Map::GameObjectBySpawnIdContainer::value_type
const& pair)
4424 return pair.second->isSpawned();
4427 return creatureItr != bounds.second ? creatureItr->second : bounds.first->second;
4465 TC_LOG_ERROR(
"maps",
"Map {} attempt to save respawn time for nonexistant spawnid ({},{}).",
GetId(), type, spawnId);
4487 TC_LOG_ERROR(
"maps",
"Attempt to load saved respawn {} for ({},{}) failed - duplicate respawn? Skipped.", respawnTime,
uint32(type), spawnId);
4513 Field* fields = result->Fetch();
4523 TC_LOG_ERROR(
"maps",
"Loading saved respawn time of {} for spawnid ({},{}) - spawn does not exist, ignoring", respawnTime,
uint32(type), spawnId);
4527 TC_LOG_ERROR(
"maps",
"Loading saved respawn time of {} for spawnid ({},{}) - invalid spawn type, ignoring", respawnTime,
uint32(type), spawnId);
4530 }
while (result->NextRow());
4572 Field* fields = result->Fetch();
4577 TC_LOG_ERROR(
"misc",
"Corpse (guid: {}) have wrong corpse type ({}), not loading.", guid, type);
4583 if (!corpse->
LoadCorpseFromDB(GenerateLowGuid<HighGuid::Corpse>(), fields))
4591 }
while (result->NextRow());
4689 std::vector<ObjectGuid> corpses;
4693 if (p.second->IsExpired(now))
4694 corpses.push_back(p.first);
4699 std::vector<Corpse*> expiredBones;
4701 if (bones->IsExpired(now))
4702 expiredBones.push_back(bones);
4704 for (
Corpse* bones : expiredBones)
4717 if (
uint32 music = itr->second.MusicId)
4725 overrideLight.
AreaLightID = lightOverride.AreaLightId;
4750 zoneDynamicInfo.
DefaultWeather->SendWeatherUpdateToPlayer(player);
4781 info.
DefaultWeather = std::make_unique<Weather>(
this, zoneId, weatherData);
4804 return lightOverride.AreaLightId == areaLightId;
4808 if (overrideLightId)
4828 if (
Player* player = itr->GetSource())
4830 if (player->IsInWorld())
4832 player->UpdateAreaDependentAuras(player->GetAreaId());
4833 player->UpdateZoneDependentAuras(player->GetZoneId());
4841 std::stringstream sstr;
4842 sstr << std::boolalpha
4850 std::stringstream sstr;
@ CHAR_SEL_PERM_BIND_BY_INSTANCE
@ CHAR_DEL_CORPSES_FROM_MAP
@ DUNGEON_DIFFICULTY_NORMAL
@ DUNGEON_DIFFICULTY_HEROIC
@ RAID_DIFFICULTY_10MAN_HEROIC
#define RAID_DIFFICULTY_MASK_25MAN
MapDifficulty const * GetMapDifficultyData(uint32 mapId, Difficulty difficulty)
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
DBCStorage< LiquidTypeEntry > sLiquidTypeStore(LiquidTypefmt)
WMOAreaTableEntry const * GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid, int32 groupid)
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
#define ASSERT_NOTNULL(pointer)
#define MAX_NUMBER_OF_CELLS
#define TOTAL_NUMBER_OF_CELLS_PER_MAP
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
#define MAX_NUMBER_OF_GRIDS
#define CENTER_GRID_CELL_ID
#define SIZE_OF_GRID_CELL
#define CENTER_GRID_OFFSET
NGrid< MAX_NUMBER_OF_CELLS, Player, AllWorldObjectTypes, AllGridObjectTypes > NGridType
#define VMAP_INVALID_HEIGHT_VALUE
#define VMAP_INVALID_HEIGHT
#define TC_LOG_WARN(filterType__,...)
#define TC_LOG_DEBUG(filterType__,...)
#define TC_LOG_ERROR(filterType__,...)
@ MAP_OBJECT_CELL_MOVE_INACTIVE
@ MAP_OBJECT_CELL_MOVE_ACTIVE
@ MAP_OBJECT_CELL_MOVE_NONE
static uint16 const holetab_h[4]
static uint16 const holetab_v[4]
u_map_magic MapLiquidMagic
static bool IsInWMOInterior(uint32 mogpFlags)
static void PushRespawnInfoFrom(std::vector< RespawnInfo const * > &data, RespawnInfoMap const &map)
GridState * si_GridStates[MAX_GRID_STATE]
u_map_magic MapHeightMagic
#define MAP_HEIGHT_HAS_FLIGHT_BOUNDS
#define MAP_HEIGHT_AS_INT8
std::unordered_map< ObjectGuid::LowType, RespawnInfo * > RespawnInfoMap
#define MAP_LIQUID_NO_TYPE
#define MAP_LIQUID_NO_HEIGHT
#define MAP_LIQUID_TYPE_WATER
#define MAP_LIQUID_TYPE_DARK_WATER
#define MAP_LIQUID_TYPE_OCEAN
@ INSTANCE_RESET_CHANGE_DIFFICULTY
#define MAP_HEIGHT_NO_HEIGHT
#define MAP_HEIGHT_AS_INT16
#define TC_METRIC_VALUE(category, value,...)
#define TC_METRIC_TAG(name, value)
#define DEFAULT_VISIBILITY_NOTIFY_PERIOD
#define MAX_VISIBILITY_DISTANCE
#define DEFAULT_VISIBILITY_DISTANCE
std::unordered_map< Player *, UpdateData > UpdateDataMapType
std::optional< T > Optional
Optional helper class to wrap optional values within.
uint32 urand(uint32 min, uint32 max)
float const GROUND_HEIGHT_TOLERANCE
@ LINEOFSIGHT_CHECK_GOBJECT
constexpr float Z_OFFSET_FIND_HEIGHT
@ SPAWNGROUP_FLAG_DYNAMIC_SPAWN_RATE
@ SPAWNGROUP_FLAG_MANUAL_SPAWN
@ SPAWNGROUP_FLAG_ESCORTQUESTNPC
@ SPAWN_TYPEMASK_CREATURE
@ SPAWN_TYPEMASK_GAMEOBJECT
bool AddPlayerToMap(Player *) override
BattlegroundMap(uint32 id, time_t, uint32 InstanceId, Map *_parent, uint8 spawnMode)
void RemoveAllPlayers() override
EnterState CannotEnter(Player *player) override
void RemovePlayerFromMap(Player *, bool) override
virtual void InitVisibilityDistance() override
void SetBgMap(BattlegroundMap *map)
static size_t BuildChatPacket(WorldPacket &data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string_view message, uint8 chatTag, std::string const &senderName="", std::string const &receiverName="", uint32 achievementId=0, bool gmMessage=false, std::string const &channelName="")
std::unordered_map< ObjectGuid, CombatReference * > const & GetPvECombatRefs() const
bool Create(ObjectGuid::LowType guidlow)
void RemoveFromWorld() override
CellCoord const & GetCellCoord() const
ObjectGuid GetOwnerGUID() const override
bool LoadCorpseFromDB(ObjectGuid::LowType guid, Field *fields)
void SetCellCoord(CellCoord const &cellCoord)
CorpseType GetType() const
void DeleteFromDB(CharacterDatabaseTransaction trans)
void GetRespawnPosition(float &x, float &y, float &z, float *ori=nullptr, float *dist=nullptr) const
bool LoadFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap, bool allowDuplicate)
bool getAreaAndLiquidData(float x, float y, float z, uint32 phasemask, Optional< uint8 > reqLiquidType, VMAP::AreaAndLiquidData &data) const
bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask) const
bool getObjectHitPos(uint32 phasemask, const G3D::Vector3 &pPos1, const G3D::Vector3 &pPos2, G3D::Vector3 &pResultHitPos, float pModifyDist) const
Class used to access individual fields of database query result.
std::string GetString() const
void GetRespawnPosition(float &x, float &y, float &z, float *ori=nullptr) const
bool LoadFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap, bool=true)
void RemoveFromWorld() override
ObjectGuid::LowType GetSpawnId() const
void UpdateModelPosition()
Transport * ToTransport()
void AddToWorld() override
PeriodicTimer & getRelocationTimer()
bool loadAreaData(FILE *in, uint32 offset, uint32 size)
float getHeightFromFlat(float x, float y) const
float getMinHeight(float x, float y) const
bool isHole(int row, int col) const
uint16 getArea(float x, float y) const
float getHeightFromFloat(float x, float y) const
float getHeightFromUint16(float x, float y) const
bool loadData(char const *filename)
ZLiquidStatus GetLiquidStatus(float x, float y, float z, Optional< uint8 > ReqLiquidType, LiquidData *data=0, float collisionHeight=2.03128f)
uint16 _liquidGlobalEntry
bool loadHolesData(FILE *in, uint32 offset, uint32 size)
float _gridIntHeightMultiplier
float getLiquidLevel(float x, float y) const
G3D::Plane * _minHeightPlanes
float getHeightFromUint8(float x, float y) const
float getHeight(float x, float y) const
bool loadHeightData(FILE *in, uint32 offset, uint32 size)
GetHeightPtr _gridGetHeight
bool loadLiquidData(FILE *in, uint32 offset, uint32 size)
virtual void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const =0
void AddWorldObject(SPECIFIC_OBJECT *obj)
void AddGridObject(SPECIFIC_OBJECT *obj)
InstanceGroupBind * BindToInstance(InstanceSave *save, bool permanent, bool load=false)
ObjectGuid GetLeaderGUID() const
InstanceGroupBind * GetBoundInstance(Player *player)
bool AddPlayerToMap(Player *) override
void Update(uint32) override
void CreateInstanceData(bool load)
InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode, Map *_parent, TeamId InstanceTeam)
void SendResetWarnings(uint32 timeLeft) const
uint32 GetMaxPlayers() const
virtual void InitVisibilityDistance() override
uint32 GetScriptId() const
void RemovePlayerFromMap(Player *, bool) override
void PermBindAllPlayers()
uint32 GetMaxResetDelay() const
bool HasPermBoundPlayers() const
EnterState CannotEnter(Player *player) override
void UnloadAll() override
std::string const & GetScriptName() const
void SetResetSchedule(bool on)
std::string GetDebugInfo() const override
InstanceScript * GetInstanceScript()
uint8 GetPlayerCount() const
uint8 GetGroupCount() const
uint32 GetInstanceId() const
Difficulty GetDifficulty() const
uint32 GetCompletedEncounterMask() const
virtual void Load(char const *data)
virtual void OnPlayerLeave(Player *)
virtual void OnPlayerEnter(Player *)
virtual void Update(uint32)
void SetCompletedEncountersMask(uint32 newMask)
static MMapManager * createOrGetMMapManager()
bool unloadMap(uint32 mapId, int32 x, int32 y)
bool loadMapInstance(std::string const &basePath, uint32 mapId, uint32 instanceId)
bool loadMap(std::string const &basePath, uint32 mapId, int32 x, int32 y)
bool unloadMapInstance(uint32 mapId, uint32 instanceId)
void SetCurrentCell(Cell const &cell)
MapObjectCellMoveState _moveState
void SetNewCellPosition(float x, float y, float z, float o)
Cell const & GetCurrentCell() const
MapReference const * nocheck_prev() const
MapEntry const * i_mapEntry
void DynamicObjectRelocation(DynamicObject *go, float x, float y, float z, float orientation)
std::map< WorldObject *, bool > i_objectsToSwitch
WorldObject * GetWorldObjectBySpawnId(SpawnObjectType type, ObjectGuid::LowType spawnId) const
std::unordered_map< uint32, uint32 > _zonePlayerCountMap
float GetWaterLevel(float x, float y) const
std::vector< Creature * > _creaturesToMove
void AddFarSpellCallback(FarSpellCallback &&callback)
void GameObjectRelocation(GameObject *go, float x, float y, float z, float orientation, bool respawnRelocationOnFail=true)
void AddGameObjectToMoveList(GameObject *go, float x, float y, float z, float ang)
void RemoveDynamicObjectFromMoveList(DynamicObject *go)
void CreatureRelocation(Creature *creature, float x, float y, float z, float ang, bool respawnRelocationOnFail=true)
void SetZoneMusic(uint32 zoneId, uint32 musicId)
bool IsBattlegroundOrArena() const
bool UnloadGrid(NGridType &ngrid, bool pForce)
std::unordered_map< ObjectGuid, Corpse * > _corpsesByPlayer
void SetZoneWeather(uint32 zoneId, WeatherState weatherId, float intensity)
Pet * GetPet(ObjectGuid const &guid)
MapStoredObjectTypesContainer & GetObjectsStore()
TransportsContainer::iterator _transportsUpdateIter
void InitializeObject(T *obj)
static void DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId)
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
void SwitchGridContainers(T *obj, bool on)
void AddObjectToRemoveList(WorldObject *obj)
void SendZoneWeather(uint32 zoneId, Player *player) const
virtual void RemovePlayerFromMap(Player *, bool)
void MoveAllGameObjectsInMoveList()
Creature * GetCreatureBySpawnId(ObjectGuid::LowType spawnId) const
void RemoveFromActiveHelper(WorldObject *obj)
void DeleteRespawnInfoFromDB(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans=nullptr)
size_t DespawnAll(SpawnObjectType type, ObjectGuid::LowType spawnId)
std::function< void(Map *)> FarSpellCallback
void SetSpawnGroupActive(uint32 groupId, bool state)
void LoadGrid(float x, float y)
void SendZoneDynamicInfo(uint32 zoneId, Player *player) const
void RemoveFromActive(WorldObject *obj)
void SendZoneText(uint32 zoneId, const char *text, WorldSession const *self=nullptr, uint32 team=0) const
Send a System Message to all players in the zone (except self if mentioned)
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
bool getObjectHitPos(uint32 phasemask, float x1, float y1, float z1, float x2, float y2, float z2, float &rx, float &ry, float &rz, float modifyDist)
void EnsureGridCreated(GridCoord const &)
void DeleteRespawnTimes()
Map(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode, Map *_parent=nullptr)
void RemoveUpdateObject(Object *obj)
RespawnInfoMap _gameObjectRespawnTimesBySpawnId
NGridType * i_grids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
Weather * GetOrGenerateZoneDefaultWeather(uint32 zoneId)
virtual void DelayedUpdate(uint32 diff)
Player * GetPlayer(ObjectGuid const &guid)
uint8 GetSpawnMode() const
MapDifficulty const * GetMapDifficulty() const
bool IsNonRaidDungeon() const
time_t GetLinkedRespawnTime(ObjectGuid guid) const
void AddCorpse(Corpse *corpse)
bool IsBattleground() const
void LoadMMap(int gx, int gy)
void UpdatePlayerZoneStats(uint32 oldZone, uint32 newZone)
IntervalTimer _weatherUpdateTimer
bool CheckRespawn(RespawnInfo *info)
void ProcessRelocationNotifies(const uint32 diff)
void UnloadAllRespawnInfos()
void RemoveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans=nullptr, bool alwaysDeleteFromDB=false)
bool _dynamicObjectsToMoveLock
NGridType * getNGrid(uint32 x, uint32 y) const
void AddToActiveHelper(WorldObject *obj)
bool _gameObjectsToMoveLock
uint32 _respawnCheckTimer
Corpse * ConvertCorpseToBones(ObjectGuid const &ownerGuid, bool insignia=false)
bool IsRemovalGrid(float x, float y) const
std::unordered_map< uint32, std::unordered_set< Corpse * > > _corpsesByCell
MapRefManager m_mapRefManager
bool ActiveObjectsNearGrid(NGridType const &ngrid) const
void RemoveCreatureFromMoveList(Creature *c)
void ScriptsProcess()
Process queued scripts.
void Visit(Cell const &cell, TypeContainerVisitor< T, CONTAINER > &visitor)
ScriptScheduleMap m_scriptSchedule
float GetMinHeight(float x, float y) const
void AddWorldObject(WorldObject *obj)
void ResetGridExpiry(NGridType &grid, float factor=1) const
DynamicMapTree _dynamicTree
std::vector< GameObject * > _gameObjectsToMove
void DeleteRespawnInfo(RespawnInfo *info, CharacterDatabaseTransaction dbTrans=nullptr)
uint32 GetZoneId(uint32 phaseMask, float x, float y, float z) const
void ApplyDynamicModeRespawnScaling(WorldObject const *obj, ObjectGuid::LowType spawnId, uint32 &respawnDelay, uint32 mode) const
bool GameObjectRespawnRelocation(GameObject *go, bool diffGridOnly)
int32 m_VisibilityNotifyPeriod
std::unordered_set< Corpse * > _corpseBones
void EnsureGridLoadedForActiveObject(Cell const &, WorldObject *object)
void LoadMap(int gx, int gy, bool reload=false)
MPSCQueue< FarSpellCallback > _farSpellCallbacks
void LoadVMap(int gx, int gy)
time_t GetGORespawnTime(ObjectGuid::LowType spawnId) const
void SendInitSelf(Player *player)
void DoRespawn(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 gridId)
virtual void RemoveAllPlayers()
RespawnInfoMap & GetRespawnMapForType(SpawnObjectType type)
std::unordered_set< uint32 > _toggledSpawnGroupIds
bool isCellMarked(uint32 pCellId)
SpawnGroupTemplateData const * GetSpawnGroupData(uint32 groupId) const
bool GameObjectCellRelocation(GameObject *go, Cell new_cell)
void SendToPlayers(WorldPacket const *data) const
time_t GetCreatureRespawnTime(ObjectGuid::LowType spawnId) const
float GetGridHeight(float x, float y) const
GameObject * GetGameObject(ObjectGuid const &guid)
bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const
void SetZoneOverrideLight(uint32 zoneId, uint32 areaLightId, uint32 overrideLightId, Milliseconds transitionTime)
GridMap * GetGrid(float x, float y)
virtual std::string GetDebugInfo() const
static void DeleteStateMachine()
void SaveRespawnInfoDB(RespawnInfo const &info, CharacterDatabaseTransaction dbTrans=nullptr)
bool IsSpawnGroupActive(uint32 groupId) const
MapRefManager::iterator m_mapRefIter
bool CreatureCellRelocation(Creature *creature, Cell new_cell)
std::unique_ptr< RespawnListContainer > _respawnTimes
virtual EnterState CannotEnter(Player *)
Corpse * GetCorpse(ObjectGuid const &guid)
time_t GetRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId) const
virtual void Update(uint32)
ZoneDynamicInfoMap _zoneDynamicInfo
DynamicObject * GetDynamicObject(ObjectGuid const &guid)
void RemoveGameObjectFromMoveList(GameObject *go)
void GetFullTerrainStatusForPosition(uint32 phaseMask, float x, float y, float z, PositionFullTerrainStatus &data, Optional< uint8 > reqLiquidType={}, float collisionHeight=2.03128f) const
void RemoveWorldObject(WorldObject *obj)
std::set< WorldObject * > i_worldObjects
ActiveNonPlayers m_activeNonPlayers
void SaveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 entry, time_t respawnTime, uint32 gridId, CharacterDatabaseTransaction dbTrans=nullptr, bool startup=false)
ZLiquidStatus GetLiquidStatus(uint32 phaseMask, float x, float y, float z, Optional< uint8 > ReqLiquidType, LiquidData *data=nullptr, float collisionHeight=2.03128f) const
void UpdateIteratorBack(Player *player)
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
bool Instanceable() const
ObjectGuidGenerator & GetGuidSequenceGenerator(HighGuid high)
void AddDynamicObjectToMoveList(DynamicObject *go, float x, float y, float z, float ang)
void LoadMapAndVMap(int gx, int gy)
std::unordered_set< Object * > _updateObjects
void buildNGridLinkage(NGridType *pNGridType)
MapEntry const * GetEntry() const
bool IsRegularDifficulty() const
std::set< WorldObject * > i_objectsToRemove
bool SpawnGroupDespawn(uint32 groupId, bool deleteRespawnTimes=false, size_t *count=nullptr)
MapStoredObjectTypesContainer _objectsStore
void AddToGrid(T *object, Cell const &cell)
void MoveAllDynamicObjectsInMoveList()
void EnsureGridCreated_i(GridCoord const &)
uint32 GetPlayersCountExceptGMs() const
void DeleteFromWorld(T *)
void UpdateAreaDependentAuras()
void SendInitTransports(Player *player)
float GetVisibilityRange() const
bool IsRaidOrHeroicDungeon() const
void GetZoneAndAreaId(uint32 phaseMask, uint32 &zoneid, uint32 &areaid, float x, float y, float z) const
float GetWaterOrGroundLevel(uint32 phasemask, float x, float y, float z, float *ground=nullptr, bool swim=false, float collisionHeight=2.03128f) const
bool CheckGridIntegrity(Creature *c, bool moved) const
char const * GetMapName() const
Corpse * GetCorpseByPlayer(ObjectGuid const &ownerGuid) const
void RemoveAllObjectsInRemoveList()
void MoveAllCreaturesInMoveList()
bool IsGridLoaded(uint32 gridId) const
Difficulty GetDifficulty() const
void markCell(uint32 pCellId)
void VisitNearbyCellsOf(WorldObject *obj, TypeContainerVisitor< Trinity::ObjectUpdater, GridTypeMapContainer > &gridVisitor, TypeContainerVisitor< Trinity::ObjectUpdater, WorldTypeMapContainer > &worldVisitor)
void AddCreatureToMoveList(Creature *c, float x, float y, float z, float ang)
void GridUnmarkNoUnload(uint32 x, uint32 y)
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
uint32 GetAreaId(uint32 phaseMask, float x, float y, float z) const
virtual void InitVisibilityDistance()
RespawnInfo * GetRespawnInfo(SpawnObjectType type, ObjectGuid::LowType spawnId) const
bool EnsureGridLoaded(Cell const &)
void RemoveFromMap(T *, bool)
virtual bool AddPlayerToMap(Player *)
std::vector< DynamicObject * > _dynamicObjectsToMove
uint32 GetInstanceId() const
bool GetEntrancePos(int32 &mapid, float &x, float &y) const
TransportsContainer _transports
void SendRemoveTransports(Player *player)
PlayerList const & GetPlayers() const
void AddToActive(WorldObject *obj)
bool IsInWater(uint32 phaseMask, float x, float y, float z, LiquidData *data=nullptr) const
static void InitStateMachine()
void PlayerRelocation(Player *, float x, float y, float z, float orientation)
RespawnInfoMap _creatureRespawnTimesBySpawnId
bool CreatureRespawnRelocation(Creature *c, bool diffGridOnly)
static bool ExistVMap(uint32 mapid, int gx, int gy)
CreatureBySpawnIdContainer _creatureBySpawnIdStore
void AddObjectToSwitchList(WorldObject *obj, bool on)
bool AddRespawnInfo(RespawnInfo const &info)
bool SendZoneMessage(uint32 zone, WorldPacket const *packet, WorldSession const *self=nullptr, uint32 team=0) const
Send a packet to all players (or players selected team) in the zone (except self if mentioned)
bool IsUnderWater(uint32 phaseMask, float x, float y, float z) const
@ CANNOT_ENTER_MAX_PLAYERS
@ CANNOT_ENTER_ZONE_IN_COMBAT
@ CANNOT_ENTER_ALREADY_IN_MAP
@ CANNOT_ENTER_INSTANCE_BIND_MISMATCH
ActiveNonPlayers::iterator m_activeNonPlayersIter
void RemoveCorpse(Corpse *corpse)
Creature * GetCreature(ObjectGuid const &guid)
Transport * GetTransport(ObjectGuid const &guid)
std::map< HighGuid, std::unique_ptr< ObjectGuidGenerator > > _guidGenerators
bool GetAreaInfo(uint32 phaseMask, float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId) const
GameObject * GetGameObjectBySpawnId(ObjectGuid::LowType spawnId) const
static bool ExistMap(uint32 mapid, int gx, int gy)
GridMap * GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
void GridMarkNoUnload(uint32 x, uint32 y)
bool DynamicObjectCellRelocation(DynamicObject *go, Cell new_cell)
GameObjectBySpawnIdContainer _gameobjectBySpawnIdStore
void Respawn(RespawnInfo *info, CharacterDatabaseTransaction dbTrans=nullptr)
void setNGrid(NGridType *grid, uint32 x, uint32 y)
bool IsBattleArena() const
bool ShouldBeSpawnedOnGridLoad(SpawnObjectType type, ObjectGuid::LowType spawnId) const
bool isGridObjectDataLoaded() const
grid_state_t GetGridState(void) const
void decUnloadActiveLock()
void setGridObjectDataLoaded(bool pLoaded)
uint32 GetWorldObjectCountInNGrid() const
void SetGridState(grid_state_t s)
void setUnloadExplicitLock(bool on)
GridType & GetGridType(const uint32 x, const uint32 y)
void incUnloadActiveLock()
GridInfo * getGridInfoRef()
void VisitAllGrids(TypeContainerVisitor< T, TypeMapContainer< TT > > &visitor)
LowType GetCounter() const
static ObjectGuid const Empty
bool IsMOTransport() const
std::string ToString() const
static Creature * ToCreature(Object *o)
uint32 GetUInt32Value(uint16 index) const
static GameObject * ToGameObject(Object *o)
virtual void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const
void SetGuidValue(uint16 index, ObjectGuid value)
virtual void BuildUpdate(UpdateDataMapType &)
static ObjectGuid GetGUID(Object const *o)
void BuildOutOfRangeUpdateBlock(UpdateData *data) const
void SetUInt32Value(uint16 index, uint32 value)
static DynamicObject * ToDynObject(Object *o)
bool HaveAtClient(Object const *u) const
bool IsBeingTeleportedFar() const
void SendDirectMessage(WorldPacket const *data) const
void SendAurasForTarget(Unit *target, bool force=false) const
void Update(uint32 time) override
void UpdateZone(uint32 newZone, uint32 newArea)
GuidUnorderedSet m_clientGUIDs
bool IsLoading() const override
WorldSession * GetSession() const
void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const override
WorldObject * GetViewpoint() const
bool IsGameMaster() const
void SetPendingBind(uint32 instanceId, uint32 bindTimer)
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0)
MapReference & GetMapRef()
uint32 GetBattlegroundId() const
void AddToWorld() override
void UpdateObjectVisibility(bool forced=true) override
void SetMap(Map *map) override
InstancePlayerBind * BindToInstance(InstanceSave *save, bool permanent, BindExtensionState extendState=EXTEND_STATE_NORMAL, bool load=false)
void RemoveFromWorld() override
InstancePlayerBind * GetBoundInstance(uint32 mapid, Difficulty difficulty, bool withExpired=false)
void setUInt16(uint8 index, uint16 value)
void setUInt32(uint8 index, uint32 value)
void setUInt64(uint8 index, uint64 value)
void DelayedUpdate(uint32 diff)
SPECIFIC_TYPE * Find(KEY_TYPE const &handle)
void UpdateObjectVisibility(bool forced=true) override
MotionMaster * GetMotionMaster()
void CleanupsBeforeDelete(bool finalCleanup=true) override
ObjectGuid GetCharmerOrOwnerGUID() const override
void CombatStop(bool includingCast=false, bool mutualPvP=true)
CombatManager & GetCombatManager()
AuraApplicationMap & GetAppliedAuras()
Vehicle * GetVehicleKit() const
ObjectGuid m_SummonSlot[MAX_SUMMON_SLOT]
bool BuildPacket(WorldPacket *packet)
virtual float getHeight(unsigned int pMapId, float x, float y, float z, float maxSearchDist)=0
bool isHeightCalcEnabled() const
virtual bool getAreaAndLiquidData(unsigned int mapId, float x, float y, float z, Optional< uint8 > reqLiquidType, AreaAndLiquidData &data) const =0
static VMapManager2 * createOrGetVMapManager()
void unloadMap(unsigned int mapId, int x, int y) override
int loadMap(char const *pBasePath, unsigned int mapId, int x, int y) override
void RelocatePassengers()
Relocate passengers. Must be called after m_base::Relocate.
virtual void SetPhaseMask(uint32 newPhaseMask, bool update)
uint32 GetPhaseMask() const
void RemoveFromWorld() override
float GetGridActivationRange() const
bool isActiveObject() const
uint32 GetInstanceId() const
std::string const & GetName() const
virtual void SetMap(Map *map)
void DestroyForNearbyPlayers()
Transport * GetTransport() const
void UpdatePositionData()
bool IsStoredInWorldObjectGridContainer() const
bool IsAlwaysStoredInWorldObjectGridContainer() const
virtual void Update(uint32 diff)
virtual void UpdateObjectVisibility(bool forced=true)
virtual void CleanupsBeforeDelete(bool finalCleanup=true)
WorldPacket const * Write() override
int32 TransitionMilliseconds
WorldPacket const * Write() override
Player session in the World.
bool Update(uint32 diff, PacketFilter &updater)
Update the WorldSession (triggered by World update)
void SendCalendarRaidLockoutAdded(InstanceSave const *save)
void AddInstanceEnterTime(uint32 instanceId, SystemTimePoint enterTime)
static float GetMaxVisibleDistanceInInstances()
static int32 GetVisibilityNotifyPeriodOnContinents()
static float GetMaxVisibleDistanceInBG()
static int32 GetVisibilityNotifyPeriodInArenas()
static int32 GetVisibilityNotifyPeriodInBG()
static int32 GetVisibilityNotifyPeriodInInstances()
static float GetMaxVisibleDistanceOnContinents()
static float GetMaxVisibleDistanceInArenas()
@ SMSG_INSTANCE_LOCK_WARNING_QUERY
@ SMSG_INSTANCE_SAVE_CREATED
WeatherData const * GetWeatherData(uint32 zone_id)
static void SendFineWeatherUpdateToPlayer(Player *player)
@ CONFIG_RESPAWN_DYNAMICMINIMUM_CREATURE
@ CONFIG_INSTANCE_UNLOAD_DELAY
@ CONFIG_RESPAWN_DYNAMICMINIMUM_GAMEOBJECT
@ CONFIG_RESPAWN_MINCHECKINTERVALMS
@ CONFIG_RESPAWN_DYNAMICRATE_CREATURE
@ CONFIG_RESPAWN_DYNAMICRATE_GAMEOBJECT
@ CONFIG_CHECK_GOBJECT_LOS
@ CONFIG_DEATH_BONES_BG_OR_ARENA
@ CONFIG_RESPAWN_DYNAMIC_ESCORTNPC
@ CONFIG_DEATH_BONES_WORLD
bool IsPathfindingEnabled(uint32 mapId)
SystemTimePoint GetSystemTime()
Current chrono system_clock time point.
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
void RemoveObject(T *object)
TC_GAME_API Corpse * GetCorpse(WorldObject const &u, ObjectGuid const &guid)
auto MapEqualRange(M &map, typename M::key_type const &key)
GridCoord ComputeGridCoordSimple(float x, float y)
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default TC string format function.
GridCoord ComputeGridCoord(float x, float y)
CellCoord ComputeCellCoord(float x, float y)
@ VMAP_LOAD_RESULT_IGNORED
struct Cell::@256::@257 Part
bool DiffGrid(Cell const &cell) const
bool DiffCell(Cell const &cell) const
static CellArea CalculateCellArea(float x, float y, float radius)
bool IsCoordValid() const
BindExtensionState extendState
void SetInterval(time_t interval)
time_t GetInterval() const
bool IsBattleground() const
bool GetEntrancePos(int32 &mapid, float &x, float &y) const
bool IsNonRaidDungeon() const
bool IsBattlegroundOrArena() const
bool IsBattleArena() const
bool Instanceable() const
void TReset(int32 diff, int32 period)
Optional< LiquidData > liquidInfo
Optional< WmoLocation > wmoLocation
ZLiquidStatus liquidStatus
float GetPositionZ() const
float GetOrientation() const
bool IsPositionValid() const
float GetPositionX() const
float GetPositionY() const
void Relocate(float x, float y)
void resetNotify(GridRefManager< T > &m)
void Visit(PlayerMapType &m)
void Visit(GridRefManager< T > &)
void Visit(CreatureMapType &m)
RespawnInfoWithHandle(RespawnInfo const &other)
RespawnListContainer::handle_type handle
ObjectGuid::LowType spawnId
Optional< AreaInfo > areaInfo
Optional< LiquidInfo > liquidInfo
uint32 TransitionMilliseconds
std::vector< LightOverride > LightOverrides
std::unique_ptr< Weather > DefaultWeather
Represents a map magic value of 4 bytes (used in versions)
uint32 asUInt
Non-null terminated string