OpenSimTools / AMS2CM

Automobilista 2 Content Manager
https://www.racedepartment.com/downloads/automobilista-2-content-manager.59727/
MIT License
36 stars 3 forks source link

Extract bootfiles from game #6

Closed paoloambrosio closed 1 year ago

paoloambrosio commented 1 year ago

If any mod has config to be applied and no __bootfiles* "mod" has been installed

Still relevant for tracks after AMS2 1.5, but not for cars (see development update):

There is a lot more to be said about V1.5 beyond physics - among other highlights, we are pushing for a solution to lift the need to use Bootfiles for mod installation and possibly lifting some other hurdles based on feedback being received on this topic to better support the great modding projects already being delivered for AMS2

paoloambrosio commented 1 year ago

Extracting pak files is very easy with PCarsTools. It would have to be published as a library though. License is the same as this project.

The original Pakfiles\BOOTFLOW.bff uses ZLib compression, so it does not require Oodle. The one in the bootfiles instead uses Mermaid.

paoloambrosio commented 1 year ago

The new Pakfiles\BOOTFLOW.bff must be there because the Madness Engine looks for it, but it can be a completely empty bff (with no files inside)!!!

" KAP"
uint32: 1 << 11 | 1
int32: 0
byte[12]
byte[0x100]: BOOTSPLASH\0...\0
uint32: 0
uint32: 0
uint32: 0
byte[8]
byte: 0
byte: 0
byte[2]

Code

using System;
using System.IO;
using System.Text;

namespace BootfileCreator
{
    internal class Program
    {
        private const string fileTag = " KAP";
        private const uint version = 1 << 11 | 1;
        private const uint fileCount = 0;

        private const string fileName = "BOOTSPLASH";

        private const uint tocEntrySize = 16; // Required or PCarsTools will fail
        private const uint crc = 0;
        private const uint extInfoSize = 0x308; // Required for cert size even with no encryption

        private const byte flags = 0;
        private const byte encryptionType = 0;

        static void Main(string[] args)
        {
            var writer = new BinaryWriter(File.Create("EMPTY.bff"));
            writer.Write(fileTag.ToCharArray());
            writer.Write(version);
            writer.Write(fileCount);
            writer.Write(new byte[12]);
            writer.Write(fileName.ToCharArray());
            writer.Write(new byte[0x100-fileName.Length]);
            writer.Write(tocEntrySize);
            writer.Write(crc);
            writer.Write(extInfoSize);
            writer.Write(new byte[8]);
            writer.Write(flags);
            writer.Write(encryptionType);
            writer.Write(new byte[2]);
            writer.Write(new byte[tocEntrySize]);
            writer.Write(new byte[extInfoSize]);
        }
    }
}