From 1a9dc1ea2bfda7705fd8d11d5e52285ebfa604e0 Mon Sep 17 00:00:00 2001 From: Dev Date: Sat, 3 Feb 2024 19:42:49 +0000 Subject: [PATCH] Cleanup of `setHideoutAreasAndCraftsTo40Secs` to more central location --- project/src/callbacks/ProfileCallbacks.ts | 7 +--- project/src/controllers/GameController.ts | 44 +------------------- project/src/controllers/ProfileController.ts | 3 ++ project/src/services/ProfileFixerService.ts | 40 ++++++++++++++++++ 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/project/src/callbacks/ProfileCallbacks.ts b/project/src/callbacks/ProfileCallbacks.ts index 48c909bf..c345d044 100644 --- a/project/src/callbacks/ProfileCallbacks.ts +++ b/project/src/callbacks/ProfileCallbacks.ts @@ -1,7 +1,7 @@ import { inject, injectable } from "tsyringe"; -import { GameController } from "@spt-aki/controllers/GameController"; import { ProfileController } from "@spt-aki/controllers/ProfileController"; +import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { IEmptyRequestData } from "@spt-aki/models/eft/common/IEmptyRequestData"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData"; @@ -20,7 +20,6 @@ import { ISearchFriendResponse } from "@spt-aki/models/eft/profile/ISearchFriend import { IValidateNicknameRequestData } from "@spt-aki/models/eft/profile/IValidateNicknameRequestData"; import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; -import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; /** Handle profile related client events */ @injectable() @@ -30,8 +29,7 @@ export class ProfileCallbacks @inject("HttpResponseUtil") protected httpResponse: HttpResponseUtil, @inject("TimeUtil") protected timeUtil: TimeUtil, @inject("ProfileController") protected profileController: ProfileController, - @inject("GameController") protected gameController: GameController, - @inject("ProfileHelper") protected profileHelper: ProfileHelper + @inject("ProfileHelper") protected profileHelper: ProfileHelper, ) {} @@ -45,7 +43,6 @@ export class ProfileCallbacks ): IGetBodyResponseData { const id = this.profileController.createProfile(info, sessionID); - this.gameController.setHideoutAreasAndCraftsTo40Secs(this.profileHelper.getFullProfile(id)); return this.httpResponse.getBody({ uid: id }); } diff --git a/project/src/controllers/GameController.ts b/project/src/controllers/GameController.ts index 1099abba..804dbda6 100644 --- a/project/src/controllers/GameController.ts +++ b/project/src/controllers/GameController.ts @@ -18,7 +18,6 @@ import { IGetRaidTimeRequest } from "@spt-aki/models/eft/game/IGetRaidTimeReques import { IGetRaidTimeResponse } from "@spt-aki/models/eft/game/IGetRaidTimeResponse"; import { IServerDetails } from "@spt-aki/models/eft/game/IServerDetails"; import { IAkiProfile } from "@spt-aki/models/eft/profile/IAkiProfile"; -import { AccountTypes } from "@spt-aki/models/enums/AccountTypes"; import { BonusType } from "@spt-aki/models/enums/BonusType"; import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; import { SkillTypes } from "@spt-aki/models/enums/SkillTypes"; @@ -158,8 +157,8 @@ export class GameController { this.updateProfileHealthValues(pmcProfile); } - - this.setHideoutAreasAndCraftsTo40Secs(fullProfile); + + this.profileFixerService.setHideoutAreasAndCraftsTo40Secs(fullProfile); if (this.locationConfig.fixEmptyBotWavesSettings.enabled) { @@ -353,45 +352,6 @@ export class GameController } } - public setHideoutAreasAndCraftsTo40Secs(fullProfile: IAkiProfile): void - { - if (!fullProfile.info.edition.toLowerCase().startsWith(AccountTypes.SPT_DEVELOPER)) - { - return; - } - - for (const hideoutProd of this.databaseServer.getTables().hideout.production) - { - if (hideoutProd.productionTime > 40) - { - hideoutProd.productionTime = 40; - } - } - this.logger.warning("DEVELOPER: SETTING ALL HIDEOUT PRODUCTIONS TO 40 SECONDS"); - - for (const hideoutArea of this.databaseServer.getTables().hideout.areas) - { - for (const stageKey in hideoutArea.stages) - { - const stage = hideoutArea.stages[stageKey]; - if (stage.constructionTime > 40) - { - stage.constructionTime = 40; - } - } - } - this.logger.warning("DEVELOPER: SETTING ALL HIDEOUT AREAS TO 40 SECOND UPGRADES"); - - for (const scavCaseCraft of this.databaseServer.getTables().hideout.scavcase) - { - if (scavCaseCraft.ProductionTime > 40) - { - scavCaseCraft.ProductionTime = 40; - } - } - this.logger.warning("DEVELOPER: SETTING ALL SCAV CASES TO 40 SECONDS"); - } - /** Apply custom limits on bot types as defined in configs/location.json/botTypeLimits */ protected adjustMapBotLimits(): void { diff --git a/project/src/controllers/ProfileController.ts b/project/src/controllers/ProfileController.ts index 717c6a31..e3c1ce3e 100644 --- a/project/src/controllers/ProfileController.ts +++ b/project/src/controllers/ProfileController.ts @@ -232,6 +232,9 @@ export class ProfileController this.seasonalEventService.enableSeasonalEvents(sessionID); } + const fullProfile = this.profileHelper.getFullProfile(account.id); + this.profileFixerService.setHideoutAreasAndCraftsTo40Secs(fullProfile); + return pmcData._id; } diff --git a/project/src/services/ProfileFixerService.ts b/project/src/services/ProfileFixerService.ts index f4e95e06..1bfb605b 100644 --- a/project/src/services/ProfileFixerService.ts +++ b/project/src/services/ProfileFixerService.ts @@ -11,6 +11,7 @@ import { IHideoutImprovement } from "@spt-aki/models/eft/common/tables/IBotBase" import { IPmcDataRepeatableQuest, IRepeatableQuest } from "@spt-aki/models/eft/common/tables/IRepeatableQuests"; import { StageBonus } from "@spt-aki/models/eft/hideout/IHideoutArea"; import { IAkiProfile } from "@spt-aki/models/eft/profile/IAkiProfile"; +import { AccountTypes } from "@spt-aki/models/enums/AccountTypes"; import { BonusType } from "@spt-aki/models/enums/BonusType"; import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; import { HideoutAreas } from "@spt-aki/models/enums/HideoutAreas"; @@ -1386,4 +1387,43 @@ export class ProfileFixerService } } } + + public setHideoutAreasAndCraftsTo40Secs(fullProfile: IAkiProfile): void + { + if (!fullProfile.info.edition.toLowerCase().startsWith(AccountTypes.SPT_DEVELOPER)) + { + return; + } + + for (const hideoutProd of this.databaseServer.getTables().hideout.production) + { + if (hideoutProd.productionTime > 40) + { + hideoutProd.productionTime = 40; + } + } + this.logger.warning("DEVELOPER: SETTING ALL HIDEOUT PRODUCTIONS TO 40 SECONDS"); + + for (const hideoutArea of this.databaseServer.getTables().hideout.areas) + { + for (const stageKey in hideoutArea.stages) + { + const stage = hideoutArea.stages[stageKey]; + if (stage.constructionTime > 40) + { + stage.constructionTime = 40; + } + } + } + this.logger.warning("DEVELOPER: SETTING ALL HIDEOUT AREAS TO 40 SECOND UPGRADES"); + + for (const scavCaseCraft of this.databaseServer.getTables().hideout.scavcase) + { + if (scavCaseCraft.ProductionTime > 40) + { + scavCaseCraft.ProductionTime = 40; + } + } + this.logger.warning("DEVELOPER: SETTING ALL SCAV CASES TO 40 SECONDS"); + } }