65#include <boost/heap/fibonacci_heap.hpp>
68#define DEFAULT_GRID_EXPIRY 300
69#define MAX_GRID_LOAD_TIME 50
70#define MAX_CREATURE_ATTACK_RADIUS (45.0f * sWorld->getRate(RATE_CREATURE_AGGRO))
80struct RespawnListContainer : boost::heap::fibonacci_heap<RespawnInfoWithHandle*, boost::heap::compare<CompareRespawnInfo>>
88 RespawnListContainer::handle_type
handle;
136_creatureToMoveLock(false), _gameObjectsToMoveLock(false), _dynamicObjectsToMoveLock(false), _areaTriggersToMoveLock(false),
137i_mapEntry(
sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode), i_InstanceId(InstanceId),
140m_activeNonPlayersIter(m_activeNonPlayers.end()), _transportsUpdateIter(_transports.end()),
141i_gridExpiry(expiry), m_terrain(
sTerrainMgr.LoadTerrain(id)), m_forceEnabledNavMeshFilterFlags(0), m_forceDisabledNavMeshFilterFlags(0),
142i_scriptLock(false), _respawnTimes(
std::make_unique<
RespawnListContainer>()), _respawnCheckTimer(0), _vignetteUpdateTimer(5200, 5200)
183 if constexpr (WorldTypeMapContainer::TypeExists<T> && GridTypeMapContainer::TypeExists<T>)
186 if (obj->IsStoredInWorldObjectGridContainer())
191 else if constexpr (WorldTypeMapContainer::TypeExists<T>)
193 else if constexpr (GridTypeMapContainer::TypeExists<T>)
196 if constexpr (std::is_base_of_v<MapObject, T>)
197 obj->SetCurrentCell(cell);
396 Cell cell(cellCoord);
443 int32 oldValue = itr->second;
444 if (oldValue == value && !inserted)
450 if (worldStateTemplate)
451 sScriptMgr->OnWorldStateValueChange(worldStateTemplate, oldValue, value,
this);
456 updateWorldState.
Value = value;
457 updateWorldState.
Hidden = hidden;
458 updateWorldState.
Write();
462 if (worldStateTemplate && !worldStateTemplate->
AreaIds.empty())
464 bool isInAllowedArea = std::any_of(worldStateTemplate->
AreaIds.begin(), worldStateTemplate->
AreaIds.end(),
465 [playerAreaId = mapReference.GetSource()->GetAreaId()](
uint32 requiredAreaId) { return DB2Manager::IsInArea(playerAreaId, requiredAreaId); });
466 if (!isInAllowedArea)
470 mapReference.GetSource()->SendDirectMessage(updateWorldState.
GetRawPacket());
480 vignetteUpdate.
Write();
484 ref.GetSource()->SendDirectMessage(vignetteUpdate.
GetRawPacket());
494 vignetteUpdate.
Write();
499 if (ref.GetSource()->GetZoneId() == vignette->
ZoneID)
500 ref.GetSource()->SendDirectMessage(vignetteUpdate.
GetRawPacket());
525 if (obj->IsInWorld())
528 obj->UpdateObjectVisibility(
true);
539 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);
544 obj->setActive(
true);
546 Cell cell(cellCoord);
547 if (obj->isActiveObject())
552 TC_LOG_DEBUG(
"maps",
"Object {} enters grid[{}, {}]", obj->GetGUID().ToString(), cell.
GridX(), cell.
GridY());
560 if (obj->isActiveObject())
565 obj->SetIsNewObject(
true);
566 obj->UpdateObjectVisibilityOnCreate();
567 obj->SetIsNewObject(
false);
594 if (itr->GetSource()->GetTransport() != obj && itr->GetSource()->
InSamePhase(obj))
598 itr->GetSource()->m_visibleTransports.insert(obj->
GetGUID());
601 itr->GetSource()->SendDirectMessage(&packet);
637 Visit(cell, gridVisitor);
638 Visit(cell, worldVisitor);
646 if (oldZone == newZone)
652 ASSERT(oldZoneCount,
"A player left zone %u (went to %u) - but there were no players in the zone!", oldZone, newZone);
670 session->
Update(t_diff, updater);
714 std::vector<Unit*> toVisit;
718 toVisit.push_back(unit);
719 for (
Unit* unit : toVisit)
724 std::unordered_set<Unit*> toVisit;
725 for (std::pair<uint32, AuraApplication*> pair : player->
GetAppliedAuras())
727 if (
Unit* caster = pair.second->GetBase()->GetCaster())
729 toVisit.insert(caster);
731 for (
Unit* unit : toVisit)
736 std::vector<Unit*> toVisit;
743 toVisit.push_back(unit);
745 for (
Unit* unit : toVisit)
773 if (vignette->NeedUpdate)
776 vignette->FillPacket(vignetteUpdate.
Updated);
777 vignetteUpdate.
Write();
780 ref.GetSource()->SendDirectMessage(vignetteUpdate.
GetRawPacket());
782 vignette->NeedUpdate =
false;
802 zoneInfo.second.DefaultWeather.reset();
833 iter->GetSource()->ResetAllNotifies();
873 Visit(cell, grid_object_relocation);
874 Visit(cell, world_object_relocation);
910 Visit(cell, grid_notifier);
911 Visit(cell, world_notifier);
927 bool const inWorld = player->
IsInWorld();
947 obj->RemoveFromWorld();
948 if (obj->isActiveObject())
954 obj->UpdateObjectVisibilityOnDestroy();
956 obj->RemoveFromGrid();
981 if (itr->GetSource()->GetTransport() != obj && itr->GetSource()->m_visibleTransports.count(obj->
GetGUID()))
983 itr->GetSource()->SendDirectMessage(&packet);
984 itr->GetSource()->m_visibleTransports.erase(obj->
GetGUID());
991 TransportsContainer::iterator itr =
_transports.find(obj);
1007template <
typename T>
1010 Cell const& cur_cell =
object->GetCurrentCell();
1011 Cell xy_cell(object->GetPositionX(), object->GetPositionY());
1012 if (xy_cell != cur_cell)
1014 TC_LOG_DEBUG(
"maps",
"{} {} X: {} Y: {} ({}) is in grid[{}, {}]cell[{}, {}] instead of grid[{}, {}]cell[{}, {}]",
1015 objType, object->GetGUID().ToString(),
1016 object->GetPositionX(), object->GetPositionY(), (moved ?
"final" :
"original"),
1030 Cell new_cell(x, y);
1032 player->
Relocate(x, y, z, orientation);
1038 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());
1056 Cell new_cell(x, y);
1066 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());
1087 Cell new_cell(x, y);
1098 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());
1105 go->
Relocate(x, y, z, orientation);
1116 Cell new_cell(x, y);
1127 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());
1134 dynObj->
Relocate(x, y, z, orientation);
1146 Cell new_cell(x, y);
1157 TC_LOG_DEBUG(
"maps",
"AreaTrigger ({}) added to moving list from grid[{}, {}]cell[{}, {}] to grid[{}, {}]cell[{}, {}].", at->
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());
1164 at->
Relocate(x, y, z, orientation);
1356 if (dynObj->
FindMap() !=
this)
1428template <
typename T>
1431 Cell const& old_cell =
object->GetCurrentCell();
1438 TC_LOG_DEBUG(
"maps",
"{} {} moved in grid[{}, {}] from cell[{}, {}] to cell[{}, {}].", objType, object->GetGUID().ToString(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY(), new_cell.
CellX(), new_cell.
CellY());
1441 object->RemoveFromGrid();
1447 TC_LOG_DEBUG(
"maps",
"{} {} moved in same grid[{}, {}]cell[{}, {}].", objType, object->GetGUID().ToString(), old_cell.
GridX(), old_cell.
GridY(), old_cell.
CellX(), old_cell.
CellY());
1455 if (object->isActiveObject())
1460 TC_LOG_DEBUG(
"maps",
"Active {} {} moved from grid[{}, {}]cell[{}, {}] to grid[{}, {}]cell[{}, {}].", objType, object->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());
1463 object->RemoveFromGrid();
1470 if (c->GetCharmerOrOwnerGUID().IsPlayer())
1477 TC_LOG_DEBUG(
"maps",
"{} {} moved from grid[{}, {}]cell[{}, {}] to grid[{}, {}]cell[{}, {}].", objType, object->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());
1480 object->RemoveFromGrid();
1489 TC_LOG_DEBUG(
"maps",
"{} {} attempted to move from grid[{}, {}]cell[{}, {}] to unloaded grid[{}, {}]cell[{}, {}].", objType, object->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());
1516 float resp_x, resp_y, resp_z, resp_o;
1518 Cell resp_cell(resp_x, resp_y);
1528 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());
1534 c->
Relocate(resp_x, resp_y, resp_z, resp_o);
1547 float resp_x, resp_y, resp_z, resp_o;
1549 Cell resp_cell(resp_x, resp_y);
1556 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());
1562 go->
Relocate(resp_x, resp_y, resp_z, resp_o);
1635 TC_LOG_DEBUG(
"maps",
"Unloading grid[{}, {}] for map {} finished", x, y,
GetId());
1645 Player* player = itr->GetSource();
1649 TC_LOG_ERROR(
"maps",
"Map::UnloadAll: player {} is still in map {} during unload, this should not happen!", player->
GetName(),
GetId());
1674 RemoveFromMap<Transport>(transport,
true);
1679 for (
Corpse* corpse : cellCorpsePair.second)
1695 m_terrain->GetFullTerrainStatusForPosition(phaseShift,
GetId(), x, y, z, data, reqLiquidType, collisionHeight, &
_dynamicTree);
1699 float collisionHeight)
1701 return m_terrain->GetLiquidStatus(phaseShift,
GetId(), x, y, z, ReqLiquidType, data, collisionHeight);
1731 return m_terrain->GetStaticHeight(phaseShift,
GetId(), x, y, z, checkVMap, maxSearchDist);
1757 && !
VMAP::VMapFactory::createOrGetVMapManager()->
isInLineOfSight(
PhasingHandler::GetTerrainMapId(phaseShift,
GetId(),
m_terrain.get(), x1, y1), x1, y1, z1, x2, y2, z2, ignoreFlags))
1765bool Map::getObjectHitPos(
PhaseShift const& phaseShift,
float x1,
float y1,
float z1,
float x2,
float y2,
float z2,
float& rx,
float& ry,
float& rz,
float modifyDist)
1767 G3D::Vector3 startPos(x1, y1, z1);
1768 G3D::Vector3 dstPos(x2, y2, z2);
1770 G3D::Vector3 resultPos;
1813 uint32 instanceIdToCheck =
sMapMgr->FindInstanceIdForPlayer(mapid, player);
1814 if (
Map* boundMap =
sMapMgr->FindMap(mapid, instanceIdToCheck))
1840 transport->BuildCreateUpdateBlockForPlayer(&data, player);
1849 for (
WorldObject* passenger : transport->GetPassengers())
1850 if (player != passenger && player->
HaveAtClient(passenger))
1851 passenger->BuildCreateUpdateBlockForPlayer(&data, player);
1866 transport->BuildCreateUpdateBlockForPlayer(&transData, player);
1887 transport->BuildOutOfRangeUpdateBlock(&transData);
1906 if (!transport->IsInWorld())
1914 transport->BuildCreateUpdateBlockForPlayer(&transData, player);
1920 transport->BuildOutOfRangeUpdateBlock(&transData);
1937 TC_LOG_ERROR(
"maps",
"map::setNGrid() Invalid grid coordinates found: {}, {}!", x, y);
1956 for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
1958 iter->second.BuildPacket(&packet);
1959 iter->first->SendDirectMessage(&packet);
1981 bool alreadyExists =
false;
1990 for (
auto it = range.first; it != range.second; ++it)
1998 alreadyExists =
true;
2006 alreadyExists =
true;
2026 if (linkedTime == std::numeric_limits<time_t>::max())
2027 respawnTime = linkedTime;
2028 else if (
sObjectMgr->GetLinkedRespawnGuid(thisGUID) == thisGUID)
2029 respawnTime = now +
WEEK;
2031 respawnTime = std::max<time_t>(now, linkedTime) +
urand(5, 15);
2050 std::vector<WorldObject*> toUnload;
2055 toUnload.push_back(pair.second);
2059 toUnload.push_back(pair.second);
2068 return toUnload.size();
2086 auto it = bySpawnIdMap->find(info.
spawnId);
2087 if (it != bySpawnIdMap->end())
2095 ASSERT(bySpawnIdMap->find(info.
spawnId) == bySpawnIdMap->end(),
"Insertion of respawn info with id (%u," UI64FMTD ") into spawn id map failed - state desync.",
uint32(info.
type), info.
spawnId);
2102 bySpawnIdMap->emplace(ri->
spawnId, ri);
2108 data.reserve(data.size() + map.size());
2109 for (
auto const& pair : map)
2110 data.push_back(pair.second);
2126 auto it = map->find(spawnId);
2127 if (it == map->end())
2151 auto range = spawnMap->equal_range(info->
spawnId);
2152 auto it = std::find_if(range.first, range.second, [info](RespawnInfoMap::value_type
const& pair) { return (pair.second == info); });
2154 spawnMap->erase(it);
2189 if (!obj->
LoadFromDB(spawnId,
this,
true,
true))
2211 if (now < next->respawnTime)
2249 ASSERT(now < next->respawnTime);
2287 uint32 const playerCount = it->second;
2291 if (adjustFactor >= 1.0)
2294 if (respawnDelay <= timeMinimum)
2297 respawnDelay = std::max<uint32>(ceil(respawnDelay * adjustFactor), timeMinimum);
2315 if (!
GetPoolData().IsSpawnedObject(type, spawnId))
2334 TC_LOG_ERROR(
"maps",
"Tried to spawn non-existing (or system) spawn group {} on map {}. Blocked.", groupId,
GetId());
2340 std::vector<SpawnData const*> toSpawn;
2341 for (
auto& pair :
sObjectMgr->GetSpawnMetadataForGroup(groupId))
2350 if (force || ignoreRespawn)
2373 if (std::find(data->spawnDifficulties.begin(), data->spawnDifficulties.end(),
GetDifficultyID()) == data->spawnDifficulties.end())
2386 if (!creature->
LoadFromDB(data->spawnId,
this,
true, force))
2388 else if (spawnedObjects)
2389 spawnedObjects->push_back(creature);
2395 if (!gameobject->
LoadFromDB(data->spawnId,
this,
true))
2397 else if (spawnedObjects)
2398 spawnedObjects->push_back(gameobject);
2404 if (!areaTrigger->
LoadFromDB(data->spawnId,
this,
true,
false))
2406 else if (spawnedObjects)
2407 spawnedObjects->push_back(areaTrigger);
2423 TC_LOG_ERROR(
"maps",
"Tried to despawn non-existing (or system) spawn group {} on map {}. Blocked.", groupId,
GetId());
2427 for (
auto const& pair :
sObjectMgr->GetSpawnMetadataForGroup(groupId))
2431 if (deleteRespawnTimes)
2446 TC_LOG_ERROR(
"maps",
"Tried to set non-existing (or system) spawn group {} to {} on map {}. Blocked.", groupId, state ?
"active" :
"inactive",
GetId());
2460 TC_LOG_ERROR(
"maps",
"Tried to query state of non-existing spawn group {} on map {}.", groupId,
GetId());
2471 std::vector<uint32>
const* spawnGroups =
sObjectMgr->GetSpawnGroupsForMap(
GetId());
2475 for (
uint32 spawnGroupId : *spawnGroups)
2487 std::vector<uint32>
const* spawnGroups =
sObjectMgr->GetSpawnGroupsForMap(
GetId());
2491 for (
uint32 spawnGroupId : *spawnGroups)
2507 if (isActive == shouldBeActive)
2523 itr =
_guidGenerators.insert(std::make_pair(high, std::make_unique<ObjectGuidGenerator>(high))).first;
2525 return *itr->second;
2553 GridInfo* info = i->GetSource()->getGridInfoRef();
2582 else if (itr->second != on)
2594 bool on = itr->second;
2602 SwitchGridContainers<Creature>(obj->
ToCreature(), on);
2652 TC_LOG_ERROR(
"maps",
"Non-grid object (TypeId: {}) is in grid object remove list, ignored.", obj->
GetTypeId());
2666 if (!itr->GetSource()->IsGameMaster())
2674 itr->GetSource()->SendDirectMessage(data);
2686 cell_min.
dec_x(cell_range);
2687 cell_min.
dec_y(cell_range);
2688 cell_max.
inc_x(cell_range);
2689 cell_max.
inc_y(cell_range);
2693 Player* player = iter->GetSource();
2724 respawnLocation.emplace();
2725 creature->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
2731 respawnLocation.emplace();
2732 gameObject->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
2739 if (respawnLocation)
2747 TC_LOG_ERROR(
"maps",
"Active object {} added to grid[{}, {}] but spawn grid[{}, {}] was not loaded.",
2763 respawnLocation.emplace();
2764 creature->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
2770 respawnLocation.emplace();
2771 gameObject->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
2778 if (respawnLocation)
2786 TC_LOG_ERROR(
"maps",
"Active object {} removed from to grid[{}, {}] but spawn grid[{}, {}] was not loaded.",
2812 :
Map(id, expiry, InstanceId, SpawnMode),
2813 i_data(nullptr), i_script_id(0), i_scenario(nullptr), i_instanceLock(instanceLock), i_lfgDungeonsId(lfgDungeonsId)
2898 if (!entries.MapDifficulty->IsUsingEncounterLocks())
2908 pendingRaidLock.
WarningOnly = entries.Map->IsFlexLocking();
2910 if (!entries.Map->IsFlexLocking())
2999 if (!lockData->
Data.empty())
3030 ref.GetSource()->SendResetFailedNotify(
GetId());
3041 raidInstanceMessage.
Write();
3044 ref.GetSource()->SendDirectMessage(raidInstanceMessage.
GetRawPacket());
3053 pendingRaidLock.
Write();
3057 ref.GetSource()->SendDirectMessage(pendingRaidLock.
GetRawPacket());
3095 if (entries.IsInstanceIdBound())
3101 Player* player = mapReference.GetSource();
3107 std::string
const* oldData =
nullptr;
3108 uint32 playerCompletedEncounters = 0;
3115 bool isNewLock = !playerLock || playerLock->
IsNew() || playerLock->
IsExpired();
3145 if (entries.IsInstanceIdBound())
3147 instanceCompletedEncounters,
nullptr, {}));
3151 Player* player = mapReference.GetSource();
3157 std::string
const* oldData =
nullptr;
3161 bool isNewLock = !playerLock || playerLock->
IsNew() || playerLock->
IsExpired();
3165 instanceCompletedEncounters,
nullptr, {}));
3186 bool isNewLock = !playerLock || playerLock->
IsNew() || playerLock->
IsExpired();
3370 :
Map(id, expiry, InstanceId, spawnMode), m_bg(nullptr), _battlegroundScript(nullptr), _scriptId(0)
3461 if (
Player* player = itr->GetSource())
3462 if (!player->IsBeingTeleportedFar())
3463 player->TeleportTo(player->GetBattlegroundEntryPoint());
3529 if (bounds.first == bounds.second)
3532 std::unordered_multimap<ObjectGuid::LowType, Creature*>::const_iterator creatureItr = std::find_if(bounds.first, bounds.second, [](Map::CreatureBySpawnIdContainer::value_type
const& pair)
3534 return pair.second->IsAlive();
3537 return creatureItr != bounds.second ? creatureItr->second : bounds.first->second;
3543 if (bounds.first == bounds.second)
3546 std::unordered_multimap<ObjectGuid::LowType, GameObject*>::const_iterator creatureItr = std::find_if(bounds.first, bounds.second, [](Map::GameObjectBySpawnIdContainer::value_type
const& pair)
3548 return pair.second->isSpawned();
3551 return creatureItr != bounds.second ? creatureItr->second : bounds.first->second;
3557 if (bounds.first == bounds.second)
3560 return bounds.first->second;
3574 TC_LOG_ERROR(
"maps",
"Map {} attempt to save respawn time for nonexistant spawnid ({},{}).",
GetId(), type, spawnId);
3596 TC_LOG_ERROR(
"maps",
"Attempt to load saved respawn {} for ({},{}) failed - duplicate respawn? Skipped.", respawnTime,
uint32(type), spawnId);
3628 Field* fields = result->Fetch();
3631 time_t respawnTime = fields[2].
GetInt64();
3638 TC_LOG_ERROR(
"maps",
"Loading saved respawn time of {} for spawnid ({},{}) - spawn does not exist, ignoring", respawnTime,
uint32(type), spawnId);
3642 TC_LOG_ERROR(
"maps",
"Loading saved respawn time of {} for spawnid ({},{}) - invalid spawn type, ignoring", respawnTime,
uint32(type), spawnId);
3645 }
while (result->NextRow());
3688 std::unordered_map<ObjectGuid::LowType, std::unordered_set<uint32>> phases;
3689 std::unordered_map<ObjectGuid::LowType, std::vector<UF::ChrCustomizationChoice>> customizations;
3701 Field* fields = phaseResult->Fetch();
3705 phases[guid].insert(phaseId);
3707 }
while (phaseResult->NextRow());
3720 Field* fields = customizationResult->Fetch();
3722 std::vector<UF::ChrCustomizationChoice>& customizationsForCorpse = customizations[guid];
3724 customizationsForCorpse.emplace_back();
3729 }
while (customizationResult->NextRow());
3734 Field* fields = result->Fetch();
3739 TC_LOG_ERROR(
"misc",
"Corpse (guid: {}) have wrong corpse type ({}), not loading.", guid, type);
3744 if (!corpse->
LoadCorpseFromDB(GenerateLowGuid<HighGuid::Corpse>(), fields))
3750 for (
uint32 phaseId : phases[guid])
3757 }
while (result->NextRow());
3861 std::vector<ObjectGuid> corpses;
3865 if (p.second->IsExpired(now))
3866 corpses.push_back(p.first);
3871 std::vector<Corpse*> expiredBones;
3873 if (bones->IsExpired(now))
3874 expiredBones.push_back(bones);
3876 for (
Corpse* bones : expiredBones)
3889 if (
uint32 music = itr->second.MusicId)
3925 zoneDynamicInfo.
DefaultWeather->SendWeatherUpdateToPlayer(player);
3942 if (
Player* player = itr->GetSource())
3957 info.
DefaultWeather = std::make_unique<Weather>(zoneId, weatherData);
3968 if (zoneDynamicInfo)
3993 if (
Player* player = itr->GetSource())
3994 if (player->GetZoneId() == zoneId)
4005 return lightOverride.AreaLightId == areaLightId;
4009 if (overrideLightId)
4024 overrideLight.
Write();
4027 if (
Player* player = itr->GetSource())
4028 if (player->GetZoneId() == zoneId)
4029 player->SendDirectMessage(overrideLight.
GetRawPacket());
4038 if (
Player* player = itr->GetSource())
4040 if (player->IsInWorld())
4042 player->UpdateAreaDependentAuras(player->GetAreaId());
4043 player->UpdateZoneDependentAuras(player->GetZoneId());
4051 std::stringstream sstr;
4052 sstr << std::boolalpha
4060 std::stringstream sstr;
@ CHAR_SEL_CORPSE_CUSTOMIZATIONS
@ CHAR_DEL_CORPSES_FROM_MAP
@ CONDITION_SOURCE_TYPE_SPAWN_GROUP
DB2Storage< DifficultyEntry > sDifficultyStore("Difficulty.db2", &DifficultyLoadInfo::Instance)
DB2Storage< MapEntry > sMapStore("Map.db2", &MapLoadInfo::Instance)
@ DIFFICULTY_LFR_15TH_ANNIVERSARY
@ DIFFICULTY_MYTHIC_KEYSTONE
@ DIFFICULTY_3_MAN_SCENARIO_HC
@ DIFFICULTY_TIMEWALKING_RAID
@ DIFFICULTY_NORMAL_WARFRONT
@ DIFFICULTY_NORMAL_ISLAND
@ DIFFICULTY_FLAG_DISPLAY_MYTHIC
@ DIFFICULTY_FLAG_DISPLAY_HEROIC
@ IgnoreInstanceFarmLimit
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
std::unordered_set< uint32 > params[2]
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
#define ASSERT_NOTNULL(pointer)
NGrid< MAX_NUMBER_OF_CELLS, Player, WorldTypeMapContainer, GridTypeMapContainer > NGridType
#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
#define TC_LOG_DEBUG(filterType__, message__,...)
#define TC_LOG_ERROR(filterType__, message__,...)
#define TC_LOG_WARN(filterType__, message__,...)
@ MAP_OBJECT_CELL_MOVE_INACTIVE
@ MAP_OBJECT_CELL_MOVE_ACTIVE
@ MAP_OBJECT_CELL_MOVE_NONE
static void PushRespawnInfoFrom(std::vector< RespawnInfo const * > &data, RespawnInfoMap const &map)
GridState * si_GridStates[MAX_GRID_STATE]
std::unordered_map< ObjectGuid::LowType, RespawnInfo * > RespawnInfoMap
@ TRANSFER_ABORT_TOO_MANY_INSTANCES
@ TRANSFER_ABORT_DIFFICULTY
@ TRANSFER_ABORT_MAP_NOT_ALLOWED
@ TRANSFER_ABORT_MAX_PLAYERS
@ TRANSFER_ABORT_ZONE_IN_COMBAT
@ TRANSFER_ABORT_LOCKED_TO_DIFFERENT_INSTANCE
@ TRANSFER_ABORT_NEED_GROUP
#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)
@ LINEOFSIGHT_CHECK_GOBJECT
@ WS_TEAM_IN_INSTANCE_ALLIANCE
@ WS_TEAM_IN_INSTANCE_HORDE
@ SPAWNGROUP_FLAG_DYNAMIC_SPAWN_RATE
@ SPAWNGROUP_FLAG_MANUAL_SPAWN
@ SPAWNGROUP_FLAG_DESPAWN_ON_CONDITION_FAILURE
@ SPAWNGROUP_FLAG_ESCORTQUESTNPC
@ SPAWN_TYPEMASK_CREATURE
@ SPAWN_TYPEMASK_GAMEOBJECT
@ SPELL_AURA_FORCE_WEATHER
bool LoadFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap, bool allowDuplicate)
TransferAbortParams CannotEnter(Player *player) override
BattlegroundMap(uint32 id, time_t, uint32 InstanceId, Difficulty spawnMode)
void RemoveAllPlayers() override
std::unique_ptr< BattlegroundScript > _battlegroundScript
Battleground * GetBG() const
std::string const & GetScriptName() const
bool AddPlayerToMap(Player *player, bool initPlayer=true) override
void RemovePlayerFromMap(Player *, bool) override
virtual void InitVisibilityDistance() override
void Update(uint32 diff) override
void SetBgMap(BattlegroundMap *map)
std::unordered_map< ObjectGuid, CombatReference * > const & GetPvECombatRefs() const
void ReplaceAllFlags(uint32 flags)
void SetClass(uint8 playerClass)
void SetGuildGUID(ObjectGuid guildGuid)
void SetDisplayId(uint32 displayId)
void SetCustomizations(Trinity::IteratorPair< Iter > customizations)
CorpseDynFlags GetCorpseDynamicFlags() const
void SetFactionTemplate(int32 factionTemplate)
void RemoveFromWorld() override
void SetOwnerGUID(ObjectGuid owner)
void SetPartyGUID(ObjectGuid partyGuid)
UF::UpdateField< UF::CorpseData, int32(WowCS::EntityFragment::CGObject), TYPEID_CORPSE > m_corpseData
CellCoord const & GetCellCoord() const
void ReplaceAllCorpseDynamicFlags(CorpseDynFlags dynamicFlags)
ObjectGuid GetOwnerGUID() const override
bool LoadCorpseFromDB(ObjectGuid::LowType guid, Field *fields)
void SetCellCoord(CellCoord const &cellCoord)
bool Create(ObjectGuid::LowType guidlow, Map *map)
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 isInLineOfSight(G3D::Vector3 const &startPos, G3D::Vector3 const &endPos, PhaseShift const &phaseShift) const
bool getObjectHitPos(G3D::Vector3 const &startPos, G3D::Vector3 const &endPos, G3D::Vector3 &resultHitPos, float modifyDist, PhaseShift const &phaseShift) const
Class used to access individual fields of database query result.
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
Transport * ToTransport()
void AddToWorld() override
PeriodicTimer & getRelocationTimer()
virtual void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const =0
void AddGridObject(SPECIFIC_OBJECT *obj)
void AddWorldObject(SPECIFIC_OBJECT *obj)
virtual InstanceLockData const * GetInstanceInitializationData() const
void SetInUse(bool inUse)
InstanceResetTimePoint GetExpiryTime() const
InstanceLockData * GetData()
Optional< SystemTimePoint > i_instanceExpireEvent
InstanceLock * i_instanceLock
TransferAbortParams CannotEnter(Player *player) override
void Update(uint32) override
InstanceResetResult Reset(InstanceResetMethod method)
TeamId GetTeamIdInInstance() const
InstanceScenario * i_scenario
void TrySetOwningGroup(Group *group)
void CreateInstanceLockForPlayer(Player *player)
uint32 GetMaxPlayers() const
virtual void InitVisibilityDistance() override
uint32 GetScriptId() const
void RemovePlayerFromMap(Player *, bool) override
InstanceMap(uint32 id, time_t, uint32 InstanceId, Difficulty SpawnMode, TeamId InstanceTeam, InstanceLock *instanceLock, Optional< uint32 > lfgDungeonsId)
GroupInstanceReference i_owningGroupRef
bool AddPlayerToMap(Player *player, bool initPlayer=true) override
std::string const & GetScriptName() const
std::string GetDebugInfo() const override
void CreateInstanceData()
InstanceScript * GetInstanceScript()
void UpdateInstanceLock(UpdateBossStateSaveDataEvent const &updateSaveDataEvent)
std::string GetSaveData()
Optional< uint32 > GetEntranceLocationForCompletedEncounters(uint32 completedEncountersMask) const
void Load(char const *data)
virtual void OnPlayerLeave(Player *)
void UpdateCombatResurrection(uint32 diff)
void SetEntranceLocation(uint32 worldSafeLocationId)
std::string UpdateAdditionalSaveData(std::string const &oldData, UpdateAdditionalSaveDataEvent const &event)
virtual void OnPlayerEnter(Player *)
virtual void Update(uint32)
std::string UpdateBossStateSaveData(std::string const &oldData, UpdateBossStateSaveDataEvent const &event)
MapObjectCellMoveState _moveState
void SetNewCellPosition(float x, float y, float z, float o)
Cell const & GetCurrentCell() 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
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)
ZLiquidStatus GetLiquidStatus(PhaseShift const &phaseShift, float x, float y, float z, Optional< map_liquidHeaderTypeFlags > ReqLiquidType={}, LiquidData *data=nullptr, float collisionHeight=2.03128f)
void SetZoneMusic(uint32 zoneId, uint32 musicId)
bool IsBattlegroundOrArena() const
void RemoveInfiniteAOIVignette(Vignettes::VignetteData *vignette)
bool UnloadGrid(NGridType &ngrid, bool pForce)
void SetSpawnGroupInactive(uint32 groupId)
std::unordered_map< ObjectGuid, Corpse * > _corpsesByPlayer
void UpdateSpawnGroupConditions()
void SetZoneWeather(uint32 zoneId, WeatherState weatherId, float intensity)
Pet * GetPet(ObjectGuid const &guid)
MapStoredObjectTypesContainer & GetObjectsStore()
TransportsContainer::iterator _transportsUpdateIter
void InitializeObject(T *obj)
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)
virtual bool AddPlayerToMap(Player *player, bool initPlayer=true)
void MoveAllGameObjectsInMoveList()
Creature * GetCreatureBySpawnId(ObjectGuid::LowType spawnId) const
void RemoveAreaTriggerFromMoveList(AreaTrigger *at)
void RemoveFromActiveHelper(WorldObject *obj)
void DeleteRespawnInfoFromDB(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans=nullptr)
size_t DespawnAll(SpawnObjectType type, ObjectGuid::LowType spawnId)
void AddAreaTriggerToMoveList(AreaTrigger *at, float x, float y, float z, float ang)
std::function< void(Map *)> FarSpellCallback
void SetSpawnGroupActive(uint32 groupId, bool state)
void LoadGrid(float x, float y)
bool IsUnderWater(PhaseShift const &phaseShift, float x, float y, float z)
void SendZoneDynamicInfo(uint32 zoneId, Player *player) const
void RemoveFromActive(WorldObject *obj)
MapDifficultyEntry const * GetMapDifficulty() const
PeriodicTimer _vignetteUpdateTimer