TehGimp / KerbalMultiPlayer

A multiplayer plugin for KMP
http://sesau.ca/ksp/KMP.html
GNU General Public License v3.0
140 stars 53 forks source link

[Request] Instant Structural updates #645

Open JohannesMP opened 10 years ago

JohannesMP commented 10 years ago

As demonstrated in the video in this forum post, structural updates do not currently sync between clients. In the video you can see client 1 opening solar panels, enabling lights, and toggling RCS, while client 2 who is either piloting a ship/EVA kerbal nearby or spectating does not see these changes, which for example causes client 2 to see the ship as using up RCS and losing electricity when that is not happening. When client 2 then takes control over the ship, since a spectator becomes the pilot of the other pilot leaves the ship, these values now become what is synced to the server.

I think for multiplayer to be playable it will be necessary for structural changes to a vessel to sync instantly, not every 45 seconds as was the case previously (and seems to be broken currently as demonstrated in the video in the forum post above)

It's far too likely to have really frustrating moments when trying to cooperate in multiplayer if this doesn't happen:

godarklight commented 10 years ago

I noticed this the other day - Brakes don't seem to instantly change state.

If you change the safety bubble down to 1700, the hill on the end of the runway is outside of the safety bubble. If you park a client there you will see it rolling down the hill and reseting back to where it was (normal vessel updates), until a full update comes along and sets the brakes.

Toggling landing gear/legs, lights, brakes, deploying solar panels, toggling parachutes and a few other cases that I've missed are other times we should send full vessel updates.

The first thing that comes to mind is traversing the ConfigNode tree, but this sounds wrong I can't imagine this would be good for performance or memory. Perhaps we can listen to a certain event, we'll have to see what KSP provides.

JohannesMP commented 10 years ago

Yeah, sending full updates for these changes would be one way, but I still think that it might be worth looking into partial updates.

This is me again just thinking in pseudocode with no bearing on how things are actually handled in the game, but couldn't you just traverse the tree once looking for nodes that contain key characteristics which indicate that they need to be watched, and then on later frames, assuming that vessel doesn't change it's tree structure (like by breaking apart) you could look at those nodes directly?

In any case, here's my attempt at a more extensive list of the types of changes that would be nice to have visible instantaneously - I'm aware that part-specific changes would need to be generalized to how the KSP's object model implements them, but I'm just listing these attributes as examples, and with made up names that make sense to me:


Ship-Wide Changes


Part-Specific Updates:


Resource Updates

Any resource flow should be updated instantly, which I think is one of the biggest reasons to consider adding partial updates. Changes in resources drastically affect how a ship that a spectator is viewing behaves on its client vs on the spectator's client.

For example if the amount of electricity in batteries de-synced somewhat, then between complete updates the lights might turn off for the spectator while they remain on for the actual client due to the changes in electricity not being accurately synchronized.

Other fast changes such as transferring fuel between containers, or intake air changing depending on how the spectated ship is moving can mean the difference of a spectator seeing an engine fire or flameout.

nevercast commented 10 years ago

Noticed this today when I throttled up to check no Thrusters were still enabled (after turning them all off), and a spectator saw me power up all thrusters and the satellite exploded.

What is worse is when he went to the KSP and back again he could still see the satellite exploding, but now he had changed from spectator to pilot (Another issue entirely). This was followed by the both of us logging out and logging in, to see that the satellite was still in one piece, only it had no orbital velocity now. 350,000km up and no Orbital speed. (Another issue again I guess)

The point is all this started because the Thruster on off state didn't sync and then I powered up the thrust.

JohannesMP commented 10 years ago

@nevercast just as a side note regarding the spectator becoming the pilot: If you are controlling a vessel that is set to public (the default setting) and leave that vessel, then whoever is spectating the vessel will become the pilot. This is as is intended. To avoid this happening in the future make sure to set your vessel to private before you leave it.

I would also guess that the vessel losing its orbital velocity is not directly related to this issue (update desync) and was caused by something while the two of you logged out/in. If you can reproduce it then it would be worth opening a new issue just for that.

nevercast commented 10 years ago

I will attempt to reproduce it the next opportunity I get, and I'm fairly sure I was piloting the vessel at the time of losing pilot status. I will test this also, I will also ensure I'm using the very lastest Jenkins build, though I'm sure it's only a couple weeks old

godarklight commented 10 years ago

Throttle status and inputs are is updated immediately (FlightCtrlState), but the others would be really nice to have.

The other bugs sound like server lag - #555.