Commit graph

594 commits

Author SHA1 Message Date
Kurt
287a2ac5c5 Rework handling of bk4 constructor
Can't really detect if it's shuffled or not; just assume it's always unshuffled unless it originates from a save file read. Probably not a perfect solution, but achieves better results.

https://projectpokemon.org/home/forums/topic/56217-error-in-archive-bk4/
2020-03-18 23:34:53 -07:00
Kurt
ed02f39224 Use another overload
Co-Authored-By: Archit Date <architdate@gmail.com>
2020-03-04 22:31:07 -08:00
Kurt
a83556d612 Heal x->pk8 converts 2020-03-02 16:32:23 -08:00
Kurt
d58426ebf5 Hide affection fields, remove setters for unused
#2738
2020-02-27 20:53:33 -08:00
Kurt
9efaae0df6 Remove unneded property copy
eggs didnt exist in lgpe, would be all zero anyways
memories copy in pk7, remove todo
2020-02-14 14:48:48 -08:00
Kurt
ae0777018c Update PB7.cs
Co-Authored-By: Chris Feger <piepie62@users.noreply.github.com>
2020-02-14 11:48:13 -08:00
Kurt
d560fbcf7f Fix typo
Co-Authored-By: Chris Feger <piepie62@users.noreply.github.com>
2020-02-13 21:00:07 -08:00
Kurt
6346444db7 Extract home tracker to interface 2020-02-12 18:52:48 -08:00
Kurt
ebf20d927b More transfer implications
Totems are downsized to regular
araquanid, togedemaru, and ribombee totems can't transfer (at the moment)
2020-02-11 20:11:33 -08:00
Kurt
435953f4e1 Don't transfer locale 2020-02-11 19:04:00 -08:00
Kurt
217156d2b9 Continued comparisons & implications
pk7->pk8 doesnt assign height/weight (zero), require zero for legal
p*7->pk8 assigns a tracker value, enforce something is present for legal
copy OT friendship (oops)
2020-02-11 18:35:54 -08:00
Kurt
332f92f5e9 Update p*7 transfer logic
Add scalars & stat natures

Do note: there is more data that is set and can potentially be used to flag you for cheats. Beware.
2020-02-11 18:05:07 -08:00
Kurt
c301ce88ab Update Random to be a bit more thread safe
Random isn't thread safe; users of PKHeX.Core.dll might run multithreaded operations (see PKSM + ALM), so we need to have a thread-specific RNG available.

Thread Local get; to improve performance, save the random object locally whenever it is used more than once in the method.

https://docs.microsoft.com/en-us/dotnet/api/system.threading.threadlocal-1?redirectedfrom=MSDN&view=netframework-4.8
https://stackoverflow.com/questions/18333885/threadstatic-v-s-threadlocalt-is-generic-better-than-attribute/18337158#18337158
2020-01-25 21:49:52 -08:00
Kurt
467045e95c Swap rand call order, rename as overload 2020-01-22 19:04:20 -08:00
Kurt
63ea57436f Make the template IV/contest stat array readonly
See prior commits
no longer need to clone subarrays, they're shared immutable
2020-01-18 19:11:29 -08:00
Kurt
843330a375 Remove unnecessary null checks
this is a null free project /s
dont provide null, else u deserve to get an exception
2020-01-18 16:57:25 -08:00
Kurt
8312c52cc1 Make Move[] readonly list
contract: don't modify the template movesets
mystery gift now exposes IRelearn, remove unnecessary type checks
2020-01-18 16:46:38 -08:00
Kurt
857124acf0 Swap zen galar -> galar zen
ty showdown for changing your convention over a month ago
a01e2a26bc (diff-58e367765263b7e21df251b3e7619b70L9307)
2020-01-16 18:54:09 -08:00
Kurt
2e16fb058c Show form arguments in gen6/7
Clamp form argument load to current list bounds (used to throw arg range exception if invalid)
2020-01-13 17:09:03 -08:00
Kurt
95f24a9d36 Revise suggested AV set logic
Closes #2630
2020-01-11 11:43:53 -08:00
Kurt
51d2fc9d93 Update with slowpoke-1/new raid data
TransferVerifier: Revise transfer check to allow slowpoke-1 (slowpoke-0 is flagged via next check)
2020-01-09 18:44:45 -08:00
Kurt
0dd4d1fe7a Remove unnecessary casts 2020-01-06 17:50:18 -08:00
Kurt
efbac28b91 Rework accessors for PKMConverter trainer cache
Might break downstream users, for the better. Internal behavior had to change!
2020-01-05 21:51:02 -08:00
Kurt
1906a1040f Relocate console-location data setting to PKMConverter
When adding data, check if the current Trainer has valid console data; if not, use a default value.
2020-01-05 21:41:32 -08:00
Kurt
e21d108fb2 Split PokeCrypto from PKX
All logic in PokeCrypto is separate from the rest of the PKHeX.Core
library; makes it easy to just rip this portion out and reuse in other
projects without needing the entirety of PKHeX.Core logic

optimize out the CheckEncrypted to the actual path, separate methods.
Only usages of this method were with hardcoded Format values, so no
impact
2020-01-04 14:48:39 -08:00
Kurt
a08ebff699 Add gen8 mimikyu form case
Closes #2618
2020-01-03 19:20:16 -08:00
Kurt
166f8d82e5 Misc clean
Refactor out some logic, make "en" literals reference one spot (where
appropriate)
2020-01-01 19:07:21 -08:00
Kurt
d736f24bb7 Heal PP on transfer
force everything to their current pp count
2019-12-26 15:28:04 -08:00
Kurt
827a7649c1 Export PCD/PGT as encrypted format
add Write method for writing the data outside the program; only use Data
if you know what you're doing!
2019-12-24 23:24:28 -08:00
Kurt
9d1bfd67b5 Add braces
style fix, no functional change
2019-12-24 23:23:42 -08:00
Kurt
8309060298 Add more egg verification for statnature/techrecord 2019-12-21 14:51:52 -08:00
Kurt
e9d127f225 Copy console data, copy OT memories
still hypothetical; we know that memories exist and console data still
has accessors
HT memories should be replaced, so no need to transfer 'em.
2019-12-10 19:13:32 -08:00
Kurt
8acb336d51 Use enum for species comparisons
slightly easier to read with named values
2019-12-08 17:39:19 -08:00
Kurt
5ddd59c9aa Fix runerigus/yamask partial load fail
320 is max hp (31IV 252EV), is this just -60 from max HP (threshold to
evolve at?)
might need some more research to see what is going on with this

only trycatch in release builds; was confused until I stepped thru and
saw the crash
2019-12-08 00:03:08 -08:00
Archit Date
3526c37f1e update forme to showdown strings (#2558)
* update forme to showdown strings

Galarian is represented as Galar on PS!
Polteageist has no form atall
galarian now called Galar by default to match with Alola as a forme. changed darmanitan forme-strings in form converter. Added sinistea to the forme ignore list when converting to showdown
2019-12-03 16:41:52 -08:00
Matt
7b7a161ac9 Minor fixes (#2547)
Fix Sinistea/Polteageist Form names (as per Strategy Guide)
Add Eternamax menu sprite
2019-11-30 13:19:22 -08:00
Kurt
3c4e668d9a Add alcremie formArg gui
Closes #2538
Standardize nomenclature as FormArgument, add interface for those
exposing the property.
2019-11-29 10:44:52 -08:00
Kurt
f25b36a306 Minor tweaks
Remove unused stuff
add some comments/xmldoc
Move Trainer1 to classes that use it
2019-11-28 14:00:55 -08:00
Kurt
445fdee2ba Add shared memory interface (encounter) 2019-11-26 10:46:16 -08:00
Kurt
24ac0d9d4b Fix WasLink comparison
Closes #2525
G4Celebi & G6Link met location match; Pokémon Link was only available
for Gen6 so just check for that origin.

Ty @Ammako

tbh I shouldn't even have this property ha
2019-11-25 19:29:12 -08:00
Kurt
5435a5d93e Minor updates
Fix mark (ribbon) read for index > 64
Heal party stats on set detail import
Wipe HT Language for eggs/untraded
Extract BST total color logic
2019-11-25 17:32:10 -08:00
Kurt
4a6fa684e6 Fix IsUntraded check
used the pk6 offsets lol
2019-11-22 23:00:36 -08:00
Kurt
a50169d3d2 Add shift-set shinyxor0 pid
Display xor value on hover, not gonna do alternate stars/square display
Closes #2482
2019-11-20 20:38:05 -08:00
Kurt
1df90199e3 Rework GetBaseSpecies to return EvoCriteria
#2452
2019-11-18 20:26:11 -08:00
Kurt
674152aa25 Add Mark interface 2019-11-18 17:00:16 -08:00
Kurt
d077d8549e Add alcremie form display for dex edit
Nothing for the PKM Editor; not sure how I want to handle the reused
FormDuration work value.

For the meantime, just use the Batch Editor for a targeted write.

Closes #2441
2019-11-17 09:34:04 -08:00
Kurt
915c2d52b1 Update handling for non-competitive set import
Gen3 item paste -> Gen3 item import => take item ID as is
once parsing moves starts, break if any following lines are not move
lines
Closes #2412 , thanks @The-Fireplace  !
2019-11-16 16:34:28 -08:00
Kurt
d981dc57e1 Handle ’ ' edge case
#2412
2019-11-16 16:21:17 -08:00
Kurt
025cf69eeb Switch pkm export formats to party format
Now dumps party format bytes
Cons: more space
Pros: stats are retained, especially when users drag-drop.

Closes #2419
2019-11-16 14:03:25 -08:00
Kurt
dfcd93bfff Fix alcremie form list, use toxtricity0 amped
https://projectpokemon.org/home/forums/topic/55410-alcreamie-mismatches/
2019-11-16 08:46:59 -08:00
Kurt
ab25038b58 Update max gen, add pk8/wc8 to dropdowns 2019-11-16 08:25:05 -08:00
Kurt
cefb56a749 Sword/Shield Update 2019-11-15 17:52:08 -08:00
Kurt
46640d48a3 Misc clean
un-nest classes,
move some logic to core,
update some get-only properties that return arrays to methods
2019-10-26 12:58:55 -07:00
Kurt
fcc993784b Rename abstract pkm inherited class names
leading underscore for a class name = pls no
2019-10-26 12:42:33 -07:00
Kurt
e3efa65160 Cleanup
handle messages for dirty cleaning :)
2019-10-26 12:33:58 -07:00
Kurt
02420d3e93
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases

Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization

* Handle bits more obviously without null

* Make SaveFile.BAK explicitly readonly again

* merge constructor methods to have readonly fields

* Inline some properties

* More nullable handling

* Rearrange box actions

define straightforward classes to not have any null properties

* Make extrabyte reference array immutable

* Move tooltip creation to designer

* Rearrange some logic to reduce nesting

* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum

* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case

* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable

* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator

* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever

* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)

* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-16 18:47:31 -07:00
Kurt
4baf745af8 Use some c#8 sugar
static local functions
switch expressions
using usings :)

nullable next?
2019-10-07 18:40:09 -07:00
Kurt
87f43a47d8 Bump lang version to 8
some lang upgrades
2019-10-04 20:10:50 -07:00
Kurt
8d8adde2b1 sealed
sealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealed
2019-10-03 19:09:02 -07:00
Kurt
ffe3a4ba15 Relocate resource naming for sprite fetch to draw 2019-10-03 18:23:40 -07:00
Kurt
94baab1c45
Split off image generation to separate project (#2395)
With the approaching games, PKM sprites are a different size from the 3DS era (as already hinted by LGPE, which has 56x68). It'll be a little easier to manage with this portion of the library walled off from the rest of the codebase.

Eventually the net46 target will use fody or something to merge in these extra dependency dll's automatically to not disturb the usual exe/dll experience.
2019-09-29 09:47:06 -07:00
Kurt
980a9874a3 Remove unused wrappers
I think I left these in so AutoLegality could function, but we already
have a couple breaking changes / build pause notice, so lets keep
cleaning our API 👍
2019-09-23 17:28:40 -07:00
Kurt
ab0b8979e9
Add swsh content placeholders (#2392)
placeholder content until real data is dumped
2019-09-23 16:56:47 -07:00
Kurt
7819c16792 Use slice operation instead of linq chain
Reuse IsRangeAll for smdemo detect
reset dragdrop on dropping folder (early returned)
2019-09-23 15:13:22 -07:00
Kurt
8912f76726 Clean up super training medal checks
Futureproof with transfer considerations
This is just a guess; gen7 didn't update the medal count and if we
assume pk8 overhauls the structure for a new console, they'll drop old
data.

With c#8 later next week, will move SuperTrainingMedalCount() to a
default interface method ez.
2019-09-20 20:55:36 -07:00
Kurt
b41f2a3062 Extract logic from PKX
Extract Species Name logic to SpeciesName
Extract Language logic to Language
Remove FormConverter wrapper for string[] fetch
Rearrange some logic to more appropriate locations, update access
modifiers / types
Move some pkm array methods to arrayutil, make generic

PKX.GetVCLanguage was a dupe of _K12.GuessedLanguage() so just expose
the method

PKX is now back to pkm data manip only
2019-09-18 19:58:23 -07:00
Kurt
0d9c18e1c6 Minor clean
dual bounds check -> single check via uint cast
pkx: keep array reference for reuse in next check
format return to second line to stick out more; lines of code are cheap
:)
2019-09-11 22:17:16 -07:00
Kurt
c5ebbbbe15 Minor clean
Magic number -> const usage
default(T) -> default (c#7.x feature)
remove some unused stuff
fix indentation in some spots
2019-09-10 22:07:50 -07:00
Kurt
62d08d7c30 Misc clean
split some methods with optional parameters=null
add more xmldoc
replace some magic numbers -> enum/const references
consolidate common array operations (span soon maybe?)
2019-09-10 00:21:51 -07:00
Kurt
7424cf6fb0 Remove GSC/C differentiation in PK2
Allows for no adjusting the game group
2019-07-28 13:26:39 -07:00
Kurt
db632905fd Remove WasEgg setter
WasEgg (aka WasDefinitelyAnEgg) from stored properties is one thing,
WasEgg from encounter info is another; don't mix
2019-07-25 17:42:20 -07:00
Kurt
f37a587a1c Minor simplifications
move some pk3->pk4 stuff into object constructor
annotate pk3->pk4 string buffer (trash) quirks
split Heal into Party/PP method uses. Setting suggested stats no longer
refreshes PP
apply current level to Stat Level (wasn't being set previously)
2019-07-12 16:41:13 -07:00
Kurt
ab735de2d9 Revert "Decapitalize non-nicknamed on 4->5 transfer"
This reverts commit 904dc84b52.
2019-07-09 20:24:47 -07:00
Kurt
7e0fc61428 Add unused character encodings to dictionary
Two of the inaccessible keyboard chars are used by Spanish trades, so
they aren't completely unused.

#2338
2019-06-26 21:16:18 -07:00
Kurt
5fbf9ba278 Fix cloning of a bad-checksum pk3 2019-06-18 20:55:35 -07:00
Kurt
e02f7ef30f Reduce allocation required for ability check 2019-06-18 20:54:59 -07:00
Kurt
523c36d982 Add qr parse util
used in pkhex.mobile, might as well migrate some logic into core
I'd rather not untangle the decode-api response parsing to use QRUtil.
2019-06-18 20:10:01 -07:00
Kurt
904dc84b52 Decapitalize non-nicknamed on 4->5 transfer
Closes #2320
2019-06-08 20:16:30 -07:00
Kurt
513648638f Fix incompatible hax conversion (1/2->3 etc) error
Shared base classes throw a new snag, where the property may be Declared
in the shared class.

eg:
PKM -> _K12 -> PK2

just filter all public ones that have a setter; works well enough idk
2019-05-28 16:52:59 -07:00
Kurt
33a07a6fcd Try and force destination language on transfer
Closes #2314
2019-05-27 11:23:47 -07:00
Kurt
1d44136e54 Update xd fateful flag leniency
not enough documentation to know what every single flag does; just be
lenient

I assume that flags being present XK3->PK3 will set fateful, so we could
remove that logic...
Exposing bitflags for editing isn't fun for the editor, so just ignore
it behind the fateful bool get/set.

fateful required for all xk3 origin

#2289
2019-05-14 20:14:15 -07:00
Kurt
555e81205d Update fateful encounter read location
Closes #2289
2019-05-14 18:36:48 -07:00
Kurt
4b770e62d9 Simplify and relocate wurmple evo logic 2019-05-11 14:25:58 -07:00
Kurt
55189a6967 Extract most common location numbers to class 2019-05-10 20:46:49 -07:00
Kurt
be50830975 Relocate method to extension logic class
GetLocationString is now right below GetPotentialString
PKX no longer has extension methods aside from the two CopyTo sugar
2019-04-29 17:36:29 -07:00
Kurt
7c380a29c3 Make sort skip delegate more general 2019-04-29 17:20:16 -07:00
Kurt
d8f064409f Fix pk1->pk2 conversion parameters
https://projectpokemon.org/home/forums/topic/52273-replicable-issue-cant-inject-pk1-in-silvercrystal-save/

Thanks Maddaren!
2019-04-17 18:35:51 -07:00
Kurt
a481757b45 Relocate CheckEncrypted to PKX
PKX references within the method; no dependence on anything in
PKMConverter
2019-04-16 22:51:01 -07:00
Kurt
5a53c2490a Simplify expression, emit inner error messages
existing logic had been overwriting the inner error messages with the
generic fail message

Remove backwards conversion precondition check; the ConvertPKM method
has no branches that allow conversion so it'll naturally fail -- end
result is the same with less upfront logic.
2019-04-16 22:38:50 -07:00
Matt
7e553155e1 Fix PKM conversion prompt order (#2285) 2019-04-16 10:54:29 -07:00
Kurt
0fdd9d98e6 Fix xmldoc typo 2019-04-14 09:04:40 -07:00
Kurt
f4740bbe52 Capture reused variables 2019-04-09 20:58:19 -07:00
Kurt
bbe56a3318 Simplify trade trainer parameters
Bank was always false, don't try to minimalize gets by fetching before
call (be simple)

remove unreachable branches now that dust has settled
2019-03-30 22:05:28 -07:00
Kurt
c7a610b02b Fix typo in method names
Transferrable->Transferable
2019-03-28 21:44:06 -07:00
Kurt
583fcfa449 Use builtin struct instead of anonymous object
faster overall
2019-03-22 18:46:31 -07:00
Kurt
bc5ed2d218 Misc reductions
Removes empty trashbyte array allocation (less objects)
Change int[] to byte[] (less filesize/mem) (-256*6)
Change int[] to ushort[], precompute reverse table in saved space
removes dictionary lookup for array index fetch (faster, less memory, no
temp obj allocations!)

could make the ushort[] arrays into byte[] by changing them to be value
shifts? Not worth saving filesize for cpu.
2019-03-22 18:42:03 -07:00
Kurt
687da38e2e Add pkrs infected/cured setters 2019-03-21 16:48:17 -07:00
Kurt
cce362b98a Relocate FFFF trim (and 0000) to same location 2019-03-20 22:13:09 -07:00
Kurt
b1ead9e630 Split StringConverter into smaller pieces
reduces loading time (don't have to allocate conversion arrays when
launching a gen7 game), and separates things to easier to manage
locations

reworks gen3 string encode/decode, no longer does 3->4->5 and 5->4->3;
instead goes straight to the end result without an intermediary format.

String sanitization should probably be broken up rather than reused, oh
well.
2019-03-20 21:50:44 -07:00
Kurt
9f7f9f9e75 Use glyph dictionary instead of creating 19 strings
muh optimization
2019-03-16 20:15:12 -07:00