Skip to content

Commit

Permalink
Add converters for backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyt857 committed Jul 20, 2023
1 parent 8869e24 commit 8d1b5f9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions proto/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ message UnitReference {
UnitReference owner = 4;

// Raid index of the player to target. A value of -1 indicates no target.
// TODO: Delete this after 2 months (on or after 9/19/2023)
int32 target_index = 1 [deprecated = true];
}

Expand Down
15 changes: 15 additions & 0 deletions ui/core/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
Stat,
UnitStats,
WeaponType,
UnitReference_Type,
} from './proto/common.js';
import {
AuraStats as AuraStatsProto,
Expand Down Expand Up @@ -1120,6 +1121,20 @@ export class Player<SpecType extends Spec> {

this.aplRotation = proto.rotation || APLRotation.create();
this.rotationChangeEmitter.emit(eventID);

const options = this.getSpecOptions();
for (let key in options) {
if ((options[key] as any)?.['targetIndex']) {
const targetIndex = (options[key] as any)['targetIndex'] as number;
if (targetIndex == -1) {
(options[key] as any) = UnitReference.create();
} else {
(options[key] as any) = UnitReference.create({type: UnitReference_Type.Player, index: targetIndex});
}
this.setSpecOptions(eventID, options);
break;
}
}
});
}

Expand Down
4 changes: 4 additions & 0 deletions ui/core/raid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ export class Raid {

fromProto(eventID: EventID, proto: RaidProto) {
TypedEvent.freezeAllAndDo(() => {
if (proto.tanks) {
proto.tanks = proto.tanks.map(tank => (tank.type == 0 && tank.targetIndex != -1) ? UnitReference.create({type: UnitReference_Type.Player, index: tank.targetIndex}) : tank);
}

if (proto.buffs) {
if (proto.buffs.demonicPact > 0 && proto.buffs.demonicPactSp == 0) {
proto.buffs.demonicPactSp = proto.buffs.demonicPact;
Expand Down

0 comments on commit 8d1b5f9

Please sign in to comment.