Commit graph

78 commits

Author SHA1 Message Date
abcboy101
417231a67c
Update how symbols are handled for Bank -> HOME transfers (#4276)
This maps the remaining (legal) symbols in the private use area that are modified on transfer from Bank -> HOME. If any of these replacements are made, any leading or trailing halfwidth spaces are trimmed. This can result in nicknames/OT names that are the empty string or consist entirely of fullwidth spaces, even though these can't normally entered.
2024-05-17 11:56:55 -05:00
Kurt
0f7d6e1b6a Handler check for WC7 ash pika reimplemented
The handler state checks to check against current trainer are new, forgot about this edge case.
Reduce allocation of temp strings on wc7->pk7, replicate the HT miss for ash pika wc7->pk7
2024-05-13 12:35:47 -05:00
Kurt
7b6abc0520 Reduce alloc for ot/nick by raw trash reads
Legality check now catches buffer overflow mons.
Now that I have each type exposing a trash length & charcount, should be easy to have some reusable trash byte measuring methods (see the old branch)
2024-05-12 14:46:58 -05:00
Kurt
08ed482555 Revise gender symbol remapping
Handles Nidoran's shenanigans as well as more clear method names
- Add normalization for PK7->PK8 (no more 0xE... usage for the gender symbols... maybe more chars?)
- Not sure if Gen3 gamecube encoding needs sanitizing. Who is transferring Nidoran to CXD? :)

Requires some silly usage of Language passing as arguments. Future improvements can be made to revise the half/full encoding determination when setting a string. Probably has issues since we're just doing a naive check without considering nicknames w/ special chars.

Closes #4174
2024-05-12 10:47:55 -05:00
Kurt
326e790e4b Handle and ' behaviors for 4->5->6
Gen5 does not use the slanted apostrophe for anything. 4->5 converts to ' for both strings.
Gen6 fixes all to be slanted. Even nicknames.
Importing to HOME (PK7, GO) resets nicknames, and the default name is not slanted. Nicknames/OTs are unaltered; again, only the "default" species name is wrong.

Closes #4066
2024-05-11 11:35:55 -05:00
Kurt
0f4024952e Minor clean
indexof -> contains
trailing space
some variable reuse
pcdata/boxdata less janky handling
2024-05-01 00:49:43 -05:00
Kurt
e7f79be41d Minor clean 2024-04-28 00:35:26 -05:00
Kurt
4e56a2b756 Fix zhs/zht table swap
simplified is the first set, not the second
Closes #4254
2024-04-26 01:27:53 -05:00
Kurt
093264bc24 Add IStringConverter, impl on PKM & SaveFile
use in trash editor to translate strings, from PKM instead of SAV.
Closes #4222
2024-04-23 00:57:17 -05:00
Kurt
1b294f7c97
Refactor: Split Gen1/2 string & pokelist conversion methods (#4251)
* Split Gen1/2 string & pokelist conversion methods

* Refactor pokelist to direct read/write, skip on save if blanked

* Add settings editor for SaveLanguage overrides
2024-04-22 14:42:22 -06:00
abcboy101
8a3a338c0b
Fix encodings for Gen 3/4/5 transfers (#4220)
Adjust Gen 3/4 encodings to be consistent with Gen 5 Unicode encodings
Gen 3 quotation marks are displayed differently based on the game language
Implement how Pal Park handles invalid characters and corrupts certain accented characters
Implement how Poké Transfer handles invalid characters
Use U+25BA BLACK RIGHT-POINTING POINTER, since this character is used as the pointer in menus/etc., rather than as a bullet or generic shape
2024-03-17 22:34:13 -06:00
Kurt
b435f8c258 Offload gen1/2 event templates to pickles
Thanks @ShadowMario3 for doing the raw data entry for these templates -- see PKHeX.EncounterSlotDumper for the csv -> pkl conversion logic.

Reduces object size by classifying groups of events with specific features, and reduces the explicitness of defining each single encounter.

Hard-code the span of Gen1 VC mew to not need to grab the resource, and add an overload to iterate a single template (skips an array creation).

Co-Authored-By: ShadowMario3 <36941677+ShadowMario3@users.noreply.github.com>
2024-02-24 17:53:46 -06:00
Kurt
1feec26d1a Split StringFontUtil
2700 line file too big; split into context-specific font classes.
2024-02-23 20:05:50 -06:00
abcboy101
32e888d871
Check nicknames/OTs against characters in font (#4146)
* Check nicknames/OTs against characters in font

* Update translations

* Do not show warning for Gen4 and earlier

* Use Gen5/7 font for Gen 3-4/1-2 transfers

* Minor style pref

* Remove font legality checks

* Add missing/update Switch fonts
2024-02-23 13:23:50 -06:00
Kurt
95fbf66a6e
Refactor: Gen3/4 Lead Encounters, property fixing (#4193)
In addition to the Method 1 (and other sibling PIDIV types) correlation, an encounter can only be triggered if the calls prior land on the Method {1} seed. The RNG community has dubbed these patterns as "Method J" (D/P/Pt), "Method K" (HG/SS), and "Method H" (Gen3, coined by yours truly). The basic gist of these is that they are pre-requisites, like the Shadow locks of Colosseum/XD. 

Rename/re-type a bunch of properties to get the codebase more in line with correct property names & more obvious underlying types.
2024-02-22 21:20:54 -06:00
Kurt
560320e2cc Fix gen4 encoding of ? 2024-01-21 23:44:12 -08:00
Kurt
c66fc2f3bf Add gen4 headbutt slot numbers
All were zero, update dumper.
Extract some logic from other parts of the codebase
Fix wyrdeer level check if originated from GO
2024-01-09 19:07:32 -08:00
Kurt
671c3564ee Echoes of trash-test
Remove glyph remap for Switch gender symbols (none actually)
Might be wise to convert StringConverter to singletons...
2024-01-08 21:55:07 -08:00
Kurt
f80c2820f9 Misc tweaks
Local event db's don't need to absorb the builtin db.
More aggressive generator filtering for fuzzed PB7's from GO (can't fake a GO8 in PB7)
Fix splitbreed relearn suggestion (chain is reversed for Origin, don't bother truncating or anything)
Only check for filtered VC ot's if transferred (not still gen1/2 format)
Remove unnecessary xmldoc, add more xmldoc
2024-01-08 20:01:19 -08:00
abcboy101
3ba2e8e376
Gen 1/2 VC filtered OT name legality (#4155) 2024-01-08 12:34:44 -08:00
abcboy101
01131e59f0
Modify G1/G2 character mappings (#4154)
### Treat 'ヘ' as katakana
- For consistency with ベ/ペ/リ which are treated as katakana here and in StringConverter12Transporter.cs, map 0xCD to katakana ヘ instead of hiragana へ.
- Allow input of hiragana べ/ぺ/へ/り, mapping them to katakana ベ/ペ/ヘ/リ. Previously, they would be treated as invalid and mapped to the string terminator.

### Swap mappings for 0xE8/0xF2
- Previously, 0xE8 was mapped to U+002E `.` FULL STOP, while 0xF2 was mapped to the special character U+2024 `․` ONE DOT LEADER. Since 0xF2 is used in user input while 0xE8 is only used in `MR.MIME`, swap these mappings so that normal keyboard input maps to the user-enterable character.
- Modifies SpeciesName.cs to produce U+2024 for Mr. Mime in G1/G2.
2024-01-07 23:27:03 -08:00
Kurt
a24e6e9cef Misc tweaks
Add notransfer for SV-ride legend
Replace dummy '0' in gen3 chartable to match Bulbapedia -- inaccessible char for entry anyways, and the byte never fetched via IndexOf due to the previous occurrence of '0'.
Enhance file namer interface to tag with a display name
2023-12-30 11:41:45 -08:00
Kurt
01c82e472e
Add support for Indigo Disk (#4111) 2023-12-17 16:41:15 -08:00
Kurt
d47bb1d297
Update .NET Runtime to .NET 8.0 (#4082)
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.
2023-12-03 20:13:20 -08:00
Kurt
5c7ce2c0a6 Misc tweaks
Fix g12 str set (jp/en was swapped, oops)
add more xmldoc
minor readability/short circuiting
2023-10-27 21:01:11 -07:00
Kurt
325f75e3d3 Gen12 strings: span instead of runtime dictionary
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.
2023-10-25 16:34:11 -07:00
Kurt
978bcfa56f Misc enc template tweaks
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
2023-08-29 22:22:23 -07:00
Kurt
f632aedd15
Encounter Templates: Searching and Creating (#3955)
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.
2023-08-12 16:01:16 -07:00
Kurt
998b8f1ce0 Minor tweaks
Add unit test for VC kata/hiragana edge case
De-duplicate some slot change notifications
Span in more spots
2023-04-22 17:51:32 -07:00
Kurt
5ce3e734b8
Skip initial cctor alloc on non-byte primitives (#3850)
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.
2023-03-25 17:55:55 -07:00
Kurt
46de8c4b06 Minor optimizations
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
2023-03-21 17:20:13 -07:00
Kurt
29b3b695bd Pre-allocate some dictionary sizes
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
2023-03-04 20:00:27 -08:00
Kurt
88830e0d00
Update from .NET Framework 4.6 to .NET 7 (#3729)
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)
2023-01-21 20:02:33 -08:00
Kurt
03182ebd3d Update 22.11.24
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>
2022-11-24 17:42:17 -08: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
f2637168ab Fix kor string writes
Was writing kor string, then writing en after (all terminators).
Make method signature match other SetString, with write buffer as first arg

Closes #3440
2022-02-17 23:11:13 -08:00
Kurt
b96e2cacd7 Add xmldoc 2022-01-08 09:54:32 -08:00
Kurt
01f1be6f89 Fix incorrect g1 trade trainer char reference 2022-01-07 20:52:26 -08: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
80d1712b72 Mark stuff with enums, remove unused arrays
Fix shuffled comments for FormInfo
Remove unnecessary Reset on ctor, all fields are already the default
2021-09-07 20:57:19 -07:00
Kurt
bedc52943e Trailing commas
No functional change
2021-08-20 13:49:20 -07:00
Kurt
e1c8ab8d96 Fix remapped glyph
Future updates to glyph remapping to come later
2021-08-13 17:25:20 -07: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
138501da2f Minor clean
Condense some expressions
Use less linq
Rename some fields
2021-05-29 15:31:47 -07:00
Kurt
2c820bfbe9 Minor tweaks 2021-05-18 13:29:55 -07:00
Kurt
50b15cd740 Use range/index
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)
2021-05-14 15:30:55 -07:00
Kurt
3597eb14ad Improve gen1-4 species name fetch
reduce nesting (separated methods)
handle gen2 french egg name (all caps)
use stringbuilder to replace chars
2021-05-10 16:09:28 -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
Kurt
c56ba76601 Expand jp table too
6754645a5f
2021-04-12 19:14:23 -07:00