From 6abce678ca5b29c308afdf68f90458d1e1d00045 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 6 Feb 2024 22:12:17 -0500 Subject: [PATCH] Misc fixes --- .../Framework/Constants/AchievementConst.cs | 2 +- Source/Framework/Database/DatabaseUpdater.cs | 4 +-- Source/Game/AI/SmartScripts/SmartAIManager.cs | 2 +- Source/Game/Accounts/AccountManager.cs | 18 ++++++++----- Source/Game/Conditions/ConditionManager.cs | 26 +++++++++++-------- Source/Game/DataStorage/DB2Manager.cs | 4 ++- .../Game/Entities/AreaTrigger/AreaTrigger.cs | 5 ++-- Source/Game/Entities/Unit/Unit.cs | 14 ++++++++-- Source/Game/Guilds/Guild.cs | 3 +-- Source/Game/Server/WorldConfig.cs | 5 ---- Source/Game/Spells/Auras/Aura.cs | 2 +- Source/Game/Spells/SpellEffects.cs | 2 ++ Source/Game/Spells/SpellManager.cs | 8 +++--- Source/Game/World/WorldManager.cs | 5 ++++ 14 files changed, 62 insertions(+), 38 deletions(-) diff --git a/Source/Framework/Constants/AchievementConst.cs b/Source/Framework/Constants/AchievementConst.cs index 51912e183..fb93035f6 100644 --- a/Source/Framework/Constants/AchievementConst.cs +++ b/Source/Framework/Constants/AchievementConst.cs @@ -751,7 +751,7 @@ namespace Framework.Constants CompleteTrackingQuest = 250, /*NYI*/ GainLevels = 253, // Gain levels - Count + Count = 257 } public enum CriteriaDataType diff --git a/Source/Framework/Database/DatabaseUpdater.cs b/Source/Framework/Database/DatabaseUpdater.cs index ed757cfc5..7e37619bb 100644 --- a/Source/Framework/Database/DatabaseUpdater.cs +++ b/Source/Framework/Database/DatabaseUpdater.cs @@ -37,10 +37,10 @@ namespace Framework.Database fileName = @"/sql/base/characters_database.sql"; break; case "WorldDatabase": - fileName = @"/sql/TDB_full_world_1015.23071_2023_07_14.sql"; + fileName = @"/sql/TDB_full_world_1020.23111_2023_11_15.sql"; break; case "HotfixDatabase": - fileName = @"/sql/TDB_full_hotfixes_1015.23071_2023_07_14.sql"; + fileName = @"/sql/TDB_full_hotfixes_1020.23111_2023_11_15.sql"; break; } diff --git a/Source/Game/AI/SmartScripts/SmartAIManager.cs b/Source/Game/AI/SmartScripts/SmartAIManager.cs index 17c853997..a8e7d9606 100644 --- a/Source/Game/AI/SmartScripts/SmartAIManager.cs +++ b/Source/Game/AI/SmartScripts/SmartAIManager.cs @@ -202,7 +202,7 @@ namespace Game.AI temp.Link = result.Read(3); bool invalidDifficulties = false; - foreach (string token in new StringArray(result.Read(4), ' ')) + foreach (string token in result.Read(4).Split(' ', StringSplitOptions.RemoveEmptyEntries)) { if (!Enum.TryParse(token, out Difficulty difficultyId)) { diff --git a/Source/Game/Accounts/AccountManager.cs b/Source/Game/Accounts/AccountManager.cs index 10091fdc6..d627764fb 100644 --- a/Source/Game/Accounts/AccountManager.cs +++ b/Source/Game/Accounts/AccountManager.cs @@ -294,15 +294,11 @@ namespace Game return false; } - public bool CheckPassword(uint accountId, string password) + public bool CheckPassword(string username, string password) { - string username; + PreparedStatement stmt = LoginDatabase.GetPreparedStatement(LoginStatements.SEL_CHECK_PASSWORD_BY_NAME); + stmt.AddValue(0, username); - if (!GetName(accountId, out username)) - return false; - - PreparedStatement stmt = LoginDatabase.GetPreparedStatement(LoginStatements.SEL_CHECK_PASSWORD); - stmt.AddValue(0, accountId); SQLResult result = DB.Login.Query(stmt); if (!result.IsEmpty()) { @@ -315,6 +311,14 @@ namespace Game return false; } + public bool CheckPassword(uint accountId, string password) + { + if (!GetName(accountId, out string username)) + return false; + + return CheckPassword(username, password); + } + public bool CheckEmail(uint accountId, string newEmail) { string oldEmail; diff --git a/Source/Game/Conditions/ConditionManager.cs b/Source/Game/Conditions/ConditionManager.cs index e06064f3e..efdf58bec 100644 --- a/Source/Game/Conditions/ConditionManager.cs +++ b/Source/Game/Conditions/ConditionManager.cs @@ -20,7 +20,11 @@ namespace Game { public sealed class ConditionManager : Singleton { - ConditionManager() { } + ConditionManager() + { + for (ConditionSourceType i = 0; i < ConditionSourceType.Max; ++i) + ConditionStorage[i] = new(); + } public GridMapTypeMask GetSearcherTypeMaskForConditionList(List conditions) { @@ -42,7 +46,7 @@ namespace Game if (i.ReferenceId != 0) // handle reference { var refe = ConditionStorage[ConditionSourceType.ReferenceCondition].LookupByKey(new ConditionId(i.ReferenceId, 0, 0)); - Cypher.Assert(refe.Empty(), "ConditionMgr.GetSearcherTypeMaskForConditionList - incorrect reference"); + Cypher.Assert(refe != null, "ConditionMgr.GetSearcherTypeMaskForConditionList - incorrect reference"); elseGroupSearcherTypeMasks[i.ElseGroup] &= GetSearcherTypeMaskForConditionList(refe); } else // handle normal condition @@ -78,7 +82,7 @@ namespace Game if (condition.ReferenceId != 0)//handle reference { var refe = ConditionStorage[ConditionSourceType.ReferenceCondition].LookupByKey(new ConditionId(condition.ReferenceId, 0, 0)); - if (!refe.Empty()) + if (refe != null) { if (!IsObjectMeetToConditionList(sourceInfo, refe)) elseGroupStore[condition.ElseGroup] = false; @@ -118,7 +122,7 @@ namespace Game public bool IsObjectMeetToConditions(ConditionSourceInfo sourceInfo, List conditions) { - if (conditions.Empty()) + if (conditions == null) return true; Log.outDebug(LogFilter.Condition, "ConditionMgr.IsObjectMeetToConditions"); @@ -189,7 +193,7 @@ namespace Game if (sourceType > ConditionSourceType.None && sourceType < ConditionSourceType.Max) { var conditions = ConditionStorage[sourceType].LookupByKey(new ConditionId(0, (int)entry, 0)); - if (!conditions.Empty()) + if (conditions != null) { Log.outDebug(LogFilter.Condition, "GetConditionsForNotGroupedEntry: found conditions for type {0} and entry {1}", sourceType, entry); return IsObjectMeetToConditions(sourceInfo, conditions); @@ -222,7 +226,7 @@ namespace Game public bool IsObjectMeetingSpellClickConditions(uint creatureId, uint spellId, WorldObject clicker, WorldObject target) { var conditions = ConditionStorage[ConditionSourceType.SpellClickEvent].LookupByKey(new ConditionId(creatureId, (int)spellId, 0)); - if (!conditions.Empty()) + if (conditions != null) { Log.outDebug(LogFilter.Condition, "GetConditionsForSpellClickEvent: found conditions for SpellClickEvent entry {0} spell {1}", creatureId, spellId); ConditionSourceInfo sourceInfo = new(clicker, target); @@ -259,7 +263,7 @@ namespace Game public bool IsObjectMeetingSmartEventConditions(long entryOrGuid, uint eventId, SmartScriptType sourceType, Unit unit, WorldObject baseObject) { var conditions = ConditionStorage[ConditionSourceType.SmartEvent].LookupByKey(new ConditionId(eventId + 1, (int)entryOrGuid, (uint)sourceType)); - if (!conditions.Empty()) + if (conditions != null) { Log.outDebug(LogFilter.Condition, "GetConditionsForSmartEvent: found conditions for Smart Event entry or guid {0} eventId {1}", entryOrGuid, eventId); ConditionSourceInfo sourceInfo = new(unit, baseObject); @@ -272,7 +276,7 @@ namespace Game public bool IsObjectMeetingVendorItemConditions(uint creatureId, uint itemId, Player player, Creature vendor) { var conditions = ConditionStorage[ConditionSourceType.NpcVendor].LookupByKey(new ConditionId(creatureId, (int)itemId, 0)); - if (!conditions.Empty()) + if (conditions != null) { Log.outDebug(LogFilter.Condition, "GetConditionsForNpcVendor: found conditions for creature entry {0} item {1}", creatureId, itemId); ConditionSourceInfo sourceInfo = new(player, vendor); @@ -295,7 +299,7 @@ namespace Game public bool IsObjectMeetingTrainerSpellConditions(uint trainerId, uint spellId, Player player) { var conditions = ConditionStorage[ConditionSourceType.NpcVendor].LookupByKey(new ConditionId(trainerId, (int)spellId, 0)); - if (!conditions.Empty()) + if (conditions != null) { Log.outDebug(LogFilter.Condition, $"GetConditionsForTrainerSpell: found conditions for trainer id {trainerId} spell {spellId}"); return IsObjectMeetToConditions(player, conditions); @@ -307,7 +311,7 @@ namespace Game public bool IsObjectMeetingVisibilityByObjectIdConditions(uint objectType, uint entry, WorldObject seer) { var conditions = ConditionStorage[ConditionSourceType.ObjectIdVisibility].LookupByKey(new ConditionId(objectType, (int)entry, 0)); - if (!conditions.Empty()) + if (conditions != null) { Log.outDebug(LogFilter.Condition, $"IsObjectMeetingVisibilityByObjectIdConditions: found conditions for objectType {objectType} entry {entry}"); return IsObjectMeetToConditions(seer, conditions); @@ -330,7 +334,7 @@ namespace Game } SQLResult result = DB.World.Query("SELECT SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, ConditionTarget, " + - " ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorType, ErrorTextId, ScriptName FROM conditions"); + "ConditionValue1, ConditionValue2, ConditionValue3, ConditionStringValue1, NegativeCondition, ErrorType, ErrorTextId, ScriptName FROM conditions"); if (result.IsEmpty()) { diff --git a/Source/Game/DataStorage/DB2Manager.cs b/Source/Game/DataStorage/DB2Manager.cs index 2c7644b97..74b3cc588 100644 --- a/Source/Game/DataStorage/DB2Manager.cs +++ b/Source/Game/DataStorage/DB2Manager.cs @@ -694,11 +694,13 @@ namespace Game.DataStorage hotfixRecord.HotfixStatus = status; hotfixRecord.AvailableLocalesMask = availableDb2Locales.ToBlockRange()[0];//Ulgy i know + if (!_hotfixData.ContainsKey(id)) + _hotfixData[id] = new(); + HotfixPush push = _hotfixData[id]; push.Records.Add(hotfixRecord); push.AvailableLocalesMask |= hotfixRecord.AvailableLocalesMask; - _hotfixData.Add(id, push); deletedRecords[(tableHash, recordId)] = status == HotfixRecord.Status.RecordRemoved; ++count; diff --git a/Source/Game/Entities/AreaTrigger/AreaTrigger.cs b/Source/Game/Entities/AreaTrigger/AreaTrigger.cs index 43b8e14d7..3e6eab9b7 100644 --- a/Source/Game/Entities/AreaTrigger/AreaTrigger.cs +++ b/Source/Game/Entities/AreaTrigger/AreaTrigger.cs @@ -31,6 +31,7 @@ namespace Game.Entities m_areaTriggerData = new AreaTriggerFieldData(); _spline = new(); + _stationaryPosition = new(); } public override void AddToWorld() @@ -261,9 +262,9 @@ namespace Game.Entities SpellInfo spellInfo = null; SpellCastVisual spellVisual = default; - if (spawnData.SpellForVisuals != 0) + if (spawnData.SpellForVisuals.HasValue) { - spellInfo = Global.SpellMgr.GetSpellInfo((uint)spawnData.SpellForVisuals, Difficulty.None); + spellInfo = Global.SpellMgr.GetSpellInfo(spawnData.SpellForVisuals.Value, Difficulty.None); if (spellInfo != null) spellVisual.SpellXSpellVisualID = spellInfo.GetSpellXSpellVisualId(); } diff --git a/Source/Game/Entities/Unit/Unit.cs b/Source/Game/Entities/Unit/Unit.cs index fdbdfa3b1..76ba3823b 100644 --- a/Source/Game/Entities/Unit/Unit.cs +++ b/Source/Game/Entities/Unit/Unit.cs @@ -1909,7 +1909,7 @@ namespace Game.Entities public virtual float GetNativeObjectScale() { return 1.0f; } public float GetDisplayScale() { return m_unitData.DisplayScale; } - + public uint GetDisplayId() { return m_unitData.DisplayID; } public virtual void SetDisplayId(uint displayId, bool setNative = false) @@ -2088,7 +2088,17 @@ namespace Game.Entities return IsCharmed() ? GetCharmerGUID() : GetOwnerGUID(); } - Player GetControllingPlayer() + public Unit GetDemonCreator() + { + return Global.ObjAccessor.GetUnit(this, GetDemonCreatorGUID()); + } + + public Player GetDemonCreatorPlayer() + { + return Global.ObjAccessor.GetPlayer(this, GetDemonCreatorGUID()); + } + + public Player GetControllingPlayer() { ObjectGuid guid = GetCharmerOrOwnerGUID(); if (!guid.IsEmpty()) diff --git a/Source/Game/Guilds/Guild.cs b/Source/Game/Guilds/Guild.cs index 2b2234f1b..ed125f074 100644 --- a/Source/Game/Guilds/Guild.cs +++ b/Source/Game/Guilds/Guild.cs @@ -316,8 +316,8 @@ namespace Game.Guilds } } + GetAchievementMgr().SendAllTrackedCriterias(player, criteriaIds); member.SetTrackedCriteriaIds(criteriaIds); - GetAchievementMgr().SendAllTrackedCriterias(player, member.GetTrackedCriteriaIds()); } } @@ -2794,7 +2794,6 @@ namespace Game.Guilds public uint GetTotalReputation() { return m_totalReputation; } public uint GetWeekReputation() { return m_weekReputation; } - public List GetTrackedCriteriaIds() { return m_trackedCriteriaIds; } public void SetTrackedCriteriaIds(List criteriaIds) { m_trackedCriteriaIds = criteriaIds; } public bool IsTrackingCriteriaId(uint criteriaId) { return m_trackedCriteriaIds.Contains(criteriaId); } public bool IsOnline() { return m_flags.HasFlag(GuildMemberFlags.Online); } diff --git a/Source/Game/Server/WorldConfig.cs b/Source/Game/Server/WorldConfig.cs index 8f353cad8..091d62b9b 100644 --- a/Source/Game/Server/WorldConfig.cs +++ b/Source/Game/Server/WorldConfig.cs @@ -713,11 +713,6 @@ namespace Game Values[WorldCfg.ThreatRadius] = GetDefaultValue("ThreatRadius", 60.0f); Values[WorldCfg.DeclinedNamesUsed] = GetDefaultValue("DeclinedNames", false); - // always use declined names in the russian client - var category = CliDB.CfgCategoriesStorage.LookupByKey((uint)Values[WorldCfg.RealmZone]); - if (category != null && category.GetCreateCharsetMask().HasFlag(CfgCategoriesCharsets.Russian)) - Values[WorldCfg.DeclinedNamesUsed] = true; - Values[WorldCfg.ListenRangeSay] = GetDefaultValue("ListenRange.Say", 25.0f); Values[WorldCfg.ListenRangeTextemote] = GetDefaultValue("ListenRange.TextEmote", 25.0f); Values[WorldCfg.ListenRangeYell] = GetDefaultValue("ListenRange.Yell", 300.0f); diff --git a/Source/Game/Spells/Auras/Aura.cs b/Source/Game/Spells/Auras/Aura.cs index 8b1c6274b..a9a30b2f5 100644 --- a/Source/Game/Spells/Auras/Aura.cs +++ b/Source/Game/Spells/Auras/Aura.cs @@ -2836,7 +2836,7 @@ namespace Game.Spells foreach (WorldObject unit in units) { - if (!targets.ContainsKey(unit)) + if (!targets.ContainsKey(unit.ToUnit())) targets[unit.ToUnit()] = 0; targets[unit.ToUnit()] |= 1u << (int)spellEffectInfo.EffectIndex; diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index 08cde6bc6..2eb70b219 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -1601,6 +1601,8 @@ namespace Game.Spells summon.SetTempSummonType(summonType); if (properties.Control == SummonCategory.Ally) summon.SetOwnerGUID(caster.GetGUID()); + else if (properties.Control == SummonCategory.Wild && caster.IsPlayer()) // there might be more conditions involved + summon.SetDemonCreatorGUID(caster.GetGUID()); ExecuteLogEffectSummonObject(effectInfo.Effect, summon); } diff --git a/Source/Game/Spells/SpellManager.cs b/Source/Game/Spells/SpellManager.cs index ea56b63c9..fcb1ff613 100644 --- a/Source/Game/Spells/SpellManager.cs +++ b/Source/Game/Spells/SpellManager.cs @@ -4522,7 +4522,7 @@ namespace Game.Entities ushort dispelType = result.Read(2); ulong mechanics = result.Read(3); - CreatureImmunities immunities = mCreatureImmunities[id]; + CreatureImmunities immunities = new(); immunities.School = new BitSet(new uint[] { school }); immunities.DispelType = new BitSet(new uint[] { dispelType }); immunities.Mechanic = new BitSet(mechanics); @@ -4536,7 +4536,7 @@ namespace Game.Entities if (immunities.Mechanic.ToUInt() != mechanics) Log.outError(LogFilter.Sql, $"Invalid value in `MechanicsMask` {mechanics} for creature immunities {id}, truncated"); - foreach (string token in new StringArray(result.Read(4), ',')) + foreach (string token in result.Read(4).Split(',', StringSplitOptions.RemoveEmptyEntries)) { if (uint.TryParse(token, out uint effect) && effect != 0 && effect < (int)SpellEffectName.TotalSpellEffects) immunities.Effect.Add((SpellEffectName)effect); @@ -4544,13 +4544,15 @@ namespace Game.Entities Log.outError(LogFilter.Sql, $"Invalid effect type in `Effects` {token} for creature immunities {id}, skipped"); } - foreach (string token in new StringArray(result.Read(5), ',')) + foreach (string token in result.Read(5).Split(',', StringSplitOptions.RemoveEmptyEntries)) { if (uint.TryParse(token, out uint aura) && aura != 0 && aura < (int)AuraType.Total) immunities.Aura.Add((AuraType)aura); else Log.outError(LogFilter.Sql, $"Invalid aura type in `Auras` {token} for creature immunities {id}, skipped"); } + + mCreatureImmunities[id] = immunities; } while (result.NextRow()); } diff --git a/Source/Game/World/WorldManager.cs b/Source/Game/World/WorldManager.cs index 8a94d1fe9..c5d502844 100644 --- a/Source/Game/World/WorldManager.cs +++ b/Source/Game/World/WorldManager.cs @@ -451,6 +451,11 @@ namespace Game //Load weighted graph on taxi nodes path TaxiPathGraph.Initialize(); + // always use declined names in the russian client + var category = CliDB.CfgCategoriesStorage.LookupByKey(WorldConfig.GetUIntValue(WorldCfg.RealmZone)); + if (category != null && category.GetCreateCharsetMask().HasFlag(CfgCategoriesCharsets.Russian)) + WorldConfig.SetValue(WorldCfg.DeclinedNamesUsed, true); + MultiMap mapData = new(); foreach (MapRecord mapEntry in CliDB.MapStorage.Values) {