Move all network payload classes to messages/

This commit is contained in:
ChillerDragon 2022-11-16 09:37:47 +01:00
parent 0f4646e011
commit 4a12262ad3
18 changed files with 23 additions and 26 deletions

View file

@ -2,8 +2,8 @@
require_relative 'models/player'
require_relative 'models/chat_message'
require_relative 'models/input_timing'
require_relative 'models/sv_client_drop'
require_relative 'messages/input_timing'
require_relative 'messages/sv_client_drop'
require_relative 'packer'
require_relative 'context'

View file

@ -1,13 +1,13 @@
# frozen_string_literal: true
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/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
attr_accessor :pred_game_tick, :ack_game_tick, :map

View file

@ -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

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
require_relative '../network'
require_relative 'player'
require_relative '../models/player'
require_relative '../packer'
class ServerInfo

View file

@ -2,6 +2,16 @@
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
#

View file

@ -8,12 +8,11 @@ require_relative 'bytes'
require_relative 'network'
require_relative 'packet'
require_relative 'chunk'
require_relative 'models/server_info'
require_relative 'messages/server_info'
require_relative 'net_base'
require_relative 'packer'
require_relative 'models/player'
require_relative 'game_client'
require_relative 'message'
class TeeworldsClient
attr_reader :state, :hooks, :game_client

View file

@ -12,7 +12,6 @@ require_relative 'net_base'
require_relative 'models/net_addr'
require_relative 'packer'
require_relative 'game_server'
require_relative 'message'
require_relative 'models/token'
class Client

View file

@ -427,7 +427,7 @@ function action_generate() {
fi
local destfile
destfile="lib/models/$(basename "$tmpfile")"
destfile="lib/messages/$(basename "$tmpfile")"
if [ -f "$destfile" ]
then
echo "Error: file already exists '$destfile'"

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
require_relative '../lib/models/server_info'
require_relative '../lib/messages/server_info'
describe 'ServerInfo', :server_info do
context 'Pack to network' do

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
require_relative '../lib/models/game_info'
require_relative '../lib/messages/game_info'
describe 'GameInfo', :game_info do
context 'Pack to network' do