Commit graph

73 commits

Author SHA1 Message Date
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
d3b0c392b2 Minor tweaks
no functional change
2019-10-03 22:21:33 -07:00
Kurt
8d8adde2b1 sealed
sealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealedsealed
2019-10-03 19:09:02 -07:00
Kurt
b81a1e1e29 Refactoring
Increase abstraction for arbitrary slot get/set operations, and fracture
SAV4 behavior for each game type.

Adds: Undo/Redo of party slot changes
Fixes: Fixed Gen5 daycare slot 2 reading, and EXP reading
Fixes: Some slot color glitchiness
Fixed: Box layout editor now hides the flag label if no flags are
present
Fixed: Gen7 box flags are now shown (unknown purpose lol)
Changed: savefile objects are generally smaller (removed a few shared
offset fields)
2019-09-02 19:30:58 -07:00
Kurt
9c58903f55 Fix blank sav3 : sapphire init
lol it's been this way for 7+mo
Closes #2369 ty @CorvusAtrox !
2019-08-04 00:59:59 -07:00
Kurt
a608e0b252 Minor clean
Remove some unnecessary properties from SaveFile
Enumerate checksum flag results for GC memcard checking
Remove unnecessary checks on savefile type
Add some documentation
Decapitalize some method parameters
2019-07-14 15:06:45 -07:00
Kurt
1b028198ad
Split gen5-7 saves with inheritance (#2319)
refer to pull request comments for summary
2019-06-08 19:56:11 -07:00
Kurt
2b8ef9236a use some explicit dex numbers as enum 2019-06-01 10:22:49 -07:00
Kurt
0dc45c00ec Check block index before calculating
Missing/Duplicate blocks (???) result in -1, so skip them.

https://projectpokemon.org/home/forums/topic/52437-cant-export-unmodified-sav-file/

replace linq with manual allocation
2019-04-27 17:19:54 -07:00
Kurt
609db23dc5 Consolidate pouch load/set 2019-03-30 16:10:14 -07:00
Kurt
bb8cf5d3d8 Simplify get/decrypt pkm access 2019-03-29 19:43:33 -07:00
Kurt
4650a6f5b5 Reduce sizes 2019-03-22 21:19:47 -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
13a6d16cb9 Relocate checksum/dexform logic 2019-03-16 12:01:21 -07:00
Kurt
ee787a0f71 Fix HoF size check
now matches the code in ChecksumsValid (< instead of <=)
2019-03-07 15:45:51 -08:00
Kurt
bb2c7e22cb Add HoF checksum verification and saving
Thanks @av🥑cado#0315 (discord)
2019-03-02 09:16:03 -08:00
Kurt
40963c012a Add sav3 BP Earned editing
misc editor, first tab (main)
2019-02-19 20:59:47 -08:00
Kurt
fa4318ae2f Add gen3 record editing
in misc edits window
2019-02-19 20:46:58 -08:00
Kurt
fb8aa3bba0 Lowercase parameter 2019-02-19 20:26:20 -08:00
Kurt
a385a8481d Misc tweak to savefile export
Use flags to request header/footer in the output
gets rid of the DSV/GCI bool arguments
2019-02-18 21:59:57 -08:00
Kurt
f481404503 Misc clean 2019-02-02 10:19:41 -08:00
Kurt
7bb3f14e1f Add wishmkr flag fetch
rs only
thx @PMArkive !
2019-01-22 22:28:30 -08:00
ShadowMario3
3f759058ce Update SAV3.cs (#2247)
Fix PC max item count in RSE
2019-01-16 12:13:58 -08:00
Kurt
53b2ca93b8 Update blank sav3 behavior
can now be selected & loaded without exception/hassle
2019-01-15 22:14:19 -08:00
Kurt
8c05b9f391 add g3 hall of fame r/w
no GUI

var sav3 = new SAV3(File.ReadAllBytes(path));
var hof = HallFame3Entry.GetEntries(sav3);
hof.Dump();
2019-01-02 18:15:29 -08:00
Kurt
d7a501c168 Relocate some logic to interfaces 2018-12-18 17:15:35 -08:00
Kurt
4c1232855f Add getstring method with non-sav data 2018-12-04 22:00:57 -08:00
Kurt
2a2361220d Add more accurate daycare egg detection
uses eventflag, different index for each game

frlg:
https://www.pokecommunity.com/showthread.php?t=302347
"Flag 0x266 is set by the game engine if an Egg is in the Daycare."

emerald:
https://www.pokecommunity.com/showthread.php?t=330008
"0x86 : Daycare Centre has egg"

rs:
https://gist.github.com/rboninsegna/a4a63c2b66c42e371a94f860eae55361
" 0x86  Egg ready at Daycare"
2018-09-30 21:27:36 -07:00
Kurt
ca0a533779 Add frlg flag toggles from thread 2018-09-27 20:01:34 -07:00
Kurt
10d73d1bf3 Redirect eventflag r/w for frlg
can't just re-call base.SetEventFlag with an adjusted flag ID since the
exception checks max.
just override the geteventflag method with a silly adjustment -- we
can't be sure if Block2 is immediately after Block2, so just adjust the
flag r/w to a different offset&flag when appropriate.

fixes r/s badgeflag get/set, oops, meant to modify FRLG's value in the
last commit.
2018-09-26 21:05:06 -07:00
Kurt
a38a0fed60 Update event flag index for frlg
was block2+0x64
8*((0xF80-0xEE0)+0x64) = 0x820

this highlights a critical flaw in event flag reading; it expects the
region to be contiguous in the savedata. it's not. that's super bad, and
event flag r/w for flags >1280 won't work until I work something out
2018-09-26 20:32:38 -07:00
Kurt
62d8abb69c Update frlg flag/var offset
https://www.pokecommunity.com/showthread.php?t=349936

https://projectpokemon.org/home/forums/topic/47715-help-frlg-flags-research/
2018-09-26 20:08:25 -07:00
Kurt
39c3a0eea7 Rework sav3 version detect
Might still be flaky for FRLG, but can now (99.99999999%) determine RS
vs E...
2018-09-16 13:57:09 -07:00
Kurt
668b8611d5 Fix sav3 active partition detect logic
change < to >
the lower updated count is the backup partition, not the one to load
from

Closes #2122 , thanks @FaronBracy !
2018-09-16 12:49:00 -07:00
Kurt
b280ffcfef style updates
should be pretty much it
2018-09-14 22:37:47 -07:00
Kurt
493bef75eb Misc updates
condense repeated logic
extract properties
extract reusable methods
2018-09-02 18:02:25 -07:00
Kurt
02a6d26e1b Break apart BAKName into smaller components
simplifies definition & makes it easier to update bakname usage later
2018-07-29 21:51:45 -07:00
Kurt
b16015e8e5 Split InventoryPouch to inheriting classes 2018-07-29 13:55:07 -07:00
Kurt
0c5c9bc33c Misc clean / xmldoc updates
remove unused label in QR (use window Font)
escape & -> &amp; for xmldoc proper style
2018-07-21 19:20:11 -07:00
Kurt
ebed1026cd Update national dex magic setting
bulbapedia is wrong, first 4 bytes are info values:

0x0 = dex order (alphabetical, numerical), unused in frlg
0x1 = mode (unused in frlg), regional vs national
0x2 = national magic rse (always set in frlg)
0x3 = national magic frlg (never set in rse)

refer to disassembly (pokefirered isn't too helpful, less developed.
just compare save files & edit ram!)
the other 2 values being set are the eventflag & event const, could use
the abstraction for those rather than direct ofs writes
2018-07-12 23:23:36 -07:00
Kurt
d42cc7cacd Add spinda/unown PID properties 2018-07-12 22:07:44 -07:00
Kurt
1e8dd3c823 Add gen3 daycare offsets
idc about frlg single mon daycare
2018-07-08 11:00:50 -07:00
Kurt
373b4ffcbb Add block offset fetch util
according to the disassembly it all makes more sense; a small block and
a large block are stored in RAM

util calc helps convert between contiguous section offset to a chunked
offset

eg: emerald daycare starts at large 0x3030, which converts to
chunk4@0x1B0
2018-07-08 09:56:01 -07:00
Kurt
0b1ae2ec67 Add pokeblock3 interaction
no gui but can use core with a rse save file
2018-07-07 21:31:41 -07:00
Kurt
ae04218c5f Update eventflagmax for e/frlg
globals.h defines as 288 bytes for RS, and 300 for E & FR respectively

verified event const vals for Emerald making sense
2018-07-07 18:03:52 -07:00
Kurt
d4c1093dd9 Add RS badge flags
make logic generic
2018-07-07 17:01:47 -07:00
Kurt
e2f11edc43 Refactoring
discards, Array.Find over FirstOrDefault
2018-05-12 08:41:29 -07:00
Kurt
5a3c8f4147 Remove trailing whitespace 2018-05-12 08:41:29 -07:00
Kurt
7ce89f0e16 Fix frlg inventory encryptionkey offset
72af1f7880/include/global.h (L219)

0xAF8 is berry powder! Thanks HaiPhuong!
2018-05-11 19:55:40 -07:00
Kurt
71faaee31c Refactor savefile tid/sid to int
can now use TrainerID editor control on a savefile... soon?
2018-04-28 11:06:58 -07:00