Move all network payload classes to messages/
This commit is contained in:
parent
0f4646e011
commit
4a12262ad3
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
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 'messages/input_timing'
|
||||||
require_relative 'models/sv_client_drop'
|
require_relative 'messages/sv_client_drop'
|
||||||
require_relative 'packer'
|
require_relative 'packer'
|
||||||
require_relative 'context'
|
require_relative 'context'
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative 'models/map'
|
require_relative 'models/map'
|
||||||
require_relative 'models/server_info'
|
|
||||||
require_relative 'models/server_settings'
|
|
||||||
require_relative 'models/game_info'
|
|
||||||
require_relative 'models/start_info'
|
|
||||||
require_relative 'models/cl_say'
|
|
||||||
require_relative 'models/chat_message'
|
require_relative 'models/chat_message'
|
||||||
require_relative 'models/cl_emoticon'
|
require_relative 'messages/game_info'
|
||||||
|
require_relative 'messages/server_info'
|
||||||
|
require_relative 'messages/server_settings'
|
||||||
|
require_relative 'messages/start_info'
|
||||||
|
require_relative 'messages/cl_say'
|
||||||
|
require_relative 'messages/cl_emoticon'
|
||||||
|
|
||||||
class GameServer
|
class GameServer
|
||||||
attr_accessor :pred_game_tick, :ack_game_tick, :map
|
attr_accessor :pred_game_tick, :ack_game_tick, :map
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
##
|
|
||||||
# Turns int into network byte
|
|
||||||
#
|
|
||||||
# Takes a NETMSGTYPE_CL_* integer
|
|
||||||
# and returns a byte that can be send over
|
|
||||||
# the network
|
|
||||||
def pack_msg_id(msg_id, options = { system: false })
|
|
||||||
(msg_id << 1) | (options[:system] ? 1 : 0)
|
|
||||||
end
|
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative '../network'
|
require_relative '../network'
|
||||||
require_relative 'player'
|
require_relative '../models/player'
|
||||||
require_relative '../packer'
|
require_relative '../packer'
|
||||||
|
|
||||||
class ServerInfo
|
class ServerInfo
|
|
@ -2,6 +2,16 @@
|
||||||
|
|
||||||
require_relative 'models/token'
|
require_relative 'models/token'
|
||||||
|
|
||||||
|
##
|
||||||
|
# Turns int into network byte
|
||||||
|
#
|
||||||
|
# Takes a NETMSGTYPE_CL_* integer
|
||||||
|
# and returns a byte that can be send over
|
||||||
|
# the network
|
||||||
|
def pack_msg_id(msg_id, options = { system: false })
|
||||||
|
(msg_id << 1) | (options[:system] ? 1 : 0)
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# NetBase
|
# NetBase
|
||||||
#
|
#
|
||||||
|
|
|
@ -8,12 +8,11 @@ require_relative 'bytes'
|
||||||
require_relative 'network'
|
require_relative 'network'
|
||||||
require_relative 'packet'
|
require_relative 'packet'
|
||||||
require_relative 'chunk'
|
require_relative 'chunk'
|
||||||
require_relative 'models/server_info'
|
require_relative 'messages/server_info'
|
||||||
require_relative 'net_base'
|
require_relative 'net_base'
|
||||||
require_relative 'packer'
|
require_relative 'packer'
|
||||||
require_relative 'models/player'
|
require_relative 'models/player'
|
||||||
require_relative 'game_client'
|
require_relative 'game_client'
|
||||||
require_relative 'message'
|
|
||||||
|
|
||||||
class TeeworldsClient
|
class TeeworldsClient
|
||||||
attr_reader :state, :hooks, :game_client
|
attr_reader :state, :hooks, :game_client
|
||||||
|
|
|
@ -12,7 +12,6 @@ require_relative 'net_base'
|
||||||
require_relative 'models/net_addr'
|
require_relative 'models/net_addr'
|
||||||
require_relative 'packer'
|
require_relative 'packer'
|
||||||
require_relative 'game_server'
|
require_relative 'game_server'
|
||||||
require_relative 'message'
|
|
||||||
require_relative 'models/token'
|
require_relative 'models/token'
|
||||||
|
|
||||||
class Client
|
class Client
|
||||||
|
|
|
@ -427,7 +427,7 @@ function action_generate() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local destfile
|
local destfile
|
||||||
destfile="lib/models/$(basename "$tmpfile")"
|
destfile="lib/messages/$(basename "$tmpfile")"
|
||||||
if [ -f "$destfile" ]
|
if [ -f "$destfile" ]
|
||||||
then
|
then
|
||||||
echo "Error: file already exists '$destfile'"
|
echo "Error: file already exists '$destfile'"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative '../lib/models/server_info'
|
require_relative '../lib/messages/server_info'
|
||||||
|
|
||||||
describe 'ServerInfo', :server_info do
|
describe 'ServerInfo', :server_info do
|
||||||
context 'Pack to network' do
|
context 'Pack to network' do
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative '../lib/models/game_info'
|
require_relative '../lib/messages/game_info'
|
||||||
|
|
||||||
describe 'GameInfo', :game_info do
|
describe 'GameInfo', :game_info do
|
||||||
context 'Pack to network' do
|
context 'Pack to network' do
|
||||||
|
|
Loading…
Reference in a new issue