Misc clean

This commit is contained in:
Kurt 2019-02-02 10:19:41 -08:00
parent 6ed9f979de
commit f481404503
28 changed files with 85 additions and 67 deletions

View file

@ -357,7 +357,7 @@ namespace PKHeX.Core
case 6: return WildPokeballs6;
case 7: return pkm.GG ? WildPokeballs7b : WildPokeballs7;
default: return null;
default: return Array.Empty<int>();
}
}

View file

@ -308,8 +308,10 @@ namespace PKHeX.Core
private static void MarkSpecific(EncounterArea[] Areas, int Location, SlotType t, EncounterType val)
{
foreach (EncounterArea Area in Areas.Where(x => x.Location == Location))
foreach (var s in Area.Slots.Where(s => s.Type == t))
s.TypeEncounter = val;
{
foreach (var s in Area.Slots.Where(s => s.Type == t))
s.TypeEncounter = val;
}
}
private static void MarkDPPtEncounterTypeSlots(EncounterArea[] Areas)
@ -318,9 +320,16 @@ namespace PKHeX.Core
{
if (DPPt_MixInteriorExteriorLocations.Contains(Area.Location))
continue;
var GrassType = (Area.Location == 70) ? EncounterType.Building_EnigmaStone :// Old Chateau
DPPt_CaveLocations.Contains(Area.Location) ? EncounterType.Cave_HallOfOrigin :
EncounterType.TallGrass;
var GrassType = GetGrassType(Area.Location);
EncounterType GetGrassType(int location)
{
if (location == 70) // Old Chateau
return EncounterType.Building_EnigmaStone;
if (DPPt_CaveLocations.Contains(Area.Location))
return EncounterType.Cave_HallOfOrigin;
return EncounterType.TallGrass;
}
foreach (EncounterSlot Slot in Area.Slots)
{
if (Slot.TypeEncounter == EncounterType.None) // not defined yet

View file

@ -330,7 +330,6 @@ namespace PKHeX.Core
if (ctr != 0) yield break;
foreach (var z in GetValidEncounterTrades(pkm))
{ yield return z; ++ctr; }
// if (ctr != 0) yield break;
}
private static IEnumerable<IEncounterable> GenerateRawEncounters4(PKM pkm, LegalInfo info)

View file

@ -388,7 +388,7 @@ namespace PKHeX.Core
{
case Any:
if (species != 646) // Kyurem moves are same for both versions, but forme movepool not present.
LearnBW.AddMoves(moves, species, form, max);
LearnBW.AddMoves(moves, species, form, max);
return LearnB2W2.AddMoves(moves, species, form, max);
case B: case W: case BW:

View file

@ -330,7 +330,7 @@ namespace PKHeX.Core
{
if (HT_Name != SAV_Trainer)
{
HT_Friendship = CurrentFriendship; // PersonalInfo.BaseFriendship;
HT_Friendship = CurrentFriendship; // copy friendship instead of resetting (don't alter CP)
HT_Affection = 0;
}
CurrentHandler = 1;
@ -489,7 +489,7 @@ namespace PKHeX.Core
{
get
{
var sum = this.AwakeningSum(); // aHP + aATK + aDEF + aSPA + aSPD + aSPE;
var sum = this.AwakeningSum();
if (sum == 0)
return 0;
var lvl = CurrentLevel;

View file

@ -410,9 +410,15 @@ namespace PKHeX.Core
return null;
}
public override void SetDaycareEXP(int loc, int slot, uint EXP) { } // todo
public override void SetDaycareEXP(int loc, int slot, uint EXP)
{
// todo
}
public override void SetDaycareOccupied(int loc, int slot, bool occupied) { } // todo
public override void SetDaycareOccupied(int loc, int slot, bool occupied)
{
// todo
}
// Storage
public override int PartyCount

View file

@ -167,7 +167,7 @@ namespace PKHeX.Core
OFS_PouchBerry = BlockOfs[1] + 0x054C;
SeenFlagOffsets = new[] { PokeDex + 0x44, BlockOfs[1] + 0x5F8, BlockOfs[4] + 0xB98 };
EventFlag = BlockOfs[1] + 0xEE0;
EventConst = BlockOfs[2] + 0x80; // EventFlag + (EventFlagMax / 8);
EventConst = BlockOfs[2] + 0x80;
Daycare = BlockOfs[4] + 0x100;
break;
}
@ -564,7 +564,7 @@ namespace PKHeX.Core
public override uint? GetDaycareEXP(int loc, int slot) => BitConverter.ToUInt32(Data, GetDaycareEXPOffset(slot));
public override void SetDaycareEXP(int loc, int slot, uint EXP) => BitConverter.GetBytes(EXP).CopyTo(Data, GetDaycareEXPOffset(slot));
public override bool? IsDaycareOccupied(int loc, int slot) => IsPKMPresent(GetDaycareSlotOffset(loc, slot));
public override void SetDaycareOccupied(int loc, int slot, bool occupied) { }
public override void SetDaycareOccupied(int loc, int slot, bool occupied) { /* todo */ }
public override int GetDaycareSlotOffset(int loc, int slot) => Daycare + (slot * DaycareSlotSize);
private int EggEventFlag => GameVersion.FRLG.Contains(Version) ? 0x266 : 0x86;
@ -891,7 +891,7 @@ namespace PKHeX.Core
{
var ofs = PokeBlockOffset;
if (ofs < 0)
throw new Exception($"Game does not support {nameof(PokeBlocks)}.");
throw new ArgumentException($"Game does not support {nameof(PokeBlocks)}.");
return new PokeBlock3Case(Data, ofs);
}
set => SetData(value.Write(), PokeBlockOffset);

View file

@ -182,7 +182,7 @@ namespace PKHeX.Core
return PKX.DecryptArray3(data);
}
protected override void SetDex(PKM pkm) { }
protected override void SetDex(PKM pkm) { /* No Pokedex for this game, do nothing */ }
public override void SetStoredSlot(PKM pkm, int offset, bool? trade = null, bool? dex = null)
{

View file

@ -374,8 +374,8 @@ namespace PKHeX.Core
public override int GetDaycareSlotOffset(int loc, int slot) { return Daycare + 8; }
public override uint? GetDaycareEXP(int loc, int slot) { return null; }
public override bool? IsDaycareOccupied(int loc, int slot) { return null; }
public override void SetDaycareEXP(int loc, int slot, uint EXP) { }
public override void SetDaycareOccupied(int loc, int slot, bool occupied) { }
public override void SetDaycareEXP(int loc, int slot, uint EXP) { /* todo */ }
public override void SetDaycareOccupied(int loc, int slot, bool occupied) { /* todo */ }
public override string GetString(byte[] data, int offset, int length) => StringConverter.GetBEString3(data, offset, length);

View file

@ -666,7 +666,10 @@ namespace PKHeX.Core
BitConverter.GetBytes(EXP).CopyTo(Data, ofs);
}
public override void SetDaycareOccupied(int loc, int slot, bool occupied) { } // todo
public override void SetDaycareOccupied(int loc, int slot, bool occupied)
{
// todo
}
// Mystery Gift
private bool MysteryGiftActive { get => (Data[GBO + 72] & 1) == 1; set => Data[GBO + 72] = (byte)((Data[GBO + 72] & 0xFE) | (value ? 1 : 0)); }

View file

@ -975,7 +975,7 @@ namespace PKHeX.Core
get
{
if (WondercardData < 0 || WondercardFlags < 0)
return null;
return Array.Empty<bool>();
bool[] r = new bool[(WondercardData - WondercardFlags) * 8];
for (int i = 0; i < r.Length; i++)
@ -986,7 +986,7 @@ namespace PKHeX.Core
{
if (WondercardData < 0 || WondercardFlags < 0)
return;
if ((WondercardData - WondercardFlags) * 8 != value?.Length)
if (value == null || (WondercardData - WondercardFlags) * 8 != value.Length)
return;
byte[] data = new byte[value.Length / 8];
@ -1006,7 +1006,7 @@ namespace PKHeX.Core
get
{
if (WondercardData < 0)
return null;
return Array.Empty<MysteryGift>();
MysteryGift[] cards = new MysteryGift[GiftCountMax];
for (int i = 0; i < cards.Length; i++)
cards[i] = GetWC6(i);
@ -1032,7 +1032,7 @@ namespace PKHeX.Core
get
{
if (LinkInfo < 0)
return null;
return Array.Empty<byte>();
return GetData(LinkInfo, 0xC48);
}
set

View file

@ -243,10 +243,10 @@ namespace PKHeX.WinForms.Controls
try { GetFieldsfromPKM(); }
finally { FieldsInitialized = oldInit; }
Stats.UpdateIVs(null, null);
UpdatePKRSInfected(null, null);
UpdatePKRSCured(null, null);
UpdateNatureModification(null, null);
Stats.UpdateIVs(null, EventArgs.Empty);
UpdatePKRSInfected(null, EventArgs.Empty);
UpdatePKRSCured(null, EventArgs.Empty);
UpdateNatureModification(null, EventArgs.Empty);
if (HaX) // Load original values from pk not pkm
{
@ -274,7 +274,7 @@ namespace PKHeX.WinForms.Controls
{
PB_WarnMove1.Visible = PB_WarnMove2.Visible = PB_WarnMove3.Visible = PB_WarnMove4.Visible =
PB_WarnRelearn1.Visible = PB_WarnRelearn2.Visible = PB_WarnRelearn3.Visible = PB_WarnRelearn4.Visible = false;
LegalityChanged?.Invoke(Legality.Valid, null);
LegalityChanged?.Invoke(Legality.Valid, EventArgs.Empty);
return;
}
@ -295,7 +295,7 @@ namespace PKHeX.WinForms.Controls
FieldsLoaded = false;
ReloadMoves(Legality.AllSuggestedMovesAndRelearn);
FieldsLoaded |= tmp;
LegalityChanged?.Invoke(Legality.Valid, null);
LegalityChanged?.Invoke(Legality.Valid, EventArgs.Empty);
}
private IReadOnlyList<ComboItem> MoveDataAllowed = new List<ComboItem>();
@ -346,7 +346,7 @@ namespace PKHeX.WinForms.Controls
private void UpdateSprite()
{
if (FieldsLoaded && FieldsInitialized && !forceValidation)
UpdatePreviewSprite?.Invoke(this, null);
UpdatePreviewSprite?.Invoke(this, EventArgs.Empty);
}
// General Use Functions //
@ -383,7 +383,7 @@ namespace PKHeX.WinForms.Controls
private void SetDetailsOT(ITrainerInfo SAV)
{
if (!(SAV.OT?.Length > 0))
if (string.IsNullOrWhiteSpace(SAV.OT))
return;
// Get Save Information
@ -410,12 +410,12 @@ namespace PKHeX.WinForms.Controls
if (SAV is SAV1 s1 && pkm is PK1 p1) p1.OT_Trash = s1.OT_Trash;
else if (SAV is SAV2 s2 && pkm is PK2 p2) p2.OT_Trash = s2.OT_Trash;
UpdateNickname(null, null);
UpdateNickname(null, EventArgs.Empty);
}
private void SetDetailsHT(ITrainerInfo SAV)
{
if (!(SAV.OT?.Length > 0))
if (string.IsNullOrWhiteSpace(SAV.OT))
return;
if (TB_OTt2.Text.Length > 0)
@ -571,7 +571,7 @@ namespace PKHeX.WinForms.Controls
if (PKX.GetGenderFromString(CB_Form.Text) < 2) // Gendered Forms
CB_Form.SelectedIndex = PKX.GetGenderFromString(Label_Gender.Text);
UpdatePreviewSprite(Label_Gender, null);
UpdatePreviewSprite(Label_Gender, EventArgs.Empty);
}
private void ClickPPUps(object sender, EventArgs e)
@ -965,7 +965,7 @@ namespace PKHeX.WinForms.Controls
while (pkm.AltForm != desiredForm)
{
FieldsLoaded = false;
Stats.UpdateRandomIVs(null, null);
Stats.UpdateRandomIVs(null, EventArgs.Empty);
FieldsLoaded = true;
}
}
@ -1131,7 +1131,7 @@ namespace PKHeX.WinForms.Controls
SpeciesIDTip.SetToolTip(CB_Species, pkm.Species.ToString("000"));
SetAbilityList();
SetForms();
UpdateForm(null, null);
UpdateForm(null, EventArgs.Empty);
if (!FieldsLoaded)
return;
@ -1386,7 +1386,7 @@ namespace PKHeX.WinForms.Controls
else // Not Egg
{
if (!CHK_Nicknamed.Checked)
UpdateNickname(null, null);
UpdateNickname(null, EventArgs.Empty);
TB_Friendship.Text = pkm.PersonalInfo.BaseFriendship.ToString();
@ -1401,7 +1401,7 @@ namespace PKHeX.WinForms.Controls
CHK_Nicknamed.Checked = false;
}
UpdateNickname(null, null);
UpdateNickname(null, EventArgs.Empty);
UpdateSprite();
}
@ -1459,11 +1459,11 @@ namespace PKHeX.WinForms.Controls
{
pkm.SetShiny();
Stats.LoadIVs(pkm.IVs);
Stats.UpdateIVs(null, null);
Stats.UpdateIVs(null, EventArgs.Empty);
}
UpdateIsShiny();
UpdatePreviewSprite?.Invoke(this, null);
UpdatePreviewSprite?.Invoke(this, EventArgs.Empty);
UpdateLegality();
}
@ -1523,7 +1523,7 @@ namespace PKHeX.WinForms.Controls
FieldsLoaded = false;
NUD_Purification.Value = CHK_Shadow.Checked ? NUD_Purification.Maximum : 0;
((IShadowPKM)pkm).Purification = (int)NUD_Purification.Value;
UpdatePreviewSprite?.Invoke(this, null);
UpdatePreviewSprite?.Invoke(this, EventArgs.Empty);
FieldsLoaded = true;
}
@ -1761,7 +1761,7 @@ namespace PKHeX.WinForms.Controls
// pk2 save files do not have an Origin Game stored. Prompt the met location list to update.
if (pkm.Format == 2)
UpdateOriginGame(null, null);
UpdateOriginGame(null, EventArgs.Empty);
return TranslationRequired;
}

