Skip to content

Commit 561317e

Browse files
committed
Verious minor code tidy-ups.
1 parent 2564125 commit 561317e

File tree

12 files changed

+25
-34
lines changed

12 files changed

+25
-34
lines changed

DataDefinitions/NavBookmark.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,7 @@ public long? arrivalRadiusMeters
148148

149149
public bool nearby = false;
150150

151-
public bool useStraightPath
152-
{
153-
get => _useStraightPath;
154-
set => _useStraightPath = value;
155-
}
156-
[JsonIgnore] private bool _useStraightPath;
151+
public bool useStraightPath { get; set; }
157152

158153
public SortedSet<DateTime> visitLog
159154
{

DataProviderService/DataProviderService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public List<StarSystem> GetOrCreateStarSystems ( Dictionary<ulong, string> reque
6161
return results;
6262
}
6363

64-
public StarSystem GetOrFetchStarSystem ( ulong systemAddress, string systemName = null, bool fetchIfMissing = true, bool refreshIfOutdated = true, bool showMarketDetails = false )
64+
public StarSystem GetOrFetchStarSystem ( ulong systemAddress, bool fetchIfMissing = true, bool refreshIfOutdated = true, bool showMarketDetails = false )
6565
{
6666
if ( systemAddress <= 0 ) { return null; }
6767

EDDI/EDDI.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1517,7 +1517,7 @@ private bool eventCarrierJumpEngaged(CarrierJumpEngagedEvent @event)
15171517
Vehicle = Constants.VEHICLE_SHIP;
15181518

15191519
// Make sure we have at least basic information about the destination star system
1520-
NextStarSystem = DataProvider.GetOrFetchStarSystem( @event.systemAddress, @event.systemname ) ??
1520+
NextStarSystem = DataProvider.GetOrFetchStarSystem( @event.systemAddress ) ??
15211521
new StarSystem()
15221522
{
15231523
systemname = @event.systemname,
@@ -1542,7 +1542,7 @@ private bool eventCarrierJumpEngaged(CarrierJumpEngagedEvent @event)
15421542
else if (!string.IsNullOrEmpty(@event.originSystemName))
15431543
{
15441544
// Remove the carrier from its prior location in the origin system so that we can re-save it with a new location
1545-
var starSystem = DataProvider.GetOrFetchStarSystem(@event.originSystemAddress, @event.originSystemName);
1545+
var starSystem = DataProvider.GetOrFetchStarSystem(@event.originSystemAddress);
15461546
var carrier = starSystem?.stations.FirstOrDefault(s => s.marketId == @event.carrierId);
15471547
starSystem?.stations.RemoveAll(s => s.marketId == @event.carrierId);
15481548
// Save the carrier to the updated star system
@@ -1557,7 +1557,7 @@ private bool eventCarrierJumpEngaged(CarrierJumpEngagedEvent @event)
15571557
}
15581558
else
15591559
{
1560-
var updatedStarSystem = DataProvider.GetOrFetchStarSystem(@event.systemAddress, @event.systemname);
1560+
var updatedStarSystem = DataProvider.GetOrFetchStarSystem(@event.systemAddress);
15611561
if (updatedStarSystem != null)
15621562
{
15631563
updatedStarSystem.stations.Add(carrier);
@@ -2453,7 +2453,7 @@ internal void updateCurrentSystem(string systemName, ulong systemAddress)
24532453
}
24542454
else
24552455
{
2456-
CurrentStarSystem = DataProvider.GetOrFetchStarSystem( systemAddress, systemName ) ??
2456+
CurrentStarSystem = DataProvider.GetOrFetchStarSystem( systemAddress ) ??
24572457
new StarSystem { systemname = systemName, systemAddress = systemAddress};
24582458
}
24592459

@@ -2515,7 +2515,7 @@ private bool eventFSDEngaged(FSDEngagedEvent @event)
25152515
private bool eventFSDTarget(FSDTargetEvent @event)
25162516
{
25172517
// Set and prepare data about the next star system
2518-
NextStarSystem = DataProvider.GetOrFetchStarSystem(@event.systemAddress, @event.system );
2518+
NextStarSystem = DataProvider.GetOrFetchStarSystem(@event.systemAddress );
25192519
if (NextStarSystem != null && !NextStarSystem.bodies.Any(b => b.mainstar ?? false))
25202520
{
25212521
// This system is unknown to us, might not be recorded, or we might not have connectivity. Use a placeholder main star
@@ -3509,7 +3509,7 @@ public void updateDestinationSystem ( ulong? destinationSystemAddress, string de
35093509
var configuration = ConfigService.Instance.eddiConfiguration;
35103510
if ( destinationSystemAddress > 0 )
35113511
{
3512-
var system = DataProvider.GetOrFetchStarSystem((ulong)destinationSystemAddress, destinationSystem );
3512+
var system = DataProvider.GetOrFetchStarSystem((ulong)destinationSystemAddress );
35133513

35143514
//Ignore null & empty systems
35153515
if (system != null)
@@ -3536,7 +3536,7 @@ public void setHomeSystem ( ulong? newSystemAddress, string newSystemName )
35363536
StarSystem newSystem = null;
35373537
if ( newSystemAddress != null )
35383538
{
3539-
newSystem = DataProvider.GetOrFetchStarSystem( (ulong)newSystemAddress, newSystemName );
3539+
newSystem = DataProvider.GetOrFetchStarSystem( (ulong)newSystemAddress );
35403540
}
35413541
if ( newSystem is null && !string.IsNullOrEmpty( newSystemName ) )
35423542
{
@@ -3591,7 +3591,7 @@ public void setSquadronSystem ( ulong? newSystemAddress, string newSystemName )
35913591
StarSystem newSystem = null;
35923592
if ( newSystemAddress != null )
35933593
{
3594-
newSystem = DataProvider.GetOrFetchStarSystem( (ulong)newSystemAddress, newSystemName );
3594+
newSystem = DataProvider.GetOrFetchStarSystem( (ulong)newSystemAddress );
35953595
}
35963596
if ( newSystem is null && !string.IsNullOrEmpty(newSystemName) )
35973597
{

EDDI/MainWindow.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ private async void createGithubIssueClicked(object sender, RoutedEventArgs e)
12081208
}
12091209
Logging.Info("Commander name: " + (EDDI.Instance.Cmdr != null ? EDDI.Instance.Cmdr.name : "null"));
12101210
Logging.Info("Default UI culture: " + (CultureInfo.DefaultThreadCurrentUICulture?.IetfLanguageTag ?? "automatic"));
1211-
Logging.Info("Current UI culture: " + (CultureInfo.CurrentUICulture.IetfLanguageTag));
1211+
Logging.Info("Current UI culture: " + CultureInfo.CurrentUICulture.IetfLanguageTag);
12121212

12131213
// Prepare a truncated log file for export if verbose logging is enabled
12141214
if (eddiVerboseLogging.IsChecked ?? false)

EddiSpanshService/SpanshQuery.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public JToken DistanceOrderedQuery ( QueryGroup queryGroup, decimal fromX, decim
3636
// TODO: Handle multi-page responses (see BgsService for example)
3737
private static IRestRequest GetRestRequest ( QueryGroup queryGroup, [NotNull] Dictionary<string, object> filter, int? maxResults, int? pageId )
3838
{
39-
var request = new RestRequest($@"{queryGroup.ToString()}/search") { Method = Method.POST };
39+
var request = new RestRequest($@"{queryGroup}/search") { Method = Method.POST };
4040
var jsonObject = new
4141
{
4242
filters = filter,
@@ -49,7 +49,7 @@ private static IRestRequest GetRestRequest ( QueryGroup queryGroup, [NotNull] Di
4949

5050
private static IRestRequest GetDistanceOrderedRestRequest ( QueryGroup queryGroup, decimal fromX, decimal fromY, decimal fromZ, [NotNull] Dictionary<string, object> filter )
5151
{
52-
var request = new RestRequest($@"{queryGroup.ToString()}/search") { Method = Method.POST };
52+
var request = new RestRequest($@"{queryGroup}/search") { Method = Method.POST };
5353
var jsonObject = new
5454
{
5555
filters = filter,

Events/ModificationCraftedEvent.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class ModificationCraftedEvent : Event
4646

4747
public Module Module { get; private set; }
4848

49-
public ModificationCraftedEvent(DateTime timestamp, string engineer, long engineerId, string blueprint, long blueprintId, int level, decimal? quality, string experimentalEffect, List<MaterialAmount> materials, List<CommodityAmount> commodities, string slot, Module module) : base(timestamp, NAME)
49+
public ModificationCraftedEvent(DateTime timestamp, string engineer, long engineerId, string blueprint, long blueprintId, int level, decimal? quality, string experimentalEffect, List<MaterialAmount> materials, List<CommodityAmount> commodities, string slot, Module Module) : base(timestamp, NAME)
5050
{
5151
this.engineer = engineer;
5252
this.engineerId = -engineerId;

Events/ShipLoadoutEvent.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ [ PublicAPI( "The optimal mass value of the frame shift drive" ) ]
6565

6666
public Ship shipDefinition => ShipDefinitions.FromEDModel(edModel);
6767

68-
private Module frameShiftDrive;
68+
private Module frameShiftDrive { get; set; }
6969

7070
public string edModel { get; private set; }
7171

GalnetMonitor/GalnetMonitor.cs

-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ public class GalnetMonitor : IEddiMonitor
3737
private bool running;
3838
private DateTime journalTimeStamp;
3939

40-
// This monitor currently requires game version 4.0 or later.
41-
private static readonly System.Version minGameVersion = new System.Version(4, 0);
42-
4340
public GalnetMonitor ()
4441
{
4542
configuration = ConfigService.Instance.galnetConfiguration;

JournalMonitor/JournalMonitor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4434,7 +4434,7 @@ dest.y is decimal sy &&
44344434
// There is a bug in the journal output where "Body" can be missing but "BodyID" can be present. Try to Work around that here.
44354435
if (string.IsNullOrEmpty(bodyName) && systemAddress > 0)
44364436
{
4437-
var starSystem = EDDI.Instance.DataProvider.GetOrFetchStarSystem(systemAddress, systemName, true, true);
4437+
var starSystem = EDDI.Instance.DataProvider.GetOrFetchStarSystem(systemAddress, true, true);
44384438
bodyName = starSystem?.bodies?.FirstOrDefault(b => b?.bodyId == bodyId)?.bodyname;
44394439
}
44404440

JournalMonitor/LogMonitor.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ namespace EddiJournalMonitor
1313
public class LogMonitor
1414
{
1515
// What we are monitoring and what to do with it
16-
private string Directory;
17-
private Regex Filter;
18-
private Action<IEnumerable<string>, bool> Callback;
16+
private readonly string Directory;
17+
private readonly Regex Filter;
18+
private readonly Action<IEnumerable<string>, bool> Callback;
1919
protected static string journalFileName;
2020

2121
private const int pollingIntervalActiveMs = 100;

NavigationService/QueryResolvers/MissionQueryResolvers.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ private RouteDetailsEvent GetFarthestMissionRoute ( [ NotNull ] StarSystem start
116116
var startSystemWaypoint = new NavWaypoint( startSystem ) { visited = true };
117117
navRouteList.Waypoints.Add( startSystemWaypoint );
118118

119-
120119
var farthestList = new SortedList<decimal, NavWaypoint>();
121120
foreach ( var mission in missions.Where( m => m.statusDef == MissionStatus.Active ).ToList() )
122121
{
@@ -309,7 +308,7 @@ private RouteDetailsEvent GetRepetiveNearestNeighborMissionRoute ( [ NotNull ] S
309308
// Add origin systems for 'return to origin' missions to the 'systems' list
310309
foreach ( var mission in missions.Where ( m => m.statusDef != MissionStatus.Failed ) )
311310
{
312-
if ( mission.originreturn && !systems.Contains ( mission.originsystem ) )
311+
if ( mission.originreturn && !string.IsNullOrEmpty( mission.originsystem ) && !systems.Contains ( mission.originsystem ) )
313312
{
314313
systems.Add ( mission.originsystem );
315314
}

SpeechService/Humanize.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static string Humanize(decimal? rawValue, bool? forceIntegerMantissa = nu
1919
if ( value == 0 )
2020
{
2121
var result = Properties.Phrases.zero;
22-
Logging.Debug( $"Converted raw value '{rawValue.ToString()}' to '{result}'" );
22+
Logging.Debug( $"Converted raw value '{rawValue}' to '{result}'" );
2323
return result;
2424
}
2525

@@ -44,7 +44,7 @@ public static string Humanize(decimal? rawValue, bool? forceIntegerMantissa = nu
4444
// Now round it to 2sf
4545
var result = ( isNegative ? Properties.Phrases.minus + " " : "" ) +
4646
( Math.Round( value * 10 ) / (decimal)Math.Pow( 10, numzeros + 2 ) );
47-
Logging.Debug($"Converted raw value '{rawValue.ToString()}' to '{result}'");
47+
Logging.Debug($"Converted raw value '{rawValue}' to '{result}'");
4848
return result;
4949
}
5050

@@ -58,20 +58,20 @@ public static string Humanize(decimal? rawValue, bool? forceIntegerMantissa = nu
5858
// Some languages render these differently than others. "1000" in English is "one thousand" but in Italian is simply "mille".
5959
// Consequently, we leave the interpretation to the culture-specific voice.
6060
var result = FormatVerbatim(number, isNegative, orderMultiplier);
61-
Logging.Debug( $"Converted raw value '{rawValue.ToString()}' to '{result}'" );
61+
Logging.Debug( $"Converted raw value '{rawValue}' to '{result}'" );
6262
return result;
6363
}
6464

6565
if (number < 100)
6666
{
6767
var result = FormatWith2SignificantDigits(number, isNegative, orderMultiplier, nextDigit, value, wantIntegerMantissa);
68-
Logging.Debug( $"Converted raw value '{rawValue.ToString()}' to '{result}'" );
68+
Logging.Debug( $"Converted raw value '{rawValue}' to '{result}'" );
6969
return result;
7070
}
7171
else // Describe (less precisely) values for numbers where the largest order number exceeds one hundred
7272
{
7373
var result = FormatWith3SignificantDigits(number, isNegative, orderMultiplier, nextDigit, value);
74-
Logging.Debug( $"Converted raw value '{rawValue.ToString()}' to '{result}'" );
74+
Logging.Debug( $"Converted raw value '{rawValue}' to '{result}'" );
7575
return result;
7676
}
7777
}

0 commit comments

Comments
 (0)