From 374f8b0c83f16abd58dcda33b650db431cc99c5a Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 24 Dec 2015 15:38:07 -0800 Subject: [PATCH] Fix pk6 modifying and event handling logic Memories won't be modified if the window has it disabled Geolocations won't be modified if the Pokemon is an event Pokemon and is so-far untraded. Misc change: initializing boxes won't do unnecessary calcs. --- Misc/PK6.cs | 7 ++++--- PKX/f1-Main.cs | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Misc/PK6.cs b/Misc/PK6.cs index e5ceb7b10..015450ee6 100644 --- a/Misc/PK6.cs +++ b/Misc/PK6.cs @@ -423,6 +423,7 @@ public int OppositeFriendship public bool IsShiny { get { return TSV == PSV; } } public bool PKRS_Infected { get { return PKRS_Strain > 0; } } public bool PKRS_Cured { get { return PKRS_Days == 0 && PKRS_Strain > 0; } } + public bool IsUntradedEvent6 { get { return Geo1_Country == 0 && Geo1_Region == 0 && Met_Location / 10000 == 4 && Gen6; } } public bool Gen6 { get { return Version >= 24 && Version <= 29; } } public bool Gen5 { get { return Version >= 20 && Version <= 23; } } public bool Gen4 { get { return (Version >= 10 && Version < 12) || (Version >= 7 && Version <= 8); } } @@ -602,9 +603,9 @@ public void FixMemories() Geo1_Region = Geo2_Region; Geo2_Country = Geo2_Region = 0; } - if (Geo1_Country == 0 /* && IsEgg (which is always true) */) + if (Geo1_Country == 0 && !IsUntradedEvent6) { - // Non-Eggs need to have a current location. + // Non-Eggs/Events need to have a current location. Geo1_Country = Country; Geo1_Region = Region; } @@ -634,7 +635,7 @@ private bool TradeOT(string SAV_Trainer, int SAV_TID, int SAV_SID, int SAV_COUNT } private void TradeHT(string SAV_Trainer, int SAV_COUNTRY, int SAV_REGION, int SAV_GENDER, bool Bank) { - if (SAV_Trainer != HT_Name || SAV_COUNTRY != Geo1_Country || SAV_REGION != Geo1_Region || SAV_GENDER != HT_Gender) + if (SAV_Trainer != HT_Name || SAV_GENDER != HT_Gender || (Geo1_Country == 0 && Geo1_Region == 0 && !IsUntradedEvent6)) TradeGeoLocation(SAV_COUNTRY, SAV_REGION); CurrentHandler = 1; diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs index b6aff27cc..234df8546 100644 --- a/PKX/f1-Main.cs +++ b/PKX/f1-Main.cs @@ -48,7 +48,7 @@ public Main() // Initialize Boxes for (int i = 0; i < 30*31; i++) - SAV.setEK6Stored(blankEK6, SAV.Box + i*PK6.SIZE_STORED); + SAV.setData(blankEK6, SAV.Box + i*PK6.SIZE_STORED); // Set up Language Selection foreach (var cbItem in main_langlist) @@ -2325,7 +2325,8 @@ public byte[] preparepkx(bool click = true) Util.Alert("Pokémon has no moves!"); // Fix Handler (Memories & OT) -- no foreign memories for Pokemon without a foreign trainer (none for eggs) - pk6.FixMemories(); + if (Menu_ModifyPK6.Checked) + pk6.FixMemories(); // PKX is now filled return pk6.Write(); @@ -2908,7 +2909,7 @@ private void loadBoxesFromDB(string path) if (dr == DialogResult.Yes) { for (int i = ctr; i < 30 * 31; i++) - SAV.setEK6Stored(blankEK6, offset + i * PK6.SIZE_STORED); + SAV.setData(blankEK6, offset + i * PK6.SIZE_STORED); } string[] filepaths = Directory.GetFiles(path, "*.*", SearchOption.TopDirectoryOnly);