Core/OutdoorPvP: refactor using Position and Quat to pack parameters
Port From (https://github.com/TrinityCore/TrinityCore/commit/bd96262248fa4d9c8e867b4056e52c44852364c3)
This commit is contained in:
@@ -3460,7 +3460,7 @@ namespace Game
|
|||||||
cellguids.creatures.Remove(guid);
|
cellguids.creatures.Remove(guid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public ulong AddCreatureData(uint entry, uint team, uint mapId, float x, float y, float z, float o, uint spawntimedelay)
|
public ulong AddCreatureData(uint entry, uint mapId, Position pos, uint spawntimedelay)
|
||||||
{
|
{
|
||||||
CreatureTemplate cInfo = GetCreatureTemplate(entry);
|
CreatureTemplate cInfo = GetCreatureTemplate(entry);
|
||||||
if (cInfo == null)
|
if (cInfo == null)
|
||||||
@@ -3480,10 +3480,7 @@ namespace Game
|
|||||||
data.mapid = (ushort)mapId;
|
data.mapid = (ushort)mapId;
|
||||||
data.displayid = 0;
|
data.displayid = 0;
|
||||||
data.equipmentId = 0;
|
data.equipmentId = 0;
|
||||||
data.posX = x;
|
pos.GetPosition(out data.posX, out data.posY, out data.posZ, out data.orientation);
|
||||||
data.posY = y;
|
|
||||||
data.posZ = z;
|
|
||||||
data.orientation = o;
|
|
||||||
data.spawntimesecs = spawntimedelay;
|
data.spawntimesecs = spawntimedelay;
|
||||||
data.spawndist = 0;
|
data.spawndist = 0;
|
||||||
data.currentwaypoint = 0;
|
data.currentwaypoint = 0;
|
||||||
@@ -3499,7 +3496,7 @@ namespace Game
|
|||||||
AddCreatureToGrid(guid, data);
|
AddCreatureToGrid(guid, data);
|
||||||
|
|
||||||
// We use spawn coords to spawn
|
// We use spawn coords to spawn
|
||||||
if (!map.Instanceable() && !map.IsRemovalGrid(x, y))
|
if (!map.Instanceable() && !map.IsRemovalGrid(data.posX, data.posY))
|
||||||
{
|
{
|
||||||
Creature creature = Creature.CreateCreatureFromDB(guid, map);
|
Creature creature = Creature.CreateCreatureFromDB(guid, map);
|
||||||
if (!creature)
|
if (!creature)
|
||||||
@@ -4332,7 +4329,7 @@ namespace Game
|
|||||||
cellguids.gameobjects.Remove(guid);
|
cellguids.gameobjects.Remove(guid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public ulong AddGOData(uint entry, uint mapId, float x, float y, float z, float o, uint spawntimedelay, float rotation0, float rotation1, float rotation2, float rotation3)
|
public ulong AddGOData(uint entry, uint mapId, Position pos, Quaternion rot, uint spawntimedelay)
|
||||||
{
|
{
|
||||||
GameObjectTemplate goinfo = GetGameObjectTemplate(entry);
|
GameObjectTemplate goinfo = GetGameObjectTemplate(entry);
|
||||||
if (goinfo == null)
|
if (goinfo == null)
|
||||||
@@ -4346,14 +4343,8 @@ namespace Game
|
|||||||
GameObjectData data = new GameObjectData();
|
GameObjectData data = new GameObjectData();
|
||||||
data.id = entry;
|
data.id = entry;
|
||||||
data.mapid = (ushort)mapId;
|
data.mapid = (ushort)mapId;
|
||||||
data.posX = x;
|
pos.GetPosition(out data.posX, out data.posY, out data.posZ, out data.orientation);
|
||||||
data.posY = y;
|
data.rotation = rot;
|
||||||
data.posZ = z;
|
|
||||||
data.orientation = o;
|
|
||||||
data.rotation.X = rotation0;
|
|
||||||
data.rotation.Y = rotation1;
|
|
||||||
data.rotation.Z = rotation2;
|
|
||||||
data.rotation.W = rotation3;
|
|
||||||
data.spawntimesecs = (int)spawntimedelay;
|
data.spawntimesecs = (int)spawntimedelay;
|
||||||
data.animprogress = 100;
|
data.animprogress = 100;
|
||||||
data.spawnDifficulties.Add(Difficulty.None);
|
data.spawnDifficulties.Add(Difficulty.None);
|
||||||
@@ -4366,7 +4357,7 @@ namespace Game
|
|||||||
|
|
||||||
// Spawn if necessary (loaded grids only)
|
// Spawn if necessary (loaded grids only)
|
||||||
// We use spawn coords to spawn
|
// We use spawn coords to spawn
|
||||||
if (!map.Instanceable() && map.IsGridLoaded(x, y))
|
if (!map.Instanceable() && map.IsGridLoaded(data.posX, data.posY))
|
||||||
{
|
{
|
||||||
GameObject go = GameObject.CreateGameObjectFromDB(guid, map);
|
GameObject go = GameObject.CreateGameObjectFromDB(guid, map);
|
||||||
if (!go)
|
if (!go)
|
||||||
@@ -4376,7 +4367,7 @@ namespace Game
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.outDebug(LogFilter.Maps, "AddGOData: dbguid:{0} entry:{1} map:{2} x:{3} y:{4} z:{5} o:{6}", guid, entry, mapId, x, y, z, o);
|
Log.outDebug(LogFilter.Maps, "AddGOData: dbguid:{0} entry:{1} map:{2} x:{3} y:{4} z:{5} o:{6}", guid, entry, mapId, data.posX, data.posY, data.posZ, data.orientation);
|
||||||
|
|
||||||
return guid;
|
return guid;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
using Framework.Constants;
|
using Framework.Constants;
|
||||||
using Framework.Database;
|
using Framework.Database;
|
||||||
|
using Framework.GameMath;
|
||||||
using Game.Chat;
|
using Game.Chat;
|
||||||
using Game.DataStorage;
|
using Game.DataStorage;
|
||||||
using Game.Entities;
|
using Game.Entities;
|
||||||
@@ -375,9 +376,9 @@ namespace Game.PvP
|
|||||||
m_CreatureTypes[guid] = type;
|
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)
|
if (guid != 0)
|
||||||
{
|
{
|
||||||
AddGO(type, guid);
|
AddGO(type, guid);
|
||||||
@@ -387,9 +388,9 @@ namespace Game.PvP
|
|||||||
return false;
|
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)
|
if (guid != 0)
|
||||||
{
|
{
|
||||||
AddCre(type, guid);
|
AddCre(type, guid);
|
||||||
@@ -399,7 +400,7 @@ namespace Game.PvP
|
|||||||
return false;
|
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);
|
Log.outDebug(LogFilter.Outdoorpvp, "Creating capture point {0}", entry);
|
||||||
|
|
||||||
@@ -411,7 +412,7 @@ namespace Game.PvP
|
|||||||
return false;
|
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)
|
if (m_capturePointSpawnId == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -755,26 +756,14 @@ namespace Game.PvP
|
|||||||
{
|
{
|
||||||
entry = _entry;
|
entry = _entry;
|
||||||
map = _map;
|
map = _map;
|
||||||
x = _x;
|
pos = new Position(_x, _y, _z, _o);
|
||||||
y = _y;
|
rot = new Quaternion(_rot0, _rot1, _rot2, _rot3);
|
||||||
z = _z;
|
|
||||||
o = _o;
|
|
||||||
rot0 = _rot0;
|
|
||||||
rot1 = _rot1;
|
|
||||||
rot2 = _rot2;
|
|
||||||
rot3 = _rot3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint entry;
|
public uint entry;
|
||||||
public uint map;
|
public uint map;
|
||||||
public float x;
|
public Position pos;
|
||||||
public float y;
|
public Quaternion rot;
|
||||||
public float z;
|
|
||||||
public float o;
|
|
||||||
public float rot0;
|
|
||||||
public float rot1;
|
|
||||||
public float rot2;
|
|
||||||
public float rot3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class creature_type
|
class creature_type
|
||||||
@@ -783,17 +772,11 @@ namespace Game.PvP
|
|||||||
{
|
{
|
||||||
entry = _entry;
|
entry = _entry;
|
||||||
map = _map;
|
map = _map;
|
||||||
x = _x;
|
pos = new Position(_x, _y, _z, _o);
|
||||||
y = _y;
|
|
||||||
z = _z;
|
|
||||||
o = _o;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint entry;
|
public uint entry;
|
||||||
public uint map;
|
public uint map;
|
||||||
public float x;
|
Position pos;
|
||||||
public float y;
|
|
||||||
public float z;
|
|
||||||
public float o;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,11 +43,10 @@ namespace Game.PvP
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint count = 0;
|
uint count = 0;
|
||||||
uint typeId = 0;
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
typeId = result.Read<byte>(0);
|
uint typeId = result.Read<byte>(0);
|
||||||
|
|
||||||
if (Global.DisableMgr.IsDisabledFor(DisableType.OutdoorPVP, typeId, null))
|
if (Global.DisableMgr.IsDisabledFor(DisableType.OutdoorPVP, typeId, null))
|
||||||
continue;
|
continue;
|
||||||
@@ -58,36 +57,32 @@ namespace Game.PvP
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
OutdoorPvPData data = new OutdoorPvPData();
|
|
||||||
OutdoorPvPTypes realTypeId = (OutdoorPvPTypes)typeId;
|
OutdoorPvPTypes realTypeId = (OutdoorPvPTypes)typeId;
|
||||||
data.TypeId = realTypeId;
|
OutdoorPvPScriptIds[realTypeId] = Global.ObjectMgr.GetScriptId(result.Read<string>(1));
|
||||||
data.ScriptId = Global.ObjectMgr.GetScriptId(result.Read<string>(1));
|
|
||||||
m_OutdoorPvPDatas[realTypeId] = data;
|
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
while (result.NextRow());
|
while (result.NextRow());
|
||||||
|
|
||||||
OutdoorPvP pvp;
|
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 (!OutdoorPvPScriptIds.ContainsKey(outdoorPvpType))
|
||||||
if (outdoor == null)
|
|
||||||
{
|
{
|
||||||
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pvp = Global.ScriptMgr.CreateOutdoorPvP(outdoor);
|
pvp = Global.ScriptMgr.CreateOutdoorPvP(OutdoorPvPScriptIds[outdoorPvpType]);
|
||||||
if (pvp == null)
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pvp.SetupOutdoorPvP())
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,15 +232,9 @@ namespace Game.PvP
|
|||||||
Dictionary<uint, OutdoorPvP> m_OutdoorPvPMap = new Dictionary<uint, OutdoorPvP>();
|
Dictionary<uint, OutdoorPvP> m_OutdoorPvPMap = new Dictionary<uint, OutdoorPvP>();
|
||||||
|
|
||||||
// Holds the outdoor PvP templates
|
// Holds the outdoor PvP templates
|
||||||
Dictionary<OutdoorPvPTypes, OutdoorPvPData> m_OutdoorPvPDatas = new Dictionary<OutdoorPvPTypes, OutdoorPvPData>();
|
Dictionary<OutdoorPvPTypes, uint> OutdoorPvPScriptIds = new Dictionary<OutdoorPvPTypes, uint>();
|
||||||
|
|
||||||
// update interval
|
// update interval
|
||||||
uint m_UpdateTimer;
|
uint m_UpdateTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OutdoorPvPData
|
|
||||||
{
|
|
||||||
public OutdoorPvPTypes TypeId;
|
|
||||||
public uint ScriptId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,13 +166,8 @@ namespace Game.PvP
|
|||||||
{
|
{
|
||||||
m_TowerType = (uint)type;
|
m_TowerType = (uint)type;
|
||||||
|
|
||||||
var capturepoint = HPConst.CapturePoints[m_TowerType];
|
SetCapturePointData(HPConst.CapturePoints[m_TowerType].entry, HPConst.CapturePoints[m_TowerType].map, HPConst.CapturePoints[m_TowerType].pos, HPConst.CapturePoints[m_TowerType].rot);
|
||||||
var towerflag = HPConst.TowerFlags[m_TowerType];
|
AddObject(m_TowerType, HPConst.TowerFlags[m_TowerType].entry, HPConst.TowerFlags[m_TowerType].map, HPConst.TowerFlags[m_TowerType].pos, HPConst.TowerFlags[m_TowerType].rot);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ChangeState()
|
public override void ChangeState()
|
||||||
|
|||||||
@@ -729,10 +729,9 @@ namespace Game.Scripting
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OutdoorPvPScript
|
// OutdoorPvPScript
|
||||||
public OutdoorPvP CreateOutdoorPvP(OutdoorPvPData data)
|
public OutdoorPvP CreateOutdoorPvP(uint scriptId)
|
||||||
{
|
{
|
||||||
Cypher.Assert(data != null);
|
return RunScriptRet<OutdoorPvPScript, OutdoorPvP>(p => p.GetOutdoorPvP(), scriptId, null);
|
||||||
return RunScriptRet<OutdoorPvPScript, OutdoorPvP>(p => p.GetOutdoorPvP(), data.ScriptId, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// WeatherScript
|
// WeatherScript
|
||||||
|
|||||||
Reference in New Issue
Block a user