From ca931165b2d96fa9a86293c221171a6af5d18c12 Mon Sep 17 00:00:00 2001 From: Kaeno Date: Thu, 6 Apr 2023 16:23:52 +0000 Subject: [PATCH] Fix: Fixed some ragfair issues (!86) Fixed bug with removing offers from flee and item returning too quickly. Fixed bug with error message that would show on removal of offers. Expose property expireSeconds in ragfair.json. Co-authored-by: Kaeno <> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/86 Co-authored-by: Kaeno Co-committed-by: Kaeno --- project/assets/configs/ragfair.json | 3 ++- project/src/controllers/RagfairController.ts | 6 +++--- project/src/models/spt/config/IRagfairConfig.ts | 2 ++ project/src/services/RagfairOfferService.ts | 6 ++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/project/assets/configs/ragfair.json b/project/assets/configs/ragfair.json index 32ffa038..78dc3f7c 100644 --- a/project/assets/configs/ragfair.json +++ b/project/assets/configs/ragfair.json @@ -16,7 +16,8 @@ "reputation": { "gain": 0.0000002, "loss": 0.0000002 - } + }, + "expireSeconds": 71 }, "traders": { "54cb50c76803fa8b248b4571": true, diff --git a/project/src/controllers/RagfairController.ts b/project/src/controllers/RagfairController.ts index f5f90c98..e67bd6ed 100644 --- a/project/src/controllers/RagfairController.ts +++ b/project/src/controllers/RagfairController.ts @@ -501,10 +501,10 @@ export class RagfairController return this.httpResponse.appendErrorToOutput(this.eventOutputHolder.getOutput(sessionID), this.localisationService.getText("ragfair-offer_not_found_in_profile_short")); } - const differenceInMins = (offers[index].endTime - this.timeUtil.getTimestamp()) / 6000; - if (differenceInMins > 1) + const differenceInSeconds = (offers[index].endTime - this.timeUtil.getTimestamp()); + if (differenceInSeconds > this.ragfairConfig.sell.expireSeconds)// expireSeconds Default is 71 seconds { - const newEndTime = 11 + this.timeUtil.getTimestamp(); + const newEndTime = this.ragfairConfig.sell.expireSeconds + this.timeUtil.getTimestamp(); offers[index].endTime = Math.round(newEndTime); } diff --git a/project/src/models/spt/config/IRagfairConfig.ts b/project/src/models/spt/config/IRagfairConfig.ts index b49d21e0..f62e0464 100644 --- a/project/src/models/spt/config/IRagfairConfig.ts +++ b/project/src/models/spt/config/IRagfairConfig.ts @@ -25,6 +25,8 @@ export interface Sell reputation: Reputation /** How many hours are simulated to figure out if player offer was sold */ simulatedSellHours: number + /**Seconds from clicking remove to remove offer from market */ + expireSeconds: number } export interface Chance diff --git a/project/src/services/RagfairOfferService.ts b/project/src/services/RagfairOfferService.ts index c18d11f8..2dfcc459 100644 --- a/project/src/services/RagfairOfferService.ts +++ b/project/src/services/RagfairOfferService.ts @@ -215,8 +215,8 @@ export class RagfairOfferService this.addOfferToExpired(staleOffer); } - // Handle player offer - items need returning/XP adjusting - if (isPlayer) + // Handle player offer - items need returning/XP adjusting. Checking if offer has actually expired or not. + if (isPlayer && staleOffer.endTime <= this.timeUtil.getTimestamp()) { // TODO: something feels wrong, func returns ItemEventRouterResponse but we dont pass it back to caller? this.returnPlayerOffer(staleOffer); @@ -254,8 +254,6 @@ export class RagfairOfferService this.ragfairServerHelper.returnItems(profile.aid, offer.items); profile.RagfairInfo.offers.splice(offerIndex, 1); - this.removeOfferById(offer._id); - return this.eventOutputHolder.getOutput(sessionID); } }