Update gen4/5 map saving

Trainer Editor now only writes back coordinates if they were changed by
the user.
DP coordinate offsets for overworld data fixed.
PokeSAV didn't have Platinum overworld offsets programmed, so I had to
figure those out myself.
This commit is contained in:
Kurt 2016-12-31 15:45:04 -08:00
parent 7a4dcf0a3a
commit 1c1b90cd38
3 changed files with 45 additions and 37 deletions

View file

@ -447,7 +447,7 @@ namespace PKHeX
int ofs = 0; int ofs = 0;
switch (Version) switch (Version)
{ {
case GameVersion.DP: case GameVersion.DP: ofs = 0x1238; break;
case GameVersion.HGSS: ofs = 0x1234; break; case GameVersion.HGSS: ofs = 0x1234; break;
case GameVersion.Pt: ofs = 0x1280; break; case GameVersion.Pt: ofs = 0x1280; break;
} }
@ -459,7 +459,7 @@ namespace PKHeX
int ofs = 0; int ofs = 0;
switch (Version) switch (Version)
{ {
case GameVersion.DP: case GameVersion.DP: ofs = 0x1238; break;
case GameVersion.HGSS: ofs = 0x1234; break; case GameVersion.HGSS: ofs = 0x1234; break;
case GameVersion.Pt: ofs = 0x1280; break; case GameVersion.Pt: ofs = 0x1280; break;
} }
@ -483,22 +483,16 @@ namespace PKHeX
} }
set set
{ {
int ofs = 0; int ofs = 0; int ofs2 = 0;
switch (Version) switch (Version)
{ {
case GameVersion.DP: ofs = 0x25FA; break; case GameVersion.DP: ofs = 0x25FA; ofs2 = 0x1240; break;
case GameVersion.Pt: ofs = 0x287E; break; case GameVersion.Pt: ofs = 0x287E; ofs2 = 0x1288; break;
case GameVersion.HGSS: ofs = 0x236E; break; case GameVersion.HGSS: ofs = 0x236E; ofs2 = 0x123C; break;
} }
ofs += GBO; ofs += GBO; ofs2 += GBO;
BitConverter.GetBytes((ushort)value).CopyTo(Data, ofs); BitConverter.GetBytes((ushort)value).CopyTo(Data, ofs);
switch (Version) BitConverter.GetBytes((ushort)value).CopyTo(Data, ofs2);
{
case GameVersion.DP:
case GameVersion.HGSS:
BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x123C + GBO);
break;
}
} }
} }
public int Z public int Z
@ -544,22 +538,16 @@ namespace PKHeX
} }
set set
{ {
int ofs = 0; int ofs = 0; int ofs2 = 0;
switch (Version) switch (Version)
{ {
case GameVersion.DP: ofs = 0x25FE; break; case GameVersion.DP: ofs = 0x25FE; ofs2 = 0x1244; break;
case GameVersion.Pt: ofs = 0x2882; break; case GameVersion.Pt: ofs = 0x2882; ofs2 = 0x128C; break;
case GameVersion.HGSS: ofs = 0x2372; break; case GameVersion.HGSS: ofs = 0x2372; ofs2 = 0x1240; break;
} }
ofs += GBO; ofs += GBO; ofs2 += GBO;
BitConverter.GetBytes((ushort)value).CopyTo(Data, ofs); BitConverter.GetBytes((ushort)value).CopyTo(Data, ofs);
switch (Version) BitConverter.GetBytes((ushort)value).CopyTo(Data, ofs2);
{
case GameVersion.DP:
case GameVersion.HGSS:
BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1240 + GBO);
break;
}
} }
} }
public override int SecondsToStart { get { return BitConverter.ToInt32(Data, AdventureInfo + 0x34); } set { BitConverter.GetBytes(value).CopyTo(Data, AdventureInfo + 0x34); } } public override int SecondsToStart { get { return BitConverter.ToInt32(Data, AdventureInfo + 0x34); } set { BitConverter.GetBytes(value).CopyTo(Data, AdventureInfo + 0x34); } }

View file

