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

Possible to overwrite files in the PCK? #25

Closed
ithinkandicode opened this issue Jan 24, 2023 · 4 comments
Closed

Possible to overwrite files in the PCK? #25

ithinkandicode opened this issue Jan 24, 2023 · 4 comments
Labels
question Further information is requested

Comments

@ithinkandicode
Copy link

ithinkandicode commented Jan 24, 2023

Is it possible to overwrite files if they already exist in the PCK?

It seems like the only option atm is to unpack to a new folder, add the edited file, then make a new pack from that folder's contents. So I was hoping there might be a way to skip the unpack-repack part of the process.

The use case is for adding a mod loader as an autoload, before any other autoloads, so if possible I'd like to streamline the install process for users, and without exposing the game's assets.

@ithinkandicode
Copy link
Author

ithinkandicode commented Jan 25, 2023

Edit: I was mistaken. I didn't realise that when you replace project.godot, you actually have to provide an binary version (project.binary). I was trying to provide the non-binary version (project.godot).

Is there a way to add a file without needing to use the binary version?

Or alternatively, how does one go about making a binary version that would be compatible with GodotPckTool? My current workflow is to export a PCK then unpack it with GodotPckTool to get the project binary, but I'm sure there's an easier way!

@hhyyrylainen
Copy link
Owner

Is there a way to add a file without needing to use the binary version?

This tool is designed for simplicity (it is used by https://github.com/Revolutionary-Games/Thrive-Launcher to be able to save on download size by reusing already downloaded content files). As such the tool doesn't understand any of the Godot internal formats so it isn't possible for it to generate a project file.

Or alternatively, how does one go about making a binary version that would be compatible with GodotPckTool? My current workflow is to export a PCK then unpack it with GodotPckTool to get the project binary, but I'm sure there's an easier way!

I think that's the easiest way. At least that's what I'd do if I needed to for example get an image converted to a Godot binary format. I'd create a new project where I import that image, then export that and extract it from the .pck file and copy it to the pack.

Overwriting files should be as simple as specifying a .pck file to repack and then specifying additional files on the command line. The tool shouldn't care if something already exists in the .pck file when adding new content and it should just replace anything that already exists.

@hhyyrylainen hhyyrylainen added the question Further information is requested label Jan 25, 2023
@ithinkandicode
Copy link
Author

ithinkandicode commented Jan 25, 2023

Thank you, that's incredibly helpful.

The modding team I'm working with found a good way to get the project.binary: we run a dumper script via the --script arg, which modifies the project settings with various ProjectSettings methods (.get_property_list, .get_setting, .set_setting) until they match what we need, then we use ProjectSetting.save_custom("project.binary") to save a customised version of the binary file. Ofc this only works for this specific file, but I'm mentioning it in case someone else has this very specific requirement too.

As such the tool doesn't understand any of the Godot internal formats so it isn't possible for it to generate a project file.

Ty, that makes sense. I think I misunderstood how PckTool was working. I'm used to GDRETools which outputs files like project.godot rather than project.binary. So I assumed that the file in the PCK was already project.godot and that PckTool was encrypting it or something. But actually, GDRETools decompiles those files for you, whereas PckTool just works with the files in the PCK as they are.

@hhyyrylainen
Copy link
Owner

Ty, that makes sense. I think I misunderstood how PckTool was working. I'm used to GDRETools which outputs files like project.godot rather than project.binary. So I assumed that the file in the PCK was already project.godot and that PckTool was encrypting it or something. But actually, GDRETools decompiles those files for you, whereas PckTool just works with the files in the PCK as they are.

That's correct. I have not used any Godot reverse engineering tools but from what I've heard second hand is that they include various tools to decode Godot format images back to png files etc. so they are useful for a variety of tasks.

GodotPckTool is meant to be just a really lightweight tool to work with the Godot .pck file format by extracting, modifying and creating .pck files, which is enough if you have all of the right data but it isn't in the right .pck file.

The build scripts I've written for Thrive can extract and remove large files from a .pck and store those separately, then the Thrive Launcher can download those separate files (and cache them, this saves a ton on download bandwidth) and use this tool to put those extracted files back into the .pck file to get it back to the original state.


I'll close this issue now unless you think there's a bug in overwriting existing files in a .pck file.

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

No branches or pull requests

2 participants