Skip to content

Commit da82e7a

Browse files
fix: Queue RewindableAction mutations ahead of rollback loop (#531)
Co-authored-by: Tamás Gálffy <ezittgtx@gmail.com>
1 parent 59d6e14 commit da82e7a

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

addons/netfox.extras/plugin.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
name="netfox.extras"
44
description="Game-specific utilities for Netfox"
55
author="Tamas Galffy and contributors"
6-
version="1.35.1"
6+
version="1.35.2"
77
script="netfox-extras.gd"

addons/netfox.internals/plugin.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
name="netfox.internals"
44
description="Shared internals for netfox addons"
55
author="Tamas Galffy and contributors"
6-
version="1.35.1"
6+
version="1.35.2"
77
script="plugin.gd"

addons/netfox.noray/plugin.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
name="netfox.noray"
44
description="Bulletproof your connectivity with noray integration for netfox"
55
author="Tamas Galffy and contributors"
6-
version="1.35.1"
6+
version="1.35.2"
77
script="netfox-noray.gd"

addons/netfox/plugin.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
name="netfox"
44
description="Shared internals for netfox addons"
55
author="Tamas Galffy and contributors"
6-
version="1.35.1"
6+
version="1.35.2"
77
script="netfox.gd"

addons/netfox/rewindable-action.gd

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
176182
func _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

Comments
 (0)