retreev / PangLib

Series of tools to interact with Pangya PC MMO game files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JP IFF files are not working - System.InvalidCastException

aleksandarstojkovski opened this issue · comments

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

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!