Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
RuneSafe
rsmod2
Commits
9c3c7fb8
Commit
9c3c7fb8
authored
2 years ago
by
Tomm0017
Browse files
Options
Download
Email Patches
Plain Diff
Remove `I26BitCode`
parent
77774cf7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
plugins/info/src/main/kotlin/org/rsmod/plugins/info/player/buffer/BitCodes.kt
+0
-11
...n/kotlin/org/rsmod/plugins/info/player/buffer/BitCodes.kt
plugins/info/src/main/kotlin/org/rsmod/plugins/info/player/model/bitcode/I26BitCode.kt
+0
-32
...org/rsmod/plugins/info/player/model/bitcode/I26BitCode.kt
plugins/info/src/test/kotlin/org/rsmod/plugins/info/player/model/bitcode/I26BitCodeTest.kt
+0
-67
...rsmod/plugins/info/player/model/bitcode/I26BitCodeTest.kt
with
0 additions
and
110 deletions
+0
-110
plugins/info/src/main/kotlin/org/rsmod/plugins/info/player/buffer/BitCodes.kt
+
0
-
11
View file @
9c3c7fb8
package
org.rsmod.plugins.info.player.buffer
import
org.rsmod.plugins.info.player.model.bitcode.I26BitCode
import
org.rsmod.plugins.info.player.model.coord.HighResCoord
import
org.rsmod.plugins.info.player.model.coord.LowResCoord
internal
fun
BitBuffer
.
getI26BitCode
(
bits
:
Int
):
I26BitCode
{
return
I26BitCode
(
getBits
(
bits
),
bits
)
}
internal
fun
BitBuffer
.
putI26BitCode
(
bitCode
:
I26BitCode
):
BitBuffer
{
if
(
bitCode
.
bitCount
==
0
)
return
this
putBits
(
bitCode
.
bitCount
,
bitCode
.
value
)
return
this
}
internal
fun
BitBuffer
.
putHighResUpdate
(
extended
:
Boolean
,
currCoords
:
HighResCoord
,
...
...
This diff is collapsed.
Click to expand it.
plugins/info/src/main/kotlin/org/rsmod/plugins/info/player/model/bitcode/I26BitCode.kt
deleted
100644 → 0
+
0
-
32
View file @
77774cf7
package
org.rsmod.plugins.info.player.model.bitcode
@JvmInline
public
value
class
I26BitCode
private
constructor
(
private
val
packed
:
Int
)
{
public
val
value
:
Int
get
()
=
packed
and
VALUE_BITMASK
public
val
bitCount
:
Int
get
()
=
(
packed
shr
VALUE_BITS
)
and
VALUE_BITMASK
public
constructor
(
value
:
Int
,
bitCount
:
Int
)
:
this
(
(
value
and
VALUE_BITMASK
)
or
((
bitCount
and
BIT_COUNT_BITMASK
)
shl
VALUE_BITS
)
)
public
operator
fun
component1
():
Int
=
value
public
operator
fun
component2
():
Int
=
bitCount
public
override
fun
toString
():
String
{
return
"I26BitCode(value=$value, bitCount=$bitCount)"
}
public
companion
object
{
public
val
ZERO
:
I26BitCode
=
I26BitCode
(
0
)
public
const
val
VALUE_BITS
:
Int
=
26
public
const
val
VALUE_BITMASK
:
Int
=
(
1
shl
VALUE_BITS
)
-
1
public
const
val
BIT_COUNT_BITS
:
Int
=
5
public
const
val
BIT_COUNT_BITMASK
:
Int
=
(
1
shl
BIT_COUNT_BITS
)
-
1
}
}
This diff is collapsed.
Click to expand it.
plugins/info/src/test/kotlin/org/rsmod/plugins/info/player/model/bitcode/I26BitCodeTest.kt
deleted
100644 → 0
+
0
-
67
View file @
77774cf7
package
org.rsmod.plugins.info.player.model.bitcode
import
org.junit.jupiter.api.Assertions
import
org.junit.jupiter.api.Test
import
org.junit.jupiter.api.extension.ExtensionContext
import
org.junit.jupiter.params.ParameterizedTest
import
org.junit.jupiter.params.provider.Arguments
import
org.junit.jupiter.params.provider.ArgumentsProvider
import
org.junit.jupiter.params.provider.ArgumentsSource
import
org.rsmod.plugins.info.player.buffer.BitBuffer
import
org.rsmod.plugins.info.player.model.bitcode.I26BitCode.Companion.VALUE_BITS
import
java.nio.ByteBuffer
import
java.util.stream.Stream
class
I26BitCodeTest
{
@Test
fun
testBitBufferTransmission
()
{
ByteBuffer
.
allocate
(
3
).
let
{
buf
->
BitBuffer
(
buf
).
use
{
bitBuf
->
bitBuf
.
putBits
(
len
=
8
,
value
=
250
)
bitBuf
.
putBoolean
(
true
)
bitBuf
.
putBits
(
len
=
5
,
value
=
1
)
bitBuf
.
putBits
(
len
=
10
,
value
=
1023
)
val
bitCount
=
bitBuf
.
position
()
val
value
=
bitBuf
.
flip
().
getBits
(
bitCount
)
val
code
=
I26BitCode
(
value
,
bitCount
)
check
(
code
.
value
==
value
)
check
(
code
.
bitCount
==
bitCount
)
bitBuf
.
setBits
(
index
=
0
,
len
=
code
.
bitCount
,
value
=
code
.
value
)
bitBuf
.
flip
()
Assertions
.
assertEquals
(
250
,
bitBuf
.
getBits
(
8
))
Assertions
.
assertTrue
(
bitBuf
.
getBoolean
())
Assertions
.
assertEquals
(
1
,
bitBuf
.
getBits
(
5
))
Assertions
.
assertEquals
(
1023
,
bitBuf
.
getBits
(
10
))
}
}
}
@ParameterizedTest
@ArgumentsSource
(
BitCodeProvider
::
class
)
fun
testConstructBitCode
(
value
:
Int
,
bitCount
:
Int
)
{
val
bitCode
=
I26BitCode
(
value
,
bitCount
)
require
(
bitCount
<=
VALUE_BITS
)
require
(
value
.
countOneBits
()
<=
VALUE_BITS
)
Assertions
.
assertEquals
(
value
,
bitCode
.
value
)
Assertions
.
assertEquals
(
bitCount
,
bitCode
.
bitCount
)
}
private
object
BitCodeProvider
:
ArgumentsProvider
{
override
fun
provideArguments
(
context
:
ExtensionContext
):
Stream
<
out
Arguments
>
{
return
Stream
.
of
(
Arguments
.
of
(
0
,
0
),
Arguments
.
of
((
1
shl
8
)
-
1
,
8
),
Arguments
.
of
((
1
shl
16
)
-
1
,
16
),
Arguments
.
of
((
1
shl
20
)
-
1
,
20
),
Arguments
.
of
((
1
shl
23
)
-
1
,
23
),
Arguments
.
of
((
1
shl
24
)
-
1
,
24
),
Arguments
.
of
((
1
shl
26
)
-
1
,
26
)
)
}
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets