mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Removal of ToArray()
This commit is contained in:
parent
9eb22da9e7
commit
9f5cf132f0
41 changed files with 184 additions and 189 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
|
|
@ -18,29 +19,35 @@ namespace ArkData
|
|||
/// <returns>The async task context containing the resulting container.</returns>
|
||||
public static async Task<DataContainer> CreateAsync(string playerFileFolder, string tribeFileFolder)
|
||||
{
|
||||
var playerFiles = new string[0];
|
||||
var tribeFiles = new string[0];
|
||||
IEnumerable<string> playerFiles = null;
|
||||
IEnumerable<string> tribeFiles = null;
|
||||
|
||||
if (Directory.Exists(playerFileFolder))
|
||||
{
|
||||
playerFiles = Directory.GetFiles(playerFileFolder).Where(f => Path.GetFileNameWithoutExtension(f).StartsWith(DataFileDetails.PlayerFilePrefix)
|
||||
&& Path.GetFileNameWithoutExtension(f).EndsWith(DataFileDetails.PlayerFileSuffix)
|
||||
&& Path.GetExtension(f).Equals(DataFileDetails.PlayerFileExtension)).ToArray();
|
||||
&& Path.GetExtension(f).Equals(DataFileDetails.PlayerFileExtension));
|
||||
}
|
||||
if (Directory.Exists(tribeFileFolder))
|
||||
{
|
||||
tribeFiles = Directory.GetFiles(tribeFileFolder).Where(f => Path.GetFileNameWithoutExtension(f).StartsWith(DataFileDetails.TribeFilePrefix)
|
||||
&& Path.GetFileNameWithoutExtension(f).EndsWith(DataFileDetails.TribeFileSuffix)
|
||||
&& Path.GetExtension(f).Equals(DataFileDetails.TribeFileExtension)).ToArray();
|
||||
&& Path.GetExtension(f).Equals(DataFileDetails.TribeFileExtension));
|
||||
}
|
||||
|
||||
var container = new DataContainer();
|
||||
|
||||
foreach (var file in playerFiles)
|
||||
container.Players.Add(await Parser.ParsePlayerAsync(file));
|
||||
if (playerFiles != null)
|
||||
{
|
||||
foreach (var file in playerFiles)
|
||||
container.Players.Add(await Parser.ParsePlayerAsync(file));
|
||||
}
|
||||
|
||||
foreach (var file in tribeFiles)
|
||||
container.Tribes.Add(await Parser.ParseTribeAsync(file));
|
||||
if (tribeFiles != null)
|
||||
{
|
||||
foreach (var file in tribeFiles)
|
||||
container.Tribes.Add(await Parser.ParseTribeAsync(file));
|
||||
}
|
||||
|
||||
container.LinkPlayerTribe();
|
||||
|
||||
|
|
@ -58,14 +65,14 @@ namespace ArkData
|
|||
// need to make multiple calls of 100 steam id's.
|
||||
var lastSteamUpdateUtc = DateTime.UtcNow;
|
||||
var startIndex = 0;
|
||||
var playerSteamIds = Players.Where(p => p.LastPlatformUpdateUtc.AddMinutes(steamUpdateInterval) < DateTime.UtcNow).Select(p => p.PlayerId).ToArray();
|
||||
var playerSteamIds = Players.Where(p => p.LastPlatformUpdateUtc.AddMinutes(steamUpdateInterval) < DateTime.UtcNow).Select(p => p.PlayerId);
|
||||
|
||||
while (true)
|
||||
{
|
||||
// check if the start index has exceeded the Players list count.
|
||||
if (startIndex >= playerSteamIds.Length) break;
|
||||
if (startIndex >= playerSteamIds.Count()) break;
|
||||
// get the number of steam ids to read.
|
||||
int steamIdsCount = System.Math.Min(MAX_STEAM_IDS, playerSteamIds.Length - startIndex);
|
||||
int steamIdsCount = Math.Min(MAX_STEAM_IDS, playerSteamIds.Count() - startIndex);
|
||||
// get a comma delimited list of the steam ids to process
|
||||
var builder = string.Join(",", playerSteamIds, startIndex, steamIdsCount);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue