TrinityCore
InstanceLockMgr Class Reference

#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. More...
 
InstanceLockFindActiveInstanceLock (ObjectGuid const &playerGuid, MapDb2Entries const &entries) const
 Attempts to find InstanceLock for given instance owner. This will also find expired but extended locks. More...
 
std::vector< InstanceLock const * > GetInstanceLocksForPlayer (ObjectGuid const &playerGuid) const
 Retrieves all existing instance locks for a player. More...
 
InstanceLockCreateInstanceLockForNewInstance (ObjectGuid const &playerGuid, MapDb2Entries const &entries, uint32 instanceId)
 Creates new InstanceLock when instance map is created. More...
 
InstanceLockUpdateInstanceLockForPlayer (CharacterDatabaseTransaction trans, ObjectGuid const &playerGuid, MapDb2Entries const &entries, InstanceLockUpdateEvent &&updateEvent)
 Updates existing instance lock for player with new completed encounter and instance state. More...
 
void UpdateSharedInstanceLock (CharacterDatabaseTransaction trans, InstanceLockUpdateEvent &&updateEvent)
 Updates existing instance id based lock shared state with new completed encounter and instance state. More...
 
void OnSharedInstanceLockDataDelete (uint32 instanceId)
 Handles last reference to shared instance state being removed to clean up leftover database data. More...
 
std::pair< InstanceResetTimePoint, InstanceResetTimePointUpdateInstanceLockExtensionForPlayer (ObjectGuid const &playerGuid, MapDb2Entries const &entries, bool extended)
 Updates existing instance lock for player with requested extension state. More...
 
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. More...
 
InstanceLocksStatistics GetStatistics () const
 Retrieves instance lock statistics - for use in GM commands. More...
 

Static Public Member Functions

static InstanceLockMgrInstance ()
 
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
 
InstanceLockMgroperator= (InstanceLockMgr const &right)=delete
 
InstanceLockMgroperator= (InstanceLockMgr &&right)=delete
 
 ~InstanceLockMgr ()
 
InstanceLockFindActiveInstanceLock (ObjectGuid const &playerGuid, MapDb2Entries const &entries, bool ignoreTemporary, bool ignoreExpired) const
 

Static Private Member Functions

static InstanceLockFindInstanceLock (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
 

Detailed Description

Definition at line 204 of file InstanceLockMgr.h.

Member Typedef Documentation

◆ LockMap

using InstanceLockMgr::LockMap = std::unordered_map<ObjectGuid, PlayerLockMap>
private

Definition at line 306 of file InstanceLockMgr.h.

◆ PlayerLockMap

using InstanceLockMgr::PlayerLockMap = std::unordered_map<InstanceLockKey, std::unique_ptr<InstanceLock> >
private

Definition at line 305 of file InstanceLockMgr.h.

Constructor & Destructor Documentation

◆ InstanceLockMgr() [1/3]

InstanceLockMgr::InstanceLockMgr ( )
privatedefault

◆ InstanceLockMgr() [2/3]

InstanceLockMgr::InstanceLockMgr ( InstanceLockMgr const &  right)
privatedelete

◆ InstanceLockMgr() [3/3]

InstanceLockMgr::InstanceLockMgr ( InstanceLockMgr &&  right)
privatedelete

◆ ~InstanceLockMgr()

InstanceLockMgr::~InstanceLockMgr ( )
privatedefault

Member Function Documentation

◆ CanJoinInstanceLock()

TransferAbortReason InstanceLockMgr::CanJoinInstanceLock ( ObjectGuid const &  playerGuid,
MapDb2Entries const &  entries,
InstanceLock const *  instanceLock 
) const

Checks if player is allowed to enter instance map.

Parameters
playerGuidGuid of player who is trying to enter instance map
entriesMap.db2 + MapDifficulty.db2 data for instance
instanceLockInstanceLock used during map creation
Returns
Failure reason to show in client or TRANSFER_ABORT_NONE when player is allowed to enter

Definition at line 176 of file InstanceLockMgr.cpp.

+ Here is the call graph for this function:

◆ CreateInstanceLockForNewInstance()

InstanceLock * InstanceLockMgr::CreateInstanceLockForNewInstance ( ObjectGuid const &  playerGuid,
MapDb2Entries const &  entries,
uint32  instanceId 
)

Creates new InstanceLock when instance map is created.

Parameters
playerGuidGuid of player owning instance. Player's own guid if not in group, otherwise group leader's
entriesMap.db2 + MapDifficulty.db2 data for instance
instanceIdPersistent instance id
Returns
New InstanceLock with clear state and _instanceId not set

Definition at line 250 of file InstanceLockMgr.cpp.

+ Here is the call graph for this function:

◆ FindActiveInstanceLock() [1/2]

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.

Parameters
playerGuidGuid of player owning instance. Player's own guid if not in group, otherwise group leader's
entriesMap.db2 + MapDifficulty.db2 data for instance
Returns
InstanceLock previously loaded from database

Definition at line 210 of file InstanceLockMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindActiveInstanceLock() [2/2]

InstanceLock * InstanceLockMgr::FindActiveInstanceLock ( ObjectGuid const &  playerGuid,
MapDb2Entries const &  entries,
bool  ignoreTemporary,
bool  ignoreExpired 
) const
private

Definition at line 215 of file InstanceLockMgr.cpp.

+ Here is the call graph for this function:

◆ FindInstanceLock()

InstanceLock * InstanceLockMgr::FindInstanceLock ( LockMap const &  locks,
ObjectGuid const &  playerGuid,
MapDb2Entries const &  entries 
)
staticprivate

Definition at line 197 of file InstanceLockMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetInstanceLocksForPlayer()

std::vector< InstanceLock const * > InstanceLockMgr::GetInstanceLocksForPlayer ( ObjectGuid const &  playerGuid) const

Retrieves all existing instance locks for a player.

Parameters
playerGuidGuid of player whose locks are requested
Returns
All locks (current and expired) for player

Definition at line 235 of file InstanceLockMgr.cpp.

◆ GetNextResetTime()

InstanceResetTimePoint InstanceLockMgr::GetNextResetTime ( MapDb2Entries const &  entries)
static

Definition at line 534 of file InstanceLockMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetStatistics()

InstanceLocksStatistics InstanceLockMgr::GetStatistics ( ) const

Retrieves instance lock statistics - for use in GM commands.

Returns
Statistics info

Definition at line 526 of file InstanceLockMgr.cpp.

◆ Instance()

InstanceLockMgr & InstanceLockMgr::Instance ( )
static

Definition at line 568 of file InstanceLockMgr.cpp.

◆ Load()

void InstanceLockMgr::Load ( )

Definition at line 102 of file InstanceLockMgr.cpp.

+ Here is the call graph for this function:

◆ OnSharedInstanceLockDataDelete()

void InstanceLockMgr::OnSharedInstanceLockDataDelete ( uint32  instanceId)

Handles last reference to shared instance state being removed to clean up leftover database data.

Parameters
instanceIdId of the instance being deleted

Definition at line 431 of file InstanceLockMgr.cpp.

+ Here is the call graph for this function:

◆ operator=() [1/2]

InstanceLockMgr & InstanceLockMgr::operator= ( InstanceLockMgr &&  right)
privatedelete

◆ operator=() [2/2]

InstanceLockMgr & InstanceLockMgr::operator= ( InstanceLockMgr const &  right)
privatedelete

◆ ResetInstanceLocksForPlayer()

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.

Parameters
playerGuidGuid of player whose locks will be removed
mapId(Optional) Map id of instance locks to reset
difficulty(Optional) Difficulty of instance locks to reset
locksResetAll locks that were reset
locksFailedToResetLocks that could not be reset because they are used by existing instance map

Definition at line 477 of file InstanceLockMgr.cpp.

+ Here is the call graph for this function:

◆ Unload()

void InstanceLockMgr::Unload ( )

Definition at line 169 of file InstanceLockMgr.cpp.

◆ UpdateInstanceLockExtensionForPlayer()

std::pair< InstanceResetTimePoint, InstanceResetTimePoint > InstanceLockMgr::UpdateInstanceLockExtensionForPlayer ( ObjectGuid const &  playerGuid,
MapDb2Entries const &  entries,
bool  extended 
)

Updates existing instance lock for player with requested extension state.

Parameters
playerGuidGuid of player whose lock is extended
entriesMap.db2 + MapDifficulty.db2 data for instance
extendedNew instance lock extension state
Returns
pair<OldExpirationTime, NewExpirationTime>

Definition at line 451 of file InstanceLockMgr.cpp.

+ Here is the call graph for this function:

◆ UpdateInstanceLockForPlayer()

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.

Parameters
transDatabase transaction
playerGuidGuid of player who will become locked to instance
entriesMap.db2 + MapDifficulty.db2 data for instance
updateEventNew instance lock data
Returns
Updated InstanceLock for player

Definition at line 277 of file InstanceLockMgr.cpp.

+ Here is the call graph for this function:

◆ UpdateSharedInstanceLock()

void InstanceLockMgr::UpdateSharedInstanceLock ( CharacterDatabaseTransaction  trans,
InstanceLockUpdateEvent &&  updateEvent 
)

Updates existing instance id based lock shared state with new completed encounter and instance state.

Parameters
transDatabase transaction
updateEventNew instance lock data

Definition at line 400 of file InstanceLockMgr.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ _instanceLockDataById

std::unordered_map<uint32, std::weak_ptr<SharedInstanceLockData> > InstanceLockMgr::_instanceLockDataById
private

Definition at line 314 of file InstanceLockMgr.h.

◆ _instanceLocksByPlayer

LockMap InstanceLockMgr::_instanceLocksByPlayer
private

Definition at line 313 of file InstanceLockMgr.h.

◆ _locksMutex

std::shared_mutex InstanceLockMgr::_locksMutex
mutableprivate

Definition at line 311 of file InstanceLockMgr.h.

◆ _temporaryInstanceLocksByPlayer

LockMap InstanceLockMgr::_temporaryInstanceLocksByPlayer
private

Definition at line 312 of file InstanceLockMgr.h.

◆ _unloading

bool InstanceLockMgr::_unloading = false
private

Definition at line 315 of file InstanceLockMgr.h.


The documentation for this class was generated from the following files: