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 change host method in Co-op game #50

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Aues6uen11Z
Copy link

Hi! I've added a feature to your codebase that enables changing the host in 4-player Co-op game.

Recently, I encountered a rather frustrating issue where, as the host, I invited friends to play in my world for a few days. However, sometimes when I'm unavailable to play but they are, they can't access our saved progress since it's all stored on my end. This led me to ponder the possibility of transferring host privileges to them. Fortunately, I stumbled upon your code that fixes save files, and noticed that running it twice could effectively facilitate a host transfer.

To make this process more convenient, I decided to integrate your code and wrote a new script called change_coop_host.py. One thing worth noting is that due to Python's module naming conventions which disallow hyphens ("-") in module names, I had to rename your file to fix_host_save.py.

Comment on lines +50 to +51
"GUID": "6E80B1A6000000000000000000000000",
"name": "Arthur"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I modified the script and dumped .sav to .json, then I found there's no player name inside the save file. How do I identify which player owns the save file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "name" serves an internal purpose within the script, primarily to simplify the command for running the script and make it more memorable. The exported JSON files still rely on the GUID to distinguish players.

@guksg
Copy link

guksg commented Jan 25, 2024

if i use multi-byte characters in the player name, will this function properly ?

fix_host_save.py Outdated

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're renaming this file but I don't see changes to the README to update the usage examples.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I forgot this.

@Zennara
Copy link

Zennara commented Jan 26, 2024

How does this work? Its not entirely clear.
Sure it will change the host, but how does it correctly assign the correct playerdata to the old host?

Edit: I understand how to fill it in (I think) but I am still getting tons of errors no matter what I do. If I validate the json by using \\ instead of \, it will show:

Traceback (most recent call last):
  File "C:\Users\Keagan\Downloads\palworld-host-save-fix-feature-change-coop-host\palworld-host-save-fix-feature-change-coop-host\change_coop_host.py", line 163, in <module>
    main()
  File "C:\Users\Keagan\Downloads\palworld-host-save-fix-feature-change-coop-host\palworld-host-save-fix-feature-change-coop-host\change_coop_host.py", line 156, in main
    old_host_guid = old_host(player_list, Path(save_path)/'Players')
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Keagan\Downloads\palworld-host-save-fix-feature-change-coop-host\palworld-host-save-fix-feature-change-coop-host\change_coop_host.py", line 14, in old_host
    return old_host.pop()
           ^^^^^^^^^^^^^^
KeyError: 'pop from an empty set'

@Aues6uen11Z
Copy link
Author

if i use multi-byte characters in the player name, will this function properly ?

As long as the name doesn't conflict with another player's GUID, the script should operate correctly.

@Aues6uen11Z
Copy link
Author

How does this work? Its not entirely clear. Sure it will change the host, but how does it correctly assign the correct playerdata to the old host?

Edit: I understand how to fill it in (I think) but I am still getting tons of errors no matter what I do. If I validate the json by using \\ instead of \, it will show:

Traceback (most recent call last):
  File "C:\Users\Keagan\Downloads\palworld-host-save-fix-feature-change-coop-host\palworld-host-save-fix-feature-change-coop-host\change_coop_host.py", line 163, in <module>
    main()
  File "C:\Users\Keagan\Downloads\palworld-host-save-fix-feature-change-coop-host\palworld-host-save-fix-feature-change-coop-host\change_coop_host.py", line 156, in main
    old_host_guid = old_host(player_list, Path(save_path)/'Players')
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Keagan\Downloads\palworld-host-save-fix-feature-change-coop-host\palworld-host-save-fix-feature-change-coop-host\change_coop_host.py", line 14, in old_host
    return old_host.pop()
           ^^^^^^^^^^^^^^
KeyError: 'pop from an empty set'

\\ should indeed be used in JSON. I originally wrote it this way in README, but for some reason it still appears as \. The issue with popping from an empty set likely stems from an incorrect configuration; could you provide the contents of your config file and the contents within the "Players" directory of your save?

@Zennara
Copy link

Zennara commented Jan 26, 2024

How does this work? Its not entirely clear. Sure it will change the host, but how does it correctly assign the correct playerdata to the old host?
Edit: I understand how to fill it in (I think) but I am still getting tons of errors no matter what I do. If I validate the json by using \\ instead of \, it will show:

Traceback (most recent call last):
  File "C:\Users\Keagan\Downloads\palworld-host-save-fix-feature-change-coop-host\palworld-host-save-fix-feature-change-coop-host\change_coop_host.py", line 163, in <module>
    main()
  File "C:\Users\Keagan\Downloads\palworld-host-save-fix-feature-change-coop-host\palworld-host-save-fix-feature-change-coop-host\change_coop_host.py", line 156, in main
    old_host_guid = old_host(player_list, Path(save_path)/'Players')
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Keagan\Downloads\palworld-host-save-fix-feature-change-coop-host\palworld-host-save-fix-feature-change-coop-host\change_coop_host.py", line 14, in old_host
    return old_host.pop()
           ^^^^^^^^^^^^^^
KeyError: 'pop from an empty set'

\\ should indeed be used in JSON. I originally wrote it this way in README, but for some reason it still appears as \. The issue with popping from an empty set likely stems from an incorrect configuration; could you provide the contents of your config file and the contents within the "Players" directory of your save?

{
   "uesave_path":"C:\\Program Files\\uesave\\bin\\uesave.exe",
   "save_path":"C:\\Users\\Keagan\\AppData\\Local\\Pal\\Saved\\SaveGames\\76561198193660883\\0BF238BF42712D7F8A80D6A753989022",
   "player_list":[
      {
         "GUID":"84FEF77F000000000000000000000000",
         "name":"Spoofle"
      },
      {
         "GUID":"4B20926D000000000000000000000000",
         "name":"Shadowsilver262"
      },
      {
         "GUID":"2945FBA8000000000000000000000000",
         "name":"Zennara"
      },
      {
         "GUID":"A47597CC000000000000000000000000",
         "name":"Arch-Duke"
      },
      {
         "GUID":"",
         "name":""
      },
      {
         "GUID":"",
         "name":""
      }
   ]
}

My save file players folder:
image
Currently when I run the server, I am playing as the old hosts save. I had the old host join in order to get his GUID of A47597CC000000000000000000000000. My old GUID is 2945FBA8000000000000000000000000

@Aues6uen11Z
Copy link
Author

The principle behind changing the host is quite straightforward: since the GUID of the original host is anomalously set to '00...01', all that's required is to assign a standard GUID to the former host and then set the new host's GUID to this '00...01' value. This can be accomplished by simply running the fix_host_save.py script twice.

@Aues6uen11Z
Copy link
Author

How does this work? Its not entirely clear. Sure it will change the host, but how does it correctly assign the correct playerdata to the old host?
Edit: I understand how to fill it in (I think) but I am still getting tons of errors no matter what I do. If I validate the json by using \\ instead of \, it will show:

Traceback (most recent call last):
  File "C:\Users\Keagan\Downloads\palworld-host-save-fix-feature-change-coop-host\palworld-host-save-fix-feature-change-coop-host\change_coop_host.py", line 163, in <module>
    main()
  File "C:\Users\Keagan\Downloads\palworld-host-save-fix-feature-change-coop-host\palworld-host-save-fix-feature-change-coop-host\change_coop_host.py", line 156, in main
    old_host_guid = old_host(player_list, Path(save_path)/'Players')
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Keagan\Downloads\palworld-host-save-fix-feature-change-coop-host\palworld-host-save-fix-feature-change-coop-host\change_coop_host.py", line 14, in old_host
    return old_host.pop()
           ^^^^^^^^^^^^^^
KeyError: 'pop from an empty set'

\\ should indeed be used in JSON. I originally wrote it this way in README, but for some reason it still appears as \. The issue with popping from an empty set likely stems from an incorrect configuration; could you provide the contents of your config file and the contents within the "Players" directory of your save?

{
   "uesave_path":"C:\\Program Files\\uesave\\bin\\uesave.exe",
   "save_path":"C:\\Users\\Keagan\\AppData\\Local\\Pal\\Saved\\SaveGames\\76561198193660883\\0BF238BF42712D7F8A80D6A753989022",
   "player_list":[
      {
         "GUID":"84FEF77F000000000000000000000000",
         "name":"Spoofle"
      },
      {
         "GUID":"4B20926D000000000000000000000000",
         "name":"Shadowsilver262"
      },
      {
         "GUID":"2945FBA8000000000000000000000000",
         "name":"Zennara"
      },
      {
         "GUID":"A47597CC000000000000000000000000",
         "name":"Arch-Duke"
      },
      {
         "GUID":"",
         "name":""
      },
      {
         "GUID":"",
         "name":""
      }
   ]
}

My save file players folder: image Currently when I run the server, I am playing as the old hosts save. I had the old host join in order to get his GUID of A47597CC000000000000000000000000. My old GUID is 2945FBA8000000000000000000000000

Remove A47597CC000000000000000000000000.sav will work, the save files themselves do not require any manual adjustments; everything necessary can be handled through config.

@Zennara
Copy link

Zennara commented Jan 26, 2024

How does this work? Its not entirely clear. Sure it will change the host, but how does it correctly assign the correct playerdata to the old host?
Edit: I understand how to fill it in (I think) but I am still getting tons of errors no matter what I do. If I validate the json by using \\ instead of \, it will show:

