Commit graph

7 commits

Author SHA1 Message Date
Kurt
12954a6369 Minor perf improvement (spans)
Remove PKM.EVs, do operations without heap allocation
Reduce usage of PKM.IVs/PKM.Moves, reuse spans if possible.
2022-06-25 23:08:28 -07:00
Kurt
fc754b346b
File scoped namespaces (#3529)
[Language Reference](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/file-scoped-namespaces)

Updates all the files, one less level of indentation.

Some small changes were made to API surfaces, renaming `PKM pkm` -> `PKM pk`, and `LegalityAnalysis.pkm` -> `LegalityAnalysis.Entity`
2022-06-18 11:04:24 -07:00
Kurt
47071b41f3
Refactoring: Span-based value writes and method signatures (#3361)
Existing `get`/`set` logic is flawed in that it doesn't work on Big Endian operating systems, and it allocates heap objects when it doesn't need to.

`System.Buffers.Binary.BinaryPrimitives` in the `System.Memory` NuGet package provides both Little Endian and Big Endian methods to read and write data; all the `get`/`set` operations have been reworked to use this new API. This removes the need for PKHeX's manual `BigEndian` class, as all functions are already covered by the BinaryPrimitives API.

The `StringConverter` has now been rewritten to accept a Span to read from & write to, no longer requiring a temporary StringBuilder.

Other Fixes included:
- The Super Training UI for Gen6 has been reworked according to the latest block structure additions.
- Cloning a Stadium2 Save File now works correctly (opening from the Folder browser list).
- Checksum & Sanity properties removed from parent PKM class, and is now implemented via interface.
2022-01-02 21:35:59 -08:00
Kurt
103aa9aa4b
Revise EncounterArea and EncounterType for clarity (#3228)
EncounterArea now stores a more specific type'd array for encounter slots. Better iteration and less casting, as the nonspecific `Slots` fetch is rarely referenced.

EncounterType renamed to GroundTile to reflect how it actually works in Gen4. Was previously an ambiguous field that was clarified a little; we can describe it a little better now. Keep the GUI the same to not scare the end users.

Change Trash Byte properties to get/set a Span. Trash Byte legality checking easier on the garbage collector?
2021-06-29 20:58:06 -07:00
Kurt
390cf518b8 Revise 4->5 encode table (Half-width symbols)
Manually transferred from English Pt to English B

All revised indexes were the result in Black.

Differences that were not incorporated:
0EE=09794 ♂, not 09325 ⑭
0EF=09792 ♀, not 09326 ⑮
0F2=00215 ×, not 09319 ⑧
0F3=00247 ÷, not 09320 ⑨

Full-width and half-width symbols I think are related to full-width games, which English isn't. Probably has different handling for other language, plus it'd result in other duplicates of the half-width symbols.

Revise not-found char glyph to return ? instead of {terminator}, to match the game's behavior. Again, this might be language specific, but whatever.

Make the Convert char methods public, add a few unit tests.

Closes #3172

Co-Authored-By: Lusamine <30205550+Lusamine@users.noreply.github.com>
2021-06-11 19:38:34 -07:00
Kurt
01f75f8441 Add test for hex string (arbitrary length) convert 2021-05-09 23:33:54 -07:00
Kurt
c67e01849a Extract 3ds chinese glyph remapping, only do on 3DS games
Optimize some functions within gen7zh for perf (no linq, no allocation)
2021-04-18 18:29:02 -07:00