Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
richardbuckle committed Sep 28, 2017
2 parents cd55ba7 + 8176f7d commit cf8abec
Show file tree
Hide file tree
Showing 16 changed files with 279 additions and 232 deletions.
3 changes: 3 additions & 0 deletions DataDefinitions/Body.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ public class Body
// materials
public List<MaterialPresence> materials;

// The reserve level
public string reserves;

/// <summary>
/// Convert gravity in m/s to g
/// </summary>
Expand Down
361 changes: 183 additions & 178 deletions DataDefinitions/CommodityDefinitions.cs

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion EDDI/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# CHANGE LOG

### 2.4.0-b4
* Core
* Revised EDDI's methods for detecting in-game betas
* Events
* Fixed a bug that would cause the 'Ship transfer initiated' event to be silent
* 'Community goal' event - refined the default script, it'll (probably) be coherent now :-)
* Speech Responder
* 'Community goal' event - fixed a bug that was causing EDDI to describe every goal twice
* 'Ship transfer initiated' event - revised to include both the transfer cost and the time to arrival
* Script changes
* If you scan without a DSS, the 'Body Report' script no longer falsely claims that all bodies are unsuitable for landing
* 'Module swapped event' - revised script to better handle swapping to an empty slot

### 2.4.0-b3
* Core
* EDDI's version number is now shown in the application's title bar
Expand Down Expand Up @@ -62,7 +75,7 @@
* Update 'Jumped' and 'Location' events to include system population, when present
* Update 'Screenshot' event, now contains longitude & latitude, when appropriate
* Update 'Ship sold' event, now contains a value for the system where the ship was sold
* Update 'Shipyard transfer' event, now includes transfer time
* Update 'Ship transfer initiated' event, now includes transfer time
* Update 'Star scanned' event to add luminosity class property
* Speech Responder
* Add Spacialise() Cottle function. Details on how to use this are in the SpeechResponder documentation
Expand Down
34 changes: 25 additions & 9 deletions EDDI/EDDI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,12 @@ private bool eventLocation(LocationEvent theEvent)
CurrentStarSystem.z = theEvent.z;
setSystemDistanceFromHome(CurrentStarSystem);

// Update the system population from the journal
if (theEvent.population != null)
{
CurrentStarSystem.population = theEvent.population;
}

