From 0dcb85a0e3d188d044db3e149b6d82725ac7d2a4 Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Sat, 20 Jan 2024 22:37:18 +0800 Subject: [PATCH] rubocop -A --- examples/08_gui_snapshot.rb | 2 +- lib/array.rb | 2 +- lib/context.rb | 2 +- lib/game_server.rb | 2 +- lib/snapshot/items/tune_params.rb | 2 +- lib/snapshot/snap_item_base.rb | 2 +- lib/teeworlds_client.rb | 2 +- lib/teeworlds_server.rb | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/08_gui_snapshot.rb b/examples/08_gui_snapshot.rb index d582b0f..e06e523 100755 --- a/examples/08_gui_snapshot.rb +++ b/examples/08_gui_snapshot.rb @@ -68,7 +68,7 @@ class Gui < Gosu::Window own_tee = @tees[@client.local_client_id] own_tee = @tees.first.last if own_tee.nil? offset = center_around_tee(own_tee) - @tees.each do |_id, tee| + @tees.each_value do |tee| @tee_image.draw(tee.x + offset.x, tee.y + offset.y) end end diff --git a/lib/array.rb b/lib/array.rb index 90751d6..bf4c616 100644 --- a/lib/array.rb +++ b/lib/array.rb @@ -22,7 +22,7 @@ class Array group = [] end end - groups.push(group) unless group.size.zero? + groups.push(group) unless group.empty? groups end end diff --git a/lib/context.rb b/lib/context.rb index 86f4b00..5dfac22 100644 --- a/lib/context.rb +++ b/lib/context.rb @@ -12,7 +12,7 @@ class Context end def verify - @data.each do |key, _value| + @data.each_key do |key| next if @old_data.key? key raise "Error: invalid data key '#{key}'\n valid keys: #{@old_data.keys}" diff --git a/lib/game_server.rb b/lib/game_server.rb index 7cb441f..571e8bf 100644 --- a/lib/game_server.rb +++ b/lib/game_server.rb @@ -149,7 +149,7 @@ class GameServer return if call_hook(:shutdown, Context.new(nil)).nil? puts '[gameserver] disconnecting all clients ...' - @server.clients.each do |_id, client| + @server.clients.each_value do |client| @server.send_ctrl_close(client, @server.shutdown_reason) end puts '[gameserver] shutting down ...' diff --git a/lib/snapshot/items/tune_params.rb b/lib/snapshot/items/tune_params.rb index 8b65df1..edb41ef 100644 --- a/lib/snapshot/items/tune_params.rb +++ b/lib/snapshot/items/tune_params.rb @@ -25,7 +25,7 @@ class NetObj end def validate - @fields.select(&:nil?).empty? + @fields.none?(&:nil?) end def init_unpacker(u) diff --git a/lib/snapshot/snap_item_base.rb b/lib/snapshot/snap_item_base.rb index b65db25..486edde 100644 --- a/lib/snapshot/snap_item_base.rb +++ b/lib/snapshot/snap_item_base.rb @@ -22,7 +22,7 @@ class SnapItemBase end def validate - @fields.select(&:nil?).empty? + @fields.none?(&:nil?) end def init_unpacker(u) diff --git a/lib/teeworlds_client.rb b/lib/teeworlds_client.rb index 2791531..aba2b29 100644 --- a/lib/teeworlds_client.rb +++ b/lib/teeworlds_client.rb @@ -438,7 +438,7 @@ class TeeworldsClient def process_server_packet(packet) data = packet.payload - if data.size.zero? + if data.empty? puts 'Error: packet payload is empty' puts packet return diff --git a/lib/teeworlds_server.rb b/lib/teeworlds_server.rb index 93e3df3..d61ce3a 100644 --- a/lib/teeworlds_server.rb +++ b/lib/teeworlds_server.rb @@ -380,7 +380,7 @@ class TeeworldsServer # msg_snap_single = NetChunk.create_header(vital: false, size: data.size + 1) + # [pack_msg_id(NETMSG_SNAPSINGLE, system: true)] + # data - @clients.each do |_id, client| + @clients.each_value do |client| next unless client.in_game? @netbase.send_packet(msg_snap_empty, chunks: 1, client:)