Misc cleanups/Fixes

This commit is contained in:
hondacrx
2020-12-07 10:07:26 -05:00
parent 5aa1c08ca1
commit 7e2df34250
39 changed files with 513 additions and 245 deletions
@@ -89,7 +89,7 @@ namespace Framework.Collections
Exchange(1, Size--);
Sink(1);
_qp[min] = -1;
_keys[_pq[Size + 1]] = default(T);
_keys[_pq[Size + 1]] = default;
_pq[Size + 1] = -1;
return min;
}
@@ -143,7 +143,7 @@ namespace Framework.Collections
Exchange(i, Size--);
Swim(i);
Sink(i);
_keys[index] = default(T);
_keys[index] = default;
_qp[index] = -1;
}
private bool Greater(int i, int j)
+2 -2
View File
@@ -137,7 +137,7 @@ namespace System.Collections.Generic
{
if (!_interalStorage.ContainsKey(key))
{
value = default(TValue);
value = default;
return false;
}
value = _interalStorage[key].Last();
@@ -381,7 +381,7 @@ namespace System.Collections.Generic
{
if (!_interalStorage.ContainsKey(key))
{
value = default(TValue);
value = default;
return false;
}
value = _interalStorage[key].Last();
+2 -2
View File
@@ -42,7 +42,7 @@ namespace Framework.Database
var value = _reader[column];
if (value == DBNull.Value)
return default(T);
return default;
if (value.GetType() != typeof(T))
return (T)Convert.ChangeType(value, typeof(T));//todo remove me when all fields are the right type this is super slow
@@ -105,7 +105,7 @@ namespace Framework.Database
var value = _currentRow[column];
if (value == DBNull.Value)
return default(T);
return default;
if (value.GetType() != typeof(T))
return (T)Convert.ChangeType(value, typeof(T));//todo remove me when all fields are the right type this is super slow
+2 -2
View File
@@ -317,7 +317,7 @@ namespace Framework.Dynamic
/// Cancel events belonging to specified group.
/// </summary>
/// <param name="group">Group to cancel.</param>
void CancelEventGroup(uint group)
public void CancelEventGroup(uint group)
{
if (group == 0 || group > 8 || Empty())
return;
@@ -334,7 +334,7 @@ namespace Framework.Dynamic
/// </summary>
/// <param name="eventId">Wanted event id.</param>
/// <returns>Time of found event.</returns>
uint GetNextEventTime(uint eventId)
public uint GetNextEventTime(uint eventId)
{
if (Empty())
return 0;
+24 -24
View File
@@ -64,145 +64,145 @@ namespace Framework.IO
public char NextChar(string delimiters = " ")
{
if (!MoveNext(delimiters))
return default(char);
return default;
char value;
if (char.TryParse(Current, out value))
return value;
return default(char);
return default;
}
public byte NextByte(string delimiters = " ")
{
if (!MoveNext(delimiters))
return default(byte);
return default;
byte value;
if (byte.TryParse(Current, out value))
return value;
return default(byte);
return default;
}
public sbyte NextSByte(string delimiters = " ")
{
if (!MoveNext(delimiters))
return default(sbyte);
return default;
sbyte value;
if (sbyte.TryParse(Current, out value))
return value;
return default(sbyte);
return default;
}
public ushort NextUInt16(string delimiters = " ")
{
if (!MoveNext(delimiters))
return default(ushort);
return default;
ushort value;
if (ushort.TryParse(Current, out value))
return value;
return default(ushort);
return default;
}
public short NextInt16(string delimiters = " ")
{
if (!MoveNext(delimiters))
return default(short);
return default;
short value;
if (short.TryParse(Current, out value))
return value;
return default(short);
return default;
}
public uint NextUInt32(string delimiters = " ")
{
if (!MoveNext(delimiters))
return default(uint);
return default;
uint value;
if (uint.TryParse(Current, out value))
return value;
return default(uint);
return default;
}
public int NextInt32(string delimiters = " ")
{
if (!MoveNext(delimiters))
return default(int);
return default;
int value;
if (int.TryParse(Current, out value))
return value;
return default(int);
return default;
}
public ulong NextUInt64(string delimiters = " ")
{
if (!MoveNext(delimiters))
return default(ulong);
return default;
ulong value;
if (ulong.TryParse(Current, out value))
return value;
return default(ulong);
return default;
}
public long NextInt64(string delimiters = " ")
{
if (!MoveNext(delimiters))
return default(long);
return default;
long value;
if (long.TryParse(Current, out value))
return value;
return default(long);
return default;
}
public float NextSingle(string delimiters = " ")
{
if (!MoveNext(delimiters))
return default(float);
return default;
float value;
if (float.TryParse(Current, out value))
return value;
return default(float);
return default;
}
public double NextDouble(string delimiters = " ")
{
if (!MoveNext(delimiters))
return default(double);
return default;
double value;
if (double.TryParse(Current, out value))
return value;
return default(double);
return default;
}
public decimal NextDecimal(string delimiters = " ")
{
if (!MoveNext(delimiters))
return default(decimal);
return default;
decimal value;
if (decimal.TryParse(Current, out value))
return value;
return default(decimal);
return default;
}
public void AlignToNextChar()
@@ -48,7 +48,7 @@ namespace Framework.Threading
public bool Pop(out T value)
{
value = default(T);
value = default;
lock (_queueLock)
{
if (_queue.Count == 0 || _shutdown)
@@ -61,7 +61,7 @@ namespace Framework.Threading
public void WaitAndPop(out T value)
{
value = default(T);
value = default;
lock (_queueLock)
{
while (_queue.Count == 0 && !_shutdown)
@@ -41,7 +41,7 @@ namespace System.Collections.Generic
/// <returns>The value, or the default value of the element type.</returns>
public static T LookupByIndex<T>(this IList<T> list, int index)
{
return index >= list.Count ? default(T) : list[index];
return index >= list.Count ? default : list[index];
}
/// <summary>
@@ -57,17 +57,17 @@ namespace System.Collections.Generic
{
TValue val;
TKey newkey = (TKey)Convert.ChangeType(key, typeof(TKey));
return dict.TryGetValue(newkey, out val) ? val : default(TValue);
return dict.TryGetValue(newkey, out val) ? val : default;
}
public static TValue LookupByKey<TKey, TValue>(this IDictionary<TKey, TValue> dict, TKey key)
{
TValue val;
return dict.TryGetValue(key, out val) ? val : default(TValue);
return dict.TryGetValue(key, out val) ? val : default;
}
public static KeyValuePair<TKey, TValue> Find<TKey, TValue>(this IDictionary<TKey, TValue> dict, TKey key)
{
if (!dict.ContainsKey(key))
return default(KeyValuePair<TKey, TValue>);
return default;
return new KeyValuePair<TKey, TValue>(key, dict[key]);
}
@@ -106,7 +106,7 @@ namespace System.Collections.Generic
else
{
for (var i = list.Count; i < size; ++i)
list.Add(default(T));
list.Add(default);
}
}
@@ -161,7 +161,7 @@ namespace System.Collections.Generic
}
return default(T);
return default;
}
public static IEnumerable<TSource> Intersect<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second, Func<TSource, TSource, bool> comparer)
+1 -1
View File
@@ -216,7 +216,7 @@ namespace System
{
T value;
if (!Enum.TryParse(str, out value))
return default(T);
return default;
return value;
}
+1
View File
@@ -492,6 +492,7 @@ namespace Game.AI
protected EventMap _events = new EventMap();
protected TaskScheduler _scheduler = new TaskScheduler();
protected InstanceScript _instance;
}
public struct AISpellInfoType
+1 -1
View File
@@ -88,7 +88,7 @@ namespace Game.AI
public class NullCreatureAI : CreatureAI
{
public NullCreatureAI(Creature c) : base(c)
public NullCreatureAI(Creature creature) : base(creature)
{
me.SetReactState(ReactStates.Passive);
}
+16 -21
View File
@@ -132,7 +132,7 @@ namespace Game.AI
/// Select the best target (in <targetType> order) satisfying <predicate> from the threat list.
/// If <offset> is nonzero, the first <offset> entries in <targetType> order (or MAXTHREAT order, if <targetType> is RANDOM) are skipped.
/// </summary>
public Unit SelectTarget(SelectAggroTarget targetType, uint offset, ISelector selector)
public Unit SelectTarget(SelectAggroTarget targetType, uint offset, ICheck<Unit> selector)
{
ThreatManager mgr = GetThreatManager();
// shortcut: if we ignore the first <offset> elements, and there are at most <offset> elements, then we ignore ALL elements
@@ -170,7 +170,7 @@ namespace Game.AI
/// - Does not have aura with ID -<aura> (if aura < 0)
/// The resulting targets are stored in <targetList> (which is cleared first).
/// </summary>
public List<Unit> SelectTargetList(uint num, SelectAggroTarget targetType, uint offset, float dist, bool playerOnly, bool withTank, int aura = 0)
public List<Unit> SelectTargetList(uint num, SelectAggroTarget targetType, uint offset = 0, float dist = 0f, bool playerOnly = false, bool withTank = true, int aura = 0)
{
return SelectTargetList(num, targetType, offset, new DefaultTargetSelector(me, dist, playerOnly, withTank, aura));
}
@@ -179,7 +179,7 @@ namespace Game.AI
/// Select the best (up to) <num> targets (in <targetType> order) satisfying <predicate> from the threat list and stores them in <targetList> (which is cleared first).
/// If <offset> is nonzero, the first <offset> entries in <targetType> order (or MAXTHREAT order, if <targetType> is RANDOM) are skipped.
/// </summary>
public List<Unit> SelectTargetList(uint num, SelectAggroTarget targetType, uint offset, ISelector selector)
public List<Unit> SelectTargetList(uint num, SelectAggroTarget targetType, uint offset, ICheck<Unit> selector)
{
var targetList = new List<Unit>();
@@ -238,7 +238,7 @@ namespace Game.AI
}
// then finally filter by predicate
targetList.RemoveAll(target => { return !selector.Check(target); });
targetList.RemoveAll(unit => !selector.Invoke(unit));
if (targetList.Count <= num)
return targetList;
@@ -289,7 +289,7 @@ namespace Game.AI
DefaultTargetSelector targetSelector = new DefaultTargetSelector(me, range, playerOnly, true, -(int)spellId);
if (!spellInfo.HasAuraInterruptFlag(SpellAuraInterruptFlags.NotVictim)
&& targetSelector.Check(me.GetVictim()))
&& targetSelector.Invoke(me.GetVictim()))
target = me.GetVictim();
else
target = SelectTarget(SelectAggroTarget.Random, 0, targetSelector);
@@ -549,13 +549,8 @@ namespace Game.AI
MinDistance // prefer targets closer to us
}
public interface ISelector
{
bool Check(Unit target);
}
// default predicate function to select target based on distance, player and/or aura criteria
public class DefaultTargetSelector : ISelector
public class DefaultTargetSelector : ICheck<Unit>
{
Unit me;
float m_dist;
@@ -577,7 +572,7 @@ namespace Game.AI
m_aura = aura;
}
public bool Check(Unit target)
public bool Invoke(Unit target)
{
if (me == null)
return false;
@@ -611,13 +606,13 @@ namespace Game.AI
}
}
return true;
return false;
}
}
// Target selector for spell casts checking range, auras and attributes
// todo Add more checks from Spell.CheckCast
public class SpellTargetSelector : ISelector
public class SpellTargetSelector : ICheck<Unit>
{
public SpellTargetSelector(Unit caster, uint spellId)
{
@@ -627,7 +622,7 @@ namespace Game.AI
Cypher.Assert(_spellInfo != null);
}
public bool Check(Unit target)
public bool Invoke(Unit target)
{
if (target == null)
return false;
@@ -698,7 +693,7 @@ namespace Game.AI
// Very simple target selector, will just skip main target
// NOTE: When passing to UnitAI.SelectTarget remember to use 0 as position for random selection
// because tank will not be in the temporary list
public class NonTankTargetSelector : ISelector
public class NonTankTargetSelector : ICheck<Unit>
{
public NonTankTargetSelector(Unit source, bool playerOnly = true)
{
@@ -706,7 +701,7 @@ namespace Game.AI
_playerOnly = playerOnly;
}
public bool Check(Unit target)
public bool Invoke(Unit target)
{
if (target == null)
return false;
@@ -726,7 +721,7 @@ namespace Game.AI
}
// Simple selector for units using mana
class PowerUsersSelector : ISelector
class PowerUsersSelector : ICheck<Unit>
{
public PowerUsersSelector(Unit unit, PowerType power, float dist, bool playerOnly)
{
@@ -736,7 +731,7 @@ namespace Game.AI
_playerOnly = playerOnly;
}
public bool Check(Unit target)
public bool Invoke(Unit target)
{
if (_me == null || target == null)
return false;
@@ -762,7 +757,7 @@ namespace Game.AI
bool _playerOnly;
}
class FarthestTargetSelector : ISelector
class FarthestTargetSelector : ICheck<Unit>
{
public FarthestTargetSelector(Unit unit, float dist, bool playerOnly, bool inLos)
{
@@ -772,7 +767,7 @@ namespace Game.AI
_inLos = inLos;
}
public bool Check(Unit target)
public bool Invoke(Unit target)
{
if (_me == null || target == null)
return false;
+2 -2
View File
@@ -1366,7 +1366,7 @@ namespace Game.AI
bool _isFollowing;
}
struct ValidTargetSelectPredicate : ISelector
struct ValidTargetSelectPredicate : ICheck<Unit>
{
UnitAI _ai;
@@ -1375,7 +1375,7 @@ namespace Game.AI
_ai = ai;
}
public bool Check(Unit target)
public bool Invoke(Unit target)
{
return _ai.CanAIAttack(target);
}
+30 -5
View File
@@ -35,7 +35,7 @@ namespace Game.AI
_difficulty = me.GetMap().GetDifficultyID();
}
void AttackStartNoMove(Unit target)
public void AttackStartNoMove(Unit target)
{
if (target == null)
return;
@@ -150,7 +150,7 @@ namespace Game.AI
/// </summary>
/// <param name="victim"></param>
/// <param name="who"></param>
void ResetThreat(Unit victim, Unit who)
public void ResetThreat(Unit victim, Unit who)
{
if (!victim)
return;
@@ -261,7 +261,7 @@ namespace Game.AI
return apSpell[RandomHelper.IRand(0, (int)(spellCount - 1))];
}
void DoTeleportTo(float x, float y, float z, uint time = 0)
public void DoTeleportTo(float x, float y, float z, uint time = 0)
{
me.Relocate(x, y, z);
float speed = me.GetDistance(x, y, z) / (time * 0.001f);
@@ -274,7 +274,7 @@ namespace Game.AI
}
//Teleports a player without dropping threat (only teleports to same map)
void DoTeleportPlayer(Unit unit, float x, float y, float z, float o)
public void DoTeleportPlayer(Unit unit, float x, float y, float z, float o)
{
if (unit == null)
return;
@@ -527,7 +527,7 @@ namespace Game.AI
ScheduleTasks();
}
void TeleportCheaters()
public void TeleportCheaters()
{
float x, y, z;
me.GetPosition(out x, out y, out z);
@@ -748,6 +748,11 @@ namespace Game.AI
public void Despawn(Creature summon) { Remove(summon.GetGUID()); }
public void DespawnIf(ICheck<ObjectGuid> predicate)
{
this.RemoveAll(predicate);
}
public void DespawnIf(Predicate<ObjectGuid> predicate)
{
RemoveAll(predicate);
@@ -762,6 +767,14 @@ namespace Game.AI
}
}
public void DoAction(int info, ICheck<ObjectGuid> predicate, ushort max = 0)
{
// We need to use a copy of SummonList here, otherwise original SummonList would be modified
List<ObjectGuid> listCopy = new List<ObjectGuid>(this);
listCopy.RandomResize(predicate.Invoke, max);
DoActionImpl(info, listCopy);
}
public void DoAction(int info, Predicate<ObjectGuid> predicate, ushort max = 0)
{
// We need to use a copy of SummonList here, otherwise original SummonList would be modified
@@ -794,4 +807,16 @@ namespace Game.AI
Creature me;
}
public class EntryCheckPredicate : ICheck<ObjectGuid>
{
public EntryCheckPredicate(uint entry)
{
_entry = entry;
}
public bool Invoke(ObjectGuid guid) { return guid.GetEntry() == _entry; }
uint _entry;
}
}
@@ -35,6 +35,8 @@ namespace Game.AI
_activeAttacker = true;
_despawnAtEnd = true;
_despawnAtFar = true;
_path = new WaypointPath();
}
public Player GetPlayerForEscort()
+1
View File
@@ -117,6 +117,7 @@ namespace Game.AI
return false;
}
_path = new WaypointPath();
_path.id = path.id;
_path.nodes = path.nodes;
foreach (WaypointNode waypoint in _path.nodes)
+2
View File
@@ -385,6 +385,8 @@ namespace Game.Combat
return iUnitGuid;
}
public Unit GetVictim() { return GetTarget(); }
public new HostileReference Next() { return (HostileReference)base.Next(); }
float iThreat;
@@ -474,8 +474,8 @@ namespace Game.Entities
uint visualStateAfter = (m_goValue.Transport.StateUpdateTimer / 20000) & 1;
if (visualStateBefore != visualStateAfter)
{
m_gameObjectData.ModifyValue(m_gameObjectData.Level);
m_gameObjectData.ModifyValue(m_gameObjectData.State);
m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.Level);
m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.State);
ForceUpdateFieldChange();
}
}
+7 -3
View File
@@ -1504,6 +1504,11 @@ namespace Game.Entities
return summon;
}
public void SummonCreatureGroup(byte group)
{
SummonCreatureGroup(group, out _);
}
public void SummonCreatureGroup(byte group, out List<TempSummon> list)
{
Cypher.Assert((IsTypeId(TypeId.GameObject) || IsTypeId(TypeId.Unit)), "Only GOs and creatures can summon npc groups!");
@@ -2028,12 +2033,11 @@ namespace Game.Entities
UpdateGroundPositionZ(rand_x, rand_y, ref rand_z); // update to LOS height if available
}
public void GetRandomPoint(Position srcPos, float distance, out Position pos)
public Position GetRandomPoint(Position srcPos, float distance)
{
pos = new Position();
float x, y, z;
GetRandomPoint(srcPos, distance, out x, out y, out z);
pos.Relocate(x, y, z, GetOrientation());
return new Position(x, y, z, GetOrientation());
}
public void UpdateGroundPositionZ(float x, float y, ref float z)
+6 -3
View File
@@ -7692,14 +7692,17 @@ namespace Game.Entities
}
//Helpers
public void ADD_GOSSIP_ITEM(GossipOptionIcon icon, string message, uint sender, uint action) { PlayerTalkClass.GetGossipMenu().AddMenuItem(-1, icon, message, sender, action, "", 0); }
public void AddGossipItem(GossipOptionIcon icon, string message, uint sender, uint action) { PlayerTalkClass.GetGossipMenu().AddMenuItem(-1, icon, message, sender, action, "", 0); }
public void ADD_GOSSIP_ITEM_DB(uint menuId, uint menuItemId, uint sender, uint action) { PlayerTalkClass.GetGossipMenu().AddMenuItem(menuId, menuItemId, sender, action); }
public void ADD_GOSSIP_ITEM_EXTENDED(GossipOptionIcon icon, string message, uint sender, uint action, string boxmessage, uint boxmoney, bool coded) { PlayerTalkClass.GetGossipMenu().AddMenuItem(-1, icon, message, sender, action, boxmessage, boxmoney, coded); }
// This fuction Sends the current menu to show to client, a - NPCTEXTID(uint32), b - npc guid(uint64)
public void SEND_GOSSIP_MENU(uint titleId, ObjectGuid objGUID) { PlayerTalkClass.SendGossipMenu(titleId, objGUID); }
public void SendGossipMenu(uint titleId, ObjectGuid objGUID) { PlayerTalkClass.SendGossipMenu(titleId, objGUID); }
// Closes the Menu
public void CLOSE_GOSSIP_MENU() { PlayerTalkClass.SendCloseGossip(); }
public void CloseGossipMenu() { PlayerTalkClass.SendCloseGossip(); }
//Clears the Menu
public void ClearGossipMenu() { PlayerTalkClass.ClearMenus(); }
}
}
+2 -2
View File
@@ -514,9 +514,9 @@ namespace Game.Entities
public bool HealthBelowPct(int pct) { return GetHealth() < CountPctFromMaxHealth(pct); }
public bool HealthBelowPctDamaged(int pct, uint damage) { return GetHealth() - damage < CountPctFromMaxHealth(pct); }
public bool HealthAbovePct(int pct) { return GetHealth() > CountPctFromMaxHealth(pct); }
bool HealthAbovePctHealed(int pct, uint heal) { return GetHealth() + heal > CountPctFromMaxHealth(pct); }
public bool HealthAbovePctHealed(int pct, uint heal) { return GetHealth() + heal > CountPctFromMaxHealth(pct); }
public ulong CountPctFromMaxHealth(int pct) { return MathFunctions.CalculatePct(GetMaxHealth(), pct); }
ulong CountPctFromCurHealth(int pct) { return MathFunctions.CalculatePct(GetHealth(), pct); }
public ulong CountPctFromCurHealth(int pct) { return MathFunctions.CalculatePct(GetHealth(), pct); }
public virtual float GetHealthMultiplierForTarget(WorldObject target) { return 1.0f; }
public virtual float GetDamageMultiplierForTarget(WorldObject target) { return 1.0f; }
+1 -1
View File
@@ -509,7 +509,7 @@ namespace Game.Entities
public Unit GetDispeller() { return _dispellerUnit; }
uint GetDispellerSpellId() { return _dispellerSpell; }
public byte GetRemovedCharges() { return _chargesRemoved; }
void SetRemovedCharges(byte amount)
public void SetRemovedCharges(byte amount)
{
_chargesRemoved = amount;
}
+1 -1
View File
@@ -39,7 +39,7 @@ namespace Game.Entities
{
return m_movementInfo.HasMovementFlag(MovementFlag.Walking);
}
bool IsHovering() { return m_movementInfo.HasMovementFlag(MovementFlag.Hover); }
public bool IsHovering() { return m_movementInfo.HasMovementFlag(MovementFlag.Hover); }
public bool IsStopped() { return !HasUnitState(UnitState.Moving); }
public bool IsMoving() { return m_movementInfo.HasMovementFlag(MovementFlag.MaskMoving); }
public bool IsTurning() { return m_movementInfo.HasMovementFlag(MovementFlag.MaskTurning); }
+2 -2
View File
@@ -1113,7 +1113,7 @@ namespace Game.Entities
}
public UnitAI GetAI() { return i_AI; }
void SetAI(UnitAI newAI) { i_AI = newAI; }
public void SetAI(UnitAI newAI) { i_AI = newAI; }
public bool IsPossessing()
{
@@ -2351,7 +2351,7 @@ namespace Game.Entities
else
return ToCreature().GetCreatureTemplate().CreatureType;
}
Player GetAffectingPlayer()
public Player GetAffectingPlayer()
{
if (GetCharmerOrOwnerGUID().IsEmpty())
return IsTypeId(TypeId.Player) ? ToPlayer() : null;
+2 -1
View File
@@ -24,6 +24,7 @@ using Game.Networking.Packets;
using System;
using System.Collections.Generic;
using Framework.Collections;
using System.Linq;
namespace Game
{
@@ -1559,7 +1560,7 @@ namespace Game
{
GameEventAIHookWorker worker = new GameEventAIHookWorker(event_id, activate);
var visitor = new Visitor(worker, GridMapTypeMask.None);
visitor.Visit(map.GetObjectsStore());
visitor.Visit(map.GetObjectsStore().Values.ToList());
});
}
+3 -1
View File
@@ -107,7 +107,7 @@ namespace Game.Garrisons
Log.outDebug(LogFilter.Maps, "{0} GameObjects and {1} Creatures loaded for grid {2} on map {3}", i_gameObjects, i_creatures, i_grid.GetGridId(), i_map.GetId());
}
public override void Visit(IList<WorldObject> objs)
public override void Visit(IList<GameObject> objs)
{
ICollection<Garrison.Plot> plots = i_garrison.GetPlots();
if (!plots.Empty())
@@ -131,6 +131,8 @@ namespace Game.Garrisons
}
}
public override void Visit(IList<Creature> objs) { }
Cell i_cell;
Grid i_grid;
GarrisonMap i_map;
+1 -1
View File
@@ -293,7 +293,7 @@ namespace Game.Maps
visitor.Visit(_container.corpses);
visitor.Visit(_container.areaTriggers);
visitor.Visit(_container.conversations);
visitor.Visit(_container.worldObjects);
visitor.Visit(_container.worldObjects.ToArray());
break;
case GridMapTypeMask.AllWorld:
visitor.Visit(_objects.players);
+367 -135
View File
@@ -73,8 +73,6 @@ namespace Game.Maps
public void Visit(IList<Corpse> corpses) { _notifier.Visit(corpses); }
public void Visit(IList<Player> players) { _notifier.Visit(players); }
public void Visit(Dictionary<ObjectGuid, WorldObject> dict) { Visit(dict.Values.ToList()); }
Notifier _notifier;
internal GridMapTypeMask _mask;
}
@@ -563,11 +561,10 @@ namespace Game.Maps
public override void Visit(IList<WorldObject> objs)
{
for (var i = 0; i < objs.Count; ++i)
foreach (var obj in objs)
{
var obj = objs[i];
if (obj.IsTypeId(TypeId.Player) || obj.IsTypeId(TypeId.Corpse))
continue;
return;
if (obj.IsInWorld)
obj.Update(i_timeDiff);
@@ -645,42 +642,85 @@ namespace Game.Maps
i_do = _do;
}
public override void Visit(IList<WorldObject> objs)
public override void Visit(IList<GameObject> objs)
{
foreach (var obj in objs)
{
switch (obj.GetTypeId())
{
case TypeId.GameObject:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.GameObject))
return;
break;
case TypeId.Player:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Player))
return;
break;
case TypeId.Unit:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Creature))
return;
break;
case TypeId.Corpse:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Corpse))
return;
break;
case TypeId.DynamicObject:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.DynamicObject))
return;
break;
case TypeId.AreaTrigger:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.AreaTrigger))
return;
break;
case TypeId.Conversation:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Conversation))
return;
break;
foreach (var obj in objs)
{
if (obj.IsInPhase(_searcher))
i_do.Invoke(obj);
}
}
public override void Visit(IList<Player> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Player))
return;
foreach (var obj in objs)
{
if (obj.IsInPhase(_searcher))
i_do.Invoke(obj);
}
}
public override void Visit(IList<Creature> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Creature))
return;
foreach (var obj in objs)
{
if (obj.IsInPhase(_searcher))
i_do.Invoke(obj);
}
}
public override void Visit(IList<Corpse> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Corpse))
return;
foreach (var obj in objs)
{
if (obj.IsInPhase(_searcher))
i_do.Invoke(obj);
}
}
public override void Visit(IList<DynamicObject> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.DynamicObject))
return;
foreach (var obj in objs)
{
if (obj.IsInPhase(_searcher))
i_do.Invoke(obj);
}
}
public override void Visit(IList<AreaTrigger> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.AreaTrigger))
return;
foreach (var obj in objs)
{
if (obj.IsInPhase(_searcher))
i_do.Invoke(obj);
}
}
public override void Visit(IList<Conversation> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Conversation))
return;
foreach (var obj in objs)
{
if (obj.IsInPhase(_searcher))
i_do.Invoke(obj);
}
@@ -918,46 +958,17 @@ namespace Game.Maps
i_check = check;
}
public override void Visit(IList<WorldObject> objs)
public override void Visit(IList<GameObject> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.GameObject))
return;
// already found
if (i_object)
return;
foreach (var obj in objs)
{
switch (obj.GetTypeId())
{
case TypeId.Player:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Player))
continue;
break;
case TypeId.GameObject:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.GameObject))
continue;
break;
case TypeId.Corpse:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Corpse))
continue;
break;
case TypeId.Unit:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Creature))
continue;
break;
case TypeId.DynamicObject:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.DynamicObject))
continue;
break;
case TypeId.AreaTrigger:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.AreaTrigger))
continue;
break;
case TypeId.Conversation:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Conversation))
continue;
break;
}
if (!obj.IsInPhase(_searcher))
continue;
@@ -966,7 +977,138 @@ namespace Game.Maps
i_object = obj;
return;
}
}
}
public override void Visit(IList<Player> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Player))
return;
// already found
if (i_object)
return;
foreach (var obj in objs)
{
if (!obj.IsInPhase(_searcher))
continue;
if (i_check.Invoke(obj))
{
i_object = obj;
return;
}
}
}
public override void Visit(IList<Creature> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Creature))
return;
// already found
if (i_object)
return;
foreach (var obj in objs)
{
if (!obj.IsInPhase(_searcher))
continue;
if (i_check.Invoke(obj))
{
i_object = obj;
return;
}
}
}
public override void Visit(IList<Corpse> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Corpse))
return;
// already found
if (i_object)
return;
foreach (var obj in objs)
{
if (!obj.IsInPhase(_searcher))
continue;
if (i_check.Invoke(obj))
{
i_object = obj;
return;
}
}
}
public override void Visit(IList<DynamicObject> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.DynamicObject))
return;
// already found
if (i_object)
return;
foreach (var obj in objs)
{
if (!obj.IsInPhase(_searcher))
continue;
if (i_check.Invoke(obj))
{
i_object = obj;
return;
}
}
}
public override void Visit(IList<AreaTrigger> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.AreaTrigger))
return;
// already found
if (i_object)
return;
foreach (var obj in objs)
{
if (!obj.IsInPhase(_searcher))
continue;
if (i_check.Invoke(obj))
{
i_object = obj;
return;
}
}
}
public override void Visit(IList<Conversation> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Conversation))
return;
// already found
if (i_object)
return;
foreach (var obj in objs)
{
if (!obj.IsInPhase(_searcher))
continue;
if (i_check.Invoke(obj))
{
i_object = obj;
return;
}
}
}
@@ -986,42 +1128,103 @@ namespace Game.Maps
i_check = check;
}
public override void Visit(IList<WorldObject> objs)
public override void Visit(IList<GameObject> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.GameObject))
return;
foreach (var obj in objs)
{
switch (obj.GetTypeId())
{
case TypeId.Player:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Player))
if (!obj.IsInPhase(_searcher))
continue;
break;
case TypeId.GameObject:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.GameObject))
continue;
break;
case TypeId.Corpse:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Corpse))
continue;
break;
case TypeId.Unit:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Creature))
continue;
break;
case TypeId.DynamicObject:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.DynamicObject))
continue;
break;
case TypeId.AreaTrigger:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.AreaTrigger))
continue;
break;
case TypeId.Conversation:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Conversation))
continue;
break;
if (i_check.Invoke(obj))
i_object = obj;
}
}
public override void Visit(IList<Player> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Player))
return;
foreach (var obj in objs)
{
if (!obj.IsInPhase(_searcher))
continue;
if (i_check.Invoke(obj))
i_object = obj;
}
}
public override void Visit(IList<Creature> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Creature))
return;
foreach (var obj in objs)
{
if (!obj.IsInPhase(_searcher))
continue;
if (i_check.Invoke(obj))
i_object = obj;
}
}
public override void Visit(IList<Corpse> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Corpse))
return;
foreach (var obj in objs)
{
if (!obj.IsInPhase(_searcher))
continue;
if (i_check.Invoke(obj))
i_object = obj;
}
}
public override void Visit(IList<DynamicObject> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.DynamicObject))
return;
foreach (var obj in objs)
{
if (!obj.IsInPhase(_searcher))
continue;
if (i_check.Invoke(obj))
i_object = obj;
}
}
public override void Visit(IList<AreaTrigger> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.AreaTrigger))
return;
foreach (var obj in objs)
{
if (!obj.IsInPhase(_searcher))
continue;
if (i_check.Invoke(obj))
i_object = obj;
}
}
public override void Visit(IList<Conversation> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Conversation))
return;
foreach (var obj in objs)
{
if (!obj.IsInPhase(_searcher))
continue;
@@ -1047,45 +1250,74 @@ namespace Game.Maps
i_check = check;
}
public override void Visit(IList<WorldObject> objs)
public override void Visit(IList<Player> objs)
{
foreach (var obj in objs)
{
switch (obj.GetTypeId())
{
case TypeId.Player:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Player))
continue;
break;
case TypeId.GameObject:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.GameObject))
continue;
break;
case TypeId.Corpse:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Corpse))
continue;
break;
case TypeId.Unit:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Creature))
continue;
break;
case TypeId.DynamicObject:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.DynamicObject))
continue;
break;
case TypeId.AreaTrigger:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.AreaTrigger))
continue;
break;
case TypeId.Conversation:
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Conversation))
continue;
break;
}
return;
foreach (var obj in objs)
if (i_check.Invoke(obj))
i_objects.Add(obj);
}
public override void Visit(IList<Creature> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Creature))
return;
foreach (var obj in objs)
if (i_check.Invoke(obj))
i_objects.Add(obj);
}
public override void Visit(IList<Corpse> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Corpse))
return;
foreach (var obj in objs)
if (i_check.Invoke(obj))
i_objects.Add(obj);
}
public override void Visit(IList<GameObject> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.GameObject))
return;
foreach (var obj in objs)
if (i_check.Invoke(obj))
i_objects.Add(obj);
}
public override void Visit(IList<DynamicObject> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.DynamicObject))
return;
foreach (var obj in objs)
if (i_check.Invoke(obj))
i_objects.Add(obj);
}
public override void Visit(IList<AreaTrigger> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.AreaTrigger))
return;
foreach (var obj in objs)
if (i_check.Invoke(obj))
i_objects.Add(obj);
}
public override void Visit(IList<Conversation> objs)
{
if (!i_mapTypeMask.HasAnyFlag(GridMapTypeMask.Conversation))
return;
foreach (var obj in objs)
if (i_check.Invoke(obj))
i_objects.Add(obj);
}
GridMapTypeMask i_mapTypeMask;
@@ -2099,7 +2331,7 @@ namespace Game.Maps
float m_fRange;
}
class AllCreaturesOfEntryInRange : ICheck<Creature>
public class AllCreaturesOfEntryInRange : ICheck<Creature>
{
public AllCreaturesOfEntryInRange(WorldObject obj, uint entry, float maxRange)
{
@@ -2181,7 +2413,7 @@ namespace Game.Maps
float m_fRange;
}
class ObjectTypeIdCheck : ICheck<WorldObject>
public class ObjectTypeIdCheck : ICheck<WorldObject>
{
public ObjectTypeIdCheck(TypeId typeId, bool equals)
{
@@ -2218,7 +2450,7 @@ namespace Game.Maps
ObjectGuid _GUID;
}
class HeightDifferenceCheck : ICheck<WorldObject>
public class HeightDifferenceCheck : ICheck<WorldObject>
{
public HeightDifferenceCheck(WorldObject go, float diff, bool reverse)
{
+1 -1
View File
@@ -725,7 +725,7 @@ namespace Game.Maps
instance.SendToPlayers(new InstanceEncounterEnd());
}
void SendBossKillCredit(uint encounterId)
public void SendBossKillCredit(uint encounterId)
{
BossKill bossKillCreditMessage = new BossKill();
bossKillCreditMessage.DungeonEncounterID = encounterId;
+2 -2
View File
@@ -3558,7 +3558,7 @@ namespace Game.Maps
return info.DefaultWeather;
}
void SetZoneWeather(uint zoneId, WeatherState weatherId, float weatherGrade)
public void SetZoneWeather(uint zoneId, WeatherState weatherId, float weatherGrade)
{
if (!_zoneDynamicInfo.ContainsKey(zoneId))
_zoneDynamicInfo[zoneId] = new ZoneDynamicInfo();
@@ -3580,7 +3580,7 @@ namespace Game.Maps
}
}
void SetZoneOverrideLight(uint zoneId, uint lightId, uint fadeInTime)
public void SetZoneOverrideLight(uint zoneId, uint lightId, uint fadeInTime)
{
if (!_zoneDynamicInfo.ContainsKey(zoneId))
_zoneDynamicInfo[zoneId] = new ZoneDynamicInfo();
+1 -1
View File
@@ -271,7 +271,7 @@ namespace Game.Maps
{
foreach (var obj in objs)
{
if (obj.IsTypeId(TypeId.Player) || obj.IsTypeId(TypeId.Corpse))
if (obj.IsTypeId(TypeId.Corpse))
continue;
// if option set then object already saved at this moment
@@ -196,7 +196,7 @@ namespace Game.Movement
if (_arrivalSpellId != 0)
owner.CastSpell(Global.ObjAccessor.GetUnit(owner, _arrivalSpellTargetGuid), _arrivalSpellId, true);
if (owner.ToCreature().GetAI() != null)
if (owner.ToCreature() && owner.ToCreature().GetAI() != null)
owner.ToCreature().GetAI().MovementInform(MovementGeneratorType.Effect, _pointId);
}
+5 -5
View File
@@ -270,7 +270,7 @@ namespace Game.Movement
StartMovement(new PointMovementGenerator<Creature>(id, x, y, z, generatePath), MovementSlot.Active);
}
void MoveCloserAndStop(uint id, Unit target, float distance)
public void MoveCloserAndStop(uint id, Unit target, float distance)
{
float distanceToTravel = _owner.GetExactDist2d(target) - distance;
if (distanceToTravel > 0.0f)
@@ -303,7 +303,7 @@ namespace Game.Movement
StartMovement(new EffectMovementGenerator(id), MovementSlot.Active);
}
void MoveTakeoff(uint id, Position pos)
public void MoveTakeoff(uint id, Position pos)
{
float x, y, z;
pos.GetPosition(out x, out y, out z);
@@ -421,7 +421,7 @@ namespace Game.Movement
StartMovement(new EffectMovementGenerator(id, arrivalSpellId, arrivalSpellTargetGuid), MovementSlot.Controlled);
}
void MoveCirclePath(float x, float y, float z, float radius, bool clockwise, byte stepCount)
public void MoveCirclePath(float x, float y, float z, float radius, bool clockwise, byte stepCount)
{
float step = 2 * MathFunctions.PI / stepCount * (clockwise ? -1.0f : 1.0f);
Position pos = new Position(x, y, z, 0.0f);
@@ -480,7 +480,7 @@ namespace Game.Movement
//MovePoint(EVENT_CHARGE_PREPATH, pos, false);
}
void MoveAlongSplineChain(uint pointId, uint dbChainId, bool walk)
public void MoveAlongSplineChain(uint pointId, uint dbChainId, bool walk)
{
Creature owner = _owner.ToCreature();
if (!owner)
@@ -606,7 +606,7 @@ namespace Game.Movement
StartMovement(new WaypointMovementGenerator(path, repeatable), MovementSlot.Idle);
}
void MoveRotate(uint time, RotateDirection direction)
public void MoveRotate(uint time, RotateDirection direction)
{
if (time == 0)
return;
+1 -1
View File
@@ -540,7 +540,7 @@ namespace Game.Scripting
Global.ScriptMgr.AddScript(this);
}
public override bool IsDatabaseBound() { return true; }
public override bool IsDatabaseBound() { return false; }
// Called when an additional criteria is checked.
public virtual bool OnCheck(Player source, Unit target) { return false; }
+1
View File
@@ -168,6 +168,7 @@ namespace Game.Scripting
case "GuildScript":
case "GroupScript":
case "AreaTriggerEntityScript":
case "OnlyOnceAreaTriggerScript":
case "SceneScript":
if (!attribute.Name.IsEmpty())
name = attribute.Name;
+1 -1
View File
@@ -1676,7 +1676,7 @@ namespace Game.Spells
[AuraEffectHandler(AuraType.ModScale)]
[AuraEffectHandler(AuraType.ModScale2)]
void HandleAuraModScale(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply)
public void HandleAuraModScale(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply)
{
if (!mode.HasAnyFlag(AuraEffectHandleModes.ChangeAmountSendForClientMask))
return;
+2 -2
View File
@@ -1720,7 +1720,7 @@ namespace Game.Spells
pos = destTarget;
else
// randomize position for multiple summons
m_caster.GetRandomPoint(destTarget, radius, out pos);
pos = m_caster.GetRandomPoint(destTarget, radius);
summon = m_originalCaster.SummonCreature(entry, pos, summonType, (uint)duration, 0, personalSpawn);
if (summon == null)
@@ -4972,7 +4972,7 @@ namespace Game.Spells
pos = destTarget;
else
// randomize position for multiple summons
m_caster.GetRandomPoint(destTarget, radius, out pos);
pos = m_caster.GetRandomPoint(destTarget, radius);
TempSummon summon = map.SummonCreature(entry, pos, properties, (uint)duration, caster, m_spellInfo.Id);
if (summon == null)
-1
View File
@@ -3611,7 +3611,6 @@ namespace Game.Spells
Dictionary<uint, SpellEffectInfo> _effects = new Dictionary<uint, SpellEffectInfo>();
List<SpellXSpellVisualRecord> _visuals = new List<SpellXSpellVisualRecord>();
bool _hasPowerDifficultyData;
SpellSpecificType _spellSpecific;
AuraStateType _auraState;
+1 -1
View File
@@ -256,7 +256,7 @@ namespace Game
return dist;
}
void SendSound(Creature source, uint sound, ChatMsg msgType, WorldObject whisperTarget = null, CreatureTextRange range = CreatureTextRange.Normal, Team team = Team.Other, bool gmOnly = false)
public void SendSound(Creature source, uint sound, ChatMsg msgType, WorldObject whisperTarget = null, CreatureTextRange range = CreatureTextRange.Normal, Team team = Team.Other, bool gmOnly = false)
{
if (sound == 0 || !source)
return;