Skip to content

Commit

Permalink
fix: game client hanging when equipping different equipment set (#945)
Browse files Browse the repository at this point in the history
* fix: only update weapon damage stats if a weapon slot changed

PLAYER_EQUIPMENT_CHANGED is a bursty event, so the event handlers
for it must handle events quickly.  Ignore PLAYER_EQUIPMENT_CHANGED
if the slot changed isn't a weapon slot since we only listen for
this event to update the weapon damage stats.

This fixes an issue with the game client hanging when changing
specializations and an new equipment set is auto-equipped.

* fix: use correct type for handleUnitStats

Event handlers always take the event string as the first argument.
This fixes an issue where the unit stats were not updated until the
next time the player changed talents or zoned into the world.
  • Loading branch information
johnnylam88 authored Jul 28, 2021
1 parent 9009bf8 commit ed1aecb
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/states/PaperDoll.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Tracer, DebugTools } from "../engine/debug";
import { Profiler, OvaleProfilerClass } from "../engine/profiler";
import { OvaleClass } from "../Ovale";
import { OvaleEquipmentClass } from "./Equipment";
import { OvaleEquipmentClass, SlotName } from "./Equipment";
import { States, StateModule } from "../engine/state";
import aceEvent, { AceEvent } from "@wowts/ace_event-3.0";
import { tonumber, LuaObj, LuaArray, ipairs, unpack } from "@wowts/lua";
Expand Down Expand Up @@ -291,7 +291,7 @@ export class OvalePaperDollClass
// this.RegisterEvent("PLAYER_DAMAGE_DONE_MODS"); // SpellBonusHealing (not really needed; spell power covered by SPELL_POWER_CHANGED)
this.module.RegisterMessage(
"Ovale_EquipmentChanged",
this.handleUpdateDamage
this.handleOvaleEquipmentChanged
);
// this.RegisterMessage("Ovale_StanceChanged", "UpdateDamage"); // Shouldn't be needed anymore, UNIT_DAMAGE covers it
this.module.RegisterMessage(
Expand Down Expand Up @@ -319,7 +319,18 @@ export class OvalePaperDollClass
this.module.UnregisterMessage("Ovale_StanceChanged");
this.module.UnregisterMessage("Ovale_TalentsChanged");
};
private handleUnitStats = (unitId: string) => {

private handleOvaleEquipmentChanged = (event: string, slot: SlotName) => {
if (
slot == "mainhandslot" ||
slot == "secondaryhandslot" ||
slot == "offhandslot"
) {
this.handleUpdateDamage();
}
};

private handleUnitStats = (event: string, unitId: string) => {
if (unitId == "player") {
this.profiler.startProfiling("OvalePaperDoll_UpdateStats");
this.current.strength = UnitStat(unitId, 1);
Expand Down Expand Up @@ -438,7 +449,7 @@ export class OvalePaperDollClass
}
private handleUpdateStats = (event: string) => {
this.updateSpecialization();
this.handleUnitStats("player");
this.handleUnitStats(event, "player");
this.handleCombatRatingUpdate();
this.handleMasteryUpdate();
this.handleUnitAttackPower(event, "player");
Expand Down

0 comments on commit ed1aecb

Please sign in to comment.