View file

@ -210,7 +210,7 @@ namespace PKHeX.WinForms.Controls
bool zero = ModifierKeys.HasFlag(Keys.Control);
var evs = zero ? new int[6] : PKX.GetRandomEVs(pkm.Format);
LoadEVs(evs);
UpdateEVs(null, null);
UpdateEVs(null, EventArgs.Empty);
}
private void UpdateHackedStats(object sender, EventArgs e)

View file

@ -38,7 +38,7 @@ namespace PKHeX.WinForms
Lines = lines;
if (pkm?.Format == 7 && pkm is PK7)
UpdateBoxSlotCopies(null, null);
UpdateBoxSlotCopies(null, EventArgs.Empty);
else
RefreshImage();
}

View file

@ -40,7 +40,7 @@ namespace PKHeX.WinForms
NUD_BagHits.Value = pk6.TrainingBagHits;
if (!CHK_SecretUnlocked.Checked) // force update to disable checkboxes
CHK_Secret_CheckedChanged(null, null);
CHK_Secret_CheckedChanged(null, EventArgs.Empty);
}
else
{

View file

@ -83,7 +83,7 @@ namespace PKHeX.WinForms
dgData.Columns[i].Width = w;
}
dgData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
Data_Sorted(null, null); // trigger row resizing
Data_Sorted(null, EventArgs.Empty); // trigger row resizing
ResumeLayout();
}

