From e1b97f972d89f121278ebd53f14cc4e48687b627 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Sat, 5 Apr 2025 21:07:12 +0200 Subject: [PATCH 1/2] fix: refuse to add items non-fatally This is needed to complete to the railjack quest when already owning a railjack --- src/services/inventoryService.ts | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 4a711c6c..e75fd880 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -1071,11 +1071,12 @@ const addCrewShip = ( inventoryChanges: IInventoryChanges = {} ): IInventoryChanges => { if (inventory.CrewShips.length != 0) { - throw new Error("refusing to add CrewShip because account already has one"); + logger.error("refusing to add CrewShip because account already has one"); + } else { + const index = inventory.CrewShips.push({ ItemType: typeName }) - 1; + inventoryChanges.CrewShips ??= []; + inventoryChanges.CrewShips.push(inventory.CrewShips[index].toJSON()); } - const index = inventory.CrewShips.push({ ItemType: typeName }) - 1; - inventoryChanges.CrewShips ??= []; - inventoryChanges.CrewShips.push(inventory.CrewShips[index].toJSON()); return inventoryChanges; }; @@ -1085,11 +1086,12 @@ const addCrewShipHarness = ( inventoryChanges: IInventoryChanges = {} ): IInventoryChanges => { if (inventory.CrewShipHarnesses.length != 0) { - throw new Error("refusing to add CrewShipHarness because account already has one"); + logger.error("refusing to add CrewShipHarness because account already has one"); + } else { + const index = inventory.CrewShipHarnesses.push({ ItemType: typeName }) - 1; + inventoryChanges.CrewShipHarnesses ??= []; + inventoryChanges.CrewShipHarnesses.push(inventory.CrewShipHarnesses[index].toJSON()); } - const index = inventory.CrewShipHarnesses.push({ ItemType: typeName }) - 1; - inventoryChanges.CrewShipHarnesses ??= []; - inventoryChanges.CrewShipHarnesses.push(inventory.CrewShipHarnesses[index].toJSON()); return inventoryChanges; }; @@ -1099,11 +1101,12 @@ const addMotorcycle = ( inventoryChanges: IInventoryChanges = {} ): IInventoryChanges => { if (inventory.Motorcycles.length != 0) { - throw new Error("refusing to add Motorcycle because account already has one"); + logger.error("refusing to add Motorcycle because account already has one"); + } else { + const index = inventory.Motorcycles.push({ ItemType: typeName }) - 1; + inventoryChanges.Motorcycles ??= []; + inventoryChanges.Motorcycles.push(inventory.Motorcycles[index].toJSON()); } - const index = inventory.Motorcycles.push({ ItemType: typeName }) - 1; - inventoryChanges.Motorcycles ??= []; - inventoryChanges.Motorcycles.push(inventory.Motorcycles[index].toJSON()); return inventoryChanges; }; -- 2.47.2 From 9f38b1cc87178f652e0df197ec233a5be0b13879 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Sat, 5 Apr 2025 21:20:24 +0200 Subject: [PATCH 2/2] use warn instead of error --- src/services/inventoryService.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index e75fd880..95e98644 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -1071,7 +1071,7 @@ const addCrewShip = ( inventoryChanges: IInventoryChanges = {} ): IInventoryChanges => { if (inventory.CrewShips.length != 0) { - logger.error("refusing to add CrewShip because account already has one"); + logger.warn("refusing to add CrewShip because account already has one"); } else { const index = inventory.CrewShips.push({ ItemType: typeName }) - 1; inventoryChanges.CrewShips ??= []; @@ -1086,7 +1086,7 @@ const addCrewShipHarness = ( inventoryChanges: IInventoryChanges = {} ): IInventoryChanges => { if (inventory.CrewShipHarnesses.length != 0) { - logger.error("refusing to add CrewShipHarness because account already has one"); + logger.warn("refusing to add CrewShipHarness because account already has one"); } else { const index = inventory.CrewShipHarnesses.push({ ItemType: typeName }) - 1; inventoryChanges.CrewShipHarnesses ??= []; @@ -1101,7 +1101,7 @@ const addMotorcycle = ( inventoryChanges: IInventoryChanges = {} ): IInventoryChanges => { if (inventory.Motorcycles.length != 0) { - logger.error("refusing to add Motorcycle because account already has one"); + logger.warn("refusing to add Motorcycle because account already has one"); } else { const index = inventory.Motorcycles.push({ ItemType: typeName }) - 1; inventoryChanges.Motorcycles ??= []; -- 2.47.2