Core/Instances: Fixed not being able to reenter instances that have no encounters completed
Port From (https://github.com/TrinityCore/TrinityCore/commit/2569dc8cfec7a5fd89f037579ea6081504b9223f)
This commit is contained in:
@@ -1607,7 +1607,7 @@ namespace Game.DungeonFinding
|
|||||||
lockStatus = LfgLockStatusType.NotInSeason;
|
lockStatus = LfgLockStatusType.NotInSeason;
|
||||||
else if (Global.DisableMgr.IsDisabledFor(DisableType.LFGMap, dungeon.map, player))
|
else if (Global.DisableMgr.IsDisabledFor(DisableType.LFGMap, dungeon.map, player))
|
||||||
lockStatus = LfgLockStatusType.RaidLocked;
|
lockStatus = LfgLockStatusType.RaidLocked;
|
||||||
else if (dungeon.difficulty > Difficulty.Normal && Global.InstanceLockMgr.FindActiveInstanceLock(guid, new MapDb2Entries(dungeon.map, dungeon.difficulty)) != null)
|
else if (Global.InstanceLockMgr.FindActiveInstanceLock(guid, new MapDb2Entries(dungeon.map, dungeon.difficulty)) != null)
|
||||||
lockStatus = LfgLockStatusType.RaidLocked;
|
lockStatus = LfgLockStatusType.RaidLocked;
|
||||||
else if (dungeon.seasonal && !IsSeasonActive(dungeon.id))
|
else if (dungeon.seasonal && !IsSeasonActive(dungeon.id))
|
||||||
lockStatus = LfgLockStatusType.NotInSeason;
|
lockStatus = LfgLockStatusType.NotInSeason;
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ namespace Game.Maps
|
|||||||
return TransferAbortReason.None;
|
return TransferAbortReason.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entries.MapDifficulty.IsUsingEncounterLocks() && playerInstanceLock.GetInstanceId() != 0 && playerInstanceLock.GetInstanceId() != instanceLock.GetInstanceId())
|
if (!entries.MapDifficulty.IsUsingEncounterLocks() && playerInstanceLock.IsNew() && playerInstanceLock.GetInstanceId() != instanceLock.GetInstanceId())
|
||||||
return TransferAbortReason.LockedToDifferentInstance;
|
return TransferAbortReason.LockedToDifferentInstance;
|
||||||
|
|
||||||
return TransferAbortReason.None;
|
return TransferAbortReason.None;
|
||||||
@@ -167,11 +167,13 @@ namespace Game.Maps
|
|||||||
SharedInstanceLockData sharedData = new();
|
SharedInstanceLockData sharedData = new();
|
||||||
_instanceLockDataById[instanceId] = sharedData;
|
_instanceLockDataById[instanceId] = sharedData;
|
||||||
instanceLock = new SharedInstanceLock(entries.MapDifficulty.MapID, (Difficulty)entries.MapDifficulty.DifficultyID,
|
instanceLock = new SharedInstanceLock(entries.MapDifficulty.MapID, (Difficulty)entries.MapDifficulty.DifficultyID,
|
||||||
GetNextResetTime(entries), 0, sharedData);
|
GetNextResetTime(entries), instanceId, sharedData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
instanceLock = new InstanceLock(entries.MapDifficulty.MapID, (Difficulty)entries.MapDifficulty.DifficultyID,
|
instanceLock = new InstanceLock(entries.MapDifficulty.MapID, (Difficulty)entries.MapDifficulty.DifficultyID,
|
||||||
GetNextResetTime(entries), 0);
|
GetNextResetTime(entries), instanceId);
|
||||||
|
|
||||||
|
instanceLock.SetIsNew(true);
|
||||||
|
|
||||||
if (!_temporaryInstanceLocksByPlayer.ContainsKey(playerGuid))
|
if (!_temporaryInstanceLocksByPlayer.ContainsKey(playerGuid))
|
||||||
_temporaryInstanceLocksByPlayer[playerGuid] = new Dictionary<InstanceLockKey, InstanceLock>();
|
_temporaryInstanceLocksByPlayer[playerGuid] = new Dictionary<InstanceLockKey, InstanceLock>();
|
||||||
@@ -237,7 +239,7 @@ namespace Game.Maps
|
|||||||
{
|
{
|
||||||
if (entries.IsInstanceIdBound())
|
if (entries.IsInstanceIdBound())
|
||||||
{
|
{
|
||||||
Cypher.Assert(instanceLock.GetInstanceId() == 0 || instanceLock.GetInstanceId() == updateEvent.InstanceId);
|
Cypher.Assert(instanceLock.GetInstanceId() == updateEvent.InstanceId);
|
||||||
var sharedDataItr = _instanceLockDataById.LookupByKey(updateEvent.InstanceId);
|
var sharedDataItr = _instanceLockDataById.LookupByKey(updateEvent.InstanceId);
|
||||||
Cypher.Assert(sharedDataItr != null);
|
Cypher.Assert(sharedDataItr != null);
|
||||||
Cypher.Assert(sharedDataItr == (instanceLock as SharedInstanceLock).GetSharedData());
|
Cypher.Assert(sharedDataItr == (instanceLock as SharedInstanceLock).GetSharedData());
|
||||||
@@ -246,6 +248,7 @@ namespace Game.Maps
|
|||||||
instanceLock.SetInstanceId(updateEvent.InstanceId);
|
instanceLock.SetInstanceId(updateEvent.InstanceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
instanceLock.SetIsNew(false);
|
||||||
instanceLock.GetData().Data = updateEvent.NewData;
|
instanceLock.GetData().Data = updateEvent.NewData;
|
||||||
if (updateEvent.CompletedEncounter != null)
|
if (updateEvent.CompletedEncounter != null)
|
||||||
{
|
{
|
||||||
@@ -325,6 +328,9 @@ namespace Game.Maps
|
|||||||
if (_unloading)
|
if (_unloading)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!_instanceLockDataById.ContainsKey(instanceId))
|
||||||
|
return;
|
||||||
|
|
||||||
_instanceLockDataById.Remove(instanceId);
|
_instanceLockDataById.Remove(instanceId);
|
||||||
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_INSTANCE);
|
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_INSTANCE);
|
||||||
stmt.AddValue(0, instanceId);
|
stmt.AddValue(0, instanceId);
|
||||||
@@ -381,6 +387,9 @@ namespace Game.Maps
|
|||||||
if (difficulty.HasValue && difficulty.Value != playerLockPair.Value.GetDifficultyId())
|
if (difficulty.HasValue && difficulty.Value != playerLockPair.Value.GetDifficultyId())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (playerLockPair.Value.IsExpired())
|
||||||
|
continue;
|
||||||
|
|
||||||
locksReset.Add(playerLockPair.Value);
|
locksReset.Add(playerLockPair.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,6 +479,7 @@ namespace Game.Maps
|
|||||||
bool _extended;
|
bool _extended;
|
||||||
InstanceLockData _data = new();
|
InstanceLockData _data = new();
|
||||||
bool _isInUse;
|
bool _isInUse;
|
||||||
|
bool _isNew;
|
||||||
|
|
||||||
public InstanceLock(uint mapId, Difficulty difficultyId, DateTime expiryTime, uint instanceId)
|
public InstanceLock(uint mapId, Difficulty difficultyId, DateTime expiryTime, uint instanceId)
|
||||||
{
|
{
|
||||||
@@ -523,6 +533,10 @@ namespace Game.Maps
|
|||||||
public bool IsInUse() { return _isInUse; }
|
public bool IsInUse() { return _isInUse; }
|
||||||
|
|
||||||
public void SetInUse(bool inUse) { _isInUse = inUse; }
|
public void SetInUse(bool inUse) { _isInUse = inUse; }
|
||||||
|
|
||||||
|
public bool IsNew() { return _isNew; }
|
||||||
|
|
||||||
|
public void SetIsNew(bool isNew) { _isNew = isNew; }
|
||||||
}
|
}
|
||||||
|
|
||||||
class SharedInstanceLockData : InstanceLockData
|
class SharedInstanceLockData : InstanceLockData
|
||||||
|
|||||||
@@ -4801,7 +4801,7 @@ namespace Game.Maps
|
|||||||
player.AddInstanceEnterTime(GetInstanceId(), GameTime.GetGameTime());
|
player.AddInstanceEnterTime(GetInstanceId(), GameTime.GetGameTime());
|
||||||
|
|
||||||
MapDb2Entries entries = new(GetEntry(), GetMapDifficulty());
|
MapDb2Entries entries = new(GetEntry(), GetMapDifficulty());
|
||||||
if (entries.MapDifficulty.HasResetSchedule() && i_instanceLock != null && i_instanceLock.GetData().CompletedEncountersMask != 0)
|
if (entries.MapDifficulty.HasResetSchedule() && i_instanceLock != null && !i_instanceLock.IsNew())
|
||||||
{
|
{
|
||||||
if (!entries.MapDifficulty.IsUsingEncounterLocks())
|
if (!entries.MapDifficulty.IsUsingEncounterLocks())
|
||||||
{
|
{
|
||||||
@@ -4890,7 +4890,7 @@ namespace Game.Maps
|
|||||||
if (i_data == null)
|
if (i_data == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (i_instanceLock == null || i_instanceLock.GetInstanceId() == 0)
|
if (i_instanceLock == null || i_instanceLock.IsNew())
|
||||||
{
|
{
|
||||||
i_data.Create();
|
i_data.Create();
|
||||||
return;
|
return;
|
||||||
@@ -4926,7 +4926,7 @@ namespace Game.Maps
|
|||||||
public InstanceResetResult Reset(InstanceResetMethod method)
|
public InstanceResetResult Reset(InstanceResetMethod method)
|
||||||
{
|
{
|
||||||
// raids can be reset if no boss was killed
|
// raids can be reset if no boss was killed
|
||||||
if (method != InstanceResetMethod.Expire && i_instanceLock != null && i_instanceLock.GetData().CompletedEncountersMask != 0)
|
if (method != InstanceResetMethod.Expire && i_instanceLock != null && !i_instanceLock.IsNew())
|
||||||
return InstanceResetResult.CannotReset;
|
return InstanceResetResult.CannotReset;
|
||||||
|
|
||||||
if (HavePlayers())
|
if (HavePlayers())
|
||||||
@@ -5015,7 +5015,7 @@ namespace Game.Maps
|
|||||||
playerCompletedEncounters = playerLock.GetData().CompletedEncountersMask | (1u << updateSaveDataEvent.DungeonEncounter.Bit);
|
playerCompletedEncounters = playerLock.GetData().CompletedEncountersMask | (1u << updateSaveDataEvent.DungeonEncounter.Bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNewLock = playerLock == null || playerLock.GetData().CompletedEncountersMask == 0 || playerLock.IsExpired();
|
bool isNewLock = playerLock == null || playerLock.IsNew() || playerLock.IsExpired();
|
||||||
|
|
||||||
InstanceLock newLock = Global.InstanceLockMgr.UpdateInstanceLockForPlayer(trans, player.GetGUID(), entries, new InstanceLockUpdateEvent(GetInstanceId(), i_data.UpdateBossStateSaveData(oldData, updateSaveDataEvent),
|
InstanceLock newLock = Global.InstanceLockMgr.UpdateInstanceLockForPlayer(trans, player.GetGUID(), entries, new InstanceLockUpdateEvent(GetInstanceId(), i_data.UpdateBossStateSaveData(oldData, updateSaveDataEvent),
|
||||||
instanceCompletedEncounters, updateSaveDataEvent.DungeonEncounter, i_data.GetEntranceLocationForCompletedEncounters(playerCompletedEncounters)));
|
instanceCompletedEncounters, updateSaveDataEvent.DungeonEncounter, i_data.GetEntranceLocationForCompletedEncounters(playerCompletedEncounters)));
|
||||||
@@ -5058,7 +5058,7 @@ namespace Game.Maps
|
|||||||
if (playerLock != null)
|
if (playerLock != null)
|
||||||
oldData = playerLock.GetData().Data;
|
oldData = playerLock.GetData().Data;
|
||||||
|
|
||||||
bool isNewLock = playerLock == null || playerLock.GetData().CompletedEncountersMask == 0 || playerLock.IsExpired();
|
bool isNewLock = playerLock == null || playerLock.IsNew() || playerLock.IsExpired();
|
||||||
|
|
||||||
InstanceLock newLock = Global.InstanceLockMgr.UpdateInstanceLockForPlayer(trans, player.GetGUID(), entries, new InstanceLockUpdateEvent(GetInstanceId(), i_data.UpdateAdditionalSaveData(oldData, updateSaveDataEvent),
|
InstanceLock newLock = Global.InstanceLockMgr.UpdateInstanceLockForPlayer(trans, player.GetGUID(), entries, new InstanceLockUpdateEvent(GetInstanceId(), i_data.UpdateAdditionalSaveData(oldData, updateSaveDataEvent),
|
||||||
instanceCompletedEncounters, null, null));
|
instanceCompletedEncounters, null, null));
|
||||||
@@ -5082,7 +5082,7 @@ namespace Game.Maps
|
|||||||
MapDb2Entries entries = new(GetEntry(), GetMapDifficulty());
|
MapDb2Entries entries = new(GetEntry(), GetMapDifficulty());
|
||||||
InstanceLock playerLock = Global.InstanceLockMgr.FindActiveInstanceLock(player.GetGUID(), entries);
|
InstanceLock playerLock = Global.InstanceLockMgr.FindActiveInstanceLock(player.GetGUID(), entries);
|
||||||
|
|
||||||
bool isNewLock = playerLock == null || playerLock.GetData().CompletedEncountersMask == 0 || playerLock.IsExpired();
|
bool isNewLock = playerLock == null || playerLock.IsNew() || playerLock.IsExpired();
|
||||||
|
|
||||||
SQLTransaction trans = new();
|
SQLTransaction trans = new();
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace Game.Entities
|
|||||||
// some instances only have one difficulty
|
// some instances only have one difficulty
|
||||||
Global.DB2Mgr.GetDownscaledMapDifficultyData(mapId, ref difficulty);
|
Global.DB2Mgr.GetDownscaledMapDifficultyData(mapId, ref difficulty);
|
||||||
|
|
||||||
Log.outDebug(LogFilter.Maps, $"MapInstanced::CreateInstance: {(instanceLock?.GetInstanceId() != 0 ? "" : "new ")}map instance {instanceId} for {mapId} created with difficulty {difficulty}");
|
Log.outDebug(LogFilter.Maps, $"MapInstanced::CreateInstance: {(instanceLock?.IsNew() == true ? "new" : " ")} map instance {instanceId} for {mapId} created with difficulty {difficulty}");
|
||||||
|
|
||||||
InstanceMap map = new InstanceMap(mapId, i_gridCleanUpDelay, instanceId, difficulty, team, instanceLock);
|
InstanceMap map = new InstanceMap(mapId, i_gridCleanUpDelay, instanceId, difficulty, team, instanceLock);
|
||||||
Cypher.Assert(map.IsDungeon());
|
Cypher.Assert(map.IsDungeon());
|
||||||
|
|||||||
Reference in New Issue
Block a user