@@ -173,6 +173,12 @@ func _before_rollback_loop() -> void:
173173 for tick in _queued_changes :
174174 set_active (_queued_changes [tick ], tick )
175175
176+ # Queue earliest event
177+ if not _active_ticks .is_empty ():
178+ var earliest_active = _active_ticks .min ()
179+ for mutated in _mutated_objects :
180+ NetworkRollback .mutate (mutated , earliest_active )
181+
176182func _after_loop () -> void :
177183 # Trim history
178184 for tick in _active_ticks :
@@ -195,12 +201,6 @@ func _after_loop() -> void:
195201 _state_changes .clear ()
196202 _queued_changes .clear ()
197203
198- # Queue earliest event
199- if not _active_ticks .is_empty ():
200- var earliest_active = _active_ticks .min ()
201- for mutated in _mutated_objects :
202- NetworkRollback .mutate (mutated , earliest_active )
203-
204204 # Submit
205205 if is_multiplayer_authority () and _last_set_tick >= 0 :
206206 var active_tick_bytes = _TicksetSerializer .serialize (NetworkRollback .history_start , _last_set_tick , _active_ticks )
@@ -220,8 +220,11 @@ func _submit_state(bytes: PackedByteArray) -> void:
220220 # Don't compare past last event, as to not cancel events the host simply doesn't know about
221221 var latest_tick = maxi (last_known_tick , NetworkRollback .history_start )
222222
223- if earliest_tick > NetworkTime .tick or latest_tick > NetworkTime .tick :
224- _logger .warning ("Received tickset for range @%d >%d , which has ticks in the future!" , [earliest_tick , latest_tick ])
223+ # Add a tolerance of 4 ticks for checking if the tickset is in the future
224+ # Server time might be ahead a tick or two under really small latencies,
225+ # e.g. LAN
226+ if earliest_tick > NetworkTime .tick + 4 or latest_tick > NetworkTime .tick + 4 :
227+ _logger .debug ("Received tickset for range @%d >%d , which has ticks in the future!" , [earliest_tick , latest_tick ])
225228
226229 for tick in range (earliest_tick , latest_tick + 1 ):
227230 var is_tick_active = active_ticks .has (tick )
0 commit comments