From 8996ec7912d6144228e649232bc5cbde9b07d1a1 Mon Sep 17 00:00:00 2001 From: VoltPrime Date: Tue, 11 Nov 2025 16:58:25 -0500 Subject: [PATCH 1/3] fix: selling items in old builds --- src/controllers/api/sellController.ts | 37 +++++++++++++++++++-------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/controllers/api/sellController.ts b/src/controllers/api/sellController.ts index b32d2aa4..20af1f37 100644 --- a/src/controllers/api/sellController.ts +++ b/src/controllers/api/sellController.ts @@ -25,11 +25,23 @@ export const sellController: RequestHandler = async (req, res) => { //console.log(JSON.stringify(payload, null, 2)); const accountId = await getAccountIdForRequest(req); const requiredFields = new Set(); - if (payload.SellCurrency == "SC_RegularCredits") { + let sellCurrency = "SC_RegularCredits"; + if (payload.SellCurrency) { + sellCurrency = payload.SellCurrency; + } + if (payload.SellForFusionPoints || payload.SellForPrimeBucks) { + if (payload.SellForFusionPoints) { + sellCurrency = "SC_FusionPoints"; + } + if (payload.SellForPrimeBucks) { + sellCurrency = "SC_PrimeBucks"; + } + } + if (sellCurrency == "SC_RegularCredits") { requiredFields.add("RegularCredits"); - } else if (payload.SellCurrency == "SC_FusionPoints") { + } else if (sellCurrency == "SC_FusionPoints") { requiredFields.add("FusionPoints"); - } else if (payload.SellCurrency == "SC_CrewShipFusionPoints") { + } else if (sellCurrency == "SC_CrewShipFusionPoints") { requiredFields.add("CrewShipFusionPoints"); } else { requiredFields.add("MiscItems"); @@ -83,27 +95,27 @@ export const sellController: RequestHandler = async (req, res) => { const inventory = await getInventory(accountId, Array.from(requiredFields).join(" ")); // Give currency - if (payload.SellCurrency == "SC_RegularCredits") { + if (sellCurrency == "SC_RegularCredits") { inventory.RegularCredits += payload.SellPrice; - } else if (payload.SellCurrency == "SC_FusionPoints") { + } else if (sellCurrency == "SC_FusionPoints") { addFusionPoints(inventory, payload.SellPrice); - } else if (payload.SellCurrency == "SC_CrewShipFusionPoints") { + } else if (sellCurrency == "SC_CrewShipFusionPoints") { addCrewShipFusionPoints(inventory, payload.SellPrice); - } else if (payload.SellCurrency == "SC_PrimeBucks") { + } else if (sellCurrency == "SC_PrimeBucks") { addMiscItems(inventory, [ { ItemType: "/Lotus/Types/Items/MiscItems/PrimeBucks", ItemCount: payload.SellPrice } ]); - } else if (payload.SellCurrency == "SC_DistillPoints") { + } else if (sellCurrency == "SC_DistillPoints") { addMiscItems(inventory, [ { ItemType: "/Lotus/Types/Items/MiscItems/DistillPoints", ItemCount: payload.SellPrice } ]); - } else if (payload.SellCurrency == "SC_Resources") { + } else if (sellCurrency == "SC_Resources") { // Will add appropriate MiscItems from CrewShipWeapons or CrewShipWeaponSkins } else { throw new Error("Unknown SellCurrency: " + payload.SellCurrency); @@ -218,7 +230,7 @@ export const sellController: RequestHandler = async (req, res) => { } else { const index = inventory.CrewShipWeapons.findIndex(x => x._id.equals(sellItem.String)); if (index != -1) { - if (payload.SellCurrency == "SC_Resources") { + if (sellCurrency == "SC_Resources") { refundPartialBuildCosts(inventory, inventory.CrewShipWeapons[index].ItemType, inventoryChanges); } inventory.CrewShipWeapons.splice(index, 1); @@ -241,7 +253,7 @@ export const sellController: RequestHandler = async (req, res) => { } else { const index = inventory.CrewShipWeaponSkins.findIndex(x => x._id.equals(sellItem.String)); if (index != -1) { - if (payload.SellCurrency == "SC_Resources") { + if (sellCurrency == "SC_Resources") { refundPartialBuildCosts( inventory, inventory.CrewShipWeaponSkins[index].ItemType, @@ -355,6 +367,9 @@ interface ISellRequest { | "SC_Resources" | "somethingelsewemightnotknowabout"; buildLabel: string; + // These are used in old builds (undetermined where it changed) instead of SellCurrency + SellForPrimeBucks?: boolean; + SellForFusionPoints?: boolean; } interface ISellItem { -- 2.49.1 From 9c70e90db6aa62248ac8112fa9ae768a8ea239fd Mon Sep 17 00:00:00 2001 From: VoltPrime Date: Tue, 11 Nov 2025 17:03:13 -0500 Subject: [PATCH 2/3] Only check legacy conditions if SellCurrency is absent --- src/controllers/api/sellController.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/controllers/api/sellController.ts b/src/controllers/api/sellController.ts index 20af1f37..0b86c16a 100644 --- a/src/controllers/api/sellController.ts +++ b/src/controllers/api/sellController.ts @@ -28,13 +28,14 @@ export const sellController: RequestHandler = async (req, res) => { let sellCurrency = "SC_RegularCredits"; if (payload.SellCurrency) { sellCurrency = payload.SellCurrency; - } - if (payload.SellForFusionPoints || payload.SellForPrimeBucks) { - if (payload.SellForFusionPoints) { - sellCurrency = "SC_FusionPoints"; - } - if (payload.SellForPrimeBucks) { - sellCurrency = "SC_PrimeBucks"; + } else { + if (payload.SellForFusionPoints || payload.SellForPrimeBucks) { + if (payload.SellForFusionPoints) { + sellCurrency = "SC_FusionPoints"; + } + if (payload.SellForPrimeBucks) { + sellCurrency = "SC_PrimeBucks"; + } } } if (sellCurrency == "SC_RegularCredits") { @@ -358,7 +359,7 @@ interface ISellRequest { WeaponSkins?: ISellItem[]; // SNS specific field }; SellPrice: number; - SellCurrency: + SellCurrency?: | "SC_RegularCredits" | "SC_PrimeBucks" | "SC_FusionPoints" -- 2.49.1 From bc18f4e656f770a8fa3d42910628a768f02c6ff3 Mon Sep 17 00:00:00 2001 From: VoltPrime Date: Wed, 12 Nov 2025 17:22:43 -0500 Subject: [PATCH 3/3] run fix --- src/controllers/api/sellController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/api/sellController.ts b/src/controllers/api/sellController.ts index 0b86c16a..4b33e4be 100644 --- a/src/controllers/api/sellController.ts +++ b/src/controllers/api/sellController.ts @@ -369,7 +369,7 @@ interface ISellRequest { | "somethingelsewemightnotknowabout"; buildLabel: string; // These are used in old builds (undetermined where it changed) instead of SellCurrency - SellForPrimeBucks?: boolean; + SellForPrimeBucks?: boolean; SellForFusionPoints?: boolean; } -- 2.49.1