Only broadcast MoveWidgetCommand when final #851
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem - some commands fire every frame and flood the network in multiplayer.
How to reproduce: Before joining a room, switch to advanced mode, add an image then switch back to beginner mode and create/join a room. Moving the widget will send the "move widget" RPC every single frame.
Cause: The current code assumes that adding a command to the undo stack is a sign that it should be sent over the network. However some command subclasses work as follows - each command is executed and added to the stack. The next command looks at the previous command and decides if it can merge with it. In the case of MoveWidgetCommand this is true until m_IsFinal is set to true (usually when the widget is released).
The original PhotonManager code has a switch/case that has a default fall-through for commands that aren't handled explicitly. I haven't removed this in this PR as I would need to figure out all possible commands that we currently want to handle and add a case statement for them all. However - I think this is probably a better approach as we shouldn't be broadcasting commands without carefully looking at their behaviour.
This PR does hopefully fix the specific MoveWidgetCommand case. Currently not tested but I'm posting it to start the discussion and get a couple of eyeballs on it.