From 572cdc14831fdd7fed0c3bab446e2a63a7ec218d Mon Sep 17 00:00:00 2001 From: hondacrx Date: Fri, 28 Oct 2022 21:58:31 -0400 Subject: [PATCH] Misc fixes. --- Source/Game/Entities/GameObject/GameObject.cs | 11 +++++++---- Source/Game/Entities/Pet.cs | 4 ++-- Source/Game/Entities/Player/Player.cs | 2 +- Source/Game/Spells/SpellEffects.cs | 6 +++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Source/Game/Entities/GameObject/GameObject.cs b/Source/Game/Entities/GameObject/GameObject.cs index 3449fa224..3820d5b78 100644 --- a/Source/Game/Entities/GameObject/GameObject.cs +++ b/Source/Game/Entities/GameObject/GameObject.cs @@ -959,7 +959,7 @@ namespace Game.Entities void DespawnForPlayer(Player seer, TimeSpan respawnTime) { - PerPlayerState perPlayerState = GetOrCreatePerPlayerStates()[seer.GetGUID()]; + PerPlayerState perPlayerState = GetOrCreatePerPlayerStates(seer.GetGUID()); perPlayerState.ValidUntil = GameTime.GetSystemTime() + respawnTime; perPlayerState.Despawned = true; seer.UpdateVisibilityOf(this); @@ -3002,7 +3002,7 @@ namespace Game.Entities void SetGoStateFor(GameObjectState state, Player viewer) { - PerPlayerState perPlayerState = GetOrCreatePerPlayerStates()[viewer.GetGUID()]; + PerPlayerState perPlayerState = GetOrCreatePerPlayerStates(viewer.GetGUID()); perPlayerState.ValidUntil = GameTime.GetSystemTime() + TimeSpan.FromSeconds(m_respawnDelayTime); perPlayerState.State = state; @@ -3495,12 +3495,15 @@ namespace Game.Entities return true; } - Dictionary GetOrCreatePerPlayerStates() + PerPlayerState GetOrCreatePerPlayerStates(ObjectGuid guid) { if (m_perPlayerState == null) m_perPlayerState = new(); - return m_perPlayerState; + if (!m_perPlayerState.ContainsKey(guid)) + m_perPlayerState[guid] = new(); + + return m_perPlayerState[guid]; } public override ushort GetAIAnimKitId() { return _animKitId; } diff --git a/Source/Game/Entities/Pet.cs b/Source/Game/Entities/Pet.cs index 5b4988e80..042dc9278 100644 --- a/Source/Game/Entities/Pet.cs +++ b/Source/Game/Entities/Pet.cs @@ -290,7 +290,7 @@ namespace Game.Entities owner.RemovePet(null, PetSaveMode.NotInSlot); var unslottedPetIndex = petStable.UnslottedPets.FindIndex(unslottedPet => unslottedPet.PetNumber == petInfoNumber); - Cypher.Assert(petStable.CurrentPetIndex == 0); + Cypher.Assert(!petStable.CurrentPetIndex.HasValue); Cypher.Assert(unslottedPetIndex != -1); petStable.SetCurrentUnslottedPetIndex((uint)unslottedPetIndex); @@ -302,7 +302,7 @@ namespace Game.Entities Cypher.Assert(activePetIndex != -1); // Check that we either have no pet (unsummoned by player) or it matches temporarily unsummoned pet by server (for example on flying mount) - Cypher.Assert(petStable.CurrentPetIndex == 0 || petStable.CurrentPetIndex == activePetIndex); + Cypher.Assert(!petStable.CurrentPetIndex.HasValue || petStable.CurrentPetIndex == activePetIndex); petStable.SetCurrentActivePetIndex((uint)activePetIndex); } diff --git a/Source/Game/Entities/Player/Player.cs b/Source/Game/Entities/Player/Player.cs index 8f07bd7ad..5ab226741 100644 --- a/Source/Game/Entities/Player/Player.cs +++ b/Source/Game/Entities/Player/Player.cs @@ -4284,7 +4284,7 @@ namespace Game.Entities map.AddToMap(pet.ToCreature()); - Cypher.Assert(petStable.CurrentPetIndex == 0); + Cypher.Assert(!petStable.CurrentPetIndex.HasValue); petStable.SetCurrentUnslottedPetIndex((uint)petStable.UnslottedPets.Count); PetStable.PetInfo petInfo = new(); pet.FillPetInfo(petInfo); diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index 959834e65..0c56a2f0e 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -168,7 +168,7 @@ namespace Game.Spells if (unitCaster != null && apply_direct_bonus) { uint bonus = unitCaster.SpellDamageBonusDone(unitTarget, m_spellInfo, (uint)damage, DamageEffectType.SpellDirect, effectInfo); - damage = (int)(bonus + (bonus * variance)); + damage = (int)(bonus + (uint)(bonus * variance)); damage = (int)unitTarget.SpellDamageBonusTaken(unitCaster, m_spellInfo, (uint)damage, DamageEffectType.SpellDirect); } @@ -697,7 +697,7 @@ namespace Game.Spells if (unitCaster != null) { uint bonus = unitCaster.SpellDamageBonusDone(unitTarget, m_spellInfo, (uint)damage, DamageEffectType.SpellDirect, effectInfo); - damage = (int)(bonus + (bonus * variance)); + damage = (int)(bonus + (uint)(bonus * variance)); damage = (int)unitTarget.SpellDamageBonusTaken(unitCaster, m_spellInfo, (uint)damage, DamageEffectType.SpellDirect); } @@ -886,7 +886,7 @@ namespace Game.Spells if (unitCaster != null) unitCaster.SpellDamageBonusDone(unitTarget, m_spellInfo, (uint)damage, DamageEffectType.SpellDirect, effectInfo); - damage = (int)(bonus + (bonus * variance)); + damage = (int)(bonus + (uint)(bonus * variance)); if (unitCaster != null) damage = (int)unitTarget.SpellDamageBonusTaken(unitCaster, m_spellInfo, (uint)damage, DamageEffectType.SpellDirect);