View file

@ -278,7 +278,7 @@ namespace PKHeX.WinForms
}
// Trigger a Reset
ResetFilters(null, null);
ResetFilters(null, EventArgs.Empty);
}
private void ResetFilters(object sender, EventArgs e)

View file

@ -174,7 +174,7 @@ namespace PKHeX.WinForms
DS_Version.Insert(0, Any); CB_GameOrigin.DataSource = DS_Version;
// Trigger a Reset
ResetFilters(null, null);
ResetFilters(null, EventArgs.Empty);
}
private void ResetFilters(object sender, EventArgs e)
@ -325,6 +325,7 @@ namespace PKHeX.WinForms
private void Menu_SearchAdvanced_Click(object sender, EventArgs e)
{
// todo
}
private void Menu_Exit_Click(object sender, EventArgs e) => Close();

View file

@ -189,7 +189,7 @@ namespace PKHeX.WinForms
}
// Trigger a Reset
ResetFilters(null, null);
ResetFilters(null, EventArgs.Empty);
B_Search.Enabled = true;
}

View file

@ -71,7 +71,7 @@ namespace PKHeX.WinForms
NUD_Group.Value = Math.Min(NUD_Group.Maximum, Tree.Group);
NUD_Slot.Value = Math.Min(NUD_Slot.Maximum, Tree.Slot);
ChangeGroupSlot(null, null);
ChangeGroupSlot(null, EventArgs.Empty);
loading = false;
}

