feat(server.game): route events through a InterestManager (#47)

* feat(server.game): route events through a InterestManager

* docs: explain the InterestManager and when to use it

* fix(login): carry the authenticated account to the game server so players get distinct characters

* fix(protocols.game): decode entity move from capture at opcode 0xE4 with little-endian ids and 16-bit coords

* feat(game): make the server authoritative over movement and broadcast steps and turns to nearby players

* refactor(game): drop the unused broadcastExcept and isOnline methods
This commit is contained in:
Fiereu authored and GitHub committed 2026-07-20 23:42:14 +02:00
1 parent 3cfbc2169a
commit 4b533bd099
28 files changed
+702 -341

No files matched your search

@@ -564,9 +564,7 @@ object GameProtocol : Protocol() {
c2s<BattleRewardSelectPacket>(0xE3u, BattleRewardSelectPacketCodec)
c2s<BattleChallengeRequestPacket>(0xE4u, BattleChallengeRequestPacketCodec)
s2c<EntityCounterPulsePacket>(0xE4u, EntityCounterPulsePacketCodec)
s2c<EntityMovePacket>(0xEAu, EntityMovePacketCodec)
s2c<EntityMovePacket>(0xE4u, EntityMovePacketCodec)
s2c<QueuePositionPacket>(0xF0u, QueuePositionPacketCodec)
@@ -1,31 +0,0 @@
package de.fiereu.openmmo.net.game.packets
import de.fiereu.bytecodec.CodecScope
import de.fiereu.bytecodec.PacketCodec
import de.fiereu.bytecodec.S64LE
import de.fiereu.bytecodec.S8
import de.fiereu.bytecodec.U16LE
/**
* Opcode 0xE4 (s2c). Sent in a burst at battle resolution, once per step, all referencing the same
* transient entity. Each packet carries a sequence value that increments across the burst. Its
* meaning is not yet decoded, so the fields keep their wire names.
*/
data class EntityCounterPulsePacket(
val entityId: Long,
val tagA: Byte,
val tagB: Byte,
val sequence: Int,
val endFlag: Byte,
)
object EntityCounterPulsePacketCodec : PacketCodec<EntityCounterPulsePacket>() {
override fun CodecScope<EntityCounterPulsePacket>.body(): EntityCounterPulsePacket {
val entityId = field(S64LE) { it.entityId }
val tagA = field(S8) { it.tagA }
val tagB = field(S8) { it.tagB }
val sequence = field(U16LE) { it.sequence }
val endFlag = field(S8) { it.endFlag }
return EntityCounterPulsePacket(entityId, tagA, tagB, sequence, endFlag)
}
}
@@ -2,13 +2,13 @@ package de.fiereu.openmmo.net.game.packets
import de.fiereu.bytecodec.CodecScope
import de.fiereu.bytecodec.PacketCodec
import de.fiereu.bytecodec.S64BE
import de.fiereu.bytecodec.S64LE
data class EntityLeavePacket(val entityId: Long)
object EntityLeavePacketCodec : PacketCodec<EntityLeavePacket>() {
override fun CodecScope<EntityLeavePacket>.body(): EntityLeavePacket {
val entityId = field(S64BE) { it.entityId }
val entityId = field(S64LE) { it.entityId }
return EntityLeavePacket(entityId)
}
}
@@ -1,15 +1,17 @@
package de.fiereu.openmmo.net.game.packets
import de.fiereu.bytecodec.*
import de.fiereu.bytecodec.CodecScope
import de.fiereu.bytecodec.PacketCodec
import de.fiereu.bytecodec.S16LE
import de.fiereu.bytecodec.S64LE
import de.fiereu.bytecodec.enumByOrdinalByte
import de.fiereu.openmmo.common.enums.Direction
/** Opcode 0xE4 (s2c). Another entity's tile after one step and the direction it walked. */
data class EntityMovePacket(
val entityId: Long,
val marker: Byte = 0x33,
val subtype: Byte = 0x03,
val seq: Byte = 0,
val x: Byte,
val y: Byte,
val x: Int,
val y: Int,
val direction: Direction,
)
@@ -17,13 +19,10 @@ object EntityMovePacketCodec : PacketCodec<EntityMovePacket>() {
private val DirectionCodec = enumByOrdinalByte<Direction>()
override fun CodecScope<EntityMovePacket>.body(): EntityMovePacket {
val entityId = field(S64BE) { it.entityId }
val marker = field(S8) { it.marker }
val subtype = field(S8) { it.subtype }
val seq = field(S8) { it.seq }
val x = field(S8) { it.x }
val y = field(S8) { it.y }
val entityId = field(S64LE) { it.entityId }
val x = field(S16LE) { it.x.toShort() }.toInt()
val y = field(S16LE) { it.y.toShort() }.toInt()
val direction = field(DirectionCodec) { it.direction }
return EntityMovePacket(entityId, marker, subtype, seq, x, y, direction)
return EntityMovePacket(entityId, x, y, direction)
}
}