Traceback (most recent call last):
  File "C:\Users\Keagan\Downloads\palworld-host-save-fix-feature-change-coop-host\palworld-host-save-fix-feature-change-coop-host\change_coop_host.py", line 163, in <module>
    main()
  File "C:\Users\Keagan\Downloads\palworld-host-save-fix-feature-change-coop-host\palworld-host-save-fix-feature-change-coop-host\change_coop_host.py", line 156, in main
    old_host_guid = old_host(player_list, Path(save_path)/'Players')
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Keagan\Downloads\palworld-host-save-fix-feature-change-coop-host\palworld-host-save-fix-feature-change-coop-host\change_coop_host.py", line 14, in old_host
    return old_host.pop()
           ^^^^^^^^^^^^^^
KeyError: 'pop from an empty set'

\\ should indeed be used in JSON. I originally wrote it this way in README, but for some reason it still appears as \. The issue with popping from an empty set likely stems from an incorrect configuration; could you provide the contents of your config file and the contents within the "Players" directory of your save?

{
   "uesave_path":"C:\\Program Files\\uesave\\bin\\uesave.exe",
   "save_path":"C:\\Users\\Keagan\\AppData\\Local\\Pal\\Saved\\SaveGames\\76561198193660883\\0BF238BF42712D7F8A80D6A753989022",
   "player_list":[
      {
         "GUID":"84FEF77F000000000000000000000000",
         "name":"Spoofle"
      },
      {
         "GUID":"4B20926D000000000000000000000000",
         "name":"Shadowsilver262"
      },
      {
         "GUID":"2945FBA8000000000000000000000000",
         "name":"Zennara"
      },
      {
         "GUID":"A47597CC000000000000000000000000",
         "name":"Arch-Duke"
      },
      {
         "GUID":"",
         "name":""
      },
      {
         "GUID":"",
         "name":""
      }
   ]
}

My save file players folder: image Currently when I run the server, I am playing as the old hosts save. I had the old host join in order to get his GUID of A47597CC000000000000000000000000. My old GUID is 2945FBA8000000000000000000000000

Remove A47597CC000000000000000000000000.sav will work, the save files themselves do not require any manual adjustments; everything necessary can be handled through config.

That seemed to work, however, do you have any clue why our day would set to 40? We were on day 9 before.

@Aues6uen11Z
Copy link
Author

The official releases patch v0.1.3.0 yesterday and it seems they fixed that bug where the game was showing fewer days than it should've. Could be the reason for what we're seeing.

@Zennara
Copy link

Zennara commented Jan 26, 2024

The official releases patch v0.1.3.0 yesterday and it seems they fixed that bug where the game was showing fewer days than it should've. Could be the reason for what we're seeing.

You are an absolute godsend. Thank you.

@Aues6uen11Z
Copy link
Author

The official releases patch v0.1.3.0 yesterday and it seems they fixed that bug where the game was showing fewer days than it should've. Could be the reason for what we're seeing.

You are an absolute godsend. Thank you.

I'm glad I could be of help : )

@ClaTron1x
Copy link

I'm not familiar with python, and I'm having some trouble. Could someone clear this up for me?

I've imported change_coop_host.py to my scripts folder, configured the config.json file to contain the user GUIDs and the names, and then put the config file in a folder. What I don't understand is how to make it so the script can find the config folder and execute the commands. I just get a syntax error when I try to run the script:

python change_coop_host.py Cla_Tronix
File "", line 1
python change_coop_host.py Cla_Tronix
^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax

@Aues6uen11Z
Copy link
Author

I'm not familiar with python, and I'm having some trouble. Could someone clear this up for me?

I've imported change_coop_host.py to my scripts folder, configured the config.json file to contain the user GUIDs and the names, and then put the config file in a folder. What I don't understand is how to make it so the script can find the config folder and execute the commands. I just get a syntax error when I try to run the script:

python change_coop_host.py Cla_Tronix File "", line 1 python change_coop_host.py Cla_Tronix ^^^^^^^^^^^^^^^^ SyntaxError: invalid syntax

Have you edited this script? It seems that you add this command to the code.

@ClaTron1x
Copy link

I'm not familiar with python, and I'm having some trouble. Could someone clear this up for me?
I've imported change_coop_host.py to my scripts folder, configured the config.json file to contain the user GUIDs and the names, and then put the config file in a folder. What I don't understand is how to make it so the script can find the config folder and execute the commands. I just get a syntax error when I try to run the script:
python change_coop_host.py Cla_Tronix File "", line 1 python change_coop_host.py Cla_Tronix ^^^^^^^^^^^^^^^^ SyntaxError: invalid syntax

