Got client stuck in connecting till timeout
This commit is contained in:
parent
1876038d82
commit
7f7963189c
|
@ -13,7 +13,7 @@ class GameServer
|
|||
@pred_game_tick = 0
|
||||
@map = Map.new(
|
||||
name: 'dm1',
|
||||
crc: 1_683_261_464,
|
||||
crc: '98a0a4c50c', # decimal 64548818
|
||||
size: 6793,
|
||||
sha256: '491af17a510214506270904f147a4c30ae0a85b91bb854395bef8c397fc078c3'
|
||||
)
|
||||
|
|
17
lib/map.rb
17
lib/map.rb
|
@ -3,14 +3,23 @@
|
|||
require_relative 'bytes'
|
||||
|
||||
class Map
|
||||
attr_reader :name, :crc, :size, :sha256, :sha256_str, :sha256_arr
|
||||
attr_reader :name, :crc, :crc_str, :crc_arr, :size, :sha256, :sha256_str, :sha256_arr
|
||||
|
||||
def initialize(attr = {})
|
||||
# map name as String
|
||||
@name = attr[:name]
|
||||
|
||||
# crc has to be a positive Integer
|
||||
# crc hex encoded string (8 characters / 4 bytes)
|
||||
@crc = attr[:crc]
|
||||
raise "Error: map crc invalid type: #{@crc.class}" unless @crc.instance_of?(String)
|
||||
|
||||
unless @crc.match(/[a-fA-F0-9]{8}/) # str encoded hex
|
||||
raise "Error: map crc raw string expects size 8 but got #{@crc.size}"
|
||||
end
|
||||
|
||||
@crc_str = @crc
|
||||
@crc_arr = str_bytes(@crc)
|
||||
@crc = @crc_arr.pack('C*')
|
||||
|
||||
# size has to be a positive Integer
|
||||
@size = attr[:size]
|
||||
|
@ -33,7 +42,7 @@ class Map
|
|||
@sha256 = @sha256_arr.pack('C*')
|
||||
@sha256_str = str_hex(@sha256).gsub(' ', '')
|
||||
else
|
||||
raise "Error: map raw string expects size 32 but got #{@sha256.size}"
|
||||
raise "Error: map sha256 raw string expects size 64 but got #{@sha256.size}"
|
||||
end
|
||||
elsif @sha256.instance_of?(Array) # int byte array
|
||||
raise "Error: map sha256 array expects size 32 but got #{@sha256.size}" if @sha256.size != 32
|
||||
|
@ -41,6 +50,8 @@ class Map
|
|||
@sha256_arr = @sha256
|
||||
@sha256 = @sha256.pack('C*')
|
||||
@sha256_str = @sha256.map { |b| b.to_s(16).rjust(2, '0') }.join
|
||||
else
|
||||
raise "Error: map sha256 invalid type: #{@sha256.class}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -116,7 +116,7 @@ class TeeworldsServer
|
|||
def send_map(addr)
|
||||
data = []
|
||||
data += Packer.pack_str(@game_server.map.name)
|
||||
data += Packer.pack_int(@game_server.map.crc)
|
||||
data += @game_server.map.crc_arr # poor mans pack_raw()
|
||||
data += Packer.pack_int(@game_server.map.size)
|
||||
data += Packer.pack_int(8) # chunk num?
|
||||
data += Packer.pack_int(MAP_CHUNK_SIZE)
|
||||
|
|
Loading…
Reference in a new issue