Use SvClientDrop on the client side
This commit is contained in:
parent
c11a7ae2d2
commit
6283648964
|
@ -3,6 +3,7 @@
|
||||||
require_relative 'models/player'
|
require_relative 'models/player'
|
||||||
require_relative 'models/chat_message'
|
require_relative 'models/chat_message'
|
||||||
require_relative 'models/input_timing'
|
require_relative 'models/input_timing'
|
||||||
|
require_relative 'models/sv_client_drop'
|
||||||
require_relative 'packer'
|
require_relative 'packer'
|
||||||
require_relative 'context'
|
require_relative 'context'
|
||||||
|
|
||||||
|
@ -58,23 +59,19 @@ class GameClient
|
||||||
|
|
||||||
def on_input_timing(chunk)
|
def on_input_timing(chunk)
|
||||||
todo_rename_this = InputTiming.new(chunk.data[1..])
|
todo_rename_this = InputTiming.new(chunk.data[1..])
|
||||||
context = Context.new(todo_rename_this, chunk:, packet:)
|
context = Context.new(todo_rename_this, chunk:)
|
||||||
call_hook(:input_timing, context)
|
call_hook(:input_timing, context)
|
||||||
end
|
end
|
||||||
|
|
||||||
def on_client_drop(chunk)
|
def on_client_drop(chunk)
|
||||||
u = Unpacker.new(chunk.data[1..])
|
todo_rename_this = SvClientDrop.new(chunk.data[1..])
|
||||||
client_id = u.get_int
|
|
||||||
reason = u.get_string
|
|
||||||
silent = u.get_int
|
|
||||||
|
|
||||||
context = Context.new(
|
context = Context.new(
|
||||||
nil,
|
nil,
|
||||||
player: @players[client_id],
|
player: @players[todo_rename_this.client_id],
|
||||||
chunk:,
|
chunk:,
|
||||||
client_id:,
|
client_id: todo_rename_this.client_id,
|
||||||
reason: reason == '' ? nil : reason,
|
reason: todo_rename_this.reason,
|
||||||
silent: silent != 0
|
silent: todo_rename_this.silent?
|
||||||
)
|
)
|
||||||
return if call_hook(:client_drop, context).nil?
|
return if call_hook(:client_drop, context).nil?
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,13 @@ class SvClientDrop
|
||||||
u = Unpacker.new(data)
|
u = Unpacker.new(data)
|
||||||
@client_id = u.get_int
|
@client_id = u.get_int
|
||||||
@reason = u.get_string
|
@reason = u.get_string
|
||||||
|
@reason = @reason == '' ? nil : @reason
|
||||||
@silent = u.get_int
|
@silent = u.get_int
|
||||||
end
|
end
|
||||||
|
|
||||||
def init_hash(attr)
|
def init_hash(attr)
|
||||||
@client_id = attr[:client_id] || 0
|
@client_id = attr[:client_id] || 0
|
||||||
@reason = attr[:reason] || ''
|
@reason = attr[:reason] == '' ? nil : attr[:reason]
|
||||||
@silent = attr[:silent] || false
|
@silent = attr[:silent] || false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue