Commit graph

207 commits

Author SHA1 Message Date
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
cc8ac7a4f1 Remove unnecessary warning suppression
fixed dat .editorconfig in vs22
Catching general exceptions is okay because this program handles user modified data that can potentially be corrupt.
2021-12-27 12:09:15 -08:00
Kurt
4cb80b5463 Update memory feeling localization files for gen8
Keep the old localizations around for displaying gen6 format memories in their original localization.

I didn't rename the files so the git diff was clean for showing the re-localized lines.

Closes #3302
2021-12-04 11:40:40 -08:00
Kurt
73159053e2 Shift x0001 offset textfiles to x0000
Removes a lot of the offset-by-1 indexing, notably in the `GameStrings.GetLocationName` method which shifted everything 1. BDSP files we dumped don't replicate this off by 1, and I don't see a reason to maintain this off-by-1 for prior games since it's unnecessary quirks to maintain.

Zero indexed ftw.
2021-11-28 14:32:05 -08:00
Kurt
5d98e41efb Indicate true met location value for debug builds
Adds in the group offset
2021-11-24 13:11:30 -08:00
Kurt
27e899ffdd Yield SP eggs in encounter db, detect "link trade" correctly 2021-11-21 18:36:36 -08:00
Kurt
723514e89c
Update 21.11.19 - Brilliant Diamond & Shining Pearl (#3289)
Big thanks to @SciresM @sora10pls @Lusamine @architdate @ReignOfComputer for testing and contributing code / test cases. Can't add co-authors from the PR menu :(

Builds will fail because azure pipelines not yet updated with net6.
2021-11-19 18:23:49 -08:00
Kurt
87a268fa7f Clean up memory generation parameter fetching 2021-08-25 19:45:47 -07:00
Kurt
0e2dac3ff6 Minor tweaks
Empty return for invalid species encountertemplate fetch
Expose property for ck3 @ 0xD7
show legal memory context items rather than gen8 always
2021-08-25 19:23:15 -07:00
Kurt
9f1a8d1da1 Split memory text string resources
Much easier to maintain and reference now
2021-08-23 23:06:51 -07:00
Kurt
bedc52943e Trailing commas
No functional change
2021-08-20 13:49:20 -07:00
Kurt
c6342a163f Minor clean
variable swaps, simplifications
2021-08-20 13:42:25 -07:00
Kurt
0f3e5095c5 Replace more linq usage 2021-08-05 22:39:38 -07:00
Kurt
277b1b658d Un-nest 3ds console region bitflags
Insert 3DS into the name to indicate that it's for the 3DS
2021-08-02 20:59:40 -07:00
Kurt
5a769312fd Finish renaming EncounterType->GroundTile
Update the localization for GroundTile for english (and Italian, which is untranslated)
2021-07-03 23:25:09 -07:00
Kurt
09ff78ba71 Simplify memory list creation 2021-07-03 22:10:45 -07:00
Kurt
871de4e213 Add more xmldoc 2021-06-06 11:56:54 -07:00
Kurt
8c970ec991 Minor tweaks
no functional change, readability++
add more xmldoc
2021-06-03 12:04:19 -07:00
Kurt
138501da2f Minor clean
Condense some expressions
Use less linq
Rename some fields
2021-05-29 15:31:47 -07:00
Kurt
d83b2331ac Enhance nullable indication of array
Fix off by one unit test
2021-05-20 08:52:47 -07:00
Kurt
d6b8a018e6 Fix 3DS console region indexing
mystery gift region ID is not the same indexing as 3DS console region
2021-05-19 09:11:54 -07:00
Kurt
74e0cba3b0 Minor tweaks
use assert instead of manual exceptions
span
remove some dead logic
2021-05-18 16:16:48 -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
1fe77c004c Cache transfer location arrays if created once 2021-05-11 23:32:29 -07:00
Kurt
b97b54e5e4 Skip first indexes if requested
Fixes partition2 calls
2021-05-11 23:25:36 -07:00
Kurt
1cad57e35d Build results in place, no linq
O(n) for speed & memory usage, as good as we can get.
Modified method is now less dumb. Array Copy doesn't have to worry about same-array overlapping src/dest regions
2021-05-09 22:48:24 -07:00
Kurt
96d941db69 Preformat csv files, remove header
Shaves off a few kb
2021-05-09 15:47:21 -07:00
Kurt
96ea7f0b39 Fix toxtricity neutral StatNature generating 2021-05-08 08:29:20 -07:00
Kurt
31142ee297 Replace some linq usage with direct logic 2021-05-06 23:26:38 -07:00
Kurt
8a2d115df3 Sanity check nature for Criteria parameter 2021-02-01 10:45:53 -08:00
Kurt
d2d20c13e0 Don't emit JP-BU as a random gameversion 2021-01-31 21:28:33 -08:00
Kurt
62bf1c2755 Add stubs for verifying memories regarding items
Not implementing these, but at least setting up a clean area for anyone else to implement the logic
2021-01-30 19:15:39 -08:00
Kurt
76ae6b2b3d Minor tweaks
Disallow OT handling when originated gen is 1/2
Cast the input not the const
Hide HighestGameID (Use the method instead)
2021-01-09 21:25:28 -08:00
Kurt
a235cae9e0 Add Move enum, similar to Species/Ability
dash,apostrophe,space => empty
Z Moves have P/S suffixed
10mil volt thunderbolt "TenM"
2021-01-09 13:07:29 -08:00
Kurt
6a3fa4c90f Shift puff strings down by 1, remove init shift 2021-01-09 08:43:57 -08:00
Kurt
89a4dde4ee Minor perf improvements for location list init
Strip out unused lines [~ XX]; behaviorially equivalent to empty strings.
Mutate original met list rather than making a copy and moving any changes into it (saves extra allocations)
Change initial loop start to pre-skip iterations not meeting criteria
Manually mark duplicate lines (only 2 exist); no more linq/searching.
Wipe merged location sub-names prior to merging (bounds check optimization, maybe? already accessed, setting should be fine).

Tests still pass :)

