NebulaModTeam / nebula

A multiplayer mod for the game Dyson Sphere Program
GNU General Public License v3.0
820 stars 125 forks source link

Construction drones range limit & command /playerdata #666

Closed starfi5h closed 3 months ago

starfi5h commented 3 months ago

Construction drones range limit

Make construction drones only launch if the local player is closer than other remote players, or within 15m. So that the drones won't try to fly to far prebuild that will be built by other players first.

SaveManager

Clear playerSaves from the previous session when server starts.

Add new chat command /playerdata. playerdata

With this command, it can achieve the following goal for the host:

  1. Reset player data so they can join as a new player if they choose the wrong planet to start in the lobby.
  2. After transferring the save files, get the stored player data instead of the data from the previous host.
starfi5h commented 3 months ago

Are these playerdata commands only available for the host/authenticated clients? If not, should they be limited?

Currently it only has effects in host, as client will see 0 player data in SaveManager. I'm not sure if it should be open to clients.

Also not a blocking issue but:

After transferring the save files, get the stored player data instead of the data from the previous host.

So once this is done, the player data from the previous host is permanently lost? If the save is transferred back then the original host would be stuck with the other host's player data, and the other host's player data doesn't get updated to match what was done on the main data?

No. It's not lost. As in SaveManager.SaveServerData(), it will store all the hash-IPlayerData pair in playerSaves and the host hash-IPlayerData in the .server file.
When a /playerdata load command is used, it just copys the inventory and appearance, the source pair is still in the SaveManager. So as long as the original host's player.key file remains the same. it can login to get back the data.

I think the best solution would be to just have the host's data also stored in the .server file with a hash (so the host would also generate a key file), and then swapping back and forth would be possible.

It's already implemented in https://github.com/NebulaModTeam/nebula/blob/master/NebulaNetwork/SaveManager.cs#L45-L47