From 129fe0dc97259c7b8acb4276ffcaa7720bb75d7d Mon Sep 17 00:00:00 2001 From: Dev Date: Wed, 19 Jul 2023 11:00:34 +0100 Subject: [PATCH] Localise server errors --- project/assets/database/locales/server/en.json | 11 +++++++++++ project/src/controllers/CustomizationController.ts | 4 ++-- project/src/controllers/LocationController.ts | 2 +- project/src/generators/BotEquipmentModGenerator.ts | 2 +- project/src/helpers/InventoryHelper.ts | 6 +++--- project/src/helpers/QuestHelper.ts | 2 +- project/src/helpers/RagfairOfferHelper.ts | 4 +++- project/src/services/BotEquipmentModPoolService.ts | 4 +++- project/src/services/RepairService.ts | 4 +++- .../src/services/TraderPurchasePersisterService.ts | 4 +++- 10 files changed, 31 insertions(+), 12 deletions(-) diff --git a/project/assets/database/locales/server/en.json b/project/assets/database/locales/server/en.json index 000815d8..444e5398 100644 --- a/project/assets/database/locales/server/en.json +++ b/project/assets/database/locales/server/en.json @@ -44,8 +44,12 @@ "bot-weapon_missing_magazine_or_chamber": "Weapon with tpl: %s has no magazine or chamber", "bot-weapon_missing_mod_slot": "Slot: {{modSlot}}' does not exist for weapon: {{weaponId}} {{weaponName}} on {{botRole}}", "bot-weapons_required_slot_missing_item": "Required slot '{{modSlot}}' on {{modName}} {{slotId}} was empty on {{botRole}}", + "bot-item_missing_props_property": "Item {{itemTpl}} {{name}} is missing a _props property", + "bot-unable_to_fill_camora_slot_mod_pool_empty": "Unable to fill weapon camora slot for {{weaponId}} {{weaponName}} mod pool for item was empty", "client_request": "[Client Request] %s", "customisation-item_already_purchased": "Clothing item {{itemId}} {{itemName}} already purchased", + "customisation-unable_to_find_suit_by_id": "Unable to find trader suit offer with id: %s", + "customisation-unable_to_find_clothing_item_in_inventory": "Clothing item not found in inventory with id: %s", "dialog-missing_item_template": "Unable to find item tpl {{tpl}} in db, cannot send message of type {{type}}, skipping", "event-unhandled_event": "[UNHANDLED EVENT] %s", "executing_startup_callbacks": "Server: executing startup callbacks...", @@ -87,6 +91,8 @@ "inventory-unable_to_find_item": "getExaminedItemTpl() Unable to find item with tpl: %s in database or flea", "inventory-unable_to_find_stash": "No stash found", "inventory-return_default_size": "Defaulting item %s to size 1x1", + "inventory-item_missing_props_property": "Item tpl: {{itemTpl}} name: {{itemName}} is missing a props property, a size for it cannot be acquired", + "inventory-get_item_size_item_not_found_by_tpl": "getSizeByInventoryItemHash() Item with tpl: %s not found", "item-durability_value_invalid_use_default": "getRepairableItemQualityValue() weapon tpl: %s durability value is invalid, defaulting to 1", "linux_use_priviledged_port_non_root": "Non-root processes cannot bind to ports below 1024", "location-containers_generated_success": "A total of %s static containers generated", @@ -97,6 +103,7 @@ "location-preset_not_found": "preset not found for {{tpl}}, defaultPreset: {{defaultId}} name: {{defaultName}}, parentId: {{parentId}}", "location-spawn_point_count_requested_vs_found": "{{requested}} spawnpoints were requested while {{found}} are available {{mapName}}", "location-unable_to_reparent_item": "createItem() failed, unable to reparent {{tpl}}, parentId: {{parentId}}", + "location-unable_to_find_airdrop_drop_config_of_type": "Unable to find airdrop config settings for type: %s, falling back to drop type: mixed ", "loot-item_missing_parentid": "Item: %s lacks a parentId value, unable to use item as loot", "mod-send_bundle_url": "[BUNDLE]: %s", "modloader-checked": "checked", @@ -141,6 +148,7 @@ "quest-no_skill_found": "Skill %s not found", "quest-handover_wrong_item": "Unable to hand item in for quest {{questId}}, expected tpl: {{requiredTpl}} but handed in: {{handedInTpl}}", "quest-reward_type_not_handled": "Quest reward type: {{rewardType}} not handled for quest: {{questId}} name: {{questName}}", + "quest-unable_to_find_compare_condition": "Unrecognised Comparison Method: %s", "ragfair-invalid_player_offer_request": "Unable to place offer, request is invalid", "ragfair-missing_barter_scheme": "generateFleaOffersForTrader() Failed to find barterScheme for item id: {{itemId}} tpl: {{tpl}} on {{name}}", "ragfair-no_trader_assorts_cant_generate_flea_offers": "Unable to generate flea offers for trader %s, no assort found", @@ -154,6 +162,7 @@ "ragfair-offer_no_longer_exists": "Offer no longer exists", "ragfair-unable_to_purchase_0_count_item": "Unable to purchase item: %s with a count of 0", "ragfair-unable_to_place_offer_with_no_requirements": "Unable to place offer with no requirements", + "ragfair-unable_to_find_locale_by_key": "Unable to find EFT locale with key: %s", "repeatable-accepted_repeatable_quest_not_found_in_active_quests": "Accepted a repeatable quest: %s which could not be found in the activeQuests array. Please report this bug", "repeatable-completion_quest_whitelist_too_small_or_blacklist_too_restrictive": "Generate Completion Quest: No items remain. Either Whitelist is too small or Blacklist too restrictive", "repeatable-difficulty_was_nan": "Repeatable Reward Generation: Difficulty was NaN. Setting to 1.", @@ -163,6 +172,7 @@ "repeatable-unable_to_accept_quest_see_log": "Unable to accept quest, see server log for details", "repeatable-unable_to_accept_quest_starting_message_not_found": "Unable to accept quest: {{questId}} cant find quest started message text with id: {{messageId}}", "route_onupdate_no_response": "onUpdate: %s route doesn't report success or fail", + "repair-unable_to_find_item_in_db": "Unable to repair item: %s, cannot find in items db, cannot add repair skill points", "scav-missing_karma_level_getting_default": "getScavKarmaLevel() failed, unable to find fence in profile.traderInfo. Defaulting to karma level 0", "scav-missing_karma_settings": "Unable to get karma settings for level %s", "scheduled_event_failed_to_run": "Scheduled event: '%s' failed to run successfully.", @@ -199,6 +209,7 @@ "trader-missing_durability_threshold_value": "Unable to find durability threshold value for trader: {{traderId}}, falling back to default of: {{value}}", "trader-missing_trader_details_using_default_refresh_time": "Trader: {{traderId}} not found, generating temp entry with default refresh time of: {{updateTime}}", "trader-price_multipler_is_zero_use_default": "traderPriceMultipler was 0, this is invalid, setting to 0.01", + "trader-unable_to_delete_stale_purchases": "Unable to process trader purchases in profile: {{profileId}} as trader: {{traderId}} cannot be found, skipping", "unhandled_response": "[UNHANDLED][%s]", "unknown_request": "Unknown request!", "watermark-commercial_use_prohibited": "Commercial use is prohibited", diff --git a/project/src/controllers/CustomizationController.ts b/project/src/controllers/CustomizationController.ts index 963dafc2..449851a7 100644 --- a/project/src/controllers/CustomizationController.ts +++ b/project/src/controllers/CustomizationController.ts @@ -95,7 +95,7 @@ export class CustomizationController const traderOffer = this.getTraderClothingOffer(sessionId, buyClothingRequest.offer); if (!traderOffer) { - this.logger.error(`Unable to find trader suit offer with id: ${buyClothingRequest.offer}`); + this.logger.error(this.localisationService.getText("customisation-unable_to_find_suit_by_id", buyClothingRequest.offer)); return output; } @@ -161,7 +161,7 @@ export class CustomizationController const relatedItem = pmcData.Inventory.items.find(x => x._id === clothingItem.id); if (!relatedItem) { - this.logger.error(`Clothing item not found in inventory with id: ${clothingItem.id}`); + this.logger.error(this.localisationService.getText("customisation-unable_to_find_clothing_item_in_inventory", clothingItem.id)); return; } diff --git a/project/src/controllers/LocationController.ts b/project/src/controllers/LocationController.ts index 7779d2d6..86247078 100644 --- a/project/src/controllers/LocationController.ts +++ b/project/src/controllers/LocationController.ts @@ -184,7 +184,7 @@ export class LocationController let lootSettingsByType = this.airdropConfig.loot[airdropType]; if (!lootSettingsByType) { - this.logger.error(`Unable to find airdrop config settings for type: ${airdropType}, falling back to mixed`); + this.logger.error(this.localisationService.getText("location-unable_to_find_airdrop_drop_config_of_type", airdropType)); lootSettingsByType = this.airdropConfig.loot[AirdropTypeEnum.MIXED]; } diff --git a/project/src/generators/BotEquipmentModGenerator.ts b/project/src/generators/BotEquipmentModGenerator.ts index 46cdf2e9..f169da9b 100644 --- a/project/src/generators/BotEquipmentModGenerator.ts +++ b/project/src/generators/BotEquipmentModGenerator.ts @@ -758,7 +758,7 @@ export class BotEquipmentModGenerator if (!itemModPool) { - this.logger.error(`mod pool for item ${parentTemplate._name} was empty, weapon gen will fail`); + this.logger.error(this.localisationService.getText("bot-unable_to_fill_camora_slot_mod_pool_empty", {weaponId: parentTemplate._id, weaponName: parentTemplate._name})); } let exhaustableModPool = null; diff --git a/project/src/helpers/InventoryHelper.ts b/project/src/helpers/InventoryHelper.ts index b5327864..6ae5c9ff 100644 --- a/project/src/helpers/InventoryHelper.ts +++ b/project/src/helpers/InventoryHelper.ts @@ -549,10 +549,10 @@ export class InventoryHelper this.logger.error(this.localisationService.getText("inventory-invalid_item_missing_from_db", itemTpl)); } - // item found but no _props property + // Item found but no _props property if (tmpItem && !tmpItem._props) { - this.logger.error(`Item ${itemTpl} ${tmpItem?._name} is missing a props field, a size for it cannot be acquired`); + this.localisationService.getText("inventory-item_missing_props_property", {itemTpl: itemTpl, itemName: tmpItem?._name}); } // No item object or getItem() returned false @@ -612,7 +612,7 @@ export class InventoryHelper const itemResult = this.itemHelper.getItem(item._tpl); if (!itemResult[0]) { - this.logger.error(`getSizeByInventoryItemHash() Item with tpl: ${item._tpl} not found`); + this.logger.error(this.localisationService.getText("inventory-get_item_size_item_not_found_by_tpl", item._tpl)); } const itm = itemResult[1]; diff --git a/project/src/helpers/QuestHelper.ts b/project/src/helpers/QuestHelper.ts index fa1399f8..2f20b050 100644 --- a/project/src/helpers/QuestHelper.ts +++ b/project/src/helpers/QuestHelper.ts @@ -95,7 +95,7 @@ export class QuestHelper case "=": return playerLevel === condition._props.value; default: - this.logger.error(`Unrecognised Comparison Method: ${condition._props.compareMethod}`); + this.logger.error(this.localisationService.getText("quest-unable_to_find_compare_condition", condition._props.compareMethod)); return false; } } diff --git a/project/src/helpers/RagfairOfferHelper.ts b/project/src/helpers/RagfairOfferHelper.ts index 8e7107ef..0fcec77f 100644 --- a/project/src/helpers/RagfairOfferHelper.ts +++ b/project/src/helpers/RagfairOfferHelper.ts @@ -20,6 +20,7 @@ import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; import { LocaleService } from "../services/LocaleService"; +import { LocalisationService } from "../services/LocalisationService"; import { RagfairOfferService } from "../services/RagfairOfferService"; import { HashUtil } from "../utils/HashUtil"; import { TimeUtil } from "../utils/TimeUtil"; @@ -58,6 +59,7 @@ export class RagfairOfferHelper @inject("RagfairHelper") protected ragfairHelper: RagfairHelper, @inject("RagfairOfferService") protected ragfairOfferService: RagfairOfferService, @inject("LocaleService") protected localeService: LocaleService, + @inject("LocalisationService") protected localisationService: LocalisationService, @inject("ConfigServer") protected configServer: ConfigServer ) { @@ -419,7 +421,7 @@ export class RagfairOfferHelper const soldMessageLocaleGuid = globalLocales[RagfairOfferHelper.goodSoldTemplate]; if (!soldMessageLocaleGuid) { - this.logger.error(`Unable to find locale with key of ${RagfairOfferHelper.goodSoldTemplate}`); + this.logger.error(this.localisationService.getText("ragfair-unable_to_find_locale_by_key", RagfairOfferHelper.goodSoldTemplate)); } // Used to replace tokens in sold message sent to player diff --git a/project/src/services/BotEquipmentModPoolService.ts b/project/src/services/BotEquipmentModPoolService.ts index 67ebc774..fbcc424e 100644 --- a/project/src/services/BotEquipmentModPoolService.ts +++ b/project/src/services/BotEquipmentModPoolService.ts @@ -10,6 +10,7 @@ import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { VFS } from "../utils/VFS"; +import { LocalisationService } from "./LocalisationService"; /** Store a mapping between weapons, their slots and the items that fit those slots */ @injectable() @@ -26,6 +27,7 @@ export class BotEquipmentModPoolService @inject("VFS") protected vfs: VFS, @inject("ItemHelper") protected itemHelper: ItemHelper, @inject("DatabaseServer") protected databaseServer: DatabaseServer, + @inject("LocalisationService") protected localisationService: LocalisationService, @inject("ConfigServer") protected configServer: ConfigServer ) { @@ -44,7 +46,7 @@ export class BotEquipmentModPoolService { if (!item._props) { - this.logger.error(`Item ${item._id} ${item._name} is missing a _props property`); + this.logger.error(this.localisationService.getText("bot-item_missing_props_property", {itemTpl: item._id, name: item._name})); continue; } diff --git a/project/src/services/RepairService.ts b/project/src/services/RepairService.ts index 07df207a..83e0042b 100644 --- a/project/src/services/RepairService.ts +++ b/project/src/services/RepairService.ts @@ -21,6 +21,7 @@ import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { RandomUtil } from "../utils/RandomUtil"; +import { LocalisationService } from "./LocalisationService"; import { PaymentService } from "./PaymentService"; @injectable() @@ -37,6 +38,7 @@ export class RepairService @inject("WeightedRandomHelper") protected weightedRandomHelper: WeightedRandomHelper, @inject("PaymentService") protected paymentService: PaymentService, @inject("RepairHelper") protected repairHelper: RepairHelper, + @inject("LocalisationService") protected localisationService: LocalisationService, @inject("ConfigServer") protected configServer: ConfigServer ) { @@ -156,7 +158,7 @@ export class RepairService const itemDetails = this.itemHelper.getItem(repairDetails.repairedItem._tpl); if (!itemDetails[0]) { - this.logger.error(`Unable to find item ${repairDetails.repairedItem._tpl} in items db, cannot add skill points`); + this.logger.error(this.localisationService.getText("repair-unable_to_find_item_in_db", repairDetails.repairedItem._tpl)); return; } diff --git a/project/src/services/TraderPurchasePersisterService.ts b/project/src/services/TraderPurchasePersisterService.ts index c6b60e17..76de725b 100644 --- a/project/src/services/TraderPurchasePersisterService.ts +++ b/project/src/services/TraderPurchasePersisterService.ts @@ -7,6 +7,7 @@ import { ITraderConfig } from "../models/spt/config/ITraderConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { TimeUtil } from "../utils/TimeUtil"; +import { LocalisationService } from "./LocalisationService"; /** * Help with storing limited item purchases from traders in profile to persist them over server restarts @@ -20,6 +21,7 @@ export class TraderPurchasePersisterService @inject("WinstonLogger") protected logger: ILogger, @inject("TimeUtil") protected timeUtil: TimeUtil, @inject("ProfileHelper") protected profileHelper: ProfileHelper, + @inject("LocalisationService") protected localisationService: LocalisationService, @inject("ConfigServer") protected configServer: ConfigServer ) { @@ -96,7 +98,7 @@ export class TraderPurchasePersisterService const traderUpdateDetails = this.traderConfig.updateTime.find(x => x.traderId === traderId); if (!traderUpdateDetails) { - this.logger.error(`Unable to process trader purchases in profile: ${profile.info.id} as trader: ${traderId} cannot be found`); + this.logger.error(this.localisationService.getText("trader-unable_to_delete_stale_purchases", {profileId: profile.info.id, traderId: traderId})); continue; }