Code cleanup

Seems like every time I go through the code I find more of my newb code.
This commit is contained in:
Kurt 2015-01-02 17:07:29 -08:00
parent bb951188a0
commit 5eaf603c3b
3 changed files with 97 additions and 128 deletions

View file

@ -18,7 +18,7 @@ namespace PKHeX
// Relies on Util for some common operations. // Relies on Util for some common operations.
// Data // Data
public static uint LCRNG(uint seed) internal static uint LCRNG(uint seed)
{ {
uint a = 0x41C64E6D; uint a = 0x41C64E6D;
uint c = 0x00006073; uint c = 0x00006073;
@ -26,7 +26,7 @@ namespace PKHeX
seed = (seed * a + c) & 0xFFFFFFFF; seed = (seed * a + c) & 0xFFFFFFFF;
return seed; return seed;
} }
public static uint LCRNG(ref uint seed) internal static uint LCRNG(ref uint seed)
{ {
uint a = 0x41C64E6D; uint a = 0x41C64E6D;
uint c = 0x00006073; uint c = 0x00006073;
@ -34,7 +34,7 @@ namespace PKHeX
seed = (seed * a + c) & 0xFFFFFFFF; seed = (seed * a + c) & 0xFFFFFFFF;
return seed; return seed;
} }
public static DataTable ExpTable() internal static DataTable ExpTable()
{ {
DataTable table = new DataTable(); DataTable table = new DataTable();
table.Columns.Add("Level", typeof(byte)); table.Columns.Add("Level", typeof(byte));
@ -149,11 +149,11 @@ namespace PKHeX
} }
// Stat Fetching // Stat Fetching
public static int getMovePP(int move, int ppup) internal static int getMovePP(int move, int ppup)
{ {
return (getBasePP(move) * (5 + ppup) / 5); return (getBasePP(move) * (5 + ppup) / 5);
} }
public static int getBasePP(int move) internal static int getBasePP(int move)
{ {
byte[] movepptable = byte[] movepptable =
{ {
@ -194,7 +194,7 @@ namespace PKHeX
if (move < 0) { move = 0; } if (move < 0) { move = 0; }
return (byte)movepptable[move]; return (byte)movepptable[move];
} }
public static byte[] getRandomEVs() internal static byte[] getRandomEVs()
{ {
byte[] evs = new byte[6] { 0xDE, 0xAD, 0xBE, 0xEF, 0xBA, 0xBE, }; // ha ha, just to start off above 510! byte[] evs = new byte[6] { 0xDE, 0xAD, 0xBE, 0xEF, 0xBA, 0xBE, }; // ha ha, just to start off above 510!
@ -210,11 +210,11 @@ namespace PKHeX
Util.Shuffle(evs); Util.Shuffle(evs);
return evs; return evs;
} }
public static byte getBaseFriendship(int species) internal static byte getBaseFriendship(int species)
{ {
return PersonalGetter.GetPersonal(species).BaseFriendship; return PersonalGetter.GetPersonal(species).BaseFriendship;
} }
public static int getLevel(int species, ref uint exp) internal static int getLevel(int species, ref uint exp)
{ {
if (exp == 0) { return 1; } if (exp == 0) { return 1; }
@ -235,13 +235,13 @@ namespace PKHeX
} }
return --tl; return --tl;
} }
public static bool getIsShiny(uint PID, uint TID, uint SID) internal static bool getIsShiny(uint PID, uint TID, uint SID)
{ {
uint PSV = getPSV(PID); uint PSV = getPSV(PID);
uint TSV = getTSV(TID, SID); uint TSV = getTSV(TID, SID);
return (TSV == PSV); return (TSV == PSV);
} }
public static uint getEXP(int level, int species) internal static uint getEXP(int level, int species)
{ {
// Fetch Growth // Fetch Growth
if ((level == 0) || (level == 1)) if ((level == 0) || (level == 1))
@ -254,11 +254,11 @@ namespace PKHeX
uint exp = (uint)PKX.ExpTable().Rows[level][growth + 1]; uint exp = (uint)PKX.ExpTable().Rows[level][growth + 1];
return exp; return exp;
} }
public static byte[] getAbilities(int species, int formnum) internal static byte[] getAbilities(int species, int formnum)
{ {
return PersonalGetter.GetPersonal(species, formnum).Abilities; return PersonalGetter.GetPersonal(species, formnum).Abilities;
} }
public static int getGender(string s) internal static int getGender(string s)
{ {
if (s == "♂" || s == "M") if (s == "♂" || s == "M")
return 0; return 0;
@ -266,7 +266,7 @@ namespace PKHeX
return 1; return 1;
else return 2; else return 2;
} }
public static string[] getCountryRegionText(int country, int region, string lang) internal static string[] getCountryRegionText(int country, int region, string lang)
{ {
// Get Language we're fetching for // Get Language we're fetching for
int index = Array.IndexOf(new string[] { "ja", "en", "fr", "de", "it", "es", "zh", "ko", }, lang); int index = Array.IndexOf(new string[] { "ja", "en", "fr", "de", "it", "es", "zh", "ko", }, lang);
@ -326,7 +326,7 @@ namespace PKHeX
catch { data[1] = "Illegal"; } catch { data[1] = "Illegal"; }
return data; return data;
} }
public static string getLocation(bool eggmet, int gameorigin, int locval) internal static string getLocation(bool eggmet, int gameorigin, int locval)
{ {
string loctext = ""; string loctext = "";
if (gameorigin < 13 && gameorigin > 6 && eggmet) if (gameorigin < 13 && gameorigin > 6 && eggmet)
@ -340,7 +340,7 @@ namespace PKHeX
} }
else if (gameorigin < 24) else if (gameorigin < 24)
{ {
if (locval < 30000) if (locval < 30000)
loctext = Form1.metBW2_00000[locval]; loctext = Form1.metBW2_00000[locval];
else if (locval < 40000) else if (locval < 40000)
loctext = Form1.metBW2_30000[locval % 10000 - 1]; loctext = Form1.metBW2_30000[locval % 10000 - 1];
@ -362,7 +362,7 @@ namespace PKHeX
} }
return loctext; return loctext;
} }
public static ushort[] getStats(int species, int level, int nature, int form, internal static ushort[] getStats(int species, int level, int nature, int form,
int HP_EV, int ATK_EV, int DEF_EV, int SPA_EV, int SPD_EV, int SPE_EV, int HP_EV, int ATK_EV, int DEF_EV, int SPA_EV, int SPD_EV, int SPE_EV,
int HP_IV, int ATK_IV, int DEF_IV, int SPA_IV, int SPD_IV, int SPE_IV) int HP_IV, int ATK_IV, int DEF_IV, int SPA_IV, int SPD_IV, int SPE_IV)
{ {
@ -397,7 +397,7 @@ namespace PKHeX
} }
// Manipulation // Manipulation
public static byte[] shuffleArray(byte[] pkx, uint sv) internal static byte[] shuffleArray(byte[] pkx, uint sv)
{ {
byte[] ekx = new byte[260]; byte[] ekx = new byte[260];
Array.Copy(pkx, ekx, 8); Array.Copy(pkx, ekx, 8);
@ -423,7 +423,7 @@ namespace PKHeX
return ekx; return ekx;
} }
public static byte[] decryptArray(byte[] ekx) internal static byte[] decryptArray(byte[] ekx)
{ {
byte[] pkx = (byte[])ekx.Clone(); byte[] pkx = (byte[])ekx.Clone();
@ -447,7 +447,7 @@ namespace PKHeX
return pkx; return pkx;
} }
public static byte[] encryptArray(byte[] pkx) internal static byte[] encryptArray(byte[] pkx)
{ {
// Shuffle // Shuffle
uint pv = BitConverter.ToUInt32(pkx, 0); uint pv = BitConverter.ToUInt32(pkx, 0);
@ -474,7 +474,7 @@ namespace PKHeX
// Done // Done
return ekx; return ekx;
} }
public static ushort getCHK(byte[] data) internal static ushort getCHK(byte[] data)
{ {
ushort chk = 0; ushort chk = 0;
for (int i = 8; i < 232; i += 2) // Loop through the entire PKX for (int i = 8; i < 232; i += 2) // Loop through the entire PKX
@ -482,7 +482,7 @@ namespace PKHeX
return chk; return chk;
} }
public static bool verifychk(byte[] input) internal static bool verifychk(byte[] input)
{ {
ushort checksum = 0; ushort checksum = 0;
if (input.Length == 100 || input.Length == 80) // Gen 3 Files if (input.Length == 100 || input.Length == 80) // Gen 3 Files
@ -507,15 +507,15 @@ namespace PKHeX
return (chk == BitConverter.ToUInt16(input, 0x6)); return (chk == BitConverter.ToUInt16(input, 0x6));
} }
} }
public static uint getPSV(uint PID) internal static uint getPSV(uint PID)
{ {
return Convert.ToUInt16(((PID >> 16) ^ (PID & 0xFFFF)) >> 4); return Convert.ToUInt16(((PID >> 16) ^ (PID & 0xFFFF)) >> 4);
} }
public static uint getTSV(uint TID, uint SID) internal static uint getTSV(uint TID, uint SID)
{ {
return ((TID ^ SID) >> 4); return ((TID ^ SID) >> 4);
} }
public static uint getRandomPID(int species, int cg) internal static uint getRandomPID(int species, int cg)
{ {
PersonalParser.Personal MonData = PersonalGetter.GetPersonal(species); PersonalParser.Personal MonData = PersonalGetter.GetPersonal(species);
int gt = MonData.GenderRatio; int gt = MonData.GenderRatio;
@ -1197,7 +1197,6 @@ namespace PKHeX
data.FormPointer = MonData[0xD]; data.FormPointer = MonData[0xD];
return data; return data;
} }
internal Personal GetPersonal(int species, int formID) internal Personal GetPersonal(int species, int formID)
{ {
Personal data = GetPersonal(species); Personal data = GetPersonal(species);

View file

@ -200,15 +200,15 @@ namespace PKHeX
// Data Retrieval // Data Retrieval
internal static int ToInt32(TextBox tb) internal static int ToInt32(TextBox tb)
{ {
string value = tb.Text; string value = tb.Text;
return ToInt32(value); return ToInt32(value);
} }
internal static uint ToUInt32(TextBox tb) internal static uint ToUInt32(TextBox tb)
{ {
string value = tb.Text; string value = tb.Text;
return ToUInt32(value); return ToUInt32(value);
} }
internal static int ToInt32(MaskedTextBox tb) internal static int ToInt32(MaskedTextBox tb)
{ {
string value = tb.Text; string value = tb.Text;
@ -222,12 +222,12 @@ namespace PKHeX
internal static int ToInt32(String value) internal static int ToInt32(String value)
{ {
value = value.Replace(" ", ""); value = value.Replace(" ", "");
if (String.IsNullOrEmpty(value)) if (String.IsNullOrEmpty(value))
return 0; return 0;
try try
{ {
value = value.TrimEnd(new char[]{'_'}); value = value.TrimEnd(new char[] { '_' });
return Int32.Parse(value); return Int32.Parse(value);
} }
catch { return 0; } catch { return 0; }
} }
@ -238,7 +238,7 @@ namespace PKHeX
return 0; return 0;
try try
{ {
value = value.TrimEnd(new char[]{'_'}); value = value.TrimEnd(new char[] { '_' });
return UInt32.Parse(value); return UInt32.Parse(value);
} }
catch { return 0; } catch { return 0; }
@ -253,11 +253,11 @@ namespace PKHeX
internal static int getIndex(ComboBox cb) internal static int getIndex(ComboBox cb)
{ {
int val = 0; int val = 0;
if (cb.SelectedValue == null) if (cb.SelectedValue == null)
return 0; return 0;
try try
{ val = Util.ToInt32(cb.SelectedValue.ToString()); } { val = (int)cb.SelectedValue; }
catch catch
{ val = cb.SelectedIndex; if (val < 0) val = 0; } { val = cb.SelectedIndex; if (val < 0) val = 0; }
return val; return val;
@ -274,7 +274,7 @@ namespace PKHeX
c = str[i]; c = str[i];
// filter for hex // filter for hex
if ((c < 0x0047 && c > 0x002F) || (c < 0x0067 && c > 0x0060)) if ((c < 0x0047 && c > 0x002F) || (c < 0x0067 && c > 0x0060))
s+= c; s += c;
else else
System.Media.SystemSounds.Beep.Play(); System.Media.SystemSounds.Beep.Play();
} }
@ -356,23 +356,23 @@ namespace PKHeX
string text = SplitString[1]; // Text to set Control.Text to... string text = SplitString[1]; // Text to set Control.Text to...
Control[] controllist = Controls.Find(ctrl, true); Control[] controllist = Controls.Find(ctrl, true);
if (controllist.Length == 0) // If Control isn't found... if (controllist.Length == 0) // If Control isn't found...
try try
{
// Menu Items can't be found with Controls.Find as they aren't Controls
ToolStripDropDownItem TSI = (ToolStripDropDownItem)menu.Items[ctrl];
if (TSI != null)
{ {
// We'll rename the main and child in a row. // Menu Items can't be found with Controls.Find as they aren't Controls
string[] ToolItems = Regex.Split(SplitString[1], " ; "); ToolStripDropDownItem TSI = (ToolStripDropDownItem)menu.Items[ctrl];
TSI.Text = ToolItems[0]; // Set parent's text first if (TSI != null)
if (TSI.DropDownItems.Count != ToolItems.Length - 1) {
continue; // Error in Input, errhandled // We'll rename the main and child in a row.
for (int ti = 1; ti <= TSI.DropDownItems.Count; ti++) string[] ToolItems = Regex.Split(SplitString[1], " ; ");
TSI.DropDownItems[ti - 1].Text = ToolItems[ti]; // Set child text TSI.Text = ToolItems[0]; // Set parent's text first
if (TSI.DropDownItems.Count != ToolItems.Length - 1)
continue; // Error in Input, errhandled
for (int ti = 1; ti <= TSI.DropDownItems.Count; ti++)
TSI.DropDownItems[ti - 1].Text = ToolItems[ti]; // Set child text
}
// If not found, it is not something to rename and is thus skipped.
} }
// If not found, it is not something to rename and is thus skipped. catch { }
}
catch { }
else // Set the input control's text. else // Set the input control's text.
controllist[0].Text = text; controllist[0].Text = text;
} }
@ -403,11 +403,6 @@ namespace PKHeX
{ {
public string Text { get; set; } public string Text { get; set; }
public object Value { get; set; } public object Value { get; set; }
public override string ToString()
{
return Text;
}
} }
internal static List<cbItem> getCBList(string textfile, string lang) internal static List<cbItem> getCBList(string textfile, string lang)
{ {

View file

@ -177,14 +177,12 @@ namespace PKHeX
} }
#region Global Variables: Always Visible! #region Global Variables: Always Visible!
public byte[] buff = new byte[260]; public byte[] buff = new byte[260]; // Tab Pokemon Data Storage
public byte[] savefile = new byte[0x100000]; public byte[] savefile = new byte[0x100000];
public byte[] cyberSAV = new byte[0x65600]; public byte[] cyberSAV = new byte[0x65600];
public bool savegame_oras = false; public bool savegame_oras = false;
public bool cybergadget = false; public bool cybergadget = false;
public bool savLoaded = false; public bool savLoaded = false;
public int gt = 258;
public int genderflag, species;
public int savindex; public int savindex;
public bool savedited; public bool savedited;
public string SDFLoc = null; public string SDFLoc = null;
@ -888,7 +886,7 @@ namespace PKHeX
uint PID = BitConverter.ToUInt32(buff, 0x18); uint PID = BitConverter.ToUInt32(buff, 0x18);
int nature = buff[0x1C]; int nature = buff[0x1C];
int feflag = buff[0x1D] % 2; int feflag = buff[0x1D] % 2;
this.genderflag = (buff[0x1D] >> 1) & 0x3; int genderflag = (buff[0x1D] >> 1) & 0x3;
int altforms = (buff[0x1D] >> 3); int altforms = (buff[0x1D] >> 3);
int HP_EV = buff[0x1E]; int HP_EV = buff[0x1E];
int ATK_EV = buff[0x1F]; int ATK_EV = buff[0x1F];
@ -1116,8 +1114,7 @@ namespace PKHeX
// Load Extrabyte Value // Load Extrabyte Value
TB_ExtraByte.Text = buff[Convert.ToInt32(CB_ExtraBytes.Text, 16)].ToString(); TB_ExtraByte.Text = buff[Convert.ToInt32(CB_ExtraBytes.Text, 16)].ToString();
// Reload Gender Flag // Load Gender Flag
this.genderflag = ((buff[0x1D] >> 1) & 0x3);
Label_Gender.Text = gendersymbols[genderflag]; Label_Gender.Text = gendersymbols[genderflag];
updateStats(); updateStats();
setIsShiny(); setIsShiny();
@ -1516,9 +1513,8 @@ namespace PKHeX
private void clickGender(object sender, EventArgs e) private void clickGender(object sender, EventArgs e)
{ {
// Get Gender Threshold // Get Gender Threshold
species = Util.getIndex(CB_Species); PKX.PersonalParser.Personal MonData = PKX.PersonalGetter.GetPersonal(Util.getIndex(CB_Species));
PKX.PersonalParser.Personal MonData = PKX.PersonalGetter.GetPersonal(species); int gt = MonData.GenderRatio;
gt = MonData.GenderRatio;
if (gt == 255 || gt == 0 || gt == 254) // Single gender/genderless if (gt == 255 || gt == 0 || gt == 254) // Single gender/genderless
return; return;
@ -1920,7 +1916,8 @@ namespace PKHeX
// Get Gender Threshold // Get Gender Threshold
species = Util.getIndex(CB_Species); species = Util.getIndex(CB_Species);
PKX.PersonalParser.Personal MonData = PKX.PersonalGetter.GetPersonal(species); PKX.PersonalParser.Personal MonData = PKX.PersonalGetter.GetPersonal(species);
gt = MonData.GenderRatio; int gt = MonData.GenderRatio;
int genderflag;
if (gt == 255) // Genderless if (gt == 255) // Genderless
genderflag = 2; genderflag = 2;
@ -2207,7 +2204,7 @@ namespace PKHeX
private void updateStats() private void updateStats()
{ {
// Gather the needed information. // Gather the needed information.
species = Util.getIndex(CB_Species); int species = Util.getIndex(CB_Species);
int level = Util.ToInt32((MT_Level.Enabled) ? MT_Level.Text : TB_Level.Text); int level = Util.ToInt32((MT_Level.Enabled) ? MT_Level.Text : TB_Level.Text);
if (level == 0) { level = 1; } if (level == 0) { level = 1; }
int form = CB_Form.SelectedIndex; int form = CB_Form.SelectedIndex;
@ -2621,10 +2618,7 @@ namespace PKHeX
// Dragout Display // Dragout Display
private void dragoutHover(object sender, EventArgs e) private void dragoutHover(object sender, EventArgs e)
{ {
if (Util.getIndex(CB_Species) > 0) dragout.BackgroundImage = (Util.getIndex(CB_Species) > 0) ? Properties.Resources.slotSet : Properties.Resources.slotDel;
dragout.BackgroundImage = Properties.Resources.slotSet;
else
dragout.BackgroundImage = Properties.Resources.slotDel;
} }
private void dragoutLeave(object sender, EventArgs e) private void dragoutLeave(object sender, EventArgs e)
{ {
@ -2642,7 +2636,7 @@ namespace PKHeX
{ {
if (savedited) if (savedited)
{ {
RTB_S.Text = "Save has been edited. Cannot integrity check."; Util.Alert("Save has been edited. Cannot integrity check.");
return; return;
} }
// Verify Checksums // Verify Checksums
@ -3236,15 +3230,11 @@ namespace PKHeX
// Box/SAV Functions // // Box/SAV Functions //
private void clickBoxRight(object sender, EventArgs e) private void clickBoxRight(object sender, EventArgs e)
{ {
if (C_BoxSelect.SelectedIndex < 30) C_BoxSelect.SelectedIndex = (C_BoxSelect.SelectedIndex + 1) % 31;
C_BoxSelect.SelectedIndex++;
else C_BoxSelect.SelectedIndex = 0;
} }
private void clickBoxLeft(object sender, EventArgs e) private void clickBoxLeft(object sender, EventArgs e)
{ {
if (C_BoxSelect.SelectedIndex > 0) C_BoxSelect.SelectedIndex = (C_BoxSelect.SelectedIndex + 30) % 31;
C_BoxSelect.SelectedIndex--;
else C_BoxSelect.SelectedIndex = 30;
} }
private void clickSlot(object sender, EventArgs e) private void clickSlot(object sender, EventArgs e)
{ {
@ -3562,24 +3552,15 @@ namespace PKHeX
dcpkx1, dcpkx2, gtspkx, fusedpkx,subepkx1,subepkx2,subepkx3, dcpkx1, dcpkx2, gtspkx, fusedpkx,subepkx1,subepkx2,subepkx3,
}; };
for (int i = 0; i < 30; i++) for (int i = 0; i < 30; i++)
{ getSlotFiller(boxoffset + 0xE8 * i, pba[i]);
int offset = boxoffset + 0xE8 * i;
getSlotFiller(offset, pba[i]);
}
// Reload Party // Reload Party
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
{ getSlotFiller(SaveGame.Party + (0x7F000 * savindex) + 0x104 * i, pba[i + 30]);
int offset = SaveGame.Party + (0x7F000 * savindex) + 0x104 * i;
getSlotFiller(offset, pba[i + 30]);
}
// Reload Battle Box // Reload Battle Box
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
{ getSlotFiller(SaveGame.BattleBox + (0x7F000 * savindex) + 0xE8 * i, pba[i + 36]);
int offset = SaveGame.BattleBox + (0x7F000 * savindex) + 0xE8 * i;
getSlotFiller(offset, pba[i + 36]);
}
// Reload Daycare // Reload Daycare
Label[] dclabela = { L_DC1, L_DC2, }; Label[] dclabela = { L_DC1, L_DC2, };
@ -3587,8 +3568,7 @@ namespace PKHeX
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
int offset = SaveGame.Daycare + (0x7F000 * savindex) + 0xE8 * i + 8 * (i + 1); getSlotFiller(SaveGame.Daycare + (0x7F000 * savindex) + 0xE8 * i + 8 * (i + 1), pba[i + 42]);
getSlotFiller(offset, pba[i + 42]);
dctexta[i].Text = BitConverter.ToUInt32(savefile, SaveGame.Daycare + (0x7F000 * savindex) + 0xF0 * i + 4).ToString(); dctexta[i].Text = BitConverter.ToUInt32(savefile, SaveGame.Daycare + (0x7F000 * savindex) + 0xF0 * i + 4).ToString();
if (Convert.ToBoolean(savefile[SaveGame.Daycare + (0x7F000 * savindex) + 0xF0 * i])) // If Occupied if (Convert.ToBoolean(savefile[SaveGame.Daycare + (0x7F000 * savindex) + 0xF0 * i])) // If Occupied
dclabela[i].Text = (i + 1) + ": ✓"; dclabela[i].Text = (i + 1) + ": ✓";
@ -4185,7 +4165,7 @@ namespace PKHeX
private void B_OUTPasserby_Click(object sender, EventArgs e) private void B_OUTPasserby_Click(object sender, EventArgs e)
{ {
string result = ""; string result = "";
result += "PSS List" + Environment.NewLine + Environment.NewLine; result += "PSS List" + Environment.NewLine;
string[] headers = { string[] headers = {
"PSS Data - Friends", "PSS Data - Friends",
"PSS Data - Acquaintances", "PSS Data - Acquaintances",
@ -4194,14 +4174,18 @@ namespace PKHeX
int offset = savindex * 0x7F000 + SaveGame.PSS; int offset = savindex * 0x7F000 + SaveGame.PSS;
for (int g = 0; g < 3; g++) for (int g = 0; g < 3; g++)
{ {
result += "----" + Environment.NewLine + headers[g] + Environment.NewLine + "----" + Environment.NewLine + Environment.NewLine; result += Environment.NewLine
+ "----" + Environment.NewLine
+ headers[g] + Environment.NewLine
+ "----" + Environment.NewLine;
uint count = BitConverter.ToUInt32(savefile, offset + 0x4E20); uint count = BitConverter.ToUInt32(savefile, offset + 0x4E20);
int r_offset = offset; int r_offset = offset;
for (int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
{ {
ulong unkn = BitConverter.ToUInt64(savefile, r_offset); ulong unkn = BitConverter.ToUInt64(savefile, r_offset);
if (unkn == 0) break; if (unkn == 0) break; // No data present here
if (i > 0) result += Environment.NewLine + Environment.NewLine;
string otname = Util.TrimFromZero(Encoding.Unicode.GetString(savefile, r_offset + 8, 0x1A)); string otname = Util.TrimFromZero(Encoding.Unicode.GetString(savefile, r_offset + 8, 0x1A));
string message = Util.TrimFromZero(Encoding.Unicode.GetString(savefile, r_offset + 0x22, 0x22)); string message = Util.TrimFromZero(Encoding.Unicode.GetString(savefile, r_offset + 0x22, 0x22));
@ -4217,16 +4201,8 @@ namespace PKHeX
byte game = savefile[r_offset + 0x5A]; byte game = savefile[r_offset + 0x5A];
ulong outfit = BitConverter.ToUInt64(savefile, r_offset + 0x5C); ulong outfit = BitConverter.ToUInt64(savefile, r_offset + 0x5C);
int favpkm = BitConverter.ToUInt16(savefile, r_offset + 0x9C) & 0x7FF; int favpkm = BitConverter.ToUInt16(savefile, r_offset + 0x9C) & 0x7FF;
string gamename; string gamename = "UNKNOWN GAME";
if (game == 24) try { gamename = gamelist[game]; } catch { }
gamename = "X";
else if (game == 25)
gamename = "Y";
else if (game == 26)
gamename = "AS";
else if (game == 27)
gamename = "OR";
else gamename = "UNK GAME";
string[] cr = PKX.getCountryRegionText(country, region, curlanguage); string[] cr = PKX.getCountryRegionText(country, region, curlanguage);
result += result +=
@ -4235,12 +4211,11 @@ namespace PKHeX
"Game: " + gamename + Environment.NewLine + "Game: " + gamename + Environment.NewLine +
"Country: " + cr[0] + Environment.NewLine + "Country: " + cr[0] + Environment.NewLine +
"Region: " + cr[1] + Environment.NewLine + "Region: " + cr[1] + Environment.NewLine +
"Favorite: " + specieslist[favpkm] + Environment.NewLine; "Favorite: " + specieslist[favpkm];
result += Environment.NewLine; r_offset += 0xC8; // Advance to next entry
r_offset += 0xC8;
} }
offset += 0x5000; offset += 0x5000; // Advance to next block
} }
RTB_T.Text = result; RTB_T.Text = result;
RTB_T.Font = new Font("Courier New", 8); RTB_T.Font = new Font("Courier New", 8);