Core/OutdoorPvP: Remove manual spawn management functions from OutdoorPvP

Port From (https://github.com/TrinityCore/TrinityCore/commit/21ae3766928641c7af24cd96544fc5b115461e82)
This commit is contained in:
hondacrx
2022-07-19 11:49:53 -04:00
parent 2f1b3dae37
commit 054dd15aa0
-127
View File
@@ -348,50 +348,6 @@ namespace Game.PvP
SendUpdateWorldState(m_capturePoint.GetGoInfo().ControlZone.worldstate3, m_neutralValuePct);
}
void AddGO(uint type, ulong guid)
{
GameObjectData data = Global.ObjectMgr.GetGameObjectData(guid);
if (data == null)
return;
m_Objects[type] = guid;
m_ObjectTypes[guid] = type;
}
void AddCre(uint type, ulong guid)
{
CreatureData data = Global.ObjectMgr.GetCreatureData(guid);
if (data == null)
return;
m_Creatures[type] = guid;
m_CreatureTypes[guid] = type;
}
public bool AddObject(uint type, uint entry, uint map, Position pos, Quaternion rot)
{
ulong guid = Global.ObjectMgr.AddGameObjectData(entry, map, pos, rot, 0);
if (guid != 0)
{
AddGO(type, guid);
return true;
}
return false;
}
public bool AddCreature(uint type, uint entry, uint map, Position pos, uint team, uint spawntimedelay)
{
ulong guid = Global.ObjectMgr.AddCreatureData(entry, map, pos, spawntimedelay);
if (guid != 0)
{
AddCre(type, guid);
return true;
}
return false;
}
public bool SetCapturePointData(uint entry)
{
Log.outDebug(LogFilter.Outdoorpvp, "Creating capture point {0}", entry);
@@ -412,80 +368,6 @@ namespace Game.PvP
return true;
}
public bool SetCapturePointData(uint entry, uint map, Position pos, Quaternion rot)
{
Log.outDebug(LogFilter.Outdoorpvp, $"Creating capture point {entry}");
// check info existence
GameObjectTemplate goinfo = Global.ObjectMgr.GetGameObjectTemplate(entry);
if (goinfo == null || goinfo.type != GameObjectTypes.ControlZone)
{
Log.outError(LogFilter.Outdoorpvp, $"OutdoorPvP: GO {entry} is not capture point!");
return false;
}
m_capturePointSpawnId = Global.ObjectMgr.AddGameObjectData(entry, map, pos, rot, 0);
if (m_capturePointSpawnId == 0)
return false;
SetCapturePointData(entry);
return true;
}
public bool DelCreature(uint type)
{
if (!m_Creatures.ContainsKey(type))
{
Log.outDebug(LogFilter.Outdoorpvp, "opvp creature type {0} was already deleted", type);
return false;
}
ulong spawnId = m_Creatures[type];
Log.outDebug(LogFilter.Outdoorpvp, "deleting opvp creature type {0}", type);
m_CreatureTypes.Remove(spawnId);
m_Creatures.Remove(type);
return Creature.DeleteFromDB(spawnId);
}
public bool DelObject(uint type)
{
ulong spawnId = m_Objects[type];
if (spawnId == 0)
return false;
m_ObjectTypes.Remove(spawnId);
m_Objects.Remove(type);
return GameObject.DeleteFromDB(spawnId);
}
bool DelCapturePoint()
{
Global.ObjectMgr.DeleteGameObjectData(m_capturePointSpawnId);
m_capturePointSpawnId = 0;
if (m_capturePoint)
{
m_capturePoint.SetRespawnTime(0); // not save respawn time
m_capturePoint.Delete();
}
return true;
}
public virtual void DeleteSpawns()
{
foreach (var type in m_Objects.Keys)
DelObject(type);
foreach (var type in m_Creatures.Keys)
DelCreature(type);
DelCapturePoint();
}
public virtual bool Update(uint diff)
{
if (!m_capturePoint)
@@ -672,10 +554,6 @@ namespace Game.PvP
public virtual int HandleOpenGo(Player player, GameObject go)
{
var value = m_ObjectTypes.LookupByKey(go.GetSpawnId());
if (value != 0)
return (int)value;
return -1;
}
@@ -702,11 +580,6 @@ namespace Game.PvP
public uint m_neutralValuePct;
// pointer to the OutdoorPvP this objective belongs to
public OutdoorPvP PvP { get; set; }
public Dictionary<uint, ulong> m_Objects = new();
public Dictionary<uint, ulong> m_Creatures = new();
Dictionary<ulong, uint> m_ObjectTypes = new();
Dictionary<ulong, uint> m_CreatureTypes = new();
}
class DefenseMessageBuilder : MessageBuilder