Core/Map: Kill zoneId from RespawnInfo, all it did was significantly slow down startup to make one gm command faster
Port From (https://github.com/TrinityCore/TrinityCore/commit/8f3904f8fd4e7536d1e7ba8e701f4774519fd867)
This commit is contained in:
@@ -579,28 +579,39 @@ namespace Game.Chat.Commands
|
|||||||
string stringOverdue = Global.ObjectMgr.GetCypherString(CypherStrings.ListRespawnsOverdue, locale);
|
string stringOverdue = Global.ObjectMgr.GetCypherString(CypherStrings.ListRespawnsOverdue, locale);
|
||||||
|
|
||||||
uint zoneId = player.GetZoneId();
|
uint zoneId = player.GetZoneId();
|
||||||
|
string zoneName = GetZoneName(zoneId, locale);
|
||||||
for (SpawnObjectType type = 0; type < SpawnObjectType.Max; type++)
|
for (SpawnObjectType type = 0; type < SpawnObjectType.Max; type++)
|
||||||
{
|
{
|
||||||
if (range != 0)
|
if (range != 0)
|
||||||
handler.SendSysMessage(CypherStrings.ListRespawnsRange, type, range);
|
handler.SendSysMessage(CypherStrings.ListRespawnsRange, type, range);
|
||||||
else
|
else
|
||||||
handler.SendSysMessage(CypherStrings.ListRespawnsZone, type, GetZoneName(zoneId, locale), zoneId);
|
handler.SendSysMessage(CypherStrings.ListRespawnsZone, type, zoneName, zoneId);
|
||||||
handler.SendSysMessage(CypherStrings.ListRespawnsListheader);
|
handler.SendSysMessage(CypherStrings.ListRespawnsListheader);
|
||||||
List<RespawnInfo> respawns = new();
|
List<RespawnInfo> respawns = new();
|
||||||
map.GetRespawnInfo(respawns, (SpawnObjectTypeMask)(1 << (int)type), range != 0 ? 0 : zoneId);
|
map.GetRespawnInfo(respawns, (SpawnObjectTypeMask)(1 << (int)type));
|
||||||
foreach (RespawnInfo ri in respawns)
|
foreach (RespawnInfo ri in respawns)
|
||||||
{
|
{
|
||||||
SpawnData data = Global.ObjectMgr.GetSpawnData(ri.type, ri.spawnId);
|
SpawnData data = Global.ObjectMgr.GetSpawnData(ri.type, ri.spawnId);
|
||||||
if (data == null)
|
if (data == null)
|
||||||
continue;
|
continue;
|
||||||
if (range != 0 && !player.IsInDist(data.spawnPoint, range))
|
|
||||||
continue;
|
uint respawnZoneId = map.GetZoneId(PhasingHandler.EmptyPhaseShift, data.spawnPoint);
|
||||||
|
if (range != 0)
|
||||||
|
{
|
||||||
|
if (!player.IsInDist(data.spawnPoint, range))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (zoneId != respawnZoneId)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
uint gridY = ri.gridId / MapConst.MaxGrids;
|
uint gridY = ri.gridId / MapConst.MaxGrids;
|
||||||
uint gridX = ri.gridId % MapConst.MaxGrids;
|
uint gridX = ri.gridId % MapConst.MaxGrids;
|
||||||
|
|
||||||
string respawnTime = ri.respawnTime > GameTime.GetGameTime() ? Time.secsToTimeString((ulong)(ri.respawnTime - GameTime.GetGameTime()), true) : stringOverdue;
|
string respawnTime = ri.respawnTime > GameTime.GetGameTime() ? Time.secsToTimeString((ulong)(ri.respawnTime - GameTime.GetGameTime()), true) : stringOverdue;
|
||||||
handler.SendSysMessage($"{ri.spawnId} | {ri.entry} | [{gridX:2},{gridY:2}] | {GetZoneName(ri.zoneId, locale)} ({ri.zoneId}) | {respawnTime}{(map.IsSpawnGroupActive(data.spawnGroupData.groupId) ? "" : " (inactive)")}");
|
handler.SendSysMessage($"{ri.spawnId} | {ri.entry} | [{gridX:2},{gridY:2}] | {GetZoneName(respawnZoneId, locale)} ({respawnZoneId}) | {respawnTime}{(map.IsSpawnGroupActive(data.spawnGroupData.groupId) ? "" : " (inactive)")}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1953,7 +1953,7 @@ namespace Game.Chat
|
|||||||
|
|
||||||
// Now handle any that had despawned, but had respawn time logged.
|
// Now handle any that had despawned, but had respawn time logged.
|
||||||
List<RespawnInfo> data = new();
|
List<RespawnInfo> data = new();
|
||||||
player.GetMap().GetRespawnInfo(data, SpawnObjectTypeMask.All, 0);
|
player.GetMap().GetRespawnInfo(data, SpawnObjectTypeMask.All);
|
||||||
if (!data.Empty())
|
if (!data.Empty())
|
||||||
{
|
{
|
||||||
uint gridId = GridDefines.ComputeGridCoord(player.GetPositionX(), player.GetPositionY()).GetId();
|
uint gridId = GridDefines.ComputeGridCoord(player.GetPositionX(), player.GetPositionY()).GetId();
|
||||||
|
|||||||
@@ -2265,7 +2265,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
long thisRespawnTime = forceDelay != 0 ? GameTime.GetGameTime() + forceDelay : m_respawnTime;
|
long thisRespawnTime = forceDelay != 0 ? GameTime.GetGameTime() + forceDelay : m_respawnTime;
|
||||||
GetMap().SaveRespawnTime(SpawnObjectType.Creature, m_spawnId, GetEntry(), thisRespawnTime, GetMap().GetZoneId(GetPhaseShift(), GetHomePosition()), GridDefines.ComputeGridCoord(GetHomePosition().GetPositionX(), GetHomePosition().GetPositionY()).GetId());
|
GetMap().SaveRespawnTime(SpawnObjectType.Creature, m_spawnId, GetEntry(), thisRespawnTime, GridDefines.ComputeGridCoord(GetHomePosition().GetPositionX(), GetHomePosition().GetPositionY()).GetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanCreatureAttack(Unit victim, bool force = true)
|
public bool CanCreatureAttack(Unit victim, bool force = true)
|
||||||
|
|||||||
@@ -1267,7 +1267,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
long thisRespawnTime = forceDelay != 0 ? GameTime.GetGameTime() + forceDelay : m_respawnTime;
|
long thisRespawnTime = forceDelay != 0 ? GameTime.GetGameTime() + forceDelay : m_respawnTime;
|
||||||
GetMap().SaveRespawnTime(SpawnObjectType.GameObject, m_spawnId, GetEntry(), thisRespawnTime, GetZoneId(), GridDefines.ComputeGridCoord(GetPositionX(), GetPositionY()).GetId());
|
GetMap().SaveRespawnTime(SpawnObjectType.GameObject, m_spawnId, GetEntry(), thisRespawnTime, GridDefines.ComputeGridCoord(GetPositionX(), GetPositionY()).GetId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-11
@@ -2487,19 +2487,18 @@ namespace Game.Maps
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PushRespawnInfoFrom(List<RespawnInfo> data, Dictionary<ulong, RespawnInfo> map, uint zoneId)
|
static void PushRespawnInfoFrom(List<RespawnInfo> data, Dictionary<ulong, RespawnInfo> map)
|
||||||
{
|
{
|
||||||
foreach (var pair in map)
|
foreach (var pair in map)
|
||||||
if (zoneId == 0 || pair.Value.zoneId == zoneId)
|
data.Add(pair.Value);
|
||||||
data.Add(pair.Value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetRespawnInfo(List<RespawnInfo> respawnData, SpawnObjectTypeMask types, uint zoneId)
|
public void GetRespawnInfo(List<RespawnInfo> respawnData, SpawnObjectTypeMask types)
|
||||||
{
|
{
|
||||||
if (types.HasAnyFlag(SpawnObjectTypeMask.Creature))
|
if (types.HasAnyFlag(SpawnObjectTypeMask.Creature))
|
||||||
PushRespawnInfoFrom(respawnData, _creatureRespawnTimesBySpawnId, zoneId);
|
PushRespawnInfoFrom(respawnData, _creatureRespawnTimesBySpawnId);
|
||||||
if (types.HasAnyFlag(SpawnObjectTypeMask.GameObject))
|
if (types.HasAnyFlag(SpawnObjectTypeMask.GameObject))
|
||||||
PushRespawnInfoFrom(respawnData, _gameObjectRespawnTimesBySpawnId, zoneId);
|
PushRespawnInfoFrom(respawnData, _gameObjectRespawnTimesBySpawnId);
|
||||||
}
|
}
|
||||||
|
|
||||||
RespawnInfo GetRespawnInfo(SpawnObjectType type, ulong spawnId)
|
RespawnInfo GetRespawnInfo(SpawnObjectType type, ulong spawnId)
|
||||||
@@ -3025,7 +3024,7 @@ namespace Game.Maps
|
|||||||
m_activeNonPlayers.Remove(obj);
|
m_activeNonPlayers.Remove(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveRespawnTime(SpawnObjectType type, ulong spawnId, uint entry, long respawnTime, uint zoneId, uint gridId = 0, SQLTransaction dbTrans = null, bool startup = false)
|
public void SaveRespawnTime(SpawnObjectType type, ulong spawnId, uint entry, long respawnTime, uint gridId = 0, SQLTransaction dbTrans = null, bool startup = false)
|
||||||
{
|
{
|
||||||
if (spawnId == 0)
|
if (spawnId == 0)
|
||||||
return;
|
return;
|
||||||
@@ -3043,7 +3042,6 @@ namespace Game.Maps
|
|||||||
ri.entry = entry;
|
ri.entry = entry;
|
||||||
ri.respawnTime = respawnTime;
|
ri.respawnTime = respawnTime;
|
||||||
ri.gridId = gridId;
|
ri.gridId = gridId;
|
||||||
ri.zoneId = zoneId;
|
|
||||||
bool success = AddRespawnInfo(ri);
|
bool success = AddRespawnInfo(ri);
|
||||||
|
|
||||||
if (startup)
|
if (startup)
|
||||||
@@ -3085,7 +3083,7 @@ namespace Game.Maps
|
|||||||
{
|
{
|
||||||
SpawnData data = Global.ObjectMgr.GetSpawnData(type, spawnId);
|
SpawnData data = Global.ObjectMgr.GetSpawnData(type, spawnId);
|
||||||
if (data != null)
|
if (data != null)
|
||||||
SaveRespawnTime(type, spawnId, data.Id, respawnTime, GetZoneId(PhasingHandler.EmptyPhaseShift, data.spawnPoint), GridDefines.ComputeGridCoord(data.spawnPoint.GetPositionX(), data.spawnPoint.GetPositionY()).GetId(), null, true);
|
SaveRespawnTime(type, spawnId, data.Id, respawnTime, GridDefines.ComputeGridCoord(data.spawnPoint.GetPositionX(), data.spawnPoint.GetPositionY()).GetId(), null, true);
|
||||||
else
|
else
|
||||||
Log.outError(LogFilter.Maps, $"Loading saved respawn time of {respawnTime} for spawnid ({type},{spawnId}) - spawn does not exist, ignoring");
|
Log.outError(LogFilter.Maps, $"Loading saved respawn time of {respawnTime} for spawnid ({type},{spawnId}) - spawn does not exist, ignoring");
|
||||||
}
|
}
|
||||||
@@ -5567,7 +5565,6 @@ namespace Game.Maps
|
|||||||
public uint entry;
|
public uint entry;
|
||||||
public long respawnTime;
|
public long respawnTime;
|
||||||
public uint gridId;
|
public uint gridId;
|
||||||
public uint zoneId;
|
|
||||||
|
|
||||||
public RespawnInfo() { }
|
public RespawnInfo() { }
|
||||||
public RespawnInfo(RespawnInfo info)
|
public RespawnInfo(RespawnInfo info)
|
||||||
@@ -5577,7 +5574,6 @@ namespace Game.Maps
|
|||||||
entry = info.entry;
|
entry = info.entry;
|
||||||
respawnTime = info.respawnTime;
|
respawnTime = info.respawnTime;
|
||||||
gridId = info.gridId;
|
gridId = info.gridId;
|
||||||
zoneId = info.zoneId;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user