Skip to content

Commit

Permalink
Fix slowdowns caused by game_client
Browse files Browse the repository at this point in the history
Old ticks were saved by game client in timeslot_map which caused that
\ map to grow forever and cause slowdowns in later waves due to very
\ expensive has() calls
  • Loading branch information
Kvel2D committed Nov 13, 2024
1 parent 8d73614 commit 3ae30fd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/game_scene/game_client.gd
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,15 @@ func receive_timeslots(timeslot_list: Dictionary):
if !_received_any_timeslots:
_received_any_timeslots = true
received_first_timeslot.emit()


# NOTE: it's important to skip old ticks, host can send
# old ticks if it hasn't received ack from client yet due
# to network/logic delay. If we don't skip old ticks, then
# _timeslot_map would grow forever.
for tick in timeslot_list.keys():
if tick < _current_tick:
continue

_timeslot_map[tick] = timeslot_list[tick]

_last_received_timeslot_list = timeslot_list.keys()
Expand Down

0 comments on commit 3ae30fd

Please sign in to comment.