Skip to content

Commit

Permalink
fix(best-action): always use the correct texture for actions
Browse files Browse the repository at this point in the history
The idiom that was used to set the texture was unnecessary when
the variables were all local, but is plain wrong when using
"result" fields because it would never overwrite a cached result's
texture. Simplify by using a simple if-else statement to set the
texture.

This fixes the rest of issue Sidoine#749.
  • Loading branch information
johnnylam88 committed Dec 29, 2020
1 parent 07e4c75 commit 3dcf9c5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/engine/best-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ export class OvaleBestActionClass {
const [spellName] = GetItemSpell(itemId);
if (node.cachedParams.named.texture) {
result.actionTexture = `Interface\\Icons\\${node.cachedParams.named.texture}`;
} else {
result.actionTexture = GetItemIcon(itemId);
}
result.actionTexture = result.actionTexture || GetItemIcon(itemId);
result.actionInRange = IsItemInRange(itemId, target);
[
result.actionCooldownStart,
Expand Down Expand Up @@ -138,9 +139,9 @@ export class OvaleBestActionClass {
}
if (element.cachedParams.named.texture) {
result.actionTexture = `Interface\\Icons\\${element.cachedParams.named.texture}`;
} else {
result.actionTexture = GetActionTexture(actionSlot);
}
result.actionTexture =
result.actionTexture || GetActionTexture(actionSlot);
result.actionInRange = IsActionInRange(actionSlot, target);
[
result.actionCooldownStart,
Expand Down Expand Up @@ -260,8 +261,9 @@ export class OvaleBestActionClass {
setResultType(result, "action");
if (element.cachedParams.named.texture) {
result.actionTexture = `Interface\\Icons\\${element.cachedParams.named.texture}`;
} else {
result.actionTexture = GetSpellTexture(spellId);
}
result.actionTexture = result.actionTexture || GetSpellTexture(spellId);
result.actionInRange = this.OvaleSpells.IsSpellInRange(spellId, target);
[
result.actionCooldownStart,
Expand Down

0 comments on commit 3dcf9c5

Please sign in to comment.