teeworlds_network/lib/game_server.rb

32 lines
711 B
Ruby

# frozen_string_literal: true
require_relative 'map'
class GameServer
attr_accessor :pred_game_tick, :ack_game_tick, :map
def initialize(server)
@server = server
@ack_game_tick = -1
@pred_game_tick = 0
@map = Map.new(
name: 'dm1',
crc: 1_683_261_464,
size: 6793,
sha256: '491af17a510214506270904f147a4c30ae0a85b91bb854395bef8c397fc078c3'
)
end
def on_info(chunk, packet)
u = Unpacker.new(chunk.data[1..])
net_version = u.get_string
password = u.get_string
client_version = u.get_int
puts "vers=#{net_version} vers=#{client_version} pass=#{password}"
# TODO: check version and password
@server.send_map(packet.addr)
end
end