Fix starting order for RollbackSynchronizer#284
Conversation
…piler hits error if function doesnt exist, so typos are caught with static RPC functions)
| var _inputs: Dictionary = {} | ||
| var _latest_state: int = -1 | ||
| var _earliest_input: int | ||
| var _started_at_tick: int = -1 |
There was a problem hiding this comment.
This variable ultimately ended up being unused, but its useful to keep so as to know when an avatar joined/started.
|
|
||
| if (await_first_frame): | ||
| await get_tree().process_frame | ||
| process_authority() |
There was a problem hiding this comment.
After await, it is basically guaranteed the input authority is set, so process_authority can be safely invoked
|
|
||
| if tick < earliest: | ||
| _logger.warning("Tried to load tick %s which is earlier than the earliest we have recorded (%s) | ||
| Try increasing the history limit." % [tick, earliest]) |
There was a problem hiding this comment.
Debug comment, to confirm #260 is fixed. Place this message on main branch, and you will see it goes from 0 to current. I will remove this message once this PR is reviewed/approved
| _snap_to_spawn() | ||
|
|
||
| # TODO: What if the RollbackSynchronizer had a flag for this? | ||
| # Wait a frame so Input has time to get its authority set |
There was a problem hiding this comment.
And that's what I did :P
There was a problem hiding this comment.
Turns out this is not needed at all, we can just defer the process_settings() call in RollbackSynchronizer - running it in the next idle time, usually at the end of the current _process().
|
EDIT: The below is arguments against and for, the Btw the "await 1 frame" logic could be skipped entirely. It is only useful if the Input authority is set in the same At forest-brawl, the input authority isn't set at func _spawn(id: int) -> BrawlerController:
var avatar = player_scene.instantiate() as BrawlerController
avatars[id] = avatar
avatar.name += " #%d" % id
avatar.player_id = id
spawn_root.add_child(avatar)
# Avatar is always owned by server
avatar.set_multiplayer_authority(1)
print("Spawned avatar %s at %s" % [avatar.name, multiplayer.get_unique_id()])
# Avatar's input object is owned by player
var input = avatar.find_child("Input")
if input != null:
input.set_multiplayer_authority(id)
print("Set input(%s) ownership to %s" % [input.name, id])
So as it is, without the await 1 frame, all |
|
Updated PR, turns out the single-frame wait is not needed at all. Also explained it under #260 (comment) |
|
There is a weird "bug" which I have to mention. If a client joins for the first full second, sometimes, the client hovers. To confirm this bug isn't a regression, I checked out to commit 20c5bfd I assume it has something to do with P.S. All testing was done with 200ms, and input broadcast disabled. |
|
On the addition of |
Solves #260 and #268 by fixing input initialization.
Also gets rid of the
await 1 framehack for 2 seperate classes (BrawlerController.gd/player.gd) in order to await for input authority to be set beforeprocess_authority, so this awaiting a frame logic is moved toRollbackSynchronizersince in most games, input authority is set in_readyor something similar.May also solve the reported problem of the first 2 ticks, having NPCs spinning. Haven't seen it in a project of mine, but it may solve it because this PR addresses the first
_earliest_inputbeing set properly