Skip to content

Commit

Permalink
Implement game version and game build support in the EDDN header.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tkael committed Nov 19, 2022
1 parent e905a8a commit cc65e07
Show file tree
Hide file tree
Showing 19 changed files with 67 additions and 153 deletions.
14 changes: 3 additions & 11 deletions EDDNResponder/EDDNResponder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,8 @@ private void FrontierApiOnStationUpdatedEvent(object sender, CompanionApiEndpoin
{
foreach (var schema in capiSchemas)
{
var handledData = schema.Handle(e.profileJson, e.marketJson, e.shipyardJson, e.fleetCarrierJson, eddnState);
if (handledData != null)
{
// The same Frontier API data may be handled by multiple schemas so we always iterate through each.
schema.SendCapi(handledData);
}
// The same Frontier API data may be handled by multiple schemas so we always iterate through each.
schema.Handle(e.profileJson, e.marketJson, e.shipyardJson, e.fleetCarrierJson, eddnState);
}
}

Expand Down Expand Up @@ -121,11 +117,7 @@ public void Handle(Event theEvent)
// Handle events
foreach (var schema in schemas)
{
if (schema.Handle(edType, ref data, eddnState))
{
schema.Send(data);
break;
}
schema.Handle(edType, ref data, eddnState);
}
}

Expand Down
4 changes: 0 additions & 4 deletions EDDNResponder/ISchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@ public interface ISchema

[UsedImplicitly]
bool Handle(string edType, ref IDictionary<string, object> data, EDDNState eddnState);

void Send(IDictionary<string, object> data);
}

public interface ICapiSchema
{
IDictionary<string, object> Handle(JObject profileJson, JObject marketJson, JObject shipyardJson, JObject fleetCarrierJson, EDDNState eddnState);

void SendCapi(IDictionary<string, object> data);
}
}
10 changes: 3 additions & 7 deletions EDDNResponder/Schemas/ApproachSettlementSchema.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using EddiEddnResponder.Sender;
using EddiEddnResponder.Sender;
using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using Utilities;

Expand All @@ -27,6 +27,7 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
data = eddnState.Location.AugmentStarPos(data);
data = eddnState.GameVersion.AugmentVersion(data);

EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/approachsettlement/1", data, eddnState);
return true;
}
catch (Exception e)
Expand All @@ -38,10 +39,5 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
return false;
}
}

public void Send(IDictionary<string, object> data)
{
EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/approachsettlement/1", data);
}
}
}
10 changes: 3 additions & 7 deletions EDDNResponder/Schemas/CodexEntrySchema.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using EddiEddnResponder.Sender;
using EddiEddnResponder.Sender;
using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using Utilities;

Expand All @@ -25,6 +25,7 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
data = eddnState.Location.AugmentStarPos(data);
data = eddnState.GameVersion.AugmentVersion(data);

EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/codexentry/1", data, eddnState);
return true;
}
catch (Exception e)
Expand All @@ -36,10 +37,5 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
return false;
}
}

public void Send(IDictionary<string, object> data)
{
EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/codexentry/1", data);
}
}
}
15 changes: 3 additions & 12 deletions EDDNResponder/Schemas/CommoditySchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ commoditiesList is List<object> commodities &&
// Apply data augments
handledData = eddnState.GameVersion.AugmentVersion(handledData);

data = handledData;
EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/commodity/3", handledData, eddnState);
return true;
}
}
Expand Down Expand Up @@ -81,11 +81,6 @@ private bool ApplyJournalMarketFilter(JToken c)
return true;
}

public void Send(IDictionary<string, object> data)
{
EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/commodity/3", data);
}

public IDictionary<string, object> Handle(JObject profileJson, JObject marketJson, JObject shipyardJson, JObject fleetCarrierJson, EDDNState eddnState)
{
try
Expand Down Expand Up @@ -125,8 +120,9 @@ public IDictionary<string, object> Handle(JObject profileJson, JObject marketJso
data = eddnState.PersonalData.Strip(data);

// Apply data augments
data = eddnState.GameVersion.AugmentVersion(data, "CAPI-market");
data = eddnState.GameVersion.AugmentVersion(data);

EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/commodity/3", data, eddnState, "CAPI-market");
return data;
}
}
Expand All @@ -140,11 +136,6 @@ public IDictionary<string, object> Handle(JObject profileJson, JObject marketJso
return null;
}

public void SendCapi(IDictionary<string, object> data)
{
EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/commodity/3", data);
}

private bool ApplyFrontierApiMarketFilter(JToken c)
{
try
Expand Down
17 changes: 4 additions & 13 deletions EDDNResponder/Schemas/FCMaterialsSchema.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using EddiEddnResponder.Sender;
using EddiEddnResponder.Sender;
using JetBrains.Annotations;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -46,11 +46,6 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
}
}

public void Send(IDictionary<string, object> data)
{
EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/fcmaterials_journal/1", data);
}

public IDictionary<string, object> Handle(JObject profileJson, JObject marketJson, JObject shipyardJson, JObject fleetCarrierJson, EDDNState eddnState)
{
try
Expand Down Expand Up @@ -83,8 +78,9 @@ public IDictionary<string, object> Handle(JObject profileJson, JObject marketJso
data = eddnState.PersonalData.Strip(data);

// Apply data augments
data = eddnState.GameVersion.AugmentVersion(data, "CAPI-market");
data = eddnState.GameVersion.AugmentVersion(data);

EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/fcmaterials_capi/1", data, eddnState, "CAPI-market");
return data;
}
}
Expand All @@ -98,10 +94,5 @@ public IDictionary<string, object> Handle(JObject profileJson, JObject marketJso

return null;
}

