Core/Maps: Link instance map to LfgDungeons

Port From (https://github.com/TrinityCore/TrinityCore/commit/81276097648abe484d720c8ee9e3e77173825c8c)
This commit is contained in:
Hondacrx
2024-11-10 17:37:17 -05:00
parent 9cb6940f7b
commit 06979399fb
5 changed files with 14 additions and 9 deletions
+1 -1
View File
@@ -1323,7 +1323,7 @@ namespace Game.DungeonFinding
player.FinishTaxiFlight(); player.FinishTaxiFlight();
if (!player.TeleportTo(mapid, x, y, z, orientation)) if (!player.TeleportTo(new Game.Entities.TeleportLocation(){ Location = new WorldLocation(mapid, x, y, z, orientation), LfgDungeonsId = dungeon.id }))
error = LfgTeleportResult.NoReturnLocation; error = LfgTeleportResult.NoReturnLocation;
} }
else else
+2 -1
View File
@@ -8061,7 +8061,8 @@ namespace Game.Entities
public class TeleportLocation public class TeleportLocation
{ {
public WorldLocation Location; public WorldLocation Location;
public uint? InstanceId;
public ObjectGuid? TransportGuid; public ObjectGuid? TransportGuid;
public uint? InstanceId;
public uint? LfgDungeonsId;
} }
} }
+1 -1
View File
@@ -263,7 +263,7 @@ namespace Game
player.m_InstanceValid = true; player.m_InstanceValid = true;
Map oldMap = player.GetMap(); Map oldMap = player.GetMap();
Map newMap = loc.InstanceId.HasValue ? Global.MapMgr.FindMap(loc.Location.GetMapId(), loc.InstanceId.Value) : Global.MapMgr.CreateMap(loc.Location.GetMapId(), GetPlayer()); Map newMap = loc.InstanceId.HasValue ? Global.MapMgr.FindMap(loc.Location.GetMapId(), loc.InstanceId.Value) : Global.MapMgr.CreateMap(loc.Location.GetMapId(), GetPlayer(), loc.LfgDungeonsId);
ITransport transport = player.GetTransport(); ITransport transport = player.GetTransport();
if (transport != null) if (transport != null)
+5 -1
View File
@@ -4871,9 +4871,10 @@ namespace Game.Maps
public class InstanceMap : Map public class InstanceMap : Map
{ {
public InstanceMap(uint id, long expiry, uint InstanceId, Difficulty spawnMode, int instanceTeam, InstanceLock instanceLock) : base(id, expiry, InstanceId, spawnMode) public InstanceMap(uint id, long expiry, uint InstanceId, Difficulty spawnMode, int instanceTeam, InstanceLock instanceLock, uint? lfgDungeonsId) : base(id, expiry, InstanceId, spawnMode)
{ {
i_instanceLock = instanceLock; i_instanceLock = instanceLock;
i_lfgDungeonsId = lfgDungeonsId;
//lets initialize visibility distance for dungeons //lets initialize visibility distance for dungeons
InitVisibilityDistance(); InitVisibilityDistance();
@@ -5270,6 +5271,8 @@ namespace Game.Maps
public Team GetTeamInInstance() { return GetTeamIdInInstance() == BattleGroundTeamId.Alliance ? Team.Alliance : Team.Horde; } public Team GetTeamInInstance() { return GetTeamIdInInstance() == BattleGroundTeamId.Alliance ? Team.Alliance : Team.Horde; }
public uint? GetLfgDungeonsId() { return i_lfgDungeonsId; }
public uint GetScriptId() public uint GetScriptId()
{ {
return i_script_id; return i_script_id;
@@ -5296,6 +5299,7 @@ namespace Game.Maps
InstanceScenario i_scenario; InstanceScenario i_scenario;
InstanceLock i_instanceLock; InstanceLock i_instanceLock;
GroupInstanceReference i_owningGroupRef = new(); GroupInstanceReference i_owningGroupRef = new();
uint? i_lfgDungeonsId;
DateTime? i_instanceExpireEvent; DateTime? i_instanceExpireEvent;
} }
+5 -5
View File
@@ -57,7 +57,7 @@ namespace Game.Entities
return map; return map;
} }
InstanceMap CreateInstance(uint mapId, uint instanceId, InstanceLock instanceLock, Difficulty difficulty, int team, Group group) InstanceMap CreateInstance(uint mapId, uint instanceId, InstanceLock instanceLock, Difficulty difficulty, int team, Group group, uint? lfgDungeonsId)
{ {
// make sure we have a valid map id // make sure we have a valid map id
var entry = CliDB.MapStorage.LookupByKey(mapId); var entry = CliDB.MapStorage.LookupByKey(mapId);
@@ -73,7 +73,7 @@ namespace Game.Entities
Log.outDebug(LogFilter.Maps, $"MapInstanced::CreateInstance: {(instanceLock?.IsNew() == true ? "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, lfgDungeonsId);
Cypher.Assert(map.IsDungeon()); Cypher.Assert(map.IsDungeon());
map.LoadRespawnTimes(); map.LoadRespawnTimes();
@@ -122,9 +122,9 @@ namespace Game.Entities
/// </summary> /// </summary>
/// <param name="mapId"></param> /// <param name="mapId"></param>
/// <param name="player"></param> /// <param name="player"></param>
/// <param name="loginInstanceId"></param> /// <param name="lfgDungeonsId"></param>
/// <returns>the right instance for the object, based on its InstanceId</returns> /// <returns>the right instance for the object, based on its InstanceId</returns>
public Map CreateMap(uint mapId, Player player) public Map CreateMap(uint mapId, Player player, uint? lfgDungeonsId = null)
{ {
if (player == null) if (player == null)
return null; return null;
@@ -199,7 +199,7 @@ namespace Game.Entities
if (map == null) if (map == null)
{ {
map = CreateInstance(mapId, newInstanceId, instanceLock, difficulty, SharedConst.GetTeamIdForTeam(Global.CharacterCacheStorage.GetCharacterTeamByGuid(instanceOwnerGuid)), group); map = CreateInstance(mapId, newInstanceId, instanceLock, difficulty, SharedConst.GetTeamIdForTeam(Global.CharacterCacheStorage.GetCharacterTeamByGuid(instanceOwnerGuid)), group, lfgDungeonsId);
if (group != null) if (group != null)
group.SetRecentInstance(mapId, instanceOwnerGuid, newInstanceId); group.SetRecentInstance(mapId, instanceOwnerGuid, newInstanceId);
else else