Skip to content

Commit

Permalink
Refactor EDDN Responder and add support for all current schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
Tkael committed Nov 13, 2022
1 parent dc1ef8f commit dd25a0a
Show file tree
Hide file tree
Showing 35 changed files with 2,060 additions and 879 deletions.
3 changes: 3 additions & 0 deletions DataDefinitions/FleetCarrier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ string ConvertHexString(string hexString)

// Station properties
Market = FrontierApiStation.FromJson(newJson["market"]?.ToObject<JObject>(), null);
Market.commoditiesupdatedat = newTimeStamp;
Market.outfittingupdatedat = newTimeStamp;
Market.shipyardupdatedat = newTimeStamp;

// Misc - Tritium stored in cargo
foreach (var cargo in Cargo)
Expand Down
11 changes: 6 additions & 5 deletions DataDefinitions/FrontierApiStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ List<ShipyardInfoItem> ShipyardFromProfile(JObject json)
List<ShipyardInfoItem> edShipyardShips = new List<ShipyardInfoItem>();
if (json?["ships"] != null)
{
edShipyardShips = json?["ships"]["shipyard_list"].Children().Values()
.Select(s => JsonConvert.DeserializeObject<ShipyardInfoItem>(s.ToString())).ToList();
edShipyardShips = json["ships"]?["shipyard_list"]?.Children().Values()
.Select(s => JsonConvert.DeserializeObject<ShipyardInfoItem>(s.ToString()))
.ToList() ?? new List<ShipyardInfoItem>();

if (json["ships"]["unavailable_list"] != null)
{
Expand All @@ -169,7 +170,7 @@ List<ShipyardInfoItem> ShipyardFromProfile(JObject json)
lastStation.economyShares = EconomiesFromProfile(marketJson);
lastStation.eddnCommodityMarketQuotes = CommodityQuotesFromProfile(marketJson);
lastStation.prohibitedCommodities = ProhibitedCommoditiesFromProfile(marketJson);
lastStation.commoditiesupdatedat = marketJson["timestamp"].ToObject<DateTime?>() ?? DateTime.MinValue;
lastStation.commoditiesupdatedat = marketJson["timestamp"]?.ToObject<DateTime?>() ?? DateTime.MinValue;
lastStation.marketJson = marketJson;

List<KeyValuePair<string, string>> stationServices = new List<KeyValuePair<string, string>>();
Expand All @@ -187,8 +188,8 @@ List<ShipyardInfoItem> ShipyardFromProfile(JObject json)
lastStation.outfitting = OutfittingFromProfile(shipyardJson);
lastStation.ships = ShipyardFromProfile(shipyardJson);
lastStation.shipyardJson = shipyardJson;
lastStation.outfittingupdatedat = shipyardJson["timestamp"].ToObject<DateTime?>() ?? DateTime.MinValue;
lastStation.shipyardupdatedat = shipyardJson["timestamp"].ToObject<DateTime?>() ?? DateTime.MinValue;
lastStation.outfittingupdatedat = shipyardJson["timestamp"]?.ToObject<DateTime?>() ?? DateTime.MinValue;
lastStation.shipyardupdatedat = shipyardJson["timestamp"]?.ToObject<DateTime?>() ?? DateTime.MinValue;
}
}
catch (JsonException ex)
Expand Down
4 changes: 2 additions & 2 deletions DataDefinitions/ModuleDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1211,9 +1211,9 @@ static Module()
"Hpt_MultiCannon_Fixed_Small_Strong", // Enforcer cannon
"Hpt_PulseLaser_Fixed_Medium_Disruptor", // Disruptor
};
public bool IsPowerPlay()
public static bool IsPowerPlay(string edname)
{
return PowerPlayModules.Contains(this.edname);
return PowerPlayModules.Contains(edname);
}

private static string NormalizedEDName(string rawEDName)
Expand Down
4 changes: 1 addition & 3 deletions DataDefinitions/OutfittingInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Newtonsoft.Json;
using System;
using System;
using System.Collections.Generic;
using Utilities;

namespace EddiDataDefinitions
{
Expand Down
2 changes: 2 additions & 0 deletions EDDI/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Full details of the variables available for each noted event, and VoiceAttack in
* Crime Monitor
* Fixed a bug that could identify a fleet carrier as a faction station.
* Moved navigation functions to the Navigation Monitor
* EDDN Responder
* Updated schema support to include all current schemas from https://github.com/EDCD/EDDN/tree/master/schemas.
* Inara Responder
* Fixed an issue with asset data not being reported correctly.
* Material Monitor
Expand Down
2 changes: 1 addition & 1 deletion EDDNResponder/EDDNEconomy.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using EddiDataDefinitions;

namespace EDDNResponder
namespace EddiEddnResponder
{
class EDDNEconomy
{
Expand Down
9 changes: 0 additions & 9 deletions EDDNResponder/EDDNHeader.cs

This file was deleted.

Loading

0 comments on commit dd25a0a

Please sign in to comment.