Skip to content

Commit edf71a9

Browse files
committed
Clean up some error producing code.
1 parent a27e083 commit edf71a9

12 files changed

Lines changed: 54 additions & 100 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
using System.Runtime.InteropServices;
2+
13
namespace Snowcloak.Configuration.Models;
24

35
[Serializable]
6+
[StructLayout(LayoutKind.Sequential)]
47
public readonly record struct AutoRejectCombo(byte Race, byte Clan, byte Gender);

Snowcloak/FileCache/FileCacheManager.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,6 @@ private long CalculateTextureVramUsage(string filePath)
353353

354354
foreach (var entry in cleanedPaths)
355355
{
356-
//_logger.LogDebug("Checking {path}", entry.Value);
357-
358356
if (dict.TryGetValue(entry.Value, out var entity))
359357
{
360358
var validatedCache = GetValidatedFileCache(entity);
@@ -483,7 +481,6 @@ private void AddHashedFile(FileCacheEntity fileCache)
483481

484482
if (!entries.Exists(u => string.Equals(u.PrefixedFilePath, fileCache.PrefixedFilePath, StringComparison.OrdinalIgnoreCase)))
485483
{
486-
//_logger.LogTrace("Adding to DB: {hash} => {path}", fileCache.Hash, fileCache.PrefixedFilePath);
487484
entries.Add(fileCache);
488485
}
489486
}
@@ -506,7 +503,6 @@ private void AddHashedFile(FileCacheEntity fileCache)
506503
private FileCacheEntity? GetValidatedFileCache(FileCacheEntity fileCache)
507504
{
508505
var resultingFileCache = ReplacePathPrefixes(fileCache);
509-
//_logger.LogTrace("Validating {path}", fileCache.PrefixedFilePath);
510506
resultingFileCache = Validate(resultingFileCache);
511507
return resultingFileCache;
512508
}

Snowcloak/Interop/GameModel/MdlFile.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,23 @@ public class MdlFile
3131
public ushort Unknown9;
3232

3333
// Offsets are stored relative to RuntimeSize instead of file start.
34-
public uint[] VertexOffset = [0, 0, 0];
35-
public uint[] IndexOffset = [0, 0, 0];
34+
public uint[] VertexOffset;
35+
public uint[] IndexOffset;
3636

37-
public uint[] VertexBufferSize = [0, 0, 0];
38-
public uint[] IndexBufferSize = [0, 0, 0];
37+
public uint[] VertexBufferSize;
38+
public uint[] IndexBufferSize;
3939
public byte LodCount;
4040
public bool EnableIndexBufferStreaming;
4141
public bool EnableEdgeGeometry;
4242

4343
public ModelFlags1 Flags1;
4444
public ModelFlags2 Flags2;
4545

46-
public VertexDeclarationStruct[] VertexDeclarations = [];
47-
public ElementIdStruct[] ElementIds = [];
48-
public MeshStruct[] Meshes = [];
46+
public VertexDeclarationStruct[] VertexDeclarations;
47+
public ElementIdStruct[] ElementIds;
48+
public MeshStruct[] Meshes;
4949
public BoundingBoxStruct[] BoneBoundingBoxes = [];
50-
public LodStruct[] Lods = [];
50+
public LodStruct[] Lods;
5151
public ExtraLodStruct[] ExtraLods = [];
5252

5353
public MdlFile(string filePath)

Snowcloak/Services/PairRequestService.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -571,14 +571,11 @@ private async Task<bool> UpdateAvailabilitySubscriptionAsync(LocationInfo locati
571571

572572
try
573573
{
574-
if (!_apiController.Value.IsConnected)
574+
if (!_apiController.Value.IsConnected && (!force || !await WaitForApiConnectionAsync(_nearbyAvailabilityCts.Token).ConfigureAwait(false)))
575575
{
576-
if (!force || !await WaitForApiConnectionAsync(_nearbyAvailabilityCts.Token).ConfigureAwait(false))
577-
{
578-
_pushChannelAvailable = false;
579-
_availabilitySubscriptionActive = false;
580-
return false;
581-
}
576+
_pushChannelAvailable = false;
577+
_availabilitySubscriptionActive = false;
578+
return false;
582579
}
583580

584581
var sendFullSnapshot = forceFullSnapshot || requiresNewSubscription;

Snowcloak/Snowcloak.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<PackageReference Include="Brio.API" Version="3.0.1" />
1919
<PackageReference Include="Chaos.NaCl.Standard" Version="1.0.0" />
2020
<PackageReference Include="ElezenTools" Version="15.0.1" />
21-
<PackageReference Include="Glamourer.Api" Version="2.8.0" />
21+
<PackageReference Include="Glamourer.Api" Version="2.8.1" />
2222
<PackageReference Include="K4os.Compression.LZ4.Legacy" Version="1.3.8" />
2323
<PackageReference Include="K4os.Compression.LZ4.Streams" Version="1.3.8" />
2424
<PackageReference Include="MessagePack" Version="3.1.4" />
@@ -29,7 +29,7 @@
2929
<PrivateAssets>all</PrivateAssets>
3030
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3131
</PackageReference>
32-
<PackageReference Include="Meziantou.Analyzer" Version="3.0.58">
32+
<PackageReference Include="Meziantou.Analyzer" Version="3.0.59">
3333
<PrivateAssets>all</PrivateAssets>
3434
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3535
</PackageReference>
@@ -38,15 +38,15 @@
3838
<PackageReference Include="Microsoft.Data.Sqlite" Version="10.0.7" />
3939
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.7" />
4040
<PackageReference Include="NAudio" Version="2.3.0" />
41-
<PackageReference Include="Penumbra.Api" Version="5.13.1" />
41+
<PackageReference Include="Penumbra.Api" Version="5.15.1" />
4242
<PackageReference Include="Snowcloak.API" Version="2.6.0.3" />
4343
<PackageReference Include="Snowcloak.CacheFile" Version="3.2.1" />
4444
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.25.0.139117">
4545
<PrivateAssets>all</PrivateAssets>
4646
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4747
</PackageReference>
4848
<PackageReference Include="System.Management" Version="10.0.7" />
49-
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.17.0" />
49+
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.18.0" />
5050
<PackageReference Update="DotNet.ReproducibleBuilds" Version="2.0.2" />
5151
<PackageReference Include="Vortice.DXGI" Version="3.8.3" />
5252
<PackageReference Include="ZstdSharp.Port" Version="0.8.8" />

Snowcloak/UI/ChatWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ private void DrawStandardChannelMembers(string channelId)
14611461
var selfRank = GetChannelRoleRank(selfRoles);
14621462

14631463
foreach (var member in members
1464-
.GroupBy(member => member.User.UID)
1464+
.GroupBy(member => member.User.UID, StringComparer.Ordinal)
14651465
.Select(group => group.OrderByDescending(entry => GetChannelRoleRank(entry.Roles)).First())
14661466
.OrderByDescending(member => GetChannelRoleRank(member.Roles))
14671467
.ThenBy(member => GetUserDisplayName(member.User), StringComparer.OrdinalIgnoreCase))

Snowcloak/UI/Components/FrostbrandPanel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ private void DrawFilterColumn()
410410
.Where(kvp => string.IsNullOrWhiteSpace(_homeworldFilterSearch)
411411
|| kvp.Value.Name.Contains(_homeworldFilterSearch, StringComparison.OrdinalIgnoreCase)
412412
|| kvp.Value.DataCenterName.Contains(_homeworldFilterSearch, StringComparison.OrdinalIgnoreCase))
413-
.GroupBy(kvp => kvp.Value.DataCenterName)
413+
.GroupBy(kvp => kvp.Value.DataCenterName, StringComparer.OrdinalIgnoreCase)
414414
.OrderBy(g => g.Key, StringComparer.Ordinal);
415415

416416
using var homeworldList = ImRaii.Child("FrostbrandHomeworldFilters", new Vector2(0, ImGui.GetTextLineHeightWithSpacing() * 9), true);

Snowcloak/UI/Components/SyncshellMemberLabelUi.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Dalamud.Interface;
22
using Snowcloak.API.Data;
33
using System.Numerics;
4+
using System.Runtime.InteropServices;
45

56
namespace Snowcloak.UI.Components;
67

@@ -160,5 +161,6 @@ public static bool TryGetLabelPresentation(string label, out FontAwesomeIcon ico
160161
}
161162
}
162163

164+
[StructLayout(LayoutKind.Sequential)]
163165
private readonly record struct LabelStyle(FontAwesomeIcon Icon, Vector4 Color, int Priority);
164166
}

Snowcloak/UI/VenueRegistryWindow.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,7 @@ private static string FormatVenueLabel(VenueRegistryEntryDto entry)
264264
var listed = entry.IsListed ? "Listed" : "Unlisted";
265265
return string.Format(CultureInfo.InvariantCulture, "{0} ({1})", name, listed);
266266
}
267-
268-
// TODO: Move this to ElezenTools maybe? Other devs might use different string formats tho
269-
// Decide then make it a reusable function instead of copy pasting
267+
270268
private string FormatHousingLocation(string associatedHousing)
271269
{
272270
if (!TryParseHousingLocation(associatedHousing, out var location))

Snowcloak/WebAPI/AccountRegistrationService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public sealed record PatreonLoginResult
5050
private readonly DalamudUtilService _dalamudUtilService;
5151
private readonly TokenProvider _tokenProvider;
5252

53-
private string GenerateSecretKey()
53+
private static string GenerateSecretKey()
5454
{
5555
return Convert.ToHexString(SHA256.HashData(RandomNumberGenerator.GetBytes(64)));
5656
}

0 commit comments

Comments
 (0)