Skip to content

Commit 5bddf5b

Browse files
authored
Merge pull request #19 from NosCoreIO/UpgradeTo5
Upgrade to5
2 parents 2971454 + 6ecfed7 commit 5bddf5b

File tree

6 files changed

+29
-19
lines changed

6 files changed

+29
-19
lines changed

src/NosCore.ParserInputGenerator.Launcher/Worker.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
8787
var entry = TarEntry.CreateEntryFromFile(fileToBeTarred.FullName);
8888
tarArchive.WriteEntry(entry, true);
8989
}
90+
tarArchive.Dispose();
9091
_logger.LogInformation(LogLanguage.Instance.GetMessageFromKey(LogLanguageKey.PARSER_INPUT_GENERATED));
9192
}
9293
}

src/NosCore.ParserInputGenerator/Downloader/ClientDownloader.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
using System.IO;
99
using System.Linq;
1010
using System.Net.Http;
11+
using System.Text.Json;
12+
using System.Text.Json.Serialization;
1113
using System.Threading.Tasks;
1214
using Microsoft.Extensions.Logging;
13-
using Newtonsoft.Json;
1415
using NosCore.ParserInputGenerator.I18N;
1516
using NosCore.Shared.Enumerations;
1617

@@ -35,7 +36,10 @@ public async Task<ClientManifest> DownloadManifestAsync(RegionType region)
3536
using var result = await client
3637
.GetAsync($"https://spark.gameforge.com/api/v1/patching/download/latest/nostale/default?locale=${region}&architecture=x64&branchToken")
3738
.ConfigureAwait(false);
38-
return JsonConvert.DeserializeObject<ClientManifest>(await result.Content.ReadAsStringAsync().ConfigureAwait(false));
39+
return JsonSerializer.Deserialize<ClientManifest>(await result.Content.ReadAsStringAsync().ConfigureAwait(false), new JsonSerializerOptions
40+
{
41+
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault
42+
}) ?? throw new InvalidOperationException();
3943
}
4044

4145
public async Task DownloadClientAsync() => await DownloadClientAsync(await DownloadManifest());
@@ -61,6 +65,9 @@ async Task Download(Entry entry)
6165
return;
6266
}
6367
}
68+
69+
_logger.LogInformation(LogLanguage.Instance.GetMessageFromKey(LogLanguageKey.DOWNLOADING),
70+
entry.Path);
6471
using var response = await client.GetAsync($"http://patches.gameforge.com/" + entry.Path)
6572
.ConfigureAwait(false);
6673

src/NosCore.ParserInputGenerator/Downloader/ClientManifest.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
1-
using Newtonsoft.Json;
1+
using System.Text.Json;
2+
using System.Text.Json.Serialization;
23

34
namespace NosCore.ParserInputGenerator.Downloader
45
{
56
public class ClientManifest
67
{
7-
[JsonProperty("entries")]
8+
[JsonPropertyName("entries")]
89
public Entry[] Entries { get; set; } = null!;
910

10-
[JsonProperty("totalSize")]
11+
[JsonPropertyName("totalSize")]
1112
public long TotalSize { get; set; }
1213

13-
[JsonProperty("build")]
14+
[JsonPropertyName("build")]
1415
public long Build { get; set; }
1516
}
1617

1718
public class Entry
1819
{
19-
[JsonProperty("path", NullValueHandling = NullValueHandling.Ignore)]
20-
public string Path { get; set; } = null!;
20+
[JsonPropertyName("path")]
21+
public string? Path { get; set; }
2122

22-
[JsonProperty("sha1", NullValueHandling = NullValueHandling.Ignore)]
23-
public string Sha1 { get; set; } = null!;
23+
[JsonPropertyName("sha1")]
24+
public string? Sha1 { get; set; }
2425

25-
[JsonProperty("file")]
26+
[JsonPropertyName("file")]
2627
public string File { get; set; } = null!;
2728

28-
[JsonProperty("flags")]
29+
[JsonPropertyName("flags")]
2930
public long Flags { get; set; }
3031

31-
[JsonProperty("size")]
32+
[JsonPropertyName("size")]
3233
public long Size { get; set; }
3334

34-
[JsonProperty("folder")]
35+
[JsonPropertyName("folder")]
3536
public bool Folder { get; set; }
3637
}
3738

src/NosCore.ParserInputGenerator/Extractor/Extractor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async Task WriteFile(string fileName, MemoryStream decryptedContent)
3030
if (rename && fileName.Contains("."))
3131
{
3232
var name = fileName.Substring(0, fileName.IndexOf('.'));
33-
var ext = fileName.Substring(fileName.IndexOf('.'));
33+
var ext = fileName[fileName.IndexOf('.')..];
3434
await using var fileStream =
3535
File.Create(
3636
$"{directory}{name}{nosFile.Name.Substring(nosFile.Name.LastIndexOf('_'), 3)}{ext}");
@@ -107,7 +107,7 @@ async Task WriteFile(string fileName, MemoryStream decryptedContent)
107107
}
108108
}
109109

110-
private byte[] DecryptDat(byte[] array)
110+
private static byte[] DecryptDat(byte[] array)
111111
{
112112
var cryptoarray = new[]
113113
{0x00, 0x20, 0x2D, 0x2E, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x0A, 0x00};

src/NosCore.ParserInputGenerator/I18N/LogLanguageKey.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public enum LogLanguageKey
1313
{
1414
DOWNLOAD_SUCCESSFULL,
1515
PARSER_INPUT_GENERATED,
16-
ERROR
16+
ERROR,
17+
DOWNLOADING
1718
}
1819
}

src/NosCore.ParserInputGenerator/NosCore.ParserInputGenerator.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
@@ -12,7 +12,7 @@
1212
<RepositoryUrl>https://github.com/NosCoreIO/NosCore.ParserInputGenerator.git</RepositoryUrl>
1313
<PackageIconUrl></PackageIconUrl>
1414
<PackageTags>nostale, noscore, nostale private server source, nostale emulator</PackageTags>
15-
<Version>1.3.0</Version>
15+
<Version>1.4.0</Version>
1616
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
1717
<Description>NosCore's Parser InputGenerator</Description>
1818
<PackageLicenseExpression></PackageLicenseExpression>

0 commit comments

Comments
 (0)