From 8d1b5f9ee6888f3035467d483b0e435904a1f22b Mon Sep 17 00:00:00 2001 From: James Tanner Date: Wed, 19 Jul 2023 19:38:32 -0700 Subject: [PATCH] Add converters for backwards compatibility --- proto/common.proto | 1 + ui/core/player.ts | 15 +++++++++++++++ ui/core/raid.ts | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/proto/common.proto b/proto/common.proto index a5dc3d8a33..8abf1d7f06 100644 --- a/proto/common.proto +++ b/proto/common.proto @@ -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]; } diff --git a/ui/core/player.ts b/ui/core/player.ts index b8d89f865a..f949ecbdaf 100644 --- a/ui/core/player.ts +++ b/ui/core/player.ts @@ -23,6 +23,7 @@ import { Stat, UnitStats, WeaponType, + UnitReference_Type, } from './proto/common.js'; import { AuraStats as AuraStatsProto, @@ -1120,6 +1121,20 @@ export class Player { 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; + } + } }); } diff --git a/ui/core/raid.ts b/ui/core/raid.ts index 5d442e0996..ad3b037c41 100644 --- a/ui/core/raid.ts +++ b/ui/core/raid.ts @@ -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;