Skip to content

Commit bd94df8

Browse files
authored
Merge pull request #53 from kwsch/master
Merge with Upstream 12 commits
2 parents 8d495c7 + 538374b commit bd94df8

File tree

164 files changed

+5627
-1373
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+5627
-1373
lines changed

PKHeX.Core/Editing/Bulk/BatchEditing.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ private static ModifyResult SetPKMProperty(StringInstruction cmd, BatchInfo info
432432
private static bool IsFilterMatch(StringInstruction cmd, BatchInfo info, Dictionary<string, PropertyInfo>.AlternateLookup<ReadOnlySpan<char>> props)
433433
{
434434
var match = BatchFilters.FilterMods.Find(z => z.IsMatch(cmd.PropertyName));
435-
if (match != null)
435+
if (match is not null)
436436
return match.IsFiltered(info, cmd);
437437
return IsPropertyFiltered(cmd, info.Entity, props);
438438
}
@@ -447,7 +447,7 @@ private static bool IsFilterMatch(StringInstruction cmd, BatchInfo info, Diction
447447
private static bool IsFilterMatch(StringInstruction cmd, PKM pk, Dictionary<string, PropertyInfo>.AlternateLookup<ReadOnlySpan<char>> props)
448448
{
449449
var match = BatchFilters.FilterMods.Find(z => z.IsMatch(cmd.PropertyName));
450-
if (match != null)
450+
if (match is not null)
451451
return match.IsFiltered(pk, cmd);
452452
return IsPropertyFiltered(cmd, pk, props);
453453
}

PKHeX.Core/Editing/Bulk/BatchMods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static class BatchMods
8181
];
8282

8383
private static char GetOptionSuffix(ReadOnlySpan<char> str, ReadOnlySpan<char> prefix)
84-
=> str.Length == prefix.Length ? default : str[^1];
84+
=> str.Length == prefix.Length ? CommonEdits.OptionNone : str[^1];
8585

8686
private static void SetRandomTeraType(PKM pk)
8787
{

PKHeX.Core/Editing/Bulk/IPropertyProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public bool TryGetProperty(PKM pk, string prop, [NotNullWhen(true)] out string?
2020
{
2121
var value = pi.GetValue(pk);
2222
result = value?.ToString();
23-
return result != null;
23+
return result is not null;
2424
}
2525
catch
2626
{

PKHeX.Core/Editing/Bulk/Suggestion/BatchModifications.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static ModifyResult SetSuggestedMetData(BatchInfo info)
8989
{
9090
var pk = info.Entity;
9191
var encounter = EncounterSuggestion.GetSuggestedMetInfo(pk);
92-
if (encounter == null)
92+
if (encounter is null)
9393
return ModifyResult.Error;
9494

9595
var location = encounter.Location;

PKHeX.Core/Editing/CommonEdits.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,18 +444,20 @@ public static string GetLocationString(this PKM pk, bool eggmet)
444444
return GameInfo.GetLocationName(eggmet, location, pk.Format, pk.Generation, pk.Version);
445445
}
446446

447+
public const char OptionNone = '\0';
448+
447449
/// <summary>
448450
/// Gets a <see cref="PKM.EncryptionConstant"/> to match the requested option.
449451
/// </summary>
450-
public static uint GetComplicatedEC(ISpeciesForm pk, char option = default)
452+
public static uint GetComplicatedEC(ISpeciesForm pk, char option = OptionNone)
451453
{
452454
var species = pk.Species;
453455
var form = pk.Form;
454456
return GetComplicatedEC(species, form, option);
455457
}
456458

457459
/// <inheritdoc cref="GetComplicatedEC(ISpeciesForm,char)"/>
458-
public static uint GetComplicatedEC(ushort species, byte form, char option = default)
460+
public static uint GetComplicatedEC(ushort species, byte form, char option = OptionNone)
459461
{
460462
var rng = Util.Rand;
461463
uint rand = rng.Rand32();

PKHeX.Core/Editing/Database/TrainerDatabase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public sealed class TrainerDatabase
4646
if (possible.Count == 0)
4747
return null;
4848

49-
if (lang != null)
49+
if (lang is not null)
5050
{
5151
possible = possible.Select(z =>
5252
{
@@ -70,7 +70,7 @@ public sealed class TrainerDatabase
7070
if (possible.Count == 0)
7171
return null;
7272

73-
if (lang != null)
73+
if (lang is not null)
7474
{
7575
possible = possible.Select(z =>
7676
{

PKHeX.Core/Editing/PKM/QR/QRMessageUtil.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Buffers;
3+
using System.Diagnostics;
34

45
namespace PKHeX.Core;
56

@@ -23,7 +24,7 @@ public static class QRMessageUtil
2324
public static PKM? GetPKM(ReadOnlySpan<char> message, EntityContext context)
2425
{
2526
var data = DecodeMessagePKM(message);
26-
if (data == null)
27+
if (data is null)
2728
return null;
2829
return EntityFormat.GetFromBytes(data, context);
2930
}
@@ -93,7 +94,7 @@ public static string GetMessageBase64(ReadOnlySpan<byte> data, string server)
9394
if (message.StartsWith("http", StringComparison.Ordinal)) // inject url
9495
return DecodeMessageDataBase64(message);
9596

96-
const int g7size = 0xE8;
97+
const int g7size = PokeCrypto.SIZE_6STORED; // 0xE8;
9798
const int g7intro = 0x30;
9899
if (message.StartsWith("POKE", StringComparison.Ordinal) && message.Length > g7intro + g7size) // G7 data
99100
return GetBytesFromMessage(message[g7intro..], g7size);
@@ -118,9 +119,15 @@ public static string GetMessageBase64(ReadOnlySpan<byte> data, string server)
118119

119120
private static byte[] GetBytesFromMessage(ReadOnlySpan<char> input, int count)
120121
{
121-
byte[] data = new byte[count];
122-
for (int i = data.Length - 1; i >= 0; i--)
123-
data[i] = (byte)input[i];
124-
return data;
122+
byte[] result = new byte[count];
123+
GetBytesFromMessage(input, result);
124+
return result;
125+
}
126+
127+
private static void GetBytesFromMessage(ReadOnlySpan<char> input, Span<byte> output)
128+
{
129+
Debug.Assert(input.Length >= output.Length);
130+
for (int i = 0; i < output.Length; i++)
131+
output[i] = (byte)input[i];
125132
}
126133
}

PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public EventBlockDiff(string f1, string f2)
3030
return;
3131
var s1 = SaveUtil.GetVariantSAV(f1);
3232
var s2 = SaveUtil.GetVariantSAV(f2);
33-
if (s1 == null || s2 == null || s1.GetType() != s2.GetType() || GetBlock(s1) is not { } t1 || GetBlock(s2) is not { } t2)
33+
if (s1 is null || s2 is null || s1.GetType() != s2.GetType() || GetBlock(s1) is not { } t1 || GetBlock(s2) is not { } t2)
3434
{
3535
Message = DifferentGameGroup;
3636
return;

PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff7b.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private void Diff(SAV7b s1, SAV7b s2)
5151

5252
public IReadOnlyList<string> Summarize()
5353
{
54-
if (S1 == null)
54+
if (S1 is null)
5555
return [];
5656
var ew = S1.Blocks.EventWork;
5757

PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff8b.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private void Diff(SAV8BS s1, SAV8BS s2)
5353

5454
public IReadOnlyList<string> Summarize()
5555
{
56-
if (S1 == null)
56+
if (S1 is null)
5757
return [];
5858

5959
var fOn = SetFlags.Select(z => new FlagSummary(z).ToString());

0 commit comments

Comments
 (0)