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 (obj->IsStoredInWorldObjectGridContainer())
426 Cell cell(cellCoord);
473 int32 oldValue = itr->second;
474 if (oldValue == value && !inserted)
480 if (worldStateTemplate)
481 sScriptMgr->OnWorldStateValueChange(worldStateTemplate, oldValue, value,
this);
486 updateWorldState.
Value = value;
487 updateWorldState.
Hidden = hidden;
488 updateWorldState.
Write();
492 if (worldStateTemplate && !worldStateTemplate->
AreaIds.empty())
494 bool isInAllowedArea = std::any_of(worldStateTemplate->
AreaIds.begin(), worldStateTemplate->
AreaIds.end(),
495 [playerAreaId = mapReference.GetSource()->GetAreaId()](
uint32 requiredAreaId) { return DB2Manager::IsInArea(playerAreaId, requiredAreaId); });
496 if (!isInAllowedArea)
500 mapReference.GetSource()->SendDirectMessage(updateWorldState.
GetRawPacket());
510 vignetteUpdate.
Write();
514 ref.GetSource()->SendDirectMessage(vignetteUpdate.
GetRawPacket());
524 vignetteUpdate.
Write();
529 if (ref.GetSource()->GetZoneId() == vignette->
ZoneID)
530 ref.GetSource()->SendDirectMessage(vignetteUpdate.
GetRawPacket());
555 if (obj->IsInWorld())
558 obj->UpdateObjectVisibility(
true);
569 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);
574 obj->setActive(
true);
576 Cell cell(cellCoord);
577 if (obj->isActiveObject())
582 TC_LOG_DEBUG(
"maps",
"Object {} enters grid[{}, {}]", obj->GetGUID().ToString(), cell.
GridX(), cell.
GridY());
590 if (obj->isActiveObject())
595 obj->SetIsNewObject(
true);
596 obj->UpdateObjectVisibilityOnCreate();
597 obj->SetIsNewObject(
false);
624 if (itr->GetSource()->GetTransport() != obj && itr->GetSource()->
InSamePhase(obj))
628 itr->GetSource()->m_visibleTransports.insert(obj->
GetGUID());
631 itr->GetSource()->SendDirectMessage(&packet);
667 Visit(cell, gridVisitor);
668 Visit(cell, worldVisitor);
676 if (oldZone == newZone)
682 ASSERT(oldZoneCount,
"A player left zone %u (went to %u) - but there were no players in the zone!", oldZone, newZone);
700 session->
Update(t_diff, updater);
744 std::vector<Unit*> toVisit;
748 toVisit.push_back(unit);
749 for (
Unit* unit : toVisit)
754 std::unordered_set<Unit*> toVisit;
755 for (std::pair<uint32, AuraApplication*> pair : player->
GetAppliedAuras())
757 if (
Unit* caster = pair.second->GetBase()->GetCaster())
759 toVisit.insert(caster);
761 for (
Unit* unit : toVisit)
766 std::vector<Unit*> toVisit;
773 toVisit.push_back(unit);
775 for (
Unit* unit : toVisit)
803 if (vignette->NeedUpdate)
806 vignette->FillPacket(vignetteUpdate.
Updated);
807 vignetteUpdate.
Write();
810 ref.GetSource()->SendDirectMessage(vignetteUpdate.
GetRawPacket());
812 vignette->NeedUpdate =
false;
832 zoneInfo.second.DefaultWeather.reset();
863 iter->GetSource()->ResetAllNotifies();
903 Visit(cell, grid_object_relocation);
904 Visit(cell, world_object_relocation);
940 Visit(cell, grid_notifier);
941 Visit(cell, world_notifier);
957 bool const inWorld = player->
IsInWorld();
977 obj->RemoveFromWorld();
978 if (obj->isActiveObject())
984 obj->UpdateObjectVisibilityOnDestroy();
986 obj->RemoveFromGrid();
1011 if (itr->GetSource()->GetTransport() != obj && itr->GetSource()->m_visibleTransports.count(obj->
GetGUID()))
1013 itr->GetSource()->SendDirectMessage(&packet);
1014 itr->GetSource()->m_visibleTransports.erase(obj->
GetGUID());
1021 TransportsContainer::iterator itr =
_transports.find(obj);
1037template <
typename T>
1040 Cell const& cur_cell =
object->GetCurrentCell();
1041 Cell xy_cell(object->GetPositionX(), object->GetPositionY());
1042 if (xy_cell != cur_cell)
1044 TC_LOG_DEBUG(
"maps",
"{} {} X: {} Y: {} ({}) is in grid[{}, {}]cell[{}, {}] instead of grid[{}, {}]cell[{}, {}]",
1045 objType, object->GetGUID().ToString(),
1046 object->GetPositionX(), object->GetPositionY(), (moved ?
"final" :
"original"),
1060 Cell new_cell(x, y);
1062 player->
Relocate(x, y, z, orientation);
1068 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());
1086 Cell new_cell(x, y);
1096 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());
1117 Cell new_cell(x, y);
1128 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());
1135 go->
Relocate(x, y, z, orientation);
1146 Cell new_cell(x, y);
1157 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());
1164 dynObj->
Relocate(x, y, z, orientation);
1176 Cell new_cell(x, y);
1187 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());
1194 at->
Relocate(x, y, z, orientation);
1386 if (dynObj->
FindMap() !=
this)
1458template <
typename T>
1461 Cell const& old_cell =
object->GetCurrentCell();
1468 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());
1471 object->RemoveFromGrid();
1477 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());
1485 if (object->isActiveObject())
1490 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());
1493 object->RemoveFromGrid();
1500 if (c->GetCharmerOrOwnerGUID().IsPlayer())
1507 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());
1510 object->RemoveFromGrid();
1519 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());
1546 float resp_x, resp_y, resp_z, resp_o;
1548 Cell resp_cell(resp_x, resp_y);
1558 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());
1564 c->
Relocate(resp_x, resp_y, resp_z, resp_o);
1577 float resp_x, resp_y, resp_z, resp_o;
1579 Cell resp_cell(resp_x, resp_y);
1586 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());
1592 go->
Relocate(resp_x, resp_y, resp_z, resp_o);
1665 TC_LOG_DEBUG(
"maps",
"Unloading grid[{}, {}] for map {} finished", x, y,
GetId());
1675 Player* player = itr->GetSource();
1679 TC_LOG_ERROR(
"maps",
"Map::UnloadAll: player {} is still in map {} during unload, this should not happen!", player->
GetName(),
GetId());
1704 RemoveFromMap<Transport>(transport,
true);
1709 for (
Corpse* corpse : cellCorpsePair.second)
1725 m_terrain->GetFullTerrainStatusForPosition(phaseShift,
GetId(), x, y, z, data, reqLiquidType, collisionHeight, &
_dynamicTree);
1729 float collisionHeight)
1731 return m_terrain->GetLiquidStatus(phaseShift,
GetId(), x, y, z, ReqLiquidType, data, collisionHeight);
1761 return m_terrain->GetStaticHeight(phaseShift,
GetId(), x, y, z, checkVMap, maxSearchDist);
1787 && !
VMAP::VMapFactory::createOrGetVMapManager()->
isInLineOfSight(
PhasingHandler::GetTerrainMapId(phaseShift,
GetId(),
m_terrain.get(), x1, y1), x1, y1, z1, x2, y2, z2, ignoreFlags))
1795bool 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)
1797 G3D::Vector3 startPos(x1, y1, z1);
1798 G3D::Vector3 dstPos(x2, y2, z2);
1800 G3D::Vector3 resultPos;
1843 uint32 instanceIdToCheck =
sMapMgr->FindInstanceIdForPlayer(mapid, player);
1844 if (
Map* boundMap =
sMapMgr->FindMap(mapid, instanceIdToCheck))
1870 transport->BuildCreateUpdateBlockForPlayer(&data, player);
1879 for (
WorldObject* passenger : transport->GetPassengers())
1880 if (player != passenger && player->
HaveAtClient(passenger))
1881 passenger->BuildCreateUpdateBlockForPlayer(&data, player);
1896 transport->BuildCreateUpdateBlockForPlayer(&transData, player);
1914 transport->BuildOutOfRangeUpdateBlock(&transData);
1930 if (!transport->IsInWorld())
1938 transport->BuildCreateUpdateBlockForPlayer(&transData, player);
1944 transport->BuildOutOfRangeUpdateBlock(&transData);
1958 TC_LOG_ERROR(
"maps",
"map::setNGrid() Invalid grid coordinates found: {}, {}!", x, y);
1977 for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
1979 iter->second.BuildPacket(&packet);
1980 iter->first->SendDirectMessage(&packet);
2002 bool alreadyExists =
false;
2011 for (
auto it = range.first; it != range.second; ++it)
2019 alreadyExists =
true;
2027 alreadyExists =
true;
2047 if (linkedTime == std::numeric_limits<time_t>::max())
2048 respawnTime = linkedTime;
2049 else if (
sObjectMgr->GetLinkedRespawnGuid(thisGUID) == thisGUID)
2050 respawnTime = now +
WEEK;
2052 respawnTime = std::max<time_t>(now, linkedTime) +
urand(5, 15);
2071 std::vector<WorldObject*> toUnload;
2076 toUnload.push_back(pair.second);
2080 toUnload.push_back(pair.second);
2089 return toUnload.size();
2107 auto it = bySpawnIdMap->find(info.
spawnId);
2108 if (it != bySpawnIdMap->end())
2116 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);
2123 bySpawnIdMap->emplace(ri->
spawnId, ri);
2129 data.reserve(data.size() + map.size());
2130 for (
auto const& pair : map)
2131 data.push_back(pair.second);
2147 auto it = map->find(spawnId);
2148 if (it == map->end())
2172 auto range = spawnMap->equal_range(info->
spawnId);
2173 auto it = std::find_if(range.first, range.second, [info](RespawnInfoMap::value_type
const& pair) { return (pair.second == info); });
2175 spawnMap->erase(it);
2210 if (!obj->
LoadFromDB(spawnId,
this,
true,
true))
2232 if (now < next->respawnTime)
2270 ASSERT(now < next->respawnTime);
2308 uint32 const playerCount = it->second;
2312 if (adjustFactor >= 1.0)
2315 if (respawnDelay <= timeMinimum)
2318 respawnDelay = std::max<uint32>(ceil(respawnDelay * adjustFactor), timeMinimum);
2336 if (!
GetPoolData().IsSpawnedObject(type, spawnId))
2355 TC_LOG_ERROR(
"maps",
"Tried to spawn non-existing (or system) spawn group {} on map {}. Blocked.", groupId,
GetId());
2361 std::vector<SpawnData const*> toSpawn;
2362 for (
auto& pair :
sObjectMgr->GetSpawnMetadataForGroup(groupId))
2371 if (force || ignoreRespawn)
2394 if (std::find(data->spawnDifficulties.begin(), data->spawnDifficulties.end(),
GetDifficultyID()) == data->spawnDifficulties.end())
2407 if (!creature->
LoadFromDB(data->spawnId,
this,
true, force))
2409 else if (spawnedObjects)
2410 spawnedObjects->push_back(creature);
2416 if (!gameobject->
LoadFromDB(data->spawnId,
this,
true))
2418 else if (spawnedObjects)
2419 spawnedObjects->push_back(gameobject);
2425 if (!areaTrigger->
LoadFromDB(data->spawnId,
this,
true,
false))
2427 else if (spawnedObjects)
2428 spawnedObjects->push_back(areaTrigger);
2444 TC_LOG_ERROR(
"maps",
"Tried to despawn non-existing (or system) spawn group {} on map {}. Blocked.", groupId,
GetId());
2448 for (
auto const& pair :
sObjectMgr->GetSpawnMetadataForGroup(groupId))
2452 if (deleteRespawnTimes)
2467 TC_LOG_ERROR(
"maps",
"Tried to set non-existing (or system) spawn group {} to {} on map {}. Blocked.", groupId, state ?
"active" :
"inactive",
GetId());
2481 TC_LOG_ERROR(
"maps",
"Tried to query state of non-existing spawn group {} on map {}.", groupId,
GetId());
2492 std::vector<uint32>
const* spawnGroups =
sObjectMgr->GetSpawnGroupsForMap(
GetId());
2496 for (
uint32 spawnGroupId : *spawnGroups)
2508 std::vector<uint32>
const* spawnGroups =
sObjectMgr->GetSpawnGroupsForMap(
GetId());
2512 for (
uint32 spawnGroupId : *spawnGroups)
2528 if (isActive == shouldBeActive)
2544 itr =
_guidGenerators.insert(std::make_pair(high, std::make_unique<ObjectGuidGenerator>(high))).first;
2546 return *itr->second;
2574 GridInfo* info = i->GetSource()->getGridInfoRef();
2603 else if (itr->second != on)
2615 bool on = itr->second;
2623 SwitchGridContainers<Creature>(obj->
ToCreature(), on);
2673 TC_LOG_ERROR(
"maps",
"Non-grid object (TypeId: {}) is in grid object remove list, ignored.", obj->
GetTypeId());
2687 if (!itr->GetSource()->IsGameMaster())
2695 itr->GetSource()->SendDirectMessage(data);
2707 cell_min.
dec_x(cell_range);
2708 cell_min.
dec_y(cell_range);
2709 cell_max.
inc_x(cell_range);
2710 cell_max.
inc_y(cell_range);
2714 Player* player = iter->GetSource();
2745 respawnLocation.emplace();
2746 creature->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
2752 respawnLocation.emplace();
2753 gameObject->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
2760 if (respawnLocation)
2768 TC_LOG_ERROR(
"maps",
"Active object {} added to grid[{}, {}] but spawn grid[{}, {}] was not loaded.",
2784 respawnLocation.emplace();
2785 creature->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
2791 respawnLocation.emplace();
2792 gameObject->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
2799 if (respawnLocation)
2807 TC_LOG_ERROR(
"maps",
"Active object {} removed from to grid[{}, {}] but spawn grid[{}, {}] was not loaded.",
2832 :
Map(id, expiry, InstanceId, SpawnMode),
2833 i_data(nullptr), i_script_id(0), i_scenario(nullptr), i_instanceLock(instanceLock)
2918 if (!entries.MapDifficulty->IsUsingEncounterLocks())
2928 pendingRaidLock.
WarningOnly = entries.Map->IsFlexLocking();
2930 if (!entries.Map->IsFlexLocking())
3019 if (!lockData->
Data.empty())
3050 ref.GetSource()->SendResetFailedNotify(
GetId());
3061 raidInstanceMessage.
Write();
3064 ref.GetSource()->SendDirectMessage(raidInstanceMessage.
GetRawPacket());
3073 pendingRaidLock.
Write();
3077 ref.GetSource()->SendDirectMessage(pendingRaidLock.
GetRawPacket());
3115 if (entries.IsInstanceIdBound())
3121 Player* player = mapReference.GetSource();
3127 std::string
const* oldData =
nullptr;
3128 uint32 playerCompletedEncounters = 0;
3135 bool isNewLock = !playerLock || playerLock->
IsNew() || playerLock->
IsExpired();
3165 if (entries.IsInstanceIdBound())
3167 instanceCompletedEncounters,
nullptr, {}));
3171 Player* player = mapReference.GetSource();
3177 std::string
const* oldData =
nullptr;
3181 bool isNewLock = !playerLock || playerLock->
IsNew() || playerLock->
IsExpired();
3185 instanceCompletedEncounters,
nullptr, {}));
3206 bool isNewLock = !playerLock || playerLock->
IsNew() || playerLock->
IsExpired();
3390 :
Map(id, expiry, InstanceId, spawnMode), m_bg(nullptr), _battlegroundScript(nullptr), _scriptId(0)
3481 if (
Player* player = itr->GetSource())
3482 if (!player->IsBeingTeleportedFar())
3483 player->TeleportTo(player->GetBattlegroundEntryPoint());
3549 if (bounds.first == bounds.second)
3552 std::unordered_multimap<ObjectGuid::LowType, Creature*>::const_iterator creatureItr = std::find_if(bounds.first, bounds.second, [](Map::CreatureBySpawnIdContainer::value_type
const& pair)
3554 return pair.second->IsAlive();
3557 return creatureItr != bounds.second ? creatureItr->second : bounds.first->second;
3563 if (bounds.first == bounds.second)
3566 std::unordered_multimap<ObjectGuid::LowType, GameObject*>::const_iterator creatureItr = std::find_if(bounds.first, bounds.second, [](Map::GameObjectBySpawnIdContainer::value_type
const& pair)
3568 return pair.second->isSpawned();
3571 return creatureItr != bounds.second ? creatureItr->second : bounds.first->second;
3577 if (bounds.first == bounds.second)
3580 return bounds.first->second;
3594 TC_LOG_ERROR(
"maps",
"Map {} attempt to save respawn time for nonexistant spawnid ({},{}).",
GetId(), type, spawnId);
3616 TC_LOG_ERROR(
"maps",
"Attempt to load saved respawn {} for ({},{}) failed - duplicate respawn? Skipped.", respawnTime,
uint32(type), spawnId);
3648 Field* fields = result->Fetch();
3651 time_t respawnTime = fields[2].
GetInt64();
3658 TC_LOG_ERROR(
"maps",
"Loading saved respawn time of {} for spawnid ({},{}) - spawn does not exist, ignoring", respawnTime,
uint32(type), spawnId);
3662 TC_LOG_ERROR(
"maps",
"Loading saved respawn time of {} for spawnid ({},{}) - invalid spawn type, ignoring", respawnTime,
uint32(type), spawnId);
3665 }
while (result->NextRow());
3708 std::unordered_map<ObjectGuid::LowType, std::unordered_set<uint32>> phases;
3709 std::unordered_map<ObjectGuid::LowType, std::vector<UF::ChrCustomizationChoice>> customizations;
3721 Field* fields = phaseResult->Fetch();
3725 phases[guid].insert(phaseId);
3727 }
while (phaseResult->NextRow());
3740 Field* fields = customizationResult->Fetch();
3742 std::vector<UF::ChrCustomizationChoice>& customizationsForCorpse = customizations[guid];
3744 customizationsForCorpse.emplace_back();
3749 }
while (customizationResult->NextRow());
3754 Field* fields = result->Fetch();
3759 TC_LOG_ERROR(
"misc",
"Corpse (guid: {}) have wrong corpse type ({}), not loading.", guid, type);
3764 if (!corpse->
LoadCorpseFromDB(GenerateLowGuid<HighGuid::Corpse>(), fields))
3770 for (
uint32 phaseId : phases[guid])
3777 }
while (result->NextRow());
3881 std::vector<ObjectGuid> corpses;
3885 if (p.second->IsExpired(now))
3886 corpses.push_back(p.first);
3891 std::vector<Corpse*> expiredBones;
3893 if (bones->IsExpired(now))
3894 expiredBones.push_back(bones);
3896 for (
Corpse* bones : expiredBones)
3909 if (
uint32 music = itr->second.MusicId)
3945 zoneDynamicInfo.
DefaultWeather->SendWeatherUpdateToPlayer(player);
3962 if (
Player* player = itr->GetSource())
3977 info.
DefaultWeather = std::make_unique<Weather>(zoneId, weatherData);
3988 if (zoneDynamicInfo)
4013 if (
Player* player = itr->GetSource())
4014 if (player->GetZoneId() == zoneId)
4025 return lightOverride.AreaLightId == areaLightId;
4029 if (overrideLightId)
4044 overrideLight.
Write();
4047 if (
Player* player = itr->GetSource())
4048 if (player->GetZoneId() == zoneId)
4049 player->SendDirectMessage(overrideLight.
GetRawPacket());
4058 if (
Player* player = itr->GetSource())
4060 if (player->IsInWorld())
4062 player->UpdateAreaDependentAuras(player->GetAreaId());
4063 player->UpdateZoneDependentAuras(player->GetZoneId());
4071 std::stringstream sstr;
4072 sstr << std::boolalpha
4080 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)
#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 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, 0, 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 AddWorldObject(SPECIFIC_OBJECT *obj)
void AddGridObject(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)
InstanceMap(uint32 id, time_t, uint32 InstanceId, Difficulty SpawnMode, TeamId InstanceTeam, InstanceLock *instanceLock)
uint32 GetMaxPlayers() const
virtual void InitVisibilityDistance() override
uint32 GetScriptId() const
void RemovePlayerFromMap(Player *, bool) override
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)
void SetCurrentCell(Cell const &cell)
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
void AddInfiniteAOIVignette(Vignettes::VignetteData *vignette)
RespawnInfoMap * GetRespawnMapForType(SpawnObjectType type)
void EnsureGridCreated(GridCoord const &)
virtual TransferAbortParams CannotEnter(Player *)
void RemoveUpdateObject(Object *obj)
RespawnInfoMap _gameObjectRespawnTimesBySpawnId
NGridType * i_grids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
void UpdatePersonalPhasesForPlayer(Player const *player)
Weather * GetOrGenerateZoneDefaultWeather(uint32 zoneId)
virtual void DelayedUpdate(uint32 diff)
Player * GetPlayer(ObjectGuid const &guid)
AreaTriggerBySpawnIdContainer & GetAreaTriggerBySpawnIdStore()
bool isInLineOfSight(PhaseShift const &phaseShift, float x1, float y1, float z1, float x2, float y2, float z2, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const
bool IsNonRaidDungeon() const
time_t GetLinkedRespawnTime(ObjectGuid guid) const
void AddCorpse(Corpse *corpse)
bool IsBattleground() const
void UpdatePlayerZoneStats(uint32 oldZone, uint32 newZone)
WorldStateValueContainer _worldStateValues
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 GetEntrancePos(int32 &mapid, float &x, float &y)
bool _dynamicObjectsToMoveLock
NGridType * getNGrid(uint3