Merge pull request #6 from openmmo-org/feat/friendlist

feat(game): add friendlist
This commit is contained in:
Fiereu authored and GitHub committed 2026-06-22 17:13:30 +02:00
commit df862c71b7
393 files changed
+6340 -6049

No files matched your search

@@ -7,593 +7,592 @@ import de.fiereu.network.s2c
import de.fiereu.openmmo.net.game.packets.*
object GameProtocol : Protocol() {
override val compressed: Boolean = true
override val compressed: Boolean = true
init {
c2s<JoinPacket>(0x01u, JoinPacketCodec)
s2c<JoinResponsePacket>(0x01u, JoinResponsePacketCodec)
init {
c2s<JoinPacket>(0x01u, JoinPacketCodec)
s2c<JoinResponsePacket>(0x01u, JoinResponsePacketCodec)
c2s<RequestCharactersPacket>(0x02u, RequestCharactersPacketCodec)
s2c<CharactersListPacket>(0x02u, CharactersListPacketCodec)
c2s<RequestCharactersPacket>(0x02u, RequestCharactersPacketCodec)
s2c<CharactersListPacket>(0x02u, CharactersListPacketCodec)
c2s<CreateCharacterPacket>(0x03u, CreateCharacterPacketCodec)
s2c<FriendRosterDeltaPacket>(0x03u, FriendRosterDeltaPacketCodec)
c2s<CreateCharacterPacket>(0x03u, CreateCharacterPacketCodec)
s2c<FriendRosterDeltaPacket>(0x03u, FriendRosterDeltaPacketCodec)
c2s<SelectCharacterPacket>(0x04u, SelectCharacterPacketCodec)
s2c<SelectedCharacterPacket>(0x04u, SelectedCharacterPacketCodec)
c2s<SelectCharacterPacket>(0x04u, SelectCharacterPacketCodec)
s2c<SelectedCharacterPacket>(0x04u, SelectedCharacterPacketCodec)
c2s<RequestPlayerPacket>(0x05u, RequestPlayerPacketCodec)
s2c<LoadEntityPacket>(0x05u, LoadEntityPacketCodec)
c2s<RequestPlayerPacket>(0x05u, RequestPlayerPacketCodec)
s2c<LoadEntityPacket>(0x05u, LoadEntityPacketCodec)
c2s<MovementPacket>(0x06u, MovementPacketCodec)
c2s<MovementPacket>(0x06u, MovementPacketCodec)
c2s<FaceDirectionPacket>(0x07u, FaceDirectionPacketCodec)
s2c<EntityFaceTurnPacket>(0x07u, EntityFaceTurnPacketCodec)
c2s<FaceDirectionPacket>(0x07u, FaceDirectionPacketCodec)
s2c<EntityFaceTurnPacket>(0x07u, EntityFaceTurnPacketCodec)
c2s<ChatMessageSendPacket>(0x08u, ChatMessageSendPacketCodec)
s2c<EntityLeavePacket>(0x08u, EntityLeavePacketCodec)
c2s<ChatMessageSendPacket>(0x08u, ChatMessageSendPacketCodec)
s2c<EntityLeavePacket>(0x08u, EntityLeavePacketCodec)
bidi<ChatMessagePacket>(0x09u, ChatMessagePacketCodec)
bidi<ChatMessagePacket>(0x09u, ChatMessagePacketCodec)
c2s<BattleMoveUsePacket>(0x0Au, BattleMoveUsePacketCodec)
s2c<WorldFlagTableResetPacket>(0x0Au, WorldFlagTableResetPacketCodec)
c2s<BattleMoveUsePacket>(0x0Au, BattleMoveUsePacketCodec)
s2c<WorldFlagTableResetPacket>(0x0Au, WorldFlagTableResetPacketCodec)
c2s<EvolutionPromptResponsePacket>(0x0Bu, EvolutionPromptResponsePacketCodec)
s2c<WorldFlagSetPacket>(0x0Bu, WorldFlagSetPacketCodec)
c2s<EvolutionPromptResponsePacket>(0x0Bu, EvolutionPromptResponsePacketCodec)
s2c<WorldFlagSetPacket>(0x0Bu, WorldFlagSetPacketCodec)
c2s<BattlePartySwitchPacket>(0x0Cu, BattlePartySwitchPacketCodec)
s2c<LocalCharacterDeltaPacket>(0x0Cu, LocalCharacterDeltaPacketCodec)
c2s<BattlePartySwitchPacket>(0x0Cu, BattlePartySwitchPacketCodec)
s2c<LocalCharacterDeltaPacket>(0x0Cu, LocalCharacterDeltaPacketCodec)
bidi<DialogDataPacket>(0x0Du, DialogDataPacketCodec)
bidi<DialogDataPacket>(0x0Du, DialogDataPacketCodec)
bidi<DialogStatePacket>(0x0Eu, DialogStatePacketCodec)
bidi<DialogStatePacket>(0x0Eu, DialogStatePacketCodec)
c2s<PokemonListAddPacket>(0x0Fu, PokemonListAddPacketCodec)
s2c<EntityPresencePacket>(0x0Fu, EntityPresencePacketCodec)
c2s<PokemonListAddPacket>(0x0Fu, PokemonListAddPacketCodec)
s2c<EntityPresencePacket>(0x0Fu, EntityPresencePacketCodec)
bidi<LoadMapPacket>(0x10u, LoadMapPacketCodec)
bidi<LoadMapPacket>(0x10u, LoadMapPacketCodec)
c2s<PartyMemberSelectPacket>(0x11u, PartyMemberSelectPacketCodec)
s2c<NpcUpdatePacket>(0x11u, NpcUpdatePacketCodec)
c2s<PartyMemberSelectPacket>(0x11u, PartyMemberSelectPacketCodec)
s2c<NpcUpdatePacket>(0x11u, NpcUpdatePacketCodec)
bidi<NpcSpawnPacket>(0x12u, NpcSpawnPacketCodec)
bidi<NpcSpawnPacket>(0x12u, NpcSpawnPacketCodec)
bidi<PokemonContainerPacket>(0x13u, PokemonContainerPacketCodec)
bidi<PokemonContainerPacket>(0x13u, PokemonContainerPacketCodec)
c2s<EntityActionRequestPacket>(0x14u, EntityActionRequestPacketCodec)
s2c<SocialListEntryAddPacket>(0x14u, SocialListEntryAddPacketCodec)
c2s<EntityActionRequestPacket>(0x14u, EntityActionRequestPacketCodec)
s2c<SocialListEntryAddPacket>(0x14u, SocialListEntryAddPacketCodec)
c2s<ChatLocalePreferencesPacket>(0x15u, ChatLocalePreferencesPacketCodec)
s2c<SocialListEntryRemovePacket>(0x15u, SocialListEntryRemovePacketCodec)
c2s<ChatLocalePreferencesPacket>(0x15u, ChatLocalePreferencesPacketCodec)
s2c<SocialListEntryRemovePacket>(0x15u, SocialListEntryRemovePacketCodec)
c2s<InGameChallengeResponsePacket>(0x16u, InGameChallengeResponsePacketCodec)
s2c<BattleEntityDeltaPacket>(0x16u, BattleEntityDeltaPacketCodec)
c2s<InGameChallengeResponsePacket>(0x16u, InGameChallengeResponsePacketCodec)
s2c<BattleEntityDeltaPacket>(0x16u, BattleEntityDeltaPacketCodec)
c2s<StorageBoxClosePacket>(0x17u, StorageBoxClosePacketCodec)
s2c<SocialEntryFlagSetPacket>(0x17u, SocialEntryFlagSetPacketCodec)
c2s<StorageBoxClosePacket>(0x17u, StorageBoxClosePacketCodec)
s2c<SocialEntryFlagSetPacket>(0x17u, SocialEntryFlagSetPacketCodec)
c2s<MonsterStatusConditionPacket>(0x18u, MonsterStatusConditionPacketCodec)
s2c<SocialEntryPresencePacket>(0x18u, SocialEntryPresencePacketCodec)
c2s<MonsterStatusConditionPacket>(0x18u, MonsterStatusConditionPacketCodec)
s2c<SocialEntryPresencePacket>(0x18u, SocialEntryPresencePacketCodec)
c2s<MonsterFormActionPacket>(0x19u, MonsterFormActionPacketCodec)
s2c<SocialEntryRenamePacket>(0x19u, SocialEntryRenamePacketCodec)
c2s<MonsterFormActionPacket>(0x19u, MonsterFormActionPacketCodec)
s2c<SocialEntryRenamePacket>(0x19u, SocialEntryRenamePacketCodec)
s2c<EntityMovePpPacket>(0x1Au, EntityMovePpPacketCodec)
s2c<EntityMovePpPacket>(0x1Au, EntityMovePpPacketCodec)
bidi<MapTransitionPacket>(0x1Bu, MapTransitionPacketCodec)
bidi<MapTransitionPacket>(0x1Bu, MapTransitionPacketCodec)
c2s<StorageBoxFilterPacket>(0x1Cu, StorageBoxFilterPacketCodec)
s2c<PokedexSpeciesResetPacket>(0x1Cu, PokedexSpeciesResetPacketCodec)
c2s<StorageBoxFilterPacket>(0x1Cu, StorageBoxFilterPacketCodec)
s2c<PokedexSpeciesResetPacket>(0x1Cu, PokedexSpeciesResetPacketCodec)
c2s<PokemonFlagsUpdatePacket>(0x1Du, PokemonFlagsUpdatePacketCodec)
s2c<PokedexSpeciesUnlockPacket>(0x1Du, PokedexSpeciesUnlockPacketCodec)
c2s<PokemonFlagsUpdatePacket>(0x1Du, PokemonFlagsUpdatePacketCodec)
s2c<PokedexSpeciesUnlockPacket>(0x1Du, PokedexSpeciesUnlockPacketCodec)
s2c<OverworldWeatherControlPacket>(0x1Eu, OverworldWeatherControlPacketCodec)
s2c<OverworldWeatherControlPacket>(0x1Eu, OverworldWeatherControlPacketCodec)
s2c<OverworldParticleSpawnPacket>(0x1Fu, OverworldParticleSpawnPacketCodec)
s2c<OverworldParticleSpawnPacket>(0x1Fu, OverworldParticleSpawnPacketCodec)
c2s<NullPacket>(0x20u, NullPacketCodec)
s2c<TokenPayloadPacket>(0x20u, TokenPayloadPacketCodec)
c2s<NullPacket>(0x20u, NullPacketCodec)
s2c<TokenPayloadPacket>(0x20u, TokenPayloadPacketCodec)
c2s<WarpTileInteractPacket>(0x21u, WarpTileInteractPacketCodec)
s2c<DialogActionPacket>(0x21u, DialogActionPacketCodec)
c2s<WarpTileInteractPacket>(0x21u, WarpTileInteractPacketCodec)
s2c<DialogActionPacket>(0x21u, DialogActionPacketCodec)
bidi<EntityInteractPacket>(0x22u, EntityInteractPacketCodec)
bidi<EntityInteractPacket>(0x22u, EntityInteractPacketCodec)
c2s<ExchangeItemRequestPacket>(0x23u, ExchangeItemRequestPacketCodec)
s2c<EventOverlayStatePacket>(0x23u, EventOverlayStatePacketCodec)
c2s<ExchangeItemRequestPacket>(0x23u, ExchangeItemRequestPacketCodec)
s2c<EventOverlayStatePacket>(0x23u, EventOverlayStatePacketCodec)
c2s<ShopSellRequestPacket>(0x24u, ShopSellRequestPacketCodec)
s2c<NpcPanelTogglePacket>(0x24u, NpcPanelTogglePacketCodec)
c2s<ShopSellRequestPacket>(0x24u, ShopSellRequestPacketCodec)
s2c<NpcPanelTogglePacket>(0x24u, NpcPanelTogglePacketCodec)
bidi<DialogChoicePacket>(0x25u, DialogChoicePacketCodec)
bidi<DialogChoicePacket>(0x25u, DialogChoicePacketCodec)
bidi<DialogOptionPacket>(0x26u, DialogOptionPacketCodec)
bidi<DialogOptionPacket>(0x26u, DialogOptionPacketCodec)
c2s<PlayerStopMovingPacket>(0x27u, PlayerStopMovingPacketCodec)
s2c<BattlePromptSwitchPacket>(0x27u, BattlePromptSwitchPacketCodec)
c2s<PlayerStopMovingPacket>(0x27u, PlayerStopMovingPacketCodec)
s2c<BattlePromptSwitchPacket>(0x27u, BattlePromptSwitchPacketCodec)
c2s<TypedBinaryDataPacket>(0x28u, TypedBinaryDataPacketCodec)
s2c<EntityInteractionFlagPacket>(0x28u, EntityInteractionFlagPacketCodec)
c2s<TypedBinaryDataPacket>(0x28u, TypedBinaryDataPacketCodec)
s2c<EntityInteractionFlagPacket>(0x28u, EntityInteractionFlagPacketCodec)
c2s<CustomizeCharacterAppearancePacket>(0x29u, CustomizeCharacterAppearancePacketCodec)
s2c<ShopPriceTablePacket>(0x29u, ShopPriceTablePacketCodec)
c2s<CustomizeCharacterAppearancePacket>(0x29u, CustomizeCharacterAppearancePacketCodec)
s2c<ShopPriceTablePacket>(0x29u, ShopPriceTablePacketCodec)
c2s<TeamNameChangePacket>(0x2Au, TeamNameChangePacketCodec)
s2c<BattleStatusFlagPacket>(0x2Au, BattleStatusFlagPacketCodec)
c2s<TeamNameChangePacket>(0x2Au, TeamNameChangePacketCodec)
s2c<BattleStatusFlagPacket>(0x2Au, BattleStatusFlagPacketCodec)
c2s<SetCharacterNamePacket>(0x2Bu, SetCharacterNamePacketCodec)
s2c<FollowerAdvancePacket>(0x2Bu, FollowerAdvancePacketCodec)
c2s<SetCharacterNamePacket>(0x2Bu, SetCharacterNamePacketCodec)
s2c<FollowerAdvancePacket>(0x2Bu, FollowerAdvancePacketCodec)
c2s<NpcDialogResponsePacket>(0x2Cu, NpcDialogResponsePacketCodec)
s2c<EntityTitleTagPacket>(0x2Cu, EntityTitleTagPacketCodec)
c2s<NpcDialogResponsePacket>(0x2Cu, NpcDialogResponsePacketCodec)
s2c<EntityTitleTagPacket>(0x2Cu, EntityTitleTagPacketCodec)
c2s<EntityInteractRequestPacket>(0x2Du, EntityInteractRequestPacketCodec)
s2c<MapCellTilesetPacket>(0x2Du, MapCellTilesetPacketCodec)
c2s<EntityInteractRequestPacket>(0x2Du, EntityInteractRequestPacketCodec)
s2c<MapCellTilesetPacket>(0x2Du, MapCellTilesetPacketCodec)
c2s<SendDirectMessagePacket>(0x2Eu, SendDirectMessagePacketCodec)
s2c<EntityRenamePacket>(0x2Eu, EntityRenamePacketCodec)
c2s<SendDirectMessagePacket>(0x2Eu, SendDirectMessagePacketCodec)
s2c<EntityRenamePacket>(0x2Eu, EntityRenamePacketCodec)
c2s<DialogResponsePacket>(0x2Fu, DialogResponsePacketCodec)
s2c<WorldJoinConfirmPacket>(0x2Fu, WorldJoinConfirmPacketCodec)
c2s<DialogResponsePacket>(0x2Fu, DialogResponsePacketCodec)
s2c<WorldJoinConfirmPacket>(0x2Fu, WorldJoinConfirmPacketCodec)
c2s<BattleActionPacket>(0x30u, BattleActionPacketCodec)
c2s<BattleActionPacket>(0x30u, BattleActionPacketCodec)
s2c<BattleBulkStatePacket>(0x31u, BattleBulkStatePacketCodec)
s2c<BattleBulkStatePacket>(0x31u, BattleBulkStatePacketCodec)
c2s<BattleActionSelectPacket>(0x32u, BattleActionSelectPacketCodec)
s2c<BattleQueuedEventPacket>(0x32u, BattleQueuedEventPacketCodec)
c2s<BattleActionSelectPacket>(0x32u, BattleActionSelectPacketCodec)
s2c<BattleQueuedEventPacket>(0x32u, BattleQueuedEventPacketCodec)
c2s<MapLoadedAckPacket>(0x33u, MapLoadedAckPacketCodec)
s2c<BattleEntityMoveEventPacket>(0x33u, BattleEntityMoveEventPacketCodec)
c2s<MapLoadedAckPacket>(0x33u, MapLoadedAckPacketCodec)
s2c<BattleEntityMoveEventPacket>(0x33u, BattleEntityMoveEventPacketCodec)
c2s<SpectateRequestPacket>(0x34u, SpectateRequestPacketCodec)
s2c<BattleSlotEventEnumPacket>(0x34u, BattleSlotEventEnumPacketCodec)
c2s<SpectateRequestPacket>(0x34u, SpectateRequestPacketCodec)
s2c<BattleSlotEventEnumPacket>(0x34u, BattleSlotEventEnumPacketCodec)
c2s<LeaveBattlePacket>(0x35u, LeaveBattlePacketCodec)
s2c<BattleSlotMoveEventPacket>(0x35u, BattleSlotMoveEventPacketCodec)
c2s<LeaveBattlePacket>(0x35u, LeaveBattlePacketCodec)
s2c<BattleSlotMoveEventPacket>(0x35u, BattleSlotMoveEventPacketCodec)
c2s<RequestNextBattleSequencePacket>(0x36u, RequestNextBattleSequencePacketCodec)
s2c<BattleSlotFlagEventPacket>(0x36u, BattleSlotFlagEventPacketCodec)
c2s<RequestNextBattleSequencePacket>(0x36u, RequestNextBattleSequencePacketCodec)
s2c<BattleSlotFlagEventPacket>(0x36u, BattleSlotFlagEventPacketCodec)
c2s<BattleSlotActionPacket>(0x37u, BattleSlotActionPacketCodec)
s2c<BattleListEventPacket>(0x37u, BattleListEventPacketCodec)
c2s<BattleSlotActionPacket>(0x37u, BattleSlotActionPacketCodec)
s2c<BattleListEventPacket>(0x37u, BattleListEventPacketCodec)
c2s<BattleSwitchSelectionsPacket>(0x38u, BattleSwitchSelectionsPacketCodec)
s2c<BattleEntityActionEventPacket>(0x38u, BattleEntityActionEventPacketCodec)
c2s<BattleSwitchSelectionsPacket>(0x38u, BattleSwitchSelectionsPacketCodec)
s2c<BattleEntityActionEventPacket>(0x38u, BattleEntityActionEventPacketCodec)
c2s<BattleUseItemPacket>(0x39u, BattleUseItemPacketCodec)
s2c<BattleLabeledMoveEventPacket>(0x39u, BattleLabeledMoveEventPacketCodec)
c2s<BattleUseItemPacket>(0x39u, BattleUseItemPacketCodec)
s2c<BattleLabeledMoveEventPacket>(0x39u, BattleLabeledMoveEventPacketCodec)
c2s<SetBattleMonsterAppearancePacket>(0x3Au, SetBattleMonsterAppearancePacketCodec)
s2c<BattleEnumPairEventPacket>(0x3Au, BattleEnumPairEventPacketCodec)
c2s<SetBattleMonsterAppearancePacket>(0x3Au, SetBattleMonsterAppearancePacketCodec)
s2c<BattleEnumPairEventPacket>(0x3Au, BattleEnumPairEventPacketCodec)
c2s<PrismaticPearlTransferPacket>(0x3Bu, PrismaticPearlTransferPacketCodec)
s2c<BattleEmptyEventPacket>(0x3Bu, BattleEmptyEventPacketCodec)
c2s<PrismaticPearlTransferPacket>(0x3Bu, PrismaticPearlTransferPacketCodec)
s2c<BattleEmptyEventPacket>(0x3Bu, BattleEmptyEventPacketCodec)
c2s<SetActiveMovesetPacket>(0x3Cu, SetActiveMovesetPacketCodec)
s2c<ServerChatTemplate5002Packet>(0x3Cu, ServerChatTemplate5002PacketCodec)
c2s<SetActiveMovesetPacket>(0x3Cu, SetActiveMovesetPacketCodec)
s2c<ServerChatTemplate5002Packet>(0x3Cu, ServerChatTemplate5002PacketCodec)
c2s<BattleCancelRequestPacket>(0x3Du, BattleCancelRequestPacketCodec)
s2c<ServerChatTemplate5003Packet>(0x3Du, ServerChatTemplate5003PacketCodec)
c2s<BattleCancelRequestPacket>(0x3Du, BattleCancelRequestPacketCodec)
s2c<ServerChatTemplate5003Packet>(0x3Du, ServerChatTemplate5003PacketCodec)
s2c<BattleSlotSwitchEventPacket>(0x3Eu, BattleSlotSwitchEventPacketCodec)
s2c<BattleSlotSwitchEventPacket>(0x3Eu, BattleSlotSwitchEventPacketCodec)
c2s<BattleSimulationRequestPacket>(0x3Fu, BattleSimulationRequestPacketCodec)
s2c<BattleMoveDisableUpdatePacket>(0x3Fu, BattleMoveDisableUpdatePacketCodec)
c2s<BattleSimulationRequestPacket>(0x3Fu, BattleSimulationRequestPacketCodec)
s2c<BattleMoveDisableUpdatePacket>(0x3Fu, BattleMoveDisableUpdatePacketCodec)
c2s<SubmitBreedingPartyPacket>(0x40u, SubmitBreedingPartyPacketCodec)
s2c<BattleSidePartyPacket>(0x40u, BattleSidePartyPacketCodec)
c2s<SubmitBreedingPartyPacket>(0x40u, SubmitBreedingPartyPacketCodec)
s2c<BattleSidePartyPacket>(0x40u, BattleSidePartyPacketCodec)
c2s<MonsterFavoriteTogglePacket>(0x41u, MonsterFavoriteTogglePacketCodec)
s2c<BattlePokemonSpritePacket>(0x41u, BattlePokemonSpritePacketCodec)
c2s<MonsterFavoriteTogglePacket>(0x41u, MonsterFavoriteTogglePacketCodec)
s2c<BattlePokemonSpritePacket>(0x41u, BattlePokemonSpritePacketCodec)
c2s<LeaveChatChannelPacket>(0x42u, LeaveChatChannelPacketCodec)
s2c<BattleSideAddPokemonPacket>(0x42u, BattleSideAddPokemonPacketCodec)
c2s<LeaveChatChannelPacket>(0x42u, LeaveChatChannelPacketCodec)
s2c<BattleSideAddPokemonPacket>(0x42u, BattleSideAddPokemonPacketCodec)
c2s<SetChatUserIgnoredPacket>(0x43u, SetChatUserIgnoredPacketCodec)
s2c<BattleSideRemovePokemonPacket>(0x43u, BattleSideRemovePokemonPacketCodec)
c2s<SetChatUserIgnoredPacket>(0x43u, SetChatUserIgnoredPacketCodec)
s2c<BattleSideRemovePokemonPacket>(0x43u, BattleSideRemovePokemonPacketCodec)
c2s<TournamentTeleportAcceptPacket>(0x44u, TournamentTeleportAcceptPacketCodec)
s2c<BattlePokemonStatusPacket>(0x44u, BattlePokemonStatusPacketCodec)
c2s<TournamentTeleportAcceptPacket>(0x44u, TournamentTeleportAcceptPacketCodec)
s2c<BattlePokemonStatusPacket>(0x44u, BattlePokemonStatusPacketCodec)
c2s<NpcDialogueChoicePacket>(0x45u, NpcDialogueChoicePacketCodec)
s2c<WorldStateControlPacket>(0x45u, WorldStateControlPacketCodec)
c2s<NpcDialogueChoicePacket>(0x45u, NpcDialogueChoicePacketCodec)
s2c<WorldStateControlPacket>(0x45u, WorldStateControlPacketCodec)
c2s<BattleReadyPacket>(0x46u, BattleReadyPacketCodec)
s2c<BattleControlBytesPacket>(0x46u, BattleControlBytesPacketCodec)
c2s<BattleReadyPacket>(0x46u, BattleReadyPacketCodec)
s2c<BattleControlBytesPacket>(0x46u, BattleControlBytesPacketCodec)
c2s<LeaveMatchmakingQueuePacket>(0x47u, LeaveMatchmakingQueuePacketCodec)
s2c<BattleScreenOpenPacket>(0x47u, BattleScreenOpenPacketCodec)
c2s<LeaveMatchmakingQueuePacket>(0x47u, LeaveMatchmakingQueuePacketCodec)
s2c<BattleScreenOpenPacket>(0x47u, BattleScreenOpenPacketCodec)
c2s<BattleActionSubmitPacket>(0x48u, BattleActionSubmitPacketCodec)
s2c<BattleActionResultPacket>(0x48u, BattleActionResultPacketCodec)
c2s<BattleActionSubmitPacket>(0x48u, BattleActionSubmitPacketCodec)
s2c<BattleActionResultPacket>(0x48u, BattleActionResultPacketCodec)
c2s<JoinMatchmakingQueuePacket>(0x49u, JoinMatchmakingQueuePacketCodec)
s2c<BattleMoveSelectionCancelPacket>(0x49u, BattleMoveSelectionCancelPacketCodec)
c2s<JoinMatchmakingQueuePacket>(0x49u, JoinMatchmakingQueuePacketCodec)
s2c<BattleMoveSelectionCancelPacket>(0x49u, BattleMoveSelectionCancelPacketCodec)
c2s<BattleTierSelectPacket>(0x4Au, BattleTierSelectPacketCodec)
s2c<BattleRatingBulkPacket>(0x4Au, BattleRatingBulkPacketCodec)
c2s<BattleTierSelectPacket>(0x4Au, BattleTierSelectPacketCodec)
s2c<BattleRatingBulkPacket>(0x4Au, BattleRatingBulkPacketCodec)
c2s<BattleChatMessagePacket>(0x4Bu, BattleChatMessagePacketCodec)
s2c<BattleRatingUpdatePacket>(0x4Bu, BattleRatingUpdatePacketCodec)
c2s<BattleChatMessagePacket>(0x4Bu, BattleChatMessagePacketCodec)
s2c<BattleRatingUpdatePacket>(0x4Bu, BattleRatingUpdatePacketCodec)
c2s<MatchmakingActionPacket>(0x4Cu, MatchmakingActionPacketCodec)
s2c<BattleMoveTargetsPacket>(0x4Cu, BattleMoveTargetsPacketCodec)
c2s<MatchmakingActionPacket>(0x4Cu, MatchmakingActionPacketCodec)
s2c<BattleMoveTargetsPacket>(0x4Cu, BattleMoveTargetsPacketCodec)
c2s<MarketListingsRequestPacket>(0x4Du, MarketListingsRequestPacketCodec)
s2c<BattleStateBytePacket>(0x4Du, BattleStateBytePacketCodec)
c2s<MarketListingsRequestPacket>(0x4Du, MarketListingsRequestPacketCodec)
s2c<BattleStateBytePacket>(0x4Du, BattleStateBytePacketCodec)
s2c<BattleMoveListPacket>(0x4Eu, BattleMoveListPacketCodec)
s2c<BattleMoveListPacket>(0x4Eu, BattleMoveListPacketCodec)
c2s<MarketSearchFilterPacket>(0x4Fu, MarketSearchFilterPacketCodec)
s2c<ChannelAssignmentsPacket>(0x4Fu, ChannelAssignmentsPacketCodec)
c2s<MarketSearchFilterPacket>(0x4Fu, MarketSearchFilterPacketCodec)
s2c<ChannelAssignmentsPacket>(0x4Fu, ChannelAssignmentsPacketCodec)
c2s<TradeActionPacket>(0x50u, TradeActionPacketCodec)
s2c<DuelInvitePacket>(0x50u, DuelInvitePacketCodec)
c2s<TradeActionPacket>(0x50u, TradeActionPacketCodec)
s2c<DuelInvitePacket>(0x50u, DuelInvitePacketCodec)
c2s<StringCommandPacket>(0x51u, StringCommandPacketCodec)
s2c<DuelInviteOutcomePacket>(0x51u, DuelInviteOutcomePacketCodec)
c2s<StringCommandPacket>(0x51u, StringCommandPacketCodec)
s2c<DuelInviteOutcomePacket>(0x51u, DuelInviteOutcomePacketCodec)
c2s<TradeSelectMonPacket>(0x52u, TradeSelectMonPacketCodec)
s2c<TradeListEntryPacket>(0x52u, TradeListEntryPacketCodec)
c2s<TradeSelectMonPacket>(0x52u, TradeSelectMonPacketCodec)
s2c<TradeListEntryPacket>(0x52u, TradeListEntryPacketCodec)
c2s<BattlePartySlotSelectPacket>(0x53u, BattlePartySlotSelectPacketCodec)
s2c<BattleStateSlotIntPacket>(0x53u, BattleStateSlotIntPacketCodec)
c2s<BattlePartySlotSelectPacket>(0x53u, BattlePartySlotSelectPacketCodec)
s2c<BattleStateSlotIntPacket>(0x53u, BattleStateSlotIntPacketCodec)
s2c<BattleBoardCellPacket>(0x54u, BattleBoardCellPacketCodec)
s2c<BattleBoardCellPacket>(0x54u, BattleBoardCellPacketCodec)
s2c<SpatialGroupSnapshotPacket>(0x55u, SpatialGroupSnapshotPacketCodec)
s2c<SpatialGroupSnapshotPacket>(0x55u, SpatialGroupSnapshotPacketCodec)
s2c<SpatialGroupInsertPacket>(0x56u, SpatialGroupInsertPacketCodec)
s2c<SpatialGroupInsertPacket>(0x56u, SpatialGroupInsertPacketCodec)
s2c<SpatialGroupDeletePacket>(0x57u, SpatialGroupDeletePacketCodec)
s2c<SpatialGroupDeletePacket>(0x57u, SpatialGroupDeletePacketCodec)
s2c<MenuVisibilityPacket>(0x58u, MenuVisibilityPacketCodec)
s2c<MenuVisibilityPacket>(0x58u, MenuVisibilityPacketCodec)
s2c<MenuPagePayloadPacket>(0x59u, MenuPagePayloadPacketCodec)
s2c<MenuPagePayloadPacket>(0x59u, MenuPagePayloadPacketCodec)
s2c<EntityNameChoicesPacket>(0x5Au, EntityNameChoicesPacketCodec)
s2c<EntityNameChoicesPacket>(0x5Au, EntityNameChoicesPacketCodec)
s2c<OptionListWindowPacket>(0x5Bu, OptionListWindowPacketCodec)
s2c<OptionListWindowPacket>(0x5Bu, OptionListWindowPacketCodec)
s2c<ListWindowPagePacket>(0x5Cu, ListWindowPagePacketCodec)
s2c<ListWindowPagePacket>(0x5Cu, ListWindowPagePacketCodec)
s2c<MarketBoardPagePacket>(0x5Du, MarketBoardPagePacketCodec)
s2c<MarketBoardPagePacket>(0x5Du, MarketBoardPagePacketCodec)
s2c<SceneObjectStatesPacket>(0x5Eu, SceneObjectStatesPacketCodec)
s2c<SceneObjectStatesPacket>(0x5Eu, SceneObjectStatesPacketCodec)
s2c<StorageInventoryPacket>(0x5Fu, StorageInventoryPacketCodec)
s2c<StorageInventoryPacket>(0x5Fu, StorageInventoryPacketCodec)
c2s<BlockPlayerPacket>(0x60u, BlockPlayerPacketCodec)
s2c<StorageContextWindowPacket>(0x60u, StorageContextWindowPacketCodec)
c2s<BlockPlayerPacket>(0x60u, BlockPlayerPacketCodec)
s2c<StorageContextWindowPacket>(0x60u, StorageContextWindowPacketCodec)
c2s<UnblockPlayerPacket>(0x61u, UnblockPlayerPacketCodec)
s2c<EntityCoordSyncPacket>(0x61u, EntityCoordSyncPacketCodec)
c2s<UnblockPlayerPacket>(0x61u, UnblockPlayerPacketCodec)
s2c<EntityCoordSyncPacket>(0x61u, EntityCoordSyncPacketCodec)
c2s<RemoveFriendPacket>(0x62u, RemoveFriendPacketCodec)
s2c<SocialActionOutcomePacket>(0x62u, SocialActionOutcomePacketCodec)
c2s<AddFriendPacket>(0x62u, AddFriendPacketCodec)
s2c<SocialActionOutcomePacket>(0x62u, SocialActionOutcomePacketCodec)
c2s<SetPlayerTitlePacket>(0x63u, SetPlayerTitlePacketCodec)
s2c<ContactRosterPacket>(0x63u, ContactRosterPacketCodec)
c2s<RemoveFriendPacket>(0x63u, RemoveFriendPacketCodec)
s2c<FriendListPacket>(0x63u, FriendListPacketCodec)
c2s<FriendProfileRequestPacket>(0x64u, FriendProfileRequestPacketCodec)
s2c<ContactInsertPacket>(0x64u, ContactInsertPacketCodec)
c2s<FriendProfileRequestPacket>(0x64u, FriendProfileRequestPacketCodec)
s2c<ContactInsertPacket>(0x64u, ContactInsertPacketCodec)
s2c<ContactDeletePacket>(0x65u, ContactDeletePacketCodec)
s2c<ContactDeletePacket>(0x65u, ContactDeletePacketCodec)
s2c<ContactOnlineStatePacket>(0x66u, ContactOnlineStatePacketCodec)
s2c<ContactOnlineStatePacket>(0x66u, ContactOnlineStatePacketCodec)
s2c<PartyRosterPacket>(0x67u, PartyRosterPacketCodec)
s2c<PartyRosterPacket>(0x67u, PartyRosterPacketCodec)
s2c<PartyMemberJoinPacket>(0x68u, PartyMemberJoinPacketCodec)
s2c<PartyMemberJoinPacket>(0x68u, PartyMemberJoinPacketCodec)
s2c<PartyMemberLeavePacket>(0x69u, PartyMemberLeavePacketCodec)
s2c<PartyMemberLeavePacket>(0x69u, PartyMemberLeavePacketCodec)
c2s<InstanceReadyCheckPacket>(0x6Au, InstanceReadyCheckPacketCodec)
c2s<InstanceReadyCheckPacket>(0x6Au, InstanceReadyCheckPacketCodec)
c2s<CancelMatchmakingSearchPacket>(0x6Bu, CancelMatchmakingSearchPacketCodec)
s2c<ActiveBattleSidePacket>(0x6Bu, ActiveBattleSidePacketCodec)
c2s<CancelMatchmakingSearchPacket>(0x6Bu, CancelMatchmakingSearchPacketCodec)
s2c<ActiveBattleSidePacket>(0x6Bu, ActiveBattleSidePacketCodec)
c2s<MatchmakingLanguagePrefsPacket>(0x6Cu, MatchmakingLanguagePrefsPacketCodec)
s2c<MountMoveCooldownPacket>(0x6Cu, MountMoveCooldownPacketCodec)
c2s<MatchmakingLanguagePrefsPacket>(0x6Cu, MatchmakingLanguagePrefsPacketCodec)
s2c<MountMoveCooldownPacket>(0x6Cu, MountMoveCooldownPacketCodec)
s2c<ClientCookieUpdatePacket>(0x6Du, ClientCookieUpdatePacketCodec)
s2c<ClientCookieUpdatePacket>(0x6Du, ClientCookieUpdatePacketCodec)
s2c<WorldToggleFlagsPacket>(0x6Eu, WorldToggleFlagsPacketCodec)
s2c<WorldToggleFlagsPacket>(0x6Eu, WorldToggleFlagsPacketCodec)
s2c<NamedCategoryEntriesPacket>(0x6Fu, NamedCategoryEntriesPacketCodec)
s2c<NamedCategoryEntriesPacket>(0x6Fu, NamedCategoryEntriesPacketCodec)
c2s<StorageBoxRequestPacket>(0x70u, StorageBoxRequestPacketCodec)
s2c<GtlMarketListingsPacket>(0x70u, GtlMarketListingsPacketCodec)
c2s<StorageBoxRequestPacket>(0x70u, StorageBoxRequestPacketCodec)
s2c<GtlMarketListingsPacket>(0x70u, GtlMarketListingsPacketCodec)
c2s<GtlPurchaseListingPacket>(0x71u, GtlPurchaseListingPacketCodec)
s2c<MatchmakingRentalsPacket>(0x71u, MatchmakingRentalsPacketCodec)
c2s<GtlPurchaseListingPacket>(0x71u, GtlPurchaseListingPacketCodec)
s2c<MatchmakingRentalsPacket>(0x71u, MatchmakingRentalsPacketCodec)
s2c<WorldStateValuePacket>(0x72u, WorldStateValuePacketCodec)
s2c<WorldStateValuePacket>(0x72u, WorldStateValuePacketCodec)
c2s<AssignBreedingSlotPacket>(0x73u, AssignBreedingSlotPacketCodec)
s2c<BreedingForecastPacket>(0x73u, BreedingForecastPacketCodec)
c2s<AssignBreedingSlotPacket>(0x73u, AssignBreedingSlotPacketCodec)
s2c<BreedingForecastPacket>(0x73u, BreedingForecastPacketCodec)
c2s<LeaderboardViewRequestPacket>(0x74u, LeaderboardViewRequestPacketCodec)
s2c<ServerNoticePacket>(0x74u, ServerNoticePacketCodec)
c2s<LeaderboardViewRequestPacket>(0x74u, LeaderboardViewRequestPacketCodec)
s2c<ServerNoticePacket>(0x74u, ServerNoticePacketCodec)
c2s<TourneyRegistrationPacket>(0x75u, TourneyRegistrationPacketCodec)
s2c<MatchmakingSideTeamPacket>(0x75u, MatchmakingSideTeamPacketCodec)
c2s<TourneyRegistrationPacket>(0x75u, TourneyRegistrationPacketCodec)
s2c<MatchmakingSideTeamPacket>(0x75u, MatchmakingSideTeamPacketCodec)
c2s<NpcInteractionChoicePacket>(0x76u, NpcInteractionChoicePacketCodec)
s2c<ActivePokemonSummaryPacket>(0x76u, ActivePokemonSummaryPacketCodec)
c2s<NpcInteractionChoicePacket>(0x76u, NpcInteractionChoicePacketCodec)
s2c<ActivePokemonSummaryPacket>(0x76u, ActivePokemonSummaryPacketCodec)
c2s<BattleTargetPickPacket>(0x77u, BattleTargetPickPacketCodec)
s2c<StreamChunkPacket>(0x77u, StreamChunkPacketCodec)
c2s<BattleTargetPickPacket>(0x77u, BattleTargetPickPacketCodec)
s2c<StreamChunkPacket>(0x77u, StreamChunkPacketCodec)
s2c<MatchmakingMemberProgressPacket>(0x78u, MatchmakingMemberProgressPacketCodec)
s2c<MatchmakingMemberProgressPacket>(0x78u, MatchmakingMemberProgressPacketCodec)
c2s<PcBoxStorePacket>(0x79u, PcBoxStorePacketCodec)
s2c<BattleStatCountersPacket>(0x79u, BattleStatCountersPacketCodec)
c2s<PcBoxStorePacket>(0x79u, PcBoxStorePacketCodec)
s2c<BattleStatCountersPacket>(0x79u, BattleStatCountersPacketCodec)
c2s<PcBoxRenamePacket>(0x7Au, PcBoxRenamePacketCodec)
s2c<LearnedMovesetPacket>(0x7Au, LearnedMovesetPacketCodec)
c2s<PcBoxRenamePacket>(0x7Au, PcBoxRenamePacketCodec)
s2c<LearnedMovesetPacket>(0x7Au, LearnedMovesetPacketCodec)
c2s<CoopScoreboardRequestPacket>(0x7Bu, CoopScoreboardRequestPacketCodec)
s2c<TournamentMatchupsPacket>(0x7Bu, TournamentMatchupsPacketCodec)
c2s<CoopScoreboardRequestPacket>(0x7Bu, CoopScoreboardRequestPacketCodec)
s2c<TournamentMatchupsPacket>(0x7Bu, TournamentMatchupsPacketCodec)
c2s<GtlListingSearchPacket>(0x7Cu, GtlListingSearchPacketCodec)
s2c<GtlItemMarketPacket>(0x7Cu, GtlItemMarketPacketCodec)
c2s<GtlListingSearchPacket>(0x7Cu, GtlListingSearchPacketCodec)
s2c<GtlItemMarketPacket>(0x7Cu, GtlItemMarketPacketCodec)
s2c<GameShopCatalogPacket>(0x7Du, GameShopCatalogPacketCodec)
s2c<GameShopCatalogPacket>(0x7Du, GameShopCatalogPacketCodec)
s2c<EggIncubatorSlotsPacket>(0x7Eu, EggIncubatorSlotsPacketCodec)
s2c<EggIncubatorSlotsPacket>(0x7Eu, EggIncubatorSlotsPacketCodec)
s2c<GtlPriceHistoryPacket>(0x7Fu, GtlPriceHistoryPacketCodec)
s2c<GtlPriceHistoryPacket>(0x7Fu, GtlPriceHistoryPacketCodec)
c2s<TeamFoundPacket>(0x80u, TeamFoundPacketCodec)
s2c<GuildMembershipPacket>(0x80u, GuildMembershipPacketCodec)
c2s<TeamFoundPacket>(0x80u, TeamFoundPacketCodec)
s2c<GuildMembershipPacket>(0x80u, GuildMembershipPacketCodec)
c2s<GuildMotdUpdatePacket>(0x81u, GuildMotdUpdatePacketCodec)
s2c<GuildProfileSyncPacket>(0x81u, GuildProfileSyncPacketCodec)
c2s<GuildMotdUpdatePacket>(0x81u, GuildMotdUpdatePacketCodec)
s2c<GuildProfileSyncPacket>(0x81u, GuildProfileSyncPacketCodec)
c2s<GuildDepartPacket>(0x82u, GuildDepartPacketCodec)
c2s<GuildDepartPacket>(0x82u, GuildDepartPacketCodec)
c2s<GuildChatSendPacket>(0x83u, GuildChatSendPacketCodec)
s2c<GuildRosterAddPacket>(0x83u, GuildRosterAddPacketCodec)
c2s<GuildChatSendPacket>(0x83u, GuildChatSendPacketCodec)
s2c<GuildRosterAddPacket>(0x83u, GuildRosterAddPacketCodec)
c2s<GuildMemberRankAssignPacket>(0x84u, GuildMemberRankAssignPacketCodec)
s2c<GuildMemberRankChangePacket>(0x84u, GuildMemberRankChangePacketCodec)
c2s<GuildMemberRankAssignPacket>(0x84u, GuildMemberRankAssignPacketCodec)
s2c<GuildMemberRankChangePacket>(0x84u, GuildMemberRankChangePacketCodec)
c2s<GuildMemberExpelPacket>(0x85u, GuildMemberExpelPacketCodec)
s2c<GuildRosterRemovePacket>(0x85u, GuildRosterRemovePacketCodec)
c2s<GuildMemberExpelPacket>(0x85u, GuildMemberExpelPacketCodec)
s2c<GuildRosterRemovePacket>(0x85u, GuildRosterRemovePacketCodec)
c2s<GuildRankPermissionUpdatePacket>(0x86u, GuildRankPermissionUpdatePacketCodec)
s2c<GuildMemberPresencePacket>(0x86u, GuildMemberPresencePacketCodec)
c2s<GuildRankPermissionUpdatePacket>(0x86u, GuildRankPermissionUpdatePacketCodec)
s2c<GuildMemberPresencePacket>(0x86u, GuildMemberPresencePacketCodec)
c2s<GuildDisbandToggleRequestPacket>(0x87u, GuildDisbandToggleRequestPacketCodec)
s2c<ContactCategoryGroupPacket>(0x87u, ContactCategoryGroupPacketCodec)
c2s<GuildDisbandToggleRequestPacket>(0x87u, GuildDisbandToggleRequestPacketCodec)
s2c<ContactCategoryGroupPacket>(0x87u, ContactCategoryGroupPacketCodec)
c2s<GuildRankLabelUpdatePacket>(0x88u, GuildRankLabelUpdatePacketCodec)
s2c<GuildRosterBulkPacket>(0x88u, GuildRosterBulkPacketCodec)
c2s<GuildRankLabelUpdatePacket>(0x88u, GuildRankLabelUpdatePacketCodec)
s2c<GuildRosterBulkPacket>(0x88u, GuildRosterBulkPacketCodec)
c2s<GuildActivityLogPageRequestPacket>(0x89u, GuildActivityLogPageRequestPacketCodec)
s2c<GuildActivityLogPacket>(0x89u, GuildActivityLogPacketCodec)
c2s<GuildActivityLogPageRequestPacket>(0x89u, GuildActivityLogPageRequestPacketCodec)
s2c<GuildActivityLogPacket>(0x89u, GuildActivityLogPacketCodec)
c2s<MailAttachmentRequestPacket>(0x8Au, MailAttachmentRequestPacketCodec)
c2s<MailAttachmentRequestPacket>(0x8Au, MailAttachmentRequestPacketCodec)
s2c<MonsterRecordBookPacket>(0x8Bu, MonsterRecordBookPacketCodec)
s2c<MonsterRecordBookPacket>(0x8Bu, MonsterRecordBookPacketCodec)
s2c<ChatChannelMessagesPacket>(0x8Cu, ChatChannelMessagesPacketCodec)
s2c<ChatChannelMessagesPacket>(0x8Cu, ChatChannelMessagesPacketCodec)
s2c<ChatChannelUserListPacket>(0x8Du, ChatChannelUserListPacketCodec)
s2c<ChatChannelUserListPacket>(0x8Du, ChatChannelUserListPacketCodec)
s2c<ChannelCountDeltaPacket>(0x8Eu, ChannelCountDeltaPacketCodec)
s2c<ChannelCountDeltaPacket>(0x8Eu, ChannelCountDeltaPacketCodec)
s2c<ChatMessageWithdrawPacket>(0x8Fu, ChatMessageWithdrawPacketCodec)
s2c<ChatMessageWithdrawPacket>(0x8Fu, ChatMessageWithdrawPacketCodec)
c2s<OverworldPathToTilePacket>(0x90u, OverworldPathToTilePacketCodec)
s2c<EntitySpriteChangePacket>(0x90u, EntitySpriteChangePacketCodec)
c2s<OverworldPathToTilePacket>(0x90u, OverworldPathToTilePacketCodec)
s2c<EntitySpriteChangePacket>(0x90u, EntitySpriteChangePacketCodec)
c2s<OverworldStepMovePacket>(0x91u, OverworldStepMovePacketCodec)
s2c<OpenAppearanceEditorPacket>(0x91u, OpenAppearanceEditorPacketCodec)
c2s<OverworldStepMovePacket>(0x91u, OverworldStepMovePacketCodec)
s2c<OpenAppearanceEditorPacket>(0x91u, OpenAppearanceEditorPacketCodec)
c2s<BattleTransitionReadyPacket>(0x92u, BattleTransitionReadyPacketCodec)
s2c<AppearanceRequestResultPacket>(0x92u, AppearanceRequestResultPacketCodec)
c2s<BattleTransitionReadyPacket>(0x92u, BattleTransitionReadyPacketCodec)
s2c<AppearanceRequestResultPacket>(0x92u, AppearanceRequestResultPacketCodec)
c2s<PendingRequestCancelPacket>(0x93u, PendingRequestCancelPacketCodec)
s2c<BattleStatStagePacket>(0x93u, BattleStatStagePacketCodec)
c2s<PendingRequestCancelPacket>(0x93u, PendingRequestCancelPacketCodec)
s2c<BattleStatStagePacket>(0x93u, BattleStatStagePacketCodec)
c2s<PartyInfoRequestPacket>(0x94u, PartyInfoRequestPacketCodec)
s2c<EntityAppearanceSyncPacket>(0x94u, EntityAppearanceSyncPacketCodec)
c2s<PartyInfoRequestPacket>(0x94u, PartyInfoRequestPacketCodec)
s2c<EntityAppearanceSyncPacket>(0x94u, EntityAppearanceSyncPacketCodec)
c2s<MailComposeSendPacket>(0x95u, MailComposeSendPacketCodec)
s2c<BattleSwitchPromptTogglePacket>(0x95u, BattleSwitchPromptTogglePacketCodec)
c2s<MailComposeSendPacket>(0x95u, MailComposeSendPacketCodec)
s2c<BattleSwitchPromptTogglePacket>(0x95u, BattleSwitchPromptTogglePacketCodec)
c2s<TeamPreviewRevealPickPacket>(0x96u, TeamPreviewRevealPickPacketCodec)
s2c<BattleEndDisconnectPacket>(0x96u, BattleEndDisconnectPacketCodec)
c2s<TeamPreviewRevealPickPacket>(0x96u, TeamPreviewRevealPickPacketCodec)
s2c<BattleEndDisconnectPacket>(0x96u, BattleEndDisconnectPacketCodec)
c2s<TeamPreviewSidePickPacket>(0x97u, TeamPreviewSidePickPacketCodec)
s2c<BattleTeamPreviewListPacket>(0x97u, BattleTeamPreviewListPacketCodec)
c2s<TeamPreviewSidePickPacket>(0x97u, TeamPreviewSidePickPacketCodec)
s2c<BattleTeamPreviewListPacket>(0x97u, BattleTeamPreviewListPacketCodec)
c2s<TeamPreviewLeadSubmitPacket>(0x98u, TeamPreviewLeadSubmitPacketCodec)
s2c<WorldVersionPacket>(0x98u, WorldVersionPacketCodec)
c2s<TeamPreviewLeadSubmitPacket>(0x98u, TeamPreviewLeadSubmitPacketCodec)
s2c<WorldVersionPacket>(0x98u, WorldVersionPacketCodec)
c2s<BattleTeamPreviewConfirmPacket>(0x99u, BattleTeamPreviewConfirmPacketCodec)
s2c<BattleSendOutActivePacket>(0x99u, BattleSendOutActivePacketCodec)
c2s<BattleTeamPreviewConfirmPacket>(0x99u, BattleTeamPreviewConfirmPacketCodec)
s2c<BattleSendOutActivePacket>(0x99u, BattleSendOutActivePacketCodec)
c2s<CreateMarketListingPacket>(0x9Au, CreateMarketListingPacketCodec)
s2c<BattleSlotAnimationResetPacket>(0x9Au, BattleSlotAnimationResetPacketCodec)
c2s<CreateMarketListingPacket>(0x9Au, CreateMarketListingPacketCodec)
s2c<BattleSlotAnimationResetPacket>(0x9Au, BattleSlotAnimationResetPacketCodec)
c2s<GtlSellPokemonListingPacket>(0x9Bu, GtlSellPokemonListingPacketCodec)
s2c<BattleActionOutcomePacket>(0x9Bu, BattleActionOutcomePacketCodec)
c2s<GtlSellPokemonListingPacket>(0x9Bu, GtlSellPokemonListingPacketCodec)
s2c<BattleActionOutcomePacket>(0x9Bu, BattleActionOutcomePacketCodec)
c2s<GtlConfirmPurchasePacket>(0x9Cu, GtlConfirmPurchasePacketCodec)
s2c<BattleDisconnectMessagePacket>(0x9Cu, BattleDisconnectMessagePacketCodec)
c2s<GtlConfirmPurchasePacket>(0x9Cu, GtlConfirmPurchasePacketCodec)
s2c<BattleDisconnectMessagePacket>(0x9Cu, BattleDisconnectMessagePacketCodec)
c2s<SelectSinglePokemonPacket>(0x9Du, SelectSinglePokemonPacketCodec)
s2c<BattleActionPromptTogglePacket>(0x9Du, BattleActionPromptTogglePacketCodec)
c2s<SelectSinglePokemonPacket>(0x9Du, SelectSinglePokemonPacketCodec)
s2c<BattleActionPromptTogglePacket>(0x9Du, BattleActionPromptTogglePacketCodec)
c2s<SelectPartyPokemonPacket>(0x9Eu, SelectPartyPokemonPacketCodec)
s2c<EntityEmoteBubblePacket>(0x9Eu, EntityEmoteBubblePacketCodec)
c2s<SelectPartyPokemonPacket>(0x9Eu, SelectPartyPokemonPacketCodec)
s2c<EntityEmoteBubblePacket>(0x9Eu, EntityEmoteBubblePacketCodec)
c2s<GtlTradeLogRequestPacket>(0x9Fu, GtlTradeLogRequestPacketCodec)
c2s<GtlTradeLogRequestPacket>(0x9Fu, GtlTradeLogRequestPacketCodec)
c2s<PlayerChatInputPacket>(0xA0u, PlayerChatInputPacketCodec)
s2c<FriendRosterPacket>(0xA0u, FriendRosterPacketCodec)
c2s<PlayerChatInputPacket>(0xA0u, PlayerChatInputPacketCodec)
s2c<FriendRosterPacket>(0xA0u, FriendRosterPacketCodec)
c2s<GtlListingCancelPacket>(0xA1u, GtlListingCancelPacketCodec)
s2c<GmPlayerLookupPacket>(0xA1u, GmPlayerLookupPacketCodec)
c2s<GtlListingCancelPacket>(0xA1u, GtlListingCancelPacketCodec)
s2c<GmPlayerLookupPacket>(0xA1u, GmPlayerLookupPacketCodec)
c2s<AdminNoteActionPacket>(0xA2u, AdminNoteActionPacketCodec)
s2c<GmPanelVariantPacket>(0xA2u, GmPanelVariantPacketCodec)
c2s<AdminNoteActionPacket>(0xA2u, AdminNoteActionPacketCodec)
s2c<GmPanelVariantPacket>(0xA2u, GmPanelVariantPacketCodec)
c2s<GtlPurchasePacket>(0xA3u, GtlPurchasePacketCodec)
s2c<EntityNameVisibilityPacket>(0xA3u, EntityNameVisibilityPacketCodec)
c2s<GtlPurchasePacket>(0xA3u, GtlPurchasePacketCodec)
s2c<EntityNameVisibilityPacket>(0xA3u, EntityNameVisibilityPacketCodec)
c2s<GtlListingActionPacket>(0xA4u, GtlListingActionPacketCodec)
s2c<HighScoreBoardPacket>(0xA4u, HighScoreBoardPacketCodec)
c2s<GtlListingActionPacket>(0xA4u, GtlListingActionPacketCodec)
s2c<HighScoreBoardPacket>(0xA4u, HighScoreBoardPacketCodec)
c2s<GtlOpenSessionPacket>(0xA5u, GtlOpenSessionPacketCodec)
s2c<WorldNoticeSlotPacket>(0xA5u, WorldNoticeSlotPacketCodec)
c2s<GtlOpenSessionPacket>(0xA5u, GtlOpenSessionPacketCodec)
s2c<WorldNoticeSlotPacket>(0xA5u, WorldNoticeSlotPacketCodec)
c2s<DataDigestSyncResponsePacket>(0xA6u, DataDigestSyncResponsePacketCodec)
s2c<DataDigestSyncPacket>(0xA6u, DataDigestSyncPacketCodec)
c2s<DataDigestSyncResponsePacket>(0xA6u, DataDigestSyncResponsePacketCodec)
s2c<DataDigestSyncPacket>(0xA6u, DataDigestSyncPacketCodec)
c2s<DataContentSyncBatchPacket>(0xA7u, DataContentSyncBatchPacketCodec)
s2c<DataDigestSyncBatchedPacket>(0xA7u, DataDigestSyncBatchedPacketCodec)
c2s<DataContentSyncBatchPacket>(0xA7u, DataContentSyncBatchPacketCodec)
s2c<DataDigestSyncBatchedPacket>(0xA7u, DataDigestSyncBatchedPacketCodec)
c2s<BatchInputEventsPacket>(0xA8u, BatchInputEventsPacketCodec)
s2c<SelectionListWindowOpenPacket>(0xA8u, SelectionListWindowOpenPacketCodec)
c2s<BatchInputEventsPacket>(0xA8u, BatchInputEventsPacketCodec)
s2c<SelectionListWindowOpenPacket>(0xA8u, SelectionListWindowOpenPacketCodec)
c2s<ModerationActionConfirmPacket>(0xA9u, ModerationActionConfirmPacketCodec)
s2c<EntityAttributeChangePacket>(0xA9u, EntityAttributeChangePacketCodec)
c2s<ModerationActionConfirmPacket>(0xA9u, ModerationActionConfirmPacketCodec)
s2c<EntityAttributeChangePacket>(0xA9u, EntityAttributeChangePacketCodec)
s2c<WorldFlagStateUpdatePacket>(0xAAu, WorldFlagStateUpdatePacketCodec)
s2c<WorldFlagStateUpdatePacket>(0xAAu, WorldFlagStateUpdatePacketCodec)
s2c<ChunkedTransferBeginPacket>(0xABu, ChunkedTransferBeginPacketCodec)
s2c<ChunkedTransferBeginPacket>(0xABu, ChunkedTransferBeginPacketCodec)
s2c<ChunkedTransferAppendPacket>(0xACu, ChunkedTransferAppendPacketCodec)
s2c<ChunkedTransferAppendPacket>(0xACu, ChunkedTransferAppendPacketCodec)
s2c<WorldTimedEventStatusPacket>(0xADu, WorldTimedEventStatusPacketCodec)
s2c<WorldTimedEventStatusPacket>(0xADu, WorldTimedEventStatusPacketCodec)
s2c<GroupMemberRosterPacket>(0xAEu, GroupMemberRosterPacketCodec)
s2c<GroupMemberRosterPacket>(0xAEu, GroupMemberRosterPacketCodec)
s2c<SceneEntityActionDispatchPacket>(0xB0u, SceneEntityActionDispatchPacketCodec)
s2c<SceneEntityActionDispatchPacket>(0xB0u, SceneEntityActionDispatchPacketCodec)
s2c<SocialProfileDialogOpenPacket>(0xB1u, SocialProfileDialogOpenPacketCodec)
s2c<SocialProfileDialogOpenPacket>(0xB1u, SocialProfileDialogOpenPacketCodec)
bidi<NpcAnimationPacket>(0xB2u, NpcAnimationPacketCodec)
bidi<NpcAnimationPacket>(0xB2u, NpcAnimationPacketCodec)
s2c<MapTileAttributeSetPacket>(0xB3u, MapTileAttributeSetPacketCodec)
s2c<MapTileAttributeSetPacket>(0xB3u, MapTileAttributeSetPacketCodec)
bidi<RenderScreenPacket>(0xB4u, RenderScreenPacketCodec)
bidi<RenderScreenPacket>(0xB4u, RenderScreenPacketCodec)
s2c<EntityAppearancePatchPacket>(0xB5u, EntityAppearancePatchPacketCodec)
s2c<EntityAppearancePatchPacket>(0xB5u, EntityAppearancePatchPacketCodec)
s2c<WorldActionDispatchPacket>(0xB6u, WorldActionDispatchPacketCodec)
s2c<WorldActionDispatchPacket>(0xB6u, WorldActionDispatchPacketCodec)
s2c<EntityDespawnPacket>(0xB7u, EntityDespawnPacketCodec)
s2c<EntityDespawnPacket>(0xB7u, EntityDespawnPacketCodec)
s2c<MapTileEntityStateSetPacket>(0xB8u, MapTileEntityStateSetPacketCodec)
s2c<MapTileEntityStateSetPacket>(0xB8u, MapTileEntityStateSetPacketCodec)
bidi<MapTransitionAckPacket>(0xB9u, MapTransitionAckPacketCodec)
bidi<MapTransitionAckPacket>(0xB9u, MapTransitionAckPacketCodec)
s2c<MapTileObjectSlotSetPacket>(0xBAu, MapTileObjectSlotSetPacketCodec)
s2c<MapTileObjectSlotSetPacket>(0xBAu, MapTileObjectSlotSetPacketCodec)
s2c<CameraFollowEntityPacket>(0xBBu, CameraFollowEntityPacketCodec)
s2c<CameraFollowEntityPacket>(0xBBu, CameraFollowEntityPacketCodec)
s2c<MapTileObjectRepositionPacket>(0xBCu, MapTileObjectRepositionPacketCodec)
s2c<MapTileObjectRepositionPacket>(0xBCu, MapTileObjectRepositionPacketCodec)
s2c<WorldEntityStateResetPacket>(0xBDu, WorldEntityStateResetPacketCodec)
s2c<WorldEntityStateResetPacket>(0xBDu, WorldEntityStateResetPacketCodec)
s2c<WorldOverlayObjectSetPacket>(0xBEu, WorldOverlayObjectSetPacketCodec)
s2c<WorldOverlayObjectSetPacket>(0xBEu, WorldOverlayObjectSetPacketCodec)
s2c<MapTileAnimationTogglePacket>(0xC0u, MapTileAnimationTogglePacketCodec)
s2c<MapTileAnimationTogglePacket>(0xC0u, MapTileAnimationTogglePacketCodec)
c2s<TournamentRegistrationPacket>(0xC1u, TournamentRegistrationPacketCodec)
s2c<MapWeatherModeSetPacket>(0xC1u, MapWeatherModeSetPacketCodec)
c2s<TournamentRegistrationPacket>(0xC1u, TournamentRegistrationPacketCodec)
s2c<MapWeatherModeSetPacket>(0xC1u, MapWeatherModeSetPacketCodec)
bidi<KeepAlivePacket>(0xC2u, KeepAlivePacketCodec)
bidi<KeepAlivePacket>(0xC2u, KeepAlivePacketCodec)
s2c<FieldMapTilePaletteApplyPacket>(0xC3u, FieldMapTilePaletteApplyPacketCodec)
s2c<FieldMapTilePaletteApplyPacket>(0xC3u, FieldMapTilePaletteApplyPacketCodec)
s2c<FieldMapBattleSlotTileMapPacket>(0xC4u, FieldMapBattleSlotTileMapPacketCodec)
s2c<FieldMapBattleSlotTileMapPacket>(0xC4u, FieldMapBattleSlotTileMapPacketCodec)
s2c<FieldMapBattleSlotMarkerPacket>(0xC5u, FieldMapBattleSlotMarkerPacketCodec)
s2c<FieldMapBattleSlotMarkerPacket>(0xC5u, FieldMapBattleSlotMarkerPacketCodec)
s2c<WorldObjectInstanceDespawnPacket>(0xC8u, WorldObjectInstanceDespawnPacketCodec)
s2c<WorldObjectInstanceDespawnPacket>(0xC8u, WorldObjectInstanceDespawnPacketCodec)
s2c<BattleStartScenePacket>(0xCAu, BattleStartScenePacketCodec)
s2c<BattleStartScenePacket>(0xCAu, BattleStartScenePacketCodec)
c2s<SendChatCommandPacket>(0xD0u, SendChatCommandPacketCodec)
s2c<EntityGroupSnapshotPacket>(0xD0u, EntityGroupSnapshotPacketCodec)
c2s<SendChatCommandPacket>(0xD0u, SendChatCommandPacketCodec)
s2c<EntityGroupSnapshotPacket>(0xD0u, EntityGroupSnapshotPacketCodec)
c2s<LinkKickMemberPacket>(0xD1u, LinkKickMemberPacketCodec)
s2c<EntityGroupMemberAddPacket>(0xD1u, EntityGroupMemberAddPacketCodec)
c2s<LinkKickMemberPacket>(0xD1u, LinkKickMemberPacketCodec)
s2c<EntityGroupMemberAddPacket>(0xD1u, EntityGroupMemberAddPacketCodec)
s2c<EntityGroupMemberRemovePacket>(0xD2u, EntityGroupMemberRemovePacketCodec)
s2c<EntityGroupMemberRemovePacket>(0xD2u, EntityGroupMemberRemovePacketCodec)
c2s<CancelSocialInteractionPacket>(0xD3u, CancelSocialInteractionPacketCodec)
s2c<ObjectiveProgressBulkPacket>(0xD3u, ObjectiveProgressBulkPacketCodec)
c2s<CancelSocialInteractionPacket>(0xD3u, CancelSocialInteractionPacketCodec)
s2c<ObjectiveProgressBulkPacket>(0xD3u, ObjectiveProgressBulkPacketCodec)
c2s<RequestSocialProfilePacket>(0xD4u, RequestSocialProfilePacketCodec)
s2c<ObjectiveProgressPacket>(0xD4u, ObjectiveProgressPacketCodec)
c2s<RequestSocialProfilePacket>(0xD4u, RequestSocialProfilePacketCodec)
s2c<ObjectiveProgressPacket>(0xD4u, ObjectiveProgressPacketCodec)
s2c<TrackedEntitySlotsPacket>(0xD5u, TrackedEntitySlotsPacketCodec)
s2c<TrackedEntitySlotsPacket>(0xD5u, TrackedEntitySlotsPacketCodec)
s2c<MenuPromptOpenPacket>(0xD6u, MenuPromptOpenPacketCodec)
s2c<MenuPromptOpenPacket>(0xD6u, MenuPromptOpenPacketCodec)
s2c<EntityChecklistPromptPacket>(0xD7u, EntityChecklistPromptPacketCodec)
s2c<EntityChecklistPromptPacket>(0xD7u, EntityChecklistPromptPacketCodec)
s2c<MenuPromptClosePacket>(0xD8u, MenuPromptClosePacketCodec)
s2c<MenuPromptClosePacket>(0xD8u, MenuPromptClosePacketCodec)
s2c<RequestConfirmationPromptPacket>(0xD9u, RequestConfirmationPromptPacketCodec)
s2c<RequestConfirmationPromptPacket>(0xD9u, RequestConfirmationPromptPacketCodec)
s2c<EntityPanelSelectPacket>(0xDAu, EntityPanelSelectPacketCodec)
s2c<EntityPanelSelectPacket>(0xDAu, EntityPanelSelectPacketCodec)
s2c<EntityFramesUpdatePacket>(0xDBu, EntityFramesUpdatePacketCodec)
s2c<EntityFramesUpdatePacket>(0xDBu, EntityFramesUpdatePacketCodec)
s2c<CategoryFlagsPacket>(0xDCu, CategoryFlagsPacketCodec)
s2c<CategoryFlagsPacket>(0xDCu, CategoryFlagsPacketCodec)
c2s<SaveTemplateEntryPacket>(0xE0u, SaveTemplateEntryPacketCodec)
c2s<SaveTemplateEntryPacket>(0xE0u, SaveTemplateEntryPacketCodec)
c2s<GtlCreateListingPacket>(0xE1u, GtlCreateListingPacketCodec)
c2s<GtlCreateListingPacket>(0xE1u, GtlCreateListingPacketCodec)
c2s<GtlSearchFilterPacket>(0xE2u, GtlSearchFilterPacketCodec)
c2s<GtlSearchFilterPacket>(0xE2u, GtlSearchFilterPacketCodec)
c2s<BattleRewardSelectPacket>(0xE3u, BattleRewardSelectPacketCodec)
c2s<BattleRewardSelectPacket>(0xE3u, BattleRewardSelectPacketCodec)
c2s<BattleChallengeRequestPacket>(0xE4u, BattleChallengeRequestPacketCodec)
c2s<BattleChallengeRequestPacket>(0xE4u, BattleChallengeRequestPacketCodec)
s2c<EntityMovePacket>(0xEAu, EntityMovePacketCodec)
s2c<EntityMovePacket>(0xEAu, EntityMovePacketCodec)
s2c<QueuePositionPacket>(0xF0u, QueuePositionPacketCodec)
s2c<QueuePositionPacket>(0xF0u, QueuePositionPacketCodec)
c2s<ChunkedTransferDataPacket>(0xF1u, ChunkedTransferDataPacketCodec)
s2c<ViewScalePacket>(0xF1u, ViewScalePacketCodec)
c2s<ChunkedTransferDataPacket>(0xF1u, ChunkedTransferDataPacketCodec)
s2c<ViewScalePacket>(0xF1u, ViewScalePacketCodec)
s2c<SessionExpiryInitPacket>(0xF2u, SessionExpiryInitPacketCodec)
s2c<SessionExpiryInitPacket>(0xF2u, SessionExpiryInitPacketCodec)
s2c<LocalPlayerStatePacket>(0xF3u, LocalPlayerStatePacketCodec)
s2c<LocalPlayerStatePacket>(0xF3u, LocalPlayerStatePacketCodec)
s2c<CurrencyBalancePacket>(0xF4u, CurrencyBalancePacketCodec)
s2c<CurrencyBalancePacket>(0xF4u, CurrencyBalancePacketCodec)
s2c<ServerMessagePacket>(0xF5u, ServerMessagePacketCodec)
s2c<ServerMessagePacket>(0xF5u, ServerMessagePacketCodec)
s2c<ChunkedImagePacket>(0xF6u, ChunkedImagePacketCodec)
s2c<ChunkedImagePacket>(0xF6u, ChunkedImagePacketCodec)
s2c<GmPanelEntryPacket>(0xF7u, GmPanelEntryPacketCodec)
s2c<GmPanelEntryPacket>(0xF7u, GmPanelEntryPacketCodec)
s2c<DisconnectNoticePacket>(0xF8u, DisconnectNoticePacketCodec)
s2c<DisconnectNoticePacket>(0xF8u, DisconnectNoticePacketCodec)
s2c<RosterCooldownPacket>(0xF9u, RosterCooldownPacketCodec)
s2c<RosterCooldownPacket>(0xF9u, RosterCooldownPacketCodec)
s2c<CancelEntityMessagePacket>(0xFAu, CancelEntityMessagePacketCodec)
s2c<CancelEntityMessagePacket>(0xFAu, CancelEntityMessagePacketCodec)
s2c<PlayerInputLockPacket>(0xFBu, PlayerInputLockPacketCodec)
s2c<PlayerInputLockPacket>(0xFBu, PlayerInputLockPacketCodec)
s2c<ServerEndpointListPacket>(0xFCu, ServerEndpointListPacketCodec)
s2c<ServerEndpointListPacket>(0xFCu, ServerEndpointListPacketCodec)
s2c<GtlListingsPagePacket>(0xFEu, GtlListingsPagePacketCodec)
s2c<GtlListingsPagePacket>(0xFEu, GtlListingsPagePacketCodec)
s2c<WorldSessionStatePacket>(0xFFu, WorldSessionStatePacketCodec)
}
s2c<WorldSessionStatePacket>(0xFFu, WorldSessionStatePacketCodec)
}
}
@@ -14,75 +14,75 @@ internal val EpochSecondsS32LE: Codec<LocalDateTime> =
private val TrailingBytes = bytesPrefixed(U16LE)
class CharacterInfoCodec(private val withExtraLong: Boolean) : PacketCodec<CharacterInfo>() {
override fun CodecScope<CharacterInfo>.body(): CharacterInfo {
val id = field(S64LE, CharacterInfo::id)
val name = field(Utf16LeNullTerminated, CharacterInfo::name)
val namePrefix = field(Utf16LeNullTerminated) { "" }
val userId = field(S32LE, CharacterInfo::userId)
val rivalSex = field(S8, CharacterInfo::rivalSex)
val lastLogin = field(EpochSecondsS32LE, CharacterInfo::lastLogin)
if (withExtraLong) field(S64LE) { 0L }
val createdAt = field(EpochSecondsS32LE, CharacterInfo::createdAt)
field(S32LE) { 0 }
field(S8) { 0 }
field(S32LE) { 0 }
val money = field(S32LE, CharacterInfo::money)
field(S16LE) { 0 }
field(S32LE) { 0 }
val permissions = field(U8) { it.permissions and 0xFF }
field(S8) { 0 }
field(S8) { 0 }
field(S32LE) { 0 }
repeat(8) { field(S8) { 0 } }
val remainingSafariSteps = field(S16LE, CharacterInfo::remainingSafariSteps)
val remainingSafariBalls = field(S8, CharacterInfo::remainingSafariBalls)
field(S32LE) { 0 }
val pcExtraSlots = field(S8, CharacterInfo::pcExtraSlots)
val battleBoxExtraSlots = field(S8, CharacterInfo::battleBoxExtraSlots)
val templateAmount = field(S8, CharacterInfo::templateAmount)
field(S8) { 0 }
field(S8) { 0 }
field(S8) { 0 }
val positionRegionId = field(S8, CharacterInfo::positionRegionId)
val positionBankId = field(S8, CharacterInfo::positionBankId)
val positionMapId = field(S8, CharacterInfo::positionMapId)
field(S8) { 0 }
val positionX = field(S16LE, CharacterInfo::positionX)
val positionY = field(S16LE, CharacterInfo::positionY)
field(S8) { 0 }
field(S8) { 0 }
val repelLeft = field(S16LE, CharacterInfo::repelLeft)
val repelItemId = field(S16LE, CharacterInfo::repelItemId)
field(S8) { 0 }
val lureItemId = field(S16LE, CharacterInfo::lureItemId)
val lureLeft = field(S16LE, CharacterInfo::lureLeft)
field(TrailingBytes) { ByteArray(0) }
return CharacterInfo(
id = id,
name = name,
namePrefix = namePrefix,
userId = userId,
rivalSex = rivalSex,
lastLogin = lastLogin,
createdAt = createdAt,
money = money,
permissions = permissions,
remainingSafariSteps = remainingSafariSteps,
remainingSafariBalls = remainingSafariBalls,
pcExtraSlots = pcExtraSlots,
battleBoxExtraSlots = battleBoxExtraSlots,
templateAmount = templateAmount,
positionRegionId = positionRegionId,
positionBankId = positionBankId,
positionMapId = positionMapId,
positionX = positionX,
positionY = positionY,
repelLeft = repelLeft,
repelItemId = repelItemId,
lureLeft = lureLeft,
lureItemId = lureItemId,
)
}
override fun CodecScope<CharacterInfo>.body(): CharacterInfo {
val id = field(S64LE, CharacterInfo::id)
val name = field(Utf16LeNullTerminated, CharacterInfo::name)
val namePrefix = field(Utf16LeNullTerminated) { "" }
val userId = field(S32LE, CharacterInfo::userId)
val rivalSex = field(S8, CharacterInfo::rivalSex)
val lastLogin = field(EpochSecondsS32LE, CharacterInfo::lastLogin)
if (withExtraLong) field(S64LE) { 0L }
val createdAt = field(EpochSecondsS32LE, CharacterInfo::createdAt)
field(S32LE) { 0 }
field(S8) { 0 }
field(S32LE) { 0 }
val money = field(S32LE, CharacterInfo::money)
field(S16LE) { 0 }
field(S32LE) { 0 }
val permissions = field(U8) { it.permissions and 0xFF }
field(S8) { 0 }
field(S8) { 0 }
field(S32LE) { 0 }
repeat(8) { field(S8) { 0 } }
val remainingSafariSteps = field(S16LE, CharacterInfo::remainingSafariSteps)
val remainingSafariBalls = field(S8, CharacterInfo::remainingSafariBalls)
field(S32LE) { 0 }
val pcExtraSlots = field(S8, CharacterInfo::pcExtraSlots)
val battleBoxExtraSlots = field(S8, CharacterInfo::battleBoxExtraSlots)
val templateAmount = field(S8, CharacterInfo::templateAmount)
field(S8) { 0 }
field(S8) { 0 }
field(S8) { 0 }
val positionRegionId = field(S8, CharacterInfo::positionRegionId)
val positionBankId = field(S8, CharacterInfo::positionBankId)
val positionMapId = field(S8, CharacterInfo::positionMapId)
field(S8) { 0 }
val positionX = field(S16LE, CharacterInfo::positionX)
val positionY = field(S16LE, CharacterInfo::positionY)
field(S8) { 0 }
field(S8) { 0 }
val repelLeft = field(S16LE, CharacterInfo::repelLeft)
val repelItemId = field(S16LE, CharacterInfo::repelItemId)
field(S8) { 0 }
val lureItemId = field(S16LE, CharacterInfo::lureItemId)
val lureLeft = field(S16LE, CharacterInfo::lureLeft)
field(TrailingBytes) { ByteArray(0) }
return CharacterInfo(
id = id,
name = name,
namePrefix = namePrefix,
userId = userId,
rivalSex = rivalSex,
lastLogin = lastLogin,
createdAt = createdAt,
money = money,
permissions = permissions,
remainingSafariSteps = remainingSafariSteps,
remainingSafariBalls = remainingSafariBalls,
pcExtraSlots = pcExtraSlots,
battleBoxExtraSlots = battleBoxExtraSlots,
templateAmount = templateAmount,
positionRegionId = positionRegionId,
positionBankId = positionBankId,
positionMapId = positionMapId,
positionX = positionX,
positionY = positionY,
repelLeft = repelLeft,
repelItemId = repelItemId,
lureLeft = lureLeft,
lureItemId = lureItemId,
)
}
}
val CharacterInfoCodecShort: Codec<CharacterInfo> = CharacterInfoCodec(withExtraLong = false)
@@ -8,87 +8,87 @@ import de.fiereu.openmmo.common.enums.*
private val PokemonUnknownBytes: Codec<ByteArray> = bytesPrefixed(U8)
object PokemonCodec : PacketCodec<Pokemon>() {
override fun CodecScope<Pokemon>.body(): Pokemon {
val id = field(S64LE, Pokemon::id)
field(S8) { 0 }
field(S64LE) { 0L }
field(S64LE) { 0L }
val container = PokemonContainer.entries[field(U8) { it.container.ordinal }]
val containerSlot = field(S16LE, Pokemon::containerSlot)
val dexId = field(U16LE, Pokemon::dexId)
val seed = field(S32LE, Pokemon::seed)
field(S64LE) { 0L }
val ot = field(Utf16LeNullTerminated, Pokemon::ot)
val nickname = field(Utf16LeNullTerminated, Pokemon::nickname)
field(S8) { 0 }
field(S8) { 0 }
val level = field(S8, Pokemon::level)
val currentHp = field(S16LE, Pokemon::hp)
field(S16LE) { 0 }
val xp = field(S32LE, Pokemon::xp)
field(S8) { 0 }
field(S16LE) { 0 }
val moveIds = List(4) { i -> field(S16LE) { it.moves[i].id } }
val movePps = List(4) { i -> field(S8) { it.moves[i].pp } }
val moves = List(4) { PokemonMove(moveIds[it], movePps[it]) }
repeat(4) { field(S16LE) { 0 } }
val eVs =
EVs().apply {
hp = field(U8) { it.eVs.hp }
atk = field(U8) { it.eVs.atk }
def = field(U8) { it.eVs.def }
spd = field(U8) { it.eVs.spd }
spAtk = field(U8) { it.eVs.spAtk }
spDef = field(U8) { it.eVs.spDef }
}
repeat(11) { field(S8) { 0 } }
val iVs = decompressIVs(field(S32LE) { it.iVs.compress() })
field(S8) { 0 }
field(S64LE) { 0L }
val rarityMask =
field(U16LE) {
var m = 0
if (it.isShiny) m = m or (1 shl PokemonRarity.SHINY.ordinal)
if (it.hasHiddenAbility) m = m or (1 shl PokemonRarity.HIDDEN_ABILITY.ordinal)
if (it.isAlpha) m = m or (1 shl PokemonRarity.ALPHA.ordinal)
if (it.isSecret) m = m or (1 shl PokemonRarity.SECRET.ordinal)
if (it.isFatefulEncounter) m = m or (1 shl PokemonRarity.FATEFUL_ENCOUNTER.ordinal)
if (it.isRaidEncounter) m = m or (1 shl PokemonRarity.RAID_ENCOUNTER.ordinal)
m
}
val isShiny = (rarityMask and (1 shl PokemonRarity.SHINY.ordinal)) != 0
val hasHiddenAbility = (rarityMask and (1 shl PokemonRarity.HIDDEN_ABILITY.ordinal)) != 0
val isAlpha = (rarityMask and (1 shl PokemonRarity.ALPHA.ordinal)) != 0
val isSecret = (rarityMask and (1 shl PokemonRarity.SECRET.ordinal)) != 0
val isFatefulEncounter = (rarityMask and (1 shl PokemonRarity.FATEFUL_ENCOUNTER.ordinal)) != 0
val isRaidEncounter = (rarityMask and (1 shl PokemonRarity.RAID_ENCOUNTER.ordinal)) != 0
val caughtAt = field(EpochSecondsS32LE, Pokemon::caughtAt)
field(S16LE) { 0 }
field(S8) { 0 }
field(S8) { 0 }
field(PokemonUnknownBytes) { ByteArray(0) }
repeat(12) { field(S8) { 0 } }
return Pokemon(
id,
container,
containerSlot,
dexId,
seed,
ot,
nickname,
level,
currentHp,
xp,
eVs,
iVs,
moves,
isShiny,
hasHiddenAbility,
isAlpha,
isSecret,
isFatefulEncounter,
isRaidEncounter,
caughtAt,
)
}
override fun CodecScope<Pokemon>.body(): Pokemon {
val id = field(S64LE, Pokemon::id)
field(S8) { 0 }
field(S64LE) { 0L }
field(S64LE) { 0L }
val container = PokemonContainer.entries[field(U8) { it.container.ordinal }]
val containerSlot = field(S16LE, Pokemon::containerSlot)
val dexId = field(U16LE, Pokemon::dexId)
val seed = field(S32LE, Pokemon::seed)
field(S64LE) { 0L }
val ot = field(Utf16LeNullTerminated, Pokemon::ot)
val nickname = field(Utf16LeNullTerminated, Pokemon::nickname)
field(S8) { 0 }
field(S8) { 0 }
val level = field(S8, Pokemon::level)
val currentHp = field(S16LE, Pokemon::hp)
field(S16LE) { 0 }
val xp = field(S32LE, Pokemon::xp)
field(S8) { 0 }
field(S16LE) { 0 }
val moveIds = List(4) { i -> field(S16LE) { it.moves[i].id } }
val movePps = List(4) { i -> field(S8) { it.moves[i].pp } }
val moves = List(4) { PokemonMove(moveIds[it], movePps[it]) }
repeat(4) { field(S16LE) { 0 } }
val eVs =
EVs().apply {
hp = field(U8) { it.eVs.hp }
atk = field(U8) { it.eVs.atk }
def = field(U8) { it.eVs.def }
spd = field(U8) { it.eVs.spd }
spAtk = field(U8) { it.eVs.spAtk }
spDef = field(U8) { it.eVs.spDef }
}
repeat(11) { field(S8) { 0 } }
val iVs = decompressIVs(field(S32LE) { it.iVs.compress() })
field(S8) { 0 }
field(S64LE) { 0L }
val rarityMask =
field(U16LE) {
var m = 0
if (it.isShiny) m = m or (1 shl PokemonRarity.SHINY.ordinal)
if (it.hasHiddenAbility) m = m or (1 shl PokemonRarity.HIDDEN_ABILITY.ordinal)
if (it.isAlpha) m = m or (1 shl PokemonRarity.ALPHA.ordinal)
if (it.isSecret) m = m or (1 shl PokemonRarity.SECRET.ordinal)
if (it.isFatefulEncounter) m = m or (1 shl PokemonRarity.FATEFUL_ENCOUNTER.ordinal)
if (it.isRaidEncounter) m = m or (1 shl PokemonRarity.RAID_ENCOUNTER.ordinal)
m
}
val isShiny = (rarityMask and (1 shl PokemonRarity.SHINY.ordinal)) != 0
val hasHiddenAbility = (rarityMask and (1 shl PokemonRarity.HIDDEN_ABILITY.ordinal)) != 0
val isAlpha = (rarityMask and (1 shl PokemonRarity.ALPHA.ordinal)) != 0
val isSecret = (rarityMask and (1 shl PokemonRarity.SECRET.ordinal)) != 0
val isFatefulEncounter = (rarityMask and (1 shl PokemonRarity.FATEFUL_ENCOUNTER.ordinal)) != 0
val isRaidEncounter = (rarityMask and (1 shl PokemonRarity.RAID_ENCOUNTER.ordinal)) != 0
val caughtAt = field(EpochSecondsS32LE, Pokemon::caughtAt)
field(S16LE) { 0 }
field(S8) { 0 }
field(S8) { 0 }
field(PokemonUnknownBytes) { ByteArray(0) }
repeat(12) { field(S8) { 0 } }
return Pokemon(
id,
container,
containerSlot,
dexId,
seed,
ot,
nickname,
level,
currentHp,
xp,
eVs,
iVs,
moves,
isShiny,
hasHiddenAbility,
isAlpha,
isSecret,
isFatefulEncounter,
isRaidEncounter,
caughtAt,
)
}
}
@@ -7,43 +7,43 @@ import java.util.*
data class Skin(val slot: SkinSlot, val type: UShort?, val color: UByte?)
class SkinSet : EnumMap<SkinSlot, Skin>(SkinSlot::class.java) {
fun put(skin: Skin) {
this[skin.slot] = skin
}
fun put(skin: Skin) {
this[skin.slot] = skin
}
override fun put(key: SkinSlot, value: Skin): Skin? {
require(key == value.slot) { "Slot mismatch: $key != ${value.slot}" }
return super.put(key, value)
}
override fun put(key: SkinSlot, value: Skin): Skin? {
require(key == value.slot) { "Slot mismatch: $key != ${value.slot}" }
return super.put(key, value)
}
}
class SkinSetCodec(
private val slots: List<SkinSlot> = SkinSlot.entries,
private val withLeadingByte: Boolean = true,
) : PacketCodec<SkinSet>() {
override fun CodecScope<SkinSet>.body(): SkinSet {
if (withLeadingByte) field(U8) { 0 }
val mask = field(U16LE) { slots.fold(0) { acc, slot -> acc or (1 shl slot.ordinal) } }
val skins = SkinSet()
slots.forEach { slot ->
if ((mask and (1 shl slot.ordinal)) != 0) {
val compressed =
field(U16LE) {
val skin = it[slot] ?: Skin(slot, 0u, 0u)
val type = skin.type ?: 0x3FFFu
val color = skin.color ?: 0x3Fu
require(type <= 0x3FFFu) { "Skin type too large: ${skin.type}" }
require(color <= 0x3Fu) { "Skin color too large: ${skin.color}" }
(type and 0x3FFFu).toInt() or ((color and 0x3Fu).toInt() shl 10)
}
val type = (compressed and 0x3FFF).toUShort()
val color = ((compressed shr 10) and 0x3F).toUByte()
skins.put(Skin(slot, type, color))
override fun CodecScope<SkinSet>.body(): SkinSet {
if (withLeadingByte) field(U8) { 0 }
val mask = field(U16LE) { slots.fold(0) { acc, slot -> acc or (1 shl slot.ordinal) } }
val skins = SkinSet()
slots.forEach { slot ->
if ((mask and (1 shl slot.ordinal)) != 0) {
val compressed =
field(U16LE) {
val skin = it[slot] ?: Skin(slot, 0u, 0u)
val type = skin.type ?: 0x3FFFu
val color = skin.color ?: 0x3Fu
require(type <= 0x3FFFu) { "Skin type too large: ${skin.type}" }
require(color <= 0x3Fu) { "Skin color too large: ${skin.color}" }
(type and 0x3FFFu).toInt() or ((color and 0x3Fu).toInt() shl 10)
}
}
return skins
val type = (compressed and 0x3FFF).toUShort()
val color = ((compressed shr 10) and 0x3F).toUByte()
skins.put(Skin(slot, type, color))
}
}
return skins
}
}
val DefaultSkinSetCodec: Codec<SkinSet> = SkinSetCodec()
val SkinSetCodecNoLeading: Codec<SkinSet> = SkinSetCodec(withLeadingByte = false)
val SkinSetCodecNoLeading: Codec<SkinSet> = SkinSetCodec(withLeadingByte = false)
@@ -8,12 +8,12 @@ import de.fiereu.openmmo.common.Tile2D
val Tile2DCodec: Codec<Tile2D> =
U16LE.imap(
decode = { raw ->
Tile2D(
material = (raw and 0x3FF).toShort(),
collision = ((raw shr 10) and 0x3F).toByte(),
)
Tile2D(
material = (raw and 0x3FF).toShort(),
collision = ((raw shr 10) and 0x3F).toByte(),
)
},
encode = { tile ->
((tile.collision.toInt() and 0x3F) shl 10) or (tile.material.toInt() and 0x3FF)
((tile.collision.toInt() and 0x3F) shl 10) or (tile.material.toInt() and 0x3FF)
},
)
@@ -9,8 +9,8 @@ data class ActiveBattleSidePacket(
)
object ActiveBattleSidePacketCodec : PacketCodec<ActiveBattleSidePacket>() {
override fun CodecScope<ActiveBattleSidePacket>.body(): ActiveBattleSidePacket {
val side = field(S8) { it.side }
return ActiveBattleSidePacket(side)
}
override fun CodecScope<ActiveBattleSidePacket>.body(): ActiveBattleSidePacket {
val side = field(S8) { it.side }
return ActiveBattleSidePacket(side)
}
}
@@ -60,155 +60,155 @@ data class ActivePokemonSummaryPacket(
)
private object SummaryRankingEntryCodec : PacketCodec<SummaryRankingEntry>() {
override fun CodecScope<SummaryRankingEntry>.body(): SummaryRankingEntry {
val entityId = field(S64LE, SummaryRankingEntry::entityId)
val rank = field(S8, SummaryRankingEntry::rank)
val flags = field(S8, SummaryRankingEntry::flags)
val name = field(Utf16LeNullTerminated, SummaryRankingEntry::name)
val value1 = field(S16LE, SummaryRankingEntry::value1)
val species = field(S16LE, SummaryRankingEntry::species)
reserved(byte = 0)
val ribbons = field(S64LE, SummaryRankingEntry::ribbons)
val value2 = field(S8, SummaryRankingEntry::value2)
val value3 = field(S32LE, SummaryRankingEntry::value3)
val value4 = field(S8, SummaryRankingEntry::value4)
val flag1 = field(Bool, SummaryRankingEntry::flag1)
val flag2 = field(Bool, SummaryRankingEntry::flag2)
reserved(byte = 0)
return SummaryRankingEntry(
entityId,
rank,
flags,
name,
value1,
species,
ribbons,
value2,
value3,
value4,
flag1,
flag2,
)
}
override fun CodecScope<SummaryRankingEntry>.body(): SummaryRankingEntry {
val entityId = field(S64LE, SummaryRankingEntry::entityId)
val rank = field(S8, SummaryRankingEntry::rank)
val flags = field(S8, SummaryRankingEntry::flags)
val name = field(Utf16LeNullTerminated, SummaryRankingEntry::name)
val value1 = field(S16LE, SummaryRankingEntry::value1)
val species = field(S16LE, SummaryRankingEntry::species)
reserved(byte = 0)
val ribbons = field(S64LE, SummaryRankingEntry::ribbons)
val value2 = field(S8, SummaryRankingEntry::value2)
val value3 = field(S32LE, SummaryRankingEntry::value3)
val value4 = field(S8, SummaryRankingEntry::value4)
val flag1 = field(Bool, SummaryRankingEntry::flag1)
val flag2 = field(Bool, SummaryRankingEntry::flag2)
reserved(byte = 0)
return SummaryRankingEntry(
entityId,
rank,
flags,
name,
value1,
species,
ribbons,
value2,
value3,
value4,
flag1,
flag2,
)
}
}
private object SummaryAppearanceCodec : PacketCodec<SummaryAppearance>() {
override fun CodecScope<SummaryAppearance>.body(): SummaryAppearance {
val name = field(Utf16LeNullTerminated, SummaryAppearance::name)
val gender = field(S8, SummaryAppearance::gender)
val formId = field(S32LE, SummaryAppearance::formId)
val kind = field(S8, SummaryAppearance::kind)
val palettePack = field(S8, SummaryAppearance::palettePack)
val slots = field(S16LE.repeat(4), SummaryAppearance::slots)
return SummaryAppearance(name, gender, formId, kind, palettePack, slots)
}
override fun CodecScope<SummaryAppearance>.body(): SummaryAppearance {
val name = field(Utf16LeNullTerminated, SummaryAppearance::name)
val gender = field(S8, SummaryAppearance::gender)
val formId = field(S32LE, SummaryAppearance::formId)
val kind = field(S8, SummaryAppearance::kind)
val palettePack = field(S8, SummaryAppearance::palettePack)
val slots = field(S16LE.repeat(4), SummaryAppearance::slots)
return SummaryAppearance(name, gender, formId, kind, palettePack, slots)
}
}
private object SummaryAbilityCodec : PacketCodec<SummaryAbility>() {
override fun CodecScope<SummaryAbility>.body(): SummaryAbility {
val slot = field(S8, SummaryAbility::slot)
val sourceId = field(S64LE, SummaryAbility::sourceId)
val appearance = field(SummaryAppearanceCodec, SummaryAbility::appearance)
return SummaryAbility(slot, sourceId, appearance)
}
override fun CodecScope<SummaryAbility>.body(): SummaryAbility {
val slot = field(S8, SummaryAbility::slot)
val sourceId = field(S64LE, SummaryAbility::sourceId)
val appearance = field(SummaryAppearanceCodec, SummaryAbility::appearance)
return SummaryAbility(slot, sourceId, appearance)
}
}
private object SummaryMoveCodec : PacketCodec<SummaryMove>() {
override fun CodecScope<SummaryMove>.body(): SummaryMove {
val moveId = field(S8, SummaryMove::moveId)
val slot = field(S8, SummaryMove::slot)
val locked = field(Bool, SummaryMove::locked)
if (!locked) {
val intA = field(S32LE, SummaryMove::intA)
val intB = field(S32LE, SummaryMove::intB)
val intC = field(S32LE, SummaryMove::intC)
val shortA = field(S16LE, SummaryMove::shortA)
val shortB = field(S16LE, SummaryMove::shortB)
val byteA = field(S8, SummaryMove::byteA)
return SummaryMove(
moveId,
slot,
locked,
intA,
intB,
intC,
shortA,
shortB,
byteA,
0,
false,
false,
0,
false,
false,
0,
0,
0,
)
}
val unlockedShort = field(S16LE, SummaryMove::unlockedShort)
val boolA = field(Bool, SummaryMove::boolA)
val boolB = field(Bool, SummaryMove::boolB)
val unlockedByteA = field(S8, SummaryMove::unlockedByteA)
val boolC = field(Bool, SummaryMove::boolC)
val boolD = field(Bool, SummaryMove::boolD)
val unlockedByteB = field(S8, SummaryMove::unlockedByteB)
val unlockedByteC = field(S8, SummaryMove::unlockedByteC)
val unlockedByteD = field(S8, SummaryMove::unlockedByteD)
return SummaryMove(
moveId,
slot,
locked,
0,
0,
0,
0,
0,
0,
unlockedShort,
boolA,
boolB,
unlockedByteA,
boolC,
boolD,
unlockedByteB,
unlockedByteC,
unlockedByteD,
)
override fun CodecScope<SummaryMove>.body(): SummaryMove {
val moveId = field(S8, SummaryMove::moveId)
val slot = field(S8, SummaryMove::slot)
val locked = field(Bool, SummaryMove::locked)
if (!locked) {
val intA = field(S32LE, SummaryMove::intA)
val intB = field(S32LE, SummaryMove::intB)
val intC = field(S32LE, SummaryMove::intC)
val shortA = field(S16LE, SummaryMove::shortA)
val shortB = field(S16LE, SummaryMove::shortB)
val byteA = field(S8, SummaryMove::byteA)
return SummaryMove(
moveId,
slot,
locked,
intA,
intB,
intC,
shortA,
shortB,
byteA,
0,
false,
false,
0,
false,
false,
0,
0,
0,
)
}
val unlockedShort = field(S16LE, SummaryMove::unlockedShort)
val boolA = field(Bool, SummaryMove::boolA)
val boolB = field(Bool, SummaryMove::boolB)
val unlockedByteA = field(S8, SummaryMove::unlockedByteA)
val boolC = field(Bool, SummaryMove::boolC)
val boolD = field(Bool, SummaryMove::boolD)
val unlockedByteB = field(S8, SummaryMove::unlockedByteB)
val unlockedByteC = field(S8, SummaryMove::unlockedByteC)
val unlockedByteD = field(S8, SummaryMove::unlockedByteD)
return SummaryMove(
moveId,
slot,
locked,
0,
0,
0,
0,
0,
0,
unlockedShort,
boolA,
boolB,
unlockedByteA,
boolC,
boolD,
unlockedByteB,
unlockedByteC,
unlockedByteD,
)
}
}
private val SummaryAbilityListPrefixedU8: Codec<List<SummaryAbility>> =
object : Codec<List<SummaryAbility>> {
override fun read(buf: ReadBuffer): List<SummaryAbility> {
val n = U8.read(buf)
return List(n) { SummaryAbilityCodec.read(buf) }
}
override fun read(buf: ReadBuffer): List<SummaryAbility> {
val n = U8.read(buf)
return List(n) { SummaryAbilityCodec.read(buf) }
}
override fun write(buf: WriteBuffer, value: List<SummaryAbility>) {
U8.write(buf, value.size)
value.forEach { SummaryAbilityCodec.write(buf, it) }
}
override fun write(buf: WriteBuffer, value: List<SummaryAbility>) {
U8.write(buf, value.size)
value.forEach { SummaryAbilityCodec.write(buf, it) }
}
}
private val SummaryMoveListPrefixedU8: Codec<List<SummaryMove>> =
object : Codec<List<SummaryMove>> {
override fun read(buf: ReadBuffer): List<SummaryMove> {
val n = U8.read(buf)
return List(n) { SummaryMoveCodec.read(buf) }
}
override fun read(buf: ReadBuffer): List<SummaryMove> {
val n = U8.read(buf)
return List(n) { SummaryMoveCodec.read(buf) }
}
override fun write(buf: WriteBuffer, value: List<SummaryMove>) {
U8.write(buf, value.size)
value.forEach { SummaryMoveCodec.write(buf, it) }
}
override fun write(buf: WriteBuffer, value: List<SummaryMove>) {
U8.write(buf, value.size)
value.forEach { SummaryMoveCodec.write(buf, it) }
}
}
object ActivePokemonSummaryPacketCodec : PacketCodec<ActivePokemonSummaryPacket>() {
override fun CodecScope<ActivePokemonSummaryPacket>.body(): ActivePokemonSummaryPacket {
val pokemon = field(SummaryRankingEntryCodec, ActivePokemonSummaryPacket::pokemon)
val abilities = field(SummaryAbilityListPrefixedU8, ActivePokemonSummaryPacket::abilities)
val moves = field(SummaryMoveListPrefixedU8, ActivePokemonSummaryPacket::moves)
return ActivePokemonSummaryPacket(pokemon, abilities, moves)
}
override fun CodecScope<ActivePokemonSummaryPacket>.body(): ActivePokemonSummaryPacket {
val pokemon = field(SummaryRankingEntryCodec, ActivePokemonSummaryPacket::pokemon)
val abilities = field(SummaryAbilityListPrefixedU8, ActivePokemonSummaryPacket::abilities)
val moves = field(SummaryMoveListPrefixedU8, ActivePokemonSummaryPacket::moves)
return ActivePokemonSummaryPacket(pokemon, abilities, moves)
}
}
@@ -0,0 +1,14 @@
package de.fiereu.openmmo.net.game.packets
import de.fiereu.bytecodec.CodecScope
import de.fiereu.bytecodec.PacketCodec
import de.fiereu.bytecodec.Utf16LeNullTerminated
data class AddFriendPacket(val username: String)
object AddFriendPacketCodec : PacketCodec<AddFriendPacket>() {
override fun CodecScope<AddFriendPacket>.body(): AddFriendPacket {
val username = field(Utf16LeNullTerminated) { it.username }
return AddFriendPacket(username)
}
}
@@ -10,34 +10,34 @@ data class AdminNoteActionPacket(
)
object AdminNoteActionPacketCodec : PacketCodec<AdminNoteActionPacket>() {
override fun CodecScope<AdminNoteActionPacket>.body(): AdminNoteActionPacket {
val actionType = field(S8) { it.actionType }
return when (actionType.toInt()) {
1 -> {
val targetEntityId =
field(S64LE) {
it.targetEntityId ?: throw MalformedPacketException("targetEntityId required")
}
val noteText =
field(Utf16LeNullTerminated) {
it.noteText ?: throw MalformedPacketException("noteText required")
}
AdminNoteActionPacket(actionType, targetEntityId, null, noteText)
override fun CodecScope<AdminNoteActionPacket>.body(): AdminNoteActionPacket {
val actionType = field(S8) { it.actionType }
return when (actionType.toInt()) {
1 -> {
val targetEntityId =
field(S64LE) {
it.targetEntityId ?: throw MalformedPacketException("targetEntityId required")
}
2 -> {
val targetEntityId =
field(S64LE) {
it.targetEntityId ?: throw MalformedPacketException("targetEntityId required")
}
val noteEntityId =
field(S64LE) {
it.noteEntityId ?: throw MalformedPacketException("noteEntityId required")
}
AdminNoteActionPacket(actionType, targetEntityId, noteEntityId, null)
val noteText =
field(Utf16LeNullTerminated) {
it.noteText ?: throw MalformedPacketException("noteText required")
}
AdminNoteActionPacket(actionType, targetEntityId, null, noteText)
}
else -> AdminNoteActionPacket(actionType, null, null, null)
}
2 -> {
val targetEntityId =
field(S64LE) {
it.targetEntityId ?: throw MalformedPacketException("targetEntityId required")
}
val noteEntityId =
field(S64LE) {
it.noteEntityId ?: throw MalformedPacketException("noteEntityId required")
}
AdminNoteActionPacket(actionType, targetEntityId, noteEntityId, null)
}
else -> AdminNoteActionPacket(actionType, null, null, null)
}
}
}
@@ -11,9 +11,9 @@ data class AppearanceRequestResultPacket(
)
object AppearanceRequestResultPacketCodec : PacketCodec<AppearanceRequestResultPacket>() {
override fun CodecScope<AppearanceRequestResultPacket>.body(): AppearanceRequestResultPacket {
val entityId = field(S64LE) { it.entityId }
val accepted = field(Bool) { it.accepted }
return AppearanceRequestResultPacket(entityId, accepted)
}
override fun CodecScope<AppearanceRequestResultPacket>.body(): AppearanceRequestResultPacket {
val entityId = field(S64LE) { it.entityId }
val accepted = field(Bool) { it.accepted }
return AppearanceRequestResultPacket(entityId, accepted)
}
}
@@ -12,10 +12,10 @@ data class AssignBreedingSlotPacket(
)
object AssignBreedingSlotPacketCodec : PacketCodec<AssignBreedingSlotPacket>() {
override fun CodecScope<AssignBreedingSlotPacket>.body(): AssignBreedingSlotPacket {
val ownPokemonEntityId = field(S64LE) { it.ownPokemonEntityId }
val partnerPokemonEntityId = field(S64LE) { it.partnerPokemonEntityId }
val slotIndex = field(S8) { it.slotIndex }
return AssignBreedingSlotPacket(ownPokemonEntityId, partnerPokemonEntityId, slotIndex)
}
override fun CodecScope<AssignBreedingSlotPacket>.body(): AssignBreedingSlotPacket {
val ownPokemonEntityId = field(S64LE) { it.ownPokemonEntityId }
val partnerPokemonEntityId = field(S64LE) { it.partnerPokemonEntityId }
val slotIndex = field(S8) { it.slotIndex }
return AssignBreedingSlotPacket(ownPokemonEntityId, partnerPokemonEntityId, slotIndex)
}
}
@@ -20,132 +20,130 @@ data class BatchInputEventsPacket(
private val EventsCodec: Codec<List<InputEventSample>> =
object : Codec<List<InputEventSample>> {
override fun read(buf: ReadBuffer): List<InputEventSample> {
val count = S16LE.read(buf).toInt()
if (count == 0) return emptyList()
var previous = S64LE.read(buf)
val result = ArrayList<InputEventSample>(count)
for (i in 0 until count) {
val type = S8.read(buf)
val delta = S16LE.read(buf).toInt()
val timestamp = if (delta == -1) S64LE.read(buf) else previous + delta
var byteA: Byte = 0
var byteB: Byte = 0
var intA = 0
var shortA: Short = 0
var shortB: Short = 0
var intB = 0
when (type.toInt()) {
0,
1 -> {
byteA = S8.read(buf)
byteB = S8.read(buf)
intA = S32LE.read(buf)
intB = S32LE.read(buf)
}
2,
3 -> {
byteA = S8.read(buf)
byteB = S8.read(buf)
shortA = S16LE.read(buf)
shortB = S16LE.read(buf)
intA = S32LE.read(buf)
intB = S32LE.read(buf)
}
4,
14 -> {
byteB = S8.read(buf)
shortA = S16LE.read(buf)
shortB = S16LE.read(buf)
intA = S32LE.read(buf)
intB = S32LE.read(buf)
}
5,
6,
7,
8 -> {
byteB = S8.read(buf)
}
9 -> {
shortA = S16LE.read(buf)
shortB = S16LE.read(buf)
}
}
result.add(
InputEventSample(type, timestamp, byteA, byteB, intA, shortA, shortB, intB)
)
previous = timestamp
override fun read(buf: ReadBuffer): List<InputEventSample> {
val count = S16LE.read(buf).toInt()
if (count == 0) return emptyList()
var previous = S64LE.read(buf)
val result = ArrayList<InputEventSample>(count)
for (i in 0 until count) {
val type = S8.read(buf)
val delta = S16LE.read(buf).toInt()
val timestamp = if (delta == -1) S64LE.read(buf) else previous + delta
var byteA: Byte = 0
var byteB: Byte = 0
var intA = 0
var shortA: Short = 0
var shortB: Short = 0
var intB = 0
when (type.toInt()) {
0,
1 -> {
byteA = S8.read(buf)
byteB = S8.read(buf)
intA = S32LE.read(buf)
intB = S32LE.read(buf)
}
return result
}
override fun write(buf: WriteBuffer, value: List<InputEventSample>) {
S16LE.write(buf, value.size.toShort())
if (value.isEmpty()) return
var previous = value[0].timestamp
S64LE.write(buf, previous)
for (event in value) {
S8.write(buf, event.type)
val delta = event.timestamp - previous
if (delta > 32767L) {
S16LE.write(buf, (-1).toShort())
S64LE.write(buf, event.timestamp)
} else {
S16LE.write(buf, delta.toShort())
}
when (event.type.toInt()) {
0,
1 -> {
S8.write(buf, event.byteA)
S8.write(buf, event.byteB)
S32LE.write(buf, event.intA)
S32LE.write(buf, event.intB)
}
2,
3 -> {
S8.write(buf, event.byteA)
S8.write(buf, event.byteB)
S16LE.write(buf, event.shortA)
S16LE.write(buf, event.shortB)
S32LE.write(buf, event.intA)
S32LE.write(buf, event.intB)
}
4,
14 -> {
S8.write(buf, event.byteB)
S16LE.write(buf, event.shortA)
S16LE.write(buf, event.shortB)
S32LE.write(buf, event.intA)
S32LE.write(buf, event.intB)
}
5,
6,
7,
8 -> {
S8.write(buf, event.byteB)
}
9 -> {
S16LE.write(buf, event.shortA)
S16LE.write(buf, event.shortB)
}
}
previous = event.timestamp
2,
3 -> {
byteA = S8.read(buf)
byteB = S8.read(buf)
shortA = S16LE.read(buf)
shortB = S16LE.read(buf)
intA = S32LE.read(buf)
intB = S32LE.read(buf)
}
4,
14 -> {
byteB = S8.read(buf)
shortA = S16LE.read(buf)
shortB = S16LE.read(buf)
intA = S32LE.read(buf)
intB = S32LE.read(buf)
}
5,
6,
7,
8 -> {
byteB = S8.read(buf)
}
9 -> {
shortA = S16LE.read(buf)
shortB = S16LE.read(buf)
}
}
result.add(InputEventSample(type, timestamp, byteA, byteB, intA, shortA, shortB, intB))
previous = timestamp
}
return result
}
override fun write(buf: WriteBuffer, value: List<InputEventSample>) {
S16LE.write(buf, value.size.toShort())
if (value.isEmpty()) return
var previous = value[0].timestamp
S64LE.write(buf, previous)
for (event in value) {
S8.write(buf, event.type)
val delta = event.timestamp - previous
if (delta > 32767L) {
S16LE.write(buf, (-1).toShort())
S64LE.write(buf, event.timestamp)
} else {
S16LE.write(buf, delta.toShort())
}
when (event.type.toInt()) {
0,
1 -> {
S8.write(buf, event.byteA)
S8.write(buf, event.byteB)
S32LE.write(buf, event.intA)
S32LE.write(buf, event.intB)
}
2,
3 -> {
S8.write(buf, event.byteA)
S8.write(buf, event.byteB)
S16LE.write(buf, event.shortA)
S16LE.write(buf, event.shortB)
S32LE.write(buf, event.intA)
S32LE.write(buf, event.intB)
}
4,
14 -> {
S8.write(buf, event.byteB)
S16LE.write(buf, event.shortA)
S16LE.write(buf, event.shortB)
S32LE.write(buf, event.intA)
S32LE.write(buf, event.intB)
}
5,
6,
7,
8 -> {
S8.write(buf, event.byteB)
}
9 -> {
S16LE.write(buf, event.shortA)
S16LE.write(buf, event.shortB)
}
}
previous = event.timestamp
}
}
}
object BatchInputEventsPacketCodec : PacketCodec<BatchInputEventsPacket>() {
override fun CodecScope<BatchInputEventsPacket>.body(): BatchInputEventsPacket {
val hasEvents = field(Bool) { it.hasEvents }
val events = field(EventsCodec) { it.events }
return BatchInputEventsPacket(hasEvents, events)
}
override fun CodecScope<BatchInputEventsPacket>.body(): BatchInputEventsPacket {
val hasEvents = field(Bool) { it.hasEvents }
val events = field(EventsCodec) { it.events }
return BatchInputEventsPacket(hasEvents, events)
}
}
@@ -29,56 +29,68 @@ data class BattleActionParticipant(
private val BattleRewardEntryCodec: Codec<BattleActionRewardEntry> =
object : PacketCodec<BattleActionRewardEntry>() {
override fun CodecScope<BattleActionRewardEntry>.body(): BattleActionRewardEntry {
val itemId = field(S32LE) { it.itemId }
val quantity = field(S16LE) { it.quantity }
return BattleActionRewardEntry(itemId, quantity)
}
override fun CodecScope<BattleActionRewardEntry>.body(): BattleActionRewardEntry {
val itemId = field(S32LE) { it.itemId }
val quantity = field(S16LE) { it.quantity }
return BattleActionRewardEntry(itemId, quantity)
}
}
private class BattleParticipantCodec(private val isCapture: Boolean) :
PacketCodec<BattleActionParticipant>() {
override fun CodecScope<BattleActionParticipant>.body(): BattleActionParticipant {
val entityId = field(S64LE) { it.entityId }
val kind = field(U8) { it.kind }
val intA = field(S32LE) { it.intA }
val intB = field(S32LE) { it.intB }
val intC = field(S32LE) { it.intC }
val shortA = field(S16LE) { it.shortA }
var critByte: Byte? = null
var critShort: Short? = null
if (isCapture) {
critByte = field(S8) { it.critByte!! }
critShort = field(S16LE) { it.critShort!! }
}
var capturedShort: Short? = null
var capturedByte: Byte? = null
if (isCapture || kind == 1) {
capturedShort = field(S16LE) { it.capturedShort!! }
capturedByte = field(S8) { it.capturedByte!! }
}
var xpShort: Short? = null
var xpByteA: Byte? = null
var xpByteB: Byte? = null
if (isCapture && kind == 0) {
xpShort = field(S16LE) { it.xpShort!! }
xpByteA = field(S8) { it.xpByteA!! }
xpByteB = field(S8) { it.xpByteB!! }
}
var pokemon: Pokemon? = null
var statStages: List<Short>? = null
if (kind == 0) {
val present = field(U8) { if (it.pokemon != null) 1 else 0 }
if (present == 1) {
pokemon = field(PokemonCodec) { it.pokemon!! }
statStages = (0 until 6).map { i -> field(S16LE) { it.statStages!![i] } }
}
}
return BattleActionParticipant(
entityId, kind, intA, intB, intC, shortA, critByte, critShort, capturedShort, capturedByte,
xpShort, xpByteA, xpByteB, pokemon, statStages
)
override fun CodecScope<BattleActionParticipant>.body(): BattleActionParticipant {
val entityId = field(S64LE) { it.entityId }
val kind = field(U8) { it.kind }
val intA = field(S32LE) { it.intA }
val intB = field(S32LE) { it.intB }
val intC = field(S32LE) { it.intC }
val shortA = field(S16LE) { it.shortA }
var critByte: Byte? = null
var critShort: Short? = null
if (isCapture) {
critByte = field(S8) { it.critByte!! }
critShort = field(S16LE) { it.critShort!! }
}
var capturedShort: Short? = null
var capturedByte: Byte? = null
if (isCapture || kind == 1) {
capturedShort = field(S16LE) { it.capturedShort!! }
capturedByte = field(S8) { it.capturedByte!! }
}
var xpShort: Short? = null
var xpByteA: Byte? = null
var xpByteB: Byte? = null
if (isCapture && kind == 0) {
xpShort = field(S16LE) { it.xpShort!! }
xpByteA = field(S8) { it.xpByteA!! }
xpByteB = field(S8) { it.xpByteB!! }
}
var pokemon: Pokemon? = null
var statStages: List<Short>? = null
if (kind == 0) {
val present = field(U8) { if (it.pokemon != null) 1 else 0 }
if (present == 1) {
pokemon = field(PokemonCodec) { it.pokemon!! }
statStages = (0 until 6).map { i -> field(S16LE) { it.statStages!![i] } }
}
}
return BattleActionParticipant(
entityId,
kind,
intA,
intB,
intC,
shortA,
critByte,
critShort,
capturedShort,
capturedByte,
xpShort,
xpByteA,
xpByteB,
pokemon,
statStages)
}
}
data class BattleActionOutcomePacket(
@@ -91,20 +103,20 @@ data class BattleActionOutcomePacket(
)
object BattleActionOutcomePacketCodec : PacketCodec<BattleActionOutcomePacket>() {
override fun CodecScope<BattleActionOutcomePacket>.body(): BattleActionOutcomePacket {
val side = field(S8) { it.side }
val category = field(U8) { it.category }
val value = field(S16LE) { it.value }
val extra = field(S32LE) { it.extra }
val isCapture = category == 2
val participantCodec = BattleParticipantCodec(isCapture)
val count = field(U8) { it.participants.size }
val participants = (0 until count).map { i -> field(participantCodec) { it.participants[i] } }
val rewards =
if (category == 1) {
val rewardCount = field(U8) { it.rewards!!.size }
(0 until rewardCount).map { i -> field(BattleRewardEntryCodec) { it.rewards!![i] } }
} else null
return BattleActionOutcomePacket(side, category, value, extra, participants, rewards)
}
override fun CodecScope<BattleActionOutcomePacket>.body(): BattleActionOutcomePacket {
val side = field(S8) { it.side }
val category = field(U8) { it.category }
val value = field(S16LE) { it.value }
val extra = field(S32LE) { it.extra }
val isCapture = category == 2
val participantCodec = BattleParticipantCodec(isCapture)
val count = field(U8) { it.participants.size }
val participants = (0 until count).map { i -> field(participantCodec) { it.participants[i] } }
val rewards =
if (category == 1) {
val rewardCount = field(U8) { it.rewards!!.size }
(0 until rewardCount).map { i -> field(BattleRewardEntryCodec) { it.rewards!![i] } }
} else null
return BattleActionOutcomePacket(side, category, value, extra, participants, rewards)
}
}
@@ -11,12 +11,12 @@ data class BattleActionPacket(
)
object BattleActionPacketCodec : PacketCodec<BattleActionPacket>() {
override fun CodecScope<BattleActionPacket>.body(): BattleActionPacket {
val actionTypeId = field(S8) { it.actionTypeId }
val isSlotTarget = field(Bool) { it.isSlotTarget }
val targetSlot: Short? = if (isSlotTarget) field(S16LE) { it.targetSlot!! } else null
val targetEntityId: Long? = if (!isSlotTarget) field(S64LE) { it.targetEntityId!! } else null
val extraFlag = field(S8) { it.extraFlag }
return BattleActionPacket(actionTypeId, isSlotTarget, targetSlot, targetEntityId, extraFlag)
}
override fun CodecScope<BattleActionPacket>.body(): BattleActionPacket {
val actionTypeId = field(S8) { it.actionTypeId }
val isSlotTarget = field(Bool) { it.isSlotTarget }
val targetSlot: Short? = if (isSlotTarget) field(S16LE) { it.targetSlot!! } else null
val targetEntityId: Long? = if (!isSlotTarget) field(S64LE) { it.targetEntityId!! } else null
val extraFlag = field(S8) { it.extraFlag }
return BattleActionPacket(actionTypeId, isSlotTarget, targetSlot, targetEntityId, extraFlag)
}
}
@@ -9,8 +9,8 @@ data class BattleActionPromptTogglePacket(
)
object BattleActionPromptTogglePacketCodec : PacketCodec<BattleActionPromptTogglePacket>() {
override fun CodecScope<BattleActionPromptTogglePacket>.body(): BattleActionPromptTogglePacket {
val shown = field(Bool) { it.shown }
return BattleActionPromptTogglePacket(shown)
}
override fun CodecScope<BattleActionPromptTogglePacket>.body(): BattleActionPromptTogglePacket {
val shown = field(Bool) { it.shown }
return BattleActionPromptTogglePacket(shown)
}
}
@@ -12,20 +12,20 @@ data class BattleActionResultPacket(
)
object BattleActionResultPacketCodec : PacketCodec<BattleActionResultPacket>() {
private const val MESSAGE_TYPE_WITH_MOVE: Int = 0
private const val MESSAGE_TYPE_WITH_MOVE: Int = 0
override fun CodecScope<BattleActionResultPacket>.body(): BattleActionResultPacket {
val targetCount = field(S8) { it.targetCount }
val targets = ArrayList<Byte>()
var entityId = 0L
if (targetCount < 0) {
entityId = field(S64LE) { it.entityId }
} else {
repeat(targetCount.toInt()) { i -> targets.add(field(S8) { p -> p.targets[i] }) }
}
val value = field(S32LE) { it.value }
val messageType = field(S8) { it.messageType }
val move = if (messageType.toInt() == MESSAGE_TYPE_WITH_MOVE) field(S8) { it.move!! } else null
return BattleActionResultPacket(targetCount, targets, entityId, value, messageType, move)
override fun CodecScope<BattleActionResultPacket>.body(): BattleActionResultPacket {
val targetCount = field(S8) { it.targetCount }
val targets = ArrayList<Byte>()
var entityId = 0L
if (targetCount < 0) {
entityId = field(S64LE) { it.entityId }
} else {
repeat(targetCount.toInt()) { i -> targets.add(field(S8) { p -> p.targets[i] }) }
}
val value = field(S32LE) { it.value }
val messageType = field(S8) { it.messageType }
val move = if (messageType.toInt() == MESSAGE_TYPE_WITH_MOVE) field(S8) { it.move!! } else null
return BattleActionResultPacket(targetCount, targets, entityId, value, messageType, move)
}
}
@@ -13,36 +13,37 @@ data class BattleActionSelectPacket(
private val BattleActionSelectBody: Codec<BattleActionSelectPacket> =
object : Codec<BattleActionSelectPacket> {
override fun read(buf: ReadBuffer): BattleActionSelectPacket {
val slotRefPacked = S8.read(buf)
val actionKindId = S8.read(buf)
return BattleActionSelectPacket(slotRefPacked, actionKindId, 0, 0, 0, 0)
}
override fun read(buf: ReadBuffer): BattleActionSelectPacket {
val slotRefPacked = S8.read(buf)
val actionKindId = S8.read(buf)
return BattleActionSelectPacket(slotRefPacked, actionKindId, 0, 0, 0, 0)
}
override fun write(buf: WriteBuffer, value: BattleActionSelectPacket) {
S8.write(buf, value.slotRefPacked)
S8.write(buf, value.actionKindId)
when (value.payloadVariant) {
1 -> {
S16LE.write(buf, value.moveOrItemId)
S8.write(buf, value.extraFlag)
}
override fun write(buf: WriteBuffer, value: BattleActionSelectPacket) {
S8.write(buf, value.slotRefPacked)
S8.write(buf, value.actionKindId)
when (value.payloadVariant) {
1 -> {
S16LE.write(buf, value.moveOrItemId)
S8.write(buf, value.extraFlag)
}
2, 3 -> {
S16LE.write(buf, value.moveOrItemId)
}
2,
3 -> {
S16LE.write(buf, value.moveOrItemId)
}
4 -> {
S16LE.write(buf, value.moveOrItemId)
S64LE.write(buf, value.targetEntityId)
S8.write(buf, value.extraFlag)
}
}
4 -> {
S16LE.write(buf, value.moveOrItemId)
S64LE.write(buf, value.targetEntityId)
S8.write(buf, value.extraFlag)
}
}
}
}
object BattleActionSelectPacketCodec : PacketCodec<BattleActionSelectPacket>() {
override fun CodecScope<BattleActionSelectPacket>.body(): BattleActionSelectPacket {
return field(BattleActionSelectBody) { it }
}
override fun CodecScope<BattleActionSelectPacket>.body(): BattleActionSelectPacket {
return field(BattleActionSelectBody) { it }
}
}
@@ -12,54 +12,54 @@ data class MultiTierAction(val selections: List<TierSlotSelection>) : BattleActi
private val BattleActionCodec: Codec<BattleAction> =
object : Codec<BattleAction> {
override fun read(buf: ReadBuffer): BattleAction {
val first = buf.readByte().toInt() and 0xFF
return if (first == 0) {
var id = 0L
for (i in 0 until 8) {
id = id or ((buf.readByte().toLong() and 0xFF) shl (i * 8))
}
val moveSlot = buf.readByte()
SinglePokemonAction(id, moveSlot)
} else {
val selections = ArrayList<TierSlotSelection>(first)
repeat(first) {
val tierIndex = buf.readByte()
val slot = buf.readByte()
selections.add(TierSlotSelection(tierIndex, slot))
}
MultiTierAction(selections)
}
override fun read(buf: ReadBuffer): BattleAction {
val first = buf.readByte().toInt() and 0xFF
return if (first == 0) {
var id = 0L
for (i in 0 until 8) {
id = id or ((buf.readByte().toLong() and 0xFF) shl (i * 8))
}
val moveSlot = buf.readByte()
SinglePokemonAction(id, moveSlot)
} else {
val selections = ArrayList<TierSlotSelection>(first)
repeat(first) {
val tierIndex = buf.readByte()
val slot = buf.readByte()
selections.add(TierSlotSelection(tierIndex, slot))
}
MultiTierAction(selections)
}
}
override fun write(buf: WriteBuffer, value: BattleAction) {
when (value) {
is SinglePokemonAction -> {
buf.writeByte(0.toByte())
var v = value.pokemonEntityId
for (i in 0 until 8) {
buf.writeByte((v and 0xFF).toByte())
v = v ushr 8
}
buf.writeByte(value.moveSlot)
}
is MultiTierAction -> {
buf.writeByte(value.selections.size.toByte())
for (s in value.selections) {
buf.writeByte(s.tierIndex)
buf.writeByte(s.slot)
}
}
override fun write(buf: WriteBuffer, value: BattleAction) {
when (value) {
is SinglePokemonAction -> {
buf.writeByte(0.toByte())
var v = value.pokemonEntityId
for (i in 0 until 8) {
buf.writeByte((v and 0xFF).toByte())
v = v ushr 8
}
buf.writeByte(value.moveSlot)
}
is MultiTierAction -> {
buf.writeByte(value.selections.size.toByte())
for (s in value.selections) {
buf.writeByte(s.tierIndex)
buf.writeByte(s.slot)
}
}
}
}
}
data class BattleActionSubmitPacket(val action: BattleAction)
object BattleActionSubmitPacketCodec : PacketCodec<BattleActionSubmitPacket>() {
override fun CodecScope<BattleActionSubmitPacket>.body(): BattleActionSubmitPacket {
val action = field(BattleActionCodec) { it.action }
return BattleActionSubmitPacket(action)
}
override fun CodecScope<BattleActionSubmitPacket>.body(): BattleActionSubmitPacket {
val action = field(BattleActionCodec) { it.action }
return BattleActionSubmitPacket(action)
}
}
@@ -12,13 +12,13 @@ data class BattleBoardCellPacket(
)
object BattleBoardCellPacketCodec : PacketCodec<BattleBoardCellPacket>() {
override fun CodecScope<BattleBoardCellPacket>.body(): BattleBoardCellPacket {
val row = field(S8) { it.row }
val column = field(S16LE) { it.column }
val entityId = field(S64LE) { it.entityId }
val valueA = field(S16LE) { it.valueA }
val valueB = field(S16LE) { it.valueB }
val flags = field(S8) { it.flags }
return BattleBoardCellPacket(row, column, entityId, valueA, valueB, flags)
}
override fun CodecScope<BattleBoardCellPacket>.body(): BattleBoardCellPacket {
val row = field(S8) { it.row }
val column = field(S16LE) { it.column }
val entityId = field(S64LE) { it.entityId }
val valueA = field(S16LE) { it.valueA }
val valueB = field(S16LE) { it.valueB }
val flags = field(S8) { it.flags }
return BattleBoardCellPacket(row, column, entityId, valueA, valueB, flags)
}
}
@@ -24,51 +24,51 @@ internal data class BattleMessageArg(
internal val BattleMessageArgCodec: Codec<BattleMessageArg> =
object : Codec<BattleMessageArg> {
override fun read(buf: ReadBuffer): BattleMessageArg {
val id = S8.read(buf)
var type = S8.read(buf)
var hasExtra = false
var extra: Byte = 0
if (type.toInt() and 0x80 != 0) {
type = (type.toInt() and 0x7F).toByte()
hasExtra = true
extra = S8.read(buf)
}
val t = type.toInt()
val payload: BattleMessageArgPayload =
when {
t == 5 -> StringArgPayload(Utf16LeNullTerminated.read(buf))
t == 28 -> EmptyArgPayload
t == 30 -> LongArgPayload(S64LE.read(buf))
t == 9 || t == 10 || t == 17 -> IntArgPayload(S32LE.read(buf))
t == 18 -> StringArgPayload(Utf16LeNullTerminated.read(buf))
else -> {
val n = U8.read(buf)
ShortListArgPayload((0 until n).map { S16LE.read(buf) })
}
}
return BattleMessageArg(id, type, hasExtra, extra, payload)
override fun read(buf: ReadBuffer): BattleMessageArg {
val id = S8.read(buf)
var type = S8.read(buf)
var hasExtra = false
var extra: Byte = 0
if (type.toInt() and 0x80 != 0) {
type = (type.toInt() and 0x7F).toByte()
hasExtra = true
extra = S8.read(buf)
}
override fun write(buf: WriteBuffer, value: BattleMessageArg) {
S8.write(buf, value.id)
val rawType = if (value.hasExtra) (value.type.toInt() or 0x80).toByte() else value.type
S8.write(buf, rawType)
if (value.hasExtra) S8.write(buf, value.extra)
val t = value.type.toInt()
val t = type.toInt()
val payload: BattleMessageArgPayload =
when {
t == 5 -> Utf16LeNullTerminated.write(buf, (value.payload as StringArgPayload).value)
t == 28 -> {}
t == 30 -> S64LE.write(buf, (value.payload as LongArgPayload).value)
t == 9 || t == 10 || t == 17 -> S32LE.write(buf, (value.payload as IntArgPayload).value)
t == 18 -> Utf16LeNullTerminated.write(buf, (value.payload as StringArgPayload).value)
else -> {
val values = (value.payload as ShortListArgPayload).values
U8.write(buf, values.size)
for (s in values) S16LE.write(buf, s)
}
t == 5 -> StringArgPayload(Utf16LeNullTerminated.read(buf))
t == 28 -> EmptyArgPayload
t == 30 -> LongArgPayload(S64LE.read(buf))
t == 9 || t == 10 || t == 17 -> IntArgPayload(S32LE.read(buf))
t == 18 -> StringArgPayload(Utf16LeNullTerminated.read(buf))
else -> {
val n = U8.read(buf)
ShortListArgPayload((0 until n).map { S16LE.read(buf) })
}
}
return BattleMessageArg(id, type, hasExtra, extra, payload)
}
override fun write(buf: WriteBuffer, value: BattleMessageArg) {
S8.write(buf, value.id)
val rawType = if (value.hasExtra) (value.type.toInt() or 0x80).toByte() else value.type
S8.write(buf, rawType)
if (value.hasExtra) S8.write(buf, value.extra)
val t = value.type.toInt()
when {
t == 5 -> Utf16LeNullTerminated.write(buf, (value.payload as StringArgPayload).value)
t == 28 -> {}
t == 30 -> S64LE.write(buf, (value.payload as LongArgPayload).value)
t == 9 || t == 10 || t == 17 -> S32LE.write(buf, (value.payload as IntArgPayload).value)
t == 18 -> Utf16LeNullTerminated.write(buf, (value.payload as StringArgPayload).value)
else -> {
val values = (value.payload as ShortListArgPayload).values
U8.write(buf, values.size)
for (s in values) S16LE.write(buf, s)
}
}
}
}
sealed class BattleSerializedEntry
@@ -91,75 +91,76 @@ internal object EmptyCreatureDataEntry : BattleSerializedEntry()
internal val BattleSerializedEntryCodec: Codec<BattleSerializedEntry> =
object : Codec<BattleSerializedEntry> {
override fun read(buf: ReadBuffer): BattleSerializedEntry {
return when (val tag = S8.read(buf).toInt()) {
-1 -> NullSerializedEntry
0 -> {
val value = S32LE.read(buf)
val n = U8.read(buf)
CreatureDataEntry(value, (0 until n).map { BattleMessageArgCodec.read(buf) })
}
override fun read(buf: ReadBuffer): BattleSerializedEntry {
return when (val tag = S8.read(buf).toInt()) {
-1 -> NullSerializedEntry
0 -> {
val value = S32LE.read(buf)
val n = U8.read(buf)
CreatureDataEntry(value, (0 until n).map { BattleMessageArgCodec.read(buf) })
}
1 -> {
val v = S8.read(buf)
val n = U8.read(buf)
CreatureMovesEntry(v, (0 until n).map { S16LE.read(buf) })
}
1 -> {
val v = S8.read(buf)
val n = U8.read(buf)
CreatureMovesEntry(v, (0 until n).map { S16LE.read(buf) })
}
2 -> {
val moveId = S16LE.read(buf)
val a = S8.read(buf)
val b = S8.read(buf)
MoveAnimationEntry(a, b, moveId)
}
2 -> {
val moveId = S16LE.read(buf)
val a = S8.read(buf)
val b = S8.read(buf)
MoveAnimationEntry(a, b, moveId)
}
3 -> {
val a = S8.read(buf)
val typeId = S8.read(buf)
val x = S16LE.read(buf)
val y = S16LE.read(buf)
TextCreatureEntry(a, typeId, x, y)
}
3 -> {
val a = S8.read(buf)
val typeId = S8.read(buf)
val x = S16LE.read(buf)
val y = S16LE.read(buf)
TextCreatureEntry(a, typeId, x, y)
}
else -> EmptyCreatureDataEntry
}
else -> EmptyCreatureDataEntry
}
}
override fun write(buf: WriteBuffer, value: BattleSerializedEntry) {
when (value) {
is NullSerializedEntry -> S8.write(buf, (-1).toByte())
is CreatureDataEntry -> {
S8.write(buf, 0)
S32LE.write(buf, value.value)
U8.write(buf, value.args.size)
for (a in value.args) BattleMessageArgCodec.write(buf, a)
}
override fun write(buf: WriteBuffer, value: BattleSerializedEntry) {
when (value) {
is NullSerializedEntry -> S8.write(buf, (-1).toByte())
is CreatureDataEntry -> {
S8.write(buf, 0)
S32LE.write(buf, value.value)
U8.write(buf, value.args.size)
for (a in value.args) BattleMessageArgCodec.write(buf, a)
}
is CreatureMovesEntry -> {
S8.write(buf, 1)
S8.write(buf, value.value)
U8.write(buf, value.moves.size)
for (m in value.moves) S16LE.write(buf, m)
}
is CreatureMovesEntry -> {
S8.write(buf, 1)
S8.write(buf, value.value)
U8.write(buf, value.moves.size)
for (m in value.moves) S16LE.write(buf, m)
}
is MoveAnimationEntry -> {
S8.write(buf, 2)
S16LE.write(buf, value.moveId)
S8.write(buf, value.a)
S8.write(buf, value.b)
}
is MoveAnimationEntry -> {
S8.write(buf, 2)
S16LE.write(buf, value.moveId)
S8.write(buf, value.a)
S8.write(buf, value.b)
}
is TextCreatureEntry -> {
S8.write(buf, 3)
S8.write(buf, value.a)
S8.write(buf, value.typeId)
S16LE.write(buf, value.x)
S16LE.write(buf, value.y)
}
is TextCreatureEntry -> {
S8.write(buf, 3)
S8.write(buf, value.a)
S8.write(buf, value.typeId)
S16LE.write(buf, value.x)
S16LE.write(buf, value.y)
}
is EmptyCreatureDataEntry -> throw MalformedPacketException("cannot encode default battle entry")
}
is EmptyCreatureDataEntry ->
throw MalformedPacketException("cannot encode default battle entry")
}
}
}
data class BattleBulkStatePacket(
@@ -173,14 +174,14 @@ data class BattleBulkStatePacket(
)
object BattleBulkStatePacketCodec : PacketCodec<BattleBulkStatePacket>() {
override fun CodecScope<BattleBulkStatePacket>.body(): BattleBulkStatePacket {
val phase = field(S8) { it.phase }
val firstGroup = field(BattleSerializedEntryCodec.listPrefixed(U8)) { it.firstGroup }
val secondGroup = field(BattleSerializedEntryCodec.listPrefixed(U8)) { it.secondGroup }
val valueA = field(S32LE) { it.valueA }
val valueB = field(S32LE) { it.valueB }
val flag = field(S8) { it.flag }
val thirdGroup = field(BattleSerializedEntryCodec.listPrefixed(U8)) { it.thirdGroup }
return BattleBulkStatePacket(phase, firstGroup, secondGroup, valueA, valueB, flag, thirdGroup)
}
override fun CodecScope<BattleBulkStatePacket>.body(): BattleBulkStatePacket {
val phase = field(S8) { it.phase }
val firstGroup = field(BattleSerializedEntryCodec.listPrefixed(U8)) { it.firstGroup }
val secondGroup = field(BattleSerializedEntryCodec.listPrefixed(U8)) { it.secondGroup }
val valueA = field(S32LE) { it.valueA }
val valueB = field(S32LE) { it.valueB }
val flag = field(S8) { it.flag }
val thirdGroup = field(BattleSerializedEntryCodec.listPrefixed(U8)) { it.thirdGroup }
return BattleBulkStatePacket(phase, firstGroup, secondGroup, valueA, valueB, flag, thirdGroup)
}
}
@@ -6,7 +6,7 @@ import de.fiereu.bytecodec.PacketCodec
class BattleCancelRequestPacket
object BattleCancelRequestPacketCodec : PacketCodec<BattleCancelRequestPacket>() {
override fun CodecScope<BattleCancelRequestPacket>.body(): BattleCancelRequestPacket {
return BattleCancelRequestPacket()
}
override fun CodecScope<BattleCancelRequestPacket>.body(): BattleCancelRequestPacket {
return BattleCancelRequestPacket()
}
}
@@ -12,70 +12,70 @@ data class BattleChallengeRequestPacket(
val ruleParam: Short,
val extraRule: ByteArray?,
) {
override fun equals(other: Any?): Boolean =
other is BattleChallengeRequestPacket &&
flags == other.flags &&
entryKindId == other.entryKindId &&
battleFormat == other.battleFormat &&
levelCap == other.levelCap &&
allowedSpecies == other.allowedSpecies &&
ruleSet == other.ruleSet &&
ruleParam == other.ruleParam &&
(extraRule?.contentEquals(other.extraRule ?: ByteArray(0)) ?: (other.extraRule == null))
override fun equals(other: Any?): Boolean =
other is BattleChallengeRequestPacket &&
flags == other.flags &&
entryKindId == other.entryKindId &&
battleFormat == other.battleFormat &&
levelCap == other.levelCap &&
allowedSpecies == other.allowedSpecies &&
ruleSet == other.ruleSet &&
ruleParam == other.ruleParam &&
(extraRule?.contentEquals(other.extraRule ?: ByteArray(0)) ?: (other.extraRule == null))
override fun hashCode(): Int {
var r = flags.toInt()
r = r * 31 + entryKindId
r = r * 31 + battleFormat
r = r * 31 + levelCap
r = r * 31 + allowedSpecies.hashCode()
r = r * 31 + ruleSet
r = r * 31 + ruleParam
r = r * 31 + (extraRule?.contentHashCode() ?: 0)
return r
}
override fun hashCode(): Int {
var r = flags.toInt()
r = r * 31 + entryKindId
r = r * 31 + battleFormat
r = r * 31 + levelCap
r = r * 31 + allowedSpecies.hashCode()
r = r * 31 + ruleSet
r = r * 31 + ruleParam
r = r * 31 + (extraRule?.contentHashCode() ?: 0)
return r
}
}
private val ExtraRuleBytes: Codec<ByteArray> =
object : Codec<ByteArray> {
override fun read(buf: ReadBuffer): ByteArray {
val data = ByteArray(buf.remaining())
if (data.isNotEmpty()) buf.readBytes(data)
return data
}
override fun read(buf: ReadBuffer): ByteArray {
val data = ByteArray(buf.remaining())
if (data.isNotEmpty()) buf.readBytes(data)
return data
}
override fun write(buf: WriteBuffer, value: ByteArray) {
if (value.isNotEmpty()) buf.writeBytes(value)
}
override fun write(buf: WriteBuffer, value: ByteArray) {
if (value.isNotEmpty()) buf.writeBytes(value)
}
}
object BattleChallengeRequestPacketCodec : PacketCodec<BattleChallengeRequestPacket>() {
override fun CodecScope<BattleChallengeRequestPacket>.body(): BattleChallengeRequestPacket {
val flags = field(S8) { it.flags }
val entryKindId = field(S8) { it.entryKindId }
val battleFormat = field(S8) { it.battleFormat }
val levelCap = field(S16LE) { it.levelCap }
val allowedSpecies = field(S16LE.listPrefixed(U8)) { it.allowedSpecies }
val ruleSet = field(S8) { it.ruleSet }
val ruleParam = field(S16LE) { it.ruleParam }
val present = field(U8) { if (it.extraRule != null) 1 else 0 }
val extraRule =
if (present != 0) {
field(ExtraRuleBytes) {
it.extraRule ?: throw MalformedPacketException("extraRule required")
}
} else {
null
}
return BattleChallengeRequestPacket(
flags,
entryKindId,
battleFormat,
levelCap,
allowedSpecies,
ruleSet,
ruleParam,
extraRule,
)
}
override fun CodecScope<BattleChallengeRequestPacket>.body(): BattleChallengeRequestPacket {
val flags = field(S8) { it.flags }
val entryKindId = field(S8) { it.entryKindId }
val battleFormat = field(S8) { it.battleFormat }
val levelCap = field(S16LE) { it.levelCap }
val allowedSpecies = field(S16LE.listPrefixed(U8)) { it.allowedSpecies }
val ruleSet = field(S8) { it.ruleSet }
val ruleParam = field(S16LE) { it.ruleParam }
val present = field(U8) { if (it.extraRule != null) 1 else 0 }
val extraRule =
if (present != 0) {
field(ExtraRuleBytes) {
it.extraRule ?: throw MalformedPacketException("extraRule required")
}
} else {
null
}
return BattleChallengeRequestPacket(
flags,
entryKindId,
battleFormat,
levelCap,
allowedSpecies,
ruleSet,
ruleParam,
extraRule,
)
}
}
@@ -8,9 +8,9 @@ import de.fiereu.bytecodec.Utf16LeNullTerminated
data class BattleChatMessagePacket(val channelOrSlot: Byte, val message: String)
object BattleChatMessagePacketCodec : PacketCodec<BattleChatMessagePacket>() {
override fun CodecScope<BattleChatMessagePacket>.body(): BattleChatMessagePacket {
val channelOrSlot = field(S8) { it.channelOrSlot }
val message = field(Utf16LeNullTerminated) { it.message }
return BattleChatMessagePacket(channelOrSlot, message)
}
override fun CodecScope<BattleChatMessagePacket>.body(): BattleChatMessagePacket {
val channelOrSlot = field(S8) { it.channelOrSlot }
val message = field(Utf16LeNullTerminated) { it.message }
return BattleChatMessagePacket(channelOrSlot, message)
}
}
@@ -7,17 +7,17 @@ import de.fiereu.bytecodec.fixedBytes
data class BattleControlBytesPacket(
val controlBytes: ByteArray,
) {
override fun equals(other: Any?): Boolean =
other is BattleControlBytesPacket && controlBytes.contentEquals(other.controlBytes)
override fun equals(other: Any?): Boolean =
other is BattleControlBytesPacket && controlBytes.contentEquals(other.controlBytes)
override fun hashCode(): Int = controlBytes.contentHashCode()
override fun hashCode(): Int = controlBytes.contentHashCode()
}
private val ControlBytes = fixedBytes(3)
object BattleControlBytesPacketCodec : PacketCodec<BattleControlBytesPacket>() {
override fun CodecScope<BattleControlBytesPacket>.body(): BattleControlBytesPacket {
val controlBytes = field(ControlBytes) { it.controlBytes }
return BattleControlBytesPacket(controlBytes)
}
override fun CodecScope<BattleControlBytesPacket>.body(): BattleControlBytesPacket {
val controlBytes = field(ControlBytes) { it.controlBytes }
return BattleControlBytesPacket(controlBytes)
}
}
@@ -15,28 +15,32 @@ data class MessageArg(
internal val MessageArgCodec: Codec<MessageArg> =
object : PacketCodec<MessageArg>() {
override fun CodecScope<MessageArg>.body(): MessageArg {
val argId = field(S8) { it.argId }
val rawType = field(U8) { if (it.hasExtra) it.type or 128 else it.type }
val hasExtra = rawType and 128 != 0
val type = if (hasExtra) rawType and 127 else rawType
val extra = if (hasExtra) field(S8) { it.extra } else 0
var longValue: Long? = null
var intValue: Int? = null
var stringValue: String? = null
var shortValues: List<Short>? = null
when (type) {
28 -> {}
30 -> longValue = field(S64LE) { it.longValue!! }
9, 10, 17 -> intValue = field(S32LE) { it.intValue!! }
5, 18 -> stringValue = field(Utf16LeNullTerminated) { it.stringValue!! }
else -> {
val count = field(U8) { it.shortValues!!.size }
shortValues = (0 until count).map { i -> field(S16LE) { it.shortValues!![i] } }
}
}
return MessageArg(argId, type, hasExtra, extra, longValue, intValue, stringValue, shortValues)
override fun CodecScope<MessageArg>.body(): MessageArg {
val argId = field(S8) { it.argId }
val rawType = field(U8) { if (it.hasExtra) it.type or 128 else it.type }
val hasExtra = rawType and 128 != 0
val type = if (hasExtra) rawType and 127 else rawType
val extra = if (hasExtra) field(S8) { it.extra } else 0
var longValue: Long? = null
var intValue: Int? = null
var stringValue: String? = null
var shortValues: List<Short>? = null
when (type) {
28 -> {}
30 -> longValue = field(S64LE) { it.longValue!! }
9,
10,
17 -> intValue = field(S32LE) { it.intValue!! }
5,
18 -> stringValue = field(Utf16LeNullTerminated) { it.stringValue!! }
else -> {
val count = field(U8) { it.shortValues!!.size }
shortValues = (0 until count).map { i -> field(S16LE) { it.shortValues!![i] } }
}
}
return MessageArg(
argId, type, hasExtra, extra, longValue, intValue, stringValue, shortValues)
}
}
data class BattleDisconnectMessagePacket(
@@ -45,10 +49,10 @@ data class BattleDisconnectMessagePacket(
)
object BattleDisconnectMessagePacketCodec : PacketCodec<BattleDisconnectMessagePacket>() {
override fun CodecScope<BattleDisconnectMessagePacket>.body(): BattleDisconnectMessagePacket {
val reason = field(S8) { it.reason }
val count = field(U8) { it.args.size }
val args = (0 until count).map { i -> field(MessageArgCodec) { it.args[i] } }
return BattleDisconnectMessagePacket(reason, args)
}
override fun CodecScope<BattleDisconnectMessagePacket>.body(): BattleDisconnectMessagePacket {
val reason = field(S8) { it.reason }
val count = field(U8) { it.args.size }
val args = (0 until count).map { i -> field(MessageArgCodec) { it.args[i] } }
return BattleDisconnectMessagePacket(reason, args)
}
}
@@ -8,7 +8,7 @@ data class BattleEmptyEventPacket(
)
object BattleEmptyEventPacketCodec : PacketCodec<BattleEmptyEventPacket>() {
override fun CodecScope<BattleEmptyEventPacket>.body(): BattleEmptyEventPacket {
return BattleEmptyEventPacket()
}
override fun CodecScope<BattleEmptyEventPacket>.body(): BattleEmptyEventPacket {
return BattleEmptyEventPacket()
}
}
@@ -9,8 +9,8 @@ data class BattleEndDisconnectPacket(
)
object BattleEndDisconnectPacketCodec : PacketCodec<BattleEndDisconnectPacket>() {
override fun CodecScope<BattleEndDisconnectPacket>.body(): BattleEndDisconnectPacket {
val reason = field(S8) { it.reason }
return BattleEndDisconnectPacket(reason)
}
override fun CodecScope<BattleEndDisconnectPacket>.body(): BattleEndDisconnectPacket {
val reason = field(S8) { it.reason }
return BattleEndDisconnectPacket(reason)
}
}
@@ -10,9 +10,9 @@ data class BattleEntityActionEventPacket(
)
object BattleEntityActionEventPacketCodec : PacketCodec<BattleEntityActionEventPacket>() {
override fun CodecScope<BattleEntityActionEventPacket>.body(): BattleEntityActionEventPacket {
val sourceId = field(S64LE) { it.sourceId }
val targetId = field(S64LE) { it.targetId }
return BattleEntityActionEventPacket(sourceId, targetId)
}
override fun CodecScope<BattleEntityActionEventPacket>.body(): BattleEntityActionEventPacket {
val sourceId = field(S64LE) { it.sourceId }
val targetId = field(S64LE) { it.targetId }
return BattleEntityActionEventPacket(sourceId, targetId)
}
}
@@ -46,90 +46,91 @@ data class BattleEntityDeltaPacket(
)
object BattleEntityDeltaPacketCodec : PacketCodec<BattleEntityDeltaPacket>() {
override fun CodecScope<BattleEntityDeltaPacket>.body(): BattleEntityDeltaPacket {
val entityId = field(S64LE) { it.entityId }
val fieldMask = field(S32LE) { it.fieldMask }
val m = fieldMask
override fun CodecScope<BattleEntityDeltaPacket>.body(): BattleEntityDeltaPacket {
val entityId = field(S64LE) { it.entityId }
val fieldMask = field(S32LE) { it.fieldMask }
val m = fieldMask
val experienceLevel = if (m and 1 != 0) field(S8) { it.experienceLevel!! } else null
val experiencePoints = if (m and 1 != 0) field(S32LE) { it.experiencePoints!! } else null
val statValues = if (m and 2 != 0) field(S16LE.repeat(6)) { it.statValues!! } else null
val moveSlots = if (m and 4 != 0) field(MoveSlotCodec.repeat(4)) { it.moveSlots!! } else null
val ppUps = if (m and 4 != 0) field(S8) { it.ppUps!! } else null
val currentHp = if (m and 8 != 0) field(S16LE) { it.currentHp!! } else null
val faintFlag = if (m and 16 != 0) field(S8) { it.faintFlag!! } else null
val speciesId = if (m and 32 != 0) field(S16LE) { it.speciesId!! } else null
val forme = if (m and 32 != 0) field(S8) { it.forme!! } else null
val listType = if (m and 64 != 0) field(S8) { it.listType!! } else null
val sortKey = if (m and 64 != 0) field(S16LE) { it.sortKey!! } else null
val evValues = if (m and 128 != 0) field(S16LE.repeat(6)) { it.evValues!! } else null
val level = if (m and 256 != 0) field(S16LE) { it.level!! } else null
val happiness = if (m and 512 != 0) field(S16LE) { it.happiness!! } else null
val shininessSeed = if (m and 1024 != 0) field(S32LE) { it.shininessSeed!! } else null
val experience = if (m and 1024 != 0) field(S32LE) { it.experience!! } else null
val flagA = if (m and 1024 != 0) field(S8) { it.flagA!! } else null
val flagB = if (m and 1024 != 0) field(S8) { it.flagB!! } else null
val encounterType = if (m and 1024 != 0) field(S8) { it.encounterType!! } else null
val statusFlagsValue = if (m and 2048 != 0) field(S16LE) { it.statusFlagsValue!! } else null
val warnA = if (m and 4096 != 0) field(S16LE) { it.warnA!! } else null
val warnB = if (m and 4096 != 0) field(S16LE) { it.warnB!! } else null
val natureId = if (m and 8192 != 0) field(S8) { it.natureId!! } else null
val ribbons = if (m and 16384 != 0) field(S64LE) { it.ribbons!! } else null
val packedIvs = if (m and 2097152 != 0) field(S32LE) { it.packedIvs!! } else null
val experienceLevel = if (m and 1 != 0) field(S8) { it.experienceLevel!! } else null
val experiencePoints = if (m and 1 != 0) field(S32LE) { it.experiencePoints!! } else null
val statValues = if (m and 2 != 0) field(S16LE.repeat(6)) { it.statValues!! } else null
val moveSlots = if (m and 4 != 0) field(MoveSlotCodec.repeat(4)) { it.moveSlots!! } else null
val ppUps = if (m and 4 != 0) field(S8) { it.ppUps!! } else null
val currentHp = if (m and 8 != 0) field(S16LE) { it.currentHp!! } else null
val faintFlag = if (m and 16 != 0) field(S8) { it.faintFlag!! } else null
val speciesId = if (m and 32 != 0) field(S16LE) { it.speciesId!! } else null
val forme = if (m and 32 != 0) field(S8) { it.forme!! } else null
val listType = if (m and 64 != 0) field(S8) { it.listType!! } else null
val sortKey = if (m and 64 != 0) field(S16LE) { it.sortKey!! } else null
val evValues = if (m and 128 != 0) field(S16LE.repeat(6)) { it.evValues!! } else null
val level = if (m and 256 != 0) field(S16LE) { it.level!! } else null
val happiness = if (m and 512 != 0) field(S16LE) { it.happiness!! } else null
val shininessSeed = if (m and 1024 != 0) field(S32LE) { it.shininessSeed!! } else null
val experience = if (m and 1024 != 0) field(S32LE) { it.experience!! } else null
val flagA = if (m and 1024 != 0) field(S8) { it.flagA!! } else null
val flagB = if (m and 1024 != 0) field(S8) { it.flagB!! } else null
val encounterType = if (m and 1024 != 0) field(S8) { it.encounterType!! } else null
val statusFlagsValue = if (m and 2048 != 0) field(S16LE) { it.statusFlagsValue!! } else null
val warnA = if (m and 4096 != 0) field(S16LE) { it.warnA!! } else null
val warnB = if (m and 4096 != 0) field(S16LE) { it.warnB!! } else null
val natureId = if (m and 8192 != 0) field(S8) { it.natureId!! } else null
val ribbons = if (m and 16384 != 0) field(S64LE) { it.ribbons!! } else null
val packedIvs = if (m and 2097152 != 0) field(S32LE) { it.packedIvs!! } else null
val effortValues = if (m and 32768 != 0) field(S16LE.repeat(4)) { it.effortValues!! } else null
val originalSpecies = if (m and 32768 != 0) field(S64LE) { it.originalSpecies!! } else null
val originalTrainerName =
if (m and 32768 != 0) field(Utf16LeNullTerminated) { it.originalTrainerName!! } else null
val originalTrainerId = if (m and 32768 != 0) field(S32LE) { it.originalTrainerId!! } else null
val effortValues = if (m and 32768 != 0) field(S16LE.repeat(4)) { it.effortValues!! } else null
val originalSpecies = if (m and 32768 != 0) field(S64LE) { it.originalSpecies!! } else null
val originalTrainerName =
if (m and 32768 != 0) field(Utf16LeNullTerminated) { it.originalTrainerName!! } else null
val originalTrainerId = if (m and 32768 != 0) field(S32LE) { it.originalTrainerId!! } else null
val shininessType = if (m and 65536 != 0) field(S8) { it.shininessType!! } else null
val gender = if (m and 131072 != 0) field(S8) { it.gender!! } 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 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 status = if (m and 8388608 != 0) field(S8) { it.status!! } else null
val shininessType = if (m and 65536 != 0) field(S8) { it.shininessType!! } else null
val gender = if (m and 131072 != 0) field(S8) { it.gender!! } 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 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 status = if (m and 8388608 != 0) field(S8) { it.status!! } else null
return BattleEntityDeltaPacket(
entityId = entityId,
fieldMask = fieldMask,
experienceLevel = experienceLevel,
experiencePoints = experiencePoints,
statValues = statValues,
moveSlots = moveSlots,
ppUps = ppUps,
currentHp = currentHp,
faintFlag = faintFlag,
speciesId = speciesId,
forme = forme,
listType = listType,
sortKey = sortKey,
evValues = evValues,
level = level,
happiness = happiness,
shininessSeed = shininessSeed,
experience = experience,
flagA = flagA,
flagB = flagB,
encounterType = encounterType,
statusFlagsValue = statusFlagsValue,
warnA = warnA,
warnB = warnB,
natureId = natureId,
ribbons = ribbons,
packedIvs = packedIvs,
effortValues = effortValues,
originalSpecies = originalSpecies,
originalTrainerName = originalTrainerName,
originalTrainerId = originalTrainerId,
shininessType = shininessType,
gender = gender,
ivs = ivs,
caughtBall = caughtBall,
statusFlags2 = statusFlags2,
statusList = statusList,
status = status,
)
}
return BattleEntityDeltaPacket(
entityId = entityId,
fieldMask = fieldMask,
experienceLevel = experienceLevel,
experiencePoints = experiencePoints,
statValues = statValues,
moveSlots = moveSlots,
ppUps = ppUps,
currentHp = currentHp,
faintFlag = faintFlag,
speciesId = speciesId,
forme = forme,
listType = listType,
sortKey = sortKey,
evValues = evValues,
level = level,
happiness = happiness,
shininessSeed = shininessSeed,
experience = experience,
flagA = flagA,
flagB = flagB,
encounterType = encounterType,
statusFlagsValue = statusFlagsValue,
warnA = warnA,
warnB = warnB,
natureId = natureId,
ribbons = ribbons,
packedIvs = packedIvs,
effortValues = effortValues,
originalSpecies = originalSpecies,
originalTrainerName = originalTrainerName,
originalTrainerId = originalTrainerId,
shininessType = shininessType,
gender = gender,
ivs = ivs,
caughtBall = caughtBall,
statusFlags2 = statusFlags2,
statusList = statusList,
status = status,
)
}
}
@@ -10,12 +10,12 @@ data class BattleMoveDataEntry(
private val BattleMoveDataEntryCodec: Codec<BattleMoveDataEntry> =
object : PacketCodec<BattleMoveDataEntry>() {
override fun CodecScope<BattleMoveDataEntry>.body(): BattleMoveDataEntry {
val entityId = field(S64LE) { it.entityId }
val value = field(S16LE) { it.value }
val actionCount = field(U8) { it.actionCount }
return BattleMoveDataEntry(entityId, value, actionCount)
}
override fun CodecScope<BattleMoveDataEntry>.body(): BattleMoveDataEntry {
val entityId = field(S64LE) { it.entityId }
val value = field(S16LE) { it.value }
val actionCount = field(U8) { it.actionCount }
return BattleMoveDataEntry(entityId, value, actionCount)
}
}
data class BattleEntityMoveEventPacket(
@@ -26,11 +26,11 @@ data class BattleEntityMoveEventPacket(
)
object BattleEntityMoveEventPacketCodec : PacketCodec<BattleEntityMoveEventPacket>() {
override fun CodecScope<BattleEntityMoveEventPacket>.body(): BattleEntityMoveEventPacket {
val entityId = field(S64LE) { it.entityId }
val value = field(S16LE) { it.value }
val kind = field(S8) { it.kind }
val entries = field(BattleMoveDataEntryCodec.listPrefixed(U8)) { it.entries }
return BattleEntityMoveEventPacket(entityId, value, kind, entries)
}
override fun CodecScope<BattleEntityMoveEventPacket>.body(): BattleEntityMoveEventPacket {
val entityId = field(S64LE) { it.entityId }
val value = field(S16LE) { it.value }
val kind = field(S8) { it.kind }
val entries = field(BattleMoveDataEntryCodec.listPrefixed(U8)) { it.entries }
return BattleEntityMoveEventPacket(entityId, value, kind, entries)
}
}
@@ -11,10 +11,10 @@ data class BattleEnumPairEventPacket(
)
object BattleEnumPairEventPacketCodec : PacketCodec<BattleEnumPairEventPacket>() {
override fun CodecScope<BattleEnumPairEventPacket>.body(): BattleEnumPairEventPacket {
val eventType = field(S8) { it.eventType }
val first = field(S8) { it.first }
val second = field(S8) { it.second }
return BattleEnumPairEventPacket(eventType, first, second)
}
override fun CodecScope<BattleEnumPairEventPacket>.body(): BattleEnumPairEventPacket {
val eventType = field(S8) { it.eventType }
val first = field(S8) { it.first }
val second = field(S8) { it.second }
return BattleEnumPairEventPacket(eventType, first, second)
}
}
@@ -10,12 +10,12 @@ data class BattleLabeledMoveEntry(
private val BattleLabeledMoveEntryCodec: Codec<BattleLabeledMoveEntry> =
object : PacketCodec<BattleLabeledMoveEntry>() {
override fun CodecScope<BattleLabeledMoveEntry>.body(): BattleLabeledMoveEntry {
val entityId = field(S64LE) { it.entityId }
val value = field(S16LE) { it.value }
val actionCount = field(U8) { it.actionCount }
return BattleLabeledMoveEntry(entityId, value, actionCount)
}
override fun CodecScope<BattleLabeledMoveEntry>.body(): BattleLabeledMoveEntry {
val entityId = field(S64LE) { it.entityId }
val value = field(S16LE) { it.value }
val actionCount = field(U8) { it.actionCount }
return BattleLabeledMoveEntry(entityId, value, actionCount)
}
}
data class BattleLabeledMoveEventPacket(
@@ -29,14 +29,14 @@ data class BattleLabeledMoveEventPacket(
)
object BattleLabeledMoveEventPacketCodec : PacketCodec<BattleLabeledMoveEventPacket>() {
override fun CodecScope<BattleLabeledMoveEventPacket>.body(): BattleLabeledMoveEventPacket {
val byte1 = field(S8) { it.byte1 }
val byte2 = field(S8) { it.byte2 }
val value = field(S16LE) { it.value }
val byte3 = field(S8) { it.byte3 }
val short2 = field(S16LE) { it.short2 }
val label = field(Utf16LeNullTerminated) { it.label }
val entries = field(BattleLabeledMoveEntryCodec.listPrefixed(U8)) { it.entries }
return BattleLabeledMoveEventPacket(byte1, byte2, value, byte3, short2, label, entries)
}
override fun CodecScope<BattleLabeledMoveEventPacket>.body(): BattleLabeledMoveEventPacket {
val byte1 = field(S8) { it.byte1 }
val byte2 = field(S8) { it.byte2 }
val value = field(S16LE) { it.value }
val byte3 = field(S8) { it.byte3 }
val short2 = field(S16LE) { it.short2 }
val label = field(Utf16LeNullTerminated) { it.label }
val entries = field(BattleLabeledMoveEntryCodec.listPrefixed(U8)) { it.entries }
return BattleLabeledMoveEventPacket(byte1, byte2, value, byte3, short2, label, entries)
}
}
@@ -18,16 +18,16 @@ data class BattleListEventPacket(
)
object BattleListEventPacketCodec : PacketCodec<BattleListEventPacket>() {
override fun CodecScope<BattleListEventPacket>.body(): BattleListEventPacket {
val kind = field(S8) { it.kind }
val value = field(S16LE) { it.value }
val subKind = field(S8) { it.subKind }
val detail =
if (subKind.toInt() == 4) {
val listType = field(S8) { it.detail!!.listType }
val detailValue = field(S16LE) { it.detail!!.value }
BattleListEventDetail(listType, detailValue)
} else null
return BattleListEventPacket(kind, value, subKind, detail)
}
override fun CodecScope<BattleListEventPacket>.body(): BattleListEventPacket {
val kind = field(S8) { it.kind }
val value = field(S16LE) { it.value }
val subKind = field(S8) { it.subKind }
val detail =
if (subKind.toInt() == 4) {
val listType = field(S8) { it.detail!!.listType }
val detailValue = field(S16LE) { it.detail!!.value }
BattleListEventDetail(listType, detailValue)
} else null
return BattleListEventPacket(kind, value, subKind, detail)
}
}
@@ -18,29 +18,29 @@ data class BattleMoveDisableUpdatePacket(
private val BattleMoveDisableEntryCodec: Codec<BattleMoveDisableEntry> =
object : PacketCodec<BattleMoveDisableEntry>() {
override fun CodecScope<BattleMoveDisableEntry>.body(): BattleMoveDisableEntry {
val present = field(Bool) { it.present }
return if (present) {
val disabled = field(Bool) { it.disabled }
val disableTurns = field(S16LE) { it.disableTurns }
BattleMoveDisableEntry(true, disabled, disableTurns)
} else {
BattleMoveDisableEntry(false, false, 0)
}
override fun CodecScope<BattleMoveDisableEntry>.body(): BattleMoveDisableEntry {
val present = field(Bool) { it.present }
return if (present) {
val disabled = field(Bool) { it.disabled }
val disableTurns = field(S16LE) { it.disableTurns }
BattleMoveDisableEntry(true, disabled, disableTurns)
} else {
BattleMoveDisableEntry(false, false, 0)
}
}
}
private val BattleMoveDisableSideCodec: Codec<BattleMoveDisableSide> =
object : PacketCodec<BattleMoveDisableSide>() {
override fun CodecScope<BattleMoveDisableSide>.body(): BattleMoveDisableSide {
val entries = field(BattleMoveDisableEntryCodec.listPrefixed(U8)) { it.entries }
return BattleMoveDisableSide(entries)
}
override fun CodecScope<BattleMoveDisableSide>.body(): BattleMoveDisableSide {
val entries = field(BattleMoveDisableEntryCodec.listPrefixed(U8)) { it.entries }
return BattleMoveDisableSide(entries)
}
}
object BattleMoveDisableUpdatePacketCodec : PacketCodec<BattleMoveDisableUpdatePacket>() {
override fun CodecScope<BattleMoveDisableUpdatePacket>.body(): BattleMoveDisableUpdatePacket {
val sides = field(BattleMoveDisableSideCodec.repeat(2)) { it.sides }
return BattleMoveDisableUpdatePacket(sides)
}
override fun CodecScope<BattleMoveDisableUpdatePacket>.body(): BattleMoveDisableUpdatePacket {
val sides = field(BattleMoveDisableSideCodec.repeat(2)) { it.sides }
return BattleMoveDisableUpdatePacket(sides)
}
}
@@ -13,15 +13,15 @@ data class BattleMoveAppearance(
private val BattleMoveAppearanceCodec: Codec<BattleMoveAppearance> =
object : PacketCodec<BattleMoveAppearance>() {
override fun CodecScope<BattleMoveAppearance>.body(): BattleMoveAppearance {
val name = field(Utf16LeNullTerminated) { it.name }
val gender = field(S8) { it.gender }
val id = field(S32LE) { it.id }
val kind = field(S8) { it.kind }
val palettePack = field(S8) { it.palettePack }
val slots = field(S16LE.repeat(4)) { it.slots }
return BattleMoveAppearance(name, gender, id, kind, palettePack, slots)
}
override fun CodecScope<BattleMoveAppearance>.body(): BattleMoveAppearance {
val name = field(Utf16LeNullTerminated) { it.name }
val gender = field(S8) { it.gender }
val id = field(S32LE) { it.id }
val kind = field(S8) { it.kind }
val palettePack = field(S8) { it.palettePack }
val slots = field(S16LE.repeat(4)) { it.slots }
return BattleMoveAppearance(name, gender, id, kind, palettePack, slots)
}
}
data class BattleMoveEntry(
@@ -34,14 +34,14 @@ data class BattleMoveEntry(
private val BattleMoveEntryCodec: Codec<BattleMoveEntry> =
object : PacketCodec<BattleMoveEntry>() {
override fun CodecScope<BattleMoveEntry>.body(): BattleMoveEntry {
val moveId = field(S32LE) { it.moveId }
val tier = field(S8) { it.tier }
val int1 = field(S32LE) { it.int1 }
val int2 = field(S32LE) { it.int2 }
val appearances = field(BattleMoveAppearanceCodec.listPrefixed(U8)) { it.appearances }
return BattleMoveEntry(moveId, tier, int1, int2, appearances)
}
override fun CodecScope<BattleMoveEntry>.body(): BattleMoveEntry {
val moveId = field(S32LE) { it.moveId }
val tier = field(S8) { it.tier }
val int1 = field(S32LE) { it.int1 }
val int2 = field(S32LE) { it.int2 }
val appearances = field(BattleMoveAppearanceCodec.listPrefixed(U8)) { it.appearances }
return BattleMoveEntry(moveId, tier, int1, int2, appearances)
}
}
data class BattleMoveListPacket(
@@ -51,10 +51,10 @@ data class BattleMoveListPacket(
)
object BattleMoveListPacketCodec : PacketCodec<BattleMoveListPacket>() {
override fun CodecScope<BattleMoveListPacket>.body(): BattleMoveListPacket {
val actionId = field(S16LE) { it.actionId }
val slot = field(S8) { it.slot }
val moves = field(BattleMoveEntryCodec.listPrefixed(U8)) { it.moves }
return BattleMoveListPacket(actionId, slot, moves)
}
override fun CodecScope<BattleMoveListPacket>.body(): BattleMoveListPacket {
val actionId = field(S16LE) { it.actionId }
val slot = field(S8) { it.slot }
val moves = field(BattleMoveEntryCodec.listPrefixed(U8)) { it.moves }
return BattleMoveListPacket(actionId, slot, moves)
}
}
@@ -9,8 +9,8 @@ data class BattleMoveSelectionCancelPacket(
)
object BattleMoveSelectionCancelPacketCodec : PacketCodec<BattleMoveSelectionCancelPacket>() {
override fun CodecScope<BattleMoveSelectionCancelPacket>.body(): BattleMoveSelectionCancelPacket {
reserved(byte = 0)
return BattleMoveSelectionCancelPacket()
}
override fun CodecScope<BattleMoveSelectionCancelPacket>.body(): BattleMoveSelectionCancelPacket {
reserved(byte = 0)
return BattleMoveSelectionCancelPacket()
}
}
@@ -7,8 +7,8 @@ import de.fiereu.bytecodec.S8
data class BattleMoveSlotChoicePacket(val moveSlotIndex: Byte)
object BattleMoveSlotChoicePacketCodec : PacketCodec<BattleMoveSlotChoicePacket>() {
override fun CodecScope<BattleMoveSlotChoicePacket>.body(): BattleMoveSlotChoicePacket {
val moveSlotIndex = field(S8) { it.moveSlotIndex }
return BattleMoveSlotChoicePacket(moveSlotIndex)
}
override fun CodecScope<BattleMoveSlotChoicePacket>.body(): BattleMoveSlotChoicePacket {
val moveSlotIndex = field(S8) { it.moveSlotIndex }
return BattleMoveSlotChoicePacket(moveSlotIndex)
}
}
@@ -13,15 +13,15 @@ data class BattleTargetAppearance(
private val BattleTargetAppearanceCodec: Codec<BattleTargetAppearance> =
object : PacketCodec<BattleTargetAppearance>() {
override fun CodecScope<BattleTargetAppearance>.body(): BattleTargetAppearance {
val name = field(Utf16LeNullTerminated) { it.name }
val gender = field(S8) { it.gender }
val id = field(S32LE) { it.id }
val kind = field(S8) { it.kind }
val palettePack = field(S8) { it.palettePack }
val slots = field(S16LE.repeat(4)) { it.slots }
return BattleTargetAppearance(name, gender, id, kind, palettePack, slots)
}
override fun CodecScope<BattleTargetAppearance>.body(): BattleTargetAppearance {
val name = field(Utf16LeNullTerminated) { it.name }
val gender = field(S8) { it.gender }
val id = field(S32LE) { it.id }
val kind = field(S8) { it.kind }
val palettePack = field(S8) { it.palettePack }
val slots = field(S16LE.repeat(4)) { it.slots }
return BattleTargetAppearance(name, gender, id, kind, palettePack, slots)
}
}
data class BattleMoveTargetEntry(
@@ -35,15 +35,15 @@ data class BattleMoveTargetEntry(
private val BattleMoveTargetEntryCodec: Codec<BattleMoveTargetEntry> =
object : PacketCodec<BattleMoveTargetEntry>() {
override fun CodecScope<BattleMoveTargetEntry>.body(): BattleMoveTargetEntry {
val entityId = field(S64LE) { it.entityId }
val weight = field(F32LE) { it.weight }
val short1 = field(S16LE) { it.short1 }
val int1 = field(S32LE) { it.int1 }
val int2 = field(S32LE) { it.int2 }
val appearance = field(BattleTargetAppearanceCodec) { it.appearance }
return BattleMoveTargetEntry(entityId, weight, short1, int1, int2, appearance)
}
override fun CodecScope<BattleMoveTargetEntry>.body(): BattleMoveTargetEntry {
val entityId = field(S64LE) { it.entityId }
val weight = field(F32LE) { it.weight }
val short1 = field(S16LE) { it.short1 }
val int1 = field(S32LE) { it.int1 }
val int2 = field(S32LE) { it.int2 }
val appearance = field(BattleTargetAppearanceCodec) { it.appearance }
return BattleMoveTargetEntry(entityId, weight, short1, int1, int2, appearance)
}
}
data class BattleMoveTargetsPacket(
@@ -54,11 +54,11 @@ data class BattleMoveTargetsPacket(
)
object BattleMoveTargetsPacketCodec : PacketCodec<BattleMoveTargetsPacket>() {
override fun CodecScope<BattleMoveTargetsPacket>.body(): BattleMoveTargetsPacket {
val actionId = field(S32LE) { it.actionId }
val slot = field(S8) { it.slot }
val tier = field(S8) { it.tier }
val targets = field(BattleMoveTargetEntryCodec.listPrefixed(U16LE)) { it.targets }
return BattleMoveTargetsPacket(actionId, slot, tier, targets)
}
override fun CodecScope<BattleMoveTargetsPacket>.body(): BattleMoveTargetsPacket {
val actionId = field(S32LE) { it.actionId }
val slot = field(S8) { it.slot }
val tier = field(S8) { it.tier }
val targets = field(BattleMoveTargetEntryCodec.listPrefixed(U16LE)) { it.targets }
return BattleMoveTargetsPacket(actionId, slot, tier, targets)
}
}
@@ -9,10 +9,10 @@ data class BattleMoveUsePacket(
)
object BattleMoveUsePacketCodec : PacketCodec<BattleMoveUsePacket>() {
override fun CodecScope<BattleMoveUsePacket>.body(): BattleMoveUsePacket {
val targetEntityId = field(S64LE) { it.targetEntityId }
val moveSlotIndex = field(S8) { it.moveSlotIndex }
val moveId = field(S16LE) { it.moveId }
return BattleMoveUsePacket(targetEntityId, moveSlotIndex, moveId)
}
override fun CodecScope<BattleMoveUsePacket>.body(): BattleMoveUsePacket {
val targetEntityId = field(S64LE) { it.targetEntityId }
val moveSlotIndex = field(S8) { it.moveSlotIndex }
val moveId = field(S16LE) { it.moveId }
return BattleMoveUsePacket(targetEntityId, moveSlotIndex, moveId)
}
}
@@ -12,10 +12,10 @@ data class BattlePartySlotSelectPacket(
)
object BattlePartySlotSelectPacketCodec : PacketCodec<BattlePartySlotSelectPacket>() {
override fun CodecScope<BattlePartySlotSelectPacket>.body(): BattlePartySlotSelectPacket {
val slotIndex = field(S16LE) { it.slotIndex }
val pokemonEntityId = field(S64LE) { it.pokemonEntityId }
val contextId = field(S16LE) { it.contextId }
return BattlePartySlotSelectPacket(slotIndex, pokemonEntityId, contextId)
}
override fun CodecScope<BattlePartySlotSelectPacket>.body(): BattlePartySlotSelectPacket {
val slotIndex = field(S16LE) { it.slotIndex }
val pokemonEntityId = field(S64LE) { it.pokemonEntityId }
val contextId = field(S16LE) { it.contextId }
return BattlePartySlotSelectPacket(slotIndex, pokemonEntityId, contextId)
}
}
@@ -7,8 +7,8 @@ import de.fiereu.bytecodec.S64LE
data class BattlePartySwitchPacket(val monsterEntityId: Long)
object BattlePartySwitchPacketCodec : PacketCodec<BattlePartySwitchPacket>() {
override fun CodecScope<BattlePartySwitchPacket>.body(): BattlePartySwitchPacket {
val monsterEntityId = field(S64LE) { it.monsterEntityId }
return BattlePartySwitchPacket(monsterEntityId)
}
override fun CodecScope<BattlePartySwitchPacket>.body(): BattlePartySwitchPacket {
val monsterEntityId = field(S64LE) { it.monsterEntityId }
return BattlePartySwitchPacket(monsterEntityId)
}
}
@@ -11,9 +11,9 @@ data class BattlePokemonSpritePacket(
)
object BattlePokemonSpritePacketCodec : PacketCodec<BattlePokemonSpritePacket>() {
override fun CodecScope<BattlePokemonSpritePacket>.body(): BattlePokemonSpritePacket {
val entityId = field(S64LE) { it.entityId }
val spriteId = field(S16LE) { it.spriteId }
return BattlePokemonSpritePacket(entityId, spriteId)
}
override fun CodecScope<BattlePokemonSpritePacket>.body(): BattlePokemonSpritePacket {
val entityId = field(S64LE) { it.entityId }
val spriteId = field(S16LE) { it.spriteId }
return BattlePokemonSpritePacket(entityId, spriteId)
}
}
@@ -15,17 +15,17 @@ data class BattlePokemonStatusPacket(
)
object BattlePokemonStatusPacketCodec : PacketCodec<BattlePokemonStatusPacket>() {
override fun CodecScope<BattlePokemonStatusPacket>.body(): BattlePokemonStatusPacket {
val entityId = field(S64LE) { it.entityId }
val statusId = field(S8) { it.statusId }
val present = field(U8) { if (it.statusEffect != null) 1 else 0 } == 1
val statusEffect =
if (present) {
val durationTurns = field(S32LE) { it.statusEffect!!.durationTurns }
val effectType = field(S8) { it.statusEffect!!.effectType }
val sourceSlot = field(S8) { it.statusEffect!!.sourceSlot }
BattleStatusEffectData(durationTurns, effectType, sourceSlot)
} else null
return BattlePokemonStatusPacket(entityId, statusId, statusEffect)
}
override fun CodecScope<BattlePokemonStatusPacket>.body(): BattlePokemonStatusPacket {
val entityId = field(S64LE) { it.entityId }
val statusId = field(S8) { it.statusId }
val present = field(U8) { if (it.statusEffect != null) 1 else 0 } == 1
val statusEffect =
if (present) {
val durationTurns = field(S32LE) { it.statusEffect!!.durationTurns }
val effectType = field(S8) { it.statusEffect!!.effectType }
val sourceSlot = field(S8) { it.statusEffect!!.sourceSlot }
BattleStatusEffectData(durationTurns, effectType, sourceSlot)
} else null
return BattlePokemonStatusPacket(entityId, statusId, statusEffect)
}
}
@@ -9,8 +9,8 @@ data class BattlePromptSwitchPacket(
)
object BattlePromptSwitchPacketCodec : PacketCodec<BattlePromptSwitchPacket>() {
override fun CodecScope<BattlePromptSwitchPacket>.body(): BattlePromptSwitchPacket {
val enabled = field(Bool) { it.enabled }
return BattlePromptSwitchPacket(enabled)
}
override fun CodecScope<BattlePromptSwitchPacket>.body(): BattlePromptSwitchPacket {
val enabled = field(Bool) { it.enabled }
return BattlePromptSwitchPacket(enabled)
}
}
@@ -7,16 +7,16 @@ import de.fiereu.bytecodec.S8
data class BattleQueuedEventPacket(
val packed: Byte,
) {
val value: Byte
get() = (packed.toInt() and 0x7F).toByte()
val value: Byte
get() = (packed.toInt() and 0x7F).toByte()
val flag: Boolean
get() = (packed.toInt() and 0x80) != 0
val flag: Boolean
get() = (packed.toInt() and 0x80) != 0
}
object BattleQueuedEventPacketCodec : PacketCodec<BattleQueuedEventPacket>() {
override fun CodecScope<BattleQueuedEventPacket>.body(): BattleQueuedEventPacket {
val packed = field(S8) { it.packed }
return BattleQueuedEventPacket(packed)
}
override fun CodecScope<BattleQueuedEventPacket>.body(): BattleQueuedEventPacket {
val packed = field(S8) { it.packed }
return BattleQueuedEventPacket(packed)
}
}
@@ -15,17 +15,17 @@ data class BattleRatingEntry(
private val BattleRatingEntryCodec: Codec<BattleRatingEntry> =
object : PacketCodec<BattleRatingEntry>() {
override fun CodecScope<BattleRatingEntry>.body(): BattleRatingEntry {
val entityId = field(S64LE) { it.entityId }
val tier = field(S8) { it.tier }
val bracket = field(S8) { it.bracket }
val elo = field(F32LE) { it.elo }
val short1 = field(S16LE) { it.short1 }
val byte1 = field(S8) { it.byte1 }
val int1 = field(S32LE) { it.int1 }
val int2 = field(S32LE) { it.int2 }
return BattleRatingEntry(entityId, tier, bracket, elo, short1, byte1, int1, int2)
}
override fun CodecScope<BattleRatingEntry>.body(): BattleRatingEntry {
val entityId = field(S64LE) { it.entityId }
val tier = field(S8) { it.tier }
val bracket = field(S8) { it.bracket }
val elo = field(F32LE) { it.elo }
val short1 = field(S16LE) { it.short1 }
val byte1 = field(S8) { it.byte1 }
val int1 = field(S32LE) { it.int1 }
val int2 = field(S32LE) { it.int2 }
return BattleRatingEntry(entityId, tier, bracket, elo, short1, byte1, int1, int2)
}
}
data class BattleRatingBulkPacket(
@@ -33,8 +33,8 @@ data class BattleRatingBulkPacket(
)
object BattleRatingBulkPacketCodec : PacketCodec<BattleRatingBulkPacket>() {
override fun CodecScope<BattleRatingBulkPacket>.body(): BattleRatingBulkPacket {
val ratings = field(BattleRatingEntryCodec.listPrefixed(U8)) { it.ratings }
return BattleRatingBulkPacket(ratings)
}
override fun CodecScope<BattleRatingBulkPacket>.body(): BattleRatingBulkPacket {
val ratings = field(BattleRatingEntryCodec.listPrefixed(U8)) { it.ratings }
return BattleRatingBulkPacket(ratings)
}
}
@@ -14,15 +14,15 @@ data class BattleRatingUpdatePacket(
)
object BattleRatingUpdatePacketCodec : PacketCodec<BattleRatingUpdatePacket>() {
override fun CodecScope<BattleRatingUpdatePacket>.body(): BattleRatingUpdatePacket {
val entityId = field(S64LE) { it.entityId }
val tier = field(S8) { it.tier }
val bracket = field(S8) { it.bracket }
val elo = field(F32LE) { it.elo }
val short1 = field(S16LE) { it.short1 }
val byte1 = field(S8) { it.byte1 }
val int1 = field(S32LE) { it.int1 }
val int2 = field(S32LE) { it.int2 }
return BattleRatingUpdatePacket(entityId, tier, bracket, elo, short1, byte1, int1, int2)
}
override fun CodecScope<BattleRatingUpdatePacket>.body(): BattleRatingUpdatePacket {
val entityId = field(S64LE) { it.entityId }
val tier = field(S8) { it.tier }
val bracket = field(S8) { it.bracket }
val elo = field(F32LE) { it.elo }
val short1 = field(S16LE) { it.short1 }
val byte1 = field(S8) { it.byte1 }
val int1 = field(S32LE) { it.int1 }
val int2 = field(S32LE) { it.int2 }
return BattleRatingUpdatePacket(entityId, tier, bracket, elo, short1, byte1, int1, int2)
}
}
@@ -7,8 +7,8 @@ import de.fiereu.bytecodec.PacketCodec
data class BattleReadyPacket(val ready: Boolean)
object BattleReadyPacketCodec : PacketCodec<BattleReadyPacket>() {
override fun CodecScope<BattleReadyPacket>.body(): BattleReadyPacket {
val ready = field(Bool) { it.ready }
return BattleReadyPacket(ready)
}
override fun CodecScope<BattleReadyPacket>.body(): BattleReadyPacket {
val ready = field(Bool) { it.ready }
return BattleReadyPacket(ready)
}
}
@@ -11,9 +11,9 @@ data class BattleRewardSelectPacket(
)
object BattleRewardSelectPacketCodec : PacketCodec<BattleRewardSelectPacket>() {
override fun CodecScope<BattleRewardSelectPacket>.body(): BattleRewardSelectPacket {
val targetEntityId = field(S64LE) { it.targetEntityId }
val rewardIndex = field(S32LE) { it.rewardIndex }
return BattleRewardSelectPacket(targetEntityId, rewardIndex)
}
override fun CodecScope<BattleRewardSelectPacket>.body(): BattleRewardSelectPacket {
val targetEntityId = field(S64LE) { it.targetEntityId }
val rewardIndex = field(S32LE) { it.rewardIndex }
return BattleRewardSelectPacket(targetEntityId, rewardIndex)
}
}
@@ -19,26 +19,35 @@ data class BattleRankingEntry(
private val BattleRankingEntryCodec: Codec<BattleRankingEntry> =
object : PacketCodec<BattleRankingEntry>() {
override fun CodecScope<BattleRankingEntry>.body(): BattleRankingEntry {
val entityId = field(S64LE) { it.entityId }
val flag1 = field(S8) { it.flag1 }
val flag2 = field(S8) { it.flag2 }
val name = field(de.fiereu.bytecodec.Utf16LeNullTerminated) { it.name }
val value1 = field(S16LE) { it.value1 }
val genderId = field(S16LE) { it.genderId }
field(S8) { 0 }
val ribbons = field(S64LE) { it.ribbons }
val byte1 = field(S8) { it.byte1 }
val int1 = field(S32LE) { it.int1 }
val byte2 = field(S8) { it.byte2 }
val bool1 = field(Bool) { it.bool1 }
val bool2 = field(Bool) { it.bool2 }
field(S8) { 0 }
return BattleRankingEntry(
entityId, flag1, flag2, name, value1, genderId, ribbons, byte1, int1, byte2, bool1,
bool2
)
}
override fun CodecScope<BattleRankingEntry>.body(): BattleRankingEntry {
val entityId = field(S64LE) { it.entityId }
val flag1 = field(S8) { it.flag1 }
val flag2 = field(S8) { it.flag2 }
val name = field(de.fiereu.bytecodec.Utf16LeNullTerminated) { it.name }
val value1 = field(S16LE) { it.value1 }
val genderId = field(S16LE) { it.genderId }
field(S8) { 0 }
val ribbons = field(S64LE) { it.ribbons }
val byte1 = field(S8) { it.byte1 }
val int1 = field(S32LE) { it.int1 }
val byte2 = field(S8) { it.byte2 }
val bool1 = field(Bool) { it.bool1 }
val bool2 = field(Bool) { it.bool2 }
field(S8) { 0 }
return BattleRankingEntry(
entityId,
flag1,
flag2,
name,
value1,
genderId,
ribbons,
byte1,
int1,
byte2,
bool1,
bool2)
}
}
data class BattleTierUpdate(
@@ -49,13 +58,13 @@ data class BattleTierUpdate(
private val BattleTierUpdateCodec: Codec<BattleTierUpdate> =
object : PacketCodec<BattleTierUpdate>() {
override fun CodecScope<BattleTierUpdate>.body(): BattleTierUpdate {
val tierIndex = field(S8) { it.tierIndex }
val unlocked = field(Bool) { it.unlocked }
val expiry = field(S64LE) { it.expiry }
field(S64LE) { 0L }
return BattleTierUpdate(tierIndex, unlocked, expiry)
}
override fun CodecScope<BattleTierUpdate>.body(): BattleTierUpdate {
val tierIndex = field(S8) { it.tierIndex }
val unlocked = field(Bool) { it.unlocked }
val expiry = field(S64LE) { it.expiry }
field(S64LE) { 0L }
return BattleTierUpdate(tierIndex, unlocked, expiry)
}
}
data class BattleMoveTarget(
@@ -71,34 +80,34 @@ data class BattleMoveTarget(
private val BattleMoveTargetCodec: Codec<BattleMoveTarget> =
object : PacketCodec<BattleMoveTarget>() {
override fun CodecScope<BattleMoveTarget>.body(): BattleMoveTarget {
val targetType = field(S8) { it.targetType }
return when (targetType.toInt()) {
0 -> {
val short1 = field(S16LE) { it.short1 }
val short2 = field(S16LE) { it.short2 }
val short3 = field(S16LE) { it.short3 }
BattleMoveTarget(targetType, short1, short2, short3, 0, 0, false, false)
}
override fun CodecScope<BattleMoveTarget>.body(): BattleMoveTarget {
val targetType = field(S8) { it.targetType }
return when (targetType.toInt()) {
0 -> {
val short1 = field(S16LE) { it.short1 }
val short2 = field(S16LE) { it.short2 }
val short3 = field(S16LE) { it.short3 }
BattleMoveTarget(targetType, short1, short2, short3, 0, 0, false, false)
}
1 -> {
val short1 = field(S16LE) { it.short1 }
field(S8) { 0 }
val byte1 = field(S8) { it.byte1 }
val byte2 = field(S8) { it.byte2 }
val flag1 = field(Bool) { it.flag1 }
val flag2 = field(Bool) { it.flag2 }
val short2 = field(S16LE) { it.short2 }
BattleMoveTarget(targetType, short1, short2, 0, byte1, byte2, flag1, flag2)
}
1 -> {
val short1 = field(S16LE) { it.short1 }
field(S8) { 0 }
val byte1 = field(S8) { it.byte1 }
val byte2 = field(S8) { it.byte2 }
val flag1 = field(Bool) { it.flag1 }
val flag2 = field(Bool) { it.flag2 }
val short2 = field(S16LE) { it.short2 }
BattleMoveTarget(targetType, short1, short2, 0, byte1, byte2, flag1, flag2)
}
else -> {
val short1 = field(S16LE) { it.short1 }
val short2 = field(S16LE) { it.short2 }
BattleMoveTarget(targetType, short1, short2, 0, 0, 0, false, false)
}
}
else -> {
val short1 = field(S16LE) { it.short1 }
val short2 = field(S16LE) { it.short2 }
BattleMoveTarget(targetType, short1, short2, 0, 0, 0, false, false)
}
}
}
}
data class BattleSelectablePokemon(
@@ -113,16 +122,16 @@ data class BattleSelectablePokemon(
private val BattleSelectablePokemonCodec: Codec<BattleSelectablePokemon> =
object : PacketCodec<BattleSelectablePokemon>() {
override fun CodecScope<BattleSelectablePokemon>.body(): BattleSelectablePokemon {
val int1 = field(S32LE) { it.int1 }
val int2 = field(S32LE) { it.int2 }
val short1 = field(S16LE) { it.short1 }
val short2 = field(S16LE) { it.short2 }
val tierIndex = field(S8) { it.tierIndex }
val targetsA = field(BattleMoveTargetCodec.listPrefixed(U8)) { it.targetsA }
val targetsB = field(BattleMoveTargetCodec.listPrefixed(U8)) { it.targetsB }
return BattleSelectablePokemon(int1, int2, short1, short2, tierIndex, targetsA, targetsB)
}
override fun CodecScope<BattleSelectablePokemon>.body(): BattleSelectablePokemon {
val int1 = field(S32LE) { it.int1 }
val int2 = field(S32LE) { it.int2 }
val short1 = field(S16LE) { it.short1 }
val short2 = field(S16LE) { it.short2 }
val tierIndex = field(S8) { it.tierIndex }
val targetsA = field(BattleMoveTargetCodec.listPrefixed(U8)) { it.targetsA }
val targetsB = field(BattleMoveTargetCodec.listPrefixed(U8)) { it.targetsB }
return BattleSelectablePokemon(int1, int2, short1, short2, tierIndex, targetsA, targetsB)
}
}
data class BattleStorageItem(
@@ -138,19 +147,18 @@ data class BattleStorageItem(
private val BattleStorageItemCodec: Codec<BattleStorageItem> =
object : PacketCodec<BattleStorageItem>() {
override fun CodecScope<BattleStorageItem>.body(): BattleStorageItem {
val typeByte = field(S8) { it.typeByte }
val short1 = field(S16LE) { it.short1 }
val short2 = field(S16LE) { it.short2 }
val short3 = field(S16LE) { it.short3 }
val short4 = field(S16LE) { it.short4 }
val byte1 = field(S8) { it.byte1 }
val pokemonByte = field(S8) { it.pokemonByte }
val boxByte = field(S8) { it.boxByte }
return BattleStorageItem(
typeByte, short1, short2, short3, short4, byte1, pokemonByte, boxByte
)
}
override fun CodecScope<BattleStorageItem>.body(): BattleStorageItem {
val typeByte = field(S8) { it.typeByte }
val short1 = field(S16LE) { it.short1 }
val short2 = field(S16LE) { it.short2 }
val short3 = field(S16LE) { it.short3 }
val short4 = field(S16LE) { it.short4 }
val byte1 = field(S8) { it.byte1 }
val pokemonByte = field(S8) { it.pokemonByte }
val boxByte = field(S8) { it.boxByte }
return BattleStorageItem(
typeByte, short1, short2, short3, short4, byte1, pokemonByte, boxByte)
}
}
data class BattleScreenOpenPacket(
@@ -163,24 +171,23 @@ data class BattleScreenOpenPacket(
)
object BattleScreenOpenPacketCodec : PacketCodec<BattleScreenOpenPacket>() {
override fun CodecScope<BattleScreenOpenPacket>.body(): BattleScreenOpenPacket {
val active = field(U8) { if (it.active) 1 else 0 } == 1
if (!active) {
return BattleScreenOpenPacket(
false, false, emptyList(), emptyList(), emptyList(), emptyList()
)
}
val wild = field(U8) { if (it.wild) 1 else 0 } == 1
var participants = emptyList<BattleRankingEntry>()
var tierUpdates = emptyList<BattleTierUpdate>()
var pokemon = emptyList<BattleSelectablePokemon>()
if (wild) {
participants = field(BattleRankingEntryCodec.listPrefixed(U8)) { it.participants }
} else {
tierUpdates = field(BattleTierUpdateCodec.listPrefixed(U8)) { it.tierUpdates }
pokemon = field(BattleSelectablePokemonCodec.listPrefixed(U8)) { it.pokemon }
}
val storageItems = field(BattleStorageItemCodec.listPrefixed(U8)) { it.storageItems }
return BattleScreenOpenPacket(active, wild, participants, tierUpdates, pokemon, storageItems)
override fun CodecScope<BattleScreenOpenPacket>.body(): BattleScreenOpenPacket {
val active = field(U8) { if (it.active) 1 else 0 } == 1
if (!active) {
return BattleScreenOpenPacket(
false, false, emptyList(), emptyList(), emptyList(), emptyList())
}
val wild = field(U8) { if (it.wild) 1 else 0 } == 1
var participants = emptyList<BattleRankingEntry>()
var tierUpdates = emptyList<BattleTierUpdate>()
var pokemon = emptyList<BattleSelectablePokemon>()
if (wild) {
participants = field(BattleRankingEntryCodec.listPrefixed(U8)) { it.participants }
} else {
tierUpdates = field(BattleTierUpdateCodec.listPrefixed(U8)) { it.tierUpdates }
pokemon = field(BattleSelectablePokemonCodec.listPrefixed(U8)) { it.pokemon }
}
val storageItems = field(BattleStorageItemCodec.listPrefixed(U8)) { it.storageItems }
return BattleScreenOpenPacket(active, wild, participants, tierUpdates, pokemon, storageItems)
}
}
@@ -22,27 +22,34 @@ data class BattleSendOutActivePacket(
)
object BattleSendOutActivePacketCodec : PacketCodec<BattleSendOutActivePacket>() {
override fun CodecScope<BattleSendOutActivePacket>.body(): BattleSendOutActivePacket {
val present = field(U8) { if (it.member != null) 1 else 0 }
if (present != 1) return BattleSendOutActivePacket(false, null)
val opponent = field(Bool) { it.opponent }
val entityIdA = field(S64LE) { it.member!!.entityIdA }
val entityIdB = field(S64LE) { it.member!!.entityIdB }
val entityIdC = field(S64LE) { it.member!!.entityIdC }
val speciesByte = field(S8) { it.member!!.speciesByte }
val nickname = if (!opponent) field(Utf16LeNullTerminated) { it.member!!.nickname } else ""
val ownerName = if (opponent) field(Utf16LeNullTerminated) { it.member!!.ownerName } else ""
val value = field(S32LE) { it.member!!.value }
val nameA = field(Utf16LeNullTerminated) { it.member!!.nameA }
val nameB = field(Utf16LeNullTerminated) { it.member!!.nameB }
val levelByte = field(S8) { it.member!!.levelByte }
val flag = field(Bool) { it.member!!.flag }
return BattleSendOutActivePacket(
opponent,
BattleSendOutMember(
entityIdA, entityIdB, entityIdC, speciesByte, nickname, ownerName, value, nameA, nameB,
levelByte, flag
)
)
}
override fun CodecScope<BattleSendOutActivePacket>.body(): BattleSendOutActivePacket {
val present = field(U8) { if (it.member != null) 1 else 0 }
if (present != 1) return BattleSendOutActivePacket(false, null)
val opponent = field(Bool) { it.opponent }
val entityIdA = field(S64LE) { it.member!!.entityIdA }
val entityIdB = field(S64LE) { it.member!!.entityIdB }
val entityIdC = field(S64LE) { it.member!!.entityIdC }
val speciesByte = field(S8) { it.member!!.speciesByte }
val nickname = if (!opponent) field(Utf16LeNullTerminated) { it.member!!.nickname } else ""
val ownerName = if (opponent) field(Utf16LeNullTerminated) { it.member!!.ownerName } else ""
val value = field(S32LE) { it.member!!.value }
val nameA = field(Utf16LeNullTerminated) { it.member!!.nameA }
val nameB = field(Utf16LeNullTerminated) { it.member!!.nameB }
val levelByte = field(S8) { it.member!!.levelByte }
val flag = field(Bool) { it.member!!.flag }
return BattleSendOutActivePacket(
opponent,
BattleSendOutMember(
entityIdA,
entityIdB,
entityIdC,
speciesByte,
nickname,
ownerName,
value,
nameA,
nameB,
levelByte,
flag))
}
}
@@ -20,32 +20,31 @@ data class BattleAddPokemon(
private val BattleAddPokemonCodec: Codec<BattleAddPokemon> =
object : PacketCodec<BattleAddPokemon>() {
override fun CodecScope<BattleAddPokemon>.body(): BattleAddPokemon {
val flags =
field(U8) {
(if (it.slot.toInt() != 0) 4 else 0) or
(if (it.partyIndex.toInt() != -1) 8 else 0) or
(if (it.statusEffect != null) 16 else 0)
}
val entityId = field(S64LE) { it.entityId }
if (flags and 1 != 0) field(S64LE) { 0L }
val frontSpriteId = field(S16LE) { it.frontSpriteId }
val backSpriteId = field(S16LE) { it.backSpriteId }
val side = field(S8) { it.side }
if (flags and 2 != 0) field(S8) { 0 }
val slot = if (flags and 4 != 0) field(S8) { it.slot } else 0
val partyIndex = if (flags and 8 != 0) field(S8) { it.partyIndex } else -1
val statusEffect =
if (flags and 16 != 0) {
val durationTurns = field(S32LE) { it.statusEffect!!.durationTurns }
val effectType = field(S8) { it.statusEffect!!.effectType }
val sourceSlot = field(S8) { it.statusEffect!!.sourceSlot }
BattleAddStatusEffect(durationTurns, effectType, sourceSlot)
} else null
return BattleAddPokemon(
entityId, frontSpriteId, backSpriteId, side, slot, partyIndex, statusEffect
)
}
override fun CodecScope<BattleAddPokemon>.body(): BattleAddPokemon {
val flags =
field(U8) {
(if (it.slot.toInt() != 0) 4 else 0) or
(if (it.partyIndex.toInt() != -1) 8 else 0) or
(if (it.statusEffect != null) 16 else 0)
}
val entityId = field(S64LE) { it.entityId }
if (flags and 1 != 0) field(S64LE) { 0L }
val frontSpriteId = field(S16LE) { it.frontSpriteId }
val backSpriteId = field(S16LE) { it.backSpriteId }
val side = field(S8) { it.side }
if (flags and 2 != 0) field(S8) { 0 }
val slot = if (flags and 4 != 0) field(S8) { it.slot } else 0
val partyIndex = if (flags and 8 != 0) field(S8) { it.partyIndex } else -1
val statusEffect =
if (flags and 16 != 0) {
val durationTurns = field(S32LE) { it.statusEffect!!.durationTurns }
val effectType = field(S8) { it.statusEffect!!.effectType }
val sourceSlot = field(S8) { it.statusEffect!!.sourceSlot }
BattleAddStatusEffect(durationTurns, effectType, sourceSlot)
} else null
return BattleAddPokemon(
entityId, frontSpriteId, backSpriteId, side, slot, partyIndex, statusEffect)
}
}
data class BattleSideAddPokemonPacket(
@@ -54,9 +53,9 @@ data class BattleSideAddPokemonPacket(
)
object BattleSideAddPokemonPacketCodec : PacketCodec<BattleSideAddPokemonPacket>() {
override fun CodecScope<BattleSideAddPokemonPacket>.body(): BattleSideAddPokemonPacket {
val side = field(S8) { it.side }
val pokemon = field(BattleAddPokemonCodec) { it.pokemon }
return BattleSideAddPokemonPacket(side, pokemon)
}
override fun CodecScope<BattleSideAddPokemonPacket>.body(): BattleSideAddPokemonPacket {
val side = field(S8) { it.side }
val pokemon = field(BattleAddPokemonCodec) { it.pokemon }
return BattleSideAddPokemonPacket(side, pokemon)
}
}
@@ -20,34 +20,33 @@ data class BattlePartyPokemon(
private val BattlePartyPokemonCodec: Codec<BattlePartyPokemon> =
object : PacketCodec<BattlePartyPokemon>() {
override fun CodecScope<BattlePartyPokemon>.body(): BattlePartyPokemon {
val flags =
field(U8) {
(if (false) 1 else 0) or
(if (false) 2 else 0) or
(if (it.slot.toInt() != 0) 4 else 0) or
(if (it.partyIndex.toInt() != -1) 8 else 0) or
(if (it.statusEffect != null) 16 else 0)
}
val entityId = field(S64LE) { it.entityId }
if (flags and 1 != 0) field(S64LE) { 0L }
val frontSpriteId = field(S16LE) { it.frontSpriteId }
val backSpriteId = field(S16LE) { it.backSpriteId }
val side = field(S8) { it.side }
if (flags and 2 != 0) field(S8) { 0 }
val slot = if (flags and 4 != 0) field(S8) { it.slot } else 0
val partyIndex = if (flags and 8 != 0) field(S8) { it.partyIndex } else -1
val statusEffect =
if (flags and 16 != 0) {
val durationTurns = field(S32LE) { it.statusEffect!!.durationTurns }
val effectType = field(S8) { it.statusEffect!!.effectType }
val sourceSlot = field(S8) { it.statusEffect!!.sourceSlot }
BattlePartyStatusEffect(durationTurns, effectType, sourceSlot)
} else null
return BattlePartyPokemon(
entityId, frontSpriteId, backSpriteId, side, slot, partyIndex, statusEffect
)
}
override fun CodecScope<BattlePartyPokemon>.body(): BattlePartyPokemon {
val flags =
field(U8) {
(if (false) 1 else 0) or
(if (false) 2 else 0) or
(if (it.slot.toInt() != 0) 4 else 0) or
(if (it.partyIndex.toInt() != -1) 8 else 0) or
(if (it.statusEffect != null) 16 else 0)
}
val entityId = field(S64LE) { it.entityId }
if (flags and 1 != 0) field(S64LE) { 0L }
val frontSpriteId = field(S16LE) { it.frontSpriteId }
val backSpriteId = field(S16LE) { it.backSpriteId }
val side = field(S8) { it.side }
if (flags and 2 != 0) field(S8) { 0 }
val slot = if (flags and 4 != 0) field(S8) { it.slot } else 0
val partyIndex = if (flags and 8 != 0) field(S8) { it.partyIndex } else -1
val statusEffect =
if (flags and 16 != 0) {
val durationTurns = field(S32LE) { it.statusEffect!!.durationTurns }
val effectType = field(S8) { it.statusEffect!!.effectType }
val sourceSlot = field(S8) { it.statusEffect!!.sourceSlot }
BattlePartyStatusEffect(durationTurns, effectType, sourceSlot)
} else null
return BattlePartyPokemon(
entityId, frontSpriteId, backSpriteId, side, slot, partyIndex, statusEffect)
}
}
data class BattleSidePartyPacket(
@@ -57,10 +56,10 @@ data class BattleSidePartyPacket(
)
object BattleSidePartyPacketCodec : PacketCodec<BattleSidePartyPacket>() {
override fun CodecScope<BattleSidePartyPacket>.body(): BattleSidePartyPacket {
val side = field(S8) { it.side }
val replace = field(U8) { if (it.replace) 1 else 0 } == 1
val pokemon = field(BattlePartyPokemonCodec.listPrefixed(U16LE)) { it.pokemon }
return BattleSidePartyPacket(side, replace, pokemon)
}
override fun CodecScope<BattleSidePartyPacket>.body(): BattleSidePartyPacket {
val side = field(S8) { it.side }
val replace = field(U8) { if (it.replace) 1 else 0 } == 1
val pokemon = field(BattlePartyPokemonCodec.listPrefixed(U16LE)) { it.pokemon }
return BattleSidePartyPacket(side, replace, pokemon)
}
}
@@ -11,9 +11,9 @@ data class BattleSideRemovePokemonPacket(
)
object BattleSideRemovePokemonPacketCodec : PacketCodec<BattleSideRemovePokemonPacket>() {
override fun CodecScope<BattleSideRemovePokemonPacket>.body(): BattleSideRemovePokemonPacket {
val side = field(S8) { it.side }
val entityId = field(S64LE) { it.entityId }
return BattleSideRemovePokemonPacket(side, entityId)
}
override fun CodecScope<BattleSideRemovePokemonPacket>.body(): BattleSideRemovePokemonPacket {
val side = field(S8) { it.side }
val entityId = field(S64LE) { it.entityId }
return BattleSideRemovePokemonPacket(side, entityId)
}
}
@@ -4,27 +4,28 @@ import de.fiereu.bytecodec.*
private val SimulationConfigPayload: Codec<ByteArray> =
object : Codec<ByteArray> {
override fun read(buf: ReadBuffer): ByteArray {
val arr = ByteArray(buf.remaining())
if (arr.isNotEmpty()) buf.readBytes(arr)
return arr
}
override fun read(buf: ReadBuffer): ByteArray {
val arr = ByteArray(buf.remaining())
if (arr.isNotEmpty()) buf.readBytes(arr)
return arr
}
override fun write(buf: WriteBuffer, value: ByteArray) {
if (value.isNotEmpty()) buf.writeBytes(value)
}
override fun write(buf: WriteBuffer, value: ByteArray) {
if (value.isNotEmpty()) buf.writeBytes(value)
}
}
data class BattleSimulationRequestPacket(val simulationConfig: ByteArray) {
override fun equals(other: Any?): Boolean =
other is BattleSimulationRequestPacket && simulationConfig.contentEquals(other.simulationConfig)
override fun equals(other: Any?): Boolean =
other is BattleSimulationRequestPacket &&
simulationConfig.contentEquals(other.simulationConfig)
override fun hashCode(): Int = simulationConfig.contentHashCode()
override fun hashCode(): Int = simulationConfig.contentHashCode()
}
object BattleSimulationRequestPacketCodec : PacketCodec<BattleSimulationRequestPacket>() {
override fun CodecScope<BattleSimulationRequestPacket>.body(): BattleSimulationRequestPacket {
val simulationConfig = field(SimulationConfigPayload) { it.simulationConfig }
return BattleSimulationRequestPacket(simulationConfig)
}
override fun CodecScope<BattleSimulationRequestPacket>.body(): BattleSimulationRequestPacket {
val simulationConfig = field(SimulationConfigPayload) { it.simulationConfig }
return BattleSimulationRequestPacket(simulationConfig)
}
}
@@ -10,9 +10,9 @@ data class BattleSlotActionPacket(
)
object BattleSlotActionPacketCodec : PacketCodec<BattleSlotActionPacket>() {
override fun CodecScope<BattleSlotActionPacket>.body(): BattleSlotActionPacket {
val slotRefPacked = field(S8) { it.slotRefPacked }
val actionByte = field(S8) { it.actionByte }
return BattleSlotActionPacket(slotRefPacked, actionByte)
}
override fun CodecScope<BattleSlotActionPacket>.body(): BattleSlotActionPacket {
val slotRefPacked = field(S8) { it.slotRefPacked }
val actionByte = field(S8) { it.actionByte }
return BattleSlotActionPacket(slotRefPacked, actionByte)
}
}
@@ -11,9 +11,9 @@ data class BattleSlotAnimationResetPacket(
)
object BattleSlotAnimationResetPacketCodec : PacketCodec<BattleSlotAnimationResetPacket>() {
override fun CodecScope<BattleSlotAnimationResetPacket>.body(): BattleSlotAnimationResetPacket {
val entityId = field(S64LE) { it.entityId }
val slot = field(S8) { it.slot }
return BattleSlotAnimationResetPacket(entityId, slot)
}
override fun CodecScope<BattleSlotAnimationResetPacket>.body(): BattleSlotAnimationResetPacket {
val entityId = field(S64LE) { it.entityId }
val slot = field(S8) { it.slot }
return BattleSlotAnimationResetPacket(entityId, slot)
}
}
@@ -10,9 +10,9 @@ data class BattleSlotEventEnumPacket(
)
object BattleSlotEventEnumPacketCodec : PacketCodec<BattleSlotEventEnumPacket>() {
override fun CodecScope<BattleSlotEventEnumPacket>.body(): BattleSlotEventEnumPacket {
val slot = field(S8) { it.slot }
val eventType = field(S8) { it.eventType }
return BattleSlotEventEnumPacket(slot, eventType)
}
override fun CodecScope<BattleSlotEventEnumPacket>.body(): BattleSlotEventEnumPacket {
val slot = field(S8) { it.slot }
val eventType = field(S8) { it.eventType }
return BattleSlotEventEnumPacket(slot, eventType)
}
}
@@ -12,10 +12,10 @@ data class BattleSlotFlagEventPacket(
)
object BattleSlotFlagEventPacketCodec : PacketCodec<BattleSlotFlagEventPacket>() {
override fun CodecScope<BattleSlotFlagEventPacket>.body(): BattleSlotFlagEventPacket {
val slot = field(S8) { it.slot }
val flag = field(Bool) { it.flag }
val immediate = field(Bool) { it.immediate }
return BattleSlotFlagEventPacket(slot, flag, immediate)
}
override fun CodecScope<BattleSlotFlagEventPacket>.body(): BattleSlotFlagEventPacket {
val slot = field(S8) { it.slot }
val flag = field(Bool) { it.flag }
val immediate = field(Bool) { it.immediate }
return BattleSlotFlagEventPacket(slot, flag, immediate)
}
}
@@ -12,10 +12,10 @@ data class BattleSlotMoveEventPacket(
)
object BattleSlotMoveEventPacketCodec : PacketCodec<BattleSlotMoveEventPacket>() {
override fun CodecScope<BattleSlotMoveEventPacket>.body(): BattleSlotMoveEventPacket {
val slot = field(S8) { it.slot }
val moveType = field(S8) { it.moveType }
val resolved = field(Bool) { it.resolved }
return BattleSlotMoveEventPacket(slot, moveType, resolved)
}
override fun CodecScope<BattleSlotMoveEventPacket>.body(): BattleSlotMoveEventPacket {
val slot = field(S8) { it.slot }
val moveType = field(S8) { it.moveType }
val resolved = field(Bool) { it.resolved }
return BattleSlotMoveEventPacket(slot, moveType, resolved)
}
}
@@ -12,10 +12,10 @@ data class BattleSlotSwitchEventPacket(
)
object BattleSlotSwitchEventPacketCodec : PacketCodec<BattleSlotSwitchEventPacket>() {
override fun CodecScope<BattleSlotSwitchEventPacket>.body(): BattleSlotSwitchEventPacket {
val slot = field(S8) { it.slot }
val switchType = field(S8) { it.switchType }
val immediate = field(Bool) { it.immediate }
return BattleSlotSwitchEventPacket(slot, switchType, immediate)
}
override fun CodecScope<BattleSlotSwitchEventPacket>.body(): BattleSlotSwitchEventPacket {
val slot = field(S8) { it.slot }
val switchType = field(S8) { it.switchType }
val immediate = field(Bool) { it.immediate }
return BattleSlotSwitchEventPacket(slot, switchType, immediate)
}
}
@@ -12,10 +12,10 @@ data class BattleStartScenePacket(
)
object BattleStartScenePacketCodec : PacketCodec<BattleStartScenePacket>() {
override fun CodecScope<BattleStartScenePacket>.body(): BattleStartScenePacket {
val battleType = field(S8) { it.battleType }
val doubleBattle = field(U8) { if (it.doubleBattle) 1 else 0 } == 1
val perspective = field(S8) { it.perspective }
return BattleStartScenePacket(battleType, doubleBattle, perspective)
}
override fun CodecScope<BattleStartScenePacket>.body(): BattleStartScenePacket {
val battleType = field(S8) { it.battleType }
val doubleBattle = field(U8) { if (it.doubleBattle) 1 else 0 } == 1
val perspective = field(S8) { it.perspective }
return BattleStartScenePacket(battleType, doubleBattle, perspective)
}
}
@@ -14,33 +14,33 @@ data class BattleStatCountersPacket(
)
object BattleStatCountersPacketCodec : PacketCodec<BattleStatCountersPacket>() {
override fun CodecScope<BattleStatCountersPacket>.body(): BattleStatCountersPacket {
val entityId = field(S64LE, BattleStatCountersPacket::entityId)
val baseCounter = field(S32LE, BattleStatCountersPacket::baseCounter)
val flags =
field(U8) {
(if (it.counter1 != null) 1 else 0) or
(if (it.counter2 != null) 2 else 0) or
(if (it.counter3 != null) 4 else 0) or
(if (it.counter4 != null) 8 else 0) or
(if (it.counter5 != null) 16 else 0) or
(if (it.counter6 != null) 32 else 0)
}
val counter1 = if (flags and 1 != 0) field(S32LE) { it.counter1!! } else null
val counter2 = if (flags and 2 != 0) field(S32LE) { it.counter2!! } else null
val counter3 = if (flags and 4 != 0) field(S32LE) { it.counter3!! } else null
val counter4 = if (flags and 8 != 0) field(S32LE) { it.counter4!! } else null
val counter5 = if (flags and 16 != 0) field(S32LE) { it.counter5!! } else null
val counter6 = if (flags and 32 != 0) field(S32LE) { it.counter6!! } else null
return BattleStatCountersPacket(
entityId,
baseCounter,
counter1,
counter2,
counter3,
counter4,
counter5,
counter6,
)
}
override fun CodecScope<BattleStatCountersPacket>.body(): BattleStatCountersPacket {
val entityId = field(S64LE, BattleStatCountersPacket::entityId)
val baseCounter = field(S32LE, BattleStatCountersPacket::baseCounter)
val flags =
field(U8) {
(if (it.counter1 != null) 1 else 0) or
(if (it.counter2 != null) 2 else 0) or
(if (it.counter3 != null) 4 else 0) or
(if (it.counter4 != null) 8 else 0) or
(if (it.counter5 != null) 16 else 0) or
(if (it.counter6 != null) 32 else 0)
}
val counter1 = if (flags and 1 != 0) field(S32LE) { it.counter1!! } else null
val counter2 = if (flags and 2 != 0) field(S32LE) { it.counter2!! } else null
val counter3 = if (flags and 4 != 0) field(S32LE) { it.counter3!! } else null
val counter4 = if (flags and 8 != 0) field(S32LE) { it.counter4!! } else null
val counter5 = if (flags and 16 != 0) field(S32LE) { it.counter5!! } else null
val counter6 = if (flags and 32 != 0) field(S32LE) { it.counter6!! } else null
return BattleStatCountersPacket(
entityId,
baseCounter,
counter1,
counter2,
counter3,
counter4,
counter5,
counter6,
)
}
}
@@ -11,12 +11,12 @@ data class BattleStatStagePacket(
)
object BattleStatStagePacketCodec : PacketCodec<BattleStatStagePacket>() {
override fun CodecScope<BattleStatStagePacket>.body(): BattleStatStagePacket {
val entityId = field(S64LE) { it.entityId }
val stat = field(S8) { it.stat }
val value = field(S16LE) { it.value }
val stage = field(S8) { it.stage }
val flags = field(S8) { it.flags }
return BattleStatStagePacket(entityId, stat, value, stage, flags)
}
override fun CodecScope<BattleStatStagePacket>.body(): BattleStatStagePacket {
val entityId = field(S64LE) { it.entityId }
val stat = field(S8) { it.stat }
val value = field(S16LE) { it.value }
val stage = field(S8) { it.stage }
val flags = field(S8) { it.flags }
return BattleStatStagePacket(entityId, stat, value, stage, flags)
}
}
@@ -9,8 +9,8 @@ data class BattleStateBytePacket(
)
object BattleStateBytePacketCodec : PacketCodec<BattleStateBytePacket>() {
override fun CodecScope<BattleStateBytePacket>.body(): BattleStateBytePacket {
val state = field(S8) { it.state }
return BattleStateBytePacket(state)
}
override fun CodecScope<BattleStateBytePacket>.body(): BattleStateBytePacket {
val state = field(S8) { it.state }
return BattleStateBytePacket(state)
}
}
@@ -11,9 +11,9 @@ data class BattleStateSlotIntPacket(
)
object BattleStateSlotIntPacketCodec : PacketCodec<BattleStateSlotIntPacket>() {
override fun CodecScope<BattleStateSlotIntPacket>.body(): BattleStateSlotIntPacket {
val index = field(S8) { it.index }
val value = field(S32LE) { it.value }
return BattleStateSlotIntPacket(index, value)
}
override fun CodecScope<BattleStateSlotIntPacket>.body(): BattleStateSlotIntPacket {
val index = field(S8) { it.index }
val value = field(S32LE) { it.value }
return BattleStateSlotIntPacket(index, value)
}
}
@@ -12,10 +12,10 @@ data class BattleStatusFlagPacket(
)
object BattleStatusFlagPacketCodec : PacketCodec<BattleStatusFlagPacket>() {
override fun CodecScope<BattleStatusFlagPacket>.body(): BattleStatusFlagPacket {
val scope = field(S8) { it.scope }
val flagId = field(S16LE) { it.flagId }
val flagValue = field(S16LE) { it.flagValue }
return BattleStatusFlagPacket(scope, flagId, flagValue)
}
override fun CodecScope<BattleStatusFlagPacket>.body(): BattleStatusFlagPacket {
val scope = field(S8) { it.scope }
val flagId = field(S16LE) { it.flagId }
val flagValue = field(S16LE) { it.flagValue }
return BattleStatusFlagPacket(scope, flagId, flagValue)
}
}
@@ -9,8 +9,8 @@ data class BattleSwitchPromptTogglePacket(
)
object BattleSwitchPromptTogglePacketCodec : PacketCodec<BattleSwitchPromptTogglePacket>() {
override fun CodecScope<BattleSwitchPromptTogglePacket>.body(): BattleSwitchPromptTogglePacket {
val shown = field(Bool) { it.shown }
return BattleSwitchPromptTogglePacket(shown)
}
override fun CodecScope<BattleSwitchPromptTogglePacket>.body(): BattleSwitchPromptTogglePacket {
val shown = field(Bool) { it.shown }
return BattleSwitchPromptTogglePacket(shown)
}
}
@@ -9,8 +9,8 @@ data class BattleSwitchSelectionsPacket(
private val SelectedEntityIdsCodec = S64LE.listPrefixed(U8)
object BattleSwitchSelectionsPacketCodec : PacketCodec<BattleSwitchSelectionsPacket>() {
override fun CodecScope<BattleSwitchSelectionsPacket>.body(): BattleSwitchSelectionsPacket {
val selectedEntityIds = field(SelectedEntityIdsCodec) { it.selectedEntityIds }
return BattleSwitchSelectionsPacket(selectedEntityIds)
}
override fun CodecScope<BattleSwitchSelectionsPacket>.body(): BattleSwitchSelectionsPacket {
val selectedEntityIds = field(SelectedEntityIdsCodec) { it.selectedEntityIds }
return BattleSwitchSelectionsPacket(selectedEntityIds)
}
}
@@ -9,8 +9,8 @@ data class BattleTargetPickPacket(
)
object BattleTargetPickPacketCodec : PacketCodec<BattleTargetPickPacket>() {
override fun CodecScope<BattleTargetPickPacket>.body(): BattleTargetPickPacket {
val targetEntityId = field(S64LE) { it.targetEntityId }
return BattleTargetPickPacket(targetEntityId)
}
override fun CodecScope<BattleTargetPickPacket>.body(): BattleTargetPickPacket {
val targetEntityId = field(S64LE) { it.targetEntityId }
return BattleTargetPickPacket(targetEntityId)
}
}
@@ -11,9 +11,9 @@ data class BattleTeamPreviewConfirmPacket(
)
object BattleTeamPreviewConfirmPacketCodec : PacketCodec<BattleTeamPreviewConfirmPacket>() {
override fun CodecScope<BattleTeamPreviewConfirmPacket>.body(): BattleTeamPreviewConfirmPacket {
val side = field(S16LE) { it.side }
val isOwnTeam = field(Bool) { it.isOwnTeam }
return BattleTeamPreviewConfirmPacket(side, isOwnTeam)
}
override fun CodecScope<BattleTeamPreviewConfirmPacket>.body(): BattleTeamPreviewConfirmPacket {
val side = field(S16LE) { it.side }
val isOwnTeam = field(Bool) { it.isOwnTeam }
return BattleTeamPreviewConfirmPacket(side, isOwnTeam)
}
}
@@ -20,23 +20,31 @@ private class BattlePreviewMemberCodec(
private val opponent: Boolean,
private val withDetails: Boolean,
) : PacketCodec<BattlePreviewMember>() {
override fun CodecScope<BattlePreviewMember>.body(): BattlePreviewMember {
val entityIdA = field(S64LE) { it.entityIdA }
val entityIdB = field(S64LE) { it.entityIdB }
val entityIdC = field(S64LE) { it.entityIdC }
val speciesByte = field(S8) { it.speciesByte }
val nickname = if (!opponent) field(Utf16LeNullTerminated) { it.nickname } else ""
val ownerName = if (opponent) field(Utf16LeNullTerminated) { it.ownerName } else ""
val value = field(S32LE) { it.value }
val nameA = field(Utf16LeNullTerminated) { it.nameA }
val nameB = if (withDetails) field(Utf16LeNullTerminated) { it.nameB } else ""
val levelByte = field(S8) { it.levelByte }
val flag = field(Bool) { it.flag }
return BattlePreviewMember(
entityIdA, entityIdB, entityIdC, speciesByte, nickname, ownerName, value, nameA, nameB,
levelByte, flag
)
}
override fun CodecScope<BattlePreviewMember>.body(): BattlePreviewMember {
val entityIdA = field(S64LE) { it.entityIdA }
val entityIdB = field(S64LE) { it.entityIdB }
val entityIdC = field(S64LE) { it.entityIdC }
val speciesByte = field(S8) { it.speciesByte }
val nickname = if (!opponent) field(Utf16LeNullTerminated) { it.nickname } else ""
val ownerName = if (opponent) field(Utf16LeNullTerminated) { it.ownerName } else ""
val value = field(S32LE) { it.value }
val nameA = field(Utf16LeNullTerminated) { it.nameA }
val nameB = if (withDetails) field(Utf16LeNullTerminated) { it.nameB } else ""
val levelByte = field(S8) { it.levelByte }
val flag = field(Bool) { it.flag }
return BattlePreviewMember(
entityIdA,
entityIdB,
entityIdC,
speciesByte,
nickname,
ownerName,
value,
nameA,
nameB,
levelByte,
flag)
}
}
data class BattleTeamPreviewListPacket(
@@ -46,12 +54,12 @@ data class BattleTeamPreviewListPacket(
)
object BattleTeamPreviewListPacketCodec : PacketCodec<BattleTeamPreviewListPacket>() {
override fun CodecScope<BattleTeamPreviewListPacket>.body(): BattleTeamPreviewListPacket {
val side = field(S16LE) { it.side }
val opponent = field(Bool) { it.opponent }
val memberCodec = BattlePreviewMemberCodec(opponent, false)
val count = field(S16LE) { it.members.size.toShort() }.toInt()
val members = (0 until count).map { i -> field(memberCodec) { it.members[i] } }
return BattleTeamPreviewListPacket(side, opponent, members)
}
override fun CodecScope<BattleTeamPreviewListPacket>.body(): BattleTeamPreviewListPacket {
val side = field(S16LE) { it.side }
val opponent = field(Bool) { it.opponent }
val memberCodec = BattlePreviewMemberCodec(opponent, false)
val count = field(S16LE) { it.members.size.toShort() }.toInt()
val members = (0 until count).map { i -> field(memberCodec) { it.members[i] } }
return BattleTeamPreviewListPacket(side, opponent, members)
}
}
@@ -7,9 +7,9 @@ import de.fiereu.bytecodec.S8
data class BattleTierSelectPacket(val pokemonSlotIndex: Byte, val tierIndex: Byte)
object BattleTierSelectPacketCodec : PacketCodec<BattleTierSelectPacket>() {
override fun CodecScope<BattleTierSelectPacket>.body(): BattleTierSelectPacket {
val pokemonSlotIndex = field(S8) { it.pokemonSlotIndex }
val tierIndex = field(S8) { it.tierIndex }
return BattleTierSelectPacket(pokemonSlotIndex, tierIndex)
}
override fun CodecScope<BattleTierSelectPacket>.body(): BattleTierSelectPacket {
val pokemonSlotIndex = field(S8) { it.pokemonSlotIndex }
val tierIndex = field(S8) { it.tierIndex }
return BattleTierSelectPacket(pokemonSlotIndex, tierIndex)
}
}
@@ -6,7 +6,7 @@ import de.fiereu.bytecodec.PacketCodec
class BattleTransitionReadyPacket
object BattleTransitionReadyPacketCodec : PacketCodec<BattleTransitionReadyPacket>() {
override fun CodecScope<BattleTransitionReadyPacket>.body(): BattleTransitionReadyPacket {
return BattleTransitionReadyPacket()
}
override fun CodecScope<BattleTransitionReadyPacket>.body(): BattleTransitionReadyPacket {
return BattleTransitionReadyPacket()
}
}
@@ -11,9 +11,9 @@ data class BattleUseItemPacket(
)
object BattleUseItemPacketCodec : PacketCodec<BattleUseItemPacket>() {
override fun CodecScope<BattleUseItemPacket>.body(): BattleUseItemPacket {
val pokemonEntityId = field(S64LE) { it.pokemonEntityId }
val quantity = field(S16LE) { it.quantity }
return BattleUseItemPacket(pokemonEntityId, quantity)
}
override fun CodecScope<BattleUseItemPacket>.body(): BattleUseItemPacket {
val pokemonEntityId = field(S64LE) { it.pokemonEntityId }
val quantity = field(S16LE) { it.quantity }
return BattleUseItemPacket(pokemonEntityId, quantity)
}
}
@@ -7,9 +7,9 @@ import de.fiereu.bytecodec.Utf16LeNullTerminated
data class BlockPlayerPacket(val username: String, val reason: String)
object BlockPlayerPacketCodec : PacketCodec<BlockPlayerPacket>() {
override fun CodecScope<BlockPlayerPacket>.body(): BlockPlayerPacket {
val username = field(Utf16LeNullTerminated) { it.username }
val reason = field(Utf16LeNullTerminated) { it.reason }
return BlockPlayerPacket(username, reason)
}
override fun CodecScope<BlockPlayerPacket>.body(): BlockPlayerPacket {
val username = field(Utf16LeNullTerminated) { it.username }
val reason = field(Utf16LeNullTerminated) { it.reason }
return BlockPlayerPacket(username, reason)
}
}
@@ -32,89 +32,89 @@ data class BreedingForecastPacket(
)
private object BreedingStatContributionCodec : PacketCodec<BreedingStatContribution>() {
override fun CodecScope<BreedingStatContribution>.body(): BreedingStatContribution {
val source = field(S8, BreedingStatContribution::source)
val weight = field(F32LE, BreedingStatContribution::weight)
val amount = field(S32LE, BreedingStatContribution::amount)
return BreedingStatContribution(source, weight, amount)
}
override fun CodecScope<BreedingStatContribution>.body(): BreedingStatContribution {
val source = field(S8, BreedingStatContribution::source)
val weight = field(F32LE, BreedingStatContribution::weight)
val amount = field(S32LE, BreedingStatContribution::amount)
return BreedingStatContribution(source, weight, amount)
}
}
private val BreedingStatContributionListPrefixedU8: Codec<List<BreedingStatContribution>> =
object : Codec<List<BreedingStatContribution>> {
override fun read(buf: ReadBuffer): List<BreedingStatContribution> {
val n = U8.read(buf)
return List(n) { BreedingStatContributionCodec.read(buf) }
}
override fun read(buf: ReadBuffer): List<BreedingStatContribution> {
val n = U8.read(buf)
return List(n) { BreedingStatContributionCodec.read(buf) }
}
override fun write(buf: WriteBuffer, value: List<BreedingStatContribution>) {
U8.write(buf, value.size)
value.forEach { BreedingStatContributionCodec.write(buf, it) }
}
override fun write(buf: WriteBuffer, value: List<BreedingStatContribution>) {
U8.write(buf, value.size)
value.forEach { BreedingStatContributionCodec.write(buf, it) }
}
}
private object BreedingStatEntryCodec : PacketCodec<BreedingStatEntry>() {
override fun CodecScope<BreedingStatEntry>.body(): BreedingStatEntry {
val guaranteed = field(Bool, BreedingStatEntry::guaranteed)
val statId = field(S16LE, BreedingStatEntry::statId)
val contributions =
field(BreedingStatContributionListPrefixedU8, BreedingStatEntry::contributions)
return BreedingStatEntry(guaranteed, statId, contributions)
}
override fun CodecScope<BreedingStatEntry>.body(): BreedingStatEntry {
val guaranteed = field(Bool, BreedingStatEntry::guaranteed)
val statId = field(S16LE, BreedingStatEntry::statId)
val contributions =
field(BreedingStatContributionListPrefixedU8, BreedingStatEntry::contributions)
return BreedingStatEntry(guaranteed, statId, contributions)
}
}
object BreedingForecastPacketCodec : PacketCodec<BreedingForecastPacket>() {
override fun CodecScope<BreedingForecastPacket>.body(): BreedingForecastPacket {
val parentA = field(S64LE, BreedingForecastPacket::parentA)
val parentB = field(S64LE, BreedingForecastPacket::parentB)
val hasPreview = field(Bool, BreedingForecastPacket::hasPreview)
if (!hasPreview) {
return BreedingForecastPacket(
parentA,
parentB,
hasPreview,
0,
0,
emptyList(),
emptyList(),
emptyList(),
emptyList(),
0,
0,
false,
0,
0,
)
}
val species = field(S16LE, BreedingForecastPacket::species)
val form = field(S8, BreedingForecastPacket::form)
val statCount = field(U8) { it.statEntries.size }
val statEntries = List(statCount) { i -> field(BreedingStatEntryCodec) { it.statEntries[i] } }
val shininessCount = field(U8) { it.shininessTypes.size }
val shininessTypes = List(shininessCount) { i -> field(S8) { it.shininessTypes[i] } }
val valueCount = field(U8) { it.valueIds.size }
val valueIds = List(valueCount) { i -> field(S16LE) { it.valueIds[i] } }
val valueSources = List(valueCount) { i -> field(S8) { it.valueSources[i] } }
val gender = field(S8, BreedingForecastPacket::gender)
val nature = field(S16LE, BreedingForecastPacket::nature)
val shiny = field(Bool, BreedingForecastPacket::shiny)
val cost = field(S32LE, BreedingForecastPacket::cost)
val secondaryCost = field(S32LE, BreedingForecastPacket::secondaryCost)
return BreedingForecastPacket(
parentA,
parentB,
hasPreview,
species,
form,
statEntries,
shininessTypes,
valueIds,
valueSources,
gender,
nature,
shiny,
cost,
secondaryCost,
)
override fun CodecScope<BreedingForecastPacket>.body(): BreedingForecastPacket {
val parentA = field(S64LE, BreedingForecastPacket::parentA)
val parentB = field(S64LE, BreedingForecastPacket::parentB)
val hasPreview = field(Bool, BreedingForecastPacket::hasPreview)
if (!hasPreview) {
return BreedingForecastPacket(
parentA,
parentB,
hasPreview,
0,
0,
emptyList(),
emptyList(),
emptyList(),
emptyList(),
0,
0,
false,
0,
0,
)
}
val species = field(S16LE, BreedingForecastPacket::species)
val form = field(S8, BreedingForecastPacket::form)
val statCount = field(U8) { it.statEntries.size }
val statEntries = List(statCount) { i -> field(BreedingStatEntryCodec) { it.statEntries[i] } }
val shininessCount = field(U8) { it.shininessTypes.size }
val shininessTypes = List(shininessCount) { i -> field(S8) { it.shininessTypes[i] } }
val valueCount = field(U8) { it.valueIds.size }
val valueIds = List(valueCount) { i -> field(S16LE) { it.valueIds[i] } }
val valueSources = List(valueCount) { i -> field(S8) { it.valueSources[i] } }
val gender = field(S8, BreedingForecastPacket::gender)
val nature = field(S16LE, BreedingForecastPacket::nature)
val shiny = field(Bool, BreedingForecastPacket::shiny)
val cost = field(S32LE, BreedingForecastPacket::cost)
val secondaryCost = field(S32LE, BreedingForecastPacket::secondaryCost)
return BreedingForecastPacket(
parentA,
parentB,
hasPreview,
species,
form,
statEntries,
shininessTypes,
valueIds,
valueSources,
gender,
nature,
shiny,
cost,
secondaryCost,
)
}
}
@@ -7,8 +7,8 @@ import de.fiereu.bytecodec.S8
data class ByteArgumentPacket(val value: Byte)
object ByteArgumentPacketCodec : PacketCodec<ByteArgumentPacket>() {
override fun CodecScope<ByteArgumentPacket>.body(): ByteArgumentPacket {
val value = field(S8) { it.value }
return ByteArgumentPacket(value)
}
override fun CodecScope<ByteArgumentPacket>.body(): ByteArgumentPacket {
val value = field(S8) { it.value }
return ByteArgumentPacket(value)
}
}
@@ -7,8 +7,8 @@ import de.fiereu.bytecodec.S8
data class ByteChoicePacket(val value: Byte)
object ByteChoicePacketCodec : PacketCodec<ByteChoicePacket>() {
override fun CodecScope<ByteChoicePacket>.body(): ByteChoicePacket {
val value = field(S8) { it.value }
return ByteChoicePacket(value)
}
override fun CodecScope<ByteChoicePacket>.body(): ByteChoicePacket {
val value = field(S8) { it.value }
return ByteChoicePacket(value)
}
}
@@ -9,8 +9,8 @@ data class CameraFollowEntityPacket(
)
object CameraFollowEntityPacketCodec : PacketCodec<CameraFollowEntityPacket>() {
override fun CodecScope<CameraFollowEntityPacket>.body(): CameraFollowEntityPacket {
val entityId = field(S64LE) { it.entityId }
return CameraFollowEntityPacket(entityId)
}
override fun CodecScope<CameraFollowEntityPacket>.body(): CameraFollowEntityPacket {
val entityId = field(S64LE) { it.entityId }
return CameraFollowEntityPacket(entityId)
}
}
@@ -9,8 +9,8 @@ data class CancelEntityMessagePacket(
)
object CancelEntityMessagePacketCodec : PacketCodec<CancelEntityMessagePacket>() {
override fun CodecScope<CancelEntityMessagePacket>.body(): CancelEntityMessagePacket {
val entityId = field(S64LE) { it.entityId }
return CancelEntityMessagePacket(entityId)
}
override fun CodecScope<CancelEntityMessagePacket>.body(): CancelEntityMessagePacket {
val entityId = field(S64LE) { it.entityId }
return CancelEntityMessagePacket(entityId)
}
}
@@ -6,7 +6,7 @@ import de.fiereu.bytecodec.PacketCodec
class CancelMatchmakingSearchPacket
object CancelMatchmakingSearchPacketCodec : PacketCodec<CancelMatchmakingSearchPacket>() {
override fun CodecScope<CancelMatchmakingSearchPacket>.body(): CancelMatchmakingSearchPacket {
return CancelMatchmakingSearchPacket()
}
override fun CodecScope<CancelMatchmakingSearchPacket>.body(): CancelMatchmakingSearchPacket {
return CancelMatchmakingSearchPacket()
}
}
@@ -6,7 +6,7 @@ import de.fiereu.bytecodec.PacketCodec
class CancelSocialInteractionPacket
object CancelSocialInteractionPacketCodec : PacketCodec<CancelSocialInteractionPacket>() {
override fun CodecScope<CancelSocialInteractionPacket>.body(): CancelSocialInteractionPacket {
return CancelSocialInteractionPacket()
}
override fun CodecScope<CancelSocialInteractionPacket>.body(): CancelSocialInteractionPacket {
return CancelSocialInteractionPacket()
}
}
@@ -7,25 +7,25 @@ data class CategoryFlagsPacket(
val timestampMillis: Long,
val flagBits: ByteArray,
) {
override fun equals(other: Any?): Boolean =
other is CategoryFlagsPacket &&
entryKind == other.entryKind &&
timestampMillis == other.timestampMillis &&
flagBits.contentEquals(other.flagBits)
override fun equals(other: Any?): Boolean =
other is CategoryFlagsPacket &&
entryKind == other.entryKind &&
timestampMillis == other.timestampMillis &&
flagBits.contentEquals(other.flagBits)
override fun hashCode(): Int {
var r = entryKind
r = r * 31 + timestampMillis.hashCode()
r = r * 31 + flagBits.contentHashCode()
return r
}
override fun hashCode(): Int {
var r = entryKind
r = r * 31 + timestampMillis.hashCode()
r = r * 31 + flagBits.contentHashCode()
return r
}
}
object CategoryFlagsPacketCodec : PacketCodec<CategoryFlagsPacket>() {
override fun CodecScope<CategoryFlagsPacket>.body(): CategoryFlagsPacket {
val entryKind = field(U8) { it.entryKind }
val timestampMillis = field(S64LE) { it.timestampMillis }
val flagBits = field(bytesPrefixed(U16LE)) { it.flagBits }
return CategoryFlagsPacket(entryKind, timestampMillis, flagBits)
}
override fun CodecScope<CategoryFlagsPacket>.body(): CategoryFlagsPacket {
val entryKind = field(U8) { it.entryKind }
val timestampMillis = field(S64LE) { it.timestampMillis }
val flagBits = field(bytesPrefixed(U16LE)) { it.flagBits }
return CategoryFlagsPacket(entryKind, timestampMillis, flagBits)
}
}
@@ -13,26 +13,26 @@ data class ChannelAssignmentsPacket(
private val ChannelTypeBindingCodec: Codec<ChannelTypeBinding> =
object : PacketCodec<ChannelTypeBinding>() {
override fun CodecScope<ChannelTypeBinding>.body(): ChannelTypeBinding {
val chatType = field(S16LE) { it.chatType }
val channel = field(S8) { it.channel }
return ChannelTypeBinding(chatType, channel)
}
override fun CodecScope<ChannelTypeBinding>.body(): ChannelTypeBinding {
val chatType = field(S16LE) { it.chatType }
val channel = field(S8) { it.channel }
return ChannelTypeBinding(chatType, channel)
}
}
private val ChannelGroupBindingCodec: Codec<ChannelGroupBinding> =
object : PacketCodec<ChannelGroupBinding>() {
override fun CodecScope<ChannelGroupBinding>.body(): ChannelGroupBinding {
val channel = field(S8) { it.channel }
val members = field(S16LE.listPrefixed(U16LE)) { it.members }
return ChannelGroupBinding(channel, members)
}
override fun CodecScope<ChannelGroupBinding>.body(): ChannelGroupBinding {
val channel = field(S8) { it.channel }
val members = field(S16LE.listPrefixed(U16LE)) { it.members }
return ChannelGroupBinding(channel, members)
}
}
object ChannelAssignmentsPacketCodec : PacketCodec<ChannelAssignmentsPacket>() {
override fun CodecScope<ChannelAssignmentsPacket>.body(): ChannelAssignmentsPacket {
val typeBindings = field(ChannelTypeBindingCodec.listPrefixed(U16LE)) { it.typeBindings }
val groupBindings = field(ChannelGroupBindingCodec.listPrefixed(U8)) { it.groupBindings }
return ChannelAssignmentsPacket(typeBindings, groupBindings)
}
override fun CodecScope<ChannelAssignmentsPacket>.body(): ChannelAssignmentsPacket {
val typeBindings = field(ChannelTypeBindingCodec.listPrefixed(U16LE)) { it.typeBindings }
val groupBindings = field(ChannelGroupBindingCodec.listPrefixed(U8)) { it.groupBindings }
return ChannelAssignmentsPacket(typeBindings, groupBindings)
}
}
@@ -15,19 +15,19 @@ data class ChannelCountDeltaPacket(
private val ChannelCountEntryCodec: Codec<ChannelCountEntry> =
object : PacketCodec<ChannelCountEntry>() {
override fun CodecScope<ChannelCountEntry>.body(): ChannelCountEntry {
val channelId = field(S16LE) { it.channelId }
val flag = field(Bool) { it.flag }
return ChannelCountEntry(channelId, flag)
}
override fun CodecScope<ChannelCountEntry>.body(): ChannelCountEntry {
val channelId = field(S16LE) { it.channelId }
val flag = field(Bool) { it.flag }
return ChannelCountEntry(channelId, flag)
}
}
object ChannelCountDeltaPacketCodec : PacketCodec<ChannelCountDeltaPacket>() {
override fun CodecScope<ChannelCountDeltaPacket>.body(): ChannelCountDeltaPacket {
val category = field(S8) { it.category }
val count = field(U8) { it.entries.size }
val entries = (0 until count).map { i -> field(ChannelCountEntryCodec) { it.entries[i] } }
val delta = field(S8) { it.delta }
return ChannelCountDeltaPacket(category, entries, delta)
}
override fun CodecScope<ChannelCountDeltaPacket>.body(): ChannelCountDeltaPacket {
val category = field(S8) { it.category }
val count = field(U8) { it.entries.size }
val entries = (0 until count).map { i -> field(ChannelCountEntryCodec) { it.entries[i] } }
val delta = field(S8) { it.delta }
return ChannelCountDeltaPacket(category, entries, delta)
}
}
@@ -8,9 +8,9 @@ import de.fiereu.bytecodec.S8
data class ChannelSwitchPacket(val channelId: Byte, val silent: Boolean)
object ChannelSwitchPacketCodec : PacketCodec<ChannelSwitchPacket>() {
override fun CodecScope<ChannelSwitchPacket>.body(): ChannelSwitchPacket {
val channelId = field(S8) { it.channelId }
val silent = field(Bool) { it.silent }
return ChannelSwitchPacket(channelId, silent)
}
override fun CodecScope<ChannelSwitchPacket>.body(): ChannelSwitchPacket {
val channelId = field(S8) { it.channelId }
val silent = field(Bool) { it.silent }
return ChannelSwitchPacket(channelId, silent)
}
}
@@ -14,38 +14,39 @@ data class CharacterAppearanceApplyPacket(
)
object CharacterAppearanceApplyPacketCodec : PacketCodec<CharacterAppearanceApplyPacket>() {
override fun CodecScope<CharacterAppearanceApplyPacket>.body(): CharacterAppearanceApplyPacket {
val characterName = field(Utf16LeNullTerminated) { it.characterName }
val appearanceTypeA = field(S8) { it.appearanceTypeA }
val appearanceTypeB = field(S8) { it.appearanceTypeB }
override fun CodecScope<CharacterAppearanceApplyPacket>.body(): CharacterAppearanceApplyPacket {
val characterName = field(Utf16LeNullTerminated) { it.characterName }
val appearanceTypeA = field(S8) { it.appearanceTypeA }
val appearanceTypeB = field(S8) { it.appearanceTypeB }
val categoryByte = field(S8) { it.creatureMoves.categoryByte }
val bitmask =
field(S16LE) {
var m = 0
for (move in it.creatureMoves.moves) {
m = m or (1 shl move.slot)
if (move.ppUp != null) m = m or 0x8000
}
m.toShort()
}
val mask = bitmask.toInt() and 0xFFFF
val hasPp = (mask and 0x8000) != 0
val moves = mutableListOf<AppearanceMoveEntry>()
for (slot in 0 until 15) {
if (mask and (1 shl slot) != 0) {
val packed = field(S16LE) { v -> v.creatureMoves.moves.first { it.slot == slot }.packedMove }
val pp: Byte? =
if (hasPp) field(S8) { v -> v.creatureMoves.moves.first { it.slot == slot }.ppUp ?: 0 }
else null
moves.add(AppearanceMoveEntry(slot, packed, pp))
}
val categoryByte = field(S8) { it.creatureMoves.categoryByte }
val bitmask =
field(S16LE) {
var m = 0
for (move in it.creatureMoves.moves) {
m = m or (1 shl move.slot)
if (move.ppUp != null) m = m or 0x8000
}
m.toShort()
}
return CharacterAppearanceApplyPacket(
characterName,
appearanceTypeA,
appearanceTypeB,
AppearanceMoveSet(categoryByte, moves),
)
val mask = bitmask.toInt() and 0xFFFF
val hasPp = (mask and 0x8000) != 0
val moves = mutableListOf<AppearanceMoveEntry>()
for (slot in 0 until 15) {
if (mask and (1 shl slot) != 0) {
val packed =
field(S16LE) { v -> v.creatureMoves.moves.first { it.slot == slot }.packedMove }
val pp: Byte? =
if (hasPp) field(S8) { v -> v.creatureMoves.moves.first { it.slot == slot }.ppUp ?: 0 }
else null
moves.add(AppearanceMoveEntry(slot, packed, pp))
}
}
return CharacterAppearanceApplyPacket(
characterName,
appearanceTypeA,
appearanceTypeB,
AppearanceMoveSet(categoryByte, moves),
)
}
}
@@ -11,57 +11,57 @@ data class CharacterEntry(
val guildId: Int? = null,
val pokemon: List<Pokemon>,
) {
init {
require(pokemon.size <= 6) { "Party size can't be more than 6 pokemon" }
}
init {
require(pokemon.size <= 6) { "Party size can't be more than 6 pokemon" }
}
}
data class CharactersListPacket(val characters: List<CharacterEntry>)
private val CharacterInfoAsymmetric: Codec<CharacterInfo> =
object : Codec<CharacterInfo> {
override fun read(buf: ReadBuffer): CharacterInfo = CharacterInfoCodecLong.read(buf)
override fun read(buf: ReadBuffer): CharacterInfo = CharacterInfoCodecLong.read(buf)
override fun write(buf: WriteBuffer, value: CharacterInfo) {
CharacterInfoCodecShort.write(buf, value)
}
override fun write(buf: WriteBuffer, value: CharacterInfo) {
CharacterInfoCodecShort.write(buf, value)
}
}
private object CharacterEntryCodec : PacketCodec<CharacterEntry>() {
override fun CodecScope<CharacterEntry>.body(): CharacterEntry {
val info = field(CharacterInfoAsymmetric, CharacterEntry::characterInfo)
val skin = field(DefaultSkinSetCodec, CharacterEntry::skinSet)
field(SkinSetCodecNoLeading, CharacterEntry::skinSet)
val hasGuild = field(Bool) { it.guildId != null }
val guildId =
if (hasGuild) {
field(Utf16LeNullTerminated) { "" }
field(S32LE) { it.guildId!! }
} else {
null
}
val partySize = field(U8) { it.pokemon.size }
val party = List(partySize) { field(PokemonCodec) { entry -> entry.pokemon[it] } }
return CharacterEntry(info, skin, guildId, party)
}
override fun CodecScope<CharacterEntry>.body(): CharacterEntry {
val info = field(CharacterInfoAsymmetric, CharacterEntry::characterInfo)
val skin = field(DefaultSkinSetCodec, CharacterEntry::skinSet)
field(SkinSetCodecNoLeading, CharacterEntry::skinSet)
val hasGuild = field(Bool) { it.guildId != null }
val guildId =
if (hasGuild) {
field(Utf16LeNullTerminated) { "" }
field(S32LE) { it.guildId!! }
} else {
null
}
val partySize = field(U8) { it.pokemon.size }
val party = List(partySize) { field(PokemonCodec) { entry -> entry.pokemon[it] } }
return CharacterEntry(info, skin, guildId, party)
}
}
private val CharacterEntryListPrefixedU8: Codec<List<CharacterEntry>> =
object : Codec<List<CharacterEntry>> {
override fun read(buf: ReadBuffer): List<CharacterEntry> {
val n = U8.read(buf)
return List(n) { CharacterEntryCodec.read(buf) }
}
override fun read(buf: ReadBuffer): List<CharacterEntry> {
val n = U8.read(buf)
return List(n) { CharacterEntryCodec.read(buf) }
}
override fun write(buf: WriteBuffer, value: List<CharacterEntry>) {
U8.write(buf, value.size)
value.forEach { CharacterEntryCodec.write(buf, it) }
}
override fun write(buf: WriteBuffer, value: List<CharacterEntry>) {
U8.write(buf, value.size)
value.forEach { CharacterEntryCodec.write(buf, it) }
}
}
object CharactersListPacketCodec : PacketCodec<CharactersListPacket>() {
override fun CodecScope<CharactersListPacket>.body() =
CharactersListPacket(
characters = field(CharacterEntryListPrefixedU8, CharactersListPacket::characters),
)
override fun CodecScope<CharactersListPacket>.body() =
CharactersListPacket(
characters = field(CharacterEntryListPrefixedU8, CharactersListPacket::characters),
)
}
@@ -10,11 +10,11 @@ data class ChatChannelMessagesPacket(
)
object ChatChannelMessagesPacketCodec : PacketCodec<ChatChannelMessagesPacket>() {
override fun CodecScope<ChatChannelMessagesPacket>.body(): ChatChannelMessagesPacket {
val channelType = field(S8, ChatChannelMessagesPacket::channelType)
val clear = field(Bool, ChatChannelMessagesPacket::clear)
val refresh = field(Bool, ChatChannelMessagesPacket::refresh)
val messageCount = field(U16LE, ChatChannelMessagesPacket::messageCount)
return ChatChannelMessagesPacket(channelType, clear, refresh, messageCount)
}
override fun CodecScope<ChatChannelMessagesPacket>.body(): ChatChannelMessagesPacket {
val channelType = field(S8, ChatChannelMessagesPacket::channelType)
val clear = field(Bool, ChatChannelMessagesPacket::clear)
val refresh = field(Bool, ChatChannelMessagesPacket::refresh)
val messageCount = field(U16LE, ChatChannelMessagesPacket::messageCount)
return ChatChannelMessagesPacket(channelType, clear, refresh, messageCount)
}
}
@@ -18,29 +18,29 @@ data class ChatChannelUserListPacket(
private val ChatChannelUserCodec: Codec<ChatChannelUser> =
object : PacketCodec<ChatChannelUser>() {
override fun CodecScope<ChatChannelUser>.body(): ChatChannelUser {
val channelId = field(S16LE) { it.channelId }
val rank = field(S8) { it.rank }
return ChatChannelUser(channelId, rank)
}
override fun CodecScope<ChatChannelUser>.body(): ChatChannelUser {
val channelId = field(S16LE) { it.channelId }
val rank = field(S8) { it.rank }
return ChatChannelUser(channelId, rank)
}
}
object ChatChannelUserListPacketCodec : PacketCodec<ChatChannelUserListPacket>() {
override fun CodecScope<ChatChannelUserListPacket>.body(): ChatChannelUserListPacket {
val channelType = field(S8) { it.channelType }
val clear = field(Bool) { it.clear }
val refresh = field(Bool) { it.refresh }
val unreadCount = if (clear) field(S32LE) { it.unreadCount } else 0
val unreadMentionCount = if (clear) field(S32LE) { it.unreadMentionCount } else 0
val count = field(S16LE) { it.users.size.toShort() }.toInt() and 0xFFFF
val users = (0 until count).map { i -> field(ChatChannelUserCodec) { it.users[i] } }
return ChatChannelUserListPacket(
channelType = channelType,
clear = clear,
refresh = refresh,
unreadCount = unreadCount,
unreadMentionCount = unreadMentionCount,
users = users,
)
}
override fun CodecScope<ChatChannelUserListPacket>.body(): ChatChannelUserListPacket {
val channelType = field(S8) { it.channelType }
val clear = field(Bool) { it.clear }
val refresh = field(Bool) { it.refresh }
val unreadCount = if (clear) field(S32LE) { it.unreadCount } else 0
val unreadMentionCount = if (clear) field(S32LE) { it.unreadMentionCount } else 0
val count = field(S16LE) { it.users.size.toShort() }.toInt() and 0xFFFF
val users = (0 until count).map { i -> field(ChatChannelUserCodec) { it.users[i] } }
return ChatChannelUserListPacket(
channelType = channelType,
clear = clear,
refresh = refresh,
unreadCount = unreadCount,
unreadMentionCount = unreadMentionCount,
users = users,
)
}
}
@@ -12,10 +12,10 @@ data class ChatLocalePreferencesPacket(
)
object ChatLocalePreferencesPacketCodec : PacketCodec<ChatLocalePreferencesPacket>() {
override fun CodecScope<ChatLocalePreferencesPacket>.body(): ChatLocalePreferencesPacket {
val languageId = field(S8) { it.languageId }
val chatChannelMask = field(S16LE) { it.chatChannelMask }
val languageFilterMask = field(S16LE) { it.languageFilterMask }
return ChatLocalePreferencesPacket(languageId, chatChannelMask, languageFilterMask)
}
override fun CodecScope<ChatLocalePreferencesPacket>.body(): ChatLocalePreferencesPacket {
val languageId = field(S8) { it.languageId }
val chatChannelMask = field(S16LE) { it.chatChannelMask }
val languageFilterMask = field(S16LE) { it.languageFilterMask }
return ChatLocalePreferencesPacket(languageId, chatChannelMask, languageFilterMask)
}
}
@@ -12,35 +12,35 @@ data class ChatMessagePacket(
)
object ChatMessagePacketCodec : PacketCodec<ChatMessagePacket>() {
override fun CodecScope<ChatMessagePacket>.body(): ChatMessagePacket {
val type = ChatType.entries[field(U8) { it.type.ordinal }]
return if (type == ChatType.TEAM) {
ChatMessagePacket(
type = type,
language = null,
message = field(Utf16LeNullTerminated, ChatMessagePacket::message),
sender = null,
)
} else {
field(S64LE) { 0L }
val sender =
field(Utf16LeNullTerminated) {
it.sender ?: throw MalformedPacketException("sender must not be null")
}
val language =
Language.entries[
field(U8) {
(it.language ?: throw MalformedPacketException("language must not be null"))
.ordinal
}]
field(S8) { -1 }
val message = field(Utf16LeNullTerminated, ChatMessagePacket::message)
ChatMessagePacket(
type = type,
language = language,
message = message,
sender = sender,
)
}
override fun CodecScope<ChatMessagePacket>.body(): ChatMessagePacket {
val type = ChatType.entries[field(U8) { it.type.ordinal }]
return if (type == ChatType.TEAM) {
ChatMessagePacket(
type = type,
language = null,
message = field(Utf16LeNullTerminated, ChatMessagePacket::message),
sender = null,
)
} else {
field(S64LE) { 0L }
val sender =
field(Utf16LeNullTerminated) {
it.sender ?: throw MalformedPacketException("sender must not be null")
}
val language =
Language.entries[
field(U8) {
(it.language ?: throw MalformedPacketException("language must not be null"))
.ordinal
}]
field(S8) { -1 }
val message = field(Utf16LeNullTerminated, ChatMessagePacket::message)
ChatMessagePacket(
type = type,
language = language,
message = message,
sender = sender,
)
}
}
}
@@ -12,11 +12,10 @@ data class ChatMessageSendPacket(
)
object ChatMessageSendPacketCodec : PacketCodec<ChatMessageSendPacket>() {
override fun CodecScope<ChatMessageSendPacket>.body(): ChatMessageSendPacket {
val mode = field(S8) { it.mode }
val target = field(Utf16LeNullTerminated) { it.target }
val message =
if (mode.toInt() == 4) field(Utf16LeNullTerminated) { it.message ?: "" } else null
return ChatMessageSendPacket(mode, target, message)
}
override fun CodecScope<ChatMessageSendPacket>.body(): ChatMessageSendPacket {
val mode = field(S8) { it.mode }
val target = field(Utf16LeNullTerminated) { it.target }
val message = if (mode.toInt() == 4) field(Utf16LeNullTerminated) { it.message ?: "" } else null
return ChatMessageSendPacket(mode, target, message)
}
}
@@ -9,8 +9,8 @@ data class ChatMessageWithdrawPacket(
)
object ChatMessageWithdrawPacketCodec : PacketCodec<ChatMessageWithdrawPacket>() {
override fun CodecScope<ChatMessageWithdrawPacket>.body(): ChatMessageWithdrawPacket {
val authorId = field(S64LE) { it.authorId }
return ChatMessageWithdrawPacket(authorId)
}
override fun CodecScope<ChatMessageWithdrawPacket>.body(): ChatMessageWithdrawPacket {
val authorId = field(S64LE) { it.authorId }
return ChatMessageWithdrawPacket(authorId)
}
}
@@ -9,33 +9,33 @@ data class ChunkedImagePacket(
val last: Boolean?,
val data: ByteArray?,
) {
override fun equals(other: Any?): Boolean =
other is ChunkedImagePacket &&
controlType == other.controlType &&
imageType == other.imageType &&
chunkIndex == other.chunkIndex &&
last == other.last &&
(if (data == null) other.data == null
else other.data != null && data.contentEquals(other.data))
override fun equals(other: Any?): Boolean =
other is ChunkedImagePacket &&
controlType == other.controlType &&
imageType == other.imageType &&
chunkIndex == other.chunkIndex &&
last == other.last &&
(if (data == null) other.data == null
else other.data != null && data.contentEquals(other.data))
override fun hashCode(): Int {
var r = controlType.toInt()
r = r * 31 + (imageType?.toInt() ?: 0)
r = r * 31 + (chunkIndex ?: 0)
r = r * 31 + (last?.hashCode() ?: 0)
r = r * 31 + (data?.contentHashCode() ?: 0)
return r
}
override fun hashCode(): Int {
var r = controlType.toInt()
r = r * 31 + (imageType?.toInt() ?: 0)
r = r * 31 + (chunkIndex ?: 0)
r = r * 31 + (last?.hashCode() ?: 0)
r = r * 31 + (data?.contentHashCode() ?: 0)
return r
}
}
object ChunkedImagePacketCodec : PacketCodec<ChunkedImagePacket>() {
override fun CodecScope<ChunkedImagePacket>.body(): ChunkedImagePacket {
val controlType = field(S8) { it.controlType }
val present = controlType.toInt() != 2
val imageType = if (present) field(S8) { it.imageType!! } else null
val chunkIndex = if (present) field(U8) { it.chunkIndex!! } else null
val last = if (present) field(U8) { if (it.last!!) 1 else 0 } == 1 else null
val data = if (present) field(bytesPrefixed(U16LE)) { it.data!! } else null
return ChunkedImagePacket(controlType, imageType, chunkIndex, last, data)
}
override fun CodecScope<ChunkedImagePacket>.body(): ChunkedImagePacket {
val controlType = field(S8) { it.controlType }
val present = controlType.toInt() != 2
val imageType = if (present) field(S8) { it.imageType!! } else null
val chunkIndex = if (present) field(U8) { it.chunkIndex!! } else null
val last = if (present) field(U8) { if (it.last!!) 1 else 0 } == 1 else null
val data = if (present) field(bytesPrefixed(U16LE)) { it.data!! } else null
return ChunkedImagePacket(controlType, imageType, chunkIndex, last, data)
}
}
@@ -8,15 +8,15 @@ import de.fiereu.bytecodec.bytesPrefixed
data class ChunkedTransferAppendPacket(
val data: ByteArray,
) {
override fun equals(other: Any?): Boolean =
other is ChunkedTransferAppendPacket && data.contentEquals(other.data)
override fun equals(other: Any?): Boolean =
other is ChunkedTransferAppendPacket && data.contentEquals(other.data)
override fun hashCode(): Int = data.contentHashCode()
override fun hashCode(): Int = data.contentHashCode()
}
object ChunkedTransferAppendPacketCodec : PacketCodec<ChunkedTransferAppendPacket>() {
override fun CodecScope<ChunkedTransferAppendPacket>.body(): ChunkedTransferAppendPacket {
val data = field(bytesPrefixed(U16LE)) { it.data }
return ChunkedTransferAppendPacket(data)
}
override fun CodecScope<ChunkedTransferAppendPacket>.body(): ChunkedTransferAppendPacket {
val data = field(bytesPrefixed(U16LE)) { it.data }
return ChunkedTransferAppendPacket(data)
}
}
@@ -7,25 +7,25 @@ data class ChunkedTransferBeginPacket(
val totalSize: Int,
val data: ByteArray,
) {
override fun equals(other: Any?): Boolean =
other is ChunkedTransferBeginPacket &&
transferId == other.transferId &&
totalSize == other.totalSize &&
data.contentEquals(other.data)
override fun equals(other: Any?): Boolean =
other is ChunkedTransferBeginPacket &&
transferId == other.transferId &&
totalSize == other.totalSize &&
data.contentEquals(other.data)
override fun hashCode(): Int {
var r = transferId.hashCode()
r = r * 31 + totalSize
r = r * 31 + data.contentHashCode()
return r
}
override fun hashCode(): Int {
var r = transferId.hashCode()
r = r * 31 + totalSize
r = r * 31 + data.contentHashCode()
return r
}
}
object ChunkedTransferBeginPacketCodec : PacketCodec<ChunkedTransferBeginPacket>() {
override fun CodecScope<ChunkedTransferBeginPacket>.body(): ChunkedTransferBeginPacket {
val transferId = field(S64LE) { it.transferId }
val totalSize = field(S32LE) { it.totalSize }
val data = field(bytesPrefixed(U16LE)) { it.data }
return ChunkedTransferBeginPacket(transferId, totalSize, data)
}
override fun CodecScope<ChunkedTransferBeginPacket>.body(): ChunkedTransferBeginPacket {
val transferId = field(S64LE) { it.transferId }
val totalSize = field(S32LE) { it.totalSize }
val data = field(bytesPrefixed(U16LE)) { it.data }
return ChunkedTransferBeginPacket(transferId, totalSize, data)
}
}
@@ -7,40 +7,40 @@ data class ChunkedTransferDataPacket(
val totalSize: Int,
val chunkData: ByteArray,
) {
override fun equals(other: Any?): Boolean =
other is ChunkedTransferDataPacket &&
transferId == other.transferId &&
totalSize == other.totalSize &&
chunkData.contentEquals(other.chunkData)
override fun equals(other: Any?): Boolean =
other is ChunkedTransferDataPacket &&
transferId == other.transferId &&
totalSize == other.totalSize &&
chunkData.contentEquals(other.chunkData)
override fun hashCode(): Int {
var r = transferId.hashCode()
r = r * 31 + totalSize
r = r * 31 + chunkData.contentHashCode()
return r
}
override fun hashCode(): Int {
var r = transferId.hashCode()
r = r * 31 + totalSize
r = r * 31 + chunkData.contentHashCode()
return r
}
}
private val ChunkBytes: Codec<ByteArray> =
object : Codec<ByteArray> {
override fun read(buf: ReadBuffer): ByteArray {
val length = S16LE.read(buf).toInt()
val data = ByteArray(length)
if (length > 0) buf.readBytes(data)
return data
}
override fun read(buf: ReadBuffer): ByteArray {
val length = S16LE.read(buf).toInt()
val data = ByteArray(length)
if (length > 0) buf.readBytes(data)
return data
}
override fun write(buf: WriteBuffer, value: ByteArray) {
S16LE.write(buf, value.size.toShort())
if (value.isNotEmpty()) buf.writeBytes(value)
}
override fun write(buf: WriteBuffer, value: ByteArray) {
S16LE.write(buf, value.size.toShort())
if (value.isNotEmpty()) buf.writeBytes(value)
}
}
object ChunkedTransferDataPacketCodec : PacketCodec<ChunkedTransferDataPacket>() {
override fun CodecScope<ChunkedTransferDataPacket>.body(): ChunkedTransferDataPacket {
val transferId = field(S64LE) { it.transferId }
val totalSize = field(S32LE) { it.totalSize }
val chunkData = field(ChunkBytes) { it.chunkData }
return ChunkedTransferDataPacket(transferId, totalSize, chunkData)
}
override fun CodecScope<ChunkedTransferDataPacket>.body(): ChunkedTransferDataPacket {
val transferId = field(S64LE) { it.transferId }
val totalSize = field(S32LE) { it.totalSize }
val chunkData = field(ChunkBytes) { it.chunkData }
return ChunkedTransferDataPacket(transferId, totalSize, chunkData)
}
}
@@ -8,50 +8,50 @@ data class ClientCookieUpdatePacket(
val blob: ByteArray?,
val namedValues: List<CookieNamedValue>?,
) {
override fun equals(other: Any?): Boolean {
if (other !is ClientCookieUpdatePacket) return false
if (namedValues != other.namedValues) return false
if (blob == null) return other.blob == null
return other.blob != null && blob.contentEquals(other.blob)
}
override fun equals(other: Any?): Boolean {
if (other !is ClientCookieUpdatePacket) return false
if (namedValues != other.namedValues) return false
if (blob == null) return other.blob == null
return other.blob != null && blob.contentEquals(other.blob)
}
override fun hashCode(): Int {
var r = blob?.contentHashCode() ?: 0
r = r * 31 + (namedValues?.hashCode() ?: 0)
return r
}
override fun hashCode(): Int {
var r = blob?.contentHashCode() ?: 0
r = r * 31 + (namedValues?.hashCode() ?: 0)
return r
}
}
private val CookieBlob = bytesPrefixed(U8)
private val CookieNamedValueCodec: Codec<CookieNamedValue> =
(S8.then(Utf16LeNullTerminated)).let { pair ->
object : Codec<CookieNamedValue> {
override fun read(buf: de.fiereu.bytecodec.ReadBuffer): CookieNamedValue {
val (k, v) = pair.read(buf)
return CookieNamedValue(k, v)
}
override fun write(buf: de.fiereu.bytecodec.WriteBuffer, value: CookieNamedValue) {
pair.write(buf, value.key to value.value)
}
object : Codec<CookieNamedValue> {
override fun read(buf: de.fiereu.bytecodec.ReadBuffer): CookieNamedValue {
val (k, v) = pair.read(buf)
return CookieNamedValue(k, v)
}
override fun write(buf: de.fiereu.bytecodec.WriteBuffer, value: CookieNamedValue) {
pair.write(buf, value.key to value.value)
}
}
}
object ClientCookieUpdatePacketCodec : PacketCodec<ClientCookieUpdatePacket>() {
override fun CodecScope<ClientCookieUpdatePacket>.body(): ClientCookieUpdatePacket {
val flags =
field(S8) {
var f = 0
if (it.blob != null) f = f or 1
if (it.namedValues != null) f = f or 2
f.toByte()
}
val blob: ByteArray? = if (flags.toInt() and 1 != 0) field(CookieBlob) { it.blob!! } else null
val namedValues: List<CookieNamedValue>? =
if (flags.toInt() and 2 != 0)
field(CookieNamedValueCodec.listPrefixed(U8)) { it.namedValues!! }
else null
return ClientCookieUpdatePacket(blob, namedValues)
}
override fun CodecScope<ClientCookieUpdatePacket>.body(): ClientCookieUpdatePacket {
val flags =
field(S8) {
var f = 0
if (it.blob != null) f = f or 1
if (it.namedValues != null) f = f or 2
f.toByte()
}
val blob: ByteArray? = if (flags.toInt() and 1 != 0) field(CookieBlob) { it.blob!! } else null
val namedValues: List<CookieNamedValue>? =
if (flags.toInt() and 2 != 0)
field(CookieNamedValueCodec.listPrefixed(U8)) { it.namedValues!! }
else null
return ClientCookieUpdatePacket(blob, namedValues)
}
}
Loaded 100 of 393 files, more files were not shown because too many files have changed in this diff. Show more