@ -353,7 +353,7 @@
this.GB_Map.Controls.Add(this.L_CurrentMap); this.GB_Map.Controls.Add(this.L_CurrentMap);
this.GB_Map.Controls.Add(this.L_Z); this.GB_Map.Controls.Add(this.L_Z);
this.GB_Map.Controls.Add(this.L_X); this.GB_Map.Controls.Add(this.L_X);
this.GB_Map.Location = new System.Drawing.Point(217, 100); this.GB_Map.Location = new System.Drawing.Point(217, 98);
this.GB_Map.Name = "GB_Map"; this.GB_Map.Name = "GB_Map";
this.GB_Map.Size = new System.Drawing.Size(157, 125); this.GB_Map.Size = new System.Drawing.Size(157, 125);
this.GB_Map.TabIndex = 71; this.GB_Map.TabIndex = 71;
@ -376,6 +376,7 @@
this.NUD_Z.Name = "NUD_Z"; this.NUD_Z.Name = "NUD_Z";
this.NUD_Z.Size = new System.Drawing.Size(50, 20); this.NUD_Z.Size = new System.Drawing.Size(50, 20);
this.NUD_Z.TabIndex = 53; this.NUD_Z.TabIndex = 53;
this.NUD_Z.ValueChanged += new System.EventHandler(this.changeMapValue);
// //
// NUD_M // NUD_M
// //
@ -388,6 +389,7 @@
this.NUD_M.Name = "NUD_M"; this.NUD_M.Name = "NUD_M";
this.NUD_M.Size = new System.Drawing.Size(50, 20); this.NUD_M.Size = new System.Drawing.Size(50, 20);
this.NUD_M.TabIndex = 52; this.NUD_M.TabIndex = 52;
this.NUD_M.ValueChanged += new System.EventHandler(this.changeMapValue);
// //
// NUD_Y // NUD_Y
// //
@ -400,6 +402,7 @@
this.NUD_Y.Name = "NUD_Y"; this.NUD_Y.Name = "NUD_Y";
this.NUD_Y.Size = new System.Drawing.Size(50, 20); this.NUD_Y.Size = new System.Drawing.Size(50, 20);
this.NUD_Y.TabIndex = 51; this.NUD_Y.TabIndex = 51;
this.NUD_Y.ValueChanged += new System.EventHandler(this.changeMapValue);
// //
// NUD_X // NUD_X
// //
@ -412,6 +415,7 @@
this.NUD_X.Name = "NUD_X"; this.NUD_X.Name = "NUD_X";
this.NUD_X.Size = new System.Drawing.Size(50, 20); this.NUD_X.Size = new System.Drawing.Size(50, 20);
this.NUD_X.TabIndex = 50; this.NUD_X.TabIndex = 50;
this.NUD_X.ValueChanged += new System.EventHandler(this.changeMapValue);
// //
// L_Y // L_Y
// //
@ -716,7 +720,7 @@
this.GB_Options.Controls.Add(this.LBL_BattleStyle); this.GB_Options.Controls.Add(this.LBL_BattleStyle);
this.GB_Options.Controls.Add(this.CB_BattleStyle); this.GB_Options.Controls.Add(this.CB_BattleStyle);
this.GB_Options.Controls.Add(this.CHK_BattleEffects); this.GB_Options.Controls.Add(this.CHK_BattleEffects);
this.GB_Options.Location = new System.Drawing.Point(217, 99); this.GB_Options.Location = new System.Drawing.Point(217, 98);
this.GB_Options.Name = "GB_Options"; this.GB_Options.Name = "GB_Options";
this.GB_Options.Size = new System.Drawing.Size(157, 125); this.GB_Options.Size = new System.Drawing.Size(157, 125);
this.GB_Options.TabIndex = 72; this.GB_Options.TabIndex = 72;

View file

@ -8,6 +8,7 @@ namespace PKHeX
{ {
public SAV_SimpleTrainer() public SAV_SimpleTrainer()
{ {
Loading = true;
InitializeComponent(); InitializeComponent();
Util.TranslateInterface(this, Main.curlanguage); Util.TranslateInterface(this, Main.curlanguage);
@ -101,10 +102,13 @@ namespace PKHeX
if (SAV is SAV4) if (SAV is SAV4)
{ {
SAV4 s = (SAV4)SAV; SAV4 s = (SAV4)SAV;
NUD_M.Value = s.M; if (MapUpdated)
NUD_X.Value = s.X; {
NUD_Z.Value = s.Z; NUD_M.Value = s.M;
NUD_Y.Value = s.Y; NUD_X.Value = s.X;
NUD_Z.Value = s.Z;
NUD_Y.Value = s.Y;
}
badgeval = s.Badges; badgeval = s.Badges;
if (s.Version == GameVersion.HGSS) if (s.Version == GameVersion.HGSS)
@ -116,10 +120,13 @@ namespace PKHeX
else if (SAV is SAV5) else if (SAV is SAV5)
{ {
SAV5 s = (SAV5)SAV; SAV5 s = (SAV5)SAV;
NUD_M.Value = s.M; if (MapUpdated)
NUD_X.Value = s.X; {
NUD_Z.Value = s.Z; NUD_M.Value = s.M;
NUD_Y.Value = s.Y; NUD_X.Value = s.X;
NUD_Z.Value = s.Z;
NUD_Y.Value = s.Y;
}
badgeval = s.Badges; badgeval = s.Badges;
} }
@ -134,10 +141,14 @@ namespace PKHeX
CAL_HoFTime.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToFame % 86400); CAL_HoFTime.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToFame % 86400);
CAL_AdventureStartDate.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToStart); CAL_AdventureStartDate.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToStart);
CAL_AdventureStartTime.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToStart % 86400); CAL_AdventureStartTime.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToStart % 86400);
Loading = false;
} }
private readonly CheckBox[] cba; private readonly CheckBox[] cba;
private readonly SaveFile SAV = Main.SAV.Clone(); private readonly SaveFile SAV = Main.SAV.Clone();
private readonly bool Loading;
private bool MapUpdated;
private void changeFFFF(object sender, EventArgs e) private void changeFFFF(object sender, EventArgs e)
{ {
MaskedTextBox box = sender as MaskedTextBox; MaskedTextBox box = sender as MaskedTextBox;
@ -228,5 +239,10 @@ namespace PKHeX
val += (int)(time.Value - new DateTime(2000, 1, 1)).TotalSeconds; val += (int)(time.Value - new DateTime(2000, 1, 1)).TotalSeconds;
return val; return val;
} }
private void changeMapValue(object sender, EventArgs e)
{
if (!Loading)
MapUpdated = true;
}
} }
} }