Resolve server error inside removeRandomItemFromAssorts()
when the item being processed has no upd
object
This commit is contained in:
parent
225c44e594
commit
ef65074dc3
@ -393,7 +393,12 @@ export class FenceService
|
|||||||
protected removeRandomItemFromAssorts(assort: ITraderAssort, rootItems: Item[]): void
|
protected removeRandomItemFromAssorts(assort: ITraderAssort, rootItems: Item[]): void
|
||||||
{
|
{
|
||||||
const rootItemToAdjust = this.randomUtil.getArrayValue(rootItems);
|
const rootItemToAdjust = this.randomUtil.getArrayValue(rootItems);
|
||||||
const itemCountToRemove = this.randomUtil.getInt(1, rootItemToAdjust.upd.StackObjectsCount);
|
|
||||||
|
// Items added by mods may not have a upd object, assume item stack size is 1
|
||||||
|
const stackSize = rootItemToAdjust.upd?.StackObjectsCount ?? 1;
|
||||||
|
|
||||||
|
// Get a random count of the chosen item to remove
|
||||||
|
const itemCountToRemove = this.randomUtil.getInt(1, stackSize);
|
||||||
if (itemCountToRemove > 1 && itemCountToRemove < rootItemToAdjust.upd.StackObjectsCount)
|
if (itemCountToRemove > 1 && itemCountToRemove < rootItemToAdjust.upd.StackObjectsCount)
|
||||||
{ // More than 1 + less then full stack
|
{ // More than 1 + less then full stack
|
||||||
// Reduce stack size but keep stack
|
// Reduce stack size but keep stack
|
||||||
|
Loading…
x
Reference in New Issue
Block a user