forked from OpenWF/SpaceNinjaServer
		
	fix: handle CurrentLoadOutIds missing LoadOuts in missionInventoryUpdate (#1421)
Reviewed-on: OpenWF/SpaceNinjaServer#1421 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									9e1a5d50af
								
							
						
					
					
						commit
						ea9333279b
					
				@ -414,17 +414,19 @@ export const addMissionInventoryUpdates = async (
 | 
				
			|||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            case "CurrentLoadOutIds": {
 | 
					            case "CurrentLoadOutIds": {
 | 
				
			||||||
                const loadout = await Loadout.findOne({ loadoutOwnerId: inventory.accountOwnerId });
 | 
					                if (value.LoadOuts) {
 | 
				
			||||||
                if (loadout) {
 | 
					                    const loadout = await Loadout.findOne({ loadoutOwnerId: inventory.accountOwnerId });
 | 
				
			||||||
                    for (const [loadoutId, loadoutConfig] of Object.entries(value.LoadOuts.NORMAL)) {
 | 
					                    if (loadout) {
 | 
				
			||||||
                        const { ItemId, ...loadoutConfigItemIdRemoved } = loadoutConfig;
 | 
					                        for (const [loadoutId, loadoutConfig] of Object.entries(value.LoadOuts.NORMAL)) {
 | 
				
			||||||
                        const loadoutConfigDatabase: ILoadoutConfigDatabase = {
 | 
					                            const { ItemId, ...loadoutConfigItemIdRemoved } = loadoutConfig;
 | 
				
			||||||
                            _id: new Types.ObjectId(ItemId.$oid),
 | 
					                            const loadoutConfigDatabase: ILoadoutConfigDatabase = {
 | 
				
			||||||
                            ...loadoutConfigItemIdRemoved
 | 
					                                _id: new Types.ObjectId(ItemId.$oid),
 | 
				
			||||||
                        };
 | 
					                                ...loadoutConfigItemIdRemoved
 | 
				
			||||||
                        loadout.NORMAL.id(loadoutId)!.overwrite(loadoutConfigDatabase);
 | 
					                            };
 | 
				
			||||||
 | 
					                            loadout.NORMAL.id(loadoutId)!.overwrite(loadoutConfigDatabase);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        await loadout.save();
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    await loadout.save();
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
				
			|||||||
@ -114,7 +114,7 @@ export type IMissionInventoryUpdateRequest = {
 | 
				
			|||||||
    UnlockWeapons?: boolean; // sent when recovered weapons from zanuka capture
 | 
					    UnlockWeapons?: boolean; // sent when recovered weapons from zanuka capture
 | 
				
			||||||
    IncHarvester?: boolean; // sent when recovered weapons from zanuka capture
 | 
					    IncHarvester?: boolean; // sent when recovered weapons from zanuka capture
 | 
				
			||||||
    CurrentLoadOutIds?: {
 | 
					    CurrentLoadOutIds?: {
 | 
				
			||||||
        LoadOuts: ILoadOutPresets; // sent when recovered weapons from zanuka capture
 | 
					        LoadOuts?: ILoadOutPresets; // sent when recovered weapons from zanuka capture
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
} & {
 | 
					} & {
 | 
				
			||||||
    [K in TEquipmentKey]?: IEquipmentClient[];
 | 
					    [K in TEquipmentKey]?: IEquipmentClient[];
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user