Better error handling in server
This commit is contained in:
@@ -40,11 +40,15 @@ class UIFixes implements IPreSptLoadMod {
|
|||||||
original.call(inRaidHelper, pmcData, sessionId);
|
original.call(inRaidHelper, pmcData, sessionId);
|
||||||
|
|
||||||
// Restore the quickbinds for items that still exist
|
// Restore the quickbinds for items that still exist
|
||||||
|
try {
|
||||||
for (const index in fastPanel) {
|
for (const index in fastPanel) {
|
||||||
if (pmcData.Inventory.items.find(i => i._id == fastPanel[index])) {
|
if (pmcData.Inventory.items.find(i => i._id == fastPanel[index])) {
|
||||||
pmcData.Inventory.fastPanel[index] = fastPanel[index];
|
pmcData.Inventory.fastPanel[index] = fastPanel[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(`UIFixes failed to restore quickbinds\n ${error}`);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{ frequency: "Always" }
|
{ frequency: "Always" }
|
||||||
@@ -61,15 +65,21 @@ class UIFixes implements IPreSptLoadMod {
|
|||||||
const result = original.call(hideoutHelper, pmcData, body, sessionID);
|
const result = original.call(hideoutHelper, pmcData, body, sessionID);
|
||||||
|
|
||||||
// The items haven't been deleted yet, augment the list with their parentId
|
// The items haven't been deleted yet, augment the list with their parentId
|
||||||
|
try {
|
||||||
const bodyAsSingle = body as IHideoutSingleProductionStartRequestData;
|
const bodyAsSingle = body as IHideoutSingleProductionStartRequestData;
|
||||||
if (bodyAsSingle && bodyAsSingle.tools?.length > 0) {
|
if (bodyAsSingle && bodyAsSingle.tools?.length > 0) {
|
||||||
const requestTools = bodyAsSingle.tools;
|
const requestTools = bodyAsSingle.tools;
|
||||||
const tools = pmcData.Hideout.Production[body.recipeId].sptRequiredTools;
|
const tools = pmcData.Hideout.Production[body.recipeId].sptRequiredTools;
|
||||||
for (let i = 0; i < tools.length; i++) {
|
for (let i = 0; i < tools.length; i++) {
|
||||||
const originalTool = pmcData.Inventory.items.find(x => x._id === requestTools[i].id);
|
const originalTool = pmcData.Inventory.items.find(
|
||||||
|
x => x._id === requestTools[i].id
|
||||||
|
);
|
||||||
tools[i]["uifixes.returnTo"] = [originalTool.parentId, originalTool.slotId];
|
tools[i]["uifixes.returnTo"] = [originalTool.parentId, originalTool.slotId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(`UIFixes failed to save tool origin\n ${error}`);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
@@ -89,11 +99,13 @@ class UIFixes implements IPreSptLoadMod {
|
|||||||
// If a tool marked with uifixes is there, try to return it to its original container
|
// If a tool marked with uifixes is there, try to return it to its original container
|
||||||
const tool = itemWithModsToAddClone[0];
|
const tool = itemWithModsToAddClone[0];
|
||||||
if (tool["uifixes.returnTo"]) {
|
if (tool["uifixes.returnTo"]) {
|
||||||
|
try {
|
||||||
const [containerId, slotId] = tool["uifixes.returnTo"];
|
const [containerId, slotId] = tool["uifixes.returnTo"];
|
||||||
|
|
||||||
const container = pmcData.Inventory.items.find(x => x._id === containerId);
|
const container = pmcData.Inventory.items.find(x => x._id === containerId);
|
||||||
if (container) {
|
if (container) {
|
||||||
const containerTemplate = itemHelper.getItem(container._tpl)[1];
|
const [foundTemplate, containerTemplate] = itemHelper.getItem(container._tpl);
|
||||||
|
if (foundTemplate && containerTemplate) {
|
||||||
const containerFS2D = inventoryHelper.getContainerMap(
|
const containerFS2D = inventoryHelper.getContainerMap(
|
||||||
containerTemplate._props.Grids[0]._props.cellsH,
|
containerTemplate._props.Grids[0]._props.cellsH,
|
||||||
containerTemplate._props.Grids[0]._props.cellsV,
|
containerTemplate._props.Grids[0]._props.cellsV,
|
||||||
@@ -136,6 +148,12 @@ class UIFixes implements IPreSptLoadMod {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(
|
||||||
|
`UIFixes failed to put a tool back, it will be returned to your stash as normal.\n ${error}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return original.call(inventoryHelper, sessionId, request, pmcData, output);
|
return original.call(inventoryHelper, sessionId, request, pmcData, output);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user