Disconnect on invalid snap item

Do not leave a timeouted tee on the server if the snap is
parsed wrong
This commit is contained in:
ChillerDragon 2022-11-20 10:24:56 +01:00
parent c28bcd15e8
commit d4332ce6b0
2 changed files with 6 additions and 1 deletions

View file

@ -158,7 +158,7 @@ class GameClient
end
def on_snapshot(chunk)
u = SnapshotUnpacker.new
u = SnapshotUnpacker.new(@client)
snapshot = u.snap_single(chunk)
return if snapshot.nil?

View file

@ -29,6 +29,10 @@ class Snapshot
end
class SnapshotUnpacker
def initialize(client)
@client = client
end
def snap_single(chunk)
u = Unpacker.new(chunk.data)
msg_id = u.get_int
@ -195,6 +199,7 @@ class SnapshotUnpacker
end
end
puts 'Error: got invalid snap item'
@client.disconnect
exit 1
end