Core/OutdoorPvP: refactor using Position and Quat to pack parameters
Port From (https://github.com/TrinityCore/TrinityCore/commit/bd96262248fa4d9c8e867b4056e52c44852364c3)
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
using Framework.Constants;
|
||||
using Framework.Database;
|
||||
using Framework.GameMath;
|
||||
using Game.Chat;
|
||||
using Game.DataStorage;
|
||||
using Game.Entities;
|
||||
@@ -375,9 +376,9 @@ namespace Game.PvP
|
||||
m_CreatureTypes[guid] = type;
|
||||
}
|
||||
|
||||
public bool AddObject(uint type, uint entry, uint map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3)
|
||||
public bool AddObject(uint type, uint entry, uint map, Position pos, Quaternion rot)
|
||||
{
|
||||
ulong guid = Global.ObjectMgr.AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3);
|
||||
ulong guid = Global.ObjectMgr.AddGOData(entry, map, pos, rot, 0);
|
||||
if (guid != 0)
|
||||
{
|
||||
AddGO(type, guid);
|
||||
@@ -387,9 +388,9 @@ namespace Game.PvP
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool AddCreature(uint type, uint entry, uint team, uint map, float x, float y, float z, float o, uint spawntimedelay)
|
||||
public bool AddCreature(uint type, uint entry, uint map, Position pos, uint team, uint spawntimedelay)
|
||||
{
|
||||
ulong guid = Global.ObjectMgr.AddCreatureData(entry, team, map, x, y, z, o, spawntimedelay);
|
||||
ulong guid = Global.ObjectMgr.AddCreatureData(entry, map, pos, spawntimedelay);
|
||||
if (guid != 0)
|
||||
{
|
||||
AddCre(type, guid);
|
||||
@@ -399,7 +400,7 @@ namespace Game.PvP
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool SetCapturePointData(uint entry, uint map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3)
|
||||
public bool SetCapturePointData(uint entry, uint map, Position pos, Quaternion rot)
|
||||
{
|
||||
Log.outDebug(LogFilter.Outdoorpvp, "Creating capture point {0}", entry);
|
||||
|
||||
@@ -411,7 +412,7 @@ namespace Game.PvP
|
||||
return false;
|
||||
}
|
||||
|
||||
m_capturePointSpawnId = Global.ObjectMgr.AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3);
|
||||
m_capturePointSpawnId = Global.ObjectMgr.AddGOData(entry, map, pos, rot, 0);
|
||||
if (m_capturePointSpawnId == 0)
|
||||
return false;
|
||||
|
||||
@@ -755,26 +756,14 @@ namespace Game.PvP
|
||||
{
|
||||
entry = _entry;
|
||||
map = _map;
|
||||
x = _x;
|
||||
y = _y;
|
||||
z = _z;
|
||||
o = _o;
|
||||
rot0 = _rot0;
|
||||
rot1 = _rot1;
|
||||
rot2 = _rot2;
|
||||
rot3 = _rot3;
|
||||
pos = new Position(_x, _y, _z, _o);
|
||||
rot = new Quaternion(_rot0, _rot1, _rot2, _rot3);
|
||||
}
|
||||
|
||||
public uint entry;
|
||||
public uint map;
|
||||
public float x;
|
||||
public float y;
|
||||
public float z;
|
||||
public float o;
|
||||
public float rot0;
|
||||
public float rot1;
|
||||
public float rot2;
|
||||
public float rot3;
|
||||
public Position pos;
|
||||
public Quaternion rot;
|
||||
}
|
||||
|
||||
class creature_type
|
||||
@@ -783,17 +772,11 @@ namespace Game.PvP
|
||||
{
|
||||
entry = _entry;
|
||||
map = _map;
|
||||
x = _x;
|
||||
y = _y;
|
||||
z = _z;
|
||||
o = _o;
|
||||
pos = new Position(_x, _y, _z, _o);
|
||||
}
|
||||
|
||||
public uint entry;
|
||||
public uint map;
|
||||
public float x;
|
||||
public float y;
|
||||
public float z;
|
||||
public float o;
|
||||
Position pos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,11 +43,10 @@ namespace Game.PvP
|
||||
}
|
||||
|
||||
uint count = 0;
|
||||
uint typeId = 0;
|
||||
|
||||
do
|
||||
{
|
||||
typeId = result.Read<byte>(0);
|
||||
uint typeId = result.Read<byte>(0);
|
||||
|
||||
if (Global.DisableMgr.IsDisabledFor(DisableType.OutdoorPVP, typeId, null))
|
||||
continue;
|
||||
@@ -58,36 +57,32 @@ namespace Game.PvP
|
||||
continue;
|
||||
}
|
||||
|
||||
OutdoorPvPData data = new OutdoorPvPData();
|
||||
OutdoorPvPTypes realTypeId = (OutdoorPvPTypes)typeId;
|
||||
data.TypeId = realTypeId;
|
||||
data.ScriptId = Global.ObjectMgr.GetScriptId(result.Read<string>(1));
|
||||
m_OutdoorPvPDatas[realTypeId] = data;
|
||||
OutdoorPvPScriptIds[realTypeId] = Global.ObjectMgr.GetScriptId(result.Read<string>(1));
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result.NextRow());
|
||||
|
||||
OutdoorPvP pvp;
|
||||
for (byte i = 1; i < (int)OutdoorPvPTypes.Max; ++i)
|
||||
for (OutdoorPvPTypes outdoorPvpType = OutdoorPvPTypes.HellfirePeninsula; outdoorPvpType < OutdoorPvPTypes.Max; ++outdoorPvpType)
|
||||
{
|
||||
var outdoor = m_OutdoorPvPDatas.LookupByKey((OutdoorPvPTypes)i);
|
||||
if (outdoor == null)
|
||||
if (!OutdoorPvPScriptIds.ContainsKey(outdoorPvpType))
|
||||
{
|
||||
Log.outError(LogFilter.Sql, "Could not initialize OutdoorPvP object for type ID {0}; no entry in database.", i);
|
||||
Log.outError(LogFilter.Sql, "Could not initialize OutdoorPvP object for type ID {0}; no entry in database.", outdoorPvpType);
|
||||
continue;
|
||||
}
|
||||
|
||||
pvp = Global.ScriptMgr.CreateOutdoorPvP(outdoor);
|
||||
pvp = Global.ScriptMgr.CreateOutdoorPvP(OutdoorPvPScriptIds[outdoorPvpType]);
|
||||
if (pvp == null)
|
||||
{
|
||||
Log.outError(LogFilter.Outdoorpvp, "Could not initialize OutdoorPvP object for type ID {0}; got NULL pointer from script.", i);
|
||||
Log.outError(LogFilter.Outdoorpvp, "Could not initialize OutdoorPvP object for type ID {0}; got NULL pointer from script.", outdoorPvpType);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!pvp.SetupOutdoorPvP())
|
||||
{
|
||||
Log.outError(LogFilter.Outdoorpvp, "Could not initialize OutdoorPvP object for type ID {0}; SetupOutdoorPvP failed.", i);
|
||||
Log.outError(LogFilter.Outdoorpvp, "Could not initialize OutdoorPvP object for type ID {0}; SetupOutdoorPvP failed.", outdoorPvpType);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -237,15 +232,9 @@ namespace Game.PvP
|
||||
Dictionary<uint, OutdoorPvP> m_OutdoorPvPMap = new Dictionary<uint, OutdoorPvP>();
|
||||
|
||||
// Holds the outdoor PvP templates
|
||||
Dictionary<OutdoorPvPTypes, OutdoorPvPData> m_OutdoorPvPDatas = new Dictionary<OutdoorPvPTypes, OutdoorPvPData>();
|
||||
Dictionary<OutdoorPvPTypes, uint> OutdoorPvPScriptIds = new Dictionary<OutdoorPvPTypes, uint>();
|
||||
|
||||
// update interval
|
||||
uint m_UpdateTimer;
|
||||
}
|
||||
|
||||
public class OutdoorPvPData
|
||||
{
|
||||
public OutdoorPvPTypes TypeId;
|
||||
public uint ScriptId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,13 +166,8 @@ namespace Game.PvP
|
||||
{
|
||||
m_TowerType = (uint)type;
|
||||
|
||||
var capturepoint = HPConst.CapturePoints[m_TowerType];
|
||||
var towerflag = HPConst.TowerFlags[m_TowerType];
|
||||
|
||||
SetCapturePointData(capturepoint.entry, capturepoint.map, capturepoint.x, capturepoint.y, capturepoint.z, capturepoint.o, capturepoint.rot0,
|
||||
capturepoint.rot1, capturepoint.rot2, capturepoint.rot3);
|
||||
|
||||
AddObject((uint)type, towerflag.entry, towerflag.map, towerflag.x, towerflag.y, towerflag.z, towerflag.o, towerflag.rot0, towerflag.rot1, towerflag.rot2, towerflag.rot3);
|
||||
SetCapturePointData(HPConst.CapturePoints[m_TowerType].entry, HPConst.CapturePoints[m_TowerType].map, HPConst.CapturePoints[m_TowerType].pos, HPConst.CapturePoints[m_TowerType].rot);
|
||||
AddObject(m_TowerType, HPConst.TowerFlags[m_TowerType].entry, HPConst.TowerFlags[m_TowerType].map, HPConst.TowerFlags[m_TowerType].pos, HPConst.TowerFlags[m_TowerType].rot);
|
||||
}
|
||||
|
||||
public override void ChangeState()
|
||||
|
||||
Reference in New Issue
Block a user