A bit of rdoc documentation comments

This commit is contained in:
ChillerDragon 2023-09-17 12:15:31 +02:00
parent ded776dd4a
commit c185d1a6b2
2 changed files with 22 additions and 0 deletions

View file

@ -4,6 +4,14 @@ require_relative 'array'
require_relative 'network'
require_relative 'bytes'
##
# The NetChunk class represents one individual
# chunk of a teeworlds packet.
#
# A teeworlds packet holds multiple game and system messages
# as its payload, those are called chunks or messages.
#
# https://chillerdragon.github.io/teeworlds-protocol/07/packet_layout.html
class NetChunk
attr_reader :next, :data, :msg, :sys, :flags, :header_raw, :full_raw
@ -131,10 +139,12 @@ class NetChunk
# in da third byte but who needs seq?!
end
# @return [Boolean]
def flags_vital
@flags[:vital]
end
# @return [Boolean]
def flags_resend
@flags[:resend]
end
@ -143,6 +153,12 @@ end
MAX_NUM_CHUNKS = 1024
class BigChungusTheChunkGetter
##
# given a raw payload of a teeworlds packet
# it splits it into the indivudal chunks
# also known as messages
#
# @return [Array<NetChunk>]
def self.get_chunks(data)
chunks = []
chunk = NetChunk.new(data)

View file

@ -86,6 +86,12 @@ class SnapshotUnpacker
DDNetSnapItem.new(u, id)
end
##
# Given a NetChunk this method
# dissects the snapshot header
# and its payload (snap items)
#
# @return [Snapshot]
def snap_single(chunk)
u = Unpacker.new(chunk.data)
msg_id = u.get_int