diff --git a/.github/workflows/run-types.yaml b/.github/workflows/run-types.yaml index 9027b4353..888a3c7cc 100644 --- a/.github/workflows/run-types.yaml +++ b/.github/workflows/run-types.yaml @@ -38,5 +38,5 @@ jobs: working-directory: ./project - name: Run Type Check - run: npm run lint:types + run: npm run type-check working-directory: ./project diff --git a/project/assets/database/locales/server/cs.json b/project/assets/database/locales/server/cs.json index ddb469a4a..1b7df3b09 100644 --- a/project/assets/database/locales/server/cs.json +++ b/project/assets/database/locales/server/cs.json @@ -591,7 +591,7 @@ "watermark-discord_url": "https://discord.sp-tarkov.com", "watermark-do_not_report": "NENAHLAŠUJ TO", "watermark-free_of_charge": "Tento produkt je zdarma", - "watermark-issue_tracker_url": "https://dev.sp-tarkov.com/SPT/Server/issues", + "watermark-issue_tracker_url": "https://github.com/sp-tarkov/server/", "watermark-modding_disabled": "TATO VERZE MÁ ZÁKÁZÁNO MÓDOVÁNÍ SERVERU", "watermark-no_support": "ŽÁDNÁ PODPORA NEBUDE POSKYTNUTA", "watermark-not_an_issue": "TOTO NENÍ CHYBA", diff --git a/project/assets/database/locales/server/de.json b/project/assets/database/locales/server/de.json index 0c7fb8e8e..ad9bb4ac6 100644 --- a/project/assets/database/locales/server/de.json +++ b/project/assets/database/locales/server/de.json @@ -708,7 +708,7 @@ "watermark-discord_url": "https://discord.sp-tarkov.com", "watermark-do_not_report": "MELDEN UNTERSAGT", "watermark-free_of_charge": "Diese Arbeit ist kostenfrei", - "watermark-issue_tracker_url": "https://dev.sp-tarkov.com/SPT/Server/issues", + "watermark-issue_tracker_url": "https://github.com/sp-tarkov/server/", "watermark-modding_disabled": "BEI DIESEM BUILD IST DAS SERVER-MODDING DEAKTIVIERT", "watermark-no_support": "ES WIRD KEIN SUPPORT GEWÄHRT", "watermark-not_an_issue": "DAS IST KEIN PROBLEM", diff --git a/project/assets/database/locales/server/el.json b/project/assets/database/locales/server/el.json index cd7357022..9fa180ae8 100644 --- a/project/assets/database/locales/server/el.json +++ b/project/assets/database/locales/server/el.json @@ -708,7 +708,7 @@ "watermark-discord_url": "https://discord.sp-tarkov.com", "watermark-do_not_report": "ΜΗΝ ΤΟ ΑΝΑΦΕΡΕΤΕ", "watermark-free_of_charge": "Αυτή η εργασία είναι χωρίς χρέωση", - "watermark-issue_tracker_url": "https://dev.sp-tarkov.com/SPT/Server/issues", + "watermark-issue_tracker_url": "https://github.com/sp-tarkov/server/", "watermark-modding_disabled": "ΑΥΤΗ Η ΕΚΔΟΣΗ ΕΧΕΙ ΑΠΕΝΕΡΓΟΠΟΙΗΜΈΝΕΣ ΤΙΣ ΤΡΟΠΟΠΟΙΗΣΕΙΣ ΑΠΟ ΤΟΝ ΔΙΑΚΟΜΙΣΤΗ", "watermark-no_support": "ΔΕΝ ΘΑ ΔΩΘΕΙ ΥΠΟΣΤΗΡΙΞΗ", "watermark-not_an_issue": "ΑΥΤΟ ΔΕΝ ΕΙΝΑΙ ΠΡΟΒΛΗΜΑ", diff --git a/project/assets/database/locales/server/en.json b/project/assets/database/locales/server/en.json index da5a5882a..8b672dc1d 100644 --- a/project/assets/database/locales/server/en.json +++ b/project/assets/database/locales/server/en.json @@ -628,7 +628,7 @@ "ragfair-unable_to_remove_offer_doesnt_exist": "Unable to remove offer with id: %s as it cannot be found in flea market", "ragfair-unable_to_remove_offer_not_found_in_profile": "Unable to find offer: {{offerId}} in profile: {{profileId}} as offer is undefined, creating", "ragfair-generating_offers": "Generating flea offers...", - "release-beta-disclaimer": "By pressing OK you agree that no support is offered and that this is for bug testing only. NOT actual gameplay. Mods are disabled. New profiles may be required frequently. Report all bugs in the reports channel in discord, or on the issues page on the website. If you don't press OK by the time specified, the game will close.", + "release-beta-disclaimer": "By pressing OK you agree that no support is offered and that this is for bug testing only. NOT actual gameplay. Mods are disabled. New profiles may be required frequently. Report all bugs in the reports channel in discord, or on the issues page on the website. If you don't press OK by the time specified, the game will close.", "release-beta-disclaimer-accept": "User accepted the beta disclaimer", "release-beta-disclaimer-mods-enabled": "By pressing OK you agree that no support is offered and that this is for bug testing only. NOT actual gameplay. Mods are enabled, do NOT report issues with mods. Do NOT ask mod authors for updated mods. Report all bugs in the reports channel in discord, or on the issues page on the website. If you dont press OK by the time specificed, the game will close.", "release-illegal-plugins-exception": "Client mods detected. Mods are not enabled for BleedingEdge/testing builds of SPT - please remove them before playing!", @@ -660,7 +660,7 @@ "scheduled_event_failed_to_run": "Scheduled event: '%s' failed to run successfully.", "season-no_matching_season_found_for_date": "Unable to find a season using the current date, defaulting to Summer", "season-event_is_active": "Event: %s is active", - "seasonal-missing_equipment_slot_on_bot": "Unable to remove christmas equipment from slot: {{equipmentSlot}} as it cannot be found on bot: {{botRole}}", + "seasonal-missing_equipment_slot_on_bot": "Unable to remove christmas equipment from slot: {{equipmentSlot}} as it cannot be found on bot: {{botRole}}", "seasonal-missing_loot_container_slot_on_bot": "Unable to remove christmas loot from slot: {{lootContainer}} as it cannot be found on bot: {{botRole}}", "server_running": "Server is running, do not close while playing SPT", "server_start_meme_1": "Live laugh love", @@ -711,7 +711,7 @@ "watermark-discord_url": "https://discord.sp-tarkov.com", "watermark-do_not_report": "DO NOT REPORT IT", "watermark-free_of_charge": "This work is free of charge", - "watermark-issue_tracker_url": "https://dev.sp-tarkov.com/SPT/Server/issues", + "watermark-issue_tracker_url": "https://github.com/sp-tarkov/server/", "watermark-modding_disabled": "THIS BUILD HAS SERVER MODDING DISABLED", "watermark-no_support": "NO SUPPORT WILL BE GIVEN", "watermark-not_an_issue": "THIS IS NOT AN ISSUE", @@ -727,9 +727,9 @@ "websocket-received_message": "[WS] Received message from user %s ", "websocket-socket_lost_deleting_handle": "[WS] Socket lost, deleting handle", "websocket-started": "Started websocket at %s", - "chatbot-cannot_accept_any_more_of_gift": "You cannot accept any more of this gift", - "chatbot-forced_event_enabled": "%s event has been enabled, restart your game client before starting a raid", - "chatbot-added_stash_rows_please_restart": "Added 2 rows to stash, please restart your game to see them", - "chatbot-snow_enabled": "Snow is enabled for all subsequent raids until the server is restarted", - "chatbot-summer_enabled": "Summer has been enabled for all subsequent raids until the server is restarted" + "chatbot-cannot_accept_any_more_of_gift": "You cannot accept any more of this gift", + "chatbot-forced_event_enabled": "%s event has been enabled, restart your game client before starting a raid", + "chatbot-added_stash_rows_please_restart": "Added 2 rows to stash, please restart your game to see them", + "chatbot-snow_enabled": "Snow is enabled for all subsequent raids until the server is restarted", + "chatbot-summer_enabled": "Summer has been enabled for all subsequent raids until the server is restarted" } diff --git a/project/assets/database/locales/server/es-es.json b/project/assets/database/locales/server/es-es.json index e2a1b2e21..d090880cd 100644 --- a/project/assets/database/locales/server/es-es.json +++ b/project/assets/database/locales/server/es-es.json @@ -708,7 +708,7 @@ "watermark-discord_url": "https://discord.sp-tarkov.com", "watermark-do_not_report": "NO LO REPORTES", "watermark-free_of_charge": "Este trabajo es libre de cargo.", - "watermark-issue_tracker_url": "https://dev.sp-tarkov.com/SPT/Server/issues", + "watermark-issue_tracker_url": "https://github.com/sp-tarkov/server/", "watermark-modding_disabled": "ESTA VERSIÓN TIENE LAS MODIFICACIONES DESACTIVADAS", "watermark-no_support": "NO SE DARÁ NINGÚN TIPO DE SOPORTE", "watermark-not_an_issue": "ESTO NO ES UN PROBLEMA", diff --git a/project/assets/database/locales/server/fr.json b/project/assets/database/locales/server/fr.json index c2f188a70..9d826ef65 100644 --- a/project/assets/database/locales/server/fr.json +++ b/project/assets/database/locales/server/fr.json @@ -708,7 +708,7 @@ "watermark-discord_url": "https://discord.sp-tarkov.com", "watermark-do_not_report": "NE PAS SIGNALER !", "watermark-free_of_charge": "Ce travail est gratuit", - "watermark-issue_tracker_url": "https://dev.sp-tarkov.com/SPT/Server/issues", + "watermark-issue_tracker_url": "https://github.com/sp-tarkov/server/", "watermark-modding_disabled": "CE BUILD A LE MODDING DESACTIVE", "watermark-no_support": "AUCUN SUPPORT NE SERA FOURNI", "watermark-not_an_issue": "CECI N'EST PAS UNE ERREUR", diff --git a/project/assets/database/locales/server/it.json b/project/assets/database/locales/server/it.json index 7b2da0ad1..987028dd5 100644 --- a/project/assets/database/locales/server/it.json +++ b/project/assets/database/locales/server/it.json @@ -708,7 +708,7 @@ "watermark-discord_url": "https://discord.sp-tarkov.com", "watermark-do_not_report": "NON SEGNALARLO", "watermark-free_of_charge": "Questo lavoro è gratuito", - "watermark-issue_tracker_url": "https://dev.sp-tarkov.com/SPT/Server/issues", + "watermark-issue_tracker_url": "https://github.com/sp-tarkov/server/", "watermark-modding_disabled": "QUESTA BUILD HA LE MOD SERVER DISATTIVATE", "watermark-no_support": "NESSUN SUPPORTO SARA' FORNITO", "watermark-not_an_issue": "QUESTO NON É UN ERRORE", diff --git a/project/assets/database/locales/server/ko.json b/project/assets/database/locales/server/ko.json index a9e87f648..faa98b301 100644 --- a/project/assets/database/locales/server/ko.json +++ b/project/assets/database/locales/server/ko.json @@ -708,7 +708,7 @@ "watermark-discord_url": "https://discord.sp-tarkov.com", "watermark-do_not_report": "리포트 하지마세요", "watermark-free_of_charge": "이 소프트웨어는 무료입니다", - "watermark-issue_tracker_url": "https://dev.sp-tarkov.com/SPT/Server/issues", + "watermark-issue_tracker_url": "https://github.com/sp-tarkov/server/", "watermark-modding_disabled": "이 버전은 모드가 비활성화된 빌드입니다", "watermark-no_support": "문의 및 지원은 없습니다", "watermark-not_an_issue": "이 메시지는 오류 또는 문제가 아닙니다", diff --git a/project/assets/database/locales/server/nl.json b/project/assets/database/locales/server/nl.json index b20aabfa4..b5410882a 100644 --- a/project/assets/database/locales/server/nl.json +++ b/project/assets/database/locales/server/nl.json @@ -708,7 +708,7 @@ "watermark-discord_url": "https://discord.sp-tarkov.com", "watermark-do_not_report": "RAPPORTEER HET NIET", "watermark-free_of_charge": "Dit werk is gratis", - "watermark-issue_tracker_url": "https://dev.sp-tarkov.com/SPT/Server/issues", + "watermark-issue_tracker_url": "https://github.com/sp-tarkov/server/", "watermark-modding_disabled": "DEZE BUILD HEEFT SERVER MODDEN UITGESCHAKELD", "watermark-no_support": "ER WORDT GEEN SUPPORT GEGEVEN", "watermark-not_an_issue": "DIT IS GEEN PROBLEEM", diff --git a/project/assets/database/locales/server/pl.json b/project/assets/database/locales/server/pl.json index e1dd1ddf1..b219f4277 100644 --- a/project/assets/database/locales/server/pl.json +++ b/project/assets/database/locales/server/pl.json @@ -701,7 +701,7 @@ "watermark-discord_url": "https://discord.sp-tarkov.com", "watermark-do_not_report": "NIE ZGŁASZAJ TEGO", "watermark-free_of_charge": "Ta praca jest darmowa", - "watermark-issue_tracker_url": "https://dev.sp-tarkov.com/SPT/Server/issues", + "watermark-issue_tracker_url": "https://github.com/sp-tarkov/server/", "watermark-modding_disabled": "TA WERSJA MA WYŁĄCZONE MODYFIKACJE SERWERA", "watermark-no_support": "NIE UDZIELAMY WSPARCIA", "watermark-not_an_issue": "TO NIE JEST PROBLEM", diff --git a/project/assets/database/locales/server/pt-br.json b/project/assets/database/locales/server/pt-br.json index 4bd8af760..d46e5deca 100644 --- a/project/assets/database/locales/server/pt-br.json +++ b/project/assets/database/locales/server/pt-br.json @@ -708,7 +708,7 @@ "watermark-discord_url": "https://discord.sp-tarkov.com", "watermark-do_not_report": "NÃO RELATE ISSO", "watermark-free_of_charge": "Esse trabalho é gratuito", - "watermark-issue_tracker_url": "https://dev.sp-tarkov.com/SPT/Server/issues", + "watermark-issue_tracker_url": "https://github.com/sp-tarkov/server/", "watermark-modding_disabled": "ESTA VERSÃO TEM OS MODS DO SERVIDOR DESATIVADO", "watermark-no_support": "NÃO SERÁ FORNECIDO NENHUM SUPORTE", "watermark-not_an_issue": "ISSO NÃO É UM PROBLEMA", diff --git a/project/assets/database/locales/server/ru.json b/project/assets/database/locales/server/ru.json index 59ad807a5..e77bb3ac5 100644 --- a/project/assets/database/locales/server/ru.json +++ b/project/assets/database/locales/server/ru.json @@ -708,7 +708,7 @@ "watermark-discord_url": "https://discord.sp-tarkov.com", "watermark-do_not_report": "НЕ ОТПРАВЛЯЙТЕ БАГ-РЕПОРТ НАСЧЕТ ЭТОГО", "watermark-free_of_charge": "Данный проект является бесплатным", - "watermark-issue_tracker_url": "https://dev.sp-tarkov.com/SPT/Server/issues", + "watermark-issue_tracker_url": "https://github.com/sp-tarkov/server/", "watermark-modding_disabled": "В ЭТОЙ СБОРКЕ ОТСУТСТВУЮТ ВОЗМОЖНОСТИ МОДИФИКАЦИИ", "watermark-no_support": "ПОДДЕРЖКА НЕ БУДЕТ ОКАЗЫВАТЬСЯ", "watermark-not_an_issue": "ЭТО НЕ ОШИБКА", diff --git a/project/assets/database/locales/server/tr.json b/project/assets/database/locales/server/tr.json index 7e4bf3613..37518129d 100644 --- a/project/assets/database/locales/server/tr.json +++ b/project/assets/database/locales/server/tr.json @@ -708,7 +708,7 @@ "watermark-discord_url": "https://discord.sp-tarkov.com", "watermark-do_not_report": "SAKIN BİLDİRMEYİN", "watermark-free_of_charge": "Bu çalışma ücretsizdir", - "watermark-issue_tracker_url": "https://dev.sp-tarkov.com/SPT/Server/issues", + "watermark-issue_tracker_url": "https://github.com/sp-tarkov/server/", "watermark-modding_disabled": "BU YAPIDA SUNUCU MODLAMASI DEVRE DIŞI BIRAKILMIŞTIR", "watermark-no_support": "HİÇBİR DESTEK VERİLMEYECEK", "watermark-not_an_issue": "BU BİR HATA DEĞİL", diff --git a/project/assets/database/locales/server/uk.json b/project/assets/database/locales/server/uk.json index aa8291442..01c27f78c 100644 --- a/project/assets/database/locales/server/uk.json +++ b/project/assets/database/locales/server/uk.json @@ -163,7 +163,7 @@ "watermark-discord_url": "https://discord.sp-tarkov.com", "watermark-do_not_report": "НЕ ПОВІДОМЛЯЙТЕ ПРО ЦЕ", "watermark-free_of_charge": "Ця робота бескоштовна ", - "watermark-issue_tracker_url": "https://dev.sp-tarkov.com/SPT/Server/issues", + "watermark-issue_tracker_url": "https://github.com/sp-tarkov/server/", "watermark-modding_disabled": "У ЦОМУ БІЛДІ ВИМКНЕНО МОДИНГ СЕРВЕРА", "watermark-no_support": "ЖОДНОЇ ПІДТРИМКИ НЕ БУДЕ НАДАНО", "watermark-not_an_issue": "ЦЕ НЕ ПРОБЛЕМА", diff --git a/project/assets/database/locales/server/zh-cn.json b/project/assets/database/locales/server/zh-cn.json index b886435d9..ee7abf0f3 100644 --- a/project/assets/database/locales/server/zh-cn.json +++ b/project/assets/database/locales/server/zh-cn.json @@ -708,7 +708,7 @@ "watermark-discord_url": "https://discord.sp-tarkov.com", "watermark-do_not_report": "不 要 报 告", "watermark-free_of_charge": "该软件免费", - "watermark-issue_tracker_url": "https://dev.sp-tarkov.com/SPT/Server/issues", + "watermark-issue_tracker_url": "https://github.com/sp-tarkov/server/", "watermark-modding_disabled": "该 编 译 不 启 用 服 务 端 模 改", "watermark-no_support": "不 会 提 供 支 持", "watermark-not_an_issue": "这 不 是 个 问 题", diff --git a/project/biome.jsonc b/project/biome.jsonc index d3ab1259b..427f6cbdf 100644 --- a/project/biome.jsonc +++ b/project/biome.jsonc @@ -60,7 +60,14 @@ }, "overrides": [ { - "include": ["tests/*"] + "include": ["tests/*"], + "linter": { + "rules": { + "suspicious": { + "noExplicitAny": "off" + } + } + } } ] } diff --git a/project/src/controllers/DialogueController.ts b/project/src/controllers/DialogueController.ts index 5b663e500..e4a21561d 100644 --- a/project/src/controllers/DialogueController.ts +++ b/project/src/controllers/DialogueController.ts @@ -83,10 +83,12 @@ export class DialogueController { // Add any friends the user has after the chatbots const profile = this.profileHelper.getFullProfile(sessionID); - for (const friendId of profile?.friends) { - const friendProfile = this.profileHelper.getChatRoomMemberFromSessionId(friendId); - if (friendProfile) { - friends.push(friendProfile); + if (profile?.friends) { + for (const friendId of profile.friends) { + const friendProfile = this.profileHelper.getChatRoomMemberFromSessionId(friendId); + if (friendProfile) { + friends.push(friendProfile); + } } } diff --git a/project/src/controllers/GameController.ts b/project/src/controllers/GameController.ts index 1047389a8..76e8c5263 100644 --- a/project/src/controllers/GameController.ts +++ b/project/src/controllers/GameController.ts @@ -256,6 +256,7 @@ export class GameController { // Hideout Improvement property changed name if ((fullProfile.characters.pmc.Hideout as any).Improvement) { fullProfile.characters.pmc.Hideout.Improvements = (fullProfile.characters.pmc.Hideout as any).Improvement; + // biome-ignore lint/performance/noDelete: Delete is fine here, as we're seeking to remove these entirely delete (fullProfile.characters.pmc.Hideout as any).Improvement; this.logger.warning(`Migration: Moved Hideout Improvement data to new property 'Improvements'`); } @@ -273,12 +274,14 @@ export class GameController { // Remove PMC 'ragfair' from trader list if (fullProfile.characters.pmc.TradersInfo.ragfair) { this.logger.warning("Migration: deleting: ragfair traderinfo object from PMC"); + // biome-ignore lint/performance/noDelete: Delete is fine here, as we're seeking to remove these entirely delete fullProfile.characters.pmc.TradersInfo.ragfair; } // Remove SCAV 'ragfair' from trader list if (fullProfile.characters.scav.TradersInfo.ragfair) { this.logger.warning("Migration: deleting: ragfair traderinfo object from PMC"); + // biome-ignore lint/performance/noDelete: Delete is fine here, as we're seeking to remove these entirely delete fullProfile.characters.scav.TradersInfo.ragfair; } @@ -561,6 +564,7 @@ export class GameController { protected checkForAndRemoveUndefinedDialogs(fullProfile: ISptProfile): void { const undefinedDialog = fullProfile.dialogues.undefined; if (undefinedDialog) { + // biome-ignore lint/performance/noDelete: Delete is fine here, as we're seeking to delete undefined dialogs. delete fullProfile.dialogues.undefined; } } diff --git a/project/src/controllers/HealthController.ts b/project/src/controllers/HealthController.ts index 619694770..6bd839afd 100644 --- a/project/src/controllers/HealthController.ts +++ b/project/src/controllers/HealthController.ts @@ -250,6 +250,7 @@ export class HealthController { // Remove empty effect object if (Object.keys(pmcData.Health.BodyParts[bodyPartKey].Effects).length === 0) { + // biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the effect. delete pmcData.Health.BodyParts[bodyPartKey].Effects; } } diff --git a/project/src/controllers/HideoutController.ts b/project/src/controllers/HideoutController.ts index e0b8f3d3e..f293503ac 100644 --- a/project/src/controllers/HideoutController.ts +++ b/project/src/controllers/HideoutController.ts @@ -1229,6 +1229,7 @@ export class HideoutController { if (hasMildPain) { // Already has mild pain, remove mild and add severe + // biome-ignore lint/performance/noDelete: Deleting is fine here, we're removing the effect to replace it with another. delete pmcData.Health.BodyParts.Chest.Effects.MildMusclePain; pmcData.Health.BodyParts.Chest.Effects.SevereMusclePain = { diff --git a/project/src/controllers/InventoryController.ts b/project/src/controllers/InventoryController.ts index cbbf9b812..392a949c0 100644 --- a/project/src/controllers/InventoryController.ts +++ b/project/src/controllers/InventoryController.ts @@ -282,7 +282,7 @@ export class InventoryController { // Remove FiR status from destination stack when source stack has no FiR but destination does if (!sourceItem.upd.SpawnedInSession && destinationItem.upd.SpawnedInSession) { - delete destinationItem.upd.SpawnedInSession; + destinationItem.upd.SpawnedInSession = false; } destinationItem.upd.StackObjectsCount += sourceItem.upd.StackObjectsCount; // Add source stackcount to destination @@ -408,6 +408,7 @@ export class InventoryController { if (request.to.location) { itemOne.location = request.to.location; } else { + // biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the location. delete itemOne.location; } @@ -416,6 +417,7 @@ export class InventoryController { if (request.to2.location) { itemTwo.location = request.to2.location; } else { + // biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the location. delete itemTwo.location; } @@ -721,6 +723,7 @@ export class InventoryController { if (change.location) { inventoryItem.location = change.location; } else { + // biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the location. delete inventoryItem.location; } } diff --git a/project/src/generators/BotWeaponGenerator.ts b/project/src/generators/BotWeaponGenerator.ts index 2ac057e34..6c8ea9a07 100644 --- a/project/src/generators/BotWeaponGenerator.ts +++ b/project/src/generators/BotWeaponGenerator.ts @@ -571,9 +571,12 @@ export class BotWeaponGenerator { } // Inner join the weapons allowed + passed in cartridge pool to get compatible cartridges - const compatibleCartridges = Object.keys(cartridgePoolForWeapon) - .filter((cartridge) => compatibleCartridgesInTemplate.includes(cartridge)) - .reduce((acc, key) => ({ ...acc, [key]: cartridgePoolForWeapon[key] }), {}); + const compatibleCartridges = {}; + for (const cartridge of Object.keys(cartridgePoolForWeapon)) { + if (compatibleCartridgesInTemplate.includes(cartridge)) { + compatibleCartridges[cartridge] = cartridgePoolForWeapon[cartridge]; + } + } if (!compatibleCartridges) { // No compatible cartridges, use default diff --git a/project/src/generators/LootGenerator.ts b/project/src/generators/LootGenerator.ts index 96d8de5e5..1ce8677ac 100644 --- a/project/src/generators/LootGenerator.ts +++ b/project/src/generators/LootGenerator.ts @@ -397,9 +397,9 @@ export class LootGenerator { const presetAndMods: IItem[] = this.itemHelper.replaceIDs(chosenPreset._items); this.itemHelper.remapRootItemId(presetAndMods); // Add chosen preset tpl to result array - presetAndMods.forEach((item) => { + for (const item of presetAndMods) { result.push(item); - }); + } if (itemLimitCount) { // Increment item count as item has been chosen and its inside itemLimitCount dictionary diff --git a/project/src/generators/RagfairOfferGenerator.ts b/project/src/generators/RagfairOfferGenerator.ts index 86e370626..4e8c8cad1 100644 --- a/project/src/generators/RagfairOfferGenerator.ts +++ b/project/src/generators/RagfairOfferGenerator.ts @@ -403,7 +403,9 @@ export class RagfairOfferGenerator { this.itemHelper.reparentItemAndChildren(clonedAssort[0], clonedAssort); // Clear unnecessary properties + // biome-ignore lint/performance/noDelete: Deleting is fine here, we're getting rid of unecessary properties. delete clonedAssort[0].parentId; + // biome-ignore lint/performance/noDelete: Deleting is fine here, we're getting rid of unecessary properties. delete clonedAssort[0].slotId; assortSingleOfferProcesses.push( diff --git a/project/src/generators/RepeatableQuestRewardGenerator.ts b/project/src/generators/RepeatableQuestRewardGenerator.ts index ac667de3c..22c6244dd 100644 --- a/project/src/generators/RepeatableQuestRewardGenerator.ts +++ b/project/src/generators/RepeatableQuestRewardGenerator.ts @@ -309,20 +309,22 @@ export class RepeatableQuestRewardGenerator { itemsToReturn.push({ item: chosenItemFromPool, stackSize: rewardItemStackCount }); const itemCost = this.presetHelper.getDefaultPresetOrItemPrice(chosenItemFromPool._id); - itemRewardBudget -= rewardItemStackCount * itemCost; + const calculatedItemRewardBudget = itemRewardBudget - rewardItemStackCount * itemCost; this.logger.debug(`Added item: ${chosenItemFromPool._id} with price: ${rewardItemStackCount * itemCost}`); // If we still have budget narrow down possible items - if (itemRewardBudget > 0) { + if (calculatedItemRewardBudget > 0) { // Filter possible reward items to only items with a price below the remaining budget exhausableItemPool = new ExhaustableArray( - this.filterRewardPoolWithinBudget(itemPool, itemRewardBudget, 0), + this.filterRewardPoolWithinBudget(itemPool, calculatedItemRewardBudget, 0), this.randomUtil, this.cloner, ); if (!exhausableItemPool.hasValues()) { - this.logger.debug(`Reward pool empty with: ${itemRewardBudget} roubles of budget remaining`); + this.logger.debug( + `Reward pool empty with: ${calculatedItemRewardBudget} roubles of budget remaining`, + ); break; // No reward items left, exit } } diff --git a/project/src/generators/ScavCaseRewardGenerator.ts b/project/src/generators/ScavCaseRewardGenerator.ts index 180a27ec2..9e0d84190 100644 --- a/project/src/generators/ScavCaseRewardGenerator.ts +++ b/project/src/generators/ScavCaseRewardGenerator.ts @@ -321,6 +321,7 @@ export class ScavCaseRewardGenerator { // Clean up upd object if it wasn't used if (!rootItem.upd) { + // biome-ignore lint/performance/noDelete: Delete is fine here, we're cleaning up this object without leaving an undefined. delete rootItem.upd; } diff --git a/project/src/helpers/HealthHelper.ts b/project/src/helpers/HealthHelper.ts index 7c23fff64..9be393f1a 100644 --- a/project/src/helpers/HealthHelper.ts +++ b/project/src/helpers/HealthHelper.ts @@ -293,6 +293,7 @@ export class HealthHelper { for (const bodyPart in bodyPartsWithEffects) { // clear effects from profile bodyPart if (deleteExistingEffects) { + // biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the effect. delete pmcData.Health.BodyParts[bodyPart].Effects; } @@ -339,6 +340,7 @@ export class HealthHelper { // Delete empty property to prevent client bugs if (this.isEmpty(profileBodyPart.Effects)) { + // biome-ignore lint/performance/noDelete: Delete is fine here, we're removing an empty property to prevent game bugs. delete profileBodyPart.Effects; } } diff --git a/project/src/helpers/HideoutHelper.ts b/project/src/helpers/HideoutHelper.ts index 8eb921ed3..aca94f4cc 100644 --- a/project/src/helpers/HideoutHelper.ts +++ b/project/src/helpers/HideoutHelper.ts @@ -180,8 +180,11 @@ export class HideoutHelper { break; case BonusType.TEXT_BONUS: // Delete values before they're added to profile + // biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the data. delete bonus.passive; + // biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the data. delete bonus.production; + // biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the data. delete bonus.visible; break; } @@ -781,6 +784,7 @@ export class HideoutHelper { } // Filter ran out / used up + // biome-ignore lint/performance/noDelete: Delete is fine here, as we're seeking to entirely delete the water filter. delete waterFilterArea.slots[i].item; // Update remaining resources to be subtracted filterDrainRate = Math.abs(resourceValue); @@ -919,6 +923,7 @@ export class HideoutHelper { break; // Break here to avoid updating all filters } + // biome-ignore lint/performance/noDelete: Delete is fine here, as we're seeking to entirely delete the air filter. delete airFilterArea.slots[i].item; // Update remaining resources to be subtracted filterDrainRate = Math.abs(resourceValue); diff --git a/project/src/helpers/InRaidHelper.ts b/project/src/helpers/InRaidHelper.ts index c4e6b67a9..63a87059c 100644 --- a/project/src/helpers/InRaidHelper.ts +++ b/project/src/helpers/InRaidHelper.ts @@ -118,7 +118,9 @@ export class InRaidHelper { }); for (const item of itemsToRemovePropertyFrom) { - delete item.upd.SpawnedInSession; + if (item.upd) { + item.upd.SpawnedInSession = false; + } } } diff --git a/project/src/helpers/InventoryHelper.ts b/project/src/helpers/InventoryHelper.ts index 93302d03a..b3c059b04 100644 --- a/project/src/helpers/InventoryHelper.ts +++ b/project/src/helpers/InventoryHelper.ts @@ -177,10 +177,14 @@ export class InventoryHelper { // Ensure item has upd object this.itemHelper.addUpdObjectToItem(item); + if (!item.upd) { + item.upd = {}; + } + if (foundInRaid) { item.upd.SpawnedInSession = foundInRaid; } else { - delete item.upd.SpawnedInSession; + item.upd.SpawnedInSession = false; } } } @@ -191,14 +195,17 @@ export class InventoryHelper { */ protected removeTraderRagfairRelatedUpdProperties(upd: IUpd): void { if (upd.UnlimitedCount !== undefined) { + // biome-ignore lint/performance/noDelete: Delete is fine here since we're attempting to remove this fully here. delete upd.UnlimitedCount; } if (upd.BuyRestrictionCurrent !== undefined) { + // biome-ignore lint/performance/noDelete: Delete is fine here since we're attempting to remove this fully here. delete upd.BuyRestrictionCurrent; } if (upd.BuyRestrictionMax !== undefined) { + // biome-ignore lint/performance/noDelete: Delete is fine here since we're attempting to remove this fully here. delete upd.BuyRestrictionMax; } } @@ -997,6 +1004,7 @@ export class InventoryHelper { } else { // No location in request, delete it if (itemToMove.location) { + // biome-ignore lint/performance/noDelete: Delete is fine here as we're trying to remove the entire data property. delete itemToMove.location; } } @@ -1059,6 +1067,7 @@ export class InventoryHelper { } else { // Moved from slot with location to one without, clean up if (matchingInventoryItem.location) { + // biome-ignore lint/performance/noDelete: Delete is fine here as we're trying to remove the entire data property. delete matchingInventoryItem.location; } } diff --git a/project/src/helpers/ItemHelper.ts b/project/src/helpers/ItemHelper.ts index c56eb4315..107e9e539 100644 --- a/project/src/helpers/ItemHelper.ts +++ b/project/src/helpers/ItemHelper.ts @@ -1194,6 +1194,7 @@ export class ItemHelper { // In live no ammo box has the first cartridge item with a location if (location === 0) { + // biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the location. delete cartridgeItemToAdd.location; } @@ -1366,6 +1367,7 @@ export class ItemHelper { // Only one cartridge stack added, remove location property as its only used for 2 or more stacks if (location === 1) { + // biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the location. delete magazineWithChildCartridges[1].location; } } @@ -1706,6 +1708,7 @@ export class ItemHelper { if (!parentExists && item.parentId !== rootId && item.slotId !== "hideout") { item.parentId = rootId; item.slotId = "hideout"; + // biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the location. delete item.location; } } @@ -1800,7 +1803,10 @@ export class ItemHelper { */ public removeSpawnedInSessionPropertyFromItems(items: IItem[]): void { for (const item of items) { - delete item.upd.SpawnedInSession; + if (item.upd) { + // biome-ignore lint/performance/noDelete: Delete is fine here as we're removing the entire property. + delete item.upd.SpawnedInSession; + } } } } diff --git a/project/src/helpers/QuestHelper.ts b/project/src/helpers/QuestHelper.ts index f378d8e53..40a380ab0 100644 --- a/project/src/helpers/QuestHelper.ts +++ b/project/src/helpers/QuestHelper.ts @@ -253,6 +253,7 @@ export class QuestHelper { existingQuest.completedConditions = []; if (existingQuest.availableAfter) { + // biome-ignore lint/performance/noDelete: Delete is fine here as we're trying to remove the entire data property. delete existingQuest.availableAfter; } diff --git a/project/src/models/eft/common/IEmptyRequestData.ts b/project/src/models/eft/common/IEmptyRequestData.ts index 52a7b126b..86455219f 100644 --- a/project/src/models/eft/common/IEmptyRequestData.ts +++ b/project/src/models/eft/common/IEmptyRequestData.ts @@ -1 +1,2 @@ +// biome-ignore lint/complexity/noBannedTypes: Empty request is empty, this is fine. export type IEmptyRequestData = {}; diff --git a/project/src/models/eft/player/IPlayerIncrementSkillLevelRequestData.ts b/project/src/models/eft/player/IPlayerIncrementSkillLevelRequestData.ts deleted file mode 100644 index 4c5bbfcca..000000000 --- a/project/src/models/eft/player/IPlayerIncrementSkillLevelRequestData.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { ISkills } from "@spt/models/eft/common/tables/IBotBase"; - -export interface IPlayerIncrementSkillLevelRequestData { - _id: string; - experience: number; - quests: any[]; - ragFairOffers: any[]; - builds: any[]; - items: Items; - production: Production; - skills: ISkills; - traderRelations: TraderRelations; -} - -export interface Items { - new: any[]; - change: any[]; - del: any[]; -} - -export type Production = {}; - -export type TraderRelations = {}; diff --git a/project/src/models/eft/profile/ISptProfile.ts b/project/src/models/eft/profile/ISptProfile.ts index 9bbf45164..da2b81837 100644 --- a/project/src/models/eft/profile/ISptProfile.ts +++ b/project/src/models/eft/profile/ISptProfile.ts @@ -227,10 +227,13 @@ export interface IEffects { RightLeg: IRightLeg; } +// biome-ignore lint/complexity/noBannedTypes: Not sure of typing on these for now. export type IHead = {}; +// biome-ignore lint/complexity/noBannedTypes: Not sure of typing on these for now. export type IChest = {}; +// biome-ignore lint/complexity/noBannedTypes: Not sure of typing on these for now. export type IStomach = {}; export interface ILeftArm { diff --git a/project/src/models/eft/ragfair/ISearchRequestData.ts b/project/src/models/eft/ragfair/ISearchRequestData.ts index ff3d22a20..046edf67c 100644 --- a/project/src/models/eft/ragfair/ISearchRequestData.ts +++ b/project/src/models/eft/ragfair/ISearchRequestData.ts @@ -20,7 +20,7 @@ export interface ISearchRequestData { handbookId: string; linkedSearchId: string; neededSearchId: string; - buildItems: BuildItems; + buildItems: Record; buildCount: number; tm: number; reload: number; @@ -31,5 +31,3 @@ export enum OfferOwnerType { TRADEROWNERTYPE = 1, PLAYEROWNERTYPE = 2, } - -export type BuildItems = {}; diff --git a/project/src/services/BotEquipmentModPoolService.ts b/project/src/services/BotEquipmentModPoolService.ts index 95b8a129e..fbf8a0ace 100644 --- a/project/src/services/BotEquipmentModPoolService.ts +++ b/project/src/services/BotEquipmentModPoolService.ts @@ -82,7 +82,7 @@ export class BotEquipmentModPoolService { // Check item added into array for slots, need to iterate over those const subItemDetails = this.itemHelper.getItem(itemToAdd)[1]; - const hasSubItemsToAdd = subItemDetails?._props?.Slots?.length ?? 0 > 0; + const hasSubItemsToAdd = (subItemDetails?._props?.Slots?.length ?? 0) > 0; if (hasSubItemsToAdd && !pool[subItemDetails._id]) { // Recursive call this.generatePool([subItemDetails], poolType); diff --git a/project/src/services/FenceService.ts b/project/src/services/FenceService.ts index d7dd0523c..5e698a8a0 100644 --- a/project/src/services/FenceService.ts +++ b/project/src/services/FenceService.ts @@ -165,6 +165,7 @@ export class FenceService { } // Clean up the items + // biome-ignore lint/performance/noDelete: Delete is fine here as we're getting rid of the items before updating. delete root.location; const createAssort: ICreateFenceAssortsResult = { sptItems: [], barter_scheme: {}, loyal_level_items: {} }; @@ -1115,6 +1116,8 @@ export class FenceService { continue; } + let armorWithMods = armorItemAndMods; + const modItemDbDetails = this.itemHelper.getItem(plateTpl)[1]; // Chance to remove plate @@ -1122,7 +1125,7 @@ export class FenceService { this.traderConfig.fence.chancePlateExistsInArmorPercent[modItemDbDetails._props?.armorClass ?? "3"]; if (!this.randomUtil.getChance100(plateExistsChance)) { // Remove plate from armor - armorItemAndMods = armorItemAndMods.filter( + armorWithMods = armorItemAndMods.filter( (item) => item.slotId.toLowerCase() !== plateSlot._name.toLowerCase(), ); @@ -1135,13 +1138,13 @@ export class FenceService { ); // Find items mod to apply dura changes to - const modItemToAdjust = armorItemAndMods.find( + const modItemToAdjust = armorWithMods.find( (mod) => mod.slotId.toLowerCase() === plateSlot._name.toLowerCase(), ); if (!modItemToAdjust) { this.logger.warning( - `Unable to randomise armor items ${armorItemAndMods[0]._tpl} ${plateSlot._name} slot as it cannot be found, skipping`, + `Unable to randomise armor items ${armorWithMods[0]._tpl} ${plateSlot._name} slot as it cannot be found, skipping`, ); continue; } diff --git a/project/src/services/ItemFilterService.ts b/project/src/services/ItemFilterService.ts index 35f0199c0..125cb7eec 100644 --- a/project/src/services/ItemFilterService.ts +++ b/project/src/services/ItemFilterService.ts @@ -29,7 +29,9 @@ export class ItemFilterService { */ public isItemBlacklisted(tpl: string): boolean { if (this.itemBlacklistCache.size === 0) { - this.itemConfig.blacklist.forEach((item) => this.itemBlacklistCache.add(item)); + for (const item of this.itemConfig.blacklist) { + this.itemBlacklistCache.add(item); + } } return this.itemBlacklistCache.has(tpl); @@ -42,7 +44,9 @@ export class ItemFilterService { */ public isLootableItemBlacklisted(tpl: string): boolean { if (this.lootableItemBlacklistCache.size === 0) { - this.itemConfig.lootableItemBlacklist.forEach((item) => this.itemBlacklistCache.add(item)); + for (const item of this.itemConfig.lootableItemBlacklist) { + this.itemBlacklistCache.add(item); + } } return this.lootableItemBlacklistCache.has(tpl); diff --git a/project/src/services/MailSendService.ts b/project/src/services/MailSendService.ts index 4fba93ee8..cddf662fb 100644 --- a/project/src/services/MailSendService.ts +++ b/project/src/services/MailSendService.ts @@ -350,11 +350,13 @@ export class MailSendService { // Clean up empty system data if (!message.systemData) { + // biome-ignore lint/performance/noDelete: Delete is fine here as we're trying to remove the entire data property. delete message.systemData; } // Clean up empty template id if (!message.templateId) { + // biome-ignore lint/performance/noDelete: Delete is fine here as we're trying to remove the entire data property. delete message.templateId; } @@ -458,6 +460,7 @@ export class MailSendService { // Remove empty data property if no rewards if (itemsToSendToPlayer.data.length === 0) { + // biome-ignore lint/performance/noDelete: Delete is fine here as we're trying to remove the empty data property. delete itemsToSendToPlayer.data; } } diff --git a/project/src/services/ModCompilerService.ts b/project/src/services/ModCompilerService.ts index 8dcb93788..1d7b0f775 100644 --- a/project/src/services/ModCompilerService.ts +++ b/project/src/services/ModCompilerService.ts @@ -42,7 +42,7 @@ export class ModCompilerService { } } - const hashMatches = this.modHashCacheService.calculateAndCompareHash(modName, tsFileContents); + const hashMatches = await this.modHashCacheService.calculateAndCompareHash(modName, tsFileContents); if (fileExists && hashMatches) { // Everything exists and matches, escape early @@ -51,7 +51,7 @@ export class ModCompilerService { if (!hashMatches) { // Store / update hash in json file - this.modHashCacheService.calculateAndStoreHash(modName, tsFileContents); + await this.modHashCacheService.calculateAndStoreHash(modName, tsFileContents); } return this.compile(modTypeScriptFiles, { diff --git a/project/src/services/ProfileFixerService.ts b/project/src/services/ProfileFixerService.ts index 6fb356a5d..098bf4731 100644 --- a/project/src/services/ProfileFixerService.ts +++ b/project/src/services/ProfileFixerService.ts @@ -83,25 +83,27 @@ export class ProfileFixerService { */ public checkForAndFixDialogueAttachments(fullProfile: ISptProfile): void { for (const traderDialogues of Object.values(fullProfile.dialogues)) { - for (const message of traderDialogues?.messages) { - // Skip any messages without attached items - if (!message.items?.data || !message.items?.stash) { - continue; - } + if (traderDialogues?.messages) { + for (const message of traderDialogues.messages) { + // Skip any messages without attached items + if (!message.items?.data || !message.items?.stash) { + continue; + } - // Skip any messages that don't have a stashId collision with the player's equipment ID - if (message.items?.stash !== fullProfile.characters?.pmc?.Inventory?.equipment) { - continue; - } + // Skip any messages that don't have a stashId collision with the player's equipment ID + if (message.items?.stash !== fullProfile.characters?.pmc?.Inventory?.equipment) { + continue; + } - // Otherwise we need to generate a new unique stash ID for this message's attachments - message.items.stash = this.hashUtil.generate(); - message.items.data = this.itemHelper.adoptOrphanedItems(message.items.stash, message.items.data); + // Otherwise we need to generate a new unique stash ID for this message's attachments + message.items.stash = this.hashUtil.generate(); + message.items.data = this.itemHelper.adoptOrphanedItems(message.items.stash, message.items.data); - // Because `adoptOrphanedItems` sets the slotId to `hideout`, we need to re-set it to `main` to work with mail - for (const item of message.items.data) { - if (item.slotId === "hideout") { - item.slotId = "main"; + // Because `adoptOrphanedItems` sets the slotId to `hideout`, we need to re-set it to `main` to work with mail + for (const item of message.items.data) { + if (item.slotId === "hideout") { + item.slotId = "main"; + } } } } @@ -325,15 +327,25 @@ export class ProfileFixerService { const productionRewards = quest.rewards.Started?.filter( (reward) => reward.type === QuestRewardType.PRODUCTIONS_SCHEME, ); - productionRewards?.forEach((reward) => this.verifyQuestProductionUnlock(pmcProfile, reward, quest)); + + if (productionRewards) { + for (const reward of productionRewards) { + this.verifyQuestProductionUnlock(pmcProfile, reward, quest); + } + } } // For successful quests, check for unlocks in the `Success` rewards - if (profileQuest.status == QuestStatus.Success) { + if (profileQuest.status === QuestStatus.Success) { const productionRewards = quest.rewards.Success?.filter( (reward) => reward.type === QuestRewardType.PRODUCTIONS_SCHEME, ); - productionRewards?.forEach((reward) => this.verifyQuestProductionUnlock(pmcProfile, reward, quest)); + + if (productionRewards) { + for (const reward of productionRewards) { + this.verifyQuestProductionUnlock(pmcProfile, reward, quest); + } + } } } diff --git a/project/src/services/RagfairOfferService.ts b/project/src/services/RagfairOfferService.ts index 27409da4c..96432167f 100644 --- a/project/src/services/RagfairOfferService.ts +++ b/project/src/services/RagfairOfferService.ts @@ -250,6 +250,7 @@ export class RagfairOfferService { if (firstOfferItem.upd.StackObjectsCount > firstOfferItem.upd.OriginalStackObjectsCount) { playerOffer.items[0].upd.StackObjectsCount = firstOfferItem.upd.OriginalStackObjectsCount; } + // biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the data. delete playerOffer.items[0].upd.OriginalStackObjectsCount; // Remove player offer from flea this.ragfairOfferHandler.removeOffer(playerOffer); diff --git a/project/src/services/RagfairTaxService.ts b/project/src/services/RagfairTaxService.ts index 9371b74ef..a8ee44b4e 100644 --- a/project/src/services/RagfairTaxService.ts +++ b/project/src/services/RagfairTaxService.ts @@ -68,7 +68,7 @@ export class RagfairTaxService { const requirementsPrice = requirementsValue * (sellInOnePiece ? 1 : offerItemCount); const itemTaxMult = globals.config.RagFair.communityItemTax / 100.0; - const requirementTaxMult = globals!.config.RagFair.communityRequirementTax / 100.0; + const requirementTaxMult = globals.config.RagFair.communityRequirementTax / 100.0; let itemPriceMult = Math.log10(itemWorth / requirementsPrice); let requirementPriceMult = Math.log10(requirementsPrice / itemWorth); @@ -144,39 +144,34 @@ export class RagfairTaxService { } } - if ("Dogtag" in item.upd!) { - worth *= item.upd!.Dogtag!.Level; - } + const upd = item.upd ?? {}; - if ("Key" in item.upd! && (itemTemplate._props.MaximumNumberOfUsage ?? 0) > 0) { + if (upd.Dogtag) { + worth *= upd.Dogtag.Level; + } + if (upd.Key && (itemTemplate._props?.MaximumNumberOfUsage ?? 0) > 0) { worth = - (worth / itemTemplate._props.MaximumNumberOfUsage!) * - (itemTemplate._props.MaximumNumberOfUsage! - item.upd!.Key!.NumberOfUsages); + (worth / (itemTemplate._props?.MaximumNumberOfUsage ?? 1)) * + ((itemTemplate._props?.MaximumNumberOfUsage ?? 1) - upd.Key.NumberOfUsages); } - - if ("Resource" in item.upd! && itemTemplate._props.MaxResource! > 0) { - worth = worth * 0.1 + ((worth * 0.9) / itemTemplate._props.MaxResource!) * item.upd.Resource!.Value; + if (upd.Resource && (itemTemplate._props?.MaxResource ?? 0) > 0) { + worth = worth * 0.1 + ((worth * 0.9) / (itemTemplate._props?.MaxResource ?? 1)) * upd.Resource.Value; } - - if ("SideEffect" in item.upd! && itemTemplate._props.MaxResource! > 0) { - worth = worth * 0.1 + ((worth * 0.9) / itemTemplate._props.MaxResource!) * item.upd.SideEffect!.Value; + if (upd.SideEffect && (itemTemplate._props?.MaxResource ?? 0) > 0) { + worth = worth * 0.1 + ((worth * 0.9) / (itemTemplate._props?.MaxResource ?? 1)) * upd.SideEffect.Value; } - - if ("MedKit" in item.upd! && itemTemplate._props.MaxHpResource! > 0) { - worth = (worth / itemTemplate._props.MaxHpResource!) * item.upd.MedKit!.HpResource; + if (upd.MedKit && (itemTemplate._props?.MaxHpResource ?? 0) > 0) { + worth = (worth / (itemTemplate._props?.MaxHpResource ?? 1)) * upd.MedKit.HpResource; } - - if ("FoodDrink" in item.upd! && itemTemplate._props.MaxResource! > 0) { - worth = (worth / itemTemplate._props.MaxResource!) * item.upd.FoodDrink!.HpPercent; + if (upd.FoodDrink && (itemTemplate._props?.MaxResource ?? 0) > 0) { + worth = (worth / (itemTemplate._props?.MaxResource ?? 1)) * upd.FoodDrink.HpPercent; } - - if ("Repairable" in item.upd! && itemTemplate._props.armorClass > 0) { - const num2 = 0.01 * 0.0 ** item.upd.Repairable!.MaxDurability; + if (upd.Repairable && Number(itemTemplate._props?.armorClass ?? 0) > 0) { + const num2 = 0.01 * 0.0 ** upd.Repairable.MaxDurability; worth = - worth * (item.upd.Repairable!.MaxDurability / itemTemplate._props.Durability! - num2) - + worth * (upd.Repairable.MaxDurability / (itemTemplate._props?.Durability ?? 1) - num2) - Math.floor( - itemTemplate._props.RepairCost! * - (item.upd.Repairable!.MaxDurability - item.upd.Repairable!.Durability), + (itemTemplate._props?.RepairCost ?? 0) * (upd.Repairable.MaxDurability - upd.Repairable.Durability), ); } diff --git a/project/src/services/cache/ModHashCacheService.ts b/project/src/services/cache/ModHashCacheService.ts index 388baee5a..9cd73f98f 100644 --- a/project/src/services/cache/ModHashCacheService.ts +++ b/project/src/services/cache/ModHashCacheService.ts @@ -38,14 +38,14 @@ export class ModHashCacheService { return this.getStoredValue(modName) === hash; } - public calculateAndCompareHash(modName: string, modContent: string): boolean { - const generatedHash = this.hashUtil.generateSha1ForData(modContent); + public async calculateAndCompareHash(modName: string, modContent: string): Promise { + const generatedHash = await this.hashUtil.generateSha1ForDataAsync(modContent); return this.matchWithStoredHash(modName, generatedHash); } - public calculateAndStoreHash(modName: string, modContent: string): void { - const generatedHash = this.hashUtil.generateSha1ForData(modContent); + public async calculateAndStoreHash(modName: string, modContent: string): Promise { + const generatedHash = await this.hashUtil.generateSha1ForDataAsync(modContent); this.storeValue(modName, generatedHash); } diff --git a/project/src/tools/ItemTplGenerator/ItemTplGenerator.ts b/project/src/tools/ItemTplGenerator/ItemTplGenerator.ts index 085d77590..6893d635a 100644 --- a/project/src/tools/ItemTplGenerator/ItemTplGenerator.ts +++ b/project/src/tools/ItemTplGenerator/ItemTplGenerator.ts @@ -350,14 +350,16 @@ export class ItemTplGenerator { } private cleanCaliber(ammoCaliber: string): string { - ammoCaliber = ammoCaliber.replace("CALIBER", ""); - ammoCaliber = ammoCaliber.replace("PARA", ""); - ammoCaliber = ammoCaliber.replace("NATO", ""); + let ammoCaliberToClean = ammoCaliber; + + ammoCaliberToClean = ammoCaliberToClean.replace("CALIBER", ""); + ammoCaliberToClean = ammoCaliberToClean.replace("PARA", ""); + ammoCaliberToClean = ammoCaliberToClean.replace("NATO", ""); // Special case for 45ACP - ammoCaliber = ammoCaliber.replace("1143X23ACP", "45ACP"); + ammoCaliberToClean = ammoCaliberToClean.replace("1143X23ACP", "45ACP"); - return ammoCaliber; + return ammoCaliberToClean; } private getAmmoBoxPrefix(item: ITemplateItem): string { diff --git a/project/tests/utils/collections/queue/Queue.test.ts b/project/tests/utils/collections/queue/Queue.test.ts deleted file mode 100644 index 02688880f..000000000 --- a/project/tests/utils/collections/queue/Queue.test.ts +++ /dev/null @@ -1,55 +0,0 @@ -import "reflect-metadata"; -import { Queue } from "@spt/utils/collections/queue/Queue"; -import { describe, expect, it } from "vitest"; - -describe("LinkedList", () => { - describe("enqueue", () => { - const queue = new Queue(); - queue.enqueue(420); - queue.enqueue(69); - queue.enqueue(8008135); - queue.enqueue(1337); - - it("adds elements to the end of the queue", () => { - expect(queue.peek()).toEqual(420); - expect(queue.length).toEqual(4); - }); - }); - - describe("enqueueAll", () => { - const queue = new Queue(); - queue.enqueueAll([420, 69, 8008135, 1337]); - - it("iterates the array and adds each element to the end of the queue", () => { - expect(queue.peek()).toEqual(420); - expect(queue.length).toEqual(4); - }); - }); - - describe("dequeue", () => { - const queue = new Queue(); - queue.enqueueAll([420, 69, 8008135, 1337]); - - it("removes the first element and return it's value", () => { - expect(queue.dequeue()).toEqual(420); - expect(queue.peek()).toEqual(69); - expect(queue.length).toEqual(3); - - expect(queue.dequeue()).toEqual(69); - expect(queue.peek()).toEqual(8008135); - expect(queue.length).toEqual(2); - - expect(queue.dequeue()).toEqual(8008135); - expect(queue.peek()).toEqual(1337); - expect(queue.length).toEqual(1); - - expect(queue.dequeue()).toEqual(1337); - expect(queue.peek()).toEqual(undefined); - expect(queue.length).toEqual(0); - - expect(queue.dequeue()).toEqual(undefined); - expect(queue.peek()).toEqual(undefined); - expect(queue.length).toEqual(0); - }); - }); -});