Actually fixed so that multiple profiles no longer share trader buy limits (!276)
This fixes a bug I found that the server uses partially old logic when using the ``traderConfig.persistPurchaseDataInProfile`` Now it works fine for multiple profiles. How to test before and after ``` start server make dev account buy something trade limited like ASH12 ammo. (Buy all) make new dev account try to buy same thing ``` Before it gave the user the error that you've already reached the limit. Even when you had bought nothing on that profile. Now the trader properly sells you the stuff, with your own profile limit. Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/276 Co-authored-by: Leaves <mwarciel@gmail.com> Co-committed-by: Leaves <mwarciel@gmail.com>
This commit is contained in:
parent
4bb5e3de43
commit
efb69d7148
@ -103,7 +103,7 @@ export class TradeHelper
|
|||||||
items: [{ itemId: buyRequestData.item_id, count: buyCount }],
|
items: [{ itemId: buyRequestData.item_id, count: buyCount }],
|
||||||
traderId: buyRequestData.tid,
|
traderId: buyRequestData.tid,
|
||||||
};
|
};
|
||||||
this.traderHelper.addTraderPurchasesToPlayerProfile(sessionID, itemPurchaseDat);
|
this.traderHelper.addTraderPurchasesToPlayerProfile(sessionID, itemPurchaseDat, itemPurchased);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assortHasBuyRestrictions)
|
if (assortHasBuyRestrictions)
|
||||||
@ -176,10 +176,10 @@ export class TradeHelper
|
|||||||
items: [{ itemId: buyRequestData.item_id, count: buyCount }],
|
items: [{ itemId: buyRequestData.item_id, count: buyCount }],
|
||||||
traderId: buyRequestData.tid,
|
traderId: buyRequestData.tid,
|
||||||
};
|
};
|
||||||
this.traderHelper.addTraderPurchasesToPlayerProfile(sessionID, itemPurchaseDat);
|
this.traderHelper.addTraderPurchasesToPlayerProfile(sessionID, itemPurchaseDat, itemPurchased);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assortHasBuyRestrictions)
|
else if (assortHasBuyRestrictions)
|
||||||
{
|
{
|
||||||
// Increment non-fence trader item buy count
|
// Increment non-fence trader item buy count
|
||||||
this.incrementAssortBuyCount(itemPurchased, buyCount);
|
this.incrementAssortBuyCount(itemPurchased, buyCount);
|
||||||
|
@ -320,6 +320,7 @@ export class TraderHelper
|
|||||||
public addTraderPurchasesToPlayerProfile(
|
public addTraderPurchasesToPlayerProfile(
|
||||||
sessionID: string,
|
sessionID: string,
|
||||||
newPurchaseDetails: { items: { itemId: string; count: number; }[]; traderId: string; },
|
newPurchaseDetails: { items: { itemId: string; count: number; }[]; traderId: string; },
|
||||||
|
itemPurchased: Item
|
||||||
): void
|
): void
|
||||||
{
|
{
|
||||||
const profile = this.profileHelper.getFullProfile(sessionID);
|
const profile = this.profileHelper.getFullProfile(sessionID);
|
||||||
@ -350,6 +351,10 @@ export class TraderHelper
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( profile.traderPurchases[traderId][purchasedItem.itemId].count + purchasedItem.count > itemPurchased.upd.BuyRestrictionMax )
|
||||||
|
{
|
||||||
|
throw new Error("Unable to purchase item, Purchase limit reached");
|
||||||
|
}
|
||||||
profile.traderPurchases[traderId][purchasedItem.itemId].count += purchasedItem.count;
|
profile.traderPurchases[traderId][purchasedItem.itemId].count += purchasedItem.count;
|
||||||
profile.traderPurchases[traderId][purchasedItem.itemId].purchaseTimestamp = currentTime;
|
profile.traderPurchases[traderId][purchasedItem.itemId].purchaseTimestamp = currentTime;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user