Send correct data to client to inform it craft has been cancelled

This commit is contained in:
Dev 2023-10-28 17:48:37 +01:00
parent ce50c88b87
commit cc86ecce2b
3 changed files with 15 additions and 4 deletions

View File

@ -983,7 +983,7 @@ export class HideoutController
* @param sessionId Session id * @param sessionId Session id
* @param pmcData Profile with craft to cancel * @param pmcData Profile with craft to cancel
* @param request Cancel production request data * @param request Cancel production request data
* @returns * @returns IItemEventRouterResponse
*/ */
public cancelProduction(sessionId: string, pmcData: IPmcData, request: IHideoutCancelProductionRequestData): IItemEventRouterResponse public cancelProduction(sessionId: string, pmcData: IPmcData, request: IHideoutCancelProductionRequestData): IItemEventRouterResponse
{ {
@ -998,8 +998,8 @@ export class HideoutController
return this.httpResponse.appendErrorToOutput(output, errorMessage); return this.httpResponse.appendErrorToOutput(output, errorMessage);
} }
// Remove production from profile // Null out production data so client gets informed when response send back
delete pmcData.Hideout.Production[request.recipeId]; pmcData.Hideout.Production[request.recipeId] = null;
// TODO - handle timestamp somehow? // TODO - handle timestamp somehow?

View File

@ -227,6 +227,11 @@ export class HideoutHelper
for (const prodId in pmcData.Hideout.Production) for (const prodId in pmcData.Hideout.Production)
{ {
const craft = pmcData.Hideout.Production[prodId]; const craft = pmcData.Hideout.Production[prodId];
if (!craft)
{
// Craft value is null, get rid of it (could be from cancelling craft that needs cleaning up)
delete pmcData.Hideout.Production[prodId];
}
// Craft complete, skip processing (Don't skip continious crafts like bitcoin farm) // Craft complete, skip processing (Don't skip continious crafts like bitcoin farm)
if (craft.Progress >= craft.ProductionTime && prodId !== HideoutHelper.bitcoinFarm) if (craft.Progress >= craft.ProductionTime && prodId !== HideoutHelper.bitcoinFarm)

View File

@ -153,8 +153,14 @@ export class EventOutputHolder
{ {
for (const productionKey in productions) for (const productionKey in productions)
{ {
// Skip completed
const production = productions[productionKey]; const production = productions[productionKey];
if (!production)
{
// Could be cancelled production, skip item to save processing
continue;
}
// Skip completed
if (!production.inProgress) if (!production.inProgress)
{ {
continue; continue;