Closed richardbuckle closed 6 years ago
Possibly a commodity def issue from my test merge. Let's see: CommodityDefinitions.cs line 285
{128672124, new Commodity(252, "EncriptedDataStorage", "Encrypted Data Storage", "Salvage", 806, false) },
Looking at the diff on the PR, that commodity definition line appears to be untouched. I've occasionally found that doing a complete rebuild after switching branches is needed for everything to work properly. Did you rebuild prior to testing, or did you go straight to 'Start debugging'?
From first pass, I don’t see anything that would indicate why it didn’t register the Cargo collection. Link/paste your cargomonitor.json file and we'll see what it says.
Yup, I did a clean and full rebuild (and a code analysis build into the bargain). Here is cargomonitor.json:
{
"cargo": [
{
"name": "Personal Effects",
"stolen": 1,
"haulage": 0,
"other": 0,
"total": 1,
"price": 379,
"category": "Salvage",
"commodity": {
"name": "Personal Effects",
"category": "Salvage",
"avgprice": 379,
"rare": false,
"buyprice": null,
"stock": null,
"stockbracket": null,
"sellprice": null,
"demand": null,
"demandbracket": null,
"StatusFlags": null,
"EDDBID": 253,
"EDName": "PersonalEffects"
},
"haulageamounts": []
}
],
"cargocarried": 1
}
I just tried re-loggin in (I'm in space, not docked) and there was no change to either cargomonitor.json or the displayed amount. EDDiscovery is showing the cargo event from my log-in and it contains all 3 items.
Stepping thru in the debugger and just noticed that the personal effects count is wrong in EDDI, see screenshots and JSON, Should be 2 but is 1.
CargoMonitor.cs line 172
cargo.other = cargo.total - cargo.stolen - cargo.haulage;
Shouldn't the LHS be inventoryCargo.other
?
Exception caught: "This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread."
Back to CargoMonitor.cs line 172, shouldnt we be setting inventoryCargo.stolen
and inventoryCargo.haulage
as well?
Oh I get it, the CargoInventoryEvent doesn't tell us the ownership types.
Testing this fix:
// CargoInventoryEvent does not contain stolen, missionid, or cost information so fill in gaps here
foreach (Cargo cargo in @event.inventory)
{
Cargo inventoryCargo = inventory.FirstOrDefault(c => c.name == cargo.name);
if (inventoryCargo != null && inventoryCargo.total != cargo.total)
{
inventoryCargo.total = cargo.total;
// we aren't given cargo.stolen or cargo.haulage so we just have to put the balancing amount in inventoryCargo.other
inventoryCargo.other = inventoryCargo.total - inventoryCargo.stolen - inventoryCargo.haulage;
}
else
{
// We haven't heard of this cargo so add it to the inventory directly
AddCargo(cargo);
}
}
The threading issue I'll leave to @Hoodathunk but this seems to work. Some unit tests around this might be a good idea.
handleCommodityCollectedEvent()
:
if (@event.stolen)
{
newCargo.stolen = 1;
}
else
{
cargo.other = 1;
}
That doesn't look right either.
Some unit tests here would help a lot!
Suggested changes pushed to branch feature/47-cargo-monitor-VB-possible-fix
.
Thread exception when jettisoning, here's the call stack (commit cf51b4e7 on branch feature/47-cargo-monitor-VB-possible-fix):
> EddiCargoMonitor.dll!EddiCargoMonitor.CargoMonitor.RemoveCargo(string commodityName) Line 602 C# Symbols loaded.
EddiCargoMonitor.dll!EddiCargoMonitor.CargoMonitor.handleCommodityEjectedEvent(EddiCargoMonitor.CommodityEjectedEvent event) Line 247 C# Symbols loaded.
EddiCargoMonitor.dll!EddiCargoMonitor.CargoMonitor.PreHandle(EddiEvents.Event event) Line 109 C# Symbols loaded.
EDDI.exe!Eddi.EDDI.OnEvent(EddiEvents.Event event) Line 761 C# Symbols loaded.
EDDI.exe!Eddi.EDDI.eventHandler(EddiEvents.Event journalEvent) Line 743 C# Symbols loaded.
EddiJournalMonitor.dll!EddiJournalMonitor.JournalMonitor.ForwardJournalEntry(string line, System.Action<EddiEvents.Event> callback) Line 31 C# Symbols loaded.
EddiJournalMonitor.dll!EddiJournalMonitor.JournalMonitor..ctor.AnonymousMethod__1_0(string result) Line 24 C# Symbols loaded.
EddiJournalMonitor.dll!EddiJournalMonitor.LogMonitor.start() Line 122 C# Symbols loaded.
EddiJournalMonitor.dll!EddiJournalMonitor.JournalMonitor.Start() Line 2575 C# Symbols loaded.
EDDI.exe!Eddi.EDDI.keepAlive.AnonymousMethod__0() Line 592 C# Symbols loaded.
[External Code] Annotated Frame
After jettisoning all, I now have -1 stolen and 1 other personal effects for a total of 0.
ANTIMATTER CONFIRMED :-P
Verified now working in-game using latest commit of CargoMonitor in feature/47-cargo-monitor
To be corrected by PR #496
Incorporated.
This refers to the unreleased branch that implements the cargo monitor (issue #47)
Steps to reproduce
Expected
Both EDSM and EDDI show all the above items in cargo
Observed
EDSM shows both
but EDDI only shows the personal effects
Investigation
Log excerpt: