fix mission failure with the same source information as mission completion

This commit is contained in:
2022-02-18 13:38:47 +01:00
parent f183462a7b
commit 9795b22e02
3 changed files with 123 additions and 6 deletions

View File

@@ -217,28 +217,28 @@ namespace EliteBGS.BGS {
if (!systems.TryGetValue(system_address, out system)) {
OnLog?.Invoke(string.Format(
"Unknown system system \"{0}\" unable to assign that mission a target.", system_address
"Unknown system \"{0}\" unable to assign that mission a target.", system_address
));
continue;
}
if (!acceptedSystems.TryGetValue(completed.MissionID, out accepted_address)) {
OnLog?.Invoke(string.Format(
"Unable to figure out in which system mission \"{0}\" was accepted.", system_address
"Unable to figure out in which system mission \"{0}\" was accepted.", completed.HumanReadableName
));
continue;
}
if (!systems.TryGetValue(accepted_address, out accepted_system)) {
OnLog?.Invoke(string.Format(
"Unable to figure out in which system mission \"{0}\" was accepted.", system_address
"Unable to figure out in which system mission \"{0}\" was accepted.", completed.HumanReadableName
));
continue;
}
if (!acceptedStations.TryGetValue(completed.MissionID, out accepted_station)) {
OnLog?.Invoke(string.Format(
"Unable to figure out in which station mission \"{0}\" was accepted.", system_address
"Unable to figure out in which station mission \"{0}\" was accepted.", completed.HumanReadableName
));
continue;
}
@@ -294,14 +294,47 @@ namespace EliteBGS.BGS {
acceptedSystems[id] = current_system_address;
}
} else if (e.Is(Events.MissionFailed)) {
var failed = e as MissionFailedEntry;
MissionFailedEntry failed = e as MissionFailedEntry;
MissionAcceptedEntry accepted = null;
ulong accepted_address = 0;
string accepted_system;
string accepted_station;
if (!acceptedMissions.TryGetValue(failed.MissionID, out accepted)) {
OnLog?.Invoke("A mission failed which wasn't accepted in the given time frame. " +
"Please adjust start date to when the mission was accepted to include it in the list.");
continue;
}
results.Add(new MissionFailed(accepted) { Failed = failed, System = current_system });
if (!acceptedSystems.TryGetValue(failed.MissionID, out accepted_address)) {
OnLog?.Invoke(string.Format(
"Unable to figure out in which system mission \"{0}\" was accepted.", accepted.Name
));
continue;
}
if (!systems.TryGetValue(accepted_address, out accepted_system)) {
OnLog?.Invoke(string.Format(
"Unable to figure out in which system mission \"{0}\" was accepted.", accepted.Name
));
continue;
}
if (!acceptedStations.TryGetValue(failed.MissionID, out accepted_station)) {
OnLog?.Invoke(string.Format(
"Unable to figure out in which station mission \"{0}\" was accepted.", accepted.Name
));
continue;
}
results.Add(new MissionFailed(accepted) {
Failed = failed,
System = accepted_system,
Station = accepted_station,
Faction = accepted.Faction,
SystemAddress = accepted_address,
});
if (failed.HumanReadableName == null) {
OnLog?.Invoke("Human readable name for mission \"" +
failed.Name +