change abandoned and failed towards newest Mission

This commit is contained in:
2022-11-24 14:25:31 +01:00
parent 1d19a8f73c
commit ce54430137
6 changed files with 38 additions and 28 deletions

View File

@@ -28,8 +28,9 @@ public class MissionFailed : Transaction {
}
/* if it is the same mission name, the same faction and the same system,
* collate mission failures together */
if (failed.Failed?.HumanReadableName == Failed?.HumanReadableName &&
* collate mission failures together
*/
if (string.Compare(failed.Failed?.Mission?.Name, Failed?.Mission?.Name) == 0 &&
failed.Faction == Faction &&
failed.System == System) {
return 0;
@@ -50,7 +51,8 @@ public class MissionFailed : Transaction {
builder.AppendFormat("{0}x Mission failed: \"{1}\"",
Amount,
Failed.HumanReadableName != null ? Failed.HumanReadableName : Failed.Name
Failed?.Mission?.LocalisedName != null ?
Failed?.Mission?.LocalisedName : Failed?.Mission?.Name
);
return builder.ToString();

View File

@@ -423,11 +423,11 @@ public class Report {
string? accepted_system;
string? accepted_station;
if (failed == null) {
if (failed == null || failed.Mission == null) {
continue;
}
if (!acceptedMissions.TryGetValue(failed.MissionID, out accepted)) {
if (!acceptedMissions.TryGetValue(failed.Mission.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;
@@ -437,7 +437,7 @@ public class Report {
continue;
}
if (!acceptedSystems.TryGetValue(failed.MissionID, out accepted_address)) {
if (!acceptedSystems.TryGetValue(failed.Mission.MissionID, out accepted_address)) {
OnLog?.Invoke(string.Format(
"Unable to figure out in which system mission \"{0}\" was accepted.", accepted.Mission.Name
));
@@ -451,7 +451,7 @@ public class Report {
continue;
}
if (!acceptedStations.TryGetValue(failed.MissionID, out accepted_station)) {
if (!acceptedStations.TryGetValue(failed.Mission.MissionID, out accepted_station)) {
OnLog?.Invoke(string.Format(
"Unable to figure out in which station mission \"{0}\" was accepted.", accepted.Mission.Name
));
@@ -466,12 +466,6 @@ public class Report {
SystemAddress = accepted_address,
});
if (failed.HumanReadableName == null) {
OnLog?.Invoke("Human readable name for mission \"" +
failed.Name +
"\" was not recognised");
}
/* Mission failed should be collated if they are in the same system/station
*/
collate = true;

View File

@@ -389,14 +389,18 @@ internal class MissionFailedParser : TransactionParserPart {
throw new NotImplementedException();
}
if (!context.AcceptedMissions.TryGetValue(entry.MissionID, out accepted)) {
if (entry.Mission == null) {
throw new InvalidJournalEntryException("No mission specified in mission failure");
}
if (!context.AcceptedMissions.TryGetValue(entry.Mission.MissionID, out accepted)) {
transactions.AddIncomplete(new MissionFailed(),
"Mission acceptance was not found"
);
return;
}
if (!context.AcceptedMissionLocation.TryGetValue(entry.MissionID, out accepted_location)) {
if (!context.AcceptedMissionLocation.TryGetValue(entry.Mission.MissionID, out accepted_location)) {
transactions.AddIncomplete(new MissionFailed(),
"Unable to figure out where failed mission was accepted"
);