A bit of rdoc documentation comments
This commit is contained in:
parent
ded776dd4a
commit
c185d1a6b2
16
lib/chunk.rb
16
lib/chunk.rb
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue