Skip to content

Commit f7d11e0

Browse files
committed
"fix" cache
not really, but oh well
1 parent 02959f7 commit f7d11e0

File tree

6 files changed

+54
-16
lines changed

6 files changed

+54
-16
lines changed

Hi3Helper.Plugin.DNA/Exports.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Hi3Helper.Plugin.DNA;
1313
public partial class DNAbyss : SharedStaticV1Ext<DNAbyss> // 2025-08-18: We use generic version of SharedStatic<T> to add support for game launch API.
1414
// Though, the devs can still use the old SharedStatic without any compatibility issue.
1515
{
16-
static DNAbyss() => Load<DNAPlugin>(!RuntimeFeature.IsDynamicCodeCompiled ? new Core.Management.GameVersion(0, 5, 1, 0) : default); // Loads the IPlugin instance as DNAPlugin.
16+
static DNAbyss() => Load<DNAPlugin>(!RuntimeFeature.IsDynamicCodeCompiled ? new Core.Management.GameVersion(0, 5, 2, 0) : default); // Loads the IPlugin instance as DNAPlugin.
1717

1818
[UnmanagedCallersOnly(EntryPoint = "TryGetApiExport", CallConvs = [typeof(CallConvCdecl)])]
1919
public static unsafe int TryGetApiExport(char* exportName, void** delegateP) =>

Hi3Helper.Plugin.DNA/Hi3Helper.Plugin.DNA.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<Company>Collapse Launcher Team</Company>
1919
<Authors>$(Company). neon-nyan, Cry0, bagusnl, shatyuka, gablm.</Authors>
2020
<Copyright>Copyright 2022-2025 $(Company)</Copyright>
21-
<Version>0.5.1</Version>
21+
<Version>0.5.2</Version>
2222
<ApplicationIcon>icon.ico</ApplicationIcon>
2323
<Configurations>Debug;Release;DebugNoReflection;ReleaseNoReflection</Configurations>
2424
</PropertyGroup>

Hi3Helper.Plugin.DNA/Management/Api/DNAGlobalLauncherApiNews.cs

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,26 @@ public override void GetNewsEntries(out nint handle, out int count, out bool isD
9090
}
9191

9292
List<DNAApiResponseNoticesEntry> validEntries = [..NoticesApiResponse.Values
93-
.Where(x => x.Event != null &&
94-
!string.IsNullOrEmpty(x.Event.Name) &&
95-
!string.IsNullOrEmpty(x.Event.Type) &&
96-
!string.IsNullOrEmpty(x.Event.Date) &&
97-
x.Event.Content != null && x.Event.Content.Count > 0
98-
)];
93+
.Where(x =>
94+
{
95+
if (x.Event == null) return false;
96+
97+
bool isValid = true;
98+
if (x.Event.ExpireTime != null)
99+
{
100+
long timestamp = long.Parse(x.Event.ExpireTime!) / 1000;
101+
DateTime time = DateTimeOffset.FromUnixTimeSeconds(timestamp)
102+
.ToLocalTime().DateTime;
103+
isValid = time > DateTimeOffset.Now;
104+
}
105+
106+
return
107+
!string.IsNullOrEmpty(x.Event.Name) &&
108+
!string.IsNullOrEmpty(x.Event.Type) &&
109+
!string.IsNullOrEmpty(x.Event.Date) &&
110+
x.Event.Content != null && x.Event.Content.Count > 0
111+
&& isValid;
112+
})];
99113

100114
int entryCount = validEntries.Count;
101115
PluginDisposableMemory<LauncherNewsEntry> memory = PluginDisposableMemory<LauncherNewsEntry>.Alloc(entryCount);
@@ -160,9 +174,21 @@ public override void GetCarouselEntries(out nint handle, out int count, out bool
160174
}
161175

162176
List<DNAApiResponseCarouselEntry> validEntries = [..CarouselApiResponse.Values
163-
.Where(x => !string.IsNullOrEmpty(x.Name) &&
164-
x.Content != null && x.Content.Count > 0
165-
)];
177+
.Where(x =>
178+
{
179+
bool isValid = true;
180+
if (x.ExpireTime != null)
181+
{
182+
long timestamp = long.Parse(x.ExpireTime!) / 1000;
183+
DateTime time = DateTimeOffset.FromUnixTimeSeconds(timestamp)
184+
.ToLocalTime().DateTime;
185+
isValid = time > DateTimeOffset.Now;
186+
}
187+
188+
return !string.IsNullOrEmpty(x.Name) &&
189+
x.Content != null && x.Content.Count > 0 &&
190+
isValid;
191+
})];
166192

167193
int entryCount = validEntries.Count;
168194
PluginDisposableMemory<LauncherCarouselEntry> memory = PluginDisposableMemory<LauncherCarouselEntry>.Alloc(entryCount);

Hi3Helper.Plugin.DNA/Management/PresetConfig/DNAGlobalPresetConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Hi3Helper.Plugin.DNA.Management.PresetConfig;
1616
[GeneratedComClass]
1717
public partial class DNAGlobalPresetConfig : DNAPresetConfig
1818
{
19-
private const string ApiResponseUrl = "http://pan01-cdn-ali-jp.dna-panstudio.com/";
19+
private const string ApiResponseUrl = "http://pan01-cdn-hs-jp.dna-panstudio.com/";
2020
private const string ExecutableName = "EM.exe";
2121
private const string EngineExecutableName = "EM-Win64-Shipping.exe";
2222
private const string VendorName = "Hero Games";

Hi3Helper.Plugin.DNA/Utility/DNAUtility.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using Hi3Helper.Plugin.Core;
22
using Hi3Helper.Plugin.Core.Utility;
3+
using System;
34
using System.Net;
45
using System.Net.Http;
6+
using System.Net.Http.Headers;
57

68
// ReSharper disable InconsistentNaming
79
// ReSharper disable StringLiteralTypo
@@ -10,8 +12,19 @@ namespace Hi3Helper.Plugin.DNA.Utility;
1012

1113
internal static class DNAUtility
1214
{
13-
internal static HttpClient CreateApiHttpClient(bool useCompression = true)
14-
=> CreateApiHttpClientBuilder(useCompression).Create();
15+
internal static HttpClient CreateApiHttpClient(bool useCompression = true)
16+
{
17+
var client = CreateApiHttpClientBuilder(useCompression).Create();
18+
client.DefaultRequestHeaders.CacheControl = new CacheControlHeaderValue()
19+
{
20+
MaxAge = TimeSpan.Zero,
21+
NoStore = true,
22+
NoCache = true,
23+
MustRevalidate = true
24+
};
25+
26+
return client;
27+
}
1528

1629
internal static PluginHttpClientBuilder CreateApiHttpClientBuilder(bool useCompression = true)
1730
{
@@ -26,7 +39,6 @@ internal static PluginHttpClientBuilder CreateApiHttpClientBuilder(bool useCompr
2639
builder.AddHeader("Accept", "*/*")
2740
.AddHeader("Accept-Encoding", "deflate, gzip")
2841
.AddHeader("Content-Length", "0")
29-
.AddHeader("Cache-Control", "no-cache, no-store, must-revalidate")
3042
.AddHeader("Pragma", "no-cache")
3143
.AddHeader("Expires", "0");
3244

0 commit comments

Comments
 (0)