rrb-common 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rune/common.rb +23 -7
- data/lib/rune/core/archive.rb +116 -0
- data/lib/rune/{network → core}/buffer.rb +9 -3
- data/lib/rune/{network → core}/constants.rb +17 -1
- data/lib/rune/core/identifiable.rb +47 -0
- data/lib/rune/{network → core}/isaac.rb +1 -1
- data/lib/rune/core/logging.rb +69 -0
- data/lib/rune/{network/readable.rb → core/readable_buffer.rb} +1 -1
- data/lib/rune/core/unit.rb +28 -0
- data/lib/rune/{network/writeable.rb → core/writeable_buffer.rb} +10 -11
- metadata +66 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77d064b5d3c6ebddbf4758b0c4848f35159c8181c503cd8c8438390605e3071c
|
4
|
+
data.tar.gz: 339bd670c3725bd9610ca0c247b3902c07bd8af7a6ad8bb894878dcf02ca8669
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05c95f37e85863385d75c8bd9dca484a86a51bd45c84dab4e91abda6e948997c9bdaa21f96f8fa281d614644c21712497345a47f998cfa271e13059b524c73b9
|
7
|
+
data.tar.gz: 86fe15955d0fc6c5c702e2b4cbe6109e97d5d3987612eb6510c513df7a47425bcaee14df391697163fd9fd5d6a106b568fae893afe714e9b53fabeb57ee01f14
|
data/lib/rune/common.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
Dir[File.dirname(__FILE__)].each { |file| $LOAD_PATH.unshift(file) if File.directory? file }
|
2
2
|
|
3
|
+
require 'console'
|
4
|
+
require 'dry/configurable'
|
5
|
+
require 'dry/container'
|
6
|
+
require 'securerandom'
|
7
|
+
require 'singleton'
|
8
|
+
|
3
9
|
# A game server written in Ruby targeting the 2006 era (or the 317-377 protocols) of the popular MMORPG, RuneScape.
|
4
10
|
#
|
5
11
|
# @title RuneRb
|
@@ -7,13 +13,17 @@ Dir[File.dirname(__FILE__)].each { |file| $LOAD_PATH.unshift(file) if File.direc
|
|
7
13
|
# @since 0.1.0
|
8
14
|
module RuneRb
|
9
15
|
|
10
|
-
# The
|
11
|
-
module
|
12
|
-
autoload :
|
13
|
-
autoload :
|
14
|
-
autoload :
|
15
|
-
autoload :
|
16
|
-
autoload :
|
16
|
+
# The Core module contains the core classes and modules of the Rune.rb framework.
|
17
|
+
module Core
|
18
|
+
autoload :Archive, 'rune/core/archive'
|
19
|
+
autoload :Buffer, 'rune/core/buffer'
|
20
|
+
autoload :Constants, 'rune/core/constants'
|
21
|
+
autoload :Identifiable, 'rune/core/identifiable'
|
22
|
+
autoload :ISAAC, 'rune/core/isaac'
|
23
|
+
autoload :Logging, 'rune/core/logging'
|
24
|
+
autoload :ReadableBuffer, 'rune/core/readable_buffer'
|
25
|
+
autoload :Unit, 'rune/core/unit'
|
26
|
+
autoload :WriteableBuffer, 'rune/core/writeable_buffer'
|
17
27
|
|
18
28
|
include Constants
|
19
29
|
end
|
@@ -23,4 +33,10 @@ module RuneRb
|
|
23
33
|
autoload :IntegerRefinements, 'rune/patches/integer_refinements'
|
24
34
|
autoload :SetRefinements, 'rune/patches/set_refinements'
|
25
35
|
end
|
36
|
+
|
37
|
+
# The Logger utility for the RuneRb framework.
|
38
|
+
# @return [Console::Logger] the logger instance.
|
39
|
+
def self.logger
|
40
|
+
Console.logger
|
41
|
+
end
|
26
42
|
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module RuneRb::Core
|
2
|
+
class Archive
|
3
|
+
include RuneRb::Core::Logging
|
4
|
+
|
5
|
+
# Constructs a new Archive object.
|
6
|
+
# @param path [String] the path to the cache directory.
|
7
|
+
def initialize(path = 'cache/')
|
8
|
+
unless check_for_archives(path)
|
9
|
+
error "Cache archive not found. Please install them into the #{path} directory."
|
10
|
+
return
|
11
|
+
end
|
12
|
+
|
13
|
+
# Find how many index files exist
|
14
|
+
count = 0.upto(255).each do |i|
|
15
|
+
break i unless File.exist?(File.join(path, "main_file_cache.idx#{i}"))
|
16
|
+
end
|
17
|
+
|
18
|
+
# Gather file objects
|
19
|
+
@data_file = File.open(File.join(path, "main_file_cache.dat"), "r")
|
20
|
+
@index_files = []
|
21
|
+
|
22
|
+
count.times do |i|
|
23
|
+
@index_files << File.open(File.join(path, "main_file_cache.idx#{i}"), "r")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Gets a file from the cache.
|
28
|
+
# @param cache [Integer] the cache archive to get the file from.
|
29
|
+
# @param file [Integer] the file to get.
|
30
|
+
def get(cache, file)
|
31
|
+
# then convert crc table stuff (easy with array pack)
|
32
|
+
# then make server send data back to the client
|
33
|
+
|
34
|
+
index_file = @index_files[cache]
|
35
|
+
cache += 1
|
36
|
+
|
37
|
+
index = IO.read(index_file.path, RuneRb::Core::INDEX_SIZE, RuneRb::Core::INDEX_SIZE * file)
|
38
|
+
idx_buffer = RuneRb::Core::Buffer.new(mode: 'r')
|
39
|
+
idx_buffer << index
|
40
|
+
|
41
|
+
file_size = (idx_buffer.read(type: :byte, signed: false) << 16) | (idx_buffer.read(type: :byte, signed: false) << 8) | idx_buffer.read(type: :byte, signed: false)
|
42
|
+
file_block = (idx_buffer.read(type: :byte, signed: false) << 16) | (idx_buffer.read(type: :byte, signed: false) << 8) | idx_buffer.read(type: :byte, signed: false)
|
43
|
+
|
44
|
+
remaining_bytes = file_size
|
45
|
+
current_block = file_block
|
46
|
+
payload = ""
|
47
|
+
cycles = 0
|
48
|
+
|
49
|
+
while remaining_bytes > 0
|
50
|
+
size = RuneRb::Core::DATA_SIZE
|
51
|
+
rem = @data_file.size - current_block * RuneRb::Core::DATA_SIZE
|
52
|
+
size = rem if rem < RuneRb::Core::DATA_SIZE
|
53
|
+
|
54
|
+
header = IO.read(@data_file.path, RuneRb::Core::DATA_HEADER_SIZE, current_block * RuneRb::Cache::DATA_SIZE)
|
55
|
+
header_buffer = RuneRb::Core::Buffer.new(mode: 'r')
|
56
|
+
header_buffer << header
|
57
|
+
|
58
|
+
next_file_id = header_buffer.read(type: :short, signed: false)
|
59
|
+
current_part_id = header_buffer.read(type: :short, signed: false)
|
60
|
+
next_block_id = (header_buffer.read(type: :byte, signed: false) << 16) | (header_buffer.read(type: :byte, signed: false) << 8) | header_buffer.read(type: :byte, signed: false)
|
61
|
+
next_cache_id = header_buffer.read(type: :byte, signed: false)
|
62
|
+
|
63
|
+
size -= 8
|
64
|
+
|
65
|
+
cycle_bytes = remaining_bytes > RuneRb::Core::DATA_BLOCK_SIZE ? RuneRb::Core::DATA_BLOCK_SIZE : remaining_bytes
|
66
|
+
|
67
|
+
payload << IO.read(@data_file.path, cycle_bytes, current_block * RuneRb::Core::DATA_SIZE + RuneRb::Core::DATA_HEADER_SIZE)
|
68
|
+
|
69
|
+
remaining_bytes -= cycle_bytes
|
70
|
+
|
71
|
+
raise "Cycle does not match part id." if cycles != current_part_id
|
72
|
+
|
73
|
+
if remaining_bytes > 0
|
74
|
+
raise "Unexpected next cache id." if next_cache_id != cache
|
75
|
+
raise "Unexpected next file id." if next_file_id != file
|
76
|
+
end
|
77
|
+
|
78
|
+
cycles += 1
|
79
|
+
current_block = next_block_id
|
80
|
+
end
|
81
|
+
|
82
|
+
payload
|
83
|
+
end
|
84
|
+
|
85
|
+
# Closes the archive file streams.
|
86
|
+
def close
|
87
|
+
@data_file.close
|
88
|
+
@index_files.each {|file| file.close }
|
89
|
+
end
|
90
|
+
|
91
|
+
# The number of index files in the cache.
|
92
|
+
# @return [Integer] the number of index files in the cache.
|
93
|
+
def cache_count
|
94
|
+
@index_files.size
|
95
|
+
end
|
96
|
+
|
97
|
+
# The number of files in a cache.
|
98
|
+
# @param cache [Integer] the cache to check.
|
99
|
+
def file_count(cache)
|
100
|
+
(@index_files[cache].size / RuneRb::Core::INDEX_SIZE) - 1
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
# Checks for the existence of cache archives in a path.
|
106
|
+
# @param path [String] the path to the cache directory.
|
107
|
+
def check_for_archives(path)
|
108
|
+
return false if path.nil?
|
109
|
+
return false if !File.directory?(path)
|
110
|
+
return false if !File.exist?(path)
|
111
|
+
return false if !File.readable?(path)
|
112
|
+
return false if Dir.empty?(path)
|
113
|
+
true
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module RuneRb::
|
1
|
+
module RuneRb::Core
|
2
2
|
|
3
3
|
# A Buffer encapsulates raw data in a String instance. Depending on the mode, the buffer can be read from or written to.
|
4
4
|
class Buffer
|
@@ -20,6 +20,12 @@ module RuneRb::Network
|
|
20
20
|
@data.dup
|
21
21
|
end
|
22
22
|
|
23
|
+
# Is the {Buffer#data} empty?
|
24
|
+
# @return [Boolean] true if the {Buffer#data} is empty, false otherwise.
|
25
|
+
def empty?
|
26
|
+
@data.empty?
|
27
|
+
end
|
28
|
+
|
23
29
|
# Returns the limit of the buffer.
|
24
30
|
# @return [Integer] the limit of the buffer.
|
25
31
|
def length
|
@@ -61,14 +67,14 @@ module RuneRb::Network
|
|
61
67
|
|
62
68
|
# Enables read functions on the buffer instance. Bit Access is disabled by default. Sets the bit position to 0.
|
63
69
|
def enable_readable
|
64
|
-
singleton_class.include(RuneRb::
|
70
|
+
singleton_class.include(RuneRb::Core::ReadableBuffer)
|
65
71
|
@bit_access = false
|
66
72
|
@bit_position = 0
|
67
73
|
end
|
68
74
|
|
69
75
|
# Enables write functions on the buffer instance.
|
70
76
|
def enable_writeable
|
71
|
-
singleton_class.include(RuneRb::
|
77
|
+
singleton_class.include(RuneRb::Core::WriteableBuffer)
|
72
78
|
end
|
73
79
|
end
|
74
80
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module RuneRb::
|
1
|
+
module RuneRb::Core::Constants
|
2
2
|
# Acceptable byte orders in which multi-byte values can be read.
|
3
3
|
# @return [Array<Symbol>]
|
4
4
|
BYTE_ORDERS = %i[BIG MIDDLE INVERSE_MIDDLE LITTLE].freeze
|
@@ -18,4 +18,20 @@ module RuneRb::Network::Constants
|
|
18
18
|
# Bit masks for bit packing
|
19
19
|
# @return [Array<Integer>]
|
20
20
|
BIT_MASK_OUT = (0...32).collect { (1 << _1) - 1 }.freeze
|
21
|
+
|
22
|
+
# The size of a single index
|
23
|
+
# @return [Integer]
|
24
|
+
INDEX_SIZE = 0x6
|
25
|
+
|
26
|
+
# The size of a single data block
|
27
|
+
# @return [Integer]
|
28
|
+
DATA_BLOCK_SIZE = 0x200
|
29
|
+
|
30
|
+
# The size of a single data header
|
31
|
+
# @return [Integer]
|
32
|
+
DATA_HEADER_SIZE = 0x8
|
33
|
+
|
34
|
+
# The size of a chunk of data
|
35
|
+
# @return [Integer]
|
36
|
+
DATA_SIZE = DATA_BLOCK_SIZE + DATA_HEADER_SIZE
|
21
37
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module RuneRb::Core::Identifiable
|
2
|
+
# @!attribute [r] id
|
3
|
+
# @return [String, Integer, Symbol] - The identifier of the object.
|
4
|
+
attr_reader :identifier
|
5
|
+
|
6
|
+
# The identifier of the object.
|
7
|
+
# @return [String, Integer, Symbol] - The identifier of the object.
|
8
|
+
def identifier
|
9
|
+
@identifier ||= SecureRandom.uuid
|
10
|
+
@identifier
|
11
|
+
end
|
12
|
+
|
13
|
+
alias id identifier
|
14
|
+
alias signature identifier
|
15
|
+
end
|
16
|
+
|
17
|
+
############################################################################################################
|
18
|
+
# Copyright (c) 2023, Patrick W. #
|
19
|
+
# All rights reserved. #
|
20
|
+
# #
|
21
|
+
# Redistribution and use in source and binary forms, with or without #
|
22
|
+
# modification, are permitted provided that the following conditions are met: #
|
23
|
+
# #
|
24
|
+
# * Redistributions of source code must retain the above copyright notice, this #
|
25
|
+
# list of conditions and the following disclaimer. #
|
26
|
+
# #
|
27
|
+
# * Redistributions in binary form must reproduce the above copyright notice, #
|
28
|
+
# this list of conditions and the following disclaimer in the documentation #
|
29
|
+
# and/or other materials provided with the distribution. #
|
30
|
+
# #
|
31
|
+
# * Neither the name of the copyright holder nor the names of its #
|
32
|
+
# contributors may be used to endorse or promote products derived from #
|
33
|
+
# this software without specific prior written permission. #
|
34
|
+
# #
|
35
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" #
|
36
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE #
|
37
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE #
|
38
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE #
|
39
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL #
|
40
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR #
|
41
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER #
|
42
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, #
|
43
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE #
|
44
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #
|
45
|
+
# #
|
46
|
+
############################################################################################################
|
47
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# A module responsible for setting up logging functions.
|
4
|
+
module RuneRb::Core::Logging
|
5
|
+
|
6
|
+
# Write information to the log.
|
7
|
+
# @param lines [Array, String] the lines to write to the log.
|
8
|
+
def log(*lines)
|
9
|
+
RuneRb.logger.info(self.class.name) { lines.join("\n") }
|
10
|
+
end
|
11
|
+
|
12
|
+
alias info log
|
13
|
+
|
14
|
+
# Write a warning to the log.
|
15
|
+
# @param lines [Array, String] the lines to write to the log.
|
16
|
+
def log!(*lines)
|
17
|
+
RuneRb.logger.warn(self.class.name) { lines.join("\n") }
|
18
|
+
end
|
19
|
+
|
20
|
+
alias warn log!
|
21
|
+
|
22
|
+
# Write an error to the log.
|
23
|
+
# @param lines [Array, String] the lines to write to the log.
|
24
|
+
def err(*lines)
|
25
|
+
RuneRb.logger.error(self.class.name) { lines.join("\n") }
|
26
|
+
end
|
27
|
+
|
28
|
+
alias error err
|
29
|
+
|
30
|
+
# Write a fatal error to the log.
|
31
|
+
# @param lines [Array, String] the lines to write to the log.
|
32
|
+
def err!(*lines)
|
33
|
+
RuneRb.logger.fatal(self.class.name) { lines.join("\n") }
|
34
|
+
end
|
35
|
+
|
36
|
+
alias fatal err!
|
37
|
+
end
|
38
|
+
|
39
|
+
############################################################################################################
|
40
|
+
# Copyright (c) 2023, Patrick W. #
|
41
|
+
# All rights reserved. #
|
42
|
+
# #
|
43
|
+
# Redistribution and use in source and binary forms, with or without #
|
44
|
+
# modification, are permitted provided that the following conditions are met: #
|
45
|
+
# #
|
46
|
+
# * Redistributions of source code must retain the above copyright notice, this #
|
47
|
+
# list of conditions and the following disclaimer. #
|
48
|
+
# #
|
49
|
+
# * Redistributions in binary form must reproduce the above copyright notice, #
|
50
|
+
# this list of conditions and the following disclaimer in the documentation #
|
51
|
+
# and/or other materials provided with the distribution. #
|
52
|
+
# #
|
53
|
+
# * Neither the name of the copyright holder nor the names of its #
|
54
|
+
# contributors may be used to endorse or promote products derived from #
|
55
|
+
# this software without specific prior written permission. #
|
56
|
+
# #
|
57
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" #
|
58
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE #
|
59
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE #
|
60
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE #
|
61
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL #
|
62
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR #
|
63
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER #
|
64
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, #
|
65
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE #
|
66
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #
|
67
|
+
# #
|
68
|
+
############################################################################################################
|
69
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module RuneRb::Core
|
2
|
+
# A Unit is a {Dry::Container} that encapsulates specific logic for a given system. Units are used to construct and run certain parts of the game. All {Unit} instances should include the {Singletons}.
|
3
|
+
# @abstract
|
4
|
+
class Unit
|
5
|
+
extend Dry::Configurable
|
6
|
+
include Dry::Container::Mixin
|
7
|
+
include RuneRb::Core::Logging
|
8
|
+
include Singleton
|
9
|
+
|
10
|
+
# Constructs a new instance of {Unit} and sets the name to the class name.
|
11
|
+
def initialize
|
12
|
+
@name = self.class.name.split('::')[-2]
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
# Prepares the unit for use. Providers are loaded and imported based on the configuration.
|
17
|
+
def prepare
|
18
|
+
info "Preparing #{@name} unit."
|
19
|
+
|
20
|
+
# Determine directory based on the class of the current instance
|
21
|
+
class_directory = File.dirname(self.class.instance_method(:prepare).source_location.first)
|
22
|
+
providers_directory = File.join(class_directory, 'providers', '*.rb')
|
23
|
+
|
24
|
+
# Load providers
|
25
|
+
Dir[providers_directory].sort.each { |provider| require provider }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# The Writeable module contains functions for writing data to a {Buffer} object.
|
2
|
-
module RuneRb::
|
2
|
+
module RuneRb::Core::WriteableBuffer
|
3
3
|
|
4
4
|
# Write data to the payload.
|
5
5
|
# @param value [Integer, String, Message, Array] the value to write.
|
@@ -107,11 +107,11 @@ module RuneRb::Network::Writeable
|
|
107
107
|
def write_long(value, mutation: :STD, signed: false, order: :BIG)
|
108
108
|
case order
|
109
109
|
when :BIG
|
110
|
-
(RuneRb::
|
110
|
+
(RuneRb::Core::BYTE_SIZE * 7).downto(0) { |div| ((div % 8).zero? and div.positive?) ? write_byte(value >> div) : next }
|
111
111
|
write_byte(value, mutation: mutation, signed: signed)
|
112
112
|
when :LITTLE
|
113
113
|
write_byte(value, mutation: mutation, signed: signed)
|
114
|
-
(0).upto(RuneRb::
|
114
|
+
(0).upto(RuneRb::Core::BYTE_SIZE * 7) { |div| ((div % 8).zero? and div.positive?) ? write_byte(value >> div) : next }
|
115
115
|
else raise "Unrecognized byte order: #{order}"
|
116
116
|
end
|
117
117
|
end
|
@@ -141,8 +141,7 @@ module RuneRb::Network::Writeable
|
|
141
141
|
def write_bytes(values)
|
142
142
|
case values
|
143
143
|
when Array then values.each { |byte| write_byte(byte.to_i) }
|
144
|
-
when RuneRb::
|
145
|
-
when RuneRb::Network::Buffer then send(:put, values)
|
144
|
+
when RuneRb::Core::Buffer then @data.concat(values.instance_variable_get(:@data))
|
146
145
|
when String then send(:<<, values)
|
147
146
|
end
|
148
147
|
end
|
@@ -173,8 +172,8 @@ module RuneRb::Network::Writeable
|
|
173
172
|
|
174
173
|
while amount > bit_offset
|
175
174
|
@buffer[byte_pos] = [0].pack('c') if @buffer[byte_pos].nil?
|
176
|
-
@buffer[byte_pos] = [(@buffer[byte_pos].unpack1('c') & ~RuneRb::
|
177
|
-
@buffer[byte_pos] = [(@buffer[byte_pos].unpack1('c') | (value >> (amount - bit_offset)) & RuneRb::
|
175
|
+
@buffer[byte_pos] = [(@buffer[byte_pos].unpack1('c') & ~RuneRb::Core::BIT_MASK_OUT[bit_offset])].pack('c')
|
176
|
+
@buffer[byte_pos] = [(@buffer[byte_pos].unpack1('c') | (value >> (amount - bit_offset)) & RuneRb::Core::BIT_MASK_OUT[bit_offset])].pack('c')
|
178
177
|
byte_pos += 1
|
179
178
|
amount -= bit_offset
|
180
179
|
bit_offset = 8
|
@@ -183,11 +182,11 @@ module RuneRb::Network::Writeable
|
|
183
182
|
@buffer[byte_pos] = [0].pack('c') if @buffer[byte_pos].nil?
|
184
183
|
|
185
184
|
if amount == bit_offset
|
186
|
-
@buffer[byte_pos] = [(@buffer[byte_pos].unpack1('c') & ~RuneRb::
|
187
|
-
@buffer[byte_pos] = [(@buffer[byte_pos].unpack1('c') | (value &
|
185
|
+
@buffer[byte_pos] = [(@buffer[byte_pos].unpack1('c') & ~RuneRb::Core::BIT_MASK_OUT[bit_offset])].pack('c')
|
186
|
+
@buffer[byte_pos] = [(@buffer[byte_pos].unpack1('c') | (value & RuneRb::Core::BIT_MASK_OUT[bit_offset]))].pack('c')
|
188
187
|
else
|
189
|
-
@buffer[byte_pos] = [(@buffer[byte_pos].unpack1('c') & ~(RuneRb::
|
190
|
-
@buffer[byte_pos] = [(@buffer[byte_pos].unpack1('c') | ((value & RuneRb::
|
188
|
+
@buffer[byte_pos] = [(@buffer[byte_pos].unpack1('c') & ~(RuneRb::Core::BIT_MASK_OUT[amount] << (bit_offset - amount)))].pack('c')
|
189
|
+
@buffer[byte_pos] = [(@buffer[byte_pos].unpack1('c') | ((value & RuneRb::Core::BIT_MASK_OUT[amount]) << (bit_offset - amount)))].pack('c')
|
191
190
|
end
|
192
191
|
end
|
193
192
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rrb-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick W.
|
@@ -24,6 +24,62 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dry-configurable
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.16'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.16'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dry-container
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.11'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.11'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: console
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: singleton
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.2'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.2'
|
27
83
|
- !ruby/object:Gem::Dependency
|
28
84
|
name: benchmark
|
29
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,11 +157,15 @@ extensions: []
|
|
101
157
|
extra_rdoc_files: []
|
102
158
|
files:
|
103
159
|
- lib/rune/common.rb
|
104
|
-
- lib/rune/
|
105
|
-
- lib/rune/
|
106
|
-
- lib/rune/
|
107
|
-
- lib/rune/
|
108
|
-
- lib/rune/
|
160
|
+
- lib/rune/core/archive.rb
|
161
|
+
- lib/rune/core/buffer.rb
|
162
|
+
- lib/rune/core/constants.rb
|
163
|
+
- lib/rune/core/identifiable.rb
|
164
|
+
- lib/rune/core/isaac.rb
|
165
|
+
- lib/rune/core/logging.rb
|
166
|
+
- lib/rune/core/readable_buffer.rb
|
167
|
+
- lib/rune/core/unit.rb
|
168
|
+
- lib/rune/core/writeable_buffer.rb
|
109
169
|
- lib/rune/patches/integer_refinements.rb
|
110
170
|
- lib/rune/patches/set_refinements.rb
|
111
171
|
homepage:
|