Commit graph

746 commits

Author SHA1 Message Date
Kurt
8936c58417 Skip setdex/modify on box sort 2020-04-14 10:46:21 -07:00
Kurt
33bdacebe8 Minor tweaks
Handle some compiler/extension suggestions
2020-04-12 16:07:59 -07:00
Kurt
0ada4cbd77 Remove some unnecessary null checks 2020-04-12 13:20:40 -07:00
Kurt
270d984130 Minor clean
Remove unnecessary null checks
Mark some methods with nullable type
2020-04-04 19:30:50 -07:00
Kurt
d65338557e Add hp stat 2020-03-24 11:44:54 -07:00
CanoeHope
df09868470
Add another SWSH block (#2793)
Nothing special. Just found it and figured why not add it.
2020-03-19 11:38:17 -07:00
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
Kermalis
face69d469
Fix Emerald decorations (#2788) 2020-03-18 00:25:02 -07:00
Kurt
429a3b1a08 Expose decoration list for editing
Closes #2785 , not making a GUI for this (someone else can do it)

Moves RTC3 to the appropriate folder
2020-03-17 12:14:01 -07:00
Kurt
1c6b99185d Ignore bits above the first 3
Some save files use bits 3-7?
2020-03-15 11:11:55 -07:00
pi1024e
8a1e73e5b3
Change OT_Class to have an expression body (#2759) 2020-03-13 10:28:50 -07:00
Kurt
b68e9472cb Break apart value fetch -> compare
easier to debug
2020-03-12 15:05:59 -07:00
Kurt
fbd533092d Fix misspelling of the word "Received"
Closes #2757

Co-Authored-By: pi1024e <pi1024e@users.noreply.github.com>
2020-03-12 15:05:34 -07:00
Kurt
eb01591861 Remove duplicate method
Extract magic number 0x40000
2020-03-11 21:09:36 -07:00
Kurt
0aa6282d73 Sanity check value types via generic method 2020-03-11 16:31:53 -07:00
Kurt
f9bbeba3ad Add get/set for swsh current box
Closes #2742

Co-Authored-By: Matt <sora10pls@users.noreply.github.com>
2020-03-10 23:18:51 -07:00
CanoeHope
e51df9855d
Add blocks for NPC and Friend League Cards (#2741)
* Add blocks for NPC and Friend League Cards

* Update SaveBlockAccessor8SWSH.cs
2020-03-01 00:47:56 -08:00
Kurt
4fb33413e3 Only set display shiny of not owned
Closes #2740 ; we don't want to set display shiny if it's not shiny

we only want to set display-shiny if (!owned && shiny)

Co-Authored-By: canoehope <canoehope@users.noreply.github.com>
2020-02-28 17:35:50 -08:00
Kurt
d80d1598dc Only set displayed form if not previously owned
Closes #2739
2020-02-28 15:31:26 -08:00
Kurt
e378821101 Remove duplicate key item list for pc items
Closes #2733

Co-Authored-By: kermalis <kermalis@users.noreply.github.com>
2020-02-22 19:47:25 -08:00
Kurt
4116fb5b9b Fix sprite format for gen3
Closes #2725

Fix crash if canceling the FRLG version select

Co-Authored-By: Kermalis <kermalis@users.noreply.github.com>
2020-02-20 19:36:06 -08:00
Kurt
0d4cff81c6 Clean 2020-02-15 14:29:23 -08:00
Kurt
3ce590aca8 Don't clear FormArgument on set to box slot
Closes #2706
removal of isParty prevents the erroneous force-0 behavior

Co-Authored-By: Russell Jones <questiondesk@gmail.com>
2020-02-13 16:35:37 -08:00
Kurt
9f6d234c53 Fix hgss box wallpaper read
lol oops
Closes #2698

Co-Authored-By: ammako <ammako@users.noreply.github.com>
2020-02-11 23:24:03 -08:00
CanoeHope
7ab128de89
Add SwSh Birthday blocks (#2696)
Because the Switch doesn't have a feature to internally store your B-day like the DS and 3DS does, you set it in-game by the "Fortune Girl" right in front of Wedgehurst's PokeCenter in month and day.
https://www.serebii.net/swordshield/birthdays.shtml
2020-02-10 18:14:20 -08:00
CanoeHope
acb9cc2a9d
Add Gender to Gen 8 Trainer Card (#2694) 2020-02-10 12:02:52 -08:00
Kurt
1bf22467de Add Rental Team (gen8) reader 2020-02-07 17:23:26 -08:00
Kurt
d52366b0d5 Add download rules/comp block labels
https: //projectpokemon.org/home/forums/topic/56121-swsh-blocks-and-save-research/
Co-Authored-By: pp-theslayer <pp-theslayer@users.noreply.github.com>
2020-02-07 16:32:05 -08:00
Kurt
a73f14836d Add HoF time block accessor object
Not gonna add it to the interface
Closes #2691

Co-Authored-By: canoehope <canoehope@users.noreply.github.com>
2020-02-07 15:59:36 -08:00
Kurt
c08cf9c95f Add rental team hashes
Co-Authored-By: Archit Date <architdate@gmail.com>
2020-02-07 15:33:53 -08:00
Kurt
7866958af8 Add dynamax crystal type, exclude from activation
Closes #2690

Co-Authored-By: slp32 <slp32@users.noreply.github.com>
2020-02-07 10:16:27 -08:00
Kurt
cc05a38548 Clear team slots on blank load
Closes #2688
2020-02-06 20:11:58 -08:00
Frank
e5286f3325
RaidSpawnList8 fix DenType and Flags (#2686)
* RaidSpawnList8 use enum RaidType for DenType

fix IsWishingPiece and add WattsHarvested

* Add check between RaidType.Event and IsEvent flag
2020-02-06 17:12:26 -08:00
Kurt
a004b301d0 Add record count incrementing for sav8
Closes #2685 ty @CanoeHope
2020-02-05 19:42:46 -08:00
Kurt
bc45660f99 Update legal raid clamp
https: //github.com/kwsch/PKHeX/issues/2681#issuecomment-582215498
Co-Authored-By: slp32 <slp32@users.noreply.github.com>
2020-02-04 19:06:33 -08:00
Kurt
2e1528b199 Merge branch 'master' of https://github.com/kwsch/PKHeX 2020-02-04 16:55:42 -08:00
Kurt
7e6cae4004 Clamp activating raids to available indexes
Closes #2681
2020-02-04 16:55:40 -08:00
CanoeHope
9b172d2666
Correct Day offset (#2679)
a1ae14325a (commitcomment-37103852)
2020-02-04 07:35:02 -08:00
Kurt
0e1fd49be1 Decrement runtime language if appropriate
Closes #2674
2020-02-03 19:16:30 -08:00
Kurt
a1ae14325a Add more block documentation
Ty @CanoeHope !
Closes #2677

To edit these values, use the Block Data editor and select the *Object Trainer Card

Co-Authored-By: CanoeHope <canoehope@users.noreply.github.com>
2020-02-03 18:56:35 -08:00
Kurt
b31f0428cf Add raidtype docs & wishing piece indication 2020-02-02 10:21:34 -08:00
Kurt
43036e7e94 Add team index recognition
lock by default until we find the location that locks team slots
2020-02-01 18:56:23 -08:00
Kurt
b35d53368f Sort blocks by initial value
allows some lumping of similar-value blocks for easier analysis
2020-01-28 19:08:26 -08:00
Kurt
ee5c033b51 Add dlc block annotations
ty @pp-theslayer
https://projectpokemon.org/home/forums/topic/56121-swsh-blocks-and-save-research/

add another array detail
2020-01-28 16:21:11 -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
527442bb49 Only fetch strings when required for compat check
if item == 0, don't bother checking. Fetch strings only if there's an issue with the item.
2020-01-25 12:16:45 -08:00
Kurt
9b6a10df46 Extract metadata-reflection class to PKHeX.Core
separate GUI logic from non-gui logic :)
2020-01-24 17:57:47 -08:00
Kurt
92d1ccf3d9 Fix Pokewalker course unlock all
write to correct location
https://projectpokemon.org/home/forums/topic/56084-pokewalker-courses/
2020-01-24 17:10:53 -08:00
Kurt
46156b48c6 Add missing generation to accessor type name
Now matches Interface declaration style (iAccessorGenGame), and is consistently named with the other accessors already using the same naming style
plus they are now ordered in the file tree :)

no functional change
2020-01-23 23:22:54 -08:00
Kurt
fb02295c70 Use object block names in diff 2020-01-23 23:19:38 -08:00
Kurt
12244909ba Split off SCBlock-logic from SWSH accessor
In case a future game uses this same setup.
2020-01-23 23:16:09 -08:00
Kurt
2adbca628b Add raw value edits
Not done for Array types or Object types
muh reflection, such spooky

mark Offset as non-browsable so it doesn't show up in propertygrid if the block is being edited by a grid :)

I imagine a struct-type-sensitive array property grid edit could be done via Buffer.BlockCopy to a dest array, but there's so few Array blocks... so meh
2020-01-23 21:30:39 -08:00
Kurt
a88c7c4800 Add more trainer card/status fields & stats
Closes #2658 ty @CanoeHope !
Mostly just serves as documentation; with the amount of fields being editable increasing, hard-coded GUI might not be optimal here. I'm thinking something like a PropertyGrid based on the selected block which will pull up the Block object if the key matches... for fields, something like a dynamically populated list or something.
2020-01-23 18:31:10 -08:00
Egzon
a5985536e2 Miscelanous fix on Underground Scores (#2657)
* UG scores are uint32, with max value up to 999999.

* fixing label position

* another positioning fix!
2020-01-23 16:37:39 -08:00
Kurt
ba5cc26e83 Add indication to which blocks changed
Use reflection to grab all const declarations (private and public), and grab the name of that const. Whenever that block is mentioned in our diff, use the name instead of the key.

Helps identify what changed / remove noise if you don't care about that block.
2020-01-22 17:06:23 -08:00
Kurt
4ea2be250f Add TitleScreen8 and Trainer Card team structs
Closes #2653 , ty @CanoeHope !

Editable from the Trainer Info button, comes with a Copy From Party button for each.
2020-01-21 23:23:27 -08:00
Egzon
9cce65e937 Fix Subway Super checks (#2652)
Oops, it's actually a byte...
2020-01-21 11:00:09 -08:00
Kurt
b84cae9ff5 Fix box name write for sav8swsh
only used via the view-all-boxes popup when switching boxes
ty anubis!
2020-01-20 22:04:52 -08:00
Kurt
6fdc71b2e4 Update tower record set
Record ID const declaration for reuse
Change 255->300 for streak max
Set record as well (ignore currently set value if modified via dropdown)
Closes #2649

Not sure if Money and BP can get a similar record-set treatment.
2020-01-20 18:16:46 -08:00
Kurt
40e5cd66da Add block diff for swsh, add bool type toggle
Apparently my copypaste of the class didn't delete all the old unused controls. Ha!

Move non-gui logic to core as separate classes, in case ppl wanted to reuse them in their own projects.
2020-01-19 22:29:50 -08:00
Kurt
a98ca2351d Don't SetValue to block if not exportable
blank saves do not have the type metadata for the blocks that are spoofed, nor do they have all blocks spoofed.

I suspect things might get more difficult as more value-blocks are identified, which would throw a wrench into things. We'll figure that out at that time :)

Add a test to ensure that the blank save can be created correctly

Closes #2644
2020-01-19 10:25:40 -08:00
Kurt
4567bba03f More elegant block read/write
Removes TONS of unnecessary allocations, and is more simple
2020-01-19 00:55:10 -08:00
Kurt
0244cc7489 Add more info to exception message
Closes #2644
2020-01-18 19:44:34 -08:00
Egzon Qukovci Jusufi
ab5016bf7d Add Subway Scores edition (#2643)
* Add Subway Scores edition

* Changing the offsets handling

Simply use the block offset as the base and add them to it. Also allow edition on B2W2.
2020-01-18 19:31:36 -08:00
Kurt
643c0c1cc7 null/empty check -> check both 2020-01-18 17:33:19 -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
40c2c483fb Common1-3 => Bool1-3
Blocks that use Bool1/2 toggle to the other state; evident when comparing between two different saves. The key doesn't change, only the Type is toggled.
2020-01-18 14:19:01 -08:00
Kurt
9b0b0cb1a6 Add misc value r/w for trainer8
Closes #2639
casting object to generic T : struct isn't valid, so just cast the get/set appropriately
2020-01-17 23:25:02 -08:00
Kurt
2a7d475b5b Rearrange key list, add syntax sugar methods 2020-01-17 21:53:51 -08:00
Kurt
e4e1681e1c Clamp roto rally score to 99_999
https://github.com/kwsch/PKHeX/issues/2639#issuecomment-575863541
2020-01-17 21:09:54 -08:00
Kurt
e3cafe5cd6 Relocate getsize to extension method
use sizeof for clarity, add test to ensure bool size is 1 byte (which is always true)
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/sizeof
2020-01-17 21:09:26 -08:00
Kurt
a590d3713b Refine enum with TypeCode names
Add GetValue/SetValue/GetType extension methods
2020-01-17 18:59:45 -08:00
Kurt
41f909c08a Add Roto Rally score, copy Jersey # to other block
Closes #2635
2020-01-15 20:48:19 -08:00
Kurt
a6aabcdc96 Split out a method before crypto step
Allows for capturing the obtaining the raw decrypted data via the PKHeX.Core api
2020-01-13 19:03:27 -08:00
Kurt
7e6edbaded Remove unnecessary constructor
Make key readonly
2020-01-11 14:18:11 -08:00
Kurt
62c35194c3 Remove unnecessary form duration code
probably misinterpreted the furfrou/hoopa stuff; probably is "SetMaxFormDuration"
d3f6d5935f (commitcomment-36754955)

ty @CanoeHope
2020-01-10 22:16:30 -08:00
Kurt
2915692daa Use more performant block lookup strategy
Rather than storing a dictionary of keys, we can abuse the fact that the SCBlock[] is stored in order of ascending block key.
Binary Search doesn't require extra memory like a Dictionary would; also, we only need to find a few blocks.
2020-01-09 19:00:49 -08:00
Kurt
3fa44361e6 Update block fetch & blank init
blanks: {key,size}
fetch: get block by key (index isnt the same between patches, as blocks with different keys get added). The savefile stores them as a SortedDictionary (by key), hence the shifting.
2020-01-09 08:59:26 -08:00
Kurt
bbd1aff5fe Add new lengths
new format still crashes as block absolute index is now different
should do a different way of loading blocks (key instead of index)
2020-01-09 08:17:41 -08:00
Kurt
3d581283c2 Minor clean
move Text.cs manual Courier new() to the designer, have it dispose when form is disposed. Set it as the numericupdown's font and just reuse that :)
2020-01-05 18:46:30 -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
f4bafe0809 Add extension methods for gym team get/set for all
Closes #2607

SAV6XY/AO had GymTeams get/set, this now makes similar logic accessible
for even SAV5BW/B2W2.
2019-12-28 22:32:45 -08:00
Kurt
be50abcc44 Add SubEventLog block object, etc
Adds gym team records, remove from savefile properties
update block list documentation
2019-12-28 21:53:58 -08:00
Kurt
0ce6254cee Add GymTeam records for Gen5 saves 2019-12-28 21:51:10 -08:00
Kurt
f65e0a96a7 repoint sav4 event constant reads
should work fine now
2019-12-27 18:30:39 -08:00
Kurt
9ee2b08ce5 Update rare flag logic
Closes #2601

Add ComponentModel attributes for properties, add u64 typeconverter for
propertygrid
2019-12-26 13:39:07 -08:00
Kurt
06348096aa Fix block de-referencing issue
SCBlock is an input to the individual save blocks; changing the SCBlock
byte[] reference won't change the individual save block reference. Just
copy the data and keep the original reference instead.

Repro: trainer data editor, save-close window, then delete a slot.
Export save; reload. Changes to box data were using old byte[]
reference, and didn't get repointed. Works fine with latest commit now.

I think I wanted to avoid copyto since it's slower than just a reference
change; but that didn't work out perfectly :)
2019-12-25 23:24:40 -08:00
Kurt
0a8c791e10 Pad with null terminators rather than 0
Can have a single digit (not forced to 3), so null terminate I assume.
2019-12-25 21:31:49 -08:00
Kurt
97c3c6b610 Add raid/den detail browser
Hold alt when hitting activate all to dump instead
I've seen DenType=5 Event=2 for at least one raid so far... not sure if
the event/rare properties are accurate.
2019-12-23 23:30:21 -08:00
Kurt
ce463d057a Add Pikachu Beach Score editing for YW saves
Closes #2585
2019-12-21 15:17:05 -08:00
Kurt
4bf71de621 Minor clean
automatically update total_watt if insufficient
SAV8 is not SAV8SWSH
#2583
2019-12-12 22:58:18 -08:00
Atzgi
d9c59666e0 Add watt in trainer data editor (#2583) 2019-12-12 16:27:01 -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
7b6d2bfa48 Fix trainerID trainer card write 2019-12-06 16:59:54 -08:00
Kurt
f07aed904d add missing pokedex offset spoof for gen3 saves
https://projectpokemon.org/home/forums/topic/55704-drag-drop-to-boxes-not-working-in-blank-gen-3-save/
ty ICanSnake
2019-12-05 23:08:01 -08:00
Kurt
65b921f806
Only apply 3DS geoloc data for 3DS blank saves
Closes #2560

Different logic in SimpleTrainerInfo applies it to <=Gen5, but that's fine... 414cb2d39e/PKHeX.Core/Legality/Structures/SimpleTrainerInfo.cs
2019-12-04 14:00:53 -08:00
Kurt
f45d730faf Add TrainerID for trainer card
Closes #2556
2019-12-03 19:54:34 -08:00
Kurt
e9b9141eda
Fix property name typo
efec331741 (r36246093)

ty @AnalogMan151
2019-12-03 10:39:57 -08:00
Frank
efec331741 add some customization options in MyStatus8 (#2552) 2019-12-02 13:40:09 -08:00
Kurt
89b4bc81b9 Update raid structure unknowns 2019-11-29 18:48:12 -08:00