Add guard to fillMagazineWithCartridge()
to prevent bad mod data breaking server
This commit is contained in:
parent
66630a5fc6
commit
10b88b54b3
@ -1028,7 +1028,14 @@ export class ItemHelper
|
|||||||
const cartridgeMaxStackSize = cartridgeDetails[1]._props.StackMaxSize;
|
const cartridgeMaxStackSize = cartridgeDetails[1]._props.StackMaxSize;
|
||||||
|
|
||||||
// Get max number of cartridges in magazine, choose random value between min/max
|
// Get max number of cartridges in magazine, choose random value between min/max
|
||||||
const magazineCartridgeMaxCount = magTemplate._props.Cartridges[0]._max_count;
|
const magazineCartridgeMaxCount = magTemplate._props.Cartridges[0]?._max_count;
|
||||||
|
if (!magazineCartridgeMaxCount)
|
||||||
|
{
|
||||||
|
this.logger.warning(`Magazine: ${magTemplate._id} ${magTemplate._name} lacks a Cartridges array, unable to fill magazine with ammo`);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const desiredStackCount = this.randomUtil.getInt(
|
const desiredStackCount = this.randomUtil.getInt(
|
||||||
Math.round(minSizePercent * magazineCartridgeMaxCount),
|
Math.round(minSizePercent * magazineCartridgeMaxCount),
|
||||||
magazineCartridgeMaxCount,
|
magazineCartridgeMaxCount,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user