Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JP IFF files are not working - System.InvalidCastException #36

Open
aleksandarstojkovski opened this issue Aug 10, 2022 · 1 comment
Open

Comments

@aleksandarstojkovski
Copy link

aleksandarstojkovski commented Aug 10, 2022

Description: I am trying to load a Caddie.iff (from pangya_jp).

  • Binding ID: 0
  • Version: 13

Problem: I get "System.InvalidCastException: 'The record length (248) mismatches the length of the passed structure (260)'"

Code snippet used:

static int Main(String[] args)
{

    IFFFile<Caddie> IFF = new IFFFile<Caddie>(File.Open("Caddie.iff", FileMode.Open));

    Console.ReadKey();

    return 0;

}

Here the Caddie.iff file I am trying to load: Caddie.zip

@aleksandarstojkovski aleksandarstojkovski changed the title JP IFF files are not working JP IFF files are not working - System.InvalidCastException Aug 10, 2022
@pixeldesu
Copy link
Member

pixeldesu commented Aug 10, 2022

I'm pretty sure the IFF file model I built that's present in the library is for US data models only, so the error you are getting makes sense.

The error says that the structure present in the IFF file you have is only 248 bytes long, but the one we have a model of is 260 bytes of data, so it cannot cast the file content into the struct.

I could implement the other models as well, but that's too much work for me. As a fix you can implement your own struct type MyCaddie or alike and use it with the generic IFFFile instead.

ex. (obviously does not work)

public struct MyCaddie
{
  public ushort Some { get; set; }
  public ushort Custom { get; set; }
  public ushort Values { get; set; }
}

IFFFile<MyCaddie> IFF = new IFFFile<MyCaddie>(File.Open("Caddie.iff", FileMode.Open));

I wrote the class in such a way that developers can supply their own models.

You could take a look at how https://github.com/retreev/PangLib/blob/master/PangLib.IFF/Models/Data/Caddie.cs is composed and see if someone else documented how a JP caddie is made up, otherwise you could also use this as an exercise to figure it out yourself!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants