From ed65f1d0fe61d93116665e56dfd6c607f5fe3883 Mon Sep 17 00:00:00 2001 From: Tomm0017 Date: Tue, 11 Nov 2025 16:47:26 -0500 Subject: [PATCH 1/3] Expose `BinarySessionStateIterator.Entry` fields --- .../net/rsprox/processor/state/BinarySessionStateIterator.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/processor/src/main/kotlin/net/rsprox/processor/state/BinarySessionStateIterator.kt b/processor/src/main/kotlin/net/rsprox/processor/state/BinarySessionStateIterator.kt index d0d54291..c4e6878b 100644 --- a/processor/src/main/kotlin/net/rsprox/processor/state/BinarySessionStateIterator.kt +++ b/processor/src/main/kotlin/net/rsprox/processor/state/BinarySessionStateIterator.kt @@ -25,8 +25,8 @@ public class BinarySessionStateIterator( } public class Entry( - private val state: BinarySessionState, - private val message: IncomingMessage, + public val state: BinarySessionState, + public val message: IncomingMessage, ) { public operator fun component1(): BinarySessionState { return state From 713109a3ab1c35ba3517195a653a353bce6bbd62 Mon Sep 17 00:00:00 2001 From: Tomm0017 Date: Tue, 11 Nov 2025 16:52:43 -0500 Subject: [PATCH 2/3] Add `absCoords(CoordGrid)` for normalizing region coordinates Messages like `npcinfo` include full coordinates for npcs but lack the information required to translate region coordinates to their base-world equivalents. This function gives the ability to perform said conversion. --- .../processor/state/BinarySessionState.kt | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/processor/src/main/kotlin/net/rsprox/processor/state/BinarySessionState.kt b/processor/src/main/kotlin/net/rsprox/processor/state/BinarySessionState.kt index 9ddca951..39348b19 100644 --- a/processor/src/main/kotlin/net/rsprox/processor/state/BinarySessionState.kt +++ b/processor/src/main/kotlin/net/rsprox/processor/state/BinarySessionState.kt @@ -18,6 +18,28 @@ public data class BinarySessionState( public val updateZone: CoordGrid, public val regionZones: BuildArea?, ) { + /** + * Returns the absolute (normalized) coordinates for the given [coord]. + * + * If the coordinate is inside a region, this converts it back to its original position in the base world. + * Otherwise, it returns [coord] unchanged. + * + * For example, if [coord] is at (6405, 3) within a region (also known as an instance) zone that copied the + * base world zone at (3200, 3200), this method returns (3205, 3203). + */ + public fun absCoords(coord: CoordGrid): CoordGrid { + return absCoord(buildArea, regionZones, coord) + } + + /** + * Returns the absolute (normalized) coordinates for the given zone-local [xInZone] and [zInZone] values. + * + * The coordinates are first calculated by offsetting [xInZone] and [zInZone] from the last known [buildArea] and + * [updateZone]. If the resulting coordinate is inside a region (instance), it is then converted back to its + * original position in the base world using [regionZones]. + * + * This method is mainly used for zone prots where limited coord information is available. (3-bit coordinate offset) + */ public fun absCoord(xInZone: Int, zInZone: Int): CoordGrid { val zoneBase = CoordGrid(updateZone.level, buildArea.x + updateZone.x, buildArea.z + updateZone.z) val coord = CoordGrid(zoneBase.level, zoneBase.x + xInZone, zoneBase.z + zInZone) @@ -64,8 +86,8 @@ public data class BinarySessionState( return this } - public companion object { - public val DEFAULT: BinarySessionState = + internal companion object { + val DEFAULT: BinarySessionState = BinarySessionState( currentTick = 0, localPlayerIndex = -1, From e05ca27778ef1e124c3b7bbe24c263b9014270cb Mon Sep 17 00:00:00 2001 From: Tomm0017 Date: Fri, 14 Nov 2025 15:40:35 -0500 Subject: [PATCH 3/3] Rename `absCoords` -> `absCoord` --- .../kotlin/net/rsprox/processor/state/BinarySessionState.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processor/src/main/kotlin/net/rsprox/processor/state/BinarySessionState.kt b/processor/src/main/kotlin/net/rsprox/processor/state/BinarySessionState.kt index 39348b19..f453053f 100644 --- a/processor/src/main/kotlin/net/rsprox/processor/state/BinarySessionState.kt +++ b/processor/src/main/kotlin/net/rsprox/processor/state/BinarySessionState.kt @@ -27,7 +27,7 @@ public data class BinarySessionState( * For example, if [coord] is at (6405, 3) within a region (also known as an instance) zone that copied the * base world zone at (3200, 3200), this method returns (3205, 3203). */ - public fun absCoords(coord: CoordGrid): CoordGrid { + public fun absCoord(coord: CoordGrid): CoordGrid { return absCoord(buildArea, regionZones, coord) }