chore(style): spotlessApply

This commit is contained in:
Fiereu committed 2026-06-22 15:08:37 +02:00
1 parent a0dc6d961b
commit a93efe624f
43 files changed
+162 -105

No files matched your search

@@ -594,6 +594,5 @@ object GameProtocol : Protocol() {
s2c<GtlListingsPagePacket>(0xFEu, GtlListingsPagePacketCodec) s2c<GtlListingsPagePacket>(0xFEu, GtlListingsPagePacketCodec)
s2c<WorldSessionStatePacket>(0xFFu, WorldSessionStatePacketCodec) s2c<WorldSessionStatePacket>(0xFFu, WorldSessionStatePacketCodec)
} }
} }
@@ -75,9 +75,7 @@ private val EventsCodec: Codec<List<InputEventSample>> =
shortB = S16LE.read(buf) shortB = S16LE.read(buf)
} }
} }
result.add( result.add(InputEventSample(type, timestamp, byteA, byteB, intA, shortA, shortB, intB))
InputEventSample(type, timestamp, byteA, byteB, intA, shortA, shortB, intB)
)
previous = timestamp previous = timestamp
} }
return result return result
@@ -75,9 +75,21 @@ private class BattleParticipantCodec(private val isCapture: Boolean) :
} }
} }
return BattleActionParticipant( return BattleActionParticipant(
entityId, kind, intA, intB, intC, shortA, critByte, critShort, capturedShort, capturedByte, entityId,
xpShort, xpByteA, xpByteB, pokemon, statStages kind,
) intA,
intB,
intC,
shortA,
critByte,
critShort,
capturedShort,
capturedByte,
xpShort,
xpByteA,
xpByteB,
pokemon,
statStages)
} }
} }
@@ -28,7 +28,8 @@ private val BattleActionSelectBody: Codec<BattleActionSelectPacket> =
S8.write(buf, value.extraFlag) S8.write(buf, value.extraFlag)
} }
2, 3 -> { 2,
3 -> {
S16LE.write(buf, value.moveOrItemId) S16LE.write(buf, value.moveOrItemId)
} }
@@ -157,7 +157,8 @@ internal val BattleSerializedEntryCodec: Codec<BattleSerializedEntry> =
S16LE.write(buf, value.y) S16LE.write(buf, value.y)
} }
is EmptyCreatureDataEntry -> throw MalformedPacketException("cannot encode default battle entry") is EmptyCreatureDataEntry ->
throw MalformedPacketException("cannot encode default battle entry")
} }
} }
} }
@@ -28,14 +28,18 @@ internal val MessageArgCodec: Codec<MessageArg> =
when (type) { when (type) {
28 -> {} 28 -> {}
30 -> longValue = field(S64LE) { it.longValue!! } 30 -> longValue = field(S64LE) { it.longValue!! }
9, 10, 17 -> intValue = field(S32LE) { it.intValue!! } 9,
5, 18 -> stringValue = field(Utf16LeNullTerminated) { it.stringValue!! } 10,
17 -> intValue = field(S32LE) { it.intValue!! }
5,
18 -> stringValue = field(Utf16LeNullTerminated) { it.stringValue!! }
else -> { else -> {
val count = field(U8) { it.shortValues!!.size } val count = field(U8) { it.shortValues!!.size }
shortValues = (0 until count).map { i -> field(S16LE) { it.shortValues!![i] } } shortValues = (0 until count).map { i -> field(S16LE) { it.shortValues!![i] } }
} }
} }
return MessageArg(argId, type, hasExtra, extra, longValue, intValue, stringValue, shortValues) return MessageArg(
argId, type, hasExtra, extra, longValue, intValue, stringValue, shortValues)
} }
} }
@@ -88,7 +88,8 @@ object BattleEntityDeltaPacketCodec : PacketCodec<BattleEntityDeltaPacket>() {
val ivs = if (m and 262144 != 0) field(S16LE.repeat(5)) { it.ivs!! } else null val ivs = if (m and 262144 != 0) field(S16LE.repeat(5)) { it.ivs!! } else null
val caughtBall = if (m and 524288 != 0) field(S8) { it.caughtBall!! } else null val caughtBall = if (m and 524288 != 0) field(S8) { it.caughtBall!! } else null
val statusFlags2 = if (m and 1048576 != 0) field(S16LE) { it.statusFlags2!! } else null val statusFlags2 = if (m and 1048576 != 0) field(S16LE) { it.statusFlags2!! } else null
val statusList = if (m and 4194304 != 0) field(S8.listPrefixed(U8)) { it.statusList!! } else null val statusList =
if (m and 4194304 != 0) field(S8.listPrefixed(U8)) { it.statusList!! } else null
val status = if (m and 8388608 != 0) field(S8) { it.status!! } else null val status = if (m and 8388608 != 0) field(S8) { it.status!! } else null
return BattleEntityDeltaPacket( return BattleEntityDeltaPacket(
@@ -35,9 +35,18 @@ private val BattleRankingEntryCodec: Codec<BattleRankingEntry> =
val bool2 = field(Bool) { it.bool2 } val bool2 = field(Bool) { it.bool2 }
field(S8) { 0 } field(S8) { 0 }
return BattleRankingEntry( return BattleRankingEntry(
entityId, flag1, flag2, name, value1, genderId, ribbons, byte1, int1, byte2, bool1, entityId,
bool2 flag1,
) flag2,
name,
value1,
genderId,
ribbons,
byte1,
int1,
byte2,
bool1,
bool2)
} }
} }
@@ -148,8 +157,7 @@ private val BattleStorageItemCodec: Codec<BattleStorageItem> =
val pokemonByte = field(S8) { it.pokemonByte } val pokemonByte = field(S8) { it.pokemonByte }
val boxByte = field(S8) { it.boxByte } val boxByte = field(S8) { it.boxByte }
return BattleStorageItem( return BattleStorageItem(
typeByte, short1, short2, short3, short4, byte1, pokemonByte, boxByte typeByte, short1, short2, short3, short4, byte1, pokemonByte, boxByte)
)
} }
} }
@@ -167,8 +175,7 @@ object BattleScreenOpenPacketCodec : PacketCodec<BattleScreenOpenPacket>() {
val active = field(U8) { if (it.active) 1 else 0 } == 1 val active = field(U8) { if (it.active) 1 else 0 } == 1
if (!active) { if (!active) {
return BattleScreenOpenPacket( return BattleScreenOpenPacket(
false, false, emptyList(), emptyList(), emptyList(), emptyList() false, false, emptyList(), emptyList(), emptyList(), emptyList())
)
} }
val wild = field(U8) { if (it.wild) 1 else 0 } == 1 val wild = field(U8) { if (it.wild) 1 else 0 } == 1
var participants = emptyList<BattleRankingEntry>() var participants = emptyList<BattleRankingEntry>()
@@ -40,9 +40,16 @@ object BattleSendOutActivePacketCodec : PacketCodec<BattleSendOutActivePacket>()
return BattleSendOutActivePacket( return BattleSendOutActivePacket(
opponent, opponent,
BattleSendOutMember( BattleSendOutMember(
entityIdA, entityIdB, entityIdC, speciesByte, nickname, ownerName, value, nameA, nameB, entityIdA,
levelByte, flag entityIdB,
) entityIdC,
) speciesByte,
nickname,
ownerName,
value,
nameA,
nameB,
levelByte,
flag))
} }
} }
@@ -43,8 +43,7 @@ private val BattleAddPokemonCodec: Codec<BattleAddPokemon> =
BattleAddStatusEffect(durationTurns, effectType, sourceSlot) BattleAddStatusEffect(durationTurns, effectType, sourceSlot)
} else null } else null
return BattleAddPokemon( return BattleAddPokemon(
entityId, frontSpriteId, backSpriteId, side, slot, partyIndex, statusEffect entityId, frontSpriteId, backSpriteId, side, slot, partyIndex, statusEffect)
)
} }
} }
@@ -45,8 +45,7 @@ private val BattlePartyPokemonCodec: Codec<BattlePartyPokemon> =
BattlePartyStatusEffect(durationTurns, effectType, sourceSlot) BattlePartyStatusEffect(durationTurns, effectType, sourceSlot)
} else null } else null
return BattlePartyPokemon( return BattlePartyPokemon(
entityId, frontSpriteId, backSpriteId, side, slot, partyIndex, statusEffect entityId, frontSpriteId, backSpriteId, side, slot, partyIndex, statusEffect)
)
} }
} }
@@ -17,7 +17,8 @@ private val SimulationConfigPayload: Codec<ByteArray> =
data class BattleSimulationRequestPacket(val simulationConfig: ByteArray) { data class BattleSimulationRequestPacket(val simulationConfig: ByteArray) {
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
other is BattleSimulationRequestPacket && simulationConfig.contentEquals(other.simulationConfig) other is BattleSimulationRequestPacket &&
simulationConfig.contentEquals(other.simulationConfig)
override fun hashCode(): Int = simulationConfig.contentHashCode() override fun hashCode(): Int = simulationConfig.contentHashCode()
} }
@@ -33,9 +33,17 @@ private class BattlePreviewMemberCodec(
val levelByte = field(S8) { it.levelByte } val levelByte = field(S8) { it.levelByte }
val flag = field(Bool) { it.flag } val flag = field(Bool) { it.flag }
return BattlePreviewMember( return BattlePreviewMember(
entityIdA, entityIdB, entityIdC, speciesByte, nickname, ownerName, value, nameA, nameB, entityIdA,
levelByte, flag entityIdB,
) entityIdC,
speciesByte,
nickname,
ownerName,
value,
nameA,
nameB,
levelByte,
flag)
} }
} }
@@ -34,7 +34,8 @@ object CharacterAppearanceApplyPacketCodec : PacketCodec<CharacterAppearanceAppl
val moves = mutableListOf<AppearanceMoveEntry>() val moves = mutableListOf<AppearanceMoveEntry>()
for (slot in 0 until 15) { for (slot in 0 until 15) {
if (mask and (1 shl slot) != 0) { if (mask and (1 shl slot) != 0) {
val packed = field(S16LE) { v -> v.creatureMoves.moves.first { it.slot == slot }.packedMove } val packed =
field(S16LE) { v -> v.creatureMoves.moves.first { it.slot == slot }.packedMove }
val pp: Byte? = val pp: Byte? =
if (hasPp) field(S8) { v -> v.creatureMoves.moves.first { it.slot == slot }.ppUp ?: 0 } if (hasPp) field(S8) { v -> v.creatureMoves.moves.first { it.slot == slot }.ppUp ?: 0 }
else null else null
@@ -15,8 +15,7 @@ object ChatMessageSendPacketCodec : PacketCodec<ChatMessageSendPacket>() {
override fun CodecScope<ChatMessageSendPacket>.body(): ChatMessageSendPacket { override fun CodecScope<ChatMessageSendPacket>.body(): ChatMessageSendPacket {
val mode = field(S8) { it.mode } val mode = field(S8) { it.mode }
val target = field(Utf16LeNullTerminated) { it.target } val target = field(Utf16LeNullTerminated) { it.target }
val message = val message = if (mode.toInt() == 4) field(Utf16LeNullTerminated) { it.message ?: "" } else null
if (mode.toInt() == 4) field(Utf16LeNullTerminated) { it.message ?: "" } else null
return ChatMessageSendPacket(mode, target, message) return ChatMessageSendPacket(mode, target, message)
} }
} }
@@ -49,8 +49,7 @@ data class CustomizeCharacterAppearancePacket(
val paletteIndex: Byte, val paletteIndex: Byte,
) )
object CustomizeCharacterAppearancePacketCodec : object CustomizeCharacterAppearancePacketCodec : PacketCodec<CustomizeCharacterAppearancePacket>() {
PacketCodec<CustomizeCharacterAppearancePacket>() {
override fun CodecScope<CustomizeCharacterAppearancePacket>.body(): override fun CodecScope<CustomizeCharacterAppearancePacket>.body():
CustomizeCharacterAppearancePacket { CustomizeCharacterAppearancePacket {
val entityId = field(S64LE) { it.entityId } val entityId = field(S64LE) { it.entityId }
@@ -59,7 +58,6 @@ object CustomizeCharacterAppearancePacketCodec :
val moveSet = field(CreatureMovesetCodec) { it.moveSet } val moveSet = field(CreatureMovesetCodec) { it.moveSet }
val paletteIndex = field(S8) { it.paletteIndex } val paletteIndex = field(S8) { it.paletteIndex }
return CustomizeCharacterAppearancePacket( return CustomizeCharacterAppearancePacket(
entityId, colorCategoryId, colorSlot, moveSet, paletteIndex entityId, colorCategoryId, colorSlot, moveSet, paletteIndex)
)
} }
} }
@@ -53,7 +53,8 @@ object EntityAppearancePatchPacketCodec : PacketCodec<EntityAppearancePatchPacke
val flagsInt = flags.toInt() val flagsInt = flags.toInt()
val direction = if (flagsInt and 1 != 0) field(S8) { it.direction!! } else null val direction = if (flagsInt and 1 != 0) field(S8) { it.direction!! } else null
val animation = if (flagsInt and 2 != 0) field(S16LE) { it.animation!! } else null val animation = if (flagsInt and 2 != 0) field(S16LE) { it.animation!! } else null
val appearance = if (flagsInt and 4 != 0) field(EntityAppearanceCodec) { it.appearance!! } else null val appearance =
if (flagsInt and 4 != 0) field(EntityAppearanceCodec) { it.appearance!! } else null
val cosmetics = val cosmetics =
if (flagsInt and 8 != 0) { if (flagsInt and 8 != 0) {
val count = field(S8) { it.cosmetics!!.size.toByte() }.toInt() val count = field(S8) { it.cosmetics!!.size.toByte() }.toInt()
@@ -64,7 +65,6 @@ object EntityAppearancePatchPacketCodec : PacketCodec<EntityAppearancePatchPacke
} }
} else null } else null
return EntityAppearancePatchPacket( return EntityAppearancePatchPacket(
entityId, spriteId, direction, animation, appearance, cosmetics entityId, spriteId, direction, animation, appearance, cosmetics)
)
} }
} }
@@ -112,7 +112,8 @@ private val EventOverlayStateCodec: Codec<EventOverlayStatePacket> =
S16LE.write(buf, r.regionId) S16LE.write(buf, r.regionId)
S16LE.write(buf, r.secondary) S16LE.write(buf, r.secondary)
if (grid) { if (grid) {
val points = r.gridPoints ?: throw MalformedPacketException("grid overlay region missing points") val points =
r.gridPoints ?: throw MalformedPacketException("grid overlay region missing points")
U8.write(buf, points.size) U8.write(buf, points.size)
for (p in points) { for (p in points) {
S16LE.write(buf, p.x) S16LE.write(buf, p.x)
@@ -15,7 +15,9 @@ data class ReconnectHelloAuth(val entityId: Long, val sessionToken: ByteArray) :
data class NewHelloAuth(val userId: Int, val sessionToken: ByteArray) : HelloAuthData() { data class NewHelloAuth(val userId: Int, val sessionToken: ByteArray) : HelloAuthData() {
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
other is NewHelloAuth && userId == other.userId && sessionToken.contentEquals(other.sessionToken) other is NewHelloAuth &&
userId == other.userId &&
sessionToken.contentEquals(other.sessionToken)
override fun hashCode(): Int = userId * 31 + sessionToken.contentHashCode() override fun hashCode(): Int = userId * 31 + sessionToken.contentHashCode()
} }
@@ -88,10 +88,36 @@ private val GmCharacterSessionCodec: Codec<GmCharacterSession> =
val statusCount = field(U8) { it.statusList.size } val statusCount = field(U8) { it.statusList.size }
val statusList = (0 until statusCount).map { i -> field(S8) { it.statusList[i] } } val statusList = (0 until statusCount).map { i -> field(S8) { it.statusList[i] } }
return GmCharacterSession( return GmCharacterSession(
entityId, name, secondaryName, intA, byteA, intB, longA, intC, intD, intE, shortA, intF, entityId,
byteB, byteC, byteD, shortB, byteE, intG, byteF, byteG, byteH, byteI, byteJ, shortC, name,
shortD, shortE, statusByte, shortF, shortG, statusList secondaryName,
) intA,
byteA,
intB,
longA,
intC,
intD,
intE,
shortA,
intF,
byteB,
byteC,
byteD,
shortB,
byteE,
intG,
byteF,
byteG,
byteH,
byteI,
byteJ,
shortC,
shortD,
shortE,
statusByte,
shortF,
shortG,
statusList)
} }
} }
@@ -157,9 +183,15 @@ object GmPlayerLookupPacketCodec : PacketCodec<GmPlayerLookupPacket>() {
val stringB = field(Utf16LeNullTerminated) { it.account!!.stringB } val stringB = field(Utf16LeNullTerminated) { it.account!!.stringB }
val stringC = field(Utf16LeNullTerminated) { it.account!!.stringC } val stringC = field(Utf16LeNullTerminated) { it.account!!.stringC }
GmAccountInfo( GmAccountInfo(
rankExtraA, rankExtraB, rankExtraC, ipAddress, playtime, accountId, stringA, stringB, rankExtraA,
stringC rankExtraB,
) rankExtraC,
ipAddress,
playtime,
accountId,
stringA,
stringB,
stringC)
} else null } else null
val extraByte = field(U8) { if (it.extra != null) 1 else 0 } val extraByte = field(U8) { if (it.extra != null) 1 else 0 }
val extra = val extra =
@@ -169,7 +201,8 @@ object GmPlayerLookupPacketCodec : PacketCodec<GmPlayerLookupPacket>() {
GmExtraDetail(value, text) GmExtraDetail(value, text)
} else null } else null
val charCount = field(U16LE) { it.characters.size } val charCount = field(U16LE) { it.characters.size }
val characters = (0 until charCount).map { i -> field(GmCharacterListingCodec) { it.characters[i] } } val characters =
(0 until charCount).map { i -> field(GmCharacterListingCodec) { it.characters[i] } }
return GmPlayerLookupPacket(true, session, rank, account, extra, characters) return GmPlayerLookupPacket(true, session, rank, account, extra, characters)
} }
} }
@@ -47,8 +47,6 @@ object GtlCreateListingPacketCodec : PacketCodec<GtlCreateListingPacket>() {
val itemKind = field(S8) { it.itemKind } val itemKind = field(S8) { it.itemKind }
val priceShort = field(S16LE) { it.priceShort } val priceShort = field(S16LE) { it.priceShort }
val filterCriteria = field(FilterCriteriaBytes) { it.filterCriteria } val filterCriteria = field(FilterCriteriaBytes) { it.filterCriteria }
return GtlCreateListingPacket( return GtlCreateListingPacket(categoryIndex, listingCount, itemKind, priceShort, filterCriteria)
categoryIndex, listingCount, itemKind, priceShort, filterCriteria
)
} }
} }
@@ -39,7 +39,6 @@ object GtlSellPokemonListingPacketCodec : PacketCodec<GtlSellPokemonListingPacke
val criteriaCount = field(U8) { it.criteriaCount } val criteriaCount = field(U8) { it.criteriaCount }
val criteriaData = field(RemainingBytes) { it.criteriaData } val criteriaData = field(RemainingBytes) { it.criteriaData }
return GtlSellPokemonListingPacket( return GtlSellPokemonListingPacket(
listingType, entryKindId, listingCategory, itemTypeId, criteriaCount, criteriaData listingType, entryKindId, listingCategory, itemTypeId, criteriaCount, criteriaData)
)
} }
} }
@@ -38,7 +38,8 @@ private object GuildProfileDataCodec : PacketCodec<GuildProfileData>() {
val value5 = field(S16LE, GuildProfileData::value5) val value5 = field(S16LE, GuildProfileData::value5)
val value6 = field(S32LE, GuildProfileData::value6) val value6 = field(S32LE, GuildProfileData::value6)
val rankCount = field(S8) { it.rankNames.size.toByte() } val rankCount = field(S8) { it.rankNames.size.toByte() }
val rankNames = List(rankCount.toInt()) { i -> field(Utf16LeNullTerminated) { it.rankNames[i] } } val rankNames =
List(rankCount.toInt()) { i -> field(Utf16LeNullTerminated) { it.rankNames[i] } }
return GuildProfileData( return GuildProfileData(
guildId, guildId,
name, name,
@@ -33,7 +33,8 @@ object GuildProfileSyncPacketCodec : PacketCodec<GuildProfileSyncPacket>() {
val value5 = field(S16LE, GuildProfileSyncPacket::value5) val value5 = field(S16LE, GuildProfileSyncPacket::value5)
val value6 = field(S32LE, GuildProfileSyncPacket::value6) val value6 = field(S32LE, GuildProfileSyncPacket::value6)
val rankCount = field(S8) { it.rankNames.size.toByte() } val rankCount = field(S8) { it.rankNames.size.toByte() }
val rankNames = List(rankCount.toInt()) { i -> field(Utf16LeNullTerminated) { it.rankNames[i] } } val rankNames =
List(rankCount.toInt()) { i -> field(Utf16LeNullTerminated) { it.rankNames[i] } }
return GuildProfileSyncPacket( return GuildProfileSyncPacket(
guildId, guildId,
name, name,
@@ -43,7 +43,8 @@ private val HighScoreEntryCodec: Codec<HighScoreEntry> =
val rank = field(S32LE) { it.rank } val rank = field(S32LE) { it.rank }
val score = field(S32LE) { it.score } val score = field(S32LE) { it.score }
val count = field(U8) { it.appearances.size } val count = field(U8) { it.appearances.size }
val appearances = (0 until count).map { i -> field(HighScoreAppearanceCodec) { it.appearances[i] } } val appearances =
(0 until count).map { i -> field(HighScoreAppearanceCodec) { it.appearances[i] } }
return HighScoreEntry(entityId, rank, score, appearances) return HighScoreEntry(entityId, rank, score, appearances)
} }
} }
@@ -47,8 +47,6 @@ object ListWindowPagePacketCodec : PacketCodec<ListWindowPagePacket>() {
val headerB = field(S8) { it.headerB } val headerB = field(S8) { it.headerB }
val headerC = field(S8) { it.headerC } val headerC = field(S8) { it.headerC }
val rows = field(ListWindowRowCodec.listPrefixed(U16LE)) { it.rows } val rows = field(ListWindowRowCodec.listPrefixed(U16LE)) { it.rows }
return ListWindowPagePacket( return ListWindowPagePacket(windowId, firstPage, lastPage, headerA, headerB, headerC, rows)
windowId, firstPage, lastPage, headerA, headerB, headerC, rows
)
} }
} }
@@ -52,7 +52,8 @@ object LocalCharacterDeltaPacketCodec : PacketCodec<LocalCharacterDeltaPacket>()
value64a = null value64a = null
value64b = null value64b = null
} }
val statusConditions = if (m and 128 != 0) field(S8.listPrefixed(U8)) { it.statusConditions!! } else null val statusConditions =
if (m and 128 != 0) field(S8.listPrefixed(U8)) { it.statusConditions!! } else null
val value256 = if (m and 256 != 0) field(S8) { it.value256!! } else null val value256 = if (m and 256 != 0) field(S8) { it.value256!! } else null
return LocalCharacterDeltaPacket( return LocalCharacterDeltaPacket(
mask = mask, mask = mask,
@@ -26,7 +26,6 @@ object MapTileObjectSlotSetPacketCodec : PacketCodec<MapTileObjectSlotSetPacket>
val objectZ = if (present) field(S8) { it.objectZ!! } else null val objectZ = if (present) field(S8) { it.objectZ!! } else null
val relative = if (present) field(U8) { if (it.relative == true) 1 else 0 } == 1 else null val relative = if (present) field(U8) { if (it.relative == true) 1 else 0 } == 1 else null
return MapTileObjectSlotSetPacket( return MapTileObjectSlotSetPacket(
blockX, blockY, blockZ, slot, present, objectX, objectY, objectZ, relative blockX, blockY, blockZ, slot, present, objectX, objectY, objectZ, relative)
)
} }
} }
@@ -42,7 +42,6 @@ object MarketBoardPagePacketCodec : PacketCodec<MarketBoardPagePacket>() {
entries.add(MarketBoardEntry(itemId, valueA, valueB, rank)) entries.add(MarketBoardEntry(itemId, valueA, valueB, rank))
} }
return MarketBoardPagePacket( return MarketBoardPagePacket(
hasData, page, category, total, expiryOffsetMillis, count, categoryRanked, entries hasData, page, category, total, expiryOffsetMillis, count, categoryRanked, entries)
)
} }
} }
@@ -34,7 +34,6 @@ object NpcSpawnPacketCodec : PacketCodec<NpcSpawnPacket>() {
val facing = field(U8) { it.facing } val facing = field(U8) { it.facing }
val unk6 = field(U16LE) { it.unk6 } val unk6 = field(U16LE) { it.unk6 }
return NpcSpawnPacket( return NpcSpawnPacket(
entityId, unk1, unk2, unk3, unk4, regionId, bankId, mapId, x, y, facing, unk5, unk6 entityId, unk1, unk2, unk3, unk4, regionId, bankId, mapId, x, y, facing, unk5, unk6)
)
} }
} }
@@ -16,7 +16,6 @@ object RequestConfirmationPromptPacketCodec : PacketCodec<RequestConfirmationPro
val requestTimeoutSeconds = if (visible) field(U16LE) { it.requestTimeoutSeconds!! } else null val requestTimeoutSeconds = if (visible) field(U16LE) { it.requestTimeoutSeconds!! } else null
val responseTimeoutSeconds = if (visible) field(U16LE) { it.responseTimeoutSeconds!! } else null val responseTimeoutSeconds = if (visible) field(U16LE) { it.responseTimeoutSeconds!! } else null
return RequestConfirmationPromptPacket( return RequestConfirmationPromptPacket(
visible, entityId, requestTimeoutSeconds, responseTimeoutSeconds visible, entityId, requestTimeoutSeconds, responseTimeoutSeconds)
)
} }
} }
@@ -40,8 +40,7 @@ private val ServerMessageArgCodec: Codec<ServerMessageArg> =
else -> shortValues = field(S16LE.listPrefixed(U8)) { it.shortValues!! } else -> shortValues = field(S16LE.listPrefixed(U8)) { it.shortValues!! }
} }
return ServerMessageArg( return ServerMessageArg(
argId, type, hasExtra, extra, longValue, intValue, stringValue, shortValues argId, type, hasExtra, extra, longValue, intValue, stringValue, shortValues)
)
} }
} }
@@ -24,16 +24,13 @@ private val ColorPaletteCodec: Codec<List<Short>> =
} }
} }
object SetBattleMonsterAppearancePacketCodec : object SetBattleMonsterAppearancePacketCodec : PacketCodec<SetBattleMonsterAppearancePacket>() {
PacketCodec<SetBattleMonsterAppearancePacket>() {
override fun CodecScope<SetBattleMonsterAppearancePacket>.body(): override fun CodecScope<SetBattleMonsterAppearancePacket>.body():
SetBattleMonsterAppearancePacket { SetBattleMonsterAppearancePacket {
val partySlot = field(S16LE) { it.partySlot } val partySlot = field(S16LE) { it.partySlot }
val pokemonEntityId = field(S64LE) { it.pokemonEntityId } val pokemonEntityId = field(S64LE) { it.pokemonEntityId }
val shininessType = field(S8) { it.shininessType } val shininessType = field(S8) { it.shininessType }
val colorPalette = field(ColorPaletteCodec) { it.colorPalette } val colorPalette = field(ColorPaletteCodec) { it.colorPalette }
return SetBattleMonsterAppearancePacket( return SetBattleMonsterAppearancePacket(partySlot, pokemonEntityId, shininessType, colorPalette)
partySlot, pokemonEntityId, shininessType, colorPalette
)
} }
} }
@@ -11,10 +11,8 @@ data class SocialActionOutcomePacket(
object SocialActionOutcomePacketCodec : PacketCodec<SocialActionOutcomePacket>() { object SocialActionOutcomePacketCodec : PacketCodec<SocialActionOutcomePacket>() {
override fun CodecScope<SocialActionOutcomePacket>.body(): SocialActionOutcomePacket { override fun CodecScope<SocialActionOutcomePacket>.body(): SocialActionOutcomePacket {
val action = field(U8) { it.action } val action = field(U8) { it.action }
val entityId: Long? = val entityId: Long? = if (resolveKind(action) == 1) field(S64LE) { it.entityId!! } else null
if (resolveKind(action) == 1) field(S64LE) { it.entityId!! } else null val value: Short? = if (resolveKind(action) == 2) field(S16LE) { it.value!! } else null
val value: Short? =
if (resolveKind(action) == 2) field(S16LE) { it.value!! } else null
return SocialActionOutcomePacket(action, entityId, value) return SocialActionOutcomePacket(action, entityId, value)
} }
@@ -16,8 +16,7 @@ object SpatialGroupInsertPacketCodec : PacketCodec<SpatialGroupInsertPacket>() {
val entityId = field(S64LE) { it.entityId } val entityId = field(S64LE) { it.entityId }
val value = field(S16LE) { it.value } val value = field(S16LE) { it.value }
val extraCoordPresent = false val extraCoordPresent = false
val extraValue: Short? = val extraValue: Short? = if (extraCoordPresent) field(S16LE) { it.extraValue ?: 0 } else null
if (extraCoordPresent) field(S16LE) { it.extraValue ?: 0 } else null
return SpatialGroupInsertPacket(group, entityId, value, extraCoordPresent, extraValue) return SpatialGroupInsertPacket(group, entityId, value, extraCoordPresent, extraValue)
} }
} }
@@ -11,7 +11,8 @@ data class StorageBoxFilterPacket(
other is StorageBoxFilterPacket && other is StorageBoxFilterPacket &&
listTypeIndex == other.listTypeIndex && listTypeIndex == other.listTypeIndex &&
boxName == other.boxName && boxName == other.boxName &&
(cookieData?.contentEquals(other.cookieData ?: ByteArray(0)) ?: (other.cookieData == null)) (cookieData?.contentEquals(other.cookieData ?: ByteArray(0))
?: (other.cookieData == null))
override fun hashCode(): Int { override fun hashCode(): Int {
var r = listTypeIndex?.hashCode() ?: 0 var r = listTypeIndex?.hashCode() ?: 0
@@ -26,9 +27,7 @@ private val CookieBytes = bytesPrefixed(U8)
object StorageBoxFilterPacketCodec : PacketCodec<StorageBoxFilterPacket>() { object StorageBoxFilterPacketCodec : PacketCodec<StorageBoxFilterPacket>() {
override fun CodecScope<StorageBoxFilterPacket>.body(): StorageBoxFilterPacket { override fun CodecScope<StorageBoxFilterPacket>.body(): StorageBoxFilterPacket {
val typeFlags = val typeFlags =
field(U8) { field(U8) { (if (it.boxName != null) 1 else 0) or (if (it.cookieData != null) 2 else 0) }
(if (it.boxName != null) 1 else 0) or (if (it.cookieData != null) 2 else 0)
}
val listTypeIndex: Byte? = val listTypeIndex: Byte? =
if (typeFlags and 1 != 0) field(S8) { it.listTypeIndex ?: 0 } else null if (typeFlags and 1 != 0) field(S8) { it.listTypeIndex ?: 0 } else null
val boxName: String? = val boxName: String? =
@@ -35,9 +35,7 @@ object StorageContextWindowPacketCodec : PacketCodec<StorageContextWindowPacket>
val quantity = field(S8) { it.items[i].quantity } val quantity = field(S8) { it.items[i].quantity }
val ball = field(S8) { it.items[i].ball } val ball = field(S8) { it.items[i].ball }
val location = field(S8) { it.items[i].location } val location = field(S8) { it.items[i].location }
items.add( items.add(StorageBoxItem(slot, valueA, valueB, valueC, valueD, quantity, ball, location))
StorageBoxItem(slot, valueA, valueB, valueC, valueD, quantity, ball, location)
)
} }
return StorageContextWindowPacket(kind, items) return StorageContextWindowPacket(kind, items)
} }
@@ -50,7 +50,6 @@ object StorageInventoryPacketCodec : PacketCodec<StorageInventoryPacket>() {
val listC = field(StorageQuantityCodec.listPrefixed(U8)) { it.listC } val listC = field(StorageQuantityCodec.listPrefixed(U8)) { it.listC }
val listD = field(StorageQuantityCodec.listPrefixed(U8)) { it.listD } val listD = field(StorageQuantityCodec.listPrefixed(U8)) { it.listD }
return StorageInventoryPacket( return StorageInventoryPacket(
header, totalA, totalB, valueC, usedA, usedB, listA, listB, listC, listD header, totalA, totalB, valueC, usedA, usedB, listA, listB, listC, listD)
)
} }
} }
@@ -56,8 +56,7 @@ object TeamPreviewLeadSubmitPacketCodec : PacketCodec<TeamPreviewLeadSubmitPacke
val pokemonEntityId = field(S64LE) { it.pokemonEntityId } val pokemonEntityId = field(S64LE) { it.pokemonEntityId }
val battleSlot = field(S8) { it.battleSlot } val battleSlot = field(S8) { it.battleSlot }
val present = field(U8) { if (it.appearance != null) 1 else 0 } val present = field(U8) { if (it.appearance != null) 1 else 0 }
val appearance = val appearance = if (present != 0) field(AppearanceCodec) { it.appearance!! } else null
if (present != 0) field(AppearanceCodec) { it.appearance!! } else null
val teamSide = field(S16LE) { it.teamSide } val teamSide = field(S16LE) { it.teamSide }
val reserved = field(S8) { it.reserved } val reserved = field(S8) { it.reserved }
return TeamPreviewLeadSubmitPacket( return TeamPreviewLeadSubmitPacket(
@@ -7,9 +7,7 @@ data class TypedBinaryDataPacket(
val data: ByteArray, val data: ByteArray,
) { ) {
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
other is TypedBinaryDataPacket && other is TypedBinaryDataPacket && dataType == other.dataType && data.contentEquals(other.data)
dataType == other.dataType &&
data.contentEquals(other.data)
override fun hashCode(): Int = dataType * 31 + data.contentHashCode() override fun hashCode(): Int = dataType * 31 + data.contentHashCode()
} }
@@ -28,16 +28,18 @@ private val WorldNoticeArgCodec: Codec<WorldNoticeArg> =
when (type) { when (type) {
28 -> {} 28 -> {}
30 -> longValue = field(S64LE) { it.longValue!! } 30 -> longValue = field(S64LE) { it.longValue!! }
9, 10, 17 -> intValue = field(S32LE) { it.intValue!! } 9,
5, 18 -> stringValue = field(Utf16LeNullTerminated) { it.stringValue!! } 10,
17 -> intValue = field(S32LE) { it.intValue!! }
5,
18 -> stringValue = field(Utf16LeNullTerminated) { it.stringValue!! }
else -> { else -> {
val count = field(U8) { it.shortValues!!.size } val count = field(U8) { it.shortValues!!.size }
shortValues = (0 until count).map { i -> field(S16LE) { it.shortValues!![i] } } shortValues = (0 until count).map { i -> field(S16LE) { it.shortValues!![i] } }
} }
} }
return WorldNoticeArg( return WorldNoticeArg(
argId, type, hasExtra, extra, longValue, intValue, stringValue, shortValues argId, type, hasExtra, extra, longValue, intValue, stringValue, shortValues)
)
} }
} }
@@ -9,7 +9,8 @@ data class WorldObjectInstanceDespawnPacket(
) )
object WorldObjectInstanceDespawnPacketCodec : PacketCodec<WorldObjectInstanceDespawnPacket>() { object WorldObjectInstanceDespawnPacketCodec : PacketCodec<WorldObjectInstanceDespawnPacket>() {
override fun CodecScope<WorldObjectInstanceDespawnPacket>.body(): WorldObjectInstanceDespawnPacket { override fun CodecScope<WorldObjectInstanceDespawnPacket>.body():
WorldObjectInstanceDespawnPacket {
val entityId = field(S64LE) { it.entityId } val entityId = field(S64LE) { it.entityId }
return WorldObjectInstanceDespawnPacket(entityId) return WorldObjectInstanceDespawnPacket(entityId)
} }
@@ -60,7 +60,9 @@ constructor(
val state = ctx.attributes[PLAYER_STATE] ?: return val state = ctx.attributes[PLAYER_STATE] ?: return
val packet = event.packet val packet = event.packet
socialStore.block(state.userId, packet.username) socialStore.block(state.userId, packet.username)
log.info { "BlockPlayer user=${state.userId} name='${packet.username}' reason='${packet.reason}'" } log.info {
"BlockPlayer user=${state.userId} name='${packet.username}' reason='${packet.reason}'"
}
ctx.send( ctx.send(
PartyMemberJoinPacket( PartyMemberJoinPacket(
player = syntheticId(packet.username), player = syntheticId(packet.username),