View file

@ -668,7 +668,7 @@ namespace PKHeX.WinForms
s.Move = slot.Moves?[Util.Rand.Next(slot.Moves.Length)] ?? 0;
s.Gender = slot.Gender == -1 ? PersonalTable.B2W2[slot.Species].RandomGender : slot.Gender;
}
ChangeArea(null, null); // refresh
ChangeArea(null, EventArgs.Empty); // refresh
NUD_Unlocked.Value = 8;
CHK_Area9.Checked = true;
System.Media.SystemSounds.Asterisk.Play();

View file

@ -191,7 +191,7 @@ namespace PKHeX.WinForms
}
else
{
ChangeBox(null, null);
ChangeBox(null, EventArgs.Empty);
}
editing = renamingBox = false;

View file

@ -49,7 +49,7 @@ namespace PKHeX.WinForms
Label_MetDate,
};
LB_DataEntry.SelectedIndex = 0;
NUP_PartyIndex_ValueChanged(null, null);
NUP_PartyIndex_ValueChanged(null, EventArgs.Empty);
try { TB_Nickname.Font = TB_OT.Font = FontUtil.GetPKXFont(11); }
catch (Exception e) { WinFormsUtil.Alert("Font loading failed...", e.ToString()); }
editing = true;
@ -316,7 +316,7 @@ namespace PKHeX.WinForms
Array.Copy(BitConverter.GetBytes(vnd), 0, data, offset + 0x1B0, 4);
bpkx.Image = SpriteUtil.GetSprite(WinFormsUtil.GetIndex(CB_Species), CB_Form.SelectedIndex & 0x1F, PKX.GetGenderFromString(Label_Gender.Text), WinFormsUtil.GetIndex(CB_HeldItem), false, CHK_Shiny.Checked);
DisplayEntry(null, null); // refresh text view
DisplayEntry(null, EventArgs.Empty); // refresh text view
}
private void Validate_TextBoxes()
@ -345,7 +345,7 @@ namespace PKHeX.WinForms
}
TB_Nickname.ReadOnly = !CHK_Nicknamed.Checked;
Write_Entry(null, null);
Write_Entry(null, EventArgs.Empty);
}
private void SetForms()
@ -361,7 +361,7 @@ namespace PKHeX.WinForms
private void UpdateSpecies(object sender, EventArgs e)
{
SetForms();
UpdateNickname(null, null);
UpdateNickname(null, EventArgs.Empty);
}
private void UpdateShiny(object sender, EventArgs e)
@ -370,7 +370,7 @@ namespace PKHeX.WinForms
return; //Don't do writing until loaded
bpkx.Image = SpriteUtil.GetSprite(WinFormsUtil.GetIndex(CB_Species), CB_Form.SelectedIndex & 0x1F, PKX.GetGenderFromString(Label_Gender.Text), WinFormsUtil.GetIndex(CB_HeldItem), false, CHK_Shiny.Checked);
Write_Entry(null, null);
Write_Entry(null, EventArgs.Empty);
}
private void UpdateGender(object sender, EventArgs e)
@ -402,7 +402,7 @@ namespace PKHeX.WinForms
if (species == 668)
CB_Form.SelectedIndex = PKX.GetGenderFromString(Label_Gender.Text);
Write_Entry(null, null);
Write_Entry(null, EventArgs.Empty);
}
private void SetGenderLabel(int gender)
@ -414,7 +414,7 @@ namespace PKHeX.WinForms
else
Label_Gender.Text = gendersymbols[2]; // Genderless
Write_Entry(null, null);
Write_Entry(null, EventArgs.Empty);
}
private void B_CopyText_Click(object sender, EventArgs e)