if (theEvent.docked == true)
{
// In this case body === station
Expand Down Expand Up @@ -1028,15 +1034,20 @@ private bool eventFSDEngaged(FSDEngagedEvent @event)

private bool eventFileHeader(FileHeaderEvent @event)
{
// If we don't recognise the build number then assume we're in beta
if (ProductionBuilds.Contains(@event.build))
{
inBeta = false;
}
else
{
inBeta = true;
}
// Test whether we're in beta by checking the filename, version described by the header,
// and certain version / build combinations
inBeta =
(
@event.filename.Contains("Beta") ||
@event.version.Contains("Beta") ||
(
@event.version.Contains("2.2") &&
(
@event.build.Contains("r121645/r0") ||
@event.build.Contains("r129516/r0")
)
)
);
Logging.Info(inBeta ? "On beta" : "On live");
EliteConfiguration config = EliteConfiguration.FromFile();
config.Beta = inBeta;
Expand Down Expand Up @@ -1065,6 +1076,10 @@ private bool eventJumped(JumpedEvent theEvent)
CurrentStarSystem.government = theEvent.government;
CurrentStarSystem.security = theEvent.security;
CurrentStarSystem.updatedat = (long)theEvent.timestamp.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
if (theEvent.population != null)
{
CurrentStarSystem.population = theEvent.population;
}

CurrentStarSystem.visits++;
// We don't update lastvisit because we do that when we leave
Expand Down Expand Up @@ -1335,6 +1350,7 @@ private bool eventBodyScanned(BodyScannedEvent theEvent)
{
body.materials.Add(new MaterialPresence(presence.definition, presence.percentage));
}
body.reserves = theEvent.reserves;
body.rings = theEvent.rings;

Logging.Debug("Saving data for scanned body " + theEvent.name);
Expand Down
7 changes: 5 additions & 2 deletions Events/FileHeaderEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class FileHeaderEvent : Event
{
public const string NAME = "File Header";
public const string DESCRIPTION = "Triggered when the file header is read";
public const string SAMPLE = @"{""timestamp"":""2016-06-10T14:31:00Z"", ""event"":""FileHeader"", ""part"":1, ""gameversion"":""2.2"", ""build"":""r131487/r0 "" }";
public const string SAMPLE = @"{""timestamp"":""2017-09-04T00:20:48Z"", ""event"":""Fileheader"", ""part"":1, ""language"":""English\\UK"", ""gameversion"":""2.4 (Beta 4)"", ""build"":""r153766/r0 "" }";
public static Dictionary<string, string> VARIABLES = new Dictionary<string, string>();

static FileHeaderEvent()
Expand All @@ -27,8 +27,11 @@ static FileHeaderEvent()
[JsonProperty("build")]
public string build { get; private set; }

public FileHeaderEvent(DateTime timestamp, string version, string build) : base(timestamp, NAME)
public string filename { get; private set; }

public FileHeaderEvent(DateTime timestamp, string filename, string version, string build) : base(timestamp, NAME)
{
this.filename = filename;
this.version = version;
this.build = build;
}
Expand Down
2 changes: 1 addition & 1 deletion Installer.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "EDDI"
#define MyAppVersion "2.4.0-b3"
#define MyAppVersion "2.4.0-b4"
#define MyAppPublisher "Elite Dangerous Community Developers (EDCD)"
#define MyAppURL "https://github.com/EDCD/EDDI/"
#define MyAppExeName "EDDI.exe"
Expand Down
34 changes: 18 additions & 16 deletions JournalMonitor/JournalMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public class JournalMonitor : LogMonitor, EDDIMonitor
{
private static Regex JsonRegex = new Regex(@"^{.*}$");

public JournalMonitor() : base(GetSavedGamesDir(), @"^Journal.*\.[0-9\.]+\.log$", result => ForwardJournalEntry(result, EDDI.Instance.eventHandler)) { }
public JournalMonitor() : base(GetSavedGamesDir(), @"^Journal.*\.[0-9\.]+\.log$", result =>
ForwardJournalEntry(result, EDDI.Instance.eventHandler)) { }

public static void ForwardJournalEntry(string line, Action<Event> callback)
{
Expand Down Expand Up @@ -742,10 +743,8 @@ public static List<Event> ParseJournalEntry(string line)

string system = getString(data, "System");
decimal distance = getDecimal(data, "Distance");
data.TryGetValue("TransferPrice", out val);
long price = (long)val;
data.TryGetValue("TransferTime", out val);
long time = (long)val;
long? price = getOptionalLong(data, "TransferPrice");
long? time = getOptionalLong(data, "TransferTime");

events.Add(new ShipTransferInitiatedEvent(timestamp, ship, shipId, system, distance, price, time) { raw = line });
}
Expand Down Expand Up @@ -898,7 +897,7 @@ public static List<Event> ParseJournalEntry(string line)
data.TryGetValue("ServerId", out val);
long serverId = (long)val;

events.Add(new ModuleSoldRemoteEvent(timestamp, ship, shipId, storageSlot, serverId, module, price) { raw = line });
events.Add(new ModuleSoldFromStorage(timestamp, ship, shipId, storageSlot, serverId, module, price) { raw = line });
}
handled = true;
break;
Expand Down Expand Up @@ -1907,9 +1906,9 @@ public static List<Event> ParseJournalEntry(string line)
goaldata.TryGetValue("TierReached", out val);
tier.Add((string)val);
tierreward.Add(getOptionalLong(goaldata, "Bonus"));

events.Add(new CommunityGoalEvent(timestamp, cgid, name, system, station, expiry, iscomplete, total, contribution, contributors, percentileband, topranksize, toprank, tier, tierreward) { raw = line });
}

events.Add(new CommunityGoalEvent(timestamp, cgid, name, system, station, expiry, iscomplete, total, contribution, contributors, percentileband, topranksize, toprank, tier, tierreward) { raw = line });
handled = true;
break;
}
Expand Down Expand Up @@ -2377,9 +2376,11 @@ public static List<Event> ParseJournalEntry(string line)
}
case "Fileheader":
{
string filename = journalFileName;
string version = getString(data, "gameversion");
string build = getString(data, "build").Replace(" ", "");
events.Add(new FileHeaderEvent(timestamp, version, build) { raw = line });

events.Add(new FileHeaderEvent(timestamp, filename, version, build) { raw = line });
handled = true;
break;
}
Expand Down Expand Up @@ -2738,13 +2739,14 @@ private static bool getBool(string key, object val)
private static bool? getOptionalBool(IDictionary<string, object> data, string key)
{
object val;
data.TryGetValue(key, out val);
return getOptionalBool(key, val);
}

private static bool? getOptionalBool(string key, object val)
{
return (bool?)val;
if (data.TryGetValue(key, out val))
{
return val as bool?;
}
else
{
return null;
}
}

private static string getString(IDictionary<string, object> data, string key)
Expand Down
4 changes: 4 additions & 0 deletions JournalMonitor/LogMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class LogMonitor
public string Directory;
public Regex Filter;
public Action<string> Callback;
public static string journalFileName = null;

// Keep track of status
private bool running;
Expand Down Expand Up @@ -56,6 +57,7 @@ public void start()
{
lastSize = fileInfo.Length;
lastName = fileInfo.Name;
journalFileName = lastName;

// Elite-specific: start off by grabbing the first line so that we know if we're in beta or live
using (FileStream fs = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Expand All @@ -79,9 +81,11 @@ public void start()
{
lastName = fileInfo == null ? null : fileInfo.Name;
lastSize = 0;
journalFileName = fileInfo.Name;
}
else
{
journalFileName = fileInfo.Name;
long thisSize = fileInfo.Length;
long seekPos = 0;
int readLen = 0;
Expand Down
2 changes: 1 addition & 1 deletion ShipMonitor/EddiShipMonitor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="ModuleSoldRemoteEvent.cs" />
<Compile Include="ModuleSoldFromStorageEvent.cs" />
<Compile Include="ModulesStored.cs" />
<Compile Include="ModulePurchasedEvent.cs" />
<Compile Include="ModuleRetrievedEvent.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

namespace EddiShipMonitor
{
public class ModuleSoldRemoteEvent : Event
public class ModuleSoldFromStorage : Event
{
public const string NAME = "Module sold remote";
public const string DESCRIPTION = "Triggered when selling a module in storage at another station";
public const string NAME = "Module sold from storage";
public const string DESCRIPTION = "Triggered when selling a module from storage";
public const string SAMPLE = "{ \"timestamp\":\"2017-09-20T02:28:37Z\", \"event\":\"ModuleSellRemote\", \"StorageSlot\":10, \"SellItem\":\"$int_fueltank_size4_class3_name;\", \"SellItem_Localised\":\"Fuel Tank\", \"ServerId\":128064349, \"SellPrice\":24116, \"Ship\":\"diamondbackxl\", \"ShipID\":38 }";
public static Dictionary<string, string> VARIABLES = new Dictionary<string, string>();

static ModuleSoldRemoteEvent()
static ModuleSoldFromStorage()
{
VARIABLES.Add("ship", "The ship from which the module was sold");
VARIABLES.Add("shipid", "The ID of the ship from which the module was sold");
Expand All @@ -33,7 +33,7 @@ static ModuleSoldRemoteEvent()
public Module module { get; private set; }
public long price { get; private set; }

public ModuleSoldRemoteEvent(DateTime timestamp, string ship, int? shipid, int storageslot, long serverid, Module module, long price) : base(timestamp, NAME)
public ModuleSoldFromStorage(DateTime timestamp, string ship, int? shipid, int storageslot, long serverid, Module module, long price) : base(timestamp, NAME)
{
this.ship = ship;
this.shipid = shipid;
Expand Down
6 changes: 3 additions & 3 deletions ShipMonitor/ShipMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ public void PreHandle(Event @event)
{
handleModuleSoldEvent((ModuleSoldEvent)@event);
}
else if (@event is ModuleSoldRemoteEvent)
else if (@event is ModuleSoldFromStorage)
{
handleModuleSoldRemoteEvent((ModuleSoldRemoteEvent)@event);
handleModuleSoldFromStorageEvent((ModuleSoldFromStorage)@event);
}
else if (@event is ModuleStoredEvent)
{
Expand Down Expand Up @@ -545,7 +545,7 @@ private void handleModuleSoldEvent(ModuleSoldEvent @event)
RemoveModule((int)@event.shipid, @event.slot);
}

private void handleModuleSoldRemoteEvent(ModuleSoldRemoteEvent @event)
private void handleModuleSoldFromStorageEvent(ModuleSoldFromStorage @event)
{
// We don't do anything here as the ship object is unaffected
}
Expand Down
7 changes: 4 additions & 3 deletions ShipMonitor/ShipTransferInitiatedEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class ShipTransferInitiatedEvent : Event
public const string NAME = "Ship transfer initiated";
public const string DESCRIPTION = "Triggered when you initiate a ship transfer";
public const string SAMPLE = "{\"timestamp\":\"2016-06-10T14:32:03Z\",\"event\":\"ShipyardTransfer\",\"ShipType\":\"Adder\",\"ShipID\":1,\"System\":\"Eranin\",\"Distance\":85.639145,\"TransferPrice\":580,\"TransferTime\":600}";
//public const string SAMPLE = "{ \"timestamp\":\"2017-09-24T12:31:38Z\", \"event\":\"ShipyardTransfer\", \"ShipType\":\"Asp\", \"ShipID\":2, \"System\":\"CD-34 9020\", \"Distance\":145.314835, \"TransferPrice\":127713 }";
public static Dictionary<string, string> VARIABLES = new Dictionary<string, string>();

static ShipTransferInitiatedEvent()
Expand All @@ -39,12 +40,12 @@ static ShipTransferInitiatedEvent()
public decimal distance { get; private set; }

[JsonProperty("price")]
public long price { get; private set; }
public long? price { get; private set; }

[JsonProperty("time")]
public long time { get; private set; }
public long? time { get; private set; }

public ShipTransferInitiatedEvent(DateTime timestamp, string ship, int? shipid, string system, decimal distance, long price, long time) : base(timestamp, NAME)
public ShipTransferInitiatedEvent(DateTime timestamp, string ship, int? shipid, string system, decimal distance, long? price, long? time) : base(timestamp, NAME)
{
this.ship = ship;
this.shipid = shipid;
Expand Down
Loading

0 comments on commit cf8abec

Please sign in to comment.