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

Add an option to generate a WorldOption.sav file automatically #337

Closed

Conversation

sonroyaalmerol
Copy link
Contributor

@sonroyaalmerol sonroyaalmerol commented Feb 9, 2024

Context

  • A WorldOption.sav file is usually generated from a single player save and not a dedicated server. However, a dedicated server can still recognize the .sav file.
  • Some settings are limited in dedicated servers such as PVP and BaseCampWorkerMaxNum being locked at 15. Having an option to generate a WorldOption.sav file would allow these settings to be modified.
  • Currently, people are generating their WorldOption.sav files from this website. While this works, it would negate the purpose of having the settings as env vars in a Docker container as having the WorldOption.sav file would ignore the PalWorldSettings.ini file generated from those env vars. (Enable PVP or Set `BaseCampWorkerMaxNum` to 20 on a dedicated Server #293)

Choices

  • The way it works is a simple HTTP POST request with the compiled settings as its body to that same website which generates the .sav file and saved to the appropriate folder within the container. Another option is to have the tool itself within the Docker image but that would require us having Python running inside the container.
  • An internal Python script is executed to generate a JSON data from the compiled PalWorldSettings.ini file to be processed by palworld-save-tools and generate the actual WorldOption.sav file.
  • The script would delete the existing WorldOption.sav file and generate a new one every boot to make sure it follows the current values of the Docker env vars.
  • GENERATE_WORLD_OPTION env var is added and is defaulted to false. Since the .sav file gets deleted every boot, having this env var to false would make sure that the PalWorldSettings.ini is used instead.
  • If for some reason the POST request file generation fails, GENERATE_WORLD_OPTION is ignored and will revert back to using PalWorldSettings.ini.

Test instructions

  1. Started the container from scratch with default env vars and GENERATE_WORLD_OPTION=true. Check if it generates the .sav file (it shouldn't as the save folder does not exist at this point).
  2. Restart the container after the save folder has been initialized by the dedicated server.
  3. Check if it generates the .sav file.
  4. Test if it follows the default configurations.
  5. Modify env vars (ENABLE_PLAYER_TO_PLAYER_DAMAGE, IS_PVP, BASE_CAMP_WORKER_MAX_NUM, etc.)
  6. Restart the container and see if the changes persist.
  7. Set GENERATE_WORLD_OPTION to false.
  8. Restart the container if it reverts back to the default configurations.

Checklist before requesting a review

  • I have performed a self-review of my code
  • I've added documentation about this change to the README.
  • I've not introduced breaking changes.

README.md Outdated Show resolved Hide resolved
scripts/compile-settings.sh Outdated Show resolved Hide resolved
scripts/compile-settings.sh Outdated Show resolved Hide resolved
scripts/compile-settings.sh Outdated Show resolved Hide resolved
scripts/generate-worldoption.sh Outdated Show resolved Hide resolved
@MSpreckels
Copy link
Contributor

Please also test this with existing savedata.

@sonroyaalmerol sonroyaalmerol marked this pull request as draft February 9, 2024 11:14
@sonroyaalmerol sonroyaalmerol marked this pull request as ready for review February 9, 2024 22:15
@sonroyaalmerol
Copy link
Contributor Author

I've removed the previous script of using the online API and opted to use the Python tools instead. I modified a portion of the palworld-worldoptions script to generate a JSON file for the palworld-save-tools to be usable instead of uesave-rs to remove the extra build step for arm64 images.

Tested it with both new and existing savedata and everything works as expected.

@sonroyaalmerol
Copy link
Contributor Author

Closing in favor of #380

@sonroyaalmerol sonroyaalmerol deleted the generate-worldoptions branch July 7, 2024 22:25
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

Successfully merging this pull request may close these issues.

4 participants