Some cleanups. (might break build for scripts as they are a WIP)
This commit is contained in:
@@ -91,7 +91,7 @@ namespace Game.Maps
|
||||
// at this moment i_clientGUIDs have guids that not iterate at grid level checks
|
||||
// but exist one case when this possible and object not out of range: transports
|
||||
Transport transport = i_player.GetTransport<Transport>();
|
||||
if (transport)
|
||||
if (transport != null)
|
||||
{
|
||||
foreach (var obj in transport.GetPassengers())
|
||||
{
|
||||
@@ -197,10 +197,10 @@ namespace Game.Maps
|
||||
{
|
||||
DynamicObject dynamicObject = objs[i];
|
||||
Unit caster = dynamicObject.GetCaster();
|
||||
if (caster)
|
||||
if (caster != null)
|
||||
{
|
||||
Player pl = caster.ToPlayer();
|
||||
if (pl && pl.seerView == dynamicObject)
|
||||
if (pl != null && pl.seerView == dynamicObject)
|
||||
pl.UpdateVisibilityOf(i_objects);
|
||||
}
|
||||
}
|
||||
@@ -277,7 +277,7 @@ namespace Game.Maps
|
||||
Creature creature = objs[i];
|
||||
CreatureUnitRelocationWorker(i_creature, creature);
|
||||
|
||||
if (!creature.IsNeedNotify(NotifyFlags.VisibilityChanged))
|
||||
if (creature.IsNeedNotify(NotifyFlags.VisibilityChanged))
|
||||
CreatureUnitRelocationWorker(creature, i_creature);
|
||||
}
|
||||
}
|
||||
@@ -320,7 +320,7 @@ namespace Game.Maps
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
{
|
||||
Creature creature = objs[i];
|
||||
if (!creature.IsNeedNotify(NotifyFlags.VisibilityChanged))
|
||||
if (creature.IsNeedNotify(NotifyFlags.VisibilityChanged))
|
||||
continue;
|
||||
|
||||
CreatureRelocationNotifier relocate = new(creature);
|
||||
@@ -439,7 +439,7 @@ namespace Game.Maps
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
{
|
||||
Creature creature = objs[i];
|
||||
if (!creature.InSamePhase(i_phaseShift))
|
||||
if (creature.InSamePhase(i_phaseShift))
|
||||
continue;
|
||||
|
||||
if ((!required3dDist ? creature.GetExactDist2dSq(i_source) : creature.GetExactDistSq(i_source)) > i_distSq)
|
||||
@@ -468,10 +468,10 @@ namespace Game.Maps
|
||||
|
||||
// Send packet back to the caster if the caster has vision of dynamic object
|
||||
Unit caster = dynamicObject.GetCaster();
|
||||
if (caster)
|
||||
if (caster != null)
|
||||
{
|
||||
Player player = caster.ToPlayer();
|
||||
if (player && player.seerView == dynamicObject)
|
||||
if (player != null && player.seerView == dynamicObject)
|
||||
SendPacket(player);
|
||||
}
|
||||
}
|
||||
@@ -524,7 +524,7 @@ namespace Game.Maps
|
||||
SendPacket(visionPlayer);
|
||||
}
|
||||
|
||||
if (player.seerView == player || player.GetVehicle())
|
||||
if (player.seerView == player || player.GetVehicle() != null)
|
||||
SendPacket(player);
|
||||
}
|
||||
}
|
||||
@@ -534,7 +534,7 @@ namespace Game.Maps
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
{
|
||||
Creature creature = objs[i];
|
||||
if (!creature.InSamePhase(i_phaseShift))
|
||||
if (creature.InSamePhase(i_phaseShift))
|
||||
continue;
|
||||
|
||||
if (creature.GetExactDist2dSq(i_source) > i_distSq)
|
||||
@@ -566,7 +566,7 @@ namespace Game.Maps
|
||||
{
|
||||
// Send packet back to the caster if the caster has vision of dynamic object
|
||||
Player player = caster.ToPlayer();
|
||||
if (player && player.seerView == dynamicObject)
|
||||
if (player != null && player.seerView == dynamicObject)
|
||||
SendPacket(player);
|
||||
}
|
||||
}
|
||||
@@ -839,7 +839,7 @@ namespace Game.Maps
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
{
|
||||
Creature creature = objs[i];
|
||||
if (!creature.GetSharedVisionList().Empty())
|
||||
if (creature.GetSharedVisionList().Empty())
|
||||
{
|
||||
foreach (var visionPlayer in creature.GetSharedVisionList())
|
||||
BuildPacket(visionPlayer);
|
||||
@@ -1007,7 +1007,7 @@ namespace Game.Maps
|
||||
return;
|
||||
|
||||
// already found
|
||||
if (i_object)
|
||||
if (i_object != null)
|
||||
return;
|
||||
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
@@ -1030,7 +1030,7 @@ namespace Game.Maps
|
||||
return;
|
||||
|
||||
// already found
|
||||
if (i_object)
|
||||
if (i_object != null)
|
||||
return;
|
||||
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
@@ -1053,13 +1053,13 @@ namespace Game.Maps
|
||||
return;
|
||||
|
||||
// already found
|
||||
if (i_object)
|
||||
if (i_object != null)
|
||||
return;
|
||||
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
{
|
||||
Creature creature = objs[i];
|
||||
if (!creature.InSamePhase(i_phaseShift))
|
||||
if (creature.InSamePhase(i_phaseShift))
|
||||
continue;
|
||||
|
||||
if (i_check.Invoke(creature))
|
||||
@@ -1076,7 +1076,7 @@ namespace Game.Maps
|
||||
return;
|
||||
|
||||
// already found
|
||||
if (i_object)
|
||||
if (i_object != null)
|
||||
return;
|
||||
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
@@ -1099,7 +1099,7 @@ namespace Game.Maps
|
||||
return;
|
||||
|
||||
// already found
|
||||
if (i_object)
|
||||
if (i_object != null)
|
||||
return;
|
||||
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
@@ -1122,7 +1122,7 @@ namespace Game.Maps
|
||||
return;
|
||||
|
||||
// already found
|
||||
if (i_object)
|
||||
if (i_object != null)
|
||||
return;
|
||||
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
@@ -1145,7 +1145,7 @@ namespace Game.Maps
|
||||
return;
|
||||
|
||||
// already found
|
||||
if (i_object)
|
||||
if (i_object != null)
|
||||
return;
|
||||
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
@@ -1168,7 +1168,7 @@ namespace Game.Maps
|
||||
return;
|
||||
|
||||
// already found
|
||||
if (i_object)
|
||||
if (i_object != null)
|
||||
return;
|
||||
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
@@ -1242,7 +1242,7 @@ namespace Game.Maps
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
{
|
||||
Creature creature = objs[i];
|
||||
if (!creature.InSamePhase(i_phaseShift))
|
||||
if (creature.InSamePhase(i_phaseShift))
|
||||
continue;
|
||||
|
||||
if (i_check.Invoke(creature))
|
||||
@@ -1468,7 +1468,7 @@ namespace Game.Maps
|
||||
public override void Visit(IList<GameObject> objs)
|
||||
{
|
||||
// already found
|
||||
if (i_object)
|
||||
if (i_object != null)
|
||||
return;
|
||||
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
@@ -1574,7 +1574,7 @@ namespace Game.Maps
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
{
|
||||
Creature creature = objs[i];
|
||||
if (!creature.InSamePhase(i_phaseShift))
|
||||
if (creature.InSamePhase(i_phaseShift))
|
||||
continue;
|
||||
|
||||
if (i_check.Invoke(creature))
|
||||
@@ -1618,7 +1618,7 @@ namespace Game.Maps
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
{
|
||||
Creature creature = objs[i];
|
||||
if (!creature.InSamePhase(i_phaseShift))
|
||||
if (creature.InSamePhase(i_phaseShift))
|
||||
continue;
|
||||
|
||||
if (i_check.Invoke(creature))
|
||||
@@ -1680,13 +1680,13 @@ namespace Game.Maps
|
||||
public override void Visit(IList<Creature> objs)
|
||||
{
|
||||
// already found
|
||||
if (i_object)
|
||||
if (i_object != null)
|
||||
return;
|
||||
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
{
|
||||
Creature creature = objs[i];
|
||||
if (!creature.InSamePhase(i_phaseShift))
|
||||
if (creature.InSamePhase(i_phaseShift))
|
||||
continue;
|
||||
|
||||
if (i_check.Invoke(creature))
|
||||
@@ -1717,7 +1717,7 @@ namespace Game.Maps
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
{
|
||||
Creature creature = objs[i];
|
||||
if (!creature.InSamePhase(i_phaseShift))
|
||||
if (creature.InSamePhase(i_phaseShift))
|
||||
continue;
|
||||
|
||||
if (i_check.Invoke(creature))
|
||||
@@ -1768,7 +1768,7 @@ namespace Game.Maps
|
||||
public override void Visit(IList<Player> objs)
|
||||
{
|
||||
// already found
|
||||
if (i_object)
|
||||
if (i_object != null)
|
||||
return;
|
||||
|
||||
for (var i = 0; i < objs.Count; ++i)
|
||||
@@ -2804,7 +2804,7 @@ namespace Game.Maps
|
||||
|
||||
public bool Invoke(T obj)
|
||||
{
|
||||
return obj.ToUnit() && obj.ToUnit().HasAura(_spellId, _casterGUID) == _present;
|
||||
return obj.ToUnit() != null && obj.ToUnit().HasAura(_spellId, _casterGUID) == _present;
|
||||
}
|
||||
|
||||
public static implicit operator Predicate<T>(UnitAuraCheck<T> unit)
|
||||
@@ -3033,15 +3033,15 @@ namespace Game.Maps
|
||||
public virtual bool Invoke(T obj)
|
||||
{
|
||||
Player player = obj.ToPlayer();
|
||||
if (player)
|
||||
if (player != null)
|
||||
return !player.IsAlive() && !player.HasAuraType(AuraType.Ghost) && i_searchObj.IsWithinDistInMap(player, i_range);
|
||||
|
||||
Creature creature = obj.ToCreature();
|
||||
if (creature)
|
||||
if (creature != null)
|
||||
return !creature.IsAlive() && i_searchObj.IsWithinDistInMap(creature, i_range);
|
||||
|
||||
Corpse corpse = obj.ToCorpse();
|
||||
if (corpse)
|
||||
if (corpse != null)
|
||||
return corpse.GetCorpseType() != CorpseType.Bones && i_searchObj.IsWithinDistInMap(corpse, i_range);
|
||||
|
||||
return false;
|
||||
@@ -3074,7 +3074,7 @@ namespace Game.Maps
|
||||
return false;
|
||||
|
||||
Creature creature = obj.ToCreature();
|
||||
if (creature)
|
||||
if (creature != null)
|
||||
return !creature.IsPet();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -232,7 +232,7 @@ namespace Game.Maps
|
||||
continue; // nothing to do here
|
||||
// if we should spawn group, then spawn it...
|
||||
if (doSpawn)
|
||||
instance.SpawnGroupSpawn(groupId, instance);
|
||||
instance.SpawnGroupSpawn(groupId, instance != null);
|
||||
else // otherwise, set it as inactive so it no longer respawns (but don't despawn it)
|
||||
instance.SetSpawnGroupInactive(groupId);
|
||||
}
|
||||
@@ -351,7 +351,7 @@ namespace Game.Maps
|
||||
foreach (var guid in bossInfo.minion)
|
||||
{
|
||||
Creature minion = instance.GetCreature(guid);
|
||||
if (minion)
|
||||
if (minion != null)
|
||||
if (minion.IsWorldBoss() && minion.IsAlive())
|
||||
return false;
|
||||
}
|
||||
@@ -401,7 +401,7 @@ namespace Game.Maps
|
||||
foreach (var guid in bossInfo.door[type])
|
||||
{
|
||||
GameObject door = instance.GetGameObject(guid);
|
||||
if (door)
|
||||
if (door != null)
|
||||
UpdateDoorState(door);
|
||||
}
|
||||
}
|
||||
@@ -409,7 +409,7 @@ namespace Game.Maps
|
||||
foreach (var guid in bossInfo.minion.ToArray())
|
||||
{
|
||||
Creature minion = instance.GetCreature(guid);
|
||||
if (minion)
|
||||
if (minion != null)
|
||||
UpdateMinionState(minion, state);
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ namespace Game.Maps
|
||||
|
||||
public bool _SkipCheckRequiredBosses(Player player = null)
|
||||
{
|
||||
return player && player.GetSession().HasPermission(RBACPermissions.SkipCheckInstanceRequiredBosses);
|
||||
return player != null && player.GetSession().HasPermission(RBACPermissions.SkipCheckInstanceRequiredBosses);
|
||||
}
|
||||
|
||||
public virtual void Create()
|
||||
@@ -510,9 +510,9 @@ namespace Game.Maps
|
||||
|
||||
public void HandleGameObject(ObjectGuid guid, bool open, GameObject go = null)
|
||||
{
|
||||
if (!go)
|
||||
if (go == null)
|
||||
go = instance.GetGameObject(guid);
|
||||
if (go)
|
||||
if (go != null)
|
||||
go.SetGoState(open ? GameObjectState.Active : GameObjectState.Ready);
|
||||
else
|
||||
Log.outDebug(LogFilter.Scripts, "InstanceScript: HandleGameObject failed");
|
||||
@@ -524,7 +524,7 @@ namespace Game.Maps
|
||||
return;
|
||||
|
||||
GameObject go = instance.GetGameObject(uiGuid);
|
||||
if (go)
|
||||
if (go != null)
|
||||
{
|
||||
if (go.GetGoType() == GameObjectTypes.Door || go.GetGoType() == GameObjectTypes.Button)
|
||||
{
|
||||
@@ -546,7 +546,7 @@ namespace Game.Maps
|
||||
return;
|
||||
|
||||
GameObject go = instance.GetGameObject(guid);
|
||||
if (go)
|
||||
if (go != null)
|
||||
{
|
||||
if (go.GetGoType() == GameObjectTypes.Door || go.GetGoType() == GameObjectTypes.Button)
|
||||
{
|
||||
@@ -563,7 +563,7 @@ namespace Game.Maps
|
||||
public void DoRespawnGameObject(ObjectGuid guid, TimeSpan timeToDespawn)
|
||||
{
|
||||
GameObject go = instance.GetGameObject(guid);
|
||||
if (go)
|
||||
if (go != null)
|
||||
{
|
||||
switch (go.GetGoType())
|
||||
{
|
||||
@@ -612,7 +612,7 @@ namespace Game.Maps
|
||||
|
||||
public void DoRemoveAurasDueToSpellOnPlayer(Player player, uint spell, bool includePets = false, bool includeControlled = false)
|
||||
{
|
||||
if (!player)
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
player.RemoveAurasDueToSpell(spell);
|
||||
@@ -651,7 +651,7 @@ namespace Game.Maps
|
||||
|
||||
public void DoCastSpellOnPlayer(Player player, uint spell, bool includePets = false, bool includeControlled = false)
|
||||
{
|
||||
if (!player)
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
player.CastSpell(player, spell, true);
|
||||
@@ -743,7 +743,7 @@ namespace Game.Maps
|
||||
instance.SendToPlayers(encounterEngageMessage);
|
||||
break;
|
||||
case EncounterFrameType.Disengage:
|
||||
if (!unit)
|
||||
if (unit == null)
|
||||
return;
|
||||
|
||||
InstanceEncounterDisengageUnit encounterDisengageMessage = new();
|
||||
@@ -751,7 +751,7 @@ namespace Game.Maps
|
||||
instance.SendToPlayers(encounterDisengageMessage);
|
||||
break;
|
||||
case EncounterFrameType.UpdatePriority:
|
||||
if (!unit)
|
||||
if (unit == null)
|
||||
return;
|
||||
|
||||
InstanceEncounterChangePriority encounterChangePriorityMessage = new();
|
||||
|
||||
+44
-49
@@ -590,7 +590,7 @@ namespace Game.Maps
|
||||
|
||||
// If player is using far sight or mind vision, visit that object too
|
||||
WorldObject viewPoint = player.GetViewpoint();
|
||||
if (viewPoint)
|
||||
if (viewPoint != null)
|
||||
VisitNearbyCellsOf(viewPoint, grid_object_update, world_object_update);
|
||||
|
||||
// Handle updates for creatures in combat with player and are more than 60 yards away
|
||||
@@ -654,7 +654,7 @@ namespace Game.Maps
|
||||
for (var i = 0; i < _transports.Count; ++i)
|
||||
{
|
||||
Transport transport = _transports[i];
|
||||
if (!transport)
|
||||
if (transport == null)
|
||||
continue;
|
||||
|
||||
transport.Update(diff);
|
||||
@@ -1119,7 +1119,7 @@ namespace Game.Maps
|
||||
}
|
||||
|
||||
creature._moveState = ObjectCellMoveState.None;
|
||||
if (!creature.IsInWorld)
|
||||
if (creature.IsInWorld)
|
||||
continue;
|
||||
|
||||
// do move or do move to respawn or remove creature if previous all fail
|
||||
@@ -1136,7 +1136,7 @@ namespace Game.Maps
|
||||
{
|
||||
// if creature can't be move in new cell/grid (not loaded) move it to repawn cell/grid
|
||||
// creature coordinates will be updated and notifiers send
|
||||
if (!CreatureRespawnRelocation(creature, false))
|
||||
if (CreatureRespawnRelocation(creature, false))
|
||||
{
|
||||
// ... or unload (if respawn grid also not loaded)
|
||||
//This may happen when a player just logs in and a pet moves to a nearby unloaded cell
|
||||
@@ -1671,7 +1671,7 @@ namespace Game.Maps
|
||||
|
||||
Group group = player.GetGroup();
|
||||
if (entry.IsRaid() && (int)entry.Expansion() >= WorldConfig.GetIntValue(WorldCfg.Expansion)) // can only enter in a raid group but raids from old expansion don't need a group
|
||||
if ((!group || !group.IsRaidGroup()) && !WorldConfig.GetBoolValue(WorldCfg.InstanceIgnoreRaid))
|
||||
if ((group == null || !group.IsRaidGroup()) && !WorldConfig.GetBoolValue(WorldCfg.InstanceIgnoreRaid))
|
||||
return new TransferAbortParams(TransferAbortReason.NeedGroup);
|
||||
|
||||
if (entry.Instanceable())
|
||||
@@ -1847,7 +1847,7 @@ namespace Game.Maps
|
||||
var range = _creatureBySpawnIdStore.LookupByKey(info.spawnId);
|
||||
foreach (var creature in range)
|
||||
{
|
||||
if (!creature.IsAlive())
|
||||
if (creature.IsAlive())
|
||||
continue;
|
||||
|
||||
// escort NPCs are allowed to respawn as long as all other instances are already escorting
|
||||
@@ -2505,7 +2505,7 @@ namespace Game.Maps
|
||||
case TypeId.GameObject:
|
||||
GameObject go = obj.ToGameObject();
|
||||
Transport transport = go.ToTransport();
|
||||
if (transport)
|
||||
if (transport != null)
|
||||
RemoveFromMap(transport, true);
|
||||
else
|
||||
RemoveFromMap(go, true);
|
||||
@@ -2877,7 +2877,7 @@ namespace Game.Maps
|
||||
|
||||
void RemoveCorpse(Corpse corpse)
|
||||
{
|
||||
Cypher.Assert(corpse);
|
||||
Cypher.Assert(corpse != null);
|
||||
|
||||
corpse.UpdateObjectVisibilityOnDestroy();
|
||||
if (corpse.GetCurrentCell() != null)
|
||||
@@ -2898,7 +2898,7 @@ namespace Game.Maps
|
||||
public Corpse ConvertCorpseToBones(ObjectGuid ownerGuid, bool insignia = false)
|
||||
{
|
||||
Corpse corpse = GetCorpseByPlayer(ownerGuid);
|
||||
if (!corpse)
|
||||
if (corpse == null)
|
||||
return null;
|
||||
|
||||
RemoveCorpse(corpse);
|
||||
@@ -3143,7 +3143,7 @@ namespace Game.Maps
|
||||
var players = GetPlayers();
|
||||
foreach (var player in players)
|
||||
{
|
||||
if (player)
|
||||
if (player != null)
|
||||
{
|
||||
if (player.IsInWorld)
|
||||
{
|
||||
@@ -3509,7 +3509,7 @@ namespace Game.Maps
|
||||
return null;
|
||||
|
||||
GameObject go = GetGameObject(guid);
|
||||
return go ? go.ToTransport() : null;
|
||||
return go != null ? go.ToTransport() : null;
|
||||
}
|
||||
|
||||
public Creature GetCreatureBySpawnId(ulong spawnId)
|
||||
@@ -3734,11 +3734,6 @@ namespace Game.Maps
|
||||
_updateObjects.Remove(obj);
|
||||
}
|
||||
|
||||
public static implicit operator bool(Map map)
|
||||
{
|
||||
return map != null;
|
||||
}
|
||||
|
||||
public MultiPersonalPhaseTracker GetMultiPersonalPhaseTracker() { return _multiPersonalPhaseTracker; }
|
||||
|
||||
public SpawnedPoolData GetPoolData() { return _poolData; }
|
||||
@@ -3829,8 +3824,8 @@ namespace Game.Maps
|
||||
|
||||
if (player == null)
|
||||
Log.outError(LogFilter.Scripts, "{0} neither source nor target object is player (source: TypeId: {1}, Entry: {2}, {3}; target: TypeId: {4}, Entry: {5}, {6}), skipping.",
|
||||
scriptInfo.GetDebugInfo(), source ? source.GetTypeId() : 0, source ? source.GetEntry() : 0, source ? source.GetGUID().ToString() : "",
|
||||
target ? target.GetTypeId() : 0, target ? target.GetEntry() : 0, target ? target.GetGUID().ToString() : "");
|
||||
scriptInfo.GetDebugInfo(), source != null ? source.GetTypeId() : 0, source != null ? source.GetEntry() : 0, source != null ? source.GetGUID().ToString() : "",
|
||||
target != null ? target.GetTypeId() : 0, target != null ? target.GetEntry() : 0, target != null ? target.GetGUID().ToString() : "");
|
||||
}
|
||||
return player;
|
||||
}
|
||||
@@ -3861,8 +3856,8 @@ namespace Game.Maps
|
||||
|
||||
if (creature == null)
|
||||
Log.outError(LogFilter.Scripts, "{0} neither source nor target are creatures (source: TypeId: {1}, Entry: {2}, {3}; target: TypeId: {4}, Entry: {5}, {6}), skipping.",
|
||||
scriptInfo.GetDebugInfo(), source ? source.GetTypeId() : 0, source ? source.GetEntry() : 0, source ? source.GetGUID().ToString() : "",
|
||||
target ? target.GetTypeId() : 0, target ? target.GetEntry() : 0, target ? target.GetGUID().ToString() : "");
|
||||
scriptInfo.GetDebugInfo(), source != null ? source.GetTypeId() : 0, source != null ? source.GetEntry() : 0, source != null ? source.GetGUID().ToString() : "",
|
||||
target != null ? target.GetTypeId() : 0, target != null ? target.GetEntry() : 0, target != null ? target.GetGUID().ToString() : "");
|
||||
}
|
||||
return creature;
|
||||
}
|
||||
@@ -4112,10 +4107,10 @@ namespace Game.Maps
|
||||
else
|
||||
source = _GetScriptCreatureSourceOrTarget(source, target, step.script);
|
||||
|
||||
if (source)
|
||||
if (source != null)
|
||||
{
|
||||
Unit sourceUnit = source.ToUnit();
|
||||
if (!sourceUnit)
|
||||
if (sourceUnit == null)
|
||||
{
|
||||
Log.outError(LogFilter.Scripts, "{0} source object ({1}) is not an unit, skipping.", step.script.GetDebugInfo(), source.GetGUID().ToString());
|
||||
break;
|
||||
@@ -4136,8 +4131,8 @@ namespace Game.Maps
|
||||
case ChatMsg.Whisper:
|
||||
case ChatMsg.RaidBossWhisper:
|
||||
{
|
||||
Player receiver = target ? target.ToPlayer() : null;
|
||||
if (!receiver)
|
||||
Player receiver = target != null ? target.ToPlayer() : null;
|
||||
if (receiver == null)
|
||||
Log.outError(LogFilter.Scripts, "{0} attempt to whisper to non-player unit, skipping.", step.script.GetDebugInfo());
|
||||
else
|
||||
sourceUnit.Whisper((uint)step.script.Talk.TextID, receiver, step.script.Talk.ChatType == ChatMsg.RaidBossWhisper);
|
||||
@@ -4153,7 +4148,7 @@ namespace Game.Maps
|
||||
{
|
||||
// Source or target must be Creature.
|
||||
Creature cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script);
|
||||
if (cSource)
|
||||
if (cSource != null)
|
||||
{
|
||||
if (step.script.Emote.Flags.HasAnyFlag(eScriptFlags.EmoteUseState))
|
||||
cSource.SetEmoteState((Emote)step.script.Emote.EmoteID);
|
||||
@@ -4166,7 +4161,7 @@ namespace Game.Maps
|
||||
{
|
||||
// Source or target must be Creature.
|
||||
Creature cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script);
|
||||
if (cSource)
|
||||
if (cSource != null)
|
||||
{
|
||||
Unit unit = cSource.ToUnit();
|
||||
if (step.script.MoveTo.TravelTime != 0)
|
||||
@@ -4189,7 +4184,7 @@ namespace Game.Maps
|
||||
{
|
||||
// Source or target must be Creature.
|
||||
Creature cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script);
|
||||
if (cSource)
|
||||
if (cSource != null)
|
||||
cSource.NearTeleportTo(step.script.TeleportTo.DestX, step.script.TeleportTo.DestY,
|
||||
step.script.TeleportTo.DestZ, step.script.TeleportTo.Orientation);
|
||||
}
|
||||
@@ -4197,7 +4192,7 @@ namespace Game.Maps
|
||||
{
|
||||
// Source or target must be Player.
|
||||
Player player = _GetScriptPlayerSourceOrTarget(source, target, step.script);
|
||||
if (player)
|
||||
if (player != null)
|
||||
player.TeleportTo(step.script.TeleportTo.MapID, step.script.TeleportTo.DestX,
|
||||
step.script.TeleportTo.DestY, step.script.TeleportTo.DestZ, step.script.TeleportTo.Orientation);
|
||||
}
|
||||
@@ -4205,12 +4200,12 @@ namespace Game.Maps
|
||||
}
|
||||
case ScriptCommands.QuestExplored:
|
||||
{
|
||||
if (!source)
|
||||
if (source == null)
|
||||
{
|
||||
Log.outError(LogFilter.Scripts, "{0} source object is NULL.", step.script.GetDebugInfo());
|
||||
break;
|
||||
}
|
||||
if (!target)
|
||||
if (target == null)
|
||||
{
|
||||
Log.outError(LogFilter.Scripts, "{0} target object is NULL.", step.script.GetDebugInfo());
|
||||
break;
|
||||
@@ -4265,7 +4260,7 @@ namespace Game.Maps
|
||||
{
|
||||
// Source or target must be Player.
|
||||
Player player = _GetScriptPlayerSourceOrTarget(source, target, step.script);
|
||||
if (player)
|
||||
if (player != null)
|
||||
{
|
||||
if (step.script.KillCredit.Flags.HasAnyFlag(eScriptFlags.KillcreditRewardGroup))
|
||||
player.RewardPlayerAndGroupAtEvent(step.script.KillCredit.CreatureEntry, player);
|
||||
@@ -4284,7 +4279,7 @@ namespace Game.Maps
|
||||
|
||||
// Source or target must be WorldObject.
|
||||
WorldObject pSummoner = _GetScriptWorldObject(source, true, step.script);
|
||||
if (pSummoner)
|
||||
if (pSummoner != null)
|
||||
{
|
||||
GameObject pGO = _FindGameObject(pSummoner, step.script.RespawnGameObject.GOGuid);
|
||||
if (pGO == null)
|
||||
@@ -4318,7 +4313,7 @@ namespace Game.Maps
|
||||
{
|
||||
// Source must be WorldObject.
|
||||
WorldObject pSummoner = _GetScriptWorldObject(source, true, step.script);
|
||||
if (pSummoner)
|
||||
if (pSummoner != null)
|
||||
{
|
||||
if (step.script.TempSummonCreature.CreatureEntry == 0)
|
||||
Log.outError(LogFilter.Scripts, "{0} creature entry (datalong) is not specified.", step.script.GetDebugInfo());
|
||||
@@ -4344,7 +4339,7 @@ namespace Game.Maps
|
||||
{
|
||||
// Source must be Unit.
|
||||
Unit unit = _GetScriptUnit(source, true, step.script);
|
||||
if (unit)
|
||||
if (unit != null)
|
||||
{
|
||||
// Target must be GameObject.
|
||||
if (target == null)
|
||||
@@ -4361,7 +4356,7 @@ namespace Game.Maps
|
||||
break;
|
||||
}
|
||||
GameObject pGO = target.ToGameObject();
|
||||
if (pGO)
|
||||
if (pGO != null)
|
||||
pGO.Use(unit);
|
||||
}
|
||||
break;
|
||||
@@ -4371,7 +4366,7 @@ namespace Game.Maps
|
||||
// Source (datalong2 != 0) or target (datalong2 == 0) must be Unit.
|
||||
bool bReverse = step.script.RemoveAura.Flags.HasAnyFlag(eScriptFlags.RemoveauraReverse);
|
||||
Unit unit = _GetScriptUnit(bReverse ? source : target, bReverse, step.script);
|
||||
if (unit)
|
||||
if (unit != null)
|
||||
unit.RemoveAurasDueToSpell(step.script.RemoveAura.SpellID);
|
||||
break;
|
||||
}
|
||||
@@ -4432,7 +4427,7 @@ namespace Game.Maps
|
||||
case ScriptCommands.PlaySound:
|
||||
// Source must be WorldObject.
|
||||
WorldObject obj = _GetScriptWorldObject(source, true, step.script);
|
||||
if (obj)
|
||||
if (obj != null)
|
||||
{
|
||||
// PlaySound.Flags bitmask: 0/1=anyone/target
|
||||
Player player2 = null;
|
||||
@@ -4455,7 +4450,7 @@ namespace Game.Maps
|
||||
case ScriptCommands.CreateItem:
|
||||
// Target or source must be Player.
|
||||
Player pReceiver = _GetScriptPlayerSourceOrTarget(source, target, step.script);
|
||||
if (pReceiver)
|
||||
if (pReceiver != null)
|
||||
{
|
||||
var dest = new List<ItemPosCount>();
|
||||
InventoryResult msg = pReceiver.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, step.script.CreateItem.ItemEntry, step.script.CreateItem.Amount);
|
||||
@@ -4488,7 +4483,7 @@ namespace Game.Maps
|
||||
{
|
||||
// Source must be Unit.
|
||||
Unit unit = _GetScriptUnit(source, true, step.script);
|
||||
if (unit)
|
||||
if (unit != null)
|
||||
{
|
||||
if (Global.WaypointMgr.GetPath(step.script.LoadPath.PathID) == null)
|
||||
Log.outError(LogFilter.Scripts, "{0} source object has an invalid path ({1}), skipping.", step.script.GetDebugInfo(), step.script.LoadPath.PathID);
|
||||
@@ -4512,7 +4507,7 @@ namespace Game.Maps
|
||||
|
||||
Creature cTarget = null;
|
||||
var creatureBounds = _creatureBySpawnIdStore.LookupByKey(step.script.CallScript.CreatureEntry);
|
||||
if (!creatureBounds.Empty())
|
||||
if (creatureBounds.Empty())
|
||||
{
|
||||
// Prefer alive (last respawned) creature
|
||||
var foundCreature = creatureBounds.Find(creature => creature.IsAlive());
|
||||
@@ -4535,7 +4530,7 @@ namespace Game.Maps
|
||||
{
|
||||
// Source or target must be Creature.
|
||||
Creature cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script);
|
||||
if (cSource)
|
||||
if (cSource != null)
|
||||
{
|
||||
if (cSource.IsDead())
|
||||
Log.outError(LogFilter.Scripts, "{0} creature is already dead (Entry: {1}, GUID: {2})", step.script.GetDebugInfo(), cSource.GetEntry(), cSource.GetGUID().ToString());
|
||||
@@ -4552,7 +4547,7 @@ namespace Game.Maps
|
||||
{
|
||||
// Source must be Unit.
|
||||
Unit sourceUnit = _GetScriptUnit(source, true, step.script);
|
||||
if (sourceUnit)
|
||||
if (sourceUnit != null)
|
||||
{
|
||||
if (step.script.Orientation.Flags.HasAnyFlag(eScriptFlags.OrientationFaceTarget))
|
||||
{
|
||||
@@ -4571,16 +4566,16 @@ namespace Game.Maps
|
||||
case ScriptCommands.Equip:
|
||||
{
|
||||
// Source must be Creature.
|
||||
Creature cSource = _GetScriptCreature(source, target, step.script);
|
||||
if (cSource)
|
||||
Creature cSource = _GetScriptCreature(source, target != null, step.script);
|
||||
if (cSource != null)
|
||||
cSource.LoadEquipment((int)step.script.Equip.EquipmentID);
|
||||
break;
|
||||
}
|
||||
case ScriptCommands.Model:
|
||||
{
|
||||
// Source must be Creature.
|
||||
Creature cSource = _GetScriptCreature(source, target, step.script);
|
||||
if (cSource)
|
||||
Creature cSource = _GetScriptCreature(source, target != null, step.script);
|
||||
if (cSource != null)
|
||||
cSource.SetDisplayId(step.script.Model.ModelID);
|
||||
break;
|
||||
}
|
||||
@@ -4596,7 +4591,7 @@ namespace Game.Maps
|
||||
{
|
||||
// Source must be Player.
|
||||
Player player = _GetScriptPlayer(source, true, step.script);
|
||||
if (player)
|
||||
if (player != null)
|
||||
player.SendMovieStart(step.script.PlayMovie.MovieID);
|
||||
break;
|
||||
}
|
||||
@@ -4604,7 +4599,7 @@ namespace Game.Maps
|
||||
{
|
||||
// Source must be Creature.
|
||||
Creature cSource = _GetScriptCreature(source, true, step.script);
|
||||
if (cSource)
|
||||
if (cSource != null)
|
||||
{
|
||||
if (!cSource.IsAlive())
|
||||
return;
|
||||
@@ -4627,7 +4622,7 @@ namespace Game.Maps
|
||||
{
|
||||
// Source must be Creature.
|
||||
Creature cSource = _GetScriptCreature(source, true, step.script);
|
||||
if (cSource)
|
||||
if (cSource != null)
|
||||
cSource.PlayOneShotAnimKitId((ushort)step.script.PlayAnimKit.AnimKitID);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Game.Entities
|
||||
/// <returns>the right instance for the object, based on its InstanceId</returns>
|
||||
public Map CreateMap(uint mapId, Player player)
|
||||
{
|
||||
if (!player)
|
||||
if (player == null)
|
||||
return null;
|
||||
|
||||
var entry = CliDB.MapStorage.LookupByKey(mapId);
|
||||
@@ -138,7 +138,7 @@ namespace Game.Entities
|
||||
return null;
|
||||
|
||||
map = FindMap_i(mapId, newInstanceId);
|
||||
if (!map)
|
||||
if (map == null)
|
||||
{
|
||||
Battleground bg = player.GetBattleground();
|
||||
if (bg != null)
|
||||
@@ -169,7 +169,7 @@ namespace Game.Entities
|
||||
{
|
||||
// Try finding instance id for normal dungeon
|
||||
if (!entries.MapDifficulty.HasResetSchedule())
|
||||
newInstanceId = group ? group.GetRecentInstanceId(mapId) : player.GetRecentInstanceId(mapId);
|
||||
newInstanceId = group != null ? group.GetRecentInstanceId(mapId) : player.GetRecentInstanceId(mapId);
|
||||
|
||||
// If not found or instance is not a normal dungeon, generate new one
|
||||
if (newInstanceId == 0)
|
||||
@@ -188,10 +188,10 @@ namespace Game.Entities
|
||||
map = null;
|
||||
}
|
||||
|
||||
if (!map)
|
||||
if (map == null)
|
||||
{
|
||||
map = CreateInstance(mapId, newInstanceId, instanceLock, difficulty, player.GetTeamId(), group);
|
||||
if (group)
|
||||
if (group != null)
|
||||
group.SetRecentInstance(mapId, instanceOwnerGuid, newInstanceId);
|
||||
else
|
||||
player.SetRecentInstance(mapId, newInstanceId);
|
||||
@@ -201,7 +201,7 @@ namespace Game.Entities
|
||||
{
|
||||
newInstanceId = (uint)player.GetGUID().GetCounter();
|
||||
map = FindMap_i(mapId, newInstanceId);
|
||||
if (!map)
|
||||
if (map == null)
|
||||
map = CreateGarrison(mapId, newInstanceId, player);
|
||||
}
|
||||
else
|
||||
@@ -211,11 +211,11 @@ namespace Game.Entities
|
||||
newInstanceId = (uint)player.GetTeamId();
|
||||
|
||||
map = FindMap_i(mapId, newInstanceId);
|
||||
if (!map)
|
||||
if (map == null)
|
||||
map = CreateWorldMap(mapId, newInstanceId);
|
||||
}
|
||||
|
||||
if (map)
|
||||
if (map != null)
|
||||
i_maps[(map.GetId(), map.GetInstanceId())] = map;
|
||||
|
||||
return map;
|
||||
@@ -242,13 +242,13 @@ namespace Game.Entities
|
||||
Difficulty difficulty = group != null ? group.GetDifficultyID(entry) : player.GetDifficultyID(entry);
|
||||
MapDb2Entries entries = new(entry, Global.DB2Mgr.GetDownscaledMapDifficultyData(mapId, ref difficulty));
|
||||
|
||||
ObjectGuid instanceOwnerGuid = group ? group.GetRecentInstanceOwner(mapId) : player.GetGUID();
|
||||
ObjectGuid instanceOwnerGuid = group != null ? group.GetRecentInstanceOwner(mapId) : player.GetGUID();
|
||||
InstanceLock instanceLock = Global.InstanceLockMgr.FindActiveInstanceLock(instanceOwnerGuid, entries);
|
||||
uint newInstanceId = 0;
|
||||
if (instanceLock != null)
|
||||
newInstanceId = instanceLock.GetInstanceId();
|
||||
else if (!entries.MapDifficulty.HasResetSchedule()) // Try finding instance id for normal dungeon
|
||||
newInstanceId = group ? group.GetRecentInstanceId(mapId) : player.GetRecentInstanceId(mapId);
|
||||
newInstanceId = group != null ? group.GetRecentInstanceId(mapId) : player.GetRecentInstanceId(mapId);
|
||||
|
||||
if (newInstanceId == 0)
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user