Commit graph

1219 commits

Author SHA1 Message Date
Kurt
06196e0440 Minor tweaks
Less alloc
2022-09-04 22:23:35 -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
66e0613d82 Minor clean 2022-08-30 15:00:45 -07:00
Kurt
319a671a6d Simplify munchlax tree list usage 2022-08-29 17:38:27 -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
eb2cef10c9 Minor clean
Stability intensifies
2022-08-22 23:18:53 -07:00
Kurt
3dde8a7cfa Reduce linq usage, minor perf 2022-08-17 23:48:37 -07:00
tastymeatball
5f3516c3ce
Fixed error getting Z coordinate (#3567) 2022-08-12 07:58:23 -07:00
Kurt
59fad0e8cf Minor tweaks
Extract some logic (origin markings)
Revise directives for NET7 targeting, remove old net5 refs
2022-08-05 16:18:42 -07:00
Kurt
94668b4672 Fix clearing of clones (off by 1 last box)
Clamp end box in the clear/modify actions too, just in case.
2022-08-05 11:24:54 -07:00
Kurt
ec45ca1a83 Set species flag on ck3/xk3->pk3
Make GetG3Species return ushort

Fixes regression caused by 5942a74147
Copying SpeciesID3 instead of Species is fine as it skips the map/unmap step, but it also skips the setting of the HasSpecies flag. So we'll just set it in the individual ConvertToPK3 methods.
2022-08-04 09:53:15 -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
Kurt
45af203a26 Fix C/XD playtime reading
ty @trigger-segfault
e611c9661e
apparently Japanese XD uses 32bit instead of 64bit, different struct size. Seems the same as the memo size being different for japanese XD too.

Since we're now using Config, apply the correct CurrentRegion/OriginalRegion values when setting a pk* to sav.
2022-07-06 17:33:15 -07:00
Kurt
e4984b203c Update SAV3GCMemoryCard.cs 2022-06-30 07:17:47 -07:00
Kurt
1d94baeb7f Fix footer size chop
oops, another hotfix
2022-06-28 16:54:18 -07:00
Kurt
1f64a41670 Fix gci recognition 2022-06-27 22:28:46 -07:00
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
d8c8a13885 Add bizhawk footer handler
Optimize some of the other handlers.
2022-06-25 11:14:00 -07:00
Kurt
210bd90fc1 Add entree MissionsComplete for BW
Closes #3532

BW/B2W2 could be the same, meaning that the pass power offsets in the B2W2 class can be merged back in to the base class.
2022-06-19 08:39:43 -07:00
Kurt
d2115eb8b9 Add remaining gen4 roamer slots
Co-Authored-By: Matt <17801814+sora10pls@users.noreply.github.com>
2022-06-18 19:46:53 -07:00
ShadyRelapse-PP
bd25312181
Added Second Roaming Pokemon for Platinum and Third Roaming Pokemon for HGSS (#3531)
* Update SAV4HGSS.cs

* Update SAV4HGSS.cs

* Update SAV4Pt.cs

* Update SAV4HGSS.cs

* Update SAV4HGSS.cs
2022-06-18 19:14:29 -07:00
Kurt
d1c2f6ef6e Add gen5 roamer get 2022-06-18 19:12:41 -07:00
Kurt
0eca5cbe05 Add gen4 roamer to block editor
Closes #3528
2022-06-18 14:11:22 -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
8319bfe003 Fix Entree Forest saving
Closes #3524
2022-06-14 22:30:57 -07:00
Kurt
0093927e15 Use ReadOnlySpan instead of Span if appropriate 2022-06-13 00:04:20 -07:00
Kurt
436588eb10 Replace é->e for code symbols
Closes #3519
Usages weren't consistent; since `é` isn't accessible on usual english keyboards, just use regular `e` instead of alt-223 entry.

Not sure why VS preferred to save the text files without an encoding prefix; oh well.
2022-06-11 15:32:12 -07:00
Kurt
184440f266 Add more GBMobileCableColor values
see 7225b2b87b
2fe0cbbb19/gfx/mobile/mobile_adapters.pal
2022-06-11 10:40:10 -07:00
Kurt
15a84d9d7e Minor clean 2022-06-11 09:51:43 -07:00
Kurt
8c528855f4 Differentiate dragged PK8/PB8 better w/preferences
Better determine preference with file extension string
2022-06-07 03:33:45 -07:00
Kurt
54cb4dc8c8 Minor comment fixes 2022-06-07 03:21:04 -07:00
Kurt
ab723af640 Expose Context for SaveFile/ITrainerInfo 2022-06-03 19:08:46 -07:00
Kurt
978be73b9a Trycatch path->sav factory method
Closes #3512 -- had a bad gen3 save backup causing trouble.
2022-06-02 19:21:47 -07:00
Kurt
5bcccc6d92
HOME 2.0.0: Handle conversion behavior & restrictions (#3506)
* Revises legality checks to account for traveling between the three game islands (PLA/BDSP/SWSH)
* Adds conversion mechanisms between the three formats, as well as flexible conversion options to backfill missing data (thanks GameFreak/ILCA for opting for lossy conversion instead of updating the games).
* Adds API abstractions for HOME data storage format (EKH/PKH format 1, aka EH1/PH1).
* Revises some APIs for better usage:
  - `PKM` now exposes a `Context` to indicate the isolation context for legality purposes.
  - Some method signatures have changed to accept `Context` or `GameVersion` instead of a vague `int` for Generation.
  - Evolution History is now tracked in the Legality parse for specific contexts, rather than only per generation.
2022-05-30 21:43:52 -07:00
Lusamine
0b50d6d4ac Label SWSH Poke Job Storage Block 2022-05-18 00:03:59 -05:00
Kurt
50ce6a92db Revise stadium detection if no teams set
Closes #3494
Thanks @keiyakins !
2022-05-15 14:05:10 -07:00
Kurt
a5b46d80f5 Minor tweaks
ShowdownSet: Lessen allocation
MoveTutor: Remove boxing by calling the generic method instead of object method
Xoro8b: Add more xmldoc, use positive constant instead of inverse negative for parity
StadiumUtil: Use built-in endianness reversal methods
2022-05-14 08:28:13 -07:00
Lusamine
4e703b7c9e Correct ordering of SWSH rental team blocks 2022-05-13 20:02:41 -05:00
Kurt
bc054c09ed PK5: Clear party stats on import
Add property get/set for the undocumented fields
2022-05-08 18:36:18 -07:00
Kurt
69794e7328 PK4: Add Seals & Ball Capsule index
0xD4 + 0x18 = 0xEC = 236 bytes -- end of data!
2022-05-08 13:16:41 -07:00
Kurt
3e8527f11a Minor tweaks
Reduce allocation in a few places, delete unused stuff, more concise expressions.
2022-05-07 21:25:26 -07:00
Kurt
a57f40ae7d Break up PKX into separate classes
Many years ago, PKX used to be a >4,000 line bloated file, which spun off multiple classes like CommonEdits and most of the early non-GUI PKM related logic. Now, it's just a stub to source the latest generation & personal table.

Separate files = more concise info, and more room to grow to do more advanced things.
Makes the IsPresent methods public (no longer internal).
2022-05-06 20:38:55 -07:00
Kurt
be9c947dd6 Use tuples and ComboItem, not anonymous class
Little more explicit
2022-05-06 15:43:51 -07:00
Kurt
75874b6b81 Show lock capsule slot in mystery gift editor
Closes #3487

editor getting hacky, but it works
2022-05-05 21:21:03 -07:00
Kurt
d58aed109d Add Current Box Changed flag for sav1/2
Flag not set causes the game to clear all boxes (except current box) to clear garbage sram if saves never cleared. Yay deferred execution?
2022-05-02 23:47:41 -07:00
Kurt
fa76da56c9 Inline some Rand32 calls
No functional change
2022-04-26 20:21:26 -07:00
Kurt
1f49574be1 Fix g6 hof len 2022-04-23 22:05:51 -07:00
Kurt
f5358e0e37 Update HoF6 entity editing
Reusable entity struct, no more overlapping fields
Adds OT Gender, fixes some flags.

Thanks L1nk2futr3 !
https://projectpokemon.org/home/forums/topic/60977-hall-of-fame-tid-resetting-gen-6/?do=findComment&comment=275575
2022-04-23 10:42:56 -07:00
Kurt
ff2e890e69 Revise Overworld8a application of PIDIV
Instantiating from template now follows group seed -> spawn 1 correlation, including alpha move.
Differentiates static encounters that don't follow the ow8a correlation, scrambles EC to disassociate.
Adds rand64 to get initial seeds
Set correct level range to match slotSeed; not respecting the slot roll being valid, but whatever.
2022-04-22 21:11:11 -07:00