public void SendCapi(IDictionary<string, object> data)
{
EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/fcmaterials_capi/1", data);
}
}
}
10 changes: 3 additions & 7 deletions EDDNResponder/Schemas/FSSAllBodiesFoundSchema.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using EddiEddnResponder.Sender;
using EddiEddnResponder.Sender;
using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using Utilities;

Expand All @@ -25,6 +25,7 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
data = eddnState.Location.AugmentStarPos(data);
data = eddnState.GameVersion.AugmentVersion(data);

EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/fssallbodiesfound/1", data, eddnState);
return true;
}
catch (Exception e)
Expand All @@ -36,10 +37,5 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
return false;
}
}

public void Send(IDictionary<string, object> data)
{
EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/fssallbodiesfound/1", data);
}
}
}
10 changes: 3 additions & 7 deletions EDDNResponder/Schemas/FSSBodySignalsSchema.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using EddiEddnResponder.Sender;
using EddiEddnResponder.Sender;
using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using Utilities;

Expand All @@ -27,6 +27,7 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
data = eddnState.Location.AugmentStarPos(data);
data = eddnState.GameVersion.AugmentVersion(data);

EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/fssbodysignals/1", data, eddnState);
return true;
}
catch (Exception e)
Expand All @@ -38,10 +39,5 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
return false;
}
}

public void Send(IDictionary<string, object> data)
{
EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/fssbodysignals/1", data);
}
}
}
10 changes: 3 additions & 7 deletions EDDNResponder/Schemas/FSSDiscoveryScanSchema.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using EddiEddnResponder.Sender;
using EddiEddnResponder.Sender;
using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using Utilities;

Expand Down Expand Up @@ -28,6 +28,7 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
data = eddnState.Location.AugmentStarPos(data);
data = eddnState.GameVersion.AugmentVersion(data);

EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/fssdiscoveryscan/1", data, eddnState);
return true;
}
catch (Exception e)
Expand All @@ -39,10 +40,5 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
return false;
}
}

public void Send(IDictionary<string, object> data)
{
EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/fssdiscoveryscan/1", data);
}
}
}
8 changes: 2 additions & 6 deletions EDDNResponder/Schemas/FSSSignalDiscoveredSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
{
data = PrepareSignalsData(latestSignalState);
lastEdType = edType;
EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/fsssignaldiscovered/1", data, eddnState);
latestSignalState = null;
return true;
}
}
Expand Down Expand Up @@ -117,11 +119,5 @@ private IDictionary<string, object> PrepareSignalsData(EDDNState eddnState)

return data;
}

public void Send(IDictionary<string, object> data)
{
EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/fsssignaldiscovered/1", data);
latestSignalState = null;
}
}
}
10 changes: 3 additions & 7 deletions EDDNResponder/Schemas/JournalSchema.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using EddiEddnResponder.Sender;
using EddiEddnResponder.Sender;
using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using Utilities;

Expand Down Expand Up @@ -35,6 +35,7 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
data = eddnState.Location.AugmentBody(data);
data = eddnState.GameVersion.AugmentVersion(data);

EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/journal/1", data, eddnState);
return true;
}
catch (Exception e)
Expand All @@ -47,11 +48,6 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
}
}

public void Send(IDictionary<string, object> data)
{
EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/journal/1", data);
}

private bool CheckSanity(string edType, IDictionary<string, object> data)
{
// We've already vetted location data via the CheckLocationData method.
Expand Down
10 changes: 3 additions & 7 deletions EDDNResponder/Schemas/NavBeaconScanSchema.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using EddiEddnResponder.Sender;
using EddiEddnResponder.Sender;
using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using Utilities;

Expand All @@ -26,6 +26,7 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
data = eddnState.Location.AugmentStarPos(data);
data = eddnState.GameVersion.AugmentVersion(data);

EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/navbeaconscan/1", data, eddnState);
return true;
}
catch (Exception e)
Expand All @@ -37,10 +38,5 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
return false;
}
}

public void Send(IDictionary<string, object> data)
{
EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/navbeaconscan/1", data);
}
}
}
10 changes: 3 additions & 7 deletions EDDNResponder/Schemas/NavRouteSchema.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using EddiEddnResponder.Sender;
using EddiEddnResponder.Sender;
using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using Utilities;

Expand All @@ -18,6 +18,7 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
if (!edTypes.Contains(edType)) { return false; }
if (eddnState?.GameVersion == null) { return false; }
data = eddnState.GameVersion.AugmentVersion(data);
EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/navroute/1", data, eddnState);
return true;
}
catch (Exception e)
Expand All @@ -29,10 +30,5 @@ public bool Handle(string edType, ref IDictionary<string, object> data, EDDNStat
return false;
}
}

public void Send(IDictionary<string, object> data)
{
EDDNSender.SendToEDDN("https://eddn.edcd.io/schemas/navroute/1", data);
}
}
}
Loading

0 comments on commit cc65e07

Please sign in to comment.