View file

@ -27,7 +27,7 @@ namespace PKHeX.WinForms
LB_Favorite.SelectedIndex = 0;
// MT_Flags.Text = BitConverter.ToUInt16(sav, 0x24800 + 0x140).ToString(); PSS Stat transmitted
MT_Flags.Text = BitConverter.ToUInt32(SAV.Data, SAV.SecretBase + 0x62C).ToString(); // read counter
B_SAV2FAV(null, null);
B_SAV2FAV(null, EventArgs.Empty);
}
private bool editing;
@ -112,7 +112,7 @@ namespace PKHeX.WinForms
}
NUD_FObject.Value = 1; // Trigger Update
ChangeObjectIndex(null, null);
ChangeObjectIndex(null, EventArgs.Empty);
GB_PKM.Enabled = index > 0;
@ -128,7 +128,7 @@ namespace PKHeX.WinForms
}
NUD_FPKM.Value = 1;
ChangeFavPKM(null, null); // Trigger Update
ChangeFavPKM(null, EventArgs.Empty); // Trigger Update
loading = false;
}

View file

@ -89,7 +89,7 @@ namespace PKHeX.WinForms
HandleSpecialFlags();
// Copy back Constants
ChangeConstantIndex(null, null); // Trigger Saving
ChangeConstantIndex(null, EventArgs.Empty); // Trigger Saving
SAV.EventConsts = Constants;
SAV.Data.CopyTo(Origin.Data, 0);
Origin.Edited = true;

View file

@ -32,9 +32,9 @@ namespace PKHeX.WinForms
private void SAV_GameSelect_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
B_OK_Click(null, null);
B_OK_Click(null, EventArgs.Empty);
if (e.KeyCode == Keys.Escape)
B_Cancel_Click(null, null);
B_Cancel_Click(null, EventArgs.Empty);
}
}
}

View file

@ -30,7 +30,7 @@ namespace PKHeX.WinForms
Pouches = SAV.Inventory;
InitBags();
GetBags();
SwitchBag(null, null); // bag 0
SwitchBag(null, EventArgs.Empty); // bag 0
}
private readonly InventoryPouch[] Pouches;

View file

@ -975,7 +975,7 @@ namespace QRCoder
private void CreateAlphanumEncDict()
{
alphanumEncDict = new Dictionary<char, int>();
var resList = alphanumEncTable.ToList().Select((x, i) => new { Chr = x, Index = i }).ToList();
var resList = alphanumEncTable.Select((x, i) => new { Chr = x, Index = i });
foreach (var res in resList)
{
alphanumEncDict.Add(res.Chr, res.Index);