2016-10-20 01:19:01 +00:00
|
|
|
|
using System;
|
2020-08-18 22:39:45 +00:00
|
|
|
|
using System.Collections.Generic;
|
2017-07-02 02:43:51 +00:00
|
|
|
|
using System.Diagnostics;
|
2016-10-20 01:19:01 +00:00
|
|
|
|
|
2017-01-08 07:54:09 +00:00
|
|
|
|
namespace PKHeX.Core
|
2016-10-20 01:19:01 +00:00
|
|
|
|
{
|
2017-10-24 06:12:58 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generation 7 <see cref="SaveFile"/> object.
|
|
|
|
|
/// </summary>
|
2021-01-23 03:04:54 +00:00
|
|
|
|
public abstract class SAV7 : SAV_BEEF, ITrainerStatRecord, ISaveBlock7Main, IRegionOrigin, IGameSync
|
2016-10-20 01:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
// Save Data Attributes
|
2020-12-05 13:36:23 +00:00
|
|
|
|
protected internal override string ShortSummary => $"{OT} ({Version}) - {Played.LastSavedTime}";
|
2019-02-08 05:40:20 +00:00
|
|
|
|
public override string Extension => string.Empty;
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2021-08-06 05:39:38 +00:00
|
|
|
|
public override IReadOnlyList<string> PKMExtensions => Array.FindAll(PKM.Extensions, f =>
|
2017-01-05 06:22:50 +00:00
|
|
|
|
{
|
2021-07-27 06:33:56 +00:00
|
|
|
|
int gen = f[^1] - 0x30;
|
2019-02-10 04:33:37 +00:00
|
|
|
|
return gen <= 7 && f[1] != 'b'; // ignore PB7
|
2021-08-06 05:39:38 +00:00
|
|
|
|
});
|
2017-01-05 06:22:50 +00:00
|
|
|
|
|
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-17 01:47:31 +00:00
|
|
|
|
protected SAV7(byte[] data, int biOffset) : base(data, biOffset)
|
2016-10-20 01:19:01 +00:00
|
|
|
|
{
|
2019-06-09 02:56:11 +00:00
|
|
|
|
}
|
2016-10-20 01:19:01 +00:00
|
|
|
|
|
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-17 01:47:31 +00:00
|
|
|
|
protected SAV7(int size, int biOffset) : base(size, biOffset)
|
2019-06-09 02:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
2016-10-20 01:19:01 +00:00
|
|
|
|
|
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-17 01:47:31 +00:00
|
|
|
|
protected void ReloadBattleTeams()
|
2019-06-09 02:56:11 +00:00
|
|
|
|
{
|
2021-05-14 22:30:55 +00:00
|
|
|
|
var demo = this is SAV7SM && new ReadOnlySpan<byte>(Data, BoxLayout.Offset, 0x4C4).IsRangeEmpty(); // up to Battle Box values
|
2020-12-05 13:36:23 +00:00
|
|
|
|
if (demo || !State.Exportable)
|
2016-11-08 16:43:57 +00:00
|
|
|
|
{
|
2019-06-09 02:56:11 +00:00
|
|
|
|
BoxLayout.ClearBattleTeams();
|
2016-11-08 16:43:57 +00:00
|
|
|
|
}
|
2016-12-16 16:50:50 +00:00
|
|
|
|
else // Valid slot locking info present
|
2016-12-16 07:17:17 +00:00
|
|
|
|
{
|
2019-06-09 02:56:11 +00:00
|
|
|
|
BoxLayout.LoadBattleTeams();
|
2016-12-16 07:17:17 +00:00
|
|
|
|
}
|
2016-10-20 01:19:01 +00:00
|
|
|
|
}
|
2018-05-12 15:13:39 +00:00
|
|
|
|
|
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-17 01:47:31 +00:00
|
|
|
|
#region Blocks
|
|
|
|
|
public abstract MyItem Items { get; }
|
2019-10-19 03:42:03 +00:00
|
|
|
|
public abstract MysteryBlock7 MysteryGift { get; }
|
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-17 01:47:31 +00:00
|
|
|
|
public abstract PokeFinder7 PokeFinder { get; }
|
|
|
|
|
public abstract JoinFesta7 Festa { get; }
|
2019-10-19 03:42:03 +00:00
|
|
|
|
public abstract Daycare7 Daycare { get; }
|
|
|
|
|
public abstract RecordBlock6 Records { get; }
|
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-17 01:47:31 +00:00
|
|
|
|
public abstract PlayTime6 Played { get; }
|
|
|
|
|
public abstract MyStatus7 MyStatus { get; }
|
2019-10-19 03:42:03 +00:00
|
|
|
|
public abstract FieldMoveModelSave7 Overworld { get; }
|
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-17 01:47:31 +00:00
|
|
|
|
public abstract Situation7 Situation { get; }
|
|
|
|
|
public abstract ConfigSave7 Config { get; }
|
|
|
|
|
public abstract GameTime7 GameTime { get; }
|
2019-10-19 03:42:03 +00:00
|
|
|
|
public abstract Misc7 Misc { get; }
|
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-17 01:47:31 +00:00
|
|
|
|
public abstract Zukan7 Zukan { get; }
|
|
|
|
|
public abstract BoxLayout7 BoxLayout { get; }
|
2019-10-19 03:42:03 +00:00
|
|
|
|
public abstract BattleTree7 BattleTree { get; }
|
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-17 01:47:31 +00:00
|
|
|
|
public abstract ResortSave7 ResortSave { get; }
|
|
|
|
|
public abstract FieldMenu7 FieldMenu { get; }
|
2019-10-19 03:42:03 +00:00
|
|
|
|
public abstract FashionBlock7 Fashion { get; }
|
2021-04-07 07:20:02 +00:00
|
|
|
|
public abstract HallOfFame7 Fame { get; }
|
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-17 01:47:31 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
2016-10-20 01:19:01 +00:00
|
|
|
|
// Configuration
|
2020-08-07 23:16:10 +00:00
|
|
|
|
protected override int SIZE_STORED => PokeCrypto.SIZE_6STORED;
|
2020-01-04 22:48:39 +00:00
|
|
|
|
protected override int SIZE_PARTY => PokeCrypto.SIZE_6PARTY;
|
2016-10-20 01:19:01 +00:00
|
|
|
|
public override PKM BlankPKM => new PK7();
|
|
|
|
|
public override Type PKMType => typeof(PK7);
|
|
|
|
|
|
|
|
|
|
public override int BoxCount => 32;
|
|
|
|
|
public override int MaxEV => 252;
|
|
|
|
|
public override int Generation => 7;
|
2016-10-27 05:06:03 +00:00
|
|
|
|
protected override int GiftCountMax => 48;
|
|
|
|
|
protected override int GiftFlagMax => 0x100 * 8;
|
2017-11-13 05:28:34 +00:00
|
|
|
|
protected override int EventConstMax => 1000;
|
2016-10-20 01:19:01 +00:00
|
|
|
|
public override int OTLength => 12;
|
|
|
|
|
public override int NickLength => 12;
|
|
|
|
|
|
2017-01-27 03:18:20 +00:00
|
|
|
|
public override int MaxBallID => Legal.MaxBallID_7; // 26
|
|
|
|
|
public override int MaxGameID => Legal.MaxGameID_7;
|
2019-06-09 02:56:11 +00:00
|
|
|
|
protected override PKM GetPKM(byte[] data) => new PK7(data);
|
2020-01-04 22:48:39 +00:00
|
|
|
|
protected override byte[] DecryptPKM(byte[] data) => PokeCrypto.DecryptArray6(data);
|
2016-11-12 22:57:54 +00:00
|
|
|
|
|
2016-10-20 01:19:01 +00:00
|
|
|
|
// Feature Overrides
|
|
|
|
|
|
|
|
|
|
// Blocks & Offsets
|
2017-11-08 23:07:04 +00:00
|
|
|
|
private const int MemeCryptoBlock = 36;
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
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-17 01:47:31 +00:00
|
|
|
|
protected void ClearMemeCrypto()
|
2017-11-04 22:04:21 +00:00
|
|
|
|
{
|
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-17 01:47:31 +00:00
|
|
|
|
new byte[0x80].CopyTo(Data, AllBlocks[MemeCryptoBlock].Offset + 0x100);
|
2016-10-20 01:19:01 +00:00
|
|
|
|
}
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2019-06-09 02:56:11 +00:00
|
|
|
|
protected override byte[] GetFinalData()
|
2016-10-27 05:06:03 +00:00
|
|
|
|
{
|
2021-02-13 09:38:09 +00:00
|
|
|
|
BoxLayout.SaveBattleTeams();
|
2019-06-09 02:56:11 +00:00
|
|
|
|
SetChecksums();
|
|
|
|
|
var result = MemeCrypto.Resign7(Data);
|
|
|
|
|
Debug.Assert(result != Data);
|
|
|
|
|
return result;
|
2016-10-27 05:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-01-02 01:08:49 +00:00
|
|
|
|
public override GameVersion Version => Game switch
|
2016-10-20 01:19:01 +00:00
|
|
|
|
{
|
2021-01-02 01:08:49 +00:00
|
|
|
|
(int)GameVersion.SN => GameVersion.SN,
|
|
|
|
|
(int)GameVersion.MN => GameVersion.MN,
|
|
|
|
|
(int)GameVersion.US => GameVersion.US,
|
|
|
|
|
(int)GameVersion.UM => GameVersion.UM,
|
|
|
|
|
_ => GameVersion.Invalid
|
|
|
|
|
};
|
2018-05-12 15:13:39 +00:00
|
|
|
|
|
2019-06-09 02:56:11 +00:00
|
|
|
|
public override string GetString(byte[] data, int offset, int length) => StringConverter.GetString7(data, offset, length);
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2019-06-09 02:56:11 +00:00
|
|
|
|
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
2016-12-21 14:45:22 +00:00
|
|
|
|
{
|
2019-06-09 02:56:11 +00:00
|
|
|
|
if (PadToSize == 0)
|
|
|
|
|
PadToSize = maxLength + 1;
|
|
|
|
|
return StringConverter.SetString7(value, maxLength, Language, PadToSize, PadWith);
|
2016-12-21 14:45:22 +00:00
|
|
|
|
}
|
2016-10-20 01:19:01 +00:00
|
|
|
|
|
2019-06-09 02:56:11 +00:00
|
|
|
|
// Player Information
|
|
|
|
|
public override int TID { get => MyStatus.TID; set => MyStatus.TID = value; }
|
|
|
|
|
public override int SID { get => MyStatus.SID; set => MyStatus.SID = value; }
|
|
|
|
|
public override int Game { get => MyStatus.Game; set => MyStatus.Game = value; }
|
|
|
|
|
public override int Gender { get => MyStatus.Gender; set => MyStatus.Gender = value; }
|
2020-10-31 18:43:57 +00:00
|
|
|
|
public int GameSyncIDSize => MyStatus7.GameSyncIDSize; // 64 bits
|
|
|
|
|
public string GameSyncID { get => MyStatus.GameSyncID; set => MyStatus.GameSyncID = value; }
|
2021-08-03 02:43:57 +00:00
|
|
|
|
public byte Region { get => MyStatus.Region; set => MyStatus.Region = value; }
|
|
|
|
|
public byte Country { get => MyStatus.Country; set => MyStatus.Country = value; }
|
|
|
|
|
public byte ConsoleRegion { get => MyStatus.ConsoleRegion; set => MyStatus.ConsoleRegion = value; }
|
2019-06-09 02:56:11 +00:00
|
|
|
|
public override int Language { get => MyStatus.Language; set => MyStatus.Language = value; }
|
|
|
|
|
public override string OT { get => MyStatus.OT; set => MyStatus.OT = value; }
|
|
|
|
|
public override int MultiplayerSpriteID { get => MyStatus.MultiplayerSpriteID; set => MyStatus.MultiplayerSpriteID = value; }
|
2019-10-19 03:42:03 +00:00
|
|
|
|
public override uint Money { get => Misc.Money; set => Misc.Money = value; }
|
2019-09-03 02:30:58 +00:00
|
|
|
|
|
2019-06-09 02:56:11 +00:00
|
|
|
|
public override int PlayedHours { get => Played.PlayedHours; set => Played.PlayedHours = value; }
|
|
|
|
|
public override int PlayedMinutes { get => Played.PlayedMinutes; set => Played.PlayedMinutes = value; }
|
|
|
|
|
public override int PlayedSeconds { get => Played.PlayedSeconds; set => Played.PlayedSeconds = value; }
|
|
|
|
|
public override uint SecondsToStart { get => GameTime.SecondsToStart; set => GameTime.SecondsToStart = value; }
|
|
|
|
|
public override uint SecondsToFame { get => GameTime.SecondsToFame; set => GameTime.SecondsToFame = value; }
|
2016-11-11 12:13:23 +00:00
|
|
|
|
|
2016-12-30 08:30:54 +00:00
|
|
|
|
// Stat Records
|
2018-07-07 22:38:11 +00:00
|
|
|
|
public int RecordCount => 200;
|
2019-06-09 02:56:11 +00:00
|
|
|
|
public int GetRecord(int recordID) => Records.GetRecord(recordID);
|
|
|
|
|
public void SetRecord(int recordID, int value) => Records.SetRecord(recordID, value);
|
|
|
|
|
public int GetRecordMax(int recordID) => Records.GetRecordMax(recordID);
|
|
|
|
|
public int GetRecordOffset(int recordID) => Records.GetRecordOffset(recordID);
|
2016-11-29 07:02:25 +00:00
|
|
|
|
|
2016-10-20 01:19:01 +00:00
|
|
|
|
// Inventory
|
2020-12-05 14:09:33 +00:00
|
|
|
|
public override IReadOnlyList<InventoryPouch> Inventory { get => Items.Inventory; set => Items.Inventory = value; }
|
2016-11-15 05:40:31 +00:00
|
|
|
|
|
2016-10-20 01:19:01 +00:00
|
|
|
|
// Storage
|
2019-06-09 02:56:11 +00:00
|
|
|
|
public override int GetPartyOffset(int slot) => Party + (SIZE_PARTY * slot);
|
|
|
|
|
public override int GetBoxOffset(int box) => Box + (SIZE_STORED * box * 30);
|
|
|
|
|
protected override int GetBoxWallpaperOffset(int box) => BoxLayout.GetBoxWallpaperOffset(box);
|
|
|
|
|
public override int GetBoxWallpaper(int box) => BoxLayout.GetBoxWallpaper(box);
|
|
|
|
|
public override void SetBoxWallpaper(int box, int value) => BoxLayout.SetBoxWallpaper(box, value);
|
|
|
|
|
public override string GetBoxName(int box) => BoxLayout[box];
|
|
|
|
|
public override void SetBoxName(int box, string value) => BoxLayout[box] = value;
|
|
|
|
|
public override int CurrentBox { get => BoxLayout.CurrentBox; set => BoxLayout.CurrentBox = value; }
|
|
|
|
|
public override int BoxesUnlocked { get => BoxLayout.BoxesUnlocked; set => BoxLayout.BoxesUnlocked = value; }
|
2019-09-03 02:30:58 +00:00
|
|
|
|
public override byte[] BoxFlags { get => BoxLayout.BoxFlags; set => BoxLayout.BoxFlags = value; }
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2021-02-09 04:26:53 +00:00
|
|
|
|
protected override void SetPKM(PKM pkm, bool isParty = false)
|
2016-10-20 01:19:01 +00:00
|
|
|
|
{
|
2017-12-12 00:01:24 +00:00
|
|
|
|
PK7 pk7 = (PK7)pkm;
|
2016-10-20 01:19:01 +00:00
|
|
|
|
// Apply to this Save File
|
|
|
|
|
int CT = pk7.CurrentHandler;
|
|
|
|
|
DateTime Date = DateTime.Now;
|
2019-03-31 05:05:28 +00:00
|
|
|
|
pk7.Trade(this, Date.Day, Date.Month, Date.Year);
|
2016-10-20 01:19:01 +00:00
|
|
|
|
if (CT != pk7.CurrentHandler) // Logic updated Friendship
|
|
|
|
|
{
|
|
|
|
|
// Copy over the Friendship Value only under certain circumstances
|
2020-08-18 22:39:45 +00:00
|
|
|
|
if (pk7.HasMove(216)) // Return
|
2016-10-20 01:19:01 +00:00
|
|
|
|
pk7.CurrentFriendship = pk7.OppositeFriendship;
|
2020-08-18 22:39:45 +00:00
|
|
|
|
else if (pk7.HasMove(218)) // Frustration
|
2016-10-20 01:19:01 +00:00
|
|
|
|
pkm.CurrentFriendship = pk7.OppositeFriendship;
|
|
|
|
|
}
|
2021-02-09 04:26:53 +00:00
|
|
|
|
|
|
|
|
|
pk7.FormArgumentElapsed = pk7.FormArgumentMaximum = 0;
|
|
|
|
|
pk7.FormArgumentRemain = (byte)GetFormArgument(pkm);
|
|
|
|
|
|
2016-10-20 01:19:01 +00:00
|
|
|
|
pkm.RefreshChecksum();
|
2019-06-09 02:56:11 +00:00
|
|
|
|
AddCountAcquired(pkm);
|
2018-09-28 04:30:20 +00:00
|
|
|
|
}
|
2018-09-27 02:06:05 +00:00
|
|
|
|
|
2018-09-28 04:30:20 +00:00
|
|
|
|
private void AddCountAcquired(PKM pkm)
|
|
|
|
|
{
|
2019-06-09 02:56:11 +00:00
|
|
|
|
Records.AddRecord(pkm.WasEgg ? 008 : 006); // egg, capture
|
2018-09-27 02:06:05 +00:00
|
|
|
|
if (pkm.CurrentHandler == 1)
|
2019-06-09 02:56:11 +00:00
|
|
|
|
Records.AddRecord(011); // trade
|
2018-11-27 16:53:56 +00:00
|
|
|
|
if (!pkm.WasEgg)
|
2021-02-24 16:12:59 +00:00
|
|
|
|
{
|
2019-06-09 02:56:11 +00:00
|
|
|
|
Records.AddRecord(004); // wild encounters
|
2021-02-24 16:12:59 +00:00
|
|
|
|
Records.AddRecord(042); // balls used
|
|
|
|
|
}
|
2016-11-08 16:43:57 +00:00
|
|
|
|
}
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2020-02-14 00:35:37 +00:00
|
|
|
|
private static uint GetFormArgument(PKM pkm)
|
2018-07-21 03:25:28 +00:00
|
|
|
|
{
|
2020-12-11 04:42:30 +00:00
|
|
|
|
if (pkm.Form == 0)
|
2018-07-21 03:25:28 +00:00
|
|
|
|
return 0;
|
2020-02-14 00:35:37 +00:00
|
|
|
|
// Gen7 allows forms to be stored in the box with the current duration & form
|
|
|
|
|
// Just cap out the form duration anyways
|
2019-10-08 01:40:09 +00:00
|
|
|
|
return pkm.Species switch
|
2018-07-21 03:25:28 +00:00
|
|
|
|
{
|
2019-10-08 01:40:09 +00:00
|
|
|
|
(int)Species.Furfrou => 5u, // Furfrou
|
|
|
|
|
(int)Species.Hoopa => 3u, // Hoopa
|
|
|
|
|
_ => 0u
|
|
|
|
|
};
|
2017-06-07 05:13:12 +00:00
|
|
|
|
}
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2019-06-09 02:56:11 +00:00
|
|
|
|
protected override void SetDex(PKM pkm) => Zukan.SetDex(pkm);
|
|
|
|
|
public override bool GetCaught(int species) => Zukan.GetCaught(species);
|
|
|
|
|
public override bool GetSeen(int species) => Zukan.GetSeen(species);
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2016-10-20 01:19:01 +00:00
|
|
|
|
public override int PartyCount
|
|
|
|
|
{
|
2018-09-15 05:37:47 +00:00
|
|
|
|
get => Data[Party + (6 * SIZE_PARTY)];
|
|
|
|
|
protected set => Data[Party + (6 * SIZE_PARTY)] = (byte)value;
|
2016-10-20 01:19:01 +00:00
|
|
|
|
}
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2018-12-05 06:59:28 +00:00
|
|
|
|
public override StorageSlotFlag GetSlotFlags(int index)
|
|
|
|
|
{
|
|
|
|
|
int team = Array.IndexOf(TeamSlots, index);
|
|
|
|
|
if (team < 0)
|
|
|
|
|
return StorageSlotFlag.None;
|
2017-10-31 16:24:54 +00:00
|
|
|
|
|
2018-12-05 06:59:28 +00:00
|
|
|
|
team /= 6;
|
|
|
|
|
var val = (StorageSlotFlag)((int)StorageSlotFlag.BattleTeam1 << team);
|
2019-06-09 02:56:11 +00:00
|
|
|
|
if (BoxLayout.GetIsTeamLocked(team))
|
2018-12-05 06:59:28 +00:00
|
|
|
|
val |= StorageSlotFlag.Locked;
|
|
|
|
|
return val;
|
2017-10-31 16:24:54 +00:00
|
|
|
|
}
|
2016-10-29 18:32:21 +00:00
|
|
|
|
|
2019-07-14 22:06:45 +00:00
|
|
|
|
private int FusedCount => this is SAV7USUM ? 3 : 1;
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2017-11-13 05:28:34 +00:00
|
|
|
|
public int GetFusedSlotOffset(int slot)
|
|
|
|
|
{
|
2019-09-12 05:17:16 +00:00
|
|
|
|
if ((uint)slot >= FusedCount)
|
2017-11-13 05:28:34 +00:00
|
|
|
|
return -1;
|
2020-01-04 22:48:39 +00:00
|
|
|
|
return AllBlocks[08].Offset + (PokeCrypto.SIZE_6PARTY * slot); // 0x104*slot
|
2017-11-13 05:28:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-09 02:56:11 +00:00
|
|
|
|
public override int DaycareSeedSize => Daycare7.DaycareSeedSize; // 128 bits
|
2019-10-19 03:42:03 +00:00
|
|
|
|
public override int GetDaycareSlotOffset(int loc, int slot) => Daycare.GetDaycareSlotOffset(slot);
|
|
|
|
|
public override bool? IsDaycareOccupied(int loc, int slot) => Daycare.GetIsOccupied(slot);
|
|
|
|
|
public override string GetDaycareRNGSeed(int loc) => Daycare.RNGSeed;
|
|
|
|
|
public override bool? IsDaycareHasEgg(int loc) => Daycare.HasEgg;
|
|
|
|
|
public override void SetDaycareOccupied(int loc, int slot, bool occupied) => Daycare.SetOccupied(slot, occupied);
|
|
|
|
|
public override void SetDaycareRNGSeed(int loc, string seed) => Daycare.RNGSeed = seed;
|
|
|
|
|
public override void SetDaycareHasEgg(int loc, bool hasEgg) => Daycare.HasEgg = hasEgg;
|
|
|
|
|
|
|
|
|
|
protected override bool[] MysteryGiftReceivedFlags { get => MysteryGift.MysteryGiftReceivedFlags; set => MysteryGift.MysteryGiftReceivedFlags = value; }
|
|
|
|
|
protected override DataMysteryGift[] MysteryGiftCards { get => MysteryGift.MysteryGiftCards; set => MysteryGift.MysteryGiftCards = value; }
|
2016-10-20 01:19:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|