Added mongoid item validation to 39x profile migration
This commit is contained in:
parent
47a7ccdfdd
commit
98d4bcc8ae
@ -2,6 +2,7 @@ import { ApplicationContext } from "@spt/context/ApplicationContext";
|
|||||||
import { ContextVariableType } from "@spt/context/ContextVariableType";
|
import { ContextVariableType } from "@spt/context/ContextVariableType";
|
||||||
import { HideoutHelper } from "@spt/helpers/HideoutHelper";
|
import { HideoutHelper } from "@spt/helpers/HideoutHelper";
|
||||||
import { HttpServerHelper } from "@spt/helpers/HttpServerHelper";
|
import { HttpServerHelper } from "@spt/helpers/HttpServerHelper";
|
||||||
|
import { InventoryHelper } from "@spt/helpers/InventoryHelper";
|
||||||
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||||
import { PreSptModLoader } from "@spt/loaders/PreSptModLoader";
|
import { PreSptModLoader } from "@spt/loaders/PreSptModLoader";
|
||||||
import { IEmptyRequestData } from "@spt/models/eft/common/IEmptyRequestData";
|
import { IEmptyRequestData } from "@spt/models/eft/common/IEmptyRequestData";
|
||||||
@ -68,6 +69,7 @@ export class GameController {
|
|||||||
@inject("HashUtil") protected hashUtil: HashUtil,
|
@inject("HashUtil") protected hashUtil: HashUtil,
|
||||||
@inject("PreSptModLoader") protected preSptModLoader: PreSptModLoader,
|
@inject("PreSptModLoader") protected preSptModLoader: PreSptModLoader,
|
||||||
@inject("HttpServerHelper") protected httpServerHelper: HttpServerHelper,
|
@inject("HttpServerHelper") protected httpServerHelper: HttpServerHelper,
|
||||||
|
@inject("InventoryHelper") protected inventoryHelper: InventoryHelper,
|
||||||
@inject("RandomUtil") protected randomUtil: RandomUtil,
|
@inject("RandomUtil") protected randomUtil: RandomUtil,
|
||||||
@inject("HideoutHelper") protected hideoutHelper: HideoutHelper,
|
@inject("HideoutHelper") protected hideoutHelper: HideoutHelper,
|
||||||
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
|
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
|
||||||
@ -165,6 +167,9 @@ export class GameController {
|
|||||||
|
|
||||||
//3.9 migrations
|
//3.9 migrations
|
||||||
if (fullProfile.spt.version.includes("3.9.") && !fullProfile.spt.migrations["39x"]) {
|
if (fullProfile.spt.version.includes("3.9.") && !fullProfile.spt.migrations["39x"]) {
|
||||||
|
// Check every item has a valid mongoid
|
||||||
|
this.inventoryHelper.validateInventoryUsesMonogoIds(fullProfile.characters.pmc.Inventory.items);
|
||||||
|
|
||||||
this.migrate39xProfile(fullProfile);
|
this.migrate39xProfile(fullProfile);
|
||||||
|
|
||||||
// Flag as migrated
|
// Flag as migrated
|
||||||
|
@ -1138,6 +1138,16 @@ export class InventoryHelper {
|
|||||||
// Start recursive check
|
// Start recursive check
|
||||||
return isParentInStash(itemToCheck._id);
|
return isParentInStash(itemToCheck._id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public validateInventoryUsesMonogoIds(itemsToValidate: Item[]) {
|
||||||
|
for (const item of itemsToValidate) {
|
||||||
|
if (!/^[a-fA-F0-9]{24}$/.test(item._id)) {
|
||||||
|
throw new Error(
|
||||||
|
`This profile is not compatible with 3.10.0, It contains an item with the ID: ${item._id} that is not compatible. Loading of SPT has been halted, use another profile or create a new one.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace InventoryHelper {
|
namespace InventoryHelper {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user