Add player info snap obj

This commit is contained in:
ChillerDragon 2022-11-19 10:16:00 +01:00
parent d4ccfc24e1
commit 0bcd7bb960
4 changed files with 26 additions and 6 deletions

View file

@ -1,6 +1,5 @@
# frozen_string_literal: true
require_relative '../../packer'
require_relative '../snap_item_base'
class NetObj

View file

@ -1,6 +1,5 @@
# frozen_string_literal: true
require_relative '../../packer'
require_relative '../snap_item_base'
class NetObj

View file

@ -0,0 +1,22 @@
# frozen_string_literal: true
require_relative '../snap_item_base'
class NetObj
class PlayerInfo < SnapItemBase
attr_accessor :player_flags, :score, :latency
def initialize(hash_or_raw)
@field_names = %i[
player_flags
score
latency
]
super
end
def self.match_type?(type)
type == NETOBJTYPE_PLAYERINFO
end
end
end

View file

@ -2,6 +2,7 @@
require_relative 'items/game_data'
require_relative 'items/character'
require_relative 'items/player_info'
require_relative '../packer'
class SnapshotUnpacker
@ -147,16 +148,15 @@ class SnapshotUnpacker
obj = nil
if NetObj::GameData.match_type?(item_type)
obj = NetObj::GameData.new(u)
notes += obj.notes
# p obj
elsif NetObj::Character.match_type?(item_type)
obj = NetObj::Character.new(u)
notes += obj.notes
# p obj
elsif NetObj::PlayerInfo.match_type?(item_type)
obj = NetObj::PlayerInfo.new(u)
elsif @verbose
puts "no match #{item_type}"
end
if obj
notes += obj.notes
notes.push([
:green,
id_parsed[:pos],