Skip to content

Commit

Permalink
fix: change usage of UnitName() to GetUnitName() (#963)
Browse files Browse the repository at this point in the history
This avoids needing to do the name-realm dance to get the correct
name of the unit.
  • Loading branch information
johnnylam88 authored Aug 12, 2021
1 parent 3061b3b commit c4c394d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/engine/guid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
LuaObj,
} from "@wowts/lua";
import { insert } from "@wowts/table";
import { GetTime, UnitGUID, UnitName } from "@wowts/wow-mock";
import { GetTime, GetUnitName, UnitGUID } from "@wowts/wow-mock";
import { AceModule } from "@wowts/tsaddon";
import { OvaleClass } from "../Ovale";
import { Tracer, DebugTools } from "./debug";
Expand Down Expand Up @@ -239,7 +239,7 @@ export class Guids {
}
updateUnit(unitId: string) {
const guid = UnitGUID(unitId);
const name = UnitName(unitId);
const name = GetUnitName(unitId, true);
const previousGUID = this.unitGUID[unitId];
const previousName = this.unitName[unitId];
if (!guid || guid != previousGUID) {
Expand Down Expand Up @@ -327,7 +327,7 @@ export class Guids {
}
getUnitName(unitId: string) {
if (unitId) {
return this.unitName[unitId] || UnitName(unitId);
return this.unitName[unitId] || GetUnitName(unitId, true);
}
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion src/states/BossMod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class OvaleBossModClass {
// let dep = depth || 1;
// isWorldBoss = target != undefined && UnitExists(target) && UnitLevel(target) < 0;
// if (isWorldBoss) {
// this.Debug("%s is worldboss (%s)", target, UnitName(target));
// this.Debug("%s is worldboss (%s)", target, GetUnitName(target, true));
// }
// return isWorldBoss || (dep <= 3 && RecursiveScanTargets(`${target}target`, dep + 1));
// }
Expand Down
4 changes: 2 additions & 2 deletions src/states/Future.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import { insert, remove } from "@wowts/table";
import {
GetSpellInfo,
GetTime,
GetUnitName,
UnitCastingInfo,
UnitChannelInfo,
UnitExists,
UnitGUID,
UnitName,
CombatLogGetCurrentEventInfo,
} from "@wowts/wow-mock";
import { OvaleStateClass, StateModule, States } from "../engine/state";
Expand Down Expand Up @@ -837,7 +837,7 @@ export class OvaleFutureClass
if (name == targetName) {
targetGUID = this.ovaleGuid.getUnitGUID("focus");
} else if (UnitExists("mouseover")) {
name = UnitName("mouseover");
name = GetUnitName("mouseover", true);
if (name == targetName) {
targetGUID = UnitGUID("mouseover");
}
Expand Down
6 changes: 3 additions & 3 deletions src/states/conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
GetItemCount,
GetNumTrackingTypes,
GetTrackingInfo,
GetUnitName,
GetUnitSpeed,
HasFullControl,
IsStealthed,
Expand All @@ -40,7 +41,6 @@ import {
UnitIsPVP,
UnitIsUnit,
UnitLevel,
UnitName,
UnitPower,
UnitPowerMax,
UnitRace,
Expand Down Expand Up @@ -2428,7 +2428,7 @@ export class OvaleConditions {
@return A boolean value.
*/
private name = (atTime: number, target: string) => {
return returnConstant(UnitName(target));
return returnConstant(GetUnitName(target, true));
};

/** Test if the game is on a PTR server
Expand Down Expand Up @@ -2505,7 +2505,7 @@ export class OvaleConditions {
const boolean =
UnitExists(target) &&
!UnitIsDead(target) &&
(name == undefined || name == UnitName(target));
(name == undefined || name == GetUnitName(target, true));
return returnBoolean(boolean);
};

Expand Down

0 comments on commit c4c394d

Please sign in to comment.