Properly differentiate between SW/SH

Previous implementation did not work correctly for LGPE. If someone wishes to merge the wild encounter buttons again, make sure it works for all games before submitting a pull request. Also fixes LGPE wild editor using small sprites.

Closes #110
This commit is contained in:
sora10pls
2021-03-04 14:43:21 -05:00
parent 15f45fafb6
commit d231a411a0
8 changed files with 21 additions and 34 deletions

View File

@@ -62,8 +62,7 @@ public static IReadOnlyCollection<GameFileReference> GetMapping(GameVersion game
GameVersion.UM => UM,
GameVersion.XY => XY,
GameVersion.GG => GG,
GameVersion.SW => SW,
GameVersion.SH => SH,
GameVersion.SWSH => SWSH,
GameVersion.ORASDEMO => AO,
GameVersion.ORAS => AO,
GameVersion.SMDEMO => SMDEMO,
@@ -344,12 +343,14 @@ public static IReadOnlyCollection<GameFileReference> GetMapping(GameVersion game
// Cutscenes bin\demo
// Models bin\archive\pokemon
// pretty much everything is obviously named :)
#endregion
};
#region Gen 8
/// <summary>
/// Sword
/// </summary>
private static readonly GameFileReference[] SW =
private static readonly GameFileReference[] SWSH =
{
new(GameFile.TrainerData, "bin", "trainer", "trainer_data"),
new(GameFile.TrainerPoke, "bin", "trainer", "trainer_poke"),
@@ -403,11 +404,6 @@ public static IReadOnlyCollection<GameFileReference> GetMapping(GameVersion game
// Models bin\archive\pokemon
// pretty much everything is obviously named :)
};
/// <summary>
/// Shield
/// </summary>
private static readonly GameFileReference[] SH = SW;
#endregion
#region Split Versions

View File

@@ -89,22 +89,16 @@ private static GameVersion GetGameFromCount(int fileCount, string romfs, string
return GameVersion.US;
return GameVersion.UM;
}
case FILECOUNT_GG:
return GameVersion.GG;
case FILECOUNT_SWSH:
case FILECOUNT_SWSH_1:
case FILECOUNT_SWSH_2:
return GameVersion.SW; // todo: differentiate between SW/SH
case FILECOUNT_SWSH_3:
{
// Unlike SM and USUM, the file structure between these two games are identical,
// so we identify the game by the size of the main binary.
var main = Path.Combine(exefs, "main");
if (new FileInfo(main).Length is 21163058 or 21163221) // 1.3.0 vs 1.3.1
return GameVersion.SW;
return GameVersion.SH;
}
return GameVersion.SWSH;
default:
return GameVersion.Invalid;
}

View File

@@ -114,8 +114,7 @@ public static GameManager GetManager(GameLocation loc, int language)
return loc.Game switch
{
GameVersion.GG => new GameManagerGG(loc, language),
GameVersion.SW => new GameManagerSWSH(loc, language),
GameVersion.SH => new GameManagerSWSH(loc, language),
GameVersion.SWSH => new GameManagerSWSH(loc, language),
_ => throw new ArgumentException(nameof(loc.Game))
};
}

View File

@@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using System.Linq;
using pkNX.Containers;
using pkNX.Structures;
@@ -8,19 +9,14 @@ namespace pkNX.Game
public class GameManagerGG : GameManager
{
public GameManagerGG(GameLocation rom, int language) : base(rom, language) { }
private GameVersion ActualGame;
public string TitleID => ActualGame == GameVersion.GP ? Pikachu : Eevee;
private const string Pikachu = "010003F003A34000";
private const string Eevee = "0100187003A36000";
private string Main => Path.Combine(PathExeFS, "main.npdm");
private GameVersion ActualGame => TitleID == "010003F003A34000" ? GameVersion.GP : GameVersion.GE;
private string TitleID => BitConverter.ToString(File.ReadAllBytes(Main).Skip(0x290).Take(0x08).Reverse().ToArray()).Replace("-", "");
protected override void SetMitm()
{
var basePath = Path.GetDirectoryName(ROM.RomFS);
var eeveevidpath = Path.Combine(ROM.RomFS, Path.Combine("bin", "movies", "EEVEE_GO"));
bool eevee = Directory.Exists(eeveevidpath);
ActualGame = eevee ? GameVersion.GE : GameVersion.GP;
var redirect = Path.Combine(basePath, TitleID);
// get pikachu vs eevee
FileMitm.SetRedirect(basePath, redirect);
}

View File

@@ -9,9 +9,9 @@ namespace pkNX.Game
public class GameManagerSWSH : GameManager
{
public GameManagerSWSH(GameLocation rom, int language) : base(rom, language) { }
public string TitleID => Game == GameVersion.SW ? Sword : Shield;
private const string Sword = "0100ABF008968000";
private const string Shield = "01008DB008C2C000";
private string Main => Path.Combine(PathExeFS, "main.npdm");
private GameVersion ActualGame => TitleID == "0100ABF008968000" ? GameVersion.SW : GameVersion.SH;
private string TitleID => BitConverter.ToString(File.ReadAllBytes(Main).Skip(0x290).Take(0x08).Reverse().ToArray()).Replace("-", "");
protected override void SetMitm()
{

View File

@@ -126,7 +126,7 @@ public static int GetMaxSpeciesID(this GameVersion game)
if (Gen4.Contains(game)) return 493;
if (Gen5.Contains(game)) return 649;
if (Gen6.Contains(game)) return Legal.MaxSpeciesID_6;
if (Gen7.Contains(game))
if (Gen7.Contains(game) || Gen7b.Contains(game))
{
if (SM.Contains(game))
return 802;

View File

@@ -218,7 +218,8 @@ void Randomize()
file[0] = objs.SelectMany(z => z.Write()).ToArray();
}
public void EditWild() => PopWildEdit(Game == GameVersion.GP ? GameFile.WildData1 : GameFile.WildData2);
public void EditWild_GP() => PopWildEdit(GameFile.WildData1);
public void EditWild_GE() => PopWildEdit(GameFile.WildData2);
private void PopWildEdit(GameFile type)
{

View File

@@ -186,7 +186,8 @@ public void NotWorking_EditTypeChart()
FileMitm.WriteAllBytes(path, data);
}
public void EditWild() => PopWildEdit(Game == GameVersion.SW ? "k" : "t");
public void EditWild_SW() => PopWildEdit("k");
public void EditWild_SH() => PopWildEdit("t");
private void PopWildEdit(string file)
{