-
-
Notifications
You must be signed in to change notification settings - Fork 303
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 in (mostly) bash #380
Add an option to generate a WorldOption.sav file automatically in (mostly) bash #380
Conversation
We implemented this in our deployment of your stuff and we are seeing the following error:
well try to fix it as well but definitely seems like some of the jq stuff is failing causing a invalid json file that python can't open. |
Hi @gzukel, do you mind sharing the log with DEBUG env var set to true? |
the double qoutes here was the issue, I changed to single qoutes and it fixed it. |
# Python script for converting JSON to .sav | ||
convert_json_to_sav_python=$( | ||
cat <<EOF | ||
import sys | ||
import json | ||
from palworld_save_tools.gvas import GvasFile | ||
from palworld_save_tools.palsav import compress_gvas_to_sav | ||
from palworld_save_tools.paltypes import PALWORLD_CUSTOM_PROPERTIES | ||
|
||
gvas_file = GvasFile.load(json.loads(sys.stdin.read())) | ||
if ("Pal.PalWorldSaveGame" in gvas_file.header.save_game_class_name or "Pal.PalLocalWorldSaveGame" in gvas_file.header.save_game_class_name): | ||
save_type = 0x32 | ||
else: | ||
save_type = 0x31 | ||
sav_file = compress_gvas_to_sav( | ||
gvas_file.write(PALWORLD_CUSTOM_PROPERTIES), save_type | ||
) | ||
sys.stdout.buffer.write(sav_file) | ||
EOF | ||
) | ||
|
||
# Function to convert JSON to .sav | ||
convert_json_to_sav() { | ||
local json_data="$1" | ||
local output_path="$2" | ||
|
||
echo "WorldOption Generator: Compressing WorldOption to .sav" | ||
if echo "$json_data" | python3 -c "$convert_json_to_sav_python" > "$output_path/WorldOption.sav"; then | ||
echo "WorldOption Generator: Generated WorldOption.sav file to $output_path" | ||
echo "Generating WorldOption.sav done!" | ||
else | ||
echo "WorldOption Generator: WorldOption.sav generation failed." | ||
fi | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't include python code in this way.
Make a separate python file and call that.
Closing PR due to its fragility and complexity. Will wait until I can think of a solution without adding an additional language to maintain before opening up another PR as we prefer to currently do things strictly in bash. |
Context
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.BaseCampWorkerMaxNum
being locked at 15. Having an option to generate aWorldOption.sav
file would allow these settings to be modified.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 theWorldOption.sav
file would ignore thePalWorldSettings.ini
file generated from those env vars. (Enable PVP or Set `BaseCampWorkerMaxNum` to 20 on a dedicated Server #293)Choices
PalWorldSettings.ini
is always valid.WorldOption.sav
file by:PalWorldSettings.ini
file.WorldOption.json.template
.WorldOption.sav
file.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 thePalWorldSettings.ini
is used instead.Test instructions
New server test:
PalWorldSettings.ini
.Existing server test:
PalWorldSettings.ini
.Checklist before requesting a review