Add Optional chaining to registerProduction()
to fix null error relating to crafts without tools
This commit is contained in:
parent
93411b8ce4
commit
69bf8939d5
@ -26,8 +26,8 @@ import { LocalisationService } from "@spt-aki/services/LocalisationService";
|
||||
import { PlayerService } from "@spt-aki/services/PlayerService";
|
||||
import { HashUtil } from "@spt-aki/utils/HashUtil";
|
||||
import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil";
|
||||
import { TimeUtil } from "@spt-aki/utils/TimeUtil";
|
||||
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
|
||||
import { TimeUtil } from "@spt-aki/utils/TimeUtil";
|
||||
|
||||
@injectable()
|
||||
export class HideoutHelper
|
||||
@ -105,13 +105,13 @@ export class HideoutHelper
|
||||
|
||||
// Store the tools used for this production, so we can return them later
|
||||
const bodyAsSingle = body as IHideoutSingleProductionStartRequestData;
|
||||
if (bodyAsSingle && bodyAsSingle.tools.length > 0)
|
||||
if (bodyAsSingle && bodyAsSingle.tools?.length > 0)
|
||||
{
|
||||
production.sptRequiredTools = [];
|
||||
|
||||
for (const tool of bodyAsSingle.tools)
|
||||
{
|
||||
const toolItem = this.jsonUtil.clone(pmcData.Inventory.items.find(x => x._id === tool.id));
|
||||
const toolItem = this.jsonUtil.clone(pmcData.Inventory.items.find((x) => x._id === tool.id));
|
||||
|
||||
// Make sure we only return as many as we took
|
||||
if (!toolItem.upd)
|
||||
@ -123,7 +123,7 @@ export class HideoutHelper
|
||||
production.sptRequiredTools.push({
|
||||
_id: this.hashUtil.generate(),
|
||||
_tpl: toolItem._tpl,
|
||||
upd: toolItem.upd
|
||||
upd: toolItem.upd,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user