![]() |
TrinityCore
|
#include <InstanceLockMgr.h>
Public Member Functions | |
| void | Load () |
| void | Unload () |
| TransferAbortReason | CanJoinInstanceLock (ObjectGuid const &playerGuid, MapDb2Entries const &entries, InstanceLock const *instanceLock) const |
| Checks if player is allowed to enter instance map. | |
| InstanceLock * | FindActiveInstanceLock (ObjectGuid const &playerGuid, MapDb2Entries const &entries) const |
| Attempts to find InstanceLock for given instance owner. This will also find expired but extended locks. | |
| std::vector< InstanceLock const * > | GetInstanceLocksForPlayer (ObjectGuid const &playerGuid) const |
| Retrieves all existing instance locks for a player. | |
| InstanceLock * | CreateInstanceLockForNewInstance (ObjectGuid const &playerGuid, MapDb2Entries const &entries, uint32 instanceId) |
| Creates new InstanceLock when instance map is created. | |
| InstanceLock * | UpdateInstanceLockForPlayer (CharacterDatabaseTransaction trans, ObjectGuid const &playerGuid, MapDb2Entries const &entries, InstanceLockUpdateEvent &&updateEvent) |
| Updates existing instance lock for player with new completed encounter and instance state. | |
| void | UpdateSharedInstanceLock (CharacterDatabaseTransaction trans, InstanceLockUpdateEvent &&updateEvent) |
| Updates existing instance id based lock shared state with new completed encounter and instance state. | |
| void | OnSharedInstanceLockDataDelete (uint32 instanceId) |
| Handles last reference to shared instance state being removed to clean up leftover database data. | |
| std::pair< InstanceResetTimePoint, InstanceResetTimePoint > | UpdateInstanceLockExtensionForPlayer (ObjectGuid const &playerGuid, MapDb2Entries const &entries, bool extended) |
| Updates existing instance lock for player with requested extension state. | |
| void | ResetInstanceLocksForPlayer (ObjectGuid const &playerGuid, Optional< uint32 > mapId, Optional< Difficulty > difficulty, std::vector< InstanceLock const * > *locksReset, std::vector< InstanceLock const * > *locksFailedToReset) |
| Resets instances that match given filter - for use in GM commands. | |
| InstanceLocksStatistics | GetStatistics () const |
| Retrieves instance lock statistics - for use in GM commands. | |
Static Public Member Functions | |
| static InstanceLockMgr & | Instance () |
| static InstanceResetTimePoint | GetNextResetTime (MapDb2Entries const &entries) |
Private Types | |
| using | PlayerLockMap = std::unordered_map< InstanceLockKey, std::unique_ptr< InstanceLock > > |
| using | LockMap = std::unordered_map< ObjectGuid, PlayerLockMap > |
Private Member Functions | |
| InstanceLockMgr () | |
| InstanceLockMgr (InstanceLockMgr const &right)=delete | |
| InstanceLockMgr (InstanceLockMgr &&right)=delete | |
| InstanceLockMgr & | operator= (InstanceLockMgr const &right)=delete |
| InstanceLockMgr & | operator= (InstanceLockMgr &&right)=delete |
| ~InstanceLockMgr () | |
| InstanceLock * | FindActiveInstanceLock (ObjectGuid const &playerGuid, MapDb2Entries const &entries, bool ignoreTemporary, bool ignoreExpired) const |
Static Private Member Functions | |
| static InstanceLock * | FindInstanceLock (LockMap const &locks, ObjectGuid const &playerGuid, MapDb2Entries const &entries) |
Private Attributes | |
| std::shared_mutex | _locksMutex |
| LockMap | _temporaryInstanceLocksByPlayer |
| LockMap | _instanceLocksByPlayer |
| std::unordered_map< uint32, std::weak_ptr< SharedInstanceLockData > > | _instanceLockDataById |
| bool | _unloading = false |
Definition at line 204 of file InstanceLockMgr.h.
|
private |
Definition at line 306 of file InstanceLockMgr.h.
|
private |
Definition at line 305 of file InstanceLockMgr.h.
|
privatedefault |
|
privatedelete |
|
privatedelete |
|
privatedefault |
| TransferAbortReason InstanceLockMgr::CanJoinInstanceLock | ( | ObjectGuid const & | playerGuid, |
| MapDb2Entries const & | entries, | ||
| InstanceLock const * | instanceLock | ||
| ) | const |
Checks if player is allowed to enter instance map.
| playerGuid | Guid of player who is trying to enter instance map |
| entries | Map.db2 + MapDifficulty.db2 data for instance |
| instanceLock | InstanceLock used during map creation |
Definition at line 176 of file InstanceLockMgr.cpp.
References InstanceLockData::CompletedEncountersMask, FindActiveInstanceLock(), InstanceLock::GetData(), InstanceLock::GetInstanceId(), MapEntry::IsFlexLocking(), InstanceLock::IsNew(), MapDifficultyEntry::IsUsingEncounterLocks(), MapDb2Entries::Map, MapDb2Entries::MapDifficulty, TRANSFER_ABORT_ALREADY_COMPLETED_ENCOUNTER, TRANSFER_ABORT_LOCKED_TO_DIFFERENT_INSTANCE, and TRANSFER_ABORT_NONE.
| InstanceLock * InstanceLockMgr::CreateInstanceLockForNewInstance | ( | ObjectGuid const & | playerGuid, |
| MapDb2Entries const & | entries, | ||
| uint32 | instanceId | ||
| ) |
Creates new InstanceLock when instance map is created.
| playerGuid | Guid of player owning instance. Player's own guid if not in group, otherwise group leader's |
| entries | Map.db2 + MapDifficulty.db2 data for instance |
| instanceId | Persistent instance id |
Definition at line 250 of file InstanceLockMgr.cpp.
References _instanceLockDataById, _temporaryInstanceLocksByPlayer, MapDifficultyEntry::DifficultyID, MapDifficultyEntry::GetDifficultyID(), DB2Manager::GetDifficultyName(), MapDb2Entries::GetKey(), GetNextResetTime(), MapDifficultyEntry::HasResetSchedule(), MapEntry::ID, MapDb2Entries::IsInstanceIdBound(), MapDb2Entries::Map, MapDb2Entries::MapDifficulty, MapDifficultyEntry::MapID, MapEntry::MapName, InstanceLock::SetIsNew(), sWorld, TC_LOG_DEBUG, and ObjectGuid::ToString().
| InstanceLock * InstanceLockMgr::FindActiveInstanceLock | ( | ObjectGuid const & | playerGuid, |
| MapDb2Entries const & | entries | ||
| ) | const |
Attempts to find InstanceLock for given instance owner. This will also find expired but extended locks.
| playerGuid | Guid of player owning instance. Player's own guid if not in group, otherwise group leader's |
| entries | Map.db2 + MapDifficulty.db2 data for instance |
Definition at line 210 of file InstanceLockMgr.cpp.
References FindActiveInstanceLock().
Referenced by CanJoinInstanceLock(), FindActiveInstanceLock(), UpdateInstanceLockExtensionForPlayer(), and UpdateInstanceLockForPlayer().
|
private |
Definition at line 215 of file InstanceLockMgr.cpp.
References _instanceLocksByPlayer, _locksMutex, _temporaryInstanceLocksByPlayer, FindInstanceLock(), MapDifficultyEntry::HasResetSchedule(), InstanceLock::IsExpired(), InstanceLock::IsExtended(), and MapDb2Entries::MapDifficulty.
|
staticprivate |
Definition at line 197 of file InstanceLockMgr.cpp.
References MapDb2Entries::GetKey().
Referenced by FindActiveInstanceLock().
| std::vector< InstanceLock const * > InstanceLockMgr::GetInstanceLocksForPlayer | ( | ObjectGuid const & | playerGuid | ) | const |
Retrieves all existing instance locks for a player.
| playerGuid | Guid of player whose locks are requested |
Definition at line 235 of file InstanceLockMgr.cpp.
References _instanceLocksByPlayer.
|
static |
Definition at line 534 of file InstanceLockMgr.cpp.
References CONFIG_RESET_SCHEDULE_HOUR, CONFIG_RESET_SCHEDULE_WEEK_DAY, GameTime::GetDateAndTime(), MAP_DIFFICULTY_RESET_DAILY, MAP_DIFFICULTY_RESET_WEEKLY, MapDb2Entries::MapDifficulty, MapDifficultyEntry::ResetInterval, and sWorld.
Referenced by CreateInstanceLockForNewInstance(), ResetInstanceLocksForPlayer(), and UpdateInstanceLockForPlayer().
| InstanceLocksStatistics InstanceLockMgr::GetStatistics | ( | ) | const |
Retrieves instance lock statistics - for use in GM commands.
Definition at line 526 of file InstanceLockMgr.cpp.
References _instanceLockDataById, _instanceLocksByPlayer, InstanceLocksStatistics::InstanceCount, and InstanceLocksStatistics::PlayerCount.
|
static |
Definition at line 568 of file InstanceLockMgr.cpp.
| void InstanceLockMgr::Load | ( | ) |
Definition at line 102 of file InstanceLockMgr.cpp.
References CharacterDatabase, InstanceLockData::CompletedEncountersMask, InstanceLockData::Data, InstanceLock::GetData(), Field::GetString(), Field::GetUInt32(), MapDb2Entries::IsInstanceIdBound(), InstanceLock::SetExtended(), sMapMgr, and TC_LOG_ERROR.
| void InstanceLockMgr::OnSharedInstanceLockDataDelete | ( | uint32 | instanceId | ) |
Handles last reference to shared instance state being removed to clean up leftover database data.
| instanceId | Id of the instance being deleted |
Definition at line 431 of file InstanceLockMgr.cpp.
References _instanceLockDataById, _unloading, CHAR_DEL_INSTANCE, CharacterDatabase, PreparedStatementBase::setUInt32(), and TC_LOG_DEBUG.
|
privatedelete |
|
privatedelete |
| void InstanceLockMgr::ResetInstanceLocksForPlayer | ( | ObjectGuid const & | playerGuid, |
| Optional< uint32 > | mapId, | ||
| Optional< Difficulty > | difficulty, | ||
| std::vector< InstanceLock const * > * | locksReset, | ||
| std::vector< InstanceLock const * > * | locksFailedToReset | ||
| ) |
Resets instances that match given filter - for use in GM commands.
| playerGuid | Guid of player whose locks will be removed |
| mapId | (Optional) Map id of instance locks to reset |
| difficulty | (Optional) Difficulty of instance locks to reset |
| locksReset | All locks that were reset |
| locksFailedToReset | Locks that could not be reset because they are used by existing instance map |
Definition at line 477 of file InstanceLockMgr.cpp.
References _instanceLocksByPlayer, CHAR_UPD_CHARACTER_INSTANCE_LOCK_FORCE_EXPIRE, CharacterDatabase, ObjectGuid::GetCounter(), GetNextResetTime(), MapDifficultyEntry::GetRaidDuration(), MapDifficultyEntry::LockID, MapDb2Entries::MapDifficulty, MapDifficultyEntry::MapID, PreparedStatementBase::setUInt32(), and PreparedStatementBase::setUInt64().
| void InstanceLockMgr::Unload | ( | ) |
Definition at line 169 of file InstanceLockMgr.cpp.
References _instanceLockDataById, _instanceLocksByPlayer, and _unloading.
| std::pair< InstanceResetTimePoint, InstanceResetTimePoint > InstanceLockMgr::UpdateInstanceLockExtensionForPlayer | ( | ObjectGuid const & | playerGuid, |
| MapDb2Entries const & | entries, | ||
| bool | extended | ||
| ) |
Updates existing instance lock for player with requested extension state.
| playerGuid | Guid of player whose lock is extended |
| entries | Map.db2 + MapDifficulty.db2 data for instance |
| extended | New instance lock extension state |
Definition at line 451 of file InstanceLockMgr.cpp.
References CHAR_UPD_CHARACTER_INSTANCE_LOCK_EXTENSION, CharacterDatabase, MapDifficultyEntry::DifficultyID, FindActiveInstanceLock(), ObjectGuid::GetCounter(), MapDifficultyEntry::GetDifficultyID(), DB2Manager::GetDifficultyName(), MapEntry::ID, MapDifficultyEntry::LockID, MapDb2Entries::Map, MapDb2Entries::MapDifficulty, MapDifficultyEntry::MapID, MapEntry::MapName, PreparedStatementBase::setUInt32(), PreparedStatementBase::setUInt64(), PreparedStatementBase::setUInt8(), sWorld, TC_LOG_DEBUG, and ObjectGuid::ToString().
| InstanceLock * InstanceLockMgr::UpdateInstanceLockForPlayer | ( | CharacterDatabaseTransaction | trans, |
| ObjectGuid const & | playerGuid, | ||
| MapDb2Entries const & | entries, | ||
| InstanceLockUpdateEvent && | updateEvent | ||
| ) |
Updates existing instance lock for player with new completed encounter and instance state.
| trans | Database transaction |
| playerGuid | Guid of player who will become locked to instance |
| entries | Map.db2 + MapDifficulty.db2 data for instance |
| updateEvent | New instance lock data |
Definition at line 277 of file InstanceLockMgr.cpp.
References _instanceLockDataById, _instanceLocksByPlayer, _locksMutex, _temporaryInstanceLocksByPlayer, ASSERT, CHAR_DEL_CHARACTER_INSTANCE_LOCK, CHAR_INS_CHARACTER_INSTANCE_LOCK, CharacterDatabase, InstanceLockData::CompletedEncountersMask, InstanceLockData::Data, MapDifficultyEntry::DifficultyID, InstanceLockData::EntranceWorldSafeLocId, FindActiveInstanceLock(), ObjectGuid::GetCounter(), InstanceLock::GetData(), MapDifficultyEntry::GetDifficultyID(), DB2Manager::GetDifficultyName(), InstanceLock::GetExpiryTime(), InstanceLock::GetInstanceId(), MapDb2Entries::GetKey(), GetNextResetTime(), SharedInstanceLock::GetSharedData(), MapEntry::ID, InstanceLock::IsExpired(), InstanceLock::IsExtended(), MapDb2Entries::IsInstanceIdBound(), MapDifficultyEntry::IsUsingEncounterLocks(), MapDifficultyEntry::LockID, MapDb2Entries::Map, MapDb2Entries::MapDifficulty, MapDifficultyEntry::MapID, MapEntry::MapName, InstanceLock::SetExpiryTime(), InstanceLock::SetExtended(), InstanceLock::SetInstanceId(), InstanceLock::SetIsNew(), PreparedStatementBase::setString(), PreparedStatementBase::setUInt32(), PreparedStatementBase::setUInt64(), PreparedStatementBase::setUInt8(), sWorld, TC_LOG_DEBUG, and ObjectGuid::ToString().
| void InstanceLockMgr::UpdateSharedInstanceLock | ( | CharacterDatabaseTransaction | trans, |
| InstanceLockUpdateEvent && | updateEvent | ||
| ) |
Updates existing instance id based lock shared state with new completed encounter and instance state.
| trans | Database transaction |
| updateEvent | New instance lock data |
Definition at line 400 of file InstanceLockMgr.cpp.
References _instanceLockDataById, ASSERT, CHAR_DEL_INSTANCE, CHAR_INS_INSTANCE, CharacterDatabase, PreparedStatementBase::setString(), PreparedStatementBase::setUInt32(), sWorld, and TC_LOG_DEBUG.
|
private |
Definition at line 314 of file InstanceLockMgr.h.
Referenced by CreateInstanceLockForNewInstance(), GetStatistics(), OnSharedInstanceLockDataDelete(), Unload(), UpdateInstanceLockForPlayer(), and UpdateSharedInstanceLock().
|
private |
Definition at line 313 of file InstanceLockMgr.h.
Referenced by FindActiveInstanceLock(), GetInstanceLocksForPlayer(), GetStatistics(), ResetInstanceLocksForPlayer(), Unload(), and UpdateInstanceLockForPlayer().
|
mutableprivate |
Definition at line 311 of file InstanceLockMgr.h.
Referenced by FindActiveInstanceLock(), and UpdateInstanceLockForPlayer().
|
private |
Definition at line 312 of file InstanceLockMgr.h.
Referenced by CreateInstanceLockForNewInstance(), FindActiveInstanceLock(), and UpdateInstanceLockForPlayer().
|
private |
Definition at line 315 of file InstanceLockMgr.h.
Referenced by OnSharedInstanceLockDataDelete(), and Unload().