From 5d8277ede421a4b9308a29b3c5b97826ae99395e Mon Sep 17 00:00:00 2001 From: vigo Date: Sat, 7 Oct 2023 19:59:10 +0200 Subject: [PATCH] [core] don't needlessly reset auraTracker.minExpires fully after Refresh() or Deactivate() anymore [character] advance() assumes that pets don't have pets anymore --- sim/core/aura.go | 25 +++++++------------------ sim/core/character.go | 14 +------------- sim/core/sim.go | 2 +- 3 files changed, 9 insertions(+), 32 deletions(-) diff --git a/sim/core/aura.go b/sim/core/aura.go index c9a6945c3e..a111b37ede 100644 --- a/sim/core/aura.go +++ b/sim/core/aura.go @@ -162,7 +162,9 @@ func (aura *Aura) Refresh(sim *Simulation) { aura.expires = NeverExpires } else { aura.expires = sim.CurrentTime + aura.Duration - aura.Unit.minExpires = 0 + if aura.expires < aura.Unit.minExpires { + aura.Unit.minExpires = aura.expires + } } } @@ -285,7 +287,7 @@ type auraTracker struct { // IDs of Auras that may expire and are currently active, in no particular order. activeAuras []*Aura - // caches the minimum expires time of all active auras; reset to 0 on Activate(), Deactivate(), and Refresh() + // caches the minimum expires time of all active auras; might be stale (too low) after Deactivate(). minExpires time.Duration // Auras that have a non-nil XXX function set and are currently active. @@ -302,20 +304,9 @@ type auraTracker struct { func newAuraTracker() auraTracker { return auraTracker{ - resetEffects: []ResetEffect{}, - ExclusiveEffectManager: &ExclusiveEffectManager{}, - activeAuras: make([]*Aura, 0, 16), - onCastCompleteAuras: make([]*Aura, 0, 16), - onSpellHitDealtAuras: make([]*Aura, 0, 16), - onSpellHitTakenAuras: make([]*Aura, 0, 16), - onPeriodicDamageDealtAuras: make([]*Aura, 0, 16), - onPeriodicDamageTakenAuras: make([]*Aura, 0, 16), - onHealDealtAuras: make([]*Aura, 0, 16), - onHealTakenAuras: make([]*Aura, 0, 16), - onPeriodicHealDealtAuras: make([]*Aura, 0, 16), - onPeriodicHealTakenAuras: make([]*Aura, 0, 16), - auras: make([]*Aura, 0, 16), - aurasByTag: make(map[string][]*Aura), + resetEffects: []ResetEffect{}, + ExclusiveEffectManager: &ExclusiveEffectManager{}, + aurasByTag: make(map[string][]*Aura), } } @@ -664,8 +655,6 @@ func (aura *Aura) Deactivate(sim *Simulation) { aura.Unit.activeAuras[removeActiveIndex].activeIndex = removeActiveIndex } aura.activeIndex = Inactive - - aura.Unit.minExpires = 0 } if aura.onCastCompleteIndex != Inactive { diff --git a/sim/core/character.go b/sim/core/character.go index 2b4d5db7cd..ac4fd28916 100644 --- a/sim/core/character.go +++ b/sim/core/character.go @@ -345,18 +345,6 @@ func (character *Character) AddPet(pet PetAgent) { character.Pets = append(character.Pets, pet.GetPet()) } -func (character *Character) MultiplyMeleeSpeed(sim *Simulation, amount float64) { - character.Unit.MultiplyMeleeSpeed(sim, amount) -} - -func (character *Character) MultiplyRangedSpeed(sim *Simulation, amount float64) { - character.Unit.MultiplyRangedSpeed(sim, amount) -} - -func (character *Character) MultiplyAttackSpeed(sim *Simulation, amount float64) { - character.Unit.MultiplyAttackSpeed(sim, amount) -} - func (character *Character) GetBaseStats() stats.Stats { return character.baseStats } @@ -523,7 +511,7 @@ func (character *Character) advance(sim *Simulation) { for _, pet := range character.Pets { if pet.enabled { - pet.advance(sim) + pet.Unit.advance(sim) } } } diff --git a/sim/core/sim.go b/sim/core/sim.go index ef87ea7c9d..22a0e688e3 100644 --- a/sim/core/sim.go +++ b/sim/core/sim.go @@ -326,7 +326,7 @@ func (sim *Simulation) reset() { sim.Duration += time.Duration(sim.RandomFloat("sim duration")*float64(variation)) - sim.DurationVariation } - sim.pendingActions = make([]*PendingAction, 0, 64) + sim.pendingActions = sim.pendingActions[:0] sim.executePhase = 0 sim.nextExecutePhase()