Remove unnecessary sub-classes

Structures was originally intended to be a big class but that'd be way
too messy.
This commit is contained in:
Kurt
2015-10-04 16:58:17 -07:00
parent b9fdaf5109
commit ded26dccb7
2 changed files with 127 additions and 133 deletions

View File

@@ -548,148 +548,142 @@ internal static uint getRandomPID(int species, int cg)
return pid;
}
#region SaveGame
public class Structures
public class SaveGame
{
public struct SaveGame
public class Inventory
{
public class Inventory
{
public int HeldItem, KeyItem, Medicine, TMHM, Berry;
public Inventory(string GameID, int Offset)
{
switch (GameID)
{
case "XY":
HeldItem = Offset + 0;
KeyItem = Offset + 0x640;
TMHM = Offset + 0x7C0;
Medicine = Offset + 0x968;
Berry = Offset + 0xA68;
break;
case "ORAS":
HeldItem = Offset + 0;
KeyItem = Offset + 0x640;
TMHM = Offset + 0x7C0;
Medicine = Offset + 0x970;
Berry = Offset + 0xA70;
break;
default:
HeldItem = KeyItem = TMHM = Medicine = Berry = 0;
break;
}
}
}
public int Box, TrainerCard, Party, BattleBox, GTS, Daycare, EonTicket,
Fused, SUBE, Puff, Item, Trainer1, Trainer2, SuperTrain, PSSStats, MaisonStats, Vivillon, SecretBase,
PCLayout, PCBackgrounds, PCFlags, WondercardFlags, WondercardData, BerryField, OPower, EventConst, EventFlag, EventAsh,
PokeDex, PokeDexLanguageFlags, Spinda, EncounterCount, HoF, PSS, JPEG;
public Inventory Items;
public string Name;
public int[] DaycareSlot;
public bool ORAS;
public SaveGame(string GameID)
public int HeldItem, KeyItem, Medicine, TMHM, Berry;
public Inventory(string GameID, int Offset)
{
switch (GameID)
{
case "XY":
Name = "XY";
ORAS = false;
Box = 0x22600;
TrainerCard = 0x14000;
Party = 0x14200;
BattleBox = 0x04A00;
Daycare = 0x1B200;
GTS = 0x17800;
Fused = 0x16000;
SUBE = 0x1D890;
Puff = 0x00000;
Item = 0x00400;
Items = new Inventory(Name, Item);
Trainer1 = 0x1400;
Trainer2 = 0x4200;
PCLayout = 0x4400;
PCBackgrounds = PCLayout + 0x41E;
PCFlags = PCLayout + 0x43D;
WondercardFlags = 0x1BC00;
WondercardData = WondercardFlags + 0x100;
BerryField = 0x1B800;
OPower = 0x16A00;
EventConst = 0x14A00;
EventAsh = -1;
EventFlag = EventConst + 0x2FC;
PokeDex = 0x15000;
PokeDexLanguageFlags = PokeDex + 0x3C8;
Spinda = PokeDex + 0x648;
EncounterCount = -1;
HoF = 0x19400;
SuperTrain = 0x1F200;
JPEG = 0x57200;
MaisonStats = 0x1B1C0;
PSS = 0x05000;
PSSStats = 0x1E400;
Vivillon = 0x4250;
SecretBase = -1;
EonTicket = -1;
HeldItem = Offset + 0;
KeyItem = Offset + 0x640;
TMHM = Offset + 0x7C0;
Medicine = Offset + 0x968;
Berry = Offset + 0xA68;
break;
case "ORAS":
Name = "ORAS";
ORAS = true;
Box = 0x33000; // Confirmed
TrainerCard = 0x14000; // Confirmed
Party = 0x14200; // Confirmed
BattleBox = 0x04A00;// Confirmed
Daycare = 0x1BC00; // Confirmed (thanks Rei)
GTS = 0x18200; // Confirmed
Fused = 0x16A00; // Confirmed
SUBE = 0x1D890; // ****not in use, not updating?****
Puff = 0x00000; // Confirmed
Item = 0x00400; // Confirmed
Items = new Inventory(Name, Item);
Trainer1 = 0x01400; // Confirmed
Trainer2 = 0x04200; // Confirmed
PCLayout = 0x04400; // Confirmed
PCBackgrounds = PCLayout + 0x41E;
PCFlags = PCLayout + 0x43D;
WondercardFlags = 0x1CC00; // Confirmed
WondercardData = WondercardFlags + 0x100;
BerryField = 0x1C400; // ****changed****
OPower = 0x17400; // ****changed****
EventConst = 0x14A00;
EventAsh = EventConst + 0x78;
EventFlag = EventConst + 0x2FC;
PokeDex = 0x15000;
Spinda = PokeDex + 0x680;
EncounterCount = PokeDex + 0x686;
PokeDexLanguageFlags = PokeDex + 0x400;
HoF = 0x19E00; // Confirmed
SuperTrain = 0x20200;
JPEG = 0x67C00; // Confirmed
MaisonStats = 0x1BBC0;
PSS = 0x05000; // Confirmed (thanks Rei)
PSSStats = 0x1F400;
Vivillon = 0x4244;
SecretBase = 0x23A00;
EonTicket = 0x319B8;
HeldItem = Offset + 0;
KeyItem = Offset + 0x640;
TMHM = Offset + 0x7C0;
Medicine = Offset + 0x970;
Berry = Offset + 0xA70;
break;
default:
Box = TrainerCard = Party = BattleBox = GTS = Daycare =
Fused = SUBE = Puff = Item = Trainer1 = Trainer2 = SecretBase = EonTicket =
PCLayout = PCBackgrounds = PCFlags = WondercardFlags = WondercardData = BerryField = OPower = SuperTrain = MaisonStats = PSSStats = Vivillon =
EventConst = EventAsh = EventFlag = PokeDex = PokeDexLanguageFlags = Spinda = EncounterCount = HoF = PSS = JPEG = 0;
Name = "Unknown";
ORAS = false;
Items = new Inventory(Name, Item);
HeldItem = KeyItem = TMHM = Medicine = Berry = 0;
break;
}
DaycareSlot = new[] { Daycare, Daycare + 0x1F0 };
}
}
public int Box, TrainerCard, Party, BattleBox, GTS, Daycare, EonTicket,
Fused, SUBE, Puff, Item, Trainer1, Trainer2, SuperTrain, PSSStats, MaisonStats, Vivillon, SecretBase,
PCLayout, PCBackgrounds, PCFlags, WondercardFlags, WondercardData, BerryField, OPower, EventConst, EventFlag, EventAsh,
PokeDex, PokeDexLanguageFlags, Spinda, EncounterCount, HoF, PSS, JPEG;
public Inventory Items;
public string Name;
public int[] DaycareSlot;
public bool ORAS;
public SaveGame(string GameID)
{
switch (GameID)
{
case "XY":
Name = "XY";
ORAS = false;
Box = 0x22600;
TrainerCard = 0x14000;
Party = 0x14200;
BattleBox = 0x04A00;
Daycare = 0x1B200;
GTS = 0x17800;
Fused = 0x16000;
SUBE = 0x1D890;
Puff = 0x00000;
Item = 0x00400;
Items = new Inventory(Name, Item);
Trainer1 = 0x1400;
Trainer2 = 0x4200;
PCLayout = 0x4400;
PCBackgrounds = PCLayout + 0x41E;
PCFlags = PCLayout + 0x43D;
WondercardFlags = 0x1BC00;
WondercardData = WondercardFlags + 0x100;
BerryField = 0x1B800;
OPower = 0x16A00;
EventConst = 0x14A00;
EventAsh = -1;
EventFlag = EventConst + 0x2FC;
PokeDex = 0x15000;
PokeDexLanguageFlags = PokeDex + 0x3C8;
Spinda = PokeDex + 0x648;
EncounterCount = -1;
HoF = 0x19400;
SuperTrain = 0x1F200;
JPEG = 0x57200;
MaisonStats = 0x1B1C0;
PSS = 0x05000;
PSSStats = 0x1E400;
Vivillon = 0x4250;
SecretBase = -1;
EonTicket = -1;
break;
case "ORAS":
Name = "ORAS";
ORAS = true;
Box = 0x33000; // Confirmed
TrainerCard = 0x14000; // Confirmed
Party = 0x14200; // Confirmed
BattleBox = 0x04A00;// Confirmed
Daycare = 0x1BC00; // Confirmed (thanks Rei)
GTS = 0x18200; // Confirmed
Fused = 0x16A00; // Confirmed
SUBE = 0x1D890; // ****not in use, not updating?****
Puff = 0x00000; // Confirmed
Item = 0x00400; // Confirmed
Items = new Inventory(Name, Item);
Trainer1 = 0x01400; // Confirmed
Trainer2 = 0x04200; // Confirmed
PCLayout = 0x04400; // Confirmed
PCBackgrounds = PCLayout + 0x41E;
PCFlags = PCLayout + 0x43D;
WondercardFlags = 0x1CC00; // Confirmed
WondercardData = WondercardFlags + 0x100;
BerryField = 0x1C400; // ****changed****
OPower = 0x17400; // ****changed****
EventConst = 0x14A00;
EventAsh = EventConst + 0x78;
EventFlag = EventConst + 0x2FC;
PokeDex = 0x15000;
Spinda = PokeDex + 0x680;
EncounterCount = PokeDex + 0x686;
PokeDexLanguageFlags = PokeDex + 0x400;
HoF = 0x19E00; // Confirmed
SuperTrain = 0x20200;
JPEG = 0x67C00; // Confirmed
MaisonStats = 0x1BBC0;
PSS = 0x05000; // Confirmed (thanks Rei)
PSSStats = 0x1F400;
Vivillon = 0x4244;
SecretBase = 0x23A00;
EonTicket = 0x319B8;
break;
default:
Box = TrainerCard = Party = BattleBox = GTS = Daycare =
Fused = SUBE = Puff = Item = Trainer1 = Trainer2 = SecretBase = EonTicket =
PCLayout = PCBackgrounds = PCFlags = WondercardFlags = WondercardData = BerryField = OPower = SuperTrain = MaisonStats = PSSStats = Vivillon =
EventConst = EventAsh = EventFlag = PokeDex = PokeDexLanguageFlags = Spinda = EncounterCount = HoF = PSS = JPEG = 0;
Name = "Unknown";
ORAS = false;
Items = new Inventory(Name, Item);
break;
}
DaycareSlot = new[] { Daycare, Daycare + 0x1F0 };
}
}
#endregion
// SAV Manipulation
/// <summary>Calculates the CRC16-CCITT checksum.</summary>

