kwsch / PKHeX

Pokémon Save File Editor
https://projectpokemon.org/pkhex/
Other
3.73k stars 700 forks source link

How to open the .pkl file and edit it? #3021

Closed CScorpion-h closed 4 years ago

CScorpion-h commented 4 years ago

I try to use the pickle, but it doesn't work.

kwsch commented 4 years ago

Why do you want to modify the Pokémon Legality binaries?

CScorpion-h commented 4 years ago

Why do you want to modify the Pokémon Legality binaries?

Add the Ash's Charizard and Mewtwo. And because I want to learn so that I can contribute,

kwsch commented 4 years ago

Event .pkl files are just concatenated files. For wc8.pkl, you just concatenate every wc8 file from the event gallery. Every other pkl file (not events) is a Mini packed file.

If you want to see how the files are read into the program, you can search for the filenames in the source code and follow the logic that converts them into objects.

There isn't a need to update these files except for releases, for which I already have a script to regenerate the binaries. The mgdb folder already allows for people to expand the event data between releases. I don't want to trigger new commits & builds each time the Event Gallery has an update.

CScorpion-h commented 4 years ago

Event .pkl files are just concatenated files. For wc8.pkl, you just concatenate every wc8 file from the event gallery. Every other pkl file (not events) is a Mini packed file.

If you want to see how the files are read into the program, you can search for the filenames in the source code and follow the logic that converts them into objects.

There isn't a need to update these files except for releases, for which I already have a script to regenerate the binaries. The mgdb folder already allows for people to expand the event data between releases. I don't want to trigger new commits & builds each time the Event Gallery has an update.

Could you tell me if you use python to create pkl files? I want to know what is the .pkl, I've never seen it before. Thanks.

kwsch commented 4 years ago

I can name the files that I create whatever extension I want; it is only a coincidence that the pkl extension is also used by python pickle.

The wild ones are generated via https://github.com/kwsch/PKHeX.EncounterSlotDumper The event dbs are generated via this method, just combining files:

void BinFiles(string[] files, string outfile, string ext)
{
    var iterate = files.Where(z => new FileInfo(z).Extension.EndsWith(ext));
    iterate = iterate.Where(z => !z.Contains("Unreleased"));

    // create/clear file
    File.WriteAllBytes(outfile, new byte[0]);   
    using (var stream = new FileStream(outfile, FileMode.Append))
    {
        foreach (var f in iterate)
        {
            byte[] bytes = File.ReadAllBytes(f);
            stream.Write(bytes, 0, bytes.Length);
        }        
    }
}
CScorpion-h commented 4 years ago

Oh, so that's it. Thank you for your help.