Skip to content

Commit

Permalink
refactor: code cleanup (intellij inspection on the entire project)
Browse files Browse the repository at this point in the history
  • Loading branch information
Z-Kris committed Apr 9, 2024
1 parent d1ea0ce commit 2e556ec
Show file tree
Hide file tree
Showing 89 changed files with 48 additions and 93 deletions.
11 changes: 10 additions & 1 deletion .idea/dictionaries/krist.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions BENCHMARKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Benchmark Mode Cnt Score Error Units
PlayerInfoBenchmark.benchmark avgt 3 170.230 ± 7.278 ms/op
```

Multi-threaded measurements (default):
Multithreaded measurements (default):
```
Benchmark Mode Cnt Score Error Units
PlayerInfoBenchmark.benchmark avgt 3 11.544 ± 0.154 ms/op
Expand All @@ -47,7 +47,7 @@ PlayerInfoBenchmark.benchmark avgt 3 11.544 ± 0.154 ms/op
> [!TIP]
> 1 operation is equal to 1 game cycle.
Multi-threaded ratio[^1]: 0.92x
Multithreaded ratio[^1]: 0.92x

#### Benchmark Description
- 2046 players are spawned into the world,
Expand All @@ -72,8 +72,8 @@ buffer is additionally released back into the pool for every player.

[^1]: Multi-threaded ratio refers to how well the application multi-threads.
This is calculated by dividing the single-threaded measurements by
multi-threaded measurements, and further dividing that by the number of
multithreaded measurements, and further dividing that by the number of
CPU cores. This gives us an effective rate of how well all the CPU threads
are being utilized (on average), with a number of 1.0 implying a perfect rate
of "every CPU core is utilized as well in multi-threaded environment as it is
of "every CPU core is utilized as well in multithreaded environment as it is
in the single-threaded benchmark".
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package net.rsprot.buffer.bitbuffer
import io.netty.buffer.ByteBuf
import io.netty.util.internal.shaded.org.jctools.util.UnsafeAccess

@Suppress("NOTHING_TO_INLINE", "unused", "MemberVisibilityCanBePrivate")
@Suppress("NOTHING_TO_INLINE", "unused")
public class UnsafeBitBuf(
buffer: ByteBuf,
) : BitBuf(buffer) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.rsprot.buffer.bitbuffer

@Suppress("NOTHING_TO_INLINE", "unused", "MemberVisibilityCanBePrivate")
@Suppress("NOTHING_TO_INLINE", "unused")
public class UnsafeLongBackedBitBuf {
internal var value: Long = 0L
private set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package net.rsprot.buffer.bitbuffer

import io.netty.buffer.ByteBuf

@Suppress("unused", "MemberVisibilityCanBePrivate")
public class WrappedBitBuf(buffer: ByteBuf) : BitBuf(buffer) {
init {
req(buffer.capacity() <= Int.MAX_VALUE ushr LOG_BITS_PER_BYTE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import java.io.IOException
* This implementation was shared by Graham on Rune-Server.
* The below implementation has been converted to Kotlin and slightly cleaned up.
*/
@Suppress("MemberVisibilityCanBePrivate")
public data class HuffmanCodec(
private val bits: IntArray,
private val codewords: IntArray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import net.rsprot.protocol.game.outgoing.map.StaticRebuildMessage
import net.rsprot.protocol.game.outgoing.prot.GameServerProt
import net.rsprot.protocol.message.codec.MessageEncoder

@Suppress("DuplicatedCode")
public class RebuildNormalEncoder : MessageEncoder<StaticRebuildMessage> {
override val prot: ServerProt = GameServerProt.REBUILD_NORMAL

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.rsprot.protocol.loginprot.outgoing.prot

@Suppress("unused")
internal object LoginServerProtId {
/**
* TFU responses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import net.rsprot.protocol.message.codec.MessageEncoder
/**
* Zone prot encoder is an extension on message encoders, with the intent being
* that this encoder can be passed on-to
* [net.rsprot.protocol.game.outgoing.codec.zone.header.UpdateZonePartialEnclosedEncoder],
* [net.rsprot.protocol.game.outgoing.codec.zone.header.DesktopUpdateZonePartialEnclosedEncoder],
* as that packet combines multiple zone payloads into a single packet.
*/
public interface ZoneProtEncoder<T : ZoneProt> : MessageEncoder<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import net.rsprot.protocol.internal.game.outgoing.info.encoder.ExtendedInfoEncod
* Extended info blocks which get cached by the client, meaning if
* an avatar goes from low resolution to high resolution, and the client has a
* cached buffer of them, unless the server writes a new variant (in the case of a
* de-synchronization), the client will use the old buffer to restore that block).
* de-synchronization), the client will use the old buffer to restore that block.
* @param T the extended info block
* @param E the encoder for that extended info block
* @param encoders the array of platform-specific encoders of type [E].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package net.rsprot.protocol.internal.game.outgoing.info
* is responsible for tracking absolute positions of avatars in the game.
* @param packed the 30-bit bitpacked integer representing the coord grid.
*/
@Suppress("unused", "MemberVisibilityCanBePrivate")
@JvmInline
public value class CoordGrid(public val packed: Int) {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import net.rsprot.protocol.internal.game.outgoing.info.encoder.ExtendedInfoEncod
* such as [net.rsprot.protocol.internal.game.outgoing.info.shared.extendedinfo.FacePathingEntity],
* In those cases, this structure is responsible for holding the state necessary to synchronize
* the avatars later on in the future. If the respective extended info block is then reset to
* the default value, new avatars should not receive this anymore, as the client will also
* the default value, new avatars should not receive this any more, as the client will also
* use the default value.
* @param T the extended info block
* @param E the encoder for the given extended info block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import java.util.BitSet
* @param allocator the byte buffer allocator, used to pre-computation purposes.
* @param huffmanCodec the huffman codec responsible for compressing public chat extended info block.
*/
@Suppress("MemberVisibilityCanBePrivate")
public class SpotAnimList(
encoders: Array<PrecomputedExtendedInfoEncoder<SpotAnimList>?> = arrayOfNulls(PlatformType.COUNT),
private val allocator: ByteBufAllocator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ package net.rsprot.protocol.internal.game.outgoing.info.shared.extendedinfo.util
* soaked hitmarks.
* @param delay the delay in client cycles (20ms/cc) until the hitmark renders.
*/
@Suppress("MemberVisibilityCanBePrivate")
public class HitMark(
public var sourceIndex: Int,
public var selfType: UShort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import net.rsprot.protocol.util.CombinedId
* @property interfaceId the interface id the player interacted with
* @property componentId the component id on that interface the player interacted with
*/
@Suppress("MemberVisibilityCanBePrivate")
public class If1Button(
private val combinedId: CombinedId,
) : IncomingMessage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class If3Button private constructor(
public val op: Int
get() = _op.toInt()

@Suppress("DuplicatedCode")
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import net.rsprot.protocol.message.IncomingMessage
* the index within this clan.
* @property muted whether to mute or unmute this player
*/
@Suppress("MemberVisibilityCanBePrivate", "DuplicatedCode")
@Suppress("MemberVisibilityCanBePrivate")
public class AffinedClanSettingsSetMutedFromChannel private constructor(
public val name: String,
private val _clanId: UByte,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public class EventKeyboard(
* format back into the normalized [java.awt.event.KeyEvent] format.
* @property length the length of the key sequence
*/
@Suppress("MemberVisibilityCanBePrivate")
@JvmInline
public value class KeySequence(private val array: ByteArray) {
public val length: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import net.rsprot.protocol.message.IncomingMessage
* @property y the y coordinate clicked, always a positive integer, capped to the
* client frame height.
*/
@Suppress("MemberVisibilityCanBePrivate", "DuplicatedCode")
@Suppress("MemberVisibilityCanBePrivate")
public class EventMouseClick private constructor(
private val _lastTransmittedMouseClick: UShort,
public val rightClick: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class EventMouseMove private constructor(
* with the encoding specified by [MousePosChange].
* @property length the number of mouse movements in this packet.
*/
@Suppress("unused", "MemberVisibilityCanBePrivate")
@Suppress("MemberVisibilityCanBePrivate")
@JvmInline
public value class MouseMovements(private val movements: LongArray) {
public val length: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import net.rsprot.protocol.message.IncomingMessage
* @property name the name of the player whose rank to change
* @property rank the id of the new rank to set to that player
*/
@Suppress("MemberVisibilityCanBePrivate")
public class FriendChatSetRank private constructor(
public val name: String,
private val _rank: UByte,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import net.rsprot.protocol.message.IncomingMessage
* @property id the id of the loc (if multiloc, transformed to the
* currently visible variant)
*/
@Suppress("DuplicatedCode", "MemberVisibilityCanBePrivate")
public class OpLoc6(
public val id: Int,
) : IncomingMessage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import net.rsprot.protocol.message.IncomingMessage
* a value of 0 to 2 (inclusive) is provided. If the clan type is not defined,
* the value of -1 is given.
*/
@Suppress("MemberVisibilityCanBePrivate", "DuplicatedCode")
@Suppress("MemberVisibilityCanBePrivate")
public class MessagePublic private constructor(
private val _type: UByte,
private val _colour: UByte,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import net.rsprot.protocol.message.IncomingMessage
* @property value1 the first integer value sent by the serer
* @property value2 the second integer value sent by the server
*/
@Suppress("DuplicatedCode", "MemberVisibilityCanBePrivate")
@Suppress("MemberVisibilityCanBePrivate")
public class SendPingReply private constructor(
private val _fps: UByte,
private val _gcPercentTime: UByte,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import net.rsprot.protocol.message.IncomingMessage
* @property clientState the state the client is in
* @property loginCount how many login attempts have occurred.
*/
@Suppress("MemberVisibilityCanBePrivate", "DuplicatedCode")
@Suppress("MemberVisibilityCanBePrivate")
public class Timings private constructor(
private val _connectionLostDuration: UShort,
private val _loginDuration: UShort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import net.rsprot.protocol.message.IncomingMessage
* @property z the absolute z coordinate to set the destination to
* @property level the level to set the destination to
*/
@Suppress("MemberVisibilityCanBePrivate")
public class ClickWorldMap(
private val coordGrid: CoordGrid,
) : IncomingMessage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import net.rsprot.protocol.util.CombinedId
* @property behaviour2 the second CRM behaviour, an integer
* @property behaviour3 the third CRM behaviour, an integer
*/
@Suppress("MemberVisibilityCanBePrivate", "DuplicatedCode")
public class IfCrmViewClick private constructor(
public val crmServerTarget: Int,
private val combinedId: CombinedId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import net.rsprot.protocol.message.IncomingMessage
* @property mute whether to mute the player. This option is only possible
* by Player and Jagex moderators.
*/
@Suppress("MemberVisibilityCanBePrivate")
public class SendSnapshot private constructor(
public val name: String,
private val _ruleId: UByte,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import net.rsprot.protocol.message.IncomingMessage
* OpNpc6 message is fired when a player clicks the 'Examine' option on a npc.
* @property id the config id of the npc clicked
*/
@Suppress("MemberVisibilityCanBePrivate")
public class OpNpc6(
public val id: Int,
) : IncomingMessage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import net.rsprot.protocol.message.IncomingMessage
* @property controlKey whether the control key was held down, used to invert movement speed
* @property op the option clicked, ranging from 1 to 5 (inclusive)
*/
@Suppress("DuplicatedCode", "MemberVisibilityCanBePrivate")
public class OpObj private constructor(
private val _id: UShort,
private val _x: UShort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import net.rsprot.protocol.util.CombinedId
* @property componentId the component id clicked
* @property sub the subcomponent id, or -1 if it doesn't exist
*/
@Suppress("MemberVisibilityCanBePrivate")
public class ResumePauseButton private constructor(
private val combinedId: CombinedId,
private val _sub: UShort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import net.rsprot.protocol.message.OutgoingMessage
* @property acceleration the speed increase as the camera looks
* towards the end coordinate.
*/
@Suppress("MemberVisibilityCanBePrivate")
public class CamLookAt private constructor(
private val destinationCoordInBuildArea: CoordInBuildArea,
private val _height: UShort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import net.rsprot.protocol.message.OutgoingMessage
* @property function the camera easing function, allowing for finer
* control over the way it moves from the start coordinate to the end.
*/
@Suppress("MemberVisibilityCanBePrivate")
public class CamLookAtEasedAngleRelative private constructor(
private val _xAngle: Short,
private val _yAngle: Short,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import net.rsprot.protocol.message.OutgoingMessage
* @property function the camera easing function, allowing for finer
* control over the way it moves from the start coordinate to the end.
*/
@Suppress("MemberVisibilityCanBePrivate")
public class CamLookAtEasedCoord private constructor(
private val destinationCoordInBuildArea: CoordInBuildArea,
private val _height: UShort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import net.rsprot.protocol.message.OutgoingMessage
* @property acceleration the speed increase as the camera moves
* towards the end coordinate.
*/
@Suppress("MemberVisibilityCanBePrivate", "DuplicatedCode")
public class CamMoveTo private constructor(
private val destinationCoordInBuildArea: CoordInBuildArea,
private val _height: UShort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import net.rsprot.protocol.message.OutgoingMessage
* @property function the camera easing function, allowing for finer
* control over the way it moves from the start coordinate to the end.
*/
@Suppress("DuplicatedCode", "MemberVisibilityCanBePrivate")
@Suppress("DuplicatedCode")
public class CamMoveToEased private constructor(
private val destinationCoordInBuildArea: CoordInBuildArea,
private val _height: UShort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import net.rsprot.protocol.message.OutgoingMessage
* @property function the camera easing function, allowing for finer
* control over the way it moves from the start coordinate to the end.
*/
@Suppress("DuplicatedCode", "MemberVisibilityCanBePrivate")
@Suppress("DuplicatedCode")
public class CamMoveToEasedCircular private constructor(
private val centerCoordInBuildArea: CoordInBuildArea,
private val destinationCoordInBuildArea: CoordInBuildArea,
Expand Down
Loading

0 comments on commit 2e556ec

Please sign in to comment.