Have you edited this script? It seems that you add this command to the code.

No, this is what happens when I try to run "python change_coop_host.py Name" in the Python cmd window. I haven't edited the script at all, only the config.json file.

@Zennara
Copy link

Zennara commented Jan 26, 2024

I'm not familiar with python, and I'm having some trouble. Could someone clear this up for me?
I've imported change_coop_host.py to my scripts folder, configured the config.json file to contain the user GUIDs and the names, and then put the config file in a folder. What I don't understand is how to make it so the script can find the config folder and execute the commands. I just get a syntax error when I try to run the script:
python change_coop_host.py Cla_Tronix File "", line 1 python change_coop_host.py Cla_Tronix ^^^^^^^^^^^^^^^^ SyntaxError: invalid syntax

Have you edited this script? It seems that you add this command to the code.

No, this is what happens when I try to run "python change_coop_host.py Name" in the Python cmd window. I haven't edited the script at all, only the config.json file.

Is the config file and the python file in the same directory?

@ClaTron1x
Copy link

ClaTron1x commented Jan 26, 2024

I'm not familiar with python, and I'm having some trouble. Could someone clear this up for me?
I've imported change_coop_host.py to my scripts folder, configured the config.json file to contain the user GUIDs and the names, and then put the config file in a folder. What I don't understand is how to make it so the script can find the config folder and execute the commands. I just get a syntax error when I try to run the script:
python change_coop_host.py Cla_Tronix File "", line 1 python change_coop_host.py Cla_Tronix ^^^^^^^^^^^^^^^^ SyntaxError: invalid syntax

Have you edited this script? It seems that you add this command to the code.

No, this is what happens when I try to run "python change_coop_host.py Name" in the Python cmd window. I haven't edited the script at all, only the config.json file.

Is the config file and the python file in the same directory?

Yes. It looks like the syntax error is directed towards the "change_coop_host" part of the command. It might be because I haven't configured Python correctly and that it can't find the script I'm trying to run. I store my data on two drives, so that might be the problem.
I have my scripts in the Scripts file that came when I installed python "D:\Python\Scripts"

Edit: I'm dumb and was running the commands in the python interpreter, and not cmd/powershell. I've managed to get the 'pop from an empty set' error and will try fixing it by following what was said above about the error.

@trinityuniverse
Copy link

I just wanted to say that your script worked perfectly for me. Had a few syntax errors at the beginning, but I was able to resolve them with ChatGPT. :)

Swapped two players and haven't been able to find any bugs so far.

@Zennara
Copy link

Zennara commented Jan 26, 2024

I just wanted to say that your script worked perfectly for me. Had a few syntax errors at the beginning, but I was able to resolve them with ChatGPT. :)

Swapped two players and haven't been able to find any bugs so far.

Mine worked too but there was one small bug where all of our pals weren't correctly registering to our guild. Therefore we couldn't pick them up when they were working. The fix was to just put all pals in the base and your palbox into your inventory, drop them on the ground, then put them back in.
Do you have that issue as well?

@guksg
Copy link

guksg commented Jan 26, 2024

I found fatal bug
any player can't lift pals after script execute.
tried put them back to box and replaced but still can't lift.
plus new host's map is overwritten by old host's map.

is that cause of my bad procedure?

@Zennara
Copy link

Zennara commented Jan 26, 2024

I found fatal bug
any player can't lift pals after script execute.
tried put them back to box and replaced but still can't lift.
plus new host's map is overwritten by old host's map.

is that cause of my bad procedure?

Pick up the pal, drop in on the ground (the actual item), then pick it back up. It will fix it then. Make sure to do this with ALL pals in your base, team, and palbox.

@Lynxaa Lynxaa mentioned this pull request Jan 26, 2024
@Aues6uen11Z
Copy link
Author

Aues6uen11Z commented Jan 27, 2024

Yes, this script has the same Pal bug with what is mentioned in README.
And I also found the map bug, this can be fixed by replacing the LocalData.sav from the modified save file with that from the original save file of the new host. LocalData.sav saves personal map and tutorial data, so replace it will work, I will update this to readme.

@guksg
Copy link

guksg commented Jan 27, 2024

スクリプト実行後にどのプレイヤーも仲間を持ち上げることができない致命的なバグを発見しました。
箱に戻して交換してみましたが、やはり持ち上げられません。
さらに、新しいホストのマップは古いホストのマップによって上書きされます。
私の手順が悪いのが原因でしょうか?

仲間を拾い上げ、地面(現物)に落としてから拾い直します。そうすれば解決します。必ずベース、チーム、パルボックス内のすべての仲間に対してこれを行ってください。

that works! thank you so much

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.

None yet

7 participants