BUGFIX: Cannot load Bladeburner tasks of Sleeves from pre-v2.6.1 (#1800)

This commit is contained in:
catloversg 2024-11-27 16:23:20 +07:00 committed by GitHub
parent 22b6458c22
commit 88322a23a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -100,8 +100,20 @@ export class SleeveBladeburnerWork extends SleeveWorkClass {
/** Initializes a BladeburnerWork object from a JSON save state. */
static fromJSON(value: IReviverValue): SleeveBladeburnerWork {
objectAssert(value.data);
const actionId = loadActionIdentifier(value.data?.actionId);
if (!actionId) return invalidWork();
let actionId = loadActionIdentifier(value.data?.actionId);
if (!actionId) {
/**
* In pre-v2.6.1 versions, "name" and "type" of actionId are saved directly in "actionName" and "actionType", not
* in the actionId object.
*/
if (!value.data["actionName"]) {
return invalidWork();
}
actionId = loadActionIdentifier({ name: value.data["actionName"], type: value.data["actionType"] });
if (!actionId) {
return invalidWork();
}
}
value.data.actionId = actionId;
return Generic_fromJSON(SleeveBladeburnerWork, value.data, SleeveBladeburnerWork.savedKeys);
}