Commit graph

17 commits

Author SHA1 Message Date
Kurt
d6e83362b3 Fix binarysearch result compare
Method returns a negative number if not found; not always -1
https://projectpokemon.org/home/forums/topic/62246-g3-xd-move-tutor-legality/
2022-09-05 08:50:27 -07:00
Kurt
1960b335fd Remove PersonalInfo.Abilities, use interfaces
If you must get a list of abilities, then use the span extension methods.
Also reworks some initial moveset fetching to allocate less
2022-09-02 10:20:19 -07:00
Kurt
e8aa2c8ed1 Correctly check xy/sm if not ao/usum levelup 2022-09-01 09:34:40 -07:00
Kurt
f4f9df3a81 Don't add new gs moves to pk1 permit array
Out of range
https://projectpokemon.org/home/forums/topic/62190-user-message-an-unhandled-exception-has-occurred-you-can-continue-running-pkhex-but-please-report-this-error
2022-08-31 21:03:26 -07:00
Kurt
88ac14946d Don't be as strict with shedinja evo moves
EncounterMovesetGenerator doesn't specify a clean encounter, don't check it as thoroughly.
2022-08-31 19:09:06 -07:00
Kurt
bf37be3ea1 Update LearnVerifierEgg.cs
Order of operations being spooky
2022-08-29 16:08:56 -07:00
Kurt
d8fe34011d Remove some bounds checks, int->byte form oops
https://github.com/kwsch/PKHeX/pull/3575#issuecomment-1229244453
ty @Kermalis !
2022-08-27 12:53:30 -07:00
Kurt
3c232505e5
Refactoring: Narrow some value types (Species, Move, Form) (#3575)
In this pull request I've changed a ton of method signatures to reflect the more-narrow types of Species, Move# and Form; additionally, I've narrowed other large collections that stored lists of species / permitted values, and reworked them to be more performant with the latest API spaghetti that PKHeX provides. Roamer met locations, usually in a range of [max-min]<64, can be quickly checked using a bitflag operation on a UInt64. Other collections (like "Is this from Colosseum or XD") were eliminated -- shadow state is not transferred COLO<->XD, so having a Shadow ID or matching the met location from a gift/wild encounter is a sufficient check for "originated in XD".
2022-08-26 23:43:36 -07:00
Kurt
d3c2d77d11 Misc move/memory tweaks
Disallow max moves from Sketch
Hide dmax moves from legal dropdown lists
Pass ushort for moves for validating memories
Internal class for move pp (hide empty class from dll users)
2022-08-24 20:32:40 -07:00
Kurt
6441bdadd8
Add specialized struct for Moveset and IV specs (#3572)
`Moveset` struct stores 4 moves, and exposes methods to interact with a moveset.
`IndividualValueSet` stores a 6 IV template (signed).

Performance impact:
* Less allocating on the heap: Moves - (8 bytes member ptr, 20 bytes heap->8 bytes member)
* Less allocating on the heap: IVs - (8 bytes member ptr, 28 bytes heap->8 bytes member)
* No heap pointers, no need to jump to grab data.
* Easy to inline logic for checking if moves are present (no linq usage with temporary collections).

End result is faster ctor times, less memory used, faster program.
2022-08-21 17:34:32 -07:00
Kurt
2cb2531288 Add more xmldoc 2022-08-21 01:39:16 -07:00
Kurt
f62597cc24 Add shared egg moves to GetAllMoves fetch 2022-08-16 12:42:40 -07:00
Kurt
7c4e5e7b04 Add more xmldoc 2022-08-11 00:46:41 -07:00
Kurt
d1959d90a4 Move files 2022-08-11 00:24:59 -07:00
Kurt
54910b8fba Early return if no evos
GO transfers like Snivy can be viewed but shouldn't exist in Gen8. This avoids any exception being thrown for shared move check.
2022-08-05 16:18:06 -07:00
Kurt
19b4a26cd7 Use evo history to check visitation
Previously, the history shared Gen8 for Gen8a/Gen8b; now they're distinct.

Add "HasVisited" for other gens
2022-08-03 18:17:46 -07:00
Kurt
9166d0eb64
Refactoring: Move Source (Legality) (#3560)
Rewrites a good amount of legality APIs pertaining to:
* Legal moves that can be learned
* Evolution chains & cross-generation paths
* Memory validation with forgotten moves

In generation 8, there are 3 separate contexts an entity can exist in: SW/SH, BD/SP, and LA. Not every entity can cross between them, and not every entity from generation 7 can exist in generation 8 (Gogoat, etc). By creating class models representing the restrictions to cross each boundary, we are able to better track and validate data.

The old implementation of validating moves was greedy: it would iterate for all generations and evolutions, and build a full list of every move that can be learned, storing it on the heap. Now, we check one game group at a time to see if the entity can learn a move that hasn't yet been validated. End result is an algorithm that requires 0 allocation, and a smaller/quicker search space.

The old implementation of storing move parses was inefficient; for each move that was parsed, a new object is created and adjusted depending on the parse. Now, move parse results are `struct` and store the move parse contiguously in memory. End result is faster parsing and 0 memory allocation.

* `PersonalTable` objects have been improved with new API methods to check if a species+form can exist in the game.
* `IEncounterTemplate` objects have been improved to indicate the `EntityContext` they originate in (similar to `Generation`).
* Some APIs have been extended to accept `Span<T>` instead of Array/IEnumerable
2022-08-03 16:15:27 -07:00