0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 01:30:44 -05:00

Better handle cultist rewards not fitting the container (#979)

Better handle rewards not fitting (they shouldn't just poof) by instead
trimming the rewards amount until they fit.
This commit is contained in:
Chomp 2024-12-09 23:26:23 +00:00 committed by GitHub
commit 8d05bf0069
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -124,7 +124,7 @@ export class CircleOfCultistService {
} }
} }
const rewards = hasDirectReward let rewards = hasDirectReward
? this.getDirectRewards(sessionId, directRewardSettings, cultistCircleStashId) ? this.getDirectRewards(sessionId, directRewardSettings, cultistCircleStashId)
: this.getRewardsWithinBudget( : this.getRewardsWithinBudget(
this.getCultistCircleRewardPool(sessionId, pmcData, craftingInfo, this.hideoutConfig.cultistCircle), this.getCultistCircleRewardPool(sessionId, pmcData, craftingInfo, this.hideoutConfig.cultistCircle),
@ -138,7 +138,9 @@ export class CircleOfCultistService {
// Ensure rewards fit into container // Ensure rewards fit into container
const containerGrid = this.inventoryHelper.getContainerSlotMap(cultistStashDbItem[1]._id); const containerGrid = this.inventoryHelper.getContainerSlotMap(cultistStashDbItem[1]._id);
const canAddToContainer = this.inventoryHelper.canPlaceItemsInContainer( let canAddToContainer = false;
while (!canAddToContainer && rewards.length > 0) {
canAddToContainer = this.inventoryHelper.canPlaceItemsInContainer(
this.cloner.clone(containerGrid), // MUST clone grid before passing in as function modifies grid this.cloner.clone(containerGrid), // MUST clone grid before passing in as function modifies grid
rewards, rewards,
); );
@ -156,9 +158,8 @@ export class CircleOfCultistService {
pmcData.Inventory.items.push(...itemToAdd); pmcData.Inventory.items.push(...itemToAdd);
} }
} else { } else {
this.logger.error( rewards.pop();
`Unable to fit all: ${rewards.length} reward items into sacrifice grid, nothing will be returned (rewards so valuable cultists stole it)`, }
);
} }
return output; return output;