View File

@@ -187,7 +187,7 @@ public Main()
#region Global Variables: Always Visible!
public static PK6 pk6 = new PK6(new byte[260]); // Tab Pokemon Data Storage
public static byte[] savefile = new byte[0x760000]; // required to initialize the program
public static PKX.Structures.SaveGame SaveGame = new PKX.Structures.SaveGame("ORAS");
public static PKX.SaveGame SaveGame = new PKX.SaveGame("ORAS");
public static byte[] originalSAV; // original save
public static byte[] powersave; // raw Powersave file
public static byte[] ramsav;
@@ -606,7 +606,7 @@ private void openMAIN(byte[] input, string path, string GameType, bool oras, boo
{
ramsavloaded = ram;
L_Save.Text = "SAV: " + Path.GetFileName(path);
SaveGame = new PKX.Structures.SaveGame(GameType);
SaveGame = new PKX.SaveGame(GameType);
// Load CyberGadget
savefile = input;
@@ -620,7 +620,7 @@ private void open1MB(byte[] input, string path, string GameType, bool oras)
{
ramsavloaded = false;
L_Save.Text = "SAV: " + Path.GetFileName(path);
SaveGame = new PKX.Structures.SaveGame(GameType);
SaveGame = new PKX.SaveGame(GameType);
powersave = input;
savefile = input.Skip(0x5400).Take(oras ? 0x76000 : 0x65600).ToArray();
@@ -2920,18 +2920,18 @@ private void getSAVOffsets(ref bool oras)
if (savefile.Length == 0x65600 && BitConverter.ToUInt32(savefile, savefile.Length - 0x1F0) == 0x42454546)
{
enableInterface = true;
SaveGame = new PKX.Structures.SaveGame("XY");
SaveGame = new PKX.SaveGame("XY");
}
else if (savefile.Length == 0x76000 && BitConverter.ToUInt32(savefile, savefile.Length - 0x1F0) == 0x42454546)
{
enableInterface = true;
SaveGame = new PKX.Structures.SaveGame("ORAS");
SaveGame = new PKX.SaveGame("ORAS");
oras = true;
}
else
{
Util.Error("Unrecognized Save File loaded.");
SaveGame = new PKX.Structures.SaveGame("Error");
SaveGame = new PKX.SaveGame("Error");
}
// Enable Buttons