store in the transaction whether it was done in legacy or live

This commit is contained in:
2022-11-29 16:30:46 +01:00
parent 91bca70168
commit 712c416725
5 changed files with 70 additions and 0 deletions

View File

@@ -19,6 +19,11 @@ internal class TransactionParserContext {
public bool HaveSeenSpecOps { get; set; } = false;
public bool HaveSeenCorrespondent { get; set; } = false;
/// <summary>
/// Returns true if the current session is legacy
/// </summary>
public bool IsLegacy { get; set; } = false;
/// <summary>
/// How many on foot kills were done.
/// </summary>
@@ -103,6 +108,7 @@ internal class TransactionParserContext {
CombatZone zone = new CombatZone() {
System = CurrentSystem,
Faction = LastRecordedAwardingFaction,
IsLegacy = IsLegacy,
Grade = grade,
Type = cztype,
// Sad truth is, if HaveSeenXXX is false, we just don't know for certain
@@ -384,6 +390,7 @@ internal class CommitCrimeParser : TransactionParserPart {
transactions.Add(new FoulMurder(entry) {
System = context.CurrentSystem,
IsLegacy = context.IsLegacy,
Faction = faction,
});
}
@@ -498,6 +505,7 @@ internal class MissionCompletedParser : TransactionParserPart {
Faction = source_faction_name,
SystemAddress = accepted_location.SystemAddress,
Station = accepted_location.Station,
IsLegacy = context.IsLegacy,
});
} else if (string.Compare(faction, source_faction_name, true) != 0 ||
(string.Compare(faction, source_faction_name) == 0 &&
@@ -511,6 +519,7 @@ internal class MissionCompletedParser : TransactionParserPart {
System = system,
SystemAddress = system_address,
RelevantMission = entry,
IsLegacy = context.IsLegacy,
});
}
}
@@ -561,6 +570,7 @@ internal class MissionFailedParser : TransactionParserPart {
Station = accepted_location.Station,
System = accepted_location.StarSystem,
SystemAddress = accepted_location.SystemAddress,
IsLegacy = context.IsLegacy,
});
}
}
@@ -576,6 +586,7 @@ internal class SellExplorationDataParser : TransactionParserPart {
System = context.CurrentSystem,
Station = context.CurrentStation,
Faction = context.ControllingFaction,
IsLegacy = context.IsLegacy,
});
}
}
@@ -591,6 +602,7 @@ internal class SellOrganicDataParser : TransactionParserPart {
System = context.CurrentSystem,
Station = context.CurrentStation,
Faction = context.ControllingFaction,
IsLegacy = context.IsLegacy,
});
}
}
@@ -606,6 +618,7 @@ internal class MultiSellExplorationDataParser : TransactionParserPart {
System = context.CurrentSystem,
Station = context.CurrentStation,
Faction = context.ControllingFaction,
IsLegacy = context.IsLegacy,
});
}
}
@@ -660,6 +673,7 @@ internal class RedeemVoucherParser : TransactionParserPart {
Station = context.CurrentStation,
Faction = relevantFaction,
ControllingFaction = context.ControllingFaction,
IsLegacy = context.IsLegacy,
});
}
}
@@ -677,6 +691,7 @@ internal class SellMicroResourcesParser : TransactionParserPart {
System = context.CurrentSystem,
Station = context.CurrentStation,
Faction = context.ControllingFaction,
IsLegacy = context.IsLegacy,
});
}
}
@@ -692,6 +707,7 @@ internal class SearchAndRescueParser : TransactionParserPart {
Faction = context.ControllingFaction,
Station = context.CurrentStation,
System = context.CurrentSystem,
IsLegacy = context.IsLegacy,
});
}
}
@@ -709,6 +725,7 @@ internal class MarketBuyParser : TransactionParserPart {
Faction = context.ControllingFaction,
Station = context.CurrentStation,
System = context.CurrentSystem,
IsLegacy = context.IsLegacy,
});
}
}
@@ -736,6 +753,7 @@ internal class MarketSellParser : TransactionParserPart {
Station = context.CurrentStation,
System = context.CurrentSystem,
Profit = profit,
IsLegacy = context.IsLegacy,
});
}
}
@@ -753,6 +771,7 @@ internal class FactionKillBondParser : TransactionParserPart {
System = context.CurrentSystem,
Faction = Factions.PilotsFederation,
Station = context.CurrentStation,
IsLegacy = context.IsLegacy,
});
// We are done
@@ -797,6 +816,18 @@ internal class CapShipBondParser : TransactionParserPart {
}
}
internal class FileHeaderParser : TransactionParserPart {
public void Parse(Entry entry, TransactionParserContext context, TransactionList transactions) {
FileHeaderEntry? fileheader = entry as FileHeaderEntry;
if (fileheader == null) {
return;
}
context.IsLegacy = fileheader.IsLegacy;
}
}
public class TransactionParser {
private static Dictionary<string, TransactionParserPart> ParserParts { get; } = new()
{
@@ -806,6 +837,7 @@ public class TransactionParser {
{ Events.Docked, new DockedParser() },
{ Events.Embark, new EmbarkDisembarkParser() },
{ Events.FactionKillBond, new FactionKillBondParser() },
{ Events.FileHeader, new FileHeaderParser() },
{ Events.FSDJump, new FSDJumpParser() },
{ Events.Location, new LocationParser() },
{ Events.MarketBuy, new MarketBuyParser() },