diff --git a/MosswartMassacre/MossyInventory.cs b/MosswartMassacre/MossyInventory.cs index 299b130..9453e7a 100644 --- a/MosswartMassacre/MossyInventory.cs +++ b/MosswartMassacre/MossyInventory.cs @@ -87,6 +87,7 @@ namespace MosswartMassacre private bool loginComplete; private bool loggedInAndWaitingForIdData; + private bool forceUploadWaitingForIdData; private readonly List requestedIds = new List(); private void CharacterFilter_LoginComplete(object sender, EventArgs e) @@ -166,7 +167,7 @@ namespace MosswartMassacre return; // Settings not ready, skip silently } - if (loggedInAndWaitingForIdData) + if (loggedInAndWaitingForIdData || forceUploadWaitingForIdData) { bool allHaveId = true; foreach (WorldObject wo in CoreManager.Current.WorldFilter.GetInventory()) @@ -179,9 +180,14 @@ namespace MosswartMassacre } if (allHaveId) { + bool wasForceUpload = forceUploadWaitingForIdData; loggedInAndWaitingForIdData = false; + forceUploadWaitingForIdData = false; DumpInventoryToFile(); - PluginCore.WriteToChat("Requesting id information for all armor/weapon inventory completed. Log file written."); + if (wasForceUpload) + PluginCore.WriteToChat("[INV] All items identified. Inventory upload completed."); + else + PluginCore.WriteToChat("Requesting id information for all armor/weapon inventory completed. Log file written."); } } else @@ -295,14 +301,15 @@ namespace MosswartMassacre } /// - /// Forces an inventory upload with ID requests - guarantees complete data + /// Forces a full inventory scan: requests ID data for all items that need it, + /// waits for all identifications to complete, then sends the complete inventory. /// public void ForceInventoryUpload() { try { // Check if inventory logging is enabled - try + try { if (!PluginSettings.Instance.InventoryLog) { @@ -323,9 +330,32 @@ namespace MosswartMassacre return; } - PluginCore.WriteToChat("[INV] Forcing inventory upload with ID requests..."); - DumpInventoryToFile(true); // Request IDs if missing - PluginCore.WriteToChat("[INV] Inventory upload completed"); + // Count items needing identification + int needsId = 0; + int totalItems = 0; + foreach (WorldObject wo in CoreManager.Current.WorldFilter.GetInventory()) + { + totalItems++; + if (!wo.HasIdData && ObjectClassNeedsIdent(wo.ObjectClass, wo.Name)) + { + CoreManager.Current.Actions.RequestId(wo.Id); + needsId++; + } + } + + if (needsId > 0) + { + // Wait for all IDs to come back before sending + forceUploadWaitingForIdData = true; + PluginCore.WriteToChat($"[INV] Scanning {totalItems} items, requesting ID for {needsId}. Waiting for identification..."); + } + else + { + // All items already identified, send immediately + PluginCore.WriteToChat($"[INV] All {totalItems} items already identified. Sending..."); + DumpInventoryToFile(); + PluginCore.WriteToChat("[INV] Inventory upload completed"); + } } catch (Exception ex) { diff --git a/MosswartMassacre/bin/Release/MosswartMassacre.dll b/MosswartMassacre/bin/Release/MosswartMassacre.dll index 0a828b5..bd84ecb 100644 Binary files a/MosswartMassacre/bin/Release/MosswartMassacre.dll and b/MosswartMassacre/bin/Release/MosswartMassacre.dll differ