With the new version of Visual Studio bringing C# 12, we can revise our logic for better readability as well as use new methods/APIs introduced in the .NET 8.0 BCL.
More performant byte->str performance (no longer needing to hash byte and fetch bucket), unmeasured str->byte performance, but it is the same implementation as Gen3 which is not a bottleneck.
Reduces the dll size by 80KB, and RAM usage by an unmeasured (likely similar amount). Better startup speeds since multiple dictionaries do not need to be allocated and created.
Moves Gen1 trainer names (0x5D) to Transporter class, and remove Korean entry (not legally obtainable since there's only Gen2 Korean games and Gen2 Korean VC cannot trade with international).
Hard verify Gen1 trainer name for language, since 0x5D is the ROM transfer language. Nickname can still be from any of the connected games.
This refactor makes it easier to use a different charmap for byte<->str for Boxes (see #4027) and the language differences. We have a master table that "works" for all text name entry, but localizations differ for some glyphs accessible in the box naming UI.
Skip string fetch for Trade1
Set gender for Trade8
Add record to wrap Gen8 raid generate params, return & use bool for filtering results, fallback to unrestricted if none succeed
Fix gender comparison for Entree5 slot
Simplify gen2 ResetKey fetch (byte sum of Money/ID/OT(used)
Closes#3970 by filtering gender inside the method like Encounter9RNG with an early return
Adds IV filtering inside the method with an early return like Encounter9RNG
We implement simple state machine iterators to iterate through every split type encounter array, and more finely control the path we iterate through. And, by using generics, we can have the compiler generate optimized code to avoid virtual calls.
In addition to this, we shift away from the big-5 encounter types and not inherit from an abstract class. This allows for creating a PK* of a specific type and directly writing properties (no virtual calls). Plus we can now fine-tune each encounter type to call specific code, and not have to worry about future game encounter types bothering the generation routines.
Runtime/jit repoints these to the dll rather than heap if we're Little Endian (always, otherwise will allocate like before).
Eliminates quite a few static constructors, so even faster startup. Items later.
Only fetch egg moves when using them
Localize KOR gen2 string directly instead of switch expression
Remap FRE gen4 chars directly, hot path instead of dictionary lookup
Uppercase chars in place
Skips the bucket array resizing steps
a 256 key dict will garbage 5KB; StringConverter2KOR wastes 100KB of garbage.
Zukan7b: save 144 bytes and eliminate cctor
Updates from net46->net7, dropping support for mono in favor of using the latest runtime (along with the performance/API improvements). Releases will be posted as 64bit only for now.
Refactors a good amount of internal API methods to be more performant and more customizable for future updates & fixes.
Adds functionality for Batch Editor commands to `>`, `<` and <=/>=
TID/SID properties renamed to TID16/SID16 for clarity; other properties exposed for Gen7 / display variants.
Main window has a new layout to account for DPI scaling (8 point grid)
Fixed: Tatsugiri and Paldean Tauros now output Showdown form names as Showdown expects
Changed: Gen9 species now interact based on the confirmed National Dex IDs (closes#3724)
Fixed: Pokedex set all no longer clears species with unavailable non-base forms (closes#3720)
Changed: Hyper Training suggestions now apply for level 50 in SV. (closes#3714)
Fixed: B2/W2 hatched egg met locations exclusive to specific versions are now explicitly checked (closes#3691)
Added: Properties for ribbon/mark count (closes#3659)
Fixed: Traded SV eggs are now checked correctly (closes#3692)
Adds support for Scarlet & Violet.
Co-Authored-By: SciresM <8676005+SciresM@users.noreply.github.com>
Co-Authored-By: Matt <17801814+sora10pls@users.noreply.github.com>
Co-Authored-By: Lusamine <30205550+Lusamine@users.noreply.github.com>
Was writing kor string, then writing en after (all terminators).
Make method signature match other SetString, with write buffer as first arg
Closes#3440
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.
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?
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>
More in line with modernizing the codebase with latest c# syntax
improve web-qr decode speed slightly (no linq skiptake)
get money/coin mask without a temporary string (lol performance)
Farfetch’d uses the non-vertical apostrophe, still.
Showdown is consistent with their usage (in/outputting ’), but we'll keep the '->’ for that sanitization just in case other services/users enter the wrong char.
Closes#3185
Retain a stringbuilder to mutate the string rather than finalizing temporary strings
yields some speed improvements (less gen0 string objects allocated)
I think this was a PKHeX issue that went unnoticed; originally, we didn't include the Á and Í chars in the dictionary.
I checked the transporter code:
The app maintains the international & japanese character tables, and depending on the ROM language, it may change a char to the language-specific entry. Refer to Bulbapedia's notes on the char tables for different languages:
https://bulbapedia.bulbagarden.net/wiki/Character_encoding_in_Generation_II
However, none of these char-changes are able to be reached with a legal char.
Á and Í (only accessible from the Spanish in-game trades) and the german 0xC0 && z <= 0xC6 chars are already in the international table. Every single difference in the VC1/VC2 table is an un-enterable char.
tl;dr -- all possible char codes are transferred fine with the VC2 table without extra language logic. We just keep out any inaccessible char (replaced with space).
Introducing a new PKM format: SK2
Split ICaughtData2 off of PK2 so it can be shared with SK2 when type-checks occur
Add conversion for PK2<->SK2
Split the split-buffer handling for GBPKM to GBPKML (what a name), so that I can reuse shared accessor logic for SK2.
Results in a little more code, but each path is less tangled
simplify some expressions
remove RBDragonair content in favor of a strict filter for catch rate
Move gen1 trade trainer names to stringconverter, since pk1/pk2 shouldn't refer to legality classes