Minor Changes to Resolve Warnings (#5)
Resolves a number of CS0109, HAA060, and HAA0401 warnings. See commits for details. Reviewed-on: #5 Co-authored-by: Refringe <me@refringe.com> Co-committed-by: Refringe <me@refringe.com>
This commit is contained in:
parent
5083c7c5c3
commit
294881dcca
@ -69,7 +69,7 @@ namespace Common.Models.Output
|
|||||||
public Dictionary<string, int> TacticalVest { get; set; }
|
public Dictionary<string, int> TacticalVest { get; set; }
|
||||||
public Dictionary<string, int> Pockets { get; set; }
|
public Dictionary<string, int> Pockets { get; set; }
|
||||||
public Dictionary<string, int> Backpack { get; set; }
|
public Dictionary<string, int> Backpack { get; set; }
|
||||||
public new Dictionary<string, int> SecuredContainer { get; set; }
|
public Dictionary<string, int> SecuredContainer { get; set; }
|
||||||
public new Dictionary<string, int> SpecialLoot { get; set; }
|
public Dictionary<string, int> SpecialLoot { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public static class BotParser
|
|||||||
DiskHelpers.CreateDirIfDoesntExist(dumpPath);
|
DiskHelpers.CreateDirIfDoesntExist(dumpPath);
|
||||||
|
|
||||||
var botFiles = Directory.GetFiles(dumpPath, "*.json", SearchOption.TopDirectoryOnly);
|
var botFiles = Directory.GetFiles(dumpPath, "*.json", SearchOption.TopDirectoryOnly);
|
||||||
LoggingHelpers.LogToConsole($"{botFiles.Length} bot dump files found");
|
LoggingHelpers.LogToConsole($"{botFiles.Length.ToString()} bot dump files found");
|
||||||
|
|
||||||
// Store a list of parsed bots so we don't parse the same bot twice
|
// Store a list of parsed bots so we don't parse the same bot twice
|
||||||
int totalDupeCount = 0;
|
int totalDupeCount = 0;
|
||||||
@ -42,7 +42,7 @@ public static class BotParser
|
|||||||
foreach (var filePath in botFiles)
|
foreach (var filePath in botFiles)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
if (i % 100 == 0) Console.WriteLine($"Processing file {i}");
|
if (i % 500 == 0) Console.WriteLine($"Processing file {i.ToString()}");
|
||||||
ProcessBotFileSync(baseBots, filePath, parsedBotIds, totalDupeCount);
|
ProcessBotFileSync(baseBots, filePath, parsedBotIds, totalDupeCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ public static class BotParser
|
|||||||
}
|
}
|
||||||
|
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
LoggingHelpers.LogToConsole($"{totalDupeCount} dupes were ignored. Took {LoggingHelpers.LogTimeTaken(stopwatch.Elapsed.TotalSeconds)} seconds");
|
LoggingHelpers.LogToConsole($"{totalDupeCount.ToString()} dupes were ignored. Took {LoggingHelpers.LogTimeTaken(stopwatch.Elapsed.TotalSeconds)} seconds");
|
||||||
|
|
||||||
return baseBots.ToList();
|
return baseBots.ToList();
|
||||||
}
|
}
|
||||||
@ -84,15 +84,14 @@ public static class BotParser
|
|||||||
|
|
||||||
int dupeCount = 0;
|
int dupeCount = 0;
|
||||||
|
|
||||||
List<Datum> bots = [];
|
List<Datum> bots = new List<Datum>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Parse the bots inside the json file
|
// Parse the bots inside the json file
|
||||||
using (var reader = new StreamReader(filePath))
|
using (var reader = new StreamReader(filePath))
|
||||||
{
|
{
|
||||||
var deSerialisedObject = JsonSerializer.Deserialize<Root>(reader.ReadToEnd(), serialiserOptions);
|
var deSerialisedObject = JsonSerializer.Deserialize<Root>(reader.ReadToEnd(), serialiserOptions);
|
||||||
|
foreach (var botData in deSerialisedObject.data.ToList())
|
||||||
foreach (var botData in deSerialisedObject.data)
|
|
||||||
{
|
{
|
||||||
// Bot fucks up something, never allow it in
|
// Bot fucks up something, never allow it in
|
||||||
if (botData._id == "6483938c53cc9087c70eae86")
|
if (botData._id == "6483938c53cc9087c70eae86")
|
||||||
@ -101,10 +100,22 @@ public static class BotParser
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var baseBot = baseBots.SingleOrDefault(bot => bot.botType.ToString().Equals(botData.Info.Settings.Role, StringComparison.OrdinalIgnoreCase));
|
var role = botData.Info.Settings.Role;
|
||||||
|
var botType = Enum.Parse<BotType>(role, true);
|
||||||
|
|
||||||
|
Bot baseBot = null;
|
||||||
|
foreach (var bot in baseBots)
|
||||||
|
{
|
||||||
|
if (bot.botType == botType)
|
||||||
|
{
|
||||||
|
baseBot = bot;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (baseBot == null)
|
if (baseBot == null)
|
||||||
{
|
{
|
||||||
//Console.WriteLine($"Skipping {botData._id} due to unknown role {botData.Info.Settings.Role}");
|
Console.WriteLine($"Skipping {botData._id} due to unknown role {botData.Info.Settings.Role}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +132,7 @@ public static class BotParser
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"File parse fucked up: {filePath}");
|
Console.WriteLine($"File parse fucked up: {filePath}");
|
||||||
throw;
|
throw;
|
||||||
@ -137,7 +148,7 @@ public static class BotParser
|
|||||||
DiskHelpers.CreateDirIfDoesntExist(dumpPath);
|
DiskHelpers.CreateDirIfDoesntExist(dumpPath);
|
||||||
|
|
||||||
var botFiles = Directory.GetFiles(dumpPath, "*.json", SearchOption.TopDirectoryOnly);
|
var botFiles = Directory.GetFiles(dumpPath, "*.json", SearchOption.TopDirectoryOnly);
|
||||||
LoggingHelpers.LogToConsole($"{botFiles.Length} bot dump files found");
|
LoggingHelpers.LogToConsole($"{botFiles.Length.ToString()} bot dump files found");
|
||||||
|
|
||||||
// key = bot type
|
// key = bot type
|
||||||
// Store bots keyed against their ID so we never get duplicates
|
// Store bots keyed against their ID so we never get duplicates
|
||||||
@ -153,9 +164,9 @@ public static class BotParser
|
|||||||
await Task.WhenAll(tasks.ToArray());
|
await Task.WhenAll(tasks.ToArray());
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
|
|
||||||
LoggingHelpers.LogToConsole($"Cleaned and Parsed: {parsedBotsDict.Count} bots. {totalDupeCount} dupes were ignored. Took {LoggingHelpers.LogTimeTaken(stopwatch.Elapsed.TotalSeconds)} seconds");
|
LoggingHelpers.LogToConsole($"Cleaned and Parsed: {parsedBotsDict.Count.ToString()} bots. {totalDupeCount.ToString()} dupes were ignored. Took {LoggingHelpers.LogTimeTaken(stopwatch.Elapsed.TotalSeconds)} seconds");
|
||||||
|
|
||||||
return [.. parsedBotsDict.Values];
|
return parsedBotsDict.Values.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<int> ProcessBotFile(
|
private static async Task<int> ProcessBotFile(
|
||||||
@ -168,17 +179,27 @@ public static class BotParser
|
|||||||
|
|
||||||
int dupeCount = 0;
|
int dupeCount = 0;
|
||||||
|
|
||||||
List<Datum> bots = [];
|
List<Datum> bots = new List<Datum>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Parse the bots inside the json file
|
// Parse the bots inside the json file
|
||||||
using (var reader = new StreamReader(filePath))
|
using var reader = new StreamReader(filePath);
|
||||||
|
var deSerialisedObject = await JsonSerializer.DeserializeAsync<Root>(reader.BaseStream, serialiserOptions);
|
||||||
|
|
||||||
|
var botTypesLower = new HashSet<string>(botTypes, StringComparer.OrdinalIgnoreCase);
|
||||||
|
var filteredBots = new List<Datum>();
|
||||||
|
foreach (var botData in deSerialisedObject.data.ToList())
|
||||||
{
|
{
|
||||||
var deSerialisedObject = JsonSerializer.Deserialize<Root>(reader.ReadToEnd(), serialiserOptions);
|
var roleLower = botData.Info.Settings.Role.ToLower();
|
||||||
bots.AddRange(deSerialisedObject.data.Where(botData => botTypes.Contains(botData.Info.Settings.Role.ToLower())));
|
if (botTypesLower.Contains(roleLower))
|
||||||
|
{
|
||||||
|
filteredBots.Add(botData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
|
bots.AddRange(filteredBots);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"File parse fucked up: {filePath}");
|
Console.WriteLine($"File parse fucked up: {filePath}");
|
||||||
throw;
|
throw;
|
||||||
@ -235,8 +256,9 @@ public static class BotParser
|
|||||||
|
|
||||||
if (jItemsToReplace != null && jItemsToReplace.Any())
|
if (jItemsToReplace != null && jItemsToReplace.Any())
|
||||||
{
|
{
|
||||||
LoggingHelpers.LogToConsole($"file {fileName} has {jItemsToReplace.Count()} json issues, cleaning up.", ConsoleColor.Yellow);
|
LoggingHelpers.LogToConsole($"file {fileName} has {jItemsToReplace.Count().ToString()} json issues, cleaning up.", ConsoleColor.Yellow);
|
||||||
foreach (var item in jItemsToReplace)
|
var jItemsToReplaceList = jItemsToReplace.ToList();
|
||||||
|
foreach (var item in jItemsToReplaceList)
|
||||||
{
|
{
|
||||||
var obj = new { x = 1, y = 0, r = 0 };
|
var obj = new { x = 1, y = 0, r = 0 };
|
||||||
item.Replace(JToken.FromObject(obj));
|
item.Replace(JToken.FromObject(obj));
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user