2019-11-16 01:34:18 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
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
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
2019-09-23 23:56:47 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generation 8 <see cref="SaveFile"/> object for <see cref="GameVersion.SWSH"/> games.
|
|
|
|
|
/// </summary>
|
2022-02-05 01:35:15 +00:00
|
|
|
|
public sealed class SAV8SWSH : SAV8, ISaveBlock8SWSH, ITrainerStatRecord, ISaveFileRevision, ISCBlockArray
|
2019-09-23 23:56:47 +00:00
|
|
|
|
{
|
2021-06-04 20:16:00 +00:00
|
|
|
|
public SAV8SWSH(byte[] data) : base(data)
|
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
|
|
|
|
{
|
2021-06-04 20:16:00 +00:00
|
|
|
|
Data = Array.Empty<byte>();
|
|
|
|
|
AllBlocks = SwishCrypto.Decrypt(data);
|
|
|
|
|
Blocks = new SaveBlockAccessor8SWSH(this);
|
|
|
|
|
SaveRevision = Zukan.GetRevision();
|
|
|
|
|
Initialize();
|
2019-11-16 01:34:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private SAV8SWSH(byte[] data, IReadOnlyList<SCBlock> blocks) : base(data)
|
|
|
|
|
{
|
|
|
|
|
Data = Array.Empty<byte>();
|
|
|
|
|
AllBlocks = blocks;
|
2020-01-24 07:22:54 +00:00
|
|
|
|
Blocks = new SaveBlockAccessor8SWSH(this);
|
2020-09-26 06:41:20 +00:00
|
|
|
|
SaveRevision = Zukan.GetRevision();
|
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
|
|
|
|
Initialize();
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-16 01:34:18 +00:00
|
|
|
|
public SAV8SWSH()
|
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
|
|
|
|
{
|
2019-11-16 01:34:18 +00:00
|
|
|
|
AllBlocks = Meta8.GetBlankDataSWSH();
|
2020-01-24 07:22:54 +00:00
|
|
|
|
Blocks = new SaveBlockAccessor8SWSH(this);
|
2020-09-26 06:41:20 +00:00
|
|
|
|
SaveRevision = Zukan.GetRevision();
|
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
|
|
|
|
Initialize();
|
2019-11-16 01:34:18 +00:00
|
|
|
|
ClearBoxes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void CopyChangesFrom(SaveFile sav)
|
|
|
|
|
{
|
|
|
|
|
// Absorb changes from all blocks
|
|
|
|
|
var z = (SAV8SWSH)sav;
|
|
|
|
|
var mine = AllBlocks;
|
|
|
|
|
var newB = z.AllBlocks;
|
|
|
|
|
for (int i = 0; i < mine.Count; i++)
|
2019-12-26 07:24:40 +00:00
|
|
|
|
newB[i].Data.CopyTo(mine[i].Data, 0);
|
2020-12-05 13:36:23 +00:00
|
|
|
|
State.Edited = true;
|
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
|
|
|
|
}
|
2019-09-23 23:56:47 +00:00
|
|
|
|
|
2020-09-26 06:41:20 +00:00
|
|
|
|
public int SaveRevision { get; }
|
|
|
|
|
|
|
|
|
|
public string SaveRevisionString => SaveRevision switch
|
|
|
|
|
{
|
|
|
|
|
0 => "-Base", // Vanilla
|
|
|
|
|
1 => "-IoA", // DLC 1: Isle of Armor
|
|
|
|
|
2 => "-CT", // DLC 2: Crown Tundra
|
|
|
|
|
_ => throw new ArgumentOutOfRangeException(nameof(SaveRevision)),
|
|
|
|
|
};
|
|
|
|
|
|
2019-11-16 01:34:18 +00:00
|
|
|
|
public IReadOnlyList<SCBlock> AllBlocks { get; }
|
|
|
|
|
public override bool ChecksumsValid => true;
|
|
|
|
|
public override string ChecksumInfo => string.Empty;
|
|
|
|
|
protected override void SetChecksums() { } // None!
|
|
|
|
|
protected override byte[] GetFinalData() => SwishCrypto.Encrypt(AllBlocks);
|
|
|
|
|
|
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 override PersonalTable Personal => PersonalTable.SWSH;
|
|
|
|
|
public override IReadOnlyList<ushort> HeldItems => Legal.HeldItems_SWSH;
|
|
|
|
|
|
|
|
|
|
#region Blocks
|
2022-02-05 01:35:15 +00:00
|
|
|
|
public SCBlockAccessor Accessor => Blocks;
|
2020-01-24 07:22:54 +00:00
|
|
|
|
public SaveBlockAccessor8SWSH Blocks { get; }
|
2019-11-16 01:34:18 +00:00
|
|
|
|
public override Box8 BoxInfo => Blocks.BoxInfo;
|
|
|
|
|
public override Party8 PartyInfo => Blocks.PartyInfo;
|
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 override MyItem Items => Blocks.Items;
|
|
|
|
|
public override MyStatus8 MyStatus => Blocks.MyStatus;
|
2019-10-19 03:42:03 +00:00
|
|
|
|
public override Misc8 Misc => Blocks.Misc;
|
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 override Zukan8 Zukan => Blocks.Zukan;
|
|
|
|
|
public override BoxLayout8 BoxLayout => Blocks.BoxLayout;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
public override PlayTime8 Played => Blocks.Played;
|
|
|
|
|
public override Fused8 Fused => Blocks.Fused;
|
|
|
|
|
public override Daycare8 Daycare => Blocks.Daycare;
|
|
|
|
|
public override Record8 Records => Blocks.Records;
|
2019-11-19 01:57:33 +00:00
|
|
|
|
public override TrainerCard8 TrainerCard => Blocks.TrainerCard;
|
2020-01-22 07:23:27 +00:00
|
|
|
|
public override RaidSpawnList8 Raid => Blocks.Raid;
|
2020-06-19 23:51:15 +00:00
|
|
|
|
public override RaidSpawnList8 RaidArmor => Blocks.RaidArmor;
|
2020-10-24 18:09:29 +00:00
|
|
|
|
public override RaidSpawnList8 RaidCrown => Blocks.RaidCrown;
|
2020-01-22 07:23:27 +00:00
|
|
|
|
public override TitleScreen8 TitleScreen => Blocks.TitleScreen;
|
2020-02-02 02:56:23 +00:00
|
|
|
|
public override TeamIndexes8 TeamIndexes => Blocks.TeamIndexes;
|
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
|
|
|
|
|
2020-03-11 23:31:53 +00:00
|
|
|
|
public T GetValue<T>(uint key) where T : struct
|
2020-03-11 06:18:51 +00:00
|
|
|
|
{
|
2020-12-05 13:36:23 +00:00
|
|
|
|
if (!State.Exportable)
|
2020-03-11 23:31:53 +00:00
|
|
|
|
return default;
|
|
|
|
|
var value = Blocks.GetBlockValue(key);
|
|
|
|
|
if (value is T v)
|
|
|
|
|
return v;
|
|
|
|
|
throw new ArgumentException($"Incorrect type request! Expected {typeof(T).Name}, received {value.GetType().Name}", nameof(T));
|
2020-03-11 06:18:51 +00:00
|
|
|
|
}
|
2020-01-19 18:25:40 +00:00
|
|
|
|
|
2020-03-11 23:31:53 +00:00
|
|
|
|
public void SetValue<T>(uint key, T value) where T : struct
|
2020-01-19 18:25:40 +00:00
|
|
|
|
{
|
2020-12-05 13:36:23 +00:00
|
|
|
|
if (!State.Exportable)
|
2020-01-19 18:25:40 +00:00
|
|
|
|
return;
|
|
|
|
|
Blocks.SetBlockValue(key, value);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
2021-06-04 20:16:00 +00:00
|
|
|
|
protected override SaveFile CloneInternal()
|
|
|
|
|
{
|
|
|
|
|
var blockCopy = new SCBlock[AllBlocks.Count];
|
|
|
|
|
for (int i = 0; i < AllBlocks.Count; i++)
|
|
|
|
|
blockCopy[i] = AllBlocks[i].Clone();
|
|
|
|
|
return new SAV8SWSH(State.BAK, blockCopy);
|
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
|
2020-06-19 23:51:15 +00:00
|
|
|
|
private int m_spec, m_item, m_move, m_abil;
|
|
|
|
|
public override int MaxMoveID => m_move;
|
|
|
|
|
public override int MaxSpeciesID => m_spec;
|
|
|
|
|
public override int MaxItemID => m_item;
|
2019-09-23 23:56:47 +00:00
|
|
|
|
public override int MaxBallID => Legal.MaxBallID_8;
|
|
|
|
|
public override int MaxGameID => Legal.MaxGameID_8;
|
2020-06-19 23:51:15 +00:00
|
|
|
|
public override int MaxAbilityID => m_abil;
|
2019-09-23 23:56:47 +00:00
|
|
|
|
|
|
|
|
|
private void Initialize()
|
|
|
|
|
{
|
2019-11-16 01:34:18 +00:00
|
|
|
|
Box = 0;
|
|
|
|
|
Party = 0;
|
|
|
|
|
PokeDex = 0;
|
2020-02-02 02:56:23 +00:00
|
|
|
|
TeamIndexes.LoadBattleTeams();
|
2020-06-19 23:51:15 +00:00
|
|
|
|
|
2020-09-26 06:41:20 +00:00
|
|
|
|
int rev = SaveRevision;
|
2020-06-19 23:51:15 +00:00
|
|
|
|
if (rev == 0)
|
|
|
|
|
{
|
|
|
|
|
m_move = Legal.MaxMoveID_8_O0;
|
|
|
|
|
m_spec = Legal.MaxSpeciesID_8_O0;
|
|
|
|
|
m_item = Legal.MaxItemID_8_O0;
|
|
|
|
|
m_abil = Legal.MaxAbilityID_8_O0;
|
|
|
|
|
}
|
2020-10-10 20:14:32 +00:00
|
|
|
|
else if (rev == 1)
|
2020-06-19 23:51:15 +00:00
|
|
|
|
{
|
|
|
|
|
m_move = Legal.MaxMoveID_8_R1;
|
|
|
|
|
m_spec = Legal.MaxSpeciesID_8_R1;
|
|
|
|
|
m_item = Legal.MaxItemID_8_R1;
|
|
|
|
|
m_abil = Legal.MaxAbilityID_8_R1;
|
|
|
|
|
}
|
2020-10-10 20:14:32 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_move = Legal.MaxMoveID_8_R2;
|
|
|
|
|
m_spec = Legal.MaxSpeciesID_8_R2;
|
|
|
|
|
m_item = Legal.MaxItemID_8_R2;
|
|
|
|
|
m_abil = Legal.MaxAbilityID_8_R2;
|
|
|
|
|
}
|
2019-11-16 01:34:18 +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);
|
|
|
|
|
public int RecordCount => Record8.RecordCount;
|
2020-02-02 02:56:23 +00:00
|
|
|
|
|
|
|
|
|
public override StorageSlotFlag GetSlotFlags(int index)
|
|
|
|
|
{
|
|
|
|
|
int team = Array.IndexOf(TeamIndexes.TeamSlots, index);
|
|
|
|
|
if (team < 0)
|
|
|
|
|
return StorageSlotFlag.None;
|
|
|
|
|
|
|
|
|
|
team /= 6;
|
2022-01-03 05:35:59 +00:00
|
|
|
|
var result = (StorageSlotFlag)((int)StorageSlotFlag.BattleTeam1 << team);
|
2020-02-02 02:56:23 +00:00
|
|
|
|
if (TeamIndexes.GetIsTeamLocked(team))
|
2022-01-03 05:35:59 +00:00
|
|
|
|
result |= StorageSlotFlag.Locked;
|
|
|
|
|
return result;
|
2020-02-02 02:56:23 +00:00
|
|
|
|
}
|
2020-03-11 06:18:51 +00:00
|
|
|
|
|
|
|
|
|
public override int CurrentBox { get => BoxLayout.CurrentBox; set => BoxLayout.CurrentBox = value; }
|
2021-03-03 05:28:53 +00:00
|
|
|
|
public override int BoxesUnlocked { get => (byte)Blocks.GetBlockValue(SaveBlockAccessor8SWSH.KBoxesUnlocked); set => Blocks.SetBlockValue(SaveBlockAccessor8SWSH.KBoxesUnlocked, (byte)value); }
|
|
|
|
|
|
|
|
|
|
public override byte[] BoxFlags
|
|
|
|
|
{
|
|
|
|
|
get => new [] {Convert.ToByte(Blocks.GetBlock(SaveBlockAccessor8SWSH.KSecretBoxUnlocked).Type - 1)};
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value.Length != 1)
|
|
|
|
|
return;
|
2021-06-03 19:35:39 +00:00
|
|
|
|
var block = Blocks.GetBlock(SaveBlockAccessor8SWSH.KSecretBoxUnlocked);
|
|
|
|
|
block.ChangeBooleanType((SCTypeCode)(value[0] & 1) + 1);
|
2021-03-03 05:28:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-16 21:50:41 +00:00
|
|
|
|
|
|
|
|
|
public override bool HasBoxWallpapers => true;
|
|
|
|
|
public override bool HasNamableBoxes => true;
|
|
|
|
|
|
|
|
|
|
public override int GetBoxWallpaper(int box)
|
|
|
|
|
{
|
|
|
|
|
if ((uint)box >= BoxCount)
|
|
|
|
|
return box;
|
|
|
|
|
var b = Blocks.GetBlock(SaveBlockAccessor8SWSH.KBoxWallpapers);
|
|
|
|
|
return b.Data[box];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void SetBoxWallpaper(int box, int value)
|
|
|
|
|
{
|
|
|
|
|
if ((uint)box >= BoxCount)
|
|
|
|
|
return;
|
|
|
|
|
var b = Blocks.GetBlock(SaveBlockAccessor8SWSH.KBoxWallpapers);
|
|
|
|
|
b.Data[box] = (byte)value;
|
|
|
|
|
}
|
2019-09-23 23:56:47 +00:00
|
|
|
|
}
|
2020-04-16 21:50:41 +00:00
|
|
|
|
}
|