From 7255455b224055bbde5eeec31116d194304cc990 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 5 Jul 2018 10:57:42 -0400 Subject: [PATCH] Core/Refactor: Part 5 --- Source/Framework/Logging/Log.cs | 14 ++++- Source/Framework/Util/CollectionExtensions.cs | 4 +- Source/Game/AI/CoreAI/CombatAI.cs | 9 +++ Source/Game/AI/CoreAI/GameObjectAI.cs | 2 + Source/Game/AI/ScriptedAI/ScriptedAI.cs | 3 - Source/Game/AI/SmartScripts/SmartScript.cs | 6 +- Source/Game/Accounts/AccountManager.cs | 2 +- .../BattleGrounds/Zones/StrandofAncients.cs | 4 +- Source/Game/Chat/Commands/LearnCommands.cs | 4 +- Source/Game/Entities/Player/Player.DB.cs | 2 +- Source/Game/Entities/Player/Player.Items.cs | 2 +- Source/Game/Entities/Player/Player.Spells.cs | 4 +- Source/Game/Entities/Player/Player.cs | 3 + Source/Game/Entities/Unit/Unit.Combat.cs | 2 +- Source/Game/Handlers/CharacterHandler.cs | 2 +- Source/Game/Loot/LootManager.cs | 14 ++--- Source/Game/Pools/PoolManager.cs | 11 ++-- Source/Game/Server/WorldConfig.cs | 4 +- Source/Game/Spells/Spell.cs | 58 +++++++++---------- Source/Game/Spells/SpellInfo.cs | 2 +- .../TrialOfTheChampion/GrandChampions.cs | 6 +- .../IcecrownCitadel/IcecrownCitadel.cs | 20 ++++--- .../IcecrownCitadel/IcecrownCitadelConst.cs | 12 ++-- .../world/master/2018_06_27_01_world.sql | 4 ++ 24 files changed, 109 insertions(+), 85 deletions(-) create mode 100644 sql/updates/world/master/2018_06_27_01_world.sql diff --git a/Source/Framework/Logging/Log.cs b/Source/Framework/Logging/Log.cs index 869855f15..85a4718e3 100644 --- a/Source/Framework/Logging/Log.cs +++ b/Source/Framework/Logging/Log.cs @@ -28,6 +28,7 @@ public class Log static Log() { m_logsDir = AppContext.BaseDirectory + ConfigMgr.GetDefaultValue("LogsDir", ""); + lowestLogLevel = LogLevel.Fatal; foreach (var appenderName in ConfigMgr.GetKeysByString("Appender.")) { @@ -66,11 +67,15 @@ public class Log outInfo(LogFilter.Server, @" \/___/ `/___/> \ \ \/ \/_/\/_/\/____/ \/_/ "); outInfo(LogFilter.Server, @" /\___/\ \_\ "); outInfo(LogFilter.Server, @" \/__/ \/_/ Core"); - outInfo(LogFilter.Server, "\r"); + outInfo(LogFilter.Server, "https://github.com/CypherCore/CypherCore \r\n"); } static bool ShouldLog(LogFilter type, LogLevel level) { + // Don't even look for a logger if the LogLevel is lower than lowest log levels across all loggers + if (level < lowestLogLevel) + return false; + Logger logger = GetLoggerByType(type); if (logger == null) return false; @@ -256,6 +261,9 @@ public class Log return; } + if (level < lowestLogLevel) + lowestLogLevel = level; + Logger logger = new Logger(name, level); int i = 0; @@ -316,6 +324,8 @@ public class Log if (logger.getName() == name) { logger.setLogLevel(newLevel); + if (newLevel != LogLevel.Disabled && newLevel < lowestLogLevel) + lowestLogLevel = newLevel; return true; } } @@ -345,6 +355,8 @@ public class Log static Dictionary loggers = new Dictionary(); static string m_logsDir; static byte AppenderId; + + static LogLevel lowestLogLevel; } enum AppenderType diff --git a/Source/Framework/Util/CollectionExtensions.cs b/Source/Framework/Util/CollectionExtensions.cs index 69fd81e38..d619435c5 100644 --- a/Source/Framework/Util/CollectionExtensions.cs +++ b/Source/Framework/Util/CollectionExtensions.cs @@ -177,12 +177,12 @@ namespace System.Collections.Generic } } - public interface ICheck + public interface ICheck { bool Invoke(T obj); } - public interface IDoWork + public interface IDoWork { void Invoke(T obj); } diff --git a/Source/Game/AI/CoreAI/CombatAI.cs b/Source/Game/AI/CoreAI/CombatAI.cs index 811831bde..04ddacb45 100644 --- a/Source/Game/AI/CoreAI/CombatAI.cs +++ b/Source/Game/AI/CoreAI/CombatAI.cs @@ -239,6 +239,7 @@ namespace Game.AI me.m_CombatDistance = spellInfo != null ? spellInfo.GetMaxRange(false) : 0; me.m_SightDistance = me.m_CombatDistance; } + public override bool CanAIAttack(Unit victim) { // todo use one function to replace it @@ -247,11 +248,13 @@ namespace Game.AI return false; return true; } + public override void AttackStart(Unit victim) { if (victim != null) me.Attack(victim, false); } + public override void UpdateAI(uint diff) { if (!UpdateVictim()) @@ -292,6 +295,10 @@ namespace Game.AI } } + public override void MoveInLineOfSight(Unit who) { } + + public override void AttackStart(Unit victim) { } + public override void OnCharmed(bool apply) { if (!me.GetVehicleKit().IsVehicleInUse() && !apply && m_HasConditions)//was used and has conditions @@ -350,6 +357,8 @@ namespace Game.AI { public ReactorAI(Creature c) : base(c) { } + public override void MoveInLineOfSight(Unit who) { } + public override void UpdateAI(uint diff) { if (!UpdateVictim()) diff --git a/Source/Game/AI/CoreAI/GameObjectAI.cs b/Source/Game/AI/CoreAI/GameObjectAI.cs index 5b715f8fb..829202ad7 100644 --- a/Source/Game/AI/CoreAI/GameObjectAI.cs +++ b/Source/Game/AI/CoreAI/GameObjectAI.cs @@ -65,5 +65,7 @@ namespace Game.AI public class NullGameObjectAI : GameObjectAI { public NullGameObjectAI(GameObject g) : base(g) { } + + public override void UpdateAI(uint diff) { } } } diff --git a/Source/Game/AI/ScriptedAI/ScriptedAI.cs b/Source/Game/AI/ScriptedAI/ScriptedAI.cs index 5938ee193..fbae9cf57 100644 --- a/Source/Game/AI/ScriptedAI/ScriptedAI.cs +++ b/Source/Game/AI/ScriptedAI/ScriptedAI.cs @@ -343,9 +343,6 @@ namespace Game.AI // Called when spell hits a target public override void SpellHitTarget(Unit target, SpellInfo spell) { } - //Called at waypoint reached or PointMovement end - public override void MovementInform(MovementGeneratorType type, uint id) { } - // Called when AI is temporarily replaced or put back when possess is applied or removed public virtual void OnPossess(bool apply) { } diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 1072f8f55..c855e1db6 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -1449,7 +1449,7 @@ namespace Game.AI break; uint delay = e.Action.wpPause.delay; - ((SmartAI)me.GetAI()).PausePath(delay, e.GetEventType() == SmartEvents.WaypointReached ? false : true); + ((SmartAI)me.GetAI()).PausePath(delay, e.GetEventType() != SmartEvents.WaypointReached); break; } case SmartActions.WpStop: @@ -2695,7 +2695,7 @@ namespace Game.AI } case SmartTargets.ClosestCreature: { - Creature target = baseObject.FindNearestCreature(e.Target.closest.entry, e.Target.closest.dist != 0 ? e.Target.closest.dist : 100, e.Target.closest.dead != 0 ? false : true); + Creature target = baseObject.FindNearestCreature(e.Target.closest.entry, e.Target.closest.dist != 0 ? e.Target.closest.dist : 100, e.Target.closest.dead == 0); if (target) l.Add(target); break; @@ -3431,7 +3431,7 @@ namespace Game.AI } // min/max was checked at loading! e.timer = RandomHelper.URand(min, max); - e.active = e.timer != 0 ? false : true; + e.active = e.timer == 0; } void UpdateTimer(SmartScriptHolder e, uint diff) diff --git a/Source/Game/Accounts/AccountManager.cs b/Source/Game/Accounts/AccountManager.cs index dff07cfa0..c2045e0e5 100644 --- a/Source/Game/Accounts/AccountManager.cs +++ b/Source/Game/Accounts/AccountManager.cs @@ -289,7 +289,7 @@ namespace Game stmt.AddValue(0, accountId); stmt.AddValue(1, CalculateShaPassHash(username, password)); SQLResult result = DB.Login.Query(stmt); - return result.IsEmpty() ? false : true; + return !result.IsEmpty(); } public bool CheckEmail(uint accountId, string newEmail) diff --git a/Source/Game/BattleGrounds/Zones/StrandofAncients.cs b/Source/Game/BattleGrounds/Zones/StrandofAncients.cs index e2b1d772e..ee5369be2 100644 --- a/Source/Game/BattleGrounds/Zones/StrandofAncients.cs +++ b/Source/Game/BattleGrounds/Zones/StrandofAncients.cs @@ -802,7 +802,7 @@ namespace Game.BattleGrounds.Zones break; default: return; - }; + } } void CaptureGraveyard(int i, Player Source) @@ -900,7 +900,7 @@ namespace Game.BattleGrounds.Zones default: //ABORT(); break; - }; + } } void TitanRelicActivated(Player clicker) diff --git a/Source/Game/Chat/Commands/LearnCommands.cs b/Source/Game/Chat/Commands/LearnCommands.cs index 1d43469ab..94965c140 100644 --- a/Source/Game/Chat/Commands/LearnCommands.cs +++ b/Source/Game/Chat/Commands/LearnCommands.cs @@ -45,7 +45,7 @@ namespace Game.Chat.Commands return false; string all = args.NextString(); - bool allRanks = !string.IsNullOrEmpty(all) ? all == "all" : false; + bool allRanks = !string.IsNullOrEmpty(all) && all == "all"; SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spell); if (spellInfo == null || !Global.SpellMgr.IsSpellValid(spellInfo, handler.GetSession().GetPlayer())) @@ -325,7 +325,7 @@ namespace Game.Chat.Commands return false; string allStr = args.NextString(); - bool allRanks = !string.IsNullOrEmpty(allStr) ? allStr == "all" : false; + bool allRanks = !string.IsNullOrEmpty(allStr) && allStr == "all"; Player target = handler.getSelectedPlayer(); if (!target) diff --git a/Source/Game/Entities/Player/Player.DB.cs b/Source/Game/Entities/Player/Player.DB.cs index 9181d49a0..5aa444da3 100644 --- a/Source/Game/Entities/Player/Player.DB.cs +++ b/Source/Game/Entities/Player/Player.DB.cs @@ -4023,7 +4023,7 @@ namespace Game.Entities if (keepDays == 0) return; - Player.DeleteOldCharacters(keepDays); + DeleteOldCharacters(keepDays); } public static void DeleteOldCharacters(int keepDays) diff --git a/Source/Game/Entities/Player/Player.Items.cs b/Source/Game/Entities/Player/Player.Items.cs index f2163231e..8812ea3d1 100644 --- a/Source/Game/Entities/Player/Player.Items.cs +++ b/Source/Game/Entities/Player/Player.Items.cs @@ -6276,7 +6276,7 @@ namespace Game.Entities if (groupRules) group.UpdateLooterGuid(go, true); - loot.FillLoot(lootid, LootManager.Gameobject, this, !groupRules, false, go.GetLootMode()); + loot.FillLoot(lootid, LootStorage.Gameobject, this, !groupRules, false, go.GetLootMode()); // get next RR player (for next loot) if (groupRules) diff --git a/Source/Game/Entities/Player/Player.Spells.cs b/Source/Game/Entities/Player/Player.Spells.cs index cbc2520d2..d31b9fd82 100644 --- a/Source/Game/Entities/Player/Player.Spells.cs +++ b/Source/Game/Entities/Player/Player.Spells.cs @@ -1973,7 +1973,7 @@ namespace Game.Entities PlayerSpell spell = m_spells.LookupByKey(spellId); bool disabled = (spell != null) ? spell.Disabled : false; - bool active = disabled ? spell.Active : true; + bool active = !disabled || spell.Active; bool learning = AddSpell(spellId, active, true, dependent, false, false, fromSkill); @@ -2525,7 +2525,7 @@ namespace Game.Entities // needs to be when spell is already learned, to prevent infinite recursion crashes if (Global.DB2Mgr.GetMount(spellId) != null) - GetSession().GetCollectionMgr().AddMount(spellId, MountStatusFlags.None, false, IsInWorld ? false : true); + GetSession().GetCollectionMgr().AddMount(spellId, MountStatusFlags.None, false, !IsInWorld); // need to add Battle pets automatically into pet journal foreach (BattlePetSpeciesRecord entry in CliDB.BattlePetSpeciesStorage.Values) diff --git a/Source/Game/Entities/Player/Player.cs b/Source/Game/Entities/Player/Player.cs index c4fba977a..d6977460b 100644 --- a/Source/Game/Entities/Player/Player.cs +++ b/Source/Game/Entities/Player/Player.cs @@ -5204,6 +5204,9 @@ namespace Game.Entities } //Target + // Used for serverside target changes, does not apply to players + public override void SetTarget(ObjectGuid guid) { } + public void SetSelection(ObjectGuid guid) { SetGuidValue(UnitFields.Target, guid); diff --git a/Source/Game/Entities/Unit/Unit.Combat.cs b/Source/Game/Entities/Unit/Unit.Combat.cs index 6bc2330ba..30d170cb4 100644 --- a/Source/Game/Entities/Unit/Unit.Combat.cs +++ b/Source/Game/Entities/Unit/Unit.Combat.cs @@ -1403,7 +1403,7 @@ namespace Game.Entities loot.clear(); uint lootid = creature.GetCreatureTemplate().LootId; if (lootid != 0) - loot.FillLoot(lootid, LootManager.Creature, looter, false, false, creature.GetLootMode()); + loot.FillLoot(lootid, LootStorage.Creature, looter, false, false, creature.GetLootMode()); loot.generateMoneyLoot(creature.GetCreatureTemplate().MinGold, creature.GetCreatureTemplate().MaxGold); diff --git a/Source/Game/Handlers/CharacterHandler.cs b/Source/Game/Handlers/CharacterHandler.cs index 90e6ca674..828fe2ac9 100644 --- a/Source/Game/Handlers/CharacterHandler.cs +++ b/Source/Game/Handlers/CharacterHandler.cs @@ -83,7 +83,7 @@ namespace Game charInfo.HairColor = 0; charInfo.FacialHair = 0; - if (!(charInfo.CustomizationFlag == CharacterCustomizeFlags.Customize)) + if (charInfo.CustomizationFlag != CharacterCustomizeFlags.Customize) { PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_ADD_AT_LOGIN_FLAG); stmt.AddValue(0, (ushort)AtLoginFlags.Customize); diff --git a/Source/Game/Loot/LootManager.cs b/Source/Game/Loot/LootManager.cs index d7a40dd82..067eb210f 100644 --- a/Source/Game/Loot/LootManager.cs +++ b/Source/Game/Loot/LootManager.cs @@ -724,7 +724,7 @@ namespace Game.Loots if (item.reference > 0) // References processing { - LootTemplate Referenced = LootManager.Reference.GetLootFor(item.reference); + LootTemplate Referenced = LootStorage.Reference.GetLootFor(item.reference); if (Referenced == null) continue; // Error message already printed at loading stage @@ -849,8 +849,8 @@ namespace Game.Loots { if (item.reference > 0) { - if (LootManager.Reference.GetLootFor(item.reference) == null) - LootManager.Reference.ReportNonExistingId(item.reference, item.itemid); + if (LootStorage.Reference.GetLootFor(item.reference) == null) + LootStorage.Reference.ReportNonExistingId(item.reference, item.itemid); else if (ref_set != null) ref_set.Remove(item.reference); } @@ -1005,8 +1005,8 @@ namespace Game.Loots { if (item.reference > 0) { - if (LootManager.Reference.GetLootFor(item.reference) == null) - LootManager.Reference.ReportNonExistingId(item.reference, item.itemid); + if (LootStorage.Reference.GetLootFor(item.reference) == null) + LootStorage.Reference.ReportNonExistingId(item.reference, item.itemid); else if (ref_set != null) ref_set.Remove(item.reference); } @@ -1016,8 +1016,8 @@ namespace Game.Loots { if (item.reference > 0) { - if (LootManager.Reference.GetLootFor(item.reference) == null) - LootManager.Reference.ReportNonExistingId(item.reference, item.itemid); + if (LootStorage.Reference.GetLootFor(item.reference) == null) + LootStorage.Reference.ReportNonExistingId(item.reference, item.itemid); else if (ref_set != null) ref_set.Remove(item.reference); } diff --git a/Source/Game/Pools/PoolManager.cs b/Source/Game/Pools/PoolManager.cs index 2cf49b067..b9b67e1b4 100644 --- a/Source/Game/Pools/PoolManager.cs +++ b/Source/Game/Pools/PoolManager.cs @@ -826,14 +826,11 @@ namespace Game DespawnObject(spawns); // recycle minimal amount of quests if possible count is lower than limit - if (limit > newQuests.Count && !currentQuests.Empty()) + while (limit > newQuests.Count && !currentQuests.Empty()) { - do - { - ulong questId = currentQuests.SelectRandom(); - newQuests.Add(questId); - currentQuests.Remove(questId); - } while (newQuests.Count < limit && !currentQuests.Empty()); // failsafe + ulong questId = currentQuests.SelectRandom(); + newQuests.Add(questId); + currentQuests.Remove(questId); } if (newQuests.Empty()) diff --git a/Source/Game/Server/WorldConfig.cs b/Source/Game/Server/WorldConfig.cs index 0803d8381..d7af0a0b2 100644 --- a/Source/Game/Server/WorldConfig.cs +++ b/Source/Game/Server/WorldConfig.cs @@ -675,9 +675,7 @@ namespace Game Values[WorldCfg.ThreatRadius] = GetDefaultValue("ThreatRadius", 60.0f); // always use declined names in the russian client - Values[WorldCfg.DeclinedNamesUsed] = - - ((RealmZones)Values[WorldCfg.RealmZone] == RealmZones.Russian) ? true : GetDefaultValue("DeclinedNames", false); + Values[WorldCfg.DeclinedNamesUsed] = (RealmZones)Values[WorldCfg.RealmZone] == RealmZones.Russian || GetDefaultValue("DeclinedNames", false); Values[WorldCfg.ListenRangeSay] = GetDefaultValue("ListenRange.Say", 25.0f); Values[WorldCfg.ListenRangeTextemote] = GetDefaultValue("ListenRange.TextEmote", 25.0f); diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 1546b76d8..79cc9de02 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -1254,12 +1254,12 @@ namespace Game.Spells case SpellEffectName.SummonPlayer: if (m_caster.IsTypeId(TypeId.Player) && !m_caster.GetTarget().IsEmpty()) { - WorldObject target1 = Global.ObjAccessor.FindPlayer(m_caster.GetTarget()); + WorldObject rafTarget = Global.ObjAccessor.FindPlayer(m_caster.GetTarget()); - CallScriptObjectTargetSelectHandlers(ref target1, effIndex, new SpellImplicitTargetInfo()); + CallScriptObjectTargetSelectHandlers(ref rafTarget, effIndex, new SpellImplicitTargetInfo()); - if (target1 != null && target1.IsTypeId(TypeId.Player)) - AddUnitTarget(target1.ToUnit(), (uint)(1 << (int)effIndex), false); + if (rafTarget != null && rafTarget.IsTypeId(TypeId.Player)) + AddUnitTarget(rafTarget.ToUnit(), (uint)(1 << (int)effIndex), false); } return; default: @@ -4765,8 +4765,8 @@ namespace Game.Spells if (!m_caster.IsTypeId(TypeId.Player)) return SpellCastResult.DontReport; - Unit target1 = m_targets.GetUnitTarget(); - if (target1 == null || !target1.IsFriendlyTo(m_caster) || target1.getAttackers().Empty()) + Unit target = m_targets.GetUnitTarget(); + if (target == null || !target.IsFriendlyTo(m_caster) || target.getAttackers().Empty()) return SpellCastResult.BadTargets; } @@ -4819,7 +4819,6 @@ namespace Game.Spells return SpellCastResult.BadTargets; SpellInfo learn_spellproto = Global.SpellMgr.GetSpellInfo(effect.TriggerSpell); - if (learn_spellproto == null) return SpellCastResult.NotKnown; @@ -4919,9 +4918,9 @@ namespace Game.Spells // Can be area effect, Check only for players and not check if target - caster (spell can have multiply drain/burn effects) if (m_caster.IsTypeId(TypeId.Player)) { - Unit target1 = m_targets.GetUnitTarget(); - if (target1 != null) - if (target1 != m_caster && unitTarget.GetPowerType() != (PowerType)effect.MiscValue) + Unit target = m_targets.GetUnitTarget(); + if (target != null) + if (target != m_caster && unitTarget.GetPowerType() != (PowerType)effect.MiscValue) return SpellCastResult.BadTargets; } break; @@ -4933,31 +4932,31 @@ namespace Game.Spells if (GetSpellInfo().NeedsExplicitUnitTarget()) { - Unit target1 = m_targets.GetUnitTarget(); - if (target1 == null) + Unit target = m_targets.GetUnitTarget(); + if (target == null) return SpellCastResult.DontReport; - float objSize = target1.GetObjectSize(); + float objSize = target.GetObjectSize(); float range = m_spellInfo.GetMaxRange(true, m_caster, this) * 1.5f + objSize; // can't be overly strict m_preGeneratedPath.SetPathLengthLimit(range); //first try with raycast, if it fails fall back to normal path - float targetObjectSize = Math.Min(target1.GetObjectSize(), 4.0f); - bool result = m_preGeneratedPath.CalculatePath(target1.GetPositionX(), target1.GetPositionY(), target1.GetPositionZ() + targetObjectSize, false, true); + float targetObjectSize = Math.Min(target.GetObjectSize(), 4.0f); + bool result = m_preGeneratedPath.CalculatePath(target.GetPositionX(), target.GetPositionY(), target.GetPositionZ() + targetObjectSize, false, true); if (m_preGeneratedPath.GetPathType().HasAnyFlag(PathType.Short)) return SpellCastResult.OutOfRange; else if (!result || m_preGeneratedPath.GetPathType().HasAnyFlag(PathType.NoPath | PathType.Incomplete)) { - result = m_preGeneratedPath.CalculatePath(target1.GetPositionX(), target1.GetPositionY(), target1.GetPositionZ() + targetObjectSize, false, false); + result = m_preGeneratedPath.CalculatePath(target.GetPositionX(), target.GetPositionY(), target.GetPositionZ() + targetObjectSize, false, false); if (m_preGeneratedPath.GetPathType().HasAnyFlag(PathType.Short)) return SpellCastResult.OutOfRange; else if (!result || m_preGeneratedPath.GetPathType().HasAnyFlag(PathType.NoPath | PathType.Incomplete)) return SpellCastResult.NoPath; - else if (m_preGeneratedPath.IsInvalidDestinationZ(target1)) // Check position z, if not in a straight line + else if (m_preGeneratedPath.IsInvalidDestinationZ(target)) // Check position z, if not in a straight line return SpellCastResult.NoPath; } - else if (m_preGeneratedPath.IsInvalidDestinationZ(target1)) // Check position z, if in a straight line + else if (m_preGeneratedPath.IsInvalidDestinationZ(target)) // Check position z, if in a straight line return SpellCastResult.NoPath; m_preGeneratedPath.ReducePathLenghtByDist(objSize); //move back @@ -5152,10 +5151,9 @@ namespace Game.Spells if (playerCaster.GetTarget().IsEmpty()) return SpellCastResult.BadTargets; - Player target1 = Global.ObjAccessor.FindPlayer(playerCaster.GetTarget()); - - if (target1 == null || - !(target1.GetSession().GetRecruiterId() == playerCaster.GetSession().GetAccountId() || target1.GetSession().GetAccountId() == playerCaster.GetSession().GetRecruiterId())) + Player target = Global.ObjAccessor.FindPlayer(playerCaster.GetTarget()); + if (target == null || + !(target.GetSession().GetRecruiterId() == playerCaster.GetSession().GetAccountId() || target.GetSession().GetAccountId() == playerCaster.GetSession().GetRecruiterId())) return SpellCastResult.BadTargets; break; @@ -5291,23 +5289,23 @@ namespace Game.Spells return SpellCastResult.AlreadyHaveCharm; } - Unit target1 = m_targets.GetUnitTarget(); - if (target1 != null) + Unit target = m_targets.GetUnitTarget(); + if (target != null) { - if (target1.IsTypeId(TypeId.Unit) && target1.ToCreature().IsVehicle()) + if (target.IsTypeId(TypeId.Unit) && target.ToCreature().IsVehicle()) return SpellCastResult.BadImplicitTargets; - if (target1.IsMounted()) + if (target.IsMounted()) return SpellCastResult.CantBeCharmed; - if (!target1.GetCharmerGUID().IsEmpty()) + if (!target.GetCharmerGUID().IsEmpty()) return SpellCastResult.Charmed; - if (target1.GetOwner() != null && target1.GetOwner().IsTypeId(TypeId.Player)) + if (target.GetOwner() != null && target.GetOwner().IsTypeId(TypeId.Player)) return SpellCastResult.TargetIsPlayerControlled; - int damage = CalculateDamage(effect.EffectIndex, target1); - if (damage != 0 && target1.GetLevelForTarget(m_caster) > damage) + int damage = CalculateDamage(effect.EffectIndex, target); + if (damage != 0 && target.GetLevelForTarget(m_caster) > damage) return SpellCastResult.Highlevel; } diff --git a/Source/Game/Spells/SpellInfo.cs b/Source/Game/Spells/SpellInfo.cs index c8bcd4ce0..ce5d789b4 100644 --- a/Source/Game/Spells/SpellInfo.cs +++ b/Source/Game/Spells/SpellInfo.cs @@ -1147,7 +1147,7 @@ namespace Game.Spells him, because it would be it's passenger, there's no such case where this gets to fail legitimacy, this problem cannot be solved from within the check in other way since target type cannot be called for the spell currently Spell examples: [ID - 52864 Devour Water, ID - 52862 Devour Wind, ID - 49370 Wyrmrest Defender: Destabilize Azure Dragonshrine Effect] */ - if (!caster.IsVehicle() && !(caster.GetCharmerOrOwner() == target)) + if (!caster.IsVehicle() && caster.GetCharmerOrOwner() != target) { if (TargetAuraState != 0 && !unitTarget.HasAuraState(TargetAuraState, this, caster)) return SpellCastResult.TargetAurastate; diff --git a/Source/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/GrandChampions.cs b/Source/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/GrandChampions.cs index e0b4a6dfb..e1a700284 100644 --- a/Source/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/GrandChampions.cs +++ b/Source/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/GrandChampions.cs @@ -564,10 +564,10 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheChampion { me.InterruptNonMeleeSpells(true); - Unit target1 = Global.ObjAccessor.GetUnit(me, uiTargetGUID); - if (target1 && me.IsInRange(target1, 5.0f, 30.0f, false)) + Unit uiTarget = Global.ObjAccessor.GetUnit(me, uiTargetGUID); + if (uiTarget && me.IsInRange(uiTarget, 5.0f, 30.0f, false)) { - DoCast(target1, TrialOfChampionSpells.MULTI_SHOT); + DoCast(uiTarget, TrialOfChampionSpells.MULTI_SHOT); } else { diff --git a/Source/Scripts/Northrend/IcecrownCitadel/IcecrownCitadel.cs b/Source/Scripts/Northrend/IcecrownCitadel/IcecrownCitadel.cs index 204e33eea..cad748a86 100644 --- a/Source/Scripts/Northrend/IcecrownCitadel/IcecrownCitadel.cs +++ b/Source/Scripts/Northrend/IcecrownCitadel/IcecrownCitadel.cs @@ -1091,10 +1091,12 @@ namespace Scripts.Northrend.IcecrownCitadel switch (eventId) { case EventTypes.ArnathFlashHeal: - Creature target = FindFriendlyCreature(); - if (target) - DoCast(target, InstanceSpells.SpellFlashHeal(IsUndead)); - _events.ScheduleEvent(EventTypes.ArnathFlashHeal, RandomHelper.URand(6000, 9000)); + { + Creature target = FindFriendlyCreature(); + if (target) + DoCast(target, InstanceSpells.SpellFlashHeal(IsUndead)); + _events.ScheduleEvent(EventTypes.ArnathFlashHeal, RandomHelper.URand(6000, 9000)); + } break; case EventTypes.ArnathPwShield: { @@ -1108,10 +1110,12 @@ namespace Scripts.Northrend.IcecrownCitadel _events.ScheduleEvent(EventTypes.ArnathSmite, RandomHelper.URand(4000, 7000)); break; case EventTypes.ArnathDominateMind: - Unit target1 = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true); - if (target1) - DoCast(target1, InstanceSpells.DominateMind); - _events.ScheduleEvent(EventTypes.ArnathDominateMind, RandomHelper.URand(28000, 37000)); + { + Unit target = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true); + if (target) + DoCast(target, InstanceSpells.DominateMind); + _events.ScheduleEvent(EventTypes.ArnathDominateMind, RandomHelper.URand(28000, 37000)); + } break; default: break; diff --git a/Source/Scripts/Northrend/IcecrownCitadel/IcecrownCitadelConst.cs b/Source/Scripts/Northrend/IcecrownCitadel/IcecrownCitadelConst.cs index 06b53369f..6d1091de6 100644 --- a/Source/Scripts/Northrend/IcecrownCitadel/IcecrownCitadelConst.cs +++ b/Source/Scripts/Northrend/IcecrownCitadel/IcecrownCitadelConst.cs @@ -145,9 +145,9 @@ namespace Scripts.Northrend.IcecrownCitadel public const uint FlashHealUndead = 71782; public const uint PowerWordShieldUndead = 71780; public const uint SmiteUndead = 71778; - public static uint SpellFlashHeal(bool isUndead) { return isUndead ? InstanceSpells.FlashHealUndead : InstanceSpells.FlashHealNormal; } - public static uint SpellPowerWordShield(bool isUndead) { return isUndead ? InstanceSpells.PowerWordShieldUndead : InstanceSpells.PowerWordShieldNormal; } - public static uint SpellSmite(bool isUndead) { return isUndead ? InstanceSpells.SmiteUndead : InstanceSpells.SmiteNormal; } + public static uint SpellFlashHeal(bool isUndead) { return isUndead ? FlashHealUndead : FlashHealNormal; } + public static uint SpellPowerWordShield(bool isUndead) { return isUndead ? PowerWordShieldUndead : PowerWordShieldNormal; } + public static uint SpellSmite(bool isUndead) { return isUndead ? SmiteUndead : SmiteNormal; } // Captain Brandon public const uint CrusaderStrike = 71549; @@ -168,9 +168,9 @@ namespace Scripts.Northrend.IcecrownCitadel public const uint FelIronBombUndead = 71787; public const uint MachineGunUndead = 71788; public const uint RocketLaunchUndead = 71786; - public static uint SpellFelIronBomb(bool isUndead) { return isUndead ? InstanceSpells.FelIronBombUndead : InstanceSpells.FelIronBombNormal; } - public static uint SpellMachineGun(bool isUndead) { return isUndead ? InstanceSpells.MachineGunUndead : InstanceSpells.MachineGunNormal; } - public static uint SpellRocketLaunch(bool isUndead) { return isUndead ? InstanceSpells.RocketLaunchUndead : InstanceSpells.RocketLaunchNormal; } + public static uint SpellFelIronBomb(bool isUndead) { return isUndead ? FelIronBombUndead : FelIronBombNormal; } + public static uint SpellMachineGun(bool isUndead) { return isUndead ? MachineGunUndead : MachineGunNormal; } + public static uint SpellRocketLaunch(bool isUndead) { return isUndead ? RocketLaunchUndead : RocketLaunchNormal; } // Invisible Stalker (Float; Uninteractible; Largeaoi) public const uint SoulMissile = 72585; diff --git a/sql/updates/world/master/2018_06_27_01_world.sql b/sql/updates/world/master/2018_06_27_01_world.sql new file mode 100644 index 000000000..f57e69cc2 --- /dev/null +++ b/sql/updates/world/master/2018_06_27_01_world.sql @@ -0,0 +1,4 @@ +-- The Stonecore normal donjon portal +DELETE FROM `gameobject` WHERE `guid`=200868; +INSERT INTO `gameobject` (`guid`, `id`, `map`, `zoneId`, `areaId`, `spawnMask`, `phaseUseFlags`, `PhaseId`, `PhaseGroup`, `terrainSwapMap`, `position_x`, `position_y`, `position_z`, `orientation`, `rotation0`, `rotation1`, `rotation2`, `rotation3`, `spawntimesecs`, `animprogress`, `state`, `ScriptName`, `VerifiedBuild`) VALUES +(200868, 207897, 646, 5042, 5303, 1, 0, 169, 0, -1, 1029.14, 618.686, 155.706, 1.77533, 0, 0, 0.775599, 0.631225, 120, 255, 1, "", 26365);