mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 06:50:43 -05:00
Replace usages of objectId.generate()
with hashUtil.generate()
This commit is contained in:
parent
6a2afe2fa7
commit
2e1e13e563
@ -12,7 +12,6 @@ import { ELocationName } from "@spt/models/enums/ELocationName";
|
||||
import { HideoutAreas } from "@spt/models/enums/HideoutAreas";
|
||||
import { QuestStatus } from "@spt/models/enums/QuestStatus";
|
||||
import { SkillTypes } from "@spt/models/enums/SkillTypes";
|
||||
import { Traders } from "@spt/models/enums/Traders";
|
||||
import { IQuestConfig, IRepeatableQuestConfig } from "@spt/models/spt/config/IQuestConfig";
|
||||
import { IGetRepeatableByIdResult } from "@spt/models/spt/quests/IGetRepeatableByIdResult";
|
||||
import { IQuestTypePool } from "@spt/models/spt/repeatable/IQuestTypePool";
|
||||
@ -23,8 +22,8 @@ import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { PaymentService } from "@spt/services/PaymentService";
|
||||
import { ProfileFixerService } from "@spt/services/ProfileFixerService";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
|
||||
import { ObjectId } from "@spt/utils/ObjectId";
|
||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||
import { TimeUtil } from "@spt/utils/TimeUtil";
|
||||
import type { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
@ -36,6 +35,7 @@ export class RepeatableQuestController {
|
||||
|
||||
constructor(
|
||||
@inject("PrimaryLogger") protected logger: ILogger,
|
||||
@inject("HashUtil") protected hashUtil: HashUtil,
|
||||
@inject("DatabaseService") protected databaseService: DatabaseService,
|
||||
@inject("TimeUtil") protected timeUtil: TimeUtil,
|
||||
@inject("RandomUtil") protected randomUtil: RandomUtil,
|
||||
@ -45,7 +45,6 @@ export class RepeatableQuestController {
|
||||
@inject("LocalisationService") protected localisationService: LocalisationService,
|
||||
@inject("EventOutputHolder") protected eventOutputHolder: EventOutputHolder,
|
||||
@inject("PaymentService") protected paymentService: PaymentService,
|
||||
@inject("ObjectId") protected objectId: ObjectId,
|
||||
@inject("RepeatableQuestGenerator") protected repeatableQuestGenerator: RepeatableQuestGenerator,
|
||||
@inject("RepeatableQuestHelper") protected repeatableQuestHelper: RepeatableQuestHelper,
|
||||
@inject("QuestHelper") protected questHelper: QuestHelper,
|
||||
@ -337,11 +336,11 @@ export class RepeatableQuestController {
|
||||
randomQuests = randomQuests.concat(this.randomUtil.drawRandomFromList(dailiesPool, numberOfQuests, false));
|
||||
|
||||
for (const element of randomQuests) {
|
||||
element._id = this.objectId.generate();
|
||||
element._id = this.hashUtil.generate();
|
||||
const conditions = element.conditions.AvailableForFinish;
|
||||
for (const condition of conditions) {
|
||||
if ("counter" in condition._props) {
|
||||
condition._props.counter.id = this.objectId.generate();
|
||||
condition._props.counter.id = this.hashUtil.generate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { ItemFilterService } from "@spt/services/ItemFilterService";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { SeasonalEventService } from "@spt/services/SeasonalEventService";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
import { MathUtil } from "@spt/utils/MathUtil";
|
||||
import { ObjectId } from "@spt/utils/ObjectId";
|
||||
import { ProbabilityObject, ProbabilityObjectArray, RandomUtil } from "@spt/utils/RandomUtil";
|
||||
import type { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { inject, injectable } from "tsyringe";
|
||||
@ -48,8 +48,8 @@ export class LocationLootGenerator {
|
||||
|
||||
constructor(
|
||||
@inject("PrimaryLogger") protected logger: ILogger,
|
||||
@inject("HashUtil") protected hashUtil: HashUtil,
|
||||
@inject("DatabaseService") protected databaseService: DatabaseService,
|
||||
@inject("ObjectId") protected objectId: ObjectId,
|
||||
@inject("RandomUtil") protected randomUtil: RandomUtil,
|
||||
@inject("ItemHelper") protected itemHelper: ItemHelper,
|
||||
@inject("MathUtil") protected mathUtil: MathUtil,
|
||||
@ -397,7 +397,7 @@ export class LocationLootGenerator {
|
||||
const containerTpl = containerClone.template.Items[0]._tpl;
|
||||
|
||||
// Create new unique parent id to prevent any collisions
|
||||
const parentId = this.objectId.generate();
|
||||
const parentId = this.hashUtil.generate();
|
||||
containerClone.template.Root = parentId;
|
||||
containerClone.template.Items[0]._id = parentId;
|
||||
|
||||
@ -885,18 +885,18 @@ export class LocationLootGenerator {
|
||||
: this.randomUtil.getInt(itemTemplate._props.StackMinRandom, itemTemplate._props.StackMaxRandom);
|
||||
|
||||
itemWithMods.push({
|
||||
_id: this.objectId.generate(),
|
||||
_id: this.hashUtil.generate(),
|
||||
_tpl: chosenTpl,
|
||||
upd: { StackObjectsCount: stackCount },
|
||||
});
|
||||
} else if (this.itemHelper.isOfBaseclass(chosenTpl, BaseClasses.AMMO_BOX)) {
|
||||
// Fill with cartridges
|
||||
const ammoBoxItem: IItem[] = [{ _id: this.objectId.generate(), _tpl: chosenTpl }];
|
||||
const ammoBoxItem: IItem[] = [{ _id: this.hashUtil.generate(), _tpl: chosenTpl }];
|
||||
this.itemHelper.addCartridgesToAmmoBox(ammoBoxItem, itemTemplate);
|
||||
itemWithMods.push(...ammoBoxItem);
|
||||
} else if (this.itemHelper.isOfBaseclass(chosenTpl, BaseClasses.MAGAZINE)) {
|
||||
// Create array with just magazine
|
||||
const magazineItem: IItem[] = [{ _id: this.objectId.generate(), _tpl: chosenTpl }];
|
||||
const magazineItem: IItem[] = [{ _id: this.hashUtil.generate(), _tpl: chosenTpl }];
|
||||
|
||||
if (this.randomUtil.getChance100(this.locationConfig.staticMagazineLootHasAmmoChancePercent)) {
|
||||
// Add randomised amount of cartridges
|
||||
@ -950,7 +950,7 @@ export class LocationLootGenerator {
|
||||
const itemTemplate = this.itemHelper.getItem(chosenTpl)[1];
|
||||
let width = itemTemplate._props.Width;
|
||||
let height = itemTemplate._props.Height;
|
||||
let items: IItem[] = [{ _id: this.objectId.generate(), _tpl: chosenTpl }];
|
||||
let items: IItem[] = [{ _id: this.hashUtil.generate(), _tpl: chosenTpl }];
|
||||
const rootItem = items[0];
|
||||
|
||||
// Use passed in parentId as override for new item
|
||||
|
@ -19,8 +19,8 @@ import type { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
import { MathUtil } from "@spt/utils/MathUtil";
|
||||
import { ObjectId } from "@spt/utils/ObjectId";
|
||||
import { ProbabilityObjectArray, RandomUtil } from "@spt/utils/RandomUtil";
|
||||
import type { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { inject, injectable } from "tsyringe";
|
||||
@ -32,12 +32,12 @@ export class RepeatableQuestGenerator {
|
||||
|
||||
constructor(
|
||||
@inject("PrimaryLogger") protected logger: ILogger,
|
||||
@inject("HashUtil") protected hashUtil: HashUtil,
|
||||
@inject("RandomUtil") protected randomUtil: RandomUtil,
|
||||
@inject("MathUtil") protected mathUtil: MathUtil,
|
||||
@inject("DatabaseService") protected databaseService: DatabaseService,
|
||||
@inject("ItemHelper") protected itemHelper: ItemHelper,
|
||||
@inject("LocalisationService") protected localisationService: LocalisationService,
|
||||
@inject("ObjectId") protected objectId: ObjectId,
|
||||
@inject("RepeatableQuestHelper") protected repeatableQuestHelper: RepeatableQuestHelper,
|
||||
@inject("RepeatableQuestRewardGenerator")
|
||||
protected repeatableQuestRewardGenerator: RepeatableQuestRewardGenerator,
|
||||
@ -308,7 +308,7 @@ export class RepeatableQuestGenerator {
|
||||
}
|
||||
|
||||
const availableForFinishCondition = quest.conditions.AvailableForFinish[0];
|
||||
availableForFinishCondition.counter.id = this.objectId.generate();
|
||||
availableForFinishCondition.counter.id = this.hashUtil.generate();
|
||||
availableForFinishCondition.counter.conditions = [];
|
||||
|
||||
// Only add specific location condition if specific map selected
|
||||
@ -327,7 +327,7 @@ export class RepeatableQuestGenerator {
|
||||
),
|
||||
);
|
||||
availableForFinishCondition.value = desiredKillCount;
|
||||
availableForFinishCondition.id = this.objectId.generate();
|
||||
availableForFinishCondition.id = this.hashUtil.generate();
|
||||
quest.location = this.getQuestLocationByMapId(locationKey);
|
||||
|
||||
quest.rewards = this.repeatableQuestRewardGenerator.generateReward(
|
||||
@ -373,7 +373,7 @@ export class RepeatableQuestGenerator {
|
||||
*/
|
||||
protected generateEliminationLocation(location: string[]): IQuestConditionCounterCondition {
|
||||
const propsObject: IQuestConditionCounterCondition = {
|
||||
id: this.objectId.generate(),
|
||||
id: this.hashUtil.generate(),
|
||||
dynamicLocale: true,
|
||||
target: location,
|
||||
conditionType: "Location",
|
||||
@ -399,7 +399,7 @@ export class RepeatableQuestGenerator {
|
||||
allowedWeaponCategory: string,
|
||||
): IQuestConditionCounterCondition {
|
||||
const killConditionProps: IQuestConditionCounterCondition = {
|
||||
id: this.objectId.generate(),
|
||||
id: this.hashUtil.generate(),
|
||||
dynamicLocale: true,
|
||||
target: target, // e,g, "AnyPmc"
|
||||
value: 1,
|
||||
@ -632,7 +632,7 @@ export class RepeatableQuestGenerator {
|
||||
}
|
||||
|
||||
return {
|
||||
id: this.objectId.generate(),
|
||||
id: this.hashUtil.generate(),
|
||||
index: 0,
|
||||
parentId: "",
|
||||
dynamicLocale: true,
|
||||
@ -692,22 +692,22 @@ export class RepeatableQuestGenerator {
|
||||
const quest = this.generateRepeatableTemplate("Exploration", traderId, repeatableConfig.side, sessionId);
|
||||
|
||||
const exitStatusCondition: IQuestConditionCounterCondition = {
|
||||
id: this.objectId.generate(),
|
||||
id: this.hashUtil.generate(),
|
||||
dynamicLocale: true,
|
||||
status: ["Survived"],
|
||||
conditionType: "ExitStatus",
|
||||
};
|
||||
const locationCondition: IQuestConditionCounterCondition = {
|
||||
id: this.objectId.generate(),
|
||||
id: this.hashUtil.generate(),
|
||||
dynamicLocale: true,
|
||||
target: locationTarget,
|
||||
conditionType: "Location",
|
||||
};
|
||||
|
||||
quest.conditions.AvailableForFinish[0].counter.id = this.objectId.generate();
|
||||
quest.conditions.AvailableForFinish[0].counter.id = this.hashUtil.generate();
|
||||
quest.conditions.AvailableForFinish[0].counter.conditions = [exitStatusCondition, locationCondition];
|
||||
quest.conditions.AvailableForFinish[0].value = numExtracts;
|
||||
quest.conditions.AvailableForFinish[0].id = this.objectId.generate();
|
||||
quest.conditions.AvailableForFinish[0].id = this.hashUtil.generate();
|
||||
quest.location = this.getQuestLocationByMapId(locationKey);
|
||||
|
||||
if (requiresSpecificExtract) {
|
||||
@ -831,7 +831,7 @@ export class RepeatableQuestGenerator {
|
||||
*/
|
||||
protected generateExplorationExitCondition(exit: IExit): IQuestConditionCounterCondition {
|
||||
return {
|
||||
id: this.objectId.generate(),
|
||||
id: this.hashUtil.generate(),
|
||||
dynamicLocale: true,
|
||||
exitName: exit.Name,
|
||||
conditionType: "ExitName",
|
||||
@ -858,7 +858,7 @@ export class RepeatableQuestGenerator {
|
||||
const questClone = this.cloner.clone<IRepeatableQuest>(
|
||||
this.databaseService.getTemplates().repeatableQuests.templates[type],
|
||||
);
|
||||
questClone._id = this.objectId.generate();
|
||||
questClone._id = this.hashUtil.generate();
|
||||
questClone.traderId = traderId;
|
||||
|
||||
/* in locale, these id correspond to the text of quests
|
||||
@ -903,7 +903,7 @@ export class RepeatableQuestGenerator {
|
||||
.replace("{traderId}", desiredTraderId)
|
||||
.replace("{templateId}", questClone.templateId);
|
||||
|
||||
questClone.questStatus.id = this.objectId.generate();
|
||||
questClone.questStatus.id = this.hashUtil.generate();
|
||||
questClone.questStatus.uid = sessionId; // Needs to match user id
|
||||
questClone.questStatus.qid = questClone._id; // Needs to match quest id
|
||||
|
||||
|
@ -25,7 +25,6 @@ import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { SeasonalEventService } from "@spt/services/SeasonalEventService";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
import { MathUtil } from "@spt/utils/MathUtil";
|
||||
import { ObjectId } from "@spt/utils/ObjectId";
|
||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||
import type { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { inject, injectable } from "tsyringe";
|
||||
@ -44,7 +43,6 @@ export class RepeatableQuestRewardGenerator {
|
||||
@inject("PresetHelper") protected presetHelper: PresetHelper,
|
||||
@inject("HandbookHelper") protected handbookHelper: HandbookHelper,
|
||||
@inject("LocalisationService") protected localisationService: LocalisationService,
|
||||
@inject("ObjectId") protected objectId: ObjectId,
|
||||
@inject("ItemFilterService") protected itemFilterService: ItemFilterService,
|
||||
@inject("SeasonalEventService") protected seasonalEventService: SeasonalEventService,
|
||||
@inject("ConfigServer") protected configServer: ConfigServer,
|
||||
@ -518,7 +516,7 @@ export class RepeatableQuestRewardGenerator {
|
||||
* @returns {object} Object of "Reward"-item-type
|
||||
*/
|
||||
protected generateItemReward(tpl: string, count: number, index: number, foundInRaid = true): IQuestReward {
|
||||
const id = this.objectId.generate();
|
||||
const id = this.hashUtil.generate();
|
||||
const questRewardItem: IQuestReward = {
|
||||
id: this.hashUtil.generate(),
|
||||
unknown: false,
|
||||
@ -555,7 +553,7 @@ export class RepeatableQuestRewardGenerator {
|
||||
preset?: IItem[],
|
||||
foundInRaid = true,
|
||||
): IQuestReward {
|
||||
const id = this.objectId.generate();
|
||||
const id = this.hashUtil.generate();
|
||||
const questRewardItem: IQuestReward = {
|
||||
id: this.hashUtil.generate(),
|
||||
unknown: false,
|
||||
|
@ -18,7 +18,6 @@ import { CompareUtil } from "@spt/utils/CompareUtil";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
import { JsonUtil } from "@spt/utils/JsonUtil";
|
||||
import { MathUtil } from "@spt/utils/MathUtil";
|
||||
import { ObjectId } from "@spt/utils/ObjectId";
|
||||
import { ProbabilityObject, ProbabilityObjectArray, RandomUtil } from "@spt/utils/RandomUtil";
|
||||
import type { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { inject, injectable } from "tsyringe";
|
||||
@ -40,7 +39,6 @@ export class ItemHelper {
|
||||
@inject("HashUtil") protected hashUtil: HashUtil,
|
||||
@inject("JsonUtil") protected jsonUtil: JsonUtil,
|
||||
@inject("RandomUtil") protected randomUtil: RandomUtil,
|
||||
@inject("ObjectId") protected objectId: ObjectId,
|
||||
@inject("MathUtil") protected mathUtil: MathUtil,
|
||||
@inject("DatabaseService") protected databaseService: DatabaseService,
|
||||
@inject("HandbookHelper") protected handbookHelper: HandbookHelper,
|
||||
@ -797,7 +795,7 @@ export class ItemHelper {
|
||||
* @param itemWithChildren Item with mods to update
|
||||
* @param newId new id to add on chidren of base item
|
||||
*/
|
||||
public replaceRootItemID(itemWithChildren: IItem[], newId = this.objectId.generate()): void {
|
||||
public replaceRootItemID(itemWithChildren: IItem[], newId = this.hashUtil.generate()): void {
|
||||
// original id on base item
|
||||
const oldId = itemWithChildren[0]._id;
|
||||
|
||||
@ -1457,7 +1455,7 @@ export class ItemHelper {
|
||||
foundInRaid = false,
|
||||
): IItem {
|
||||
return {
|
||||
_id: this.objectId.generate(),
|
||||
_id: this.hashUtil.generate(),
|
||||
_tpl: ammoTpl,
|
||||
parentId: parentId,
|
||||
slotId: "cartridges",
|
||||
|
Loading…
x
Reference in New Issue
Block a user