From 8fe595b0a6c2979abaeccdde256551b03aefa194 Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Sat, 5 Nov 2022 11:34:34 +0100 Subject: [PATCH] Client info is actually used to display join msgs Looked at the c++ client code and it actually does that. The entergame message is only used in demos. Yeet on those. --- lib/game_client.rb | 16 +++------------- lib/teeworlds-client.rb | 1 - sample.rb | 9 --------- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/lib/game_client.rb b/lib/game_client.rb index 70bbba9..c9114a5 100644 --- a/lib/game_client.rb +++ b/lib/game_client.rb @@ -38,11 +38,6 @@ class GameClient @players = {} end - def on_client_enter(chunk) - puts "ON CLIENT ENTER" - puts chunk - end - def on_client_info(chunk) # puts "Got playerinfo flags: #{chunk.flags}" u = Unpacker.new(chunk.data[1..]) @@ -86,6 +81,9 @@ class GameClient @client.send_msg_startinfo end + def on_emoticon(chunk) + end + def on_map_change(chunk) context = Context.new(@client, chunk: chunk) if @client.hooks[:map_change] @@ -99,14 +97,6 @@ class GameClient end def on_chat(chunk) - # 06 01 00 40 41 00 - # msg mode cl_id trgt A nullbyte? - # all -1 - # mode = chunk.data[1] - # client_id = chunk.data[2] - # target = chunk.data[3] - # msg = chunk.data[4..] - u = Unpacker.new(chunk.data[1..]) data = { mode: u.get_int(), diff --git a/lib/teeworlds-client.rb b/lib/teeworlds-client.rb index 0deed7b..634c433 100644 --- a/lib/teeworlds-client.rb +++ b/lib/teeworlds-client.rb @@ -265,7 +265,6 @@ class TeeworldsClient case chunk.msg when NETMSGTYPE_SV_READYTOENTER then @game_client.on_ready_to_enter(chunk) when NETMSGTYPE_SV_CLIENTINFO then @game_client.on_client_info(chunk) - when NETMSGTYPE_DE_CLIENTENTER then @game_client.on_client_enter(chunk) when NETMSGTYPE_SV_EMOTICON then @game_client.on_emoticon(chunk) when NETMSGTYPE_SV_CHAT then @game_client.on_chat(chunk) else diff --git a/sample.rb b/sample.rb index 4f15e53..efdda33 100755 --- a/sample.rb +++ b/sample.rb @@ -27,9 +27,6 @@ args[:port] = args[:port] || 8303 client = TeeworldsClient.new(verbose: args[:verbose]) -client.set_startinfo( - name: "ruby gamer") - client.on_chat do |msg| puts "[chat] #{msg}" end @@ -39,10 +36,4 @@ Signal.trap('INT') do end # connect and detach thread -client.connect(args[:ip], args[:port], detach: true) - -# after 2 seconds reconnect -# and block the main thread -sleep 2 client.connect(args[:ip], args[:port], detach: false) -