diff --git a/lib/game_server.rb b/lib/game_server.rb index 935081b..0772ba3 100644 --- a/lib/game_server.rb +++ b/lib/game_server.rb @@ -59,6 +59,7 @@ class GameServer # - game info # - client info # - snap single + packet.client.in_game = true @server.send_server_info(packet.client, ServerInfo.new.to_a) @server.send_game_info(packet.client, GameInfo.new.to_a) end diff --git a/lib/teeworlds_server.rb b/lib/teeworlds_server.rb index 2d39efb..69d2fcd 100644 --- a/lib/teeworlds_server.rb +++ b/lib/teeworlds_server.rb @@ -16,7 +16,7 @@ require_relative 'message' require_relative 'token' class Client - attr_accessor :id, :addr, :vital_sent, :last_recv_time, :token, :player + attr_accessor :id, :addr, :vital_sent, :last_recv_time, :token, :player, :in_game attr_reader :ack def initialize(attr = {}) @@ -24,6 +24,7 @@ class Client @addr = attr[:addr] @vital_sent = 0 @ack = 0 + @in_game = false @last_recv_time = Time.now @player = Player.new( id: @id, @@ -37,6 +38,10 @@ class Client SecurityToken.validate(@token) end + def in_game? + @in_game + end + def bump_ack @ack = (@ack + 1) % NET_MAX_SEQUENCE end @@ -297,6 +302,8 @@ class TeeworldsServer [pack_msg_id(NETMSG_SNAPEMPTY, system: true)] + data @clients.each do |_id, client| + next unless client.in_game? + @netbase.send_packet(msg_snap_empty, chunks: 1, client:) end end