Misc tweaks

Add bulkstorage SaveFile template
remove unused using
un-virtual box property (don't override behavior)
Split new-USUM island names (unused)
Remove island names from valid egg locations (thanks Davil !)

https://projectpokemon.org/home/forums/topic/43874-bug-met-location/?tab=comments#comment-227684
This commit is contained in:
Kurt
2018-02-15 17:05:45 -08:00
parent 89248b30a9
commit f8bf3e400b
6 changed files with 77 additions and 8 deletions

View File

@@ -237,6 +237,7 @@ private void SanitizeMetLocations()
if (i > 0 && !string.IsNullOrWhiteSpace(metSM_00000_good[i]) && metSM_00000_good.Take(i - 1).Contains(metSM_00000_good[i]))
metSM_00000_good[i] += $" ({metSM_00000_good.Take(i - 1).Count(s => s == metSM_00000_good[i]) + 1})";
}
Array.Copy(metSM_00000, 194, metSM_00000_good, 194, 4); // Restore Island Names (unused)
metSM_00000_good.CopyTo(metSM_00000, 0);
metSM_30000[0] += $" ({NPC})"; // Anything from an NPC

View File

@@ -29,7 +29,8 @@ public static partial class Legal
100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148,
150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192,
194, 196, 198,
194, 195, 196, 197, // Invalid
198,
200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232,
};
@@ -480,7 +481,8 @@ public static partial class Legal
};
internal static readonly HashSet<int> ValidMet_USUM = new HashSet<int>(ValidMet_SM)
{
194, 196, 198,
// 194, 195, 196, 197, // Unobtainable new Locations
198,
200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232,
};

View File

@@ -69,10 +69,13 @@ protected override byte[] Write(bool DSV)
public readonly List<int> SaveSlots;
public readonly string[] SaveNames;
public int CurrentSlot;
protected override int Box { // 4 save slots, data reading depends on current slot
get => 0x978 + 0x6FF00 * CurrentSlot;
set { }
private int _currentSlot;
public int CurrentSlot
{
get => _currentSlot;
// 4 save slots, data reading depends on current slot
set => Box = 0x978 + 0x6FF00 * (_currentSlot = value);
}
public override int SIZE_STORED => PKX.SIZE_4STORED;

View File

@@ -130,7 +130,7 @@ protected virtual byte[] Write(bool DSV)
public virtual int MaxShadowID => 0;
// Offsets
protected virtual int Box { get; set; } = int.MinValue;
protected int Box { get; set; } = int.MinValue;
protected int Party { get; set; } = int.MinValue;
protected int Trainer1 { get; set; } = int.MinValue;
protected int Daycare { get; set; } = int.MinValue;

View File

@@ -0,0 +1,64 @@
using System;
namespace PKHeX.Core
{
/// <summary>
/// Simple Storage Binary wrapper for a concatenated list of <see cref="PKM"/> data.
/// </summary>
public class BulkStorage : SaveFile
{
public BulkStorage(byte[] data, Type t, int start, int slotsPerBox = 30)
{
Box = start;
Data = data;
SlotsPerBox = slotsPerBox;
blank = PKMConverter.GetBlank(t);
var slots = (Data.Length - Box) / blank.SIZE_STORED;
BoxCount = slots / SlotsPerBox;
}
private readonly int SlotsPerBox;
public override string BAKName => $"{FileName} [{SaveUtil.CRC16(Data, Box, Data.Length - Box)}].bak";
public override SaveFile Clone() => new BulkStorage((byte[])Data.Clone(), PKMType, Box, SlotsPerBox);
public override string Filter { get; } = "All Files|*.*";
public override string Extension { get; } = ".bin";
public override bool ChecksumsValid { get; } = true;
public override string ChecksumInfo { get; } = "No Info.";
private readonly PKM blank;
public override Type PKMType => blank.GetType();
public override PKM BlankPKM => blank.Clone();
public override PKM GetPKM(byte[] data) => PKMConverter.GetPKMfromBytes(data, prefer: Generation);
public override byte[] DecryptPKM(byte[] data) => GetPKM(data).Data;
public override int SIZE_STORED => blank.SIZE_STORED;
protected override int SIZE_PARTY => blank.SIZE_PARTY;
public override int MaxEV => blank.MaxEV;
public override int Generation => blank.Format;
public override int MaxMoveID => blank.MaxMoveID;
public override int MaxSpeciesID => blank.MaxSpeciesID;
public override int MaxAbilityID => blank.MaxAbilityID;
public override int MaxItemID => blank.MaxItemID;
public override int MaxBallID => blank.MaxBallID;
public override int MaxGameID => blank.MaxGameID;
public override int OTLength => blank.OTLength;
public override int NickLength => blank.NickLength;
public bool BigEndian => blank is BK4 || blank is XK3 || blank is CK3;
public override int BoxCount { get; }
protected override void SetChecksums() { }
public override int GetBoxOffset(int box) => Box + SlotsPerBox * SIZE_STORED;
public override string GetBoxName(int box) => $"Box {box + 1:d2}";
public override void SetBoxName(int box, string val) { }
public override int GetPartyOffset(int slot) => int.MinValue;
public override string GetString(int Offset, int Length)
=> StringConverter.GetString(Data, Generation, blank.Japanese, BigEndian, Length, Offset);
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
=> StringConverter.SetString(value, Generation, blank.Japanese, BigEndian, maxLength, padTo: PadToSize, padWith: PadWith);
}
}

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace PKHeX.Core