diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 24da0bf0d..6c65fe013 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -722,9 +722,9 @@ namespace Game.AI { foreach (var seat in vehicle.Seats) { - Player player1 = Global.ObjAccessor.GetPlayer(unit, seat.Value.Passenger.Guid); - if (player1 != null) - player1.GroupEventHappens(e.Action.quest.questId, GetBaseObject()); + Player passenger = Global.ObjAccessor.GetPlayer(unit, seat.Value.Passenger.Guid); + if (passenger != null) + passenger.GroupEventHappens(e.Action.quest.questId, GetBaseObject()); } } break; diff --git a/Source/Game/Chat/Channels/Channel.cs b/Source/Game/Chat/Channels/Channel.cs index f6746561e..f5a0d31b0 100644 --- a/Source/Game/Chat/Channels/Channel.cs +++ b/Source/Game/Chat/Channels/Channel.cs @@ -764,8 +764,8 @@ namespace Game.Chat if (exclaim) { - ChannelNameBuilder ownerChangedBuilder = new(this, new OwnerChangedAppend(_ownerGuid)); - SendToAll(ownerChangedBuilder); + ChannelNameBuilder ownerBuilder = new(this, new OwnerChangedAppend(_ownerGuid)); + SendToAll(ownerBuilder); } UpdateChannelInDB(); diff --git a/Source/Game/Chat/Commands/LookupCommands.cs b/Source/Game/Chat/Commands/LookupCommands.cs index f0d2c9361..7059bc390 100644 --- a/Source/Game/Chat/Commands/LookupCommands.cs +++ b/Source/Game/Chat/Commands/LookupCommands.cs @@ -30,7 +30,7 @@ namespace Game.Chat [CommandGroup("lookup", RBACPermissions.CommandLookup, true)] class LookupCommands { - static int maxlookup = 50; + static int maxResults = 50; [Command("area", RBACPermissions.CommandLookupArea, true)] static bool Area(StringArguments args, CommandHandler handler) @@ -70,9 +70,9 @@ namespace Game.Chat if (locale < Locale.Total) { - if (maxlookup != 0 && count++ == maxlookup) + if (maxResults != 0 && count++ == maxResults) { - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); return true; } @@ -121,9 +121,9 @@ namespace Game.Chat if (name.Like(namePart)) { - if (maxlookup != 0 && count++ == maxlookup) + if (maxResults != 0 && count++ == maxResults) { - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); return true; } @@ -146,9 +146,9 @@ namespace Game.Chat if (_name.Like(namePart)) { - if (maxlookup != 0 && count++ == maxlookup) + if (maxResults != 0 && count++ == maxResults) { - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); return true; } @@ -192,9 +192,9 @@ namespace Game.Chat if (descr.Like(namePart)) { - if (maxlookup != 0 && count++ == maxlookup) + if (maxResults != 0 && count++ == maxResults) { - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); return true; } @@ -259,9 +259,9 @@ namespace Game.Chat if (locale < Locale.Total) { - if (maxlookup != 0 && count++ == maxlookup) + if (maxResults != 0 && count++ == maxResults) { - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); return true; } @@ -330,9 +330,9 @@ namespace Game.Chat if (name.Like(namePart)) { - if (maxlookup != 0 && count++ == maxlookup) + if (maxResults != 0 && count++ == maxResults) { - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); return true; } @@ -390,9 +390,9 @@ namespace Game.Chat if (locale < Locale.Total) { - if (maxlookup != 0 && count++ == maxlookup) + if (maxResults != 0 && count++ == maxResults) { - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); return true; } @@ -437,9 +437,9 @@ namespace Game.Chat if (name.Like(namePart)) { - if (maxlookup != 0 && count++ == maxlookup) + if (maxResults != 0 && count++ == maxResults) { - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); return true; } @@ -462,9 +462,9 @@ namespace Game.Chat if (_name.Like(namePart)) { - if (maxlookup != 0 && count++ == maxlookup) + if (maxResults != 0 && count++ == maxResults) { - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); return true; } @@ -502,72 +502,66 @@ namespace Game.Chat foreach (var qInfo in qTemplates.Values) { int localeIndex = handler.GetSessionDbLocaleIndex(); - if (localeIndex >= 0) + QuestTemplateLocale questLocale = Global.ObjectMgr.GetQuestLocale(qInfo.Id); + if (questLocale != null) { - byte ulocaleIndex = (byte)localeIndex; - QuestTemplateLocale questLocale = Global.ObjectMgr.GetQuestLocale(qInfo.Id); - if (questLocale != null) + if (questLocale.LogTitle.Length > localeIndex && !questLocale.LogTitle[localeIndex].IsEmpty()) { - if (questLocale.LogTitle.Length > ulocaleIndex && !string.IsNullOrEmpty(questLocale.LogTitle[ulocaleIndex])) + string title = questLocale.LogTitle[localeIndex]; + + if (title.Like(namePart)) { - string title = questLocale.LogTitle[ulocaleIndex]; - - if (title.Like(namePart)) + if (maxResults != 0 && count++ == maxResults) { - if (maxlookup != 0 && count++ == maxlookup) - { - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); - return true; - } - - string statusStr = ""; - - if (target) - { - QuestStatus status = target.GetQuestStatus(qInfo.Id); - - switch (status) - { - case QuestStatus.Complete: - statusStr = handler.GetCypherString(CypherStrings.CommandQuestComplete); - break; - case QuestStatus.Incomplete: - statusStr = handler.GetCypherString(CypherStrings.CommandQuestActive); - break; - case QuestStatus.Rewarded: - statusStr = handler.GetCypherString(CypherStrings.CommandQuestRewarded); - break; - default: - break; - } - } - - if (handler.GetSession() != null) - { - int maxLevel = 0; - var questLevels = Global.DB2Mgr.GetContentTuningData(qInfo.ContentTuningId, handler.GetSession().GetPlayer().m_playerData.CtrOptions.GetValue().ContentTuningConditionMask); - if (questLevels.HasValue) - maxLevel = questLevels.Value.MaxLevel; - - int scalingFactionGroup = 0; - ContentTuningRecord contentTuning = CliDB.ContentTuningStorage.LookupByKey(qInfo.ContentTuningId); - if (contentTuning != null) - scalingFactionGroup = contentTuning.GetScalingFactionGroup(); - - handler.SendSysMessage(CypherStrings.QuestListChat, qInfo.Id, qInfo.Id, - handler.GetSession().GetPlayer().GetQuestLevel(qInfo), - handler.GetSession().GetPlayer().GetQuestMinLevel(qInfo), - maxLevel, scalingFactionGroup, - title, statusStr); - } - else - handler.SendSysMessage(CypherStrings.QuestListConsole, qInfo.Id, title, statusStr); - - if (!found) - found = true; - - continue; + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); + return true; } + + string statusStr = ""; + + if (target) + { + switch (target.GetQuestStatus(qInfo.Id)) + { + case QuestStatus.Complete: + statusStr = handler.GetCypherString(CypherStrings.CommandQuestComplete); + break; + case QuestStatus.Incomplete: + statusStr = handler.GetCypherString(CypherStrings.CommandQuestActive); + break; + case QuestStatus.Rewarded: + statusStr = handler.GetCypherString(CypherStrings.CommandQuestRewarded); + break; + default: + break; + } + } + + if (handler.GetSession() != null) + { + int maxLevel = 0; + var questLevels = Global.DB2Mgr.GetContentTuningData(qInfo.ContentTuningId, handler.GetSession().GetPlayer().m_playerData.CtrOptions.GetValue().ContentTuningConditionMask); + if (questLevels.HasValue) + maxLevel = questLevels.Value.MaxLevel; + + int scalingFactionGroup = 0; + ContentTuningRecord contentTuning = CliDB.ContentTuningStorage.LookupByKey(qInfo.ContentTuningId); + if (contentTuning != null) + scalingFactionGroup = contentTuning.GetScalingFactionGroup(); + + handler.SendSysMessage(CypherStrings.QuestListChat, qInfo.Id, qInfo.Id, + handler.GetSession().GetPlayer().GetQuestLevel(qInfo), + handler.GetSession().GetPlayer().GetQuestMinLevel(qInfo), + maxLevel, scalingFactionGroup, + title, statusStr); + } + else + handler.SendSysMessage(CypherStrings.QuestListConsole, qInfo.Id, title, statusStr); + + if (!found) + found = true; + + continue; } } } @@ -578,9 +572,9 @@ namespace Game.Chat if (_title.Like(namePart)) { - if (maxlookup != 0 && count++ == maxlookup) + if (maxResults != 0 && count++ == maxResults) { - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); return true; } @@ -678,9 +672,9 @@ namespace Game.Chat if (locale < Locale.Total) { - if (maxlookup != 0 && count++ == maxlookup) + if (maxResults != 0 && count++ == maxResults) { - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); return true; } @@ -737,9 +731,9 @@ namespace Game.Chat if (!name.Like(namePart)) continue; - if (maxlookup != 0 && count++ == maxlookup) + if (maxResults != 0 && count++ == maxResults) { - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); return true; } @@ -781,7 +775,7 @@ namespace Game.Chat if (!tele.Value.name.Like(namePart)) continue; - if (maxlookup != 0 && count++ == maxlookup) + if (maxResults != 0 && count++ == maxResults) { limitReached = true; break; @@ -799,7 +793,7 @@ namespace Game.Chat handler.SendSysMessage(CypherStrings.CommandTeleLocation, reply.ToString()); if (limitReached) - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); return true; } @@ -851,9 +845,9 @@ namespace Game.Chat if (locale < Locale.Total) { - if (maxlookup != 0 && counter == maxlookup) + if (maxResults != 0 && counter == maxResults) { - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); return true; } @@ -918,9 +912,9 @@ namespace Game.Chat if (locale < Locale.Total) { - if (maxlookup != 0 && counter == maxlookup) + if (maxResults != 0 && counter == maxResults) { - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); return true; } @@ -1035,9 +1029,9 @@ namespace Game.Chat uint count = 0; do { - if (maxlookup != 0 && count++ == maxlookup) + if (maxResults != 0 && count++ == maxResults) { - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); return true; } uint accountId = result.Read(0); @@ -1120,9 +1114,9 @@ namespace Game.Chat if (locale < Locale.Total) { - if (maxlookup != 0 && count++ == maxlookup) + if (maxResults != 0 && count++ == maxResults) { - handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); + handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults); return true; } diff --git a/Source/Game/Entities/Player/PetitionManager.cs b/Source/Game/Entities/Player/PetitionManager.cs index 0d3537b25..72227f0cf 100644 --- a/Source/Game/Entities/Player/PetitionManager.cs +++ b/Source/Game/Entities/Player/PetitionManager.cs @@ -68,7 +68,7 @@ namespace Game.Entities if (petition == null) continue; - petition.AddSignature(petition.PetitionGuid, result.Read(1), ObjectGuid.Create(HighGuid.Player, result.Read(2)), true); + petition.AddSignature(result.Read(1), ObjectGuid.Create(HighGuid.Player, result.Read(2)), true); ++count; } while (result.NextRow()); @@ -80,8 +80,8 @@ namespace Game.Entities Petition p = new(); p.PetitionGuid = petitionGuid; p.ownerGuid = ownerGuid; - p.petitionName = name; - p.signatures.Clear(); + p.PetitionName = name; + p.Signatures.Clear(); _petitionStorage[petitionGuid] = p; @@ -160,28 +160,28 @@ namespace Game.Entities { public ObjectGuid PetitionGuid; public ObjectGuid ownerGuid; - public string petitionName; - public List<(uint AccountId, ObjectGuid PlayerGuid)> signatures = new(); + public string PetitionName; + public List<(uint AccountId, ObjectGuid PlayerGuid)> Signatures = new(); public bool IsPetitionSignedByAccount(uint accountId) { - foreach (var signature in signatures) + foreach (var signature in Signatures) if (signature.AccountId == accountId) return true; return false; } - public void AddSignature(ObjectGuid petitionGuid, uint accountId, ObjectGuid playerGuid, bool isLoading) + public void AddSignature(uint accountId, ObjectGuid playerGuid, bool isLoading) { - signatures.Add((accountId, playerGuid)); + Signatures.Add((accountId, playerGuid)); if (isLoading) return; PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_PETITION_SIGNATURE); stmt.AddValue(0, ownerGuid.GetCounter()); - stmt.AddValue(1, petitionGuid.GetCounter()); + stmt.AddValue(1, PetitionGuid.GetCounter()); stmt.AddValue(2, playerGuid.GetCounter()); stmt.AddValue(3, accountId); @@ -190,7 +190,7 @@ namespace Game.Entities public void UpdateName(string newName) { - petitionName = newName; + PetitionName = newName; PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_PETITION_NAME); stmt.AddValue(0, newName); @@ -200,11 +200,11 @@ namespace Game.Entities public void RemoveSignatureBySigner(ObjectGuid playerGuid) { - foreach (var itr in signatures) + foreach (var itr in Signatures) { if (itr.PlayerGuid == playerGuid) { - signatures.Remove(itr); + Signatures.Remove(itr); // notify owner Player owner = Global.ObjAccessor.FindConnectedPlayer(ownerGuid); diff --git a/Source/Game/Handlers/PetitionsHandler.cs b/Source/Game/Handlers/PetitionsHandler.cs index 59956f3eb..5b0e4a103 100644 --- a/Source/Game/Handlers/PetitionsHandler.cs +++ b/Source/Game/Handlers/PetitionsHandler.cs @@ -132,7 +132,7 @@ namespace Game signaturesPacket.OwnerAccountID = ObjectGuid.Create(HighGuid.WowAccount, Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(petition.ownerGuid)); signaturesPacket.PetitionID = (int)petition.PetitionGuid.GetCounter(); - foreach (var signature in petition.signatures) + foreach (var signature in petition.Signatures) { ServerPetitionShowSignatures.PetitionSignature signaturePkt = new(); signaturePkt.Signer = signature.PlayerGuid; @@ -170,7 +170,7 @@ namespace Game petitionInfo.Petitioner = petition.ownerGuid; petitionInfo.MinSignatures = reqSignatures; petitionInfo.MaxSignatures = reqSignatures; - petitionInfo.Title = petition.petitionName; + petitionInfo.Title = petition.PetitionName; responsePacket.Allow = true; responsePacket.Info = petitionInfo; @@ -223,7 +223,7 @@ namespace Game } ObjectGuid ownerGuid = petition.ownerGuid; - int signs = petition.signatures.Count; + int signs = petition.Signatures.Count; if (ownerGuid == GetPlayer().GetGUID()) return; @@ -272,7 +272,7 @@ namespace Game } // fill petition store - petition.AddSignature(packet.PetitionGUID, GetAccountId(), _player.GetGUID(), false); + petition.AddSignature(GetAccountId(), _player.GetGUID(), false); Log.outDebug(LogFilter.Network, "PETITION SIGN: {0} by player: {1} ({2} Account: {3})", packet.PetitionGUID.ToString(), GetPlayer().GetName(), GetPlayer().GetGUID().ToString(), GetAccountId()); @@ -360,7 +360,7 @@ namespace Game return; } - string name = petition.petitionName; // we need a copy, Guild::AddMember invalidates petition + string name = petition.PetitionName; // we need a copy, Guild::AddMember invalidates petition // Only the petition owner can turn in the petition if (GetPlayer().GetGUID() != petition.ownerGuid) @@ -383,7 +383,7 @@ namespace Game return; } - var signatures = petition.signatures; // we need a copy, Guild::AddMember invalidates petition + var signatures = petition.Signatures; // we need a copy, Guild::AddMember invalidates petition uint requiredSignatures = WorldConfig.GetUIntValue(WorldCfg.MinPetitionSigns); // Notify player if signatures are missing diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 4b2b814e4..356ed0c09 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -2698,15 +2698,15 @@ namespace Game.Spells // This prevents spells such as Hunter's Mark from triggering pet attack if (m_spellInfo.DmgClass != SpellDmgClass.None) { - Unit unitTarget = m_targets.GetUnitTarget(); - if (unitTarget) + Unit target = m_targets.GetUnitTarget(); + if (target != null) { foreach (Unit controlled in playerCaster.m_Controlled) { Creature cControlled = controlled.ToCreature(); if (cControlled != null) if (cControlled.IsAIEnabled) - cControlled.GetAI().OwnerAttacked(unitTarget); + cControlled.GetAI().OwnerAttacked(target); } } } @@ -2784,8 +2784,7 @@ namespace Game.Spells if (aura_effmask != 0) { - DiminishingGroup diminishGroup = m_spellInfo.GetDiminishingReturnsGroupForSpell(); - if (diminishGroup != 0) + if (m_spellInfo.GetDiminishingReturnsGroupForSpell() != 0) { DiminishingReturnsType type = m_spellInfo.GetDiminishingReturnsGroupType(); if (type == DiminishingReturnsType.All || (type == DiminishingReturnsType.Player && target.IsAffectedByDiminishingReturns()))