Check for negative met location IDs to return empty (fuzzing?)
2021-01-08 19:26:20 -08:00
Kurt
1882d284bd Enable Gen1 slot location indication
Change "FRLG" -> "Kanto" as strings are reused

Used lines:
39c3968e5e/Gen1/DumpUtil.cs (L5)
table.Where(z => z != 0).Select(z => lines[z]).Distinct()

The only two that had FRLG are now showing "Kanto"
2021-01-08 13:59:18 -08:00
Kurt
09089da14e Use more expression return style
Reduces indentation & bracketing, a bit more concise
2021-01-01 17:08:49 -08:00
Kurt
e8c23f6644 Simplify some repeated comparisons with expressions
Less prone for bugs since it uses the same value for all comparisons without re-specifying
2020-12-29 00:37:59 -08:00
Kurt
0a46f45b00 Split MetDataSource from GameDataSource 2020-12-28 21:12:46 -08:00
Kurt
934316d68d Simplify some expressions for game datasources
Reduce allocations for ball
Use a clean switch expression for version->met list
2020-12-28 13:32:36 -08:00
Kurt
74ee22e66e Make ComboItem a record 2020-12-28 11:57:34 -08:00
Kurt
e44100a9fd Remove unnecessary ComboItem logic 2020-12-28 11:56:00 -08:00
Kurt
c14f2a1dd1 Minor initialization tweaks
GameStrings: 10% of strings are unique; just mark everything. Stop a little early so we don't process the empty & (trade) string.
LearnsetReader: All empty entries are length==0; malformed should throw an exception (never).
EggMoves: Compute ptr inside the array fetch loop; don't use linq.

EggMoves & string shaves off 80ms of startup time according to profiling; some could be attributed to warm-up but yay more efficient.
2020-12-28 10:22:13 -08:00
Kurt
ee5349ff98 moar is or 2020-12-25 12:30:26 -08:00
Kurt
4a8a495d04 Condense some switch expressions
Should be it for now; exhaustively searched for all that made sense to change
2020-12-25 10:58:33 -08:00
Kurt
93910df2c6 Use new switch statements 2020-12-23 17:14:38 -08:00
Kurt
324ce9d6ac Minor clean 2020-12-23 09:34:29 -08:00
Kurt
997e0751f3 Minor clean
Handle remainder of c#9 sugar
Fix some spelling mistakes
2020-12-21 23:37:07 -08:00