Make some properties into consts

This commit is contained in:
Kurt 2021-03-20 12:47:21 -07:00
parent a71d7d1950
commit 8d3f990667
6 changed files with 28 additions and 30 deletions

View file

@ -119,8 +119,8 @@ namespace PKHeX.Core
{ {
return new() return new()
{ {
new SlotInfoMisc(sav.Data, 0, sav.GTS) {Type = StorageSlotType.GTS}, new SlotInfoMisc(sav.Data, 0, SAV6AO.GTS) {Type = StorageSlotType.GTS},
new SlotInfoMisc(sav.Data, 0, sav.Fused) {Type = StorageSlotType.Fused}, new SlotInfoMisc(sav.Data, 0, SAV6AO.Fused) {Type = StorageSlotType.Fused},
new SlotInfoMisc(sav.Data, 0, sav.GetBattleBoxSlot(0)) {Type = StorageSlotType.BattleBox}, new SlotInfoMisc(sav.Data, 0, sav.GetBattleBoxSlot(0)) {Type = StorageSlotType.BattleBox},
new SlotInfoMisc(sav.Data, 1, sav.GetBattleBoxSlot(1)) {Type = StorageSlotType.BattleBox}, new SlotInfoMisc(sav.Data, 1, sav.GetBattleBoxSlot(1)) {Type = StorageSlotType.BattleBox},

View file

@ -33,9 +33,6 @@ namespace PKHeX.Core
private void Initialize() private void Initialize()
{ {
GTS = 0x18200; // GtsData
Fused = 0x16A00; // UnionPokemon
PCLayout = 0x04400; PCLayout = 0x04400;
BattleBoxOffset = 0x04A00; BattleBoxOffset = 0x04A00;
PSS = 0x05000; PSS = 0x05000;
@ -46,23 +43,23 @@ namespace PKHeX.Core
DaycareOffset = 0x1BC00; DaycareOffset = 0x1BC00;
BerryField = 0x1C400; BerryField = 0x1C400;
WondercardFlags = 0x1CC00; WondercardFlags = 0x1CC00;
Contest = 0x23600;
SecretBase = 0x23A00;
EonTicket = 0x319B8;
Box = 0x33000; Box = 0x33000;
JPEG = 0x67C00; JPEG = 0x67C00;
EventFlag = EventConst + 0x2F0; EventFlag = EventConst + 0x2F0;
WondercardData = WondercardFlags + 0x100; WondercardData = WondercardFlags + 0x100;
Daycare2 = DaycareOffset + 0x1F0;
} }
public int EonTicket { get; private set; } /// <summary> Offset of the UnionPokemon block. </summary>
public int Contest { get; private set; } public const int Fused = 0x16A00;
private int Daycare2 { get; set; } /// <summary> Offset of the GtsData block. </summary>
public int SecretBase { get; private set; } public const int GTS = 0x18200;
public int GTS { get; private set; } /// <summary> Offset of the second daycare structure within the Daycare block. </summary>
public int Fused { get; private set; } private const int Daycare2 = 0x1BC00 + 0x1F0;
/// <summary> Offset of the Contest data block. </summary>
public const int Contest = 0x23600;
/// <summary> Offset of the Secret Base block. </summary>
public const int SecretBase = 0x23A00;
#region Blocks #region Blocks
public override IReadOnlyList<BlockInfo> AllBlocks => Blocks.BlockInfo; public override IReadOnlyList<BlockInfo> AllBlocks => Blocks.BlockInfo;

View file

@ -334,15 +334,16 @@ namespace PKHeX.Core
public void SetPartySlotAtIndex(PKM pkm, int index, PKMImportSetting trade = PKMImportSetting.UseDefault, PKMImportSetting dex = PKMImportSetting.UseDefault) public void SetPartySlotAtIndex(PKM pkm, int index, PKMImportSetting trade = PKMImportSetting.UseDefault, PKMImportSetting dex = PKMImportSetting.UseDefault)
{ {
// update party count // update party count
if (index <= -1) if ((uint)index > 5)
throw new ArgumentException("Invalid Party offset provided; unable to resolve party slot index."); throw new ArgumentOutOfRangeException(nameof(index));
int currentCount = PartyCount;
if (pkm.Species != 0) if (pkm.Species != 0)
{ {
if (PartyCount <= index) if (currentCount <= index)
PartyCount = index + 1; PartyCount = index + 1;
} }
else if (PartyCount > index) else if (currentCount > index)
{ {
PartyCount = index; PartyCount = index;
} }

View file

@ -20,7 +20,7 @@ namespace PKHeX.WinForms
for (int i = 0; i < lbl_spec.Length; i++) for (int i = 0; i < lbl_spec.Length; i++)
{ {
lbl_spec[i].Text = $"{GameInfo.Strings.pokeblocks[94 + i]}:"; lbl_spec[i].Text = $"{GameInfo.Strings.pokeblocks[94 + i]}:";
nup_spec[i].Value = BitConverter.ToUInt32(SAV.Data, SAV.Contest + (i * 4)); nup_spec[i].Value = BitConverter.ToUInt32(SAV.Data, SAV6AO.Contest + (i * 4));
} }
} }
@ -34,7 +34,7 @@ namespace PKHeX.WinForms
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
for (int i = 0; i < nup_spec.Length; i++) for (int i = 0; i < nup_spec.Length; i++)
BitConverter.GetBytes((uint)nup_spec[i].Value).CopyTo(SAV.Data, SAV.Contest + (i * 4)); BitConverter.GetBytes((uint)nup_spec[i].Value).CopyTo(SAV.Data, SAV6AO.Contest + (i * 4));
Origin.CopyChangesFrom(SAV); Origin.CopyChangesFrom(SAV);
Close(); Close();
} }

View file

@ -70,8 +70,8 @@ namespace PKHeX.WinForms
{ {
LB_Favorite.Items.Clear(); LB_Favorite.Items.Clear();
int playeroff = SAV.SecretBase + 0x326; int playeroff = SAV6AO.SecretBase + 0x326;
int favoff = SAV.SecretBase + 0x63A; int favoff = SAV6AO.SecretBase + 0x63A;
string OT = StringConverter.GetString6(SAV.Data, playeroff + 0x218, 0x1A); string OT = StringConverter.GetString6(SAV.Data, playeroff + 0x218, 0x1A);
LB_Favorite.Items.Add($"* {OT}"); LB_Favorite.Items.Add($"* {OT}");
for (int i = 0; i < 30; i++) for (int i = 0; i < 30; i++)
@ -153,11 +153,11 @@ namespace PKHeX.WinForms
{ {
// OR/AS: Secret base @ 0x23A00 // OR/AS: Secret base @ 0x23A00
if (index == 0) // Self, 0x314 bytes? Doesn't store pokemon data if (index == 0) // Self, 0x314 bytes? Doesn't store pokemon data
return SAV.SecretBase + 0x326; return SAV6AO.SecretBase + 0x326;
--index; --index;
// Received // Received
return SAV.SecretBase + 0x63A + (index * SecretBase6.SIZE); return SAV6AO.SecretBase + 0x63A + (index * SecretBase6.SIZE);
} }
private void B_FAV2SAV(object sender, EventArgs e) private void B_FAV2SAV(object sender, EventArgs e)
@ -224,7 +224,7 @@ namespace PKHeX.WinForms
{ {
uint flags = Util.ToUInt32(MT_Flags.Text); uint flags = Util.ToUInt32(MT_Flags.Text);
SAV.Records.SetRecord(080, (int)flags); SAV.Records.SetRecord(080, (int)flags);
Array.Copy(BitConverter.GetBytes(flags), 0, SAV.Data, SAV.SecretBase + 0x62C, 4); // write counter Array.Copy(BitConverter.GetBytes(flags), 0, SAV.Data, SAV6AO.SecretBase + 0x62C, 4); // write counter
Origin.CopyChangesFrom(SAV); Origin.CopyChangesFrom(SAV);
Close(); Close();
} }
@ -236,8 +236,8 @@ namespace PKHeX.WinForms
// int qty = BitConverter.ToUInt16(sav, offset + i * 4); // int qty = BitConverter.ToUInt16(sav, offset + i * 4);
// int has = BitConverter.ToUInt16(sav, offset + i * 4 + 2); // int has = BitConverter.ToUInt16(sav, offset + i * 4 + 2);
SAV.Data[SAV.SecretBase + (i * 4)] = 25; SAV.Data[SAV6AO.SecretBase + (i * 4)] = 25;
SAV.Data[SAV.SecretBase + (i * 4) + 2] = 1; SAV.Data[SAV6AO.SecretBase + (i * 4) + 2] = 1;
} }
} }
@ -518,7 +518,7 @@ namespace PKHeX.WinForms
if (LB_Favorite.SelectedIndex < 1) { WinFormsUtil.Alert("Cannot delete your Secret Base."); return; } if (LB_Favorite.SelectedIndex < 1) { WinFormsUtil.Alert("Cannot delete your Secret Base."); return; }
int index = LB_Favorite.SelectedIndex - 1; int index = LB_Favorite.SelectedIndex - 1;
int favoff = SAV.SecretBase + 0x63A; int favoff = SAV6AO.SecretBase + 0x63A;
string BaseTrainer = StringConverter.GetString6(SAV.Data, favoff + (index * 0x3E0) + 0x218, 0x1A); string BaseTrainer = StringConverter.GetString6(SAV.Data, favoff + (index * 0x3E0) + 0x218, 0x1A);
if (string.IsNullOrEmpty(BaseTrainer)) if (string.IsNullOrEmpty(BaseTrainer))
BaseTrainer = "Empty"; BaseTrainer = "Empty";