Send server settings
This commit is contained in:
parent
263e579661
commit
d9b0096ae8
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
require_relative 'models/map'
|
require_relative 'models/map'
|
||||||
require_relative 'models/server_info'
|
require_relative 'models/server_info'
|
||||||
|
require_relative 'models/server_settings'
|
||||||
require_relative 'models/game_info'
|
require_relative 'models/game_info'
|
||||||
|
|
||||||
class GameServer
|
class GameServer
|
||||||
|
@ -37,7 +38,7 @@ class GameServer
|
||||||
# - server settings
|
# - server settings
|
||||||
# - ready
|
# - ready
|
||||||
#
|
#
|
||||||
# We only send ready for now
|
@server.send_server_settings(packet.client, ServerSettings.new.to_a)
|
||||||
@server.send_ready(packet.client)
|
@server.send_ready(packet.client)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
23
lib/models/server_settings.rb
Normal file
23
lib/models/server_settings.rb
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class ServerSettings
|
||||||
|
def initialize(attr = {})
|
||||||
|
@kick_vote = attr[:kick_vote] || 0
|
||||||
|
@kick_min = attr[:kick_min] || 0
|
||||||
|
@spec_vote = attr[:spec_vote] || 0
|
||||||
|
@team_lock = attr[:team_lock] || 0
|
||||||
|
@team_balance = attr[:team_balance] || 0
|
||||||
|
@player_slots = attr[:player_slots] || 16
|
||||||
|
end
|
||||||
|
|
||||||
|
# basically to_network
|
||||||
|
# int array the server sends to the client
|
||||||
|
def to_a
|
||||||
|
Packer.pack_int(@kick_vote) +
|
||||||
|
Packer.pack_int(@kick_min) +
|
||||||
|
Packer.pack_int(@spec_vote) +
|
||||||
|
Packer.pack_int(@team_lock) +
|
||||||
|
Packer.pack_int(@team_balance) +
|
||||||
|
Packer.pack_int(@player_slots)
|
||||||
|
end
|
||||||
|
end
|
|
@ -213,6 +213,13 @@ class TeeworldsServer
|
||||||
@netbase.send_packet(msg, chunks: 1, client:)
|
@netbase.send_packet(msg, chunks: 1, client:)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def send_server_settings(client, server_settings)
|
||||||
|
msg = NetChunk.create_header(vital: true, size: 1 + server_settings.size, client:) +
|
||||||
|
[pack_msg_id(NETMSGTYPE_SV_SERVERSETTINGS, system: false)] +
|
||||||
|
server_settings
|
||||||
|
@netbase.send_packet(msg, chunks: 1, client:)
|
||||||
|
end
|
||||||
|
|
||||||
def send_server_info(client, server_info)
|
def send_server_info(client, server_info)
|
||||||
msg = NetChunk.create_header(vital: true, size: 1 + server_info.size, client:) +
|
msg = NetChunk.create_header(vital: true, size: 1 + server_info.size, client:) +
|
||||||
[pack_msg_id(NETMSG_SERVERINFO, system: true)] +
|
[pack_msg_id(NETMSG_SERVERINFO, system: true)] +
|
||||||
|
|
Loading…
Reference in a new issue