From 1777a283e457e36f0999036ae1080091a4015bfd Mon Sep 17 00:00:00 2001 From: AnthonyFuller <24512050+AnthonyFuller@users.noreply.github.com> Date: Sat, 16 Sep 2023 13:44:21 +0100 Subject: [PATCH] Expose SMF lastDeploy to plugins --- components/controller.ts | 22 ++++++++-------------- components/types/types.ts | 13 +++++++++++++ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/components/controller.ts b/components/controller.ts index 9847ee8b..44b88964 100644 --- a/components/controller.ts +++ b/components/controller.ts @@ -390,9 +390,9 @@ export class Controller { escalationMappings: Map> = new Map() public progressionService: ProgressionService /** - * A list of Simple Mod Framework mods installed. + * SMF's lastDeploy.json */ - public readonly installedMods: readonly string[] + public readonly lastDeploy: SMFLastDeploy private _pubIdToContractId: Map = new Map() /** Internal elusive target contracts - only accessible during bootstrap. */ private _internalElusives: MissionManifest[] | undefined @@ -418,15 +418,13 @@ export class Controller { } if (modFrameworkDataPath && existsSync(modFrameworkDataPath)) { - this.installedMods = ( - parse( - readFileSync(modFrameworkDataPath!).toString(), - ) as SMFLastDeploy - )?.loadOrder as readonly string[] + this.lastDeploy = parse( + readFileSync(modFrameworkDataPath!).toString(), + ) return } - this.installedMods = [] + this.lastDeploy = null } /** @@ -437,7 +435,7 @@ export class Controller { */ public modIsInstalled(modId: string): boolean { return ( - this.installedMods.includes(modId) || + this.lastDeploy.loadOrder.includes(modId) || getFlag("overrideFrameworkChecks") === true ) } @@ -477,11 +475,7 @@ export class Controller { "boot", ) - const lastServerSideData = ( - parse( - readFileSync(modFrameworkDataPath!).toString(), - ) as SMFLastDeploy - ).lastServerSideStates + const lastServerSideData = this.lastDeploy.lastServerSideStates if (lastServerSideData?.unlockables) { this.configManager.configs["allunlockables"] = diff --git a/components/types/types.ts b/components/types/types.ts index a08ae03a..9bf9fcd0 100644 --- a/components/types/types.ts +++ b/components/types/types.ts @@ -1531,8 +1531,21 @@ export type ContractProgressionData = Record /** SMF's lastDeploy.json */ export interface SMFLastDeploy { + runtimePath: string + retailPath: string + skipIntro: boolean + outputToSeparateDirectory: boolean loadOrder: string[] + modOptions: { + [modId: string]: string[] + } + outputConfigToAppDataOnDeploy: boolean + reportErrors: boolean + developerMode: boolean + knownMods: string[] + platform: string lastServerSideStates?: { + peacockPlugins: string[] unlockables?: Unlockable[] contracts?: { [k: string]: MissionManifest