Skip to content

Commit

Permalink
fix: auto-migration of broken mainStashId
Browse files Browse the repository at this point in the history
  • Loading branch information
Trap committed Aug 2, 2024
1 parent af91ccf commit 32eab33
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/stash-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import type { DatabaseServer } from '@spt/servers/DatabaseServer';
import type { SaveServer } from '@spt/servers/SaveServer';
import type { ConfigGetter, Profile, StashConfig } from './config';
import { EMPTY_STASH, STANDARD_STASH_ID } from './config';
import { checkAccessVia, getMainStashId, retrieveMainStashIdFromItems } from './helpers';
import {
checkAccessVia,
getMainStashId,
isVanillaSptId,
retrieveMainStashIdFromItems,
} from './helpers';
import { deepClone } from './utils';

export const getTemplateIdFromStashId = (stashId: string): string => `template_${stashId}`;
Expand Down Expand Up @@ -70,7 +75,9 @@ export class StashController {
profile.PathToTarkov = {};
}

if (!profile.PathToTarkov.mainStashId) {
const initialMainStashId = profile.PathToTarkov.mainStashId;

if (!initialMainStashId || !isVanillaSptId(initialMainStashId)) {
const mainStashId = retrieveMainStashIdFromItems(pmc.Inventory.items);
profile.PathToTarkov.mainStashId = mainStashId ?? pmc.Inventory.stash;
}
Expand Down

0 comments on commit 32eab33

Please sign in to comment.