feat(game): add game protocol packets (100% ai slop)
This commit is contained in:
1 parent
cc9b2beaf8
commit
cd7c7c9aa7
366 files changed
+11638
-220
No files matched your search
@@ -4,70 +4,7 @@ import de.fiereu.network.Protocol
|
||||
import de.fiereu.network.bidi
|
||||
import de.fiereu.network.c2s
|
||||
import de.fiereu.network.s2c
|
||||
import de.fiereu.openmmo.net.game.packets.CharactersListPacket
|
||||
import de.fiereu.openmmo.net.game.packets.CharactersListPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.ChatMessagePacket
|
||||
import de.fiereu.openmmo.net.game.packets.ChatMessagePacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.CreateCharacterPacket
|
||||
import de.fiereu.openmmo.net.game.packets.CreateCharacterPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.DialogChoicePacket
|
||||
import de.fiereu.openmmo.net.game.packets.DialogChoicePacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.DialogDataPacket
|
||||
import de.fiereu.openmmo.net.game.packets.DialogDataPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.DialogOptionPacket
|
||||
import de.fiereu.openmmo.net.game.packets.DialogOptionPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.DialogStatePacket
|
||||
import de.fiereu.openmmo.net.game.packets.DialogStatePacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.EntityInteractPacket
|
||||
import de.fiereu.openmmo.net.game.packets.EntityInteractPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.EntityLeavePacket
|
||||
import de.fiereu.openmmo.net.game.packets.EntityLeavePacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.EntityMovePacket
|
||||
import de.fiereu.openmmo.net.game.packets.EntityMovePacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.FaceDirectionPacket
|
||||
import de.fiereu.openmmo.net.game.packets.FaceDirectionPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.InteractivePacket
|
||||
import de.fiereu.openmmo.net.game.packets.InteractivePacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.InteractiveResponsePacket
|
||||
import de.fiereu.openmmo.net.game.packets.InteractiveResponsePacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.JoinPacket
|
||||
import de.fiereu.openmmo.net.game.packets.JoinPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.JoinResponsePacket
|
||||
import de.fiereu.openmmo.net.game.packets.JoinResponsePacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.KeepAlivePacket
|
||||
import de.fiereu.openmmo.net.game.packets.KeepAlivePacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.LoadEntityPacket
|
||||
import de.fiereu.openmmo.net.game.packets.LoadEntityPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.LoadMapPacket
|
||||
import de.fiereu.openmmo.net.game.packets.LoadMapPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.MapTransitionAckPacket
|
||||
import de.fiereu.openmmo.net.game.packets.MapTransitionAckPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.MapTransitionPacket
|
||||
import de.fiereu.openmmo.net.game.packets.MapTransitionPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.MovementPacket
|
||||
import de.fiereu.openmmo.net.game.packets.MovementPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.NpcAnimationPacket
|
||||
import de.fiereu.openmmo.net.game.packets.NpcAnimationPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.NpcSpawnPacket
|
||||
import de.fiereu.openmmo.net.game.packets.NpcSpawnPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.NpcUpdatePacket
|
||||
import de.fiereu.openmmo.net.game.packets.NpcUpdatePacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.NullPacket
|
||||
import de.fiereu.openmmo.net.game.packets.NullPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.PokemonContainerPacket
|
||||
import de.fiereu.openmmo.net.game.packets.PokemonContainerPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.RenderScreenPacket
|
||||
import de.fiereu.openmmo.net.game.packets.RenderScreenPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.RequestCharactersPacket
|
||||
import de.fiereu.openmmo.net.game.packets.RequestCharactersPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.RequestPlayerPacket
|
||||
import de.fiereu.openmmo.net.game.packets.RequestPlayerPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.SelectCharacterPacket
|
||||
import de.fiereu.openmmo.net.game.packets.SelectCharacterPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.SelectedCharacterPacket
|
||||
import de.fiereu.openmmo.net.game.packets.SelectedCharacterPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.TokenPayloadPacket
|
||||
import de.fiereu.openmmo.net.game.packets.TokenPayloadPacketCodec
|
||||
import de.fiereu.openmmo.net.game.packets.*
|
||||
|
||||
object GameProtocol : Protocol() {
|
||||
override val compressed: Boolean = true
|
||||
@@ -80,6 +17,7 @@ object GameProtocol : Protocol() {
|
||||
s2c<CharactersListPacket>(0x02u, CharactersListPacketCodec)
|
||||
|
||||
c2s<CreateCharacterPacket>(0x03u, CreateCharacterPacketCodec)
|
||||
s2c<FriendRosterDeltaPacket>(0x03u, FriendRosterDeltaPacketCodec)
|
||||
|
||||
c2s<SelectCharacterPacket>(0x04u, SelectCharacterPacketCodec)
|
||||
s2c<SelectedCharacterPacket>(0x04u, SelectedCharacterPacketCodec)
|
||||
@@ -90,40 +28,572 @@ object GameProtocol : Protocol() {
|
||||
c2s<MovementPacket>(0x06u, MovementPacketCodec)
|
||||
|
||||
c2s<FaceDirectionPacket>(0x07u, FaceDirectionPacketCodec)
|
||||
s2c<EntityFaceTurnPacket>(0x07u, EntityFaceTurnPacketCodec)
|
||||
|
||||
c2s<ChatMessageSendPacket>(0x08u, ChatMessageSendPacketCodec)
|
||||
s2c<EntityLeavePacket>(0x08u, EntityLeavePacketCodec)
|
||||
|
||||
bidi<ChatMessagePacket>(0x09u, ChatMessagePacketCodec)
|
||||
|
||||
c2s<BattleMoveUsePacket>(0x0Au, BattleMoveUsePacketCodec)
|
||||
s2c<WorldFlagTableResetPacket>(0x0Au, WorldFlagTableResetPacketCodec)
|
||||
|
||||
c2s<EvolutionPromptResponsePacket>(0x0Bu, EvolutionPromptResponsePacketCodec)
|
||||
s2c<WorldFlagSetPacket>(0x0Bu, WorldFlagSetPacketCodec)
|
||||
|
||||
c2s<BattlePartySwitchPacket>(0x0Cu, BattlePartySwitchPacketCodec)
|
||||
s2c<LocalCharacterDeltaPacket>(0x0Cu, LocalCharacterDeltaPacketCodec)
|
||||
|
||||
bidi<DialogDataPacket>(0x0Du, DialogDataPacketCodec)
|
||||
|
||||
bidi<DialogStatePacket>(0x0Eu, DialogStatePacketCodec)
|
||||
|
||||
c2s<PokemonListAddPacket>(0x0Fu, PokemonListAddPacketCodec)
|
||||
s2c<EntityPresencePacket>(0x0Fu, EntityPresencePacketCodec)
|
||||
|
||||
bidi<LoadMapPacket>(0x10u, LoadMapPacketCodec)
|
||||
|
||||
c2s<PartyMemberSelectPacket>(0x11u, PartyMemberSelectPacketCodec)
|
||||
s2c<NpcUpdatePacket>(0x11u, NpcUpdatePacketCodec)
|
||||
|
||||
bidi<NpcSpawnPacket>(0x12u, NpcSpawnPacketCodec)
|
||||
|
||||
bidi<PokemonContainerPacket>(0x13u, PokemonContainerPacketCodec)
|
||||
|
||||
c2s<EntityActionRequestPacket>(0x14u, EntityActionRequestPacketCodec)
|
||||
s2c<SocialListEntryAddPacket>(0x14u, SocialListEntryAddPacketCodec)
|
||||
|
||||
c2s<ChatLocalePreferencesPacket>(0x15u, ChatLocalePreferencesPacketCodec)
|
||||
s2c<SocialListEntryRemovePacket>(0x15u, SocialListEntryRemovePacketCodec)
|
||||
|
||||
c2s<InGameChallengeResponsePacket>(0x16u, InGameChallengeResponsePacketCodec)
|
||||
s2c<BattleEntityDeltaPacket>(0x16u, BattleEntityDeltaPacketCodec)
|
||||
|
||||
c2s<StorageBoxClosePacket>(0x17u, StorageBoxClosePacketCodec)
|
||||
s2c<SocialEntryFlagSetPacket>(0x17u, SocialEntryFlagSetPacketCodec)
|
||||
|
||||
c2s<MonsterStatusConditionPacket>(0x18u, MonsterStatusConditionPacketCodec)
|
||||
s2c<SocialEntryPresencePacket>(0x18u, SocialEntryPresencePacketCodec)
|
||||
|
||||
c2s<MonsterFormActionPacket>(0x19u, MonsterFormActionPacketCodec)
|
||||
s2c<SocialEntryRenamePacket>(0x19u, SocialEntryRenamePacketCodec)
|
||||
|
||||
s2c<EntityMovePpPacket>(0x1Au, EntityMovePpPacketCodec)
|
||||
|
||||
bidi<MapTransitionPacket>(0x1Bu, MapTransitionPacketCodec)
|
||||
|
||||
c2s<StorageBoxFilterPacket>(0x1Cu, StorageBoxFilterPacketCodec)
|
||||
s2c<PokedexSpeciesResetPacket>(0x1Cu, PokedexSpeciesResetPacketCodec)
|
||||
|
||||
c2s<PokemonFlagsUpdatePacket>(0x1Du, PokemonFlagsUpdatePacketCodec)
|
||||
s2c<PokedexSpeciesUnlockPacket>(0x1Du, PokedexSpeciesUnlockPacketCodec)
|
||||
|
||||
s2c<OverworldWeatherControlPacket>(0x1Eu, OverworldWeatherControlPacketCodec)
|
||||
|
||||
s2c<OverworldParticleSpawnPacket>(0x1Fu, OverworldParticleSpawnPacketCodec)
|
||||
|
||||
c2s<NullPacket>(0x20u, NullPacketCodec)
|
||||
s2c<TokenPayloadPacket>(0x20u, TokenPayloadPacketCodec)
|
||||
|
||||
s2c<InteractivePacket>(0x21u, InteractivePacketCodec)
|
||||
c2s<InteractiveResponsePacket>(0x21u, InteractiveResponsePacketCodec)
|
||||
c2s<WarpTileInteractPacket>(0x21u, WarpTileInteractPacketCodec)
|
||||
s2c<DialogActionPacket>(0x21u, DialogActionPacketCodec)
|
||||
|
||||
bidi<EntityInteractPacket>(0x22u, EntityInteractPacketCodec)
|
||||
|
||||
c2s<ExchangeItemRequestPacket>(0x23u, ExchangeItemRequestPacketCodec)
|
||||
s2c<EventOverlayStatePacket>(0x23u, EventOverlayStatePacketCodec)
|
||||
|
||||
c2s<ShopSellRequestPacket>(0x24u, ShopSellRequestPacketCodec)
|
||||
s2c<NpcPanelTogglePacket>(0x24u, NpcPanelTogglePacketCodec)
|
||||
|
||||
bidi<DialogChoicePacket>(0x25u, DialogChoicePacketCodec)
|
||||
|
||||
bidi<DialogOptionPacket>(0x26u, DialogOptionPacketCodec)
|
||||
|
||||
c2s<PlayerStopMovingPacket>(0x27u, PlayerStopMovingPacketCodec)
|
||||
s2c<BattlePromptSwitchPacket>(0x27u, BattlePromptSwitchPacketCodec)
|
||||
|
||||
c2s<TypedBinaryDataPacket>(0x28u, TypedBinaryDataPacketCodec)
|
||||
s2c<EntityInteractionFlagPacket>(0x28u, EntityInteractionFlagPacketCodec)
|
||||
|
||||
c2s<CustomizeCharacterAppearancePacket>(0x29u, CustomizeCharacterAppearancePacketCodec)
|
||||
s2c<ShopPriceTablePacket>(0x29u, ShopPriceTablePacketCodec)
|
||||
|
||||
c2s<TeamNameChangePacket>(0x2Au, TeamNameChangePacketCodec)
|
||||
s2c<BattleStatusFlagPacket>(0x2Au, BattleStatusFlagPacketCodec)
|
||||
|
||||
c2s<SetCharacterNamePacket>(0x2Bu, SetCharacterNamePacketCodec)
|
||||
s2c<FollowerAdvancePacket>(0x2Bu, FollowerAdvancePacketCodec)
|
||||
|
||||
c2s<NpcDialogResponsePacket>(0x2Cu, NpcDialogResponsePacketCodec)
|
||||
s2c<EntityTitleTagPacket>(0x2Cu, EntityTitleTagPacketCodec)
|
||||
|
||||
c2s<EntityInteractRequestPacket>(0x2Du, EntityInteractRequestPacketCodec)
|
||||
s2c<MapCellTilesetPacket>(0x2Du, MapCellTilesetPacketCodec)
|
||||
|
||||
c2s<SendDirectMessagePacket>(0x2Eu, SendDirectMessagePacketCodec)
|
||||
s2c<EntityRenamePacket>(0x2Eu, EntityRenamePacketCodec)
|
||||
|
||||
c2s<DialogResponsePacket>(0x2Fu, DialogResponsePacketCodec)
|
||||
s2c<WorldJoinConfirmPacket>(0x2Fu, WorldJoinConfirmPacketCodec)
|
||||
|
||||
c2s<BattleActionPacket>(0x30u, BattleActionPacketCodec)
|
||||
|
||||
s2c<BattleBulkStatePacket>(0x31u, BattleBulkStatePacketCodec)
|
||||
|
||||
c2s<BattleActionSelectPacket>(0x32u, BattleActionSelectPacketCodec)
|
||||
s2c<BattleQueuedEventPacket>(0x32u, BattleQueuedEventPacketCodec)
|
||||
|
||||
c2s<MapLoadedAckPacket>(0x33u, MapLoadedAckPacketCodec)
|
||||
s2c<BattleEntityMoveEventPacket>(0x33u, BattleEntityMoveEventPacketCodec)
|
||||
|
||||
c2s<SpectateRequestPacket>(0x34u, SpectateRequestPacketCodec)
|
||||
s2c<BattleSlotEventEnumPacket>(0x34u, BattleSlotEventEnumPacketCodec)
|
||||
|
||||
c2s<LeaveBattlePacket>(0x35u, LeaveBattlePacketCodec)
|
||||
s2c<BattleSlotMoveEventPacket>(0x35u, BattleSlotMoveEventPacketCodec)
|
||||
|
||||
c2s<RequestNextBattleSequencePacket>(0x36u, RequestNextBattleSequencePacketCodec)
|
||||
s2c<BattleSlotFlagEventPacket>(0x36u, BattleSlotFlagEventPacketCodec)
|
||||
|
||||
c2s<BattleSlotActionPacket>(0x37u, BattleSlotActionPacketCodec)
|
||||
s2c<BattleListEventPacket>(0x37u, BattleListEventPacketCodec)
|
||||
|
||||
c2s<BattleSwitchSelectionsPacket>(0x38u, BattleSwitchSelectionsPacketCodec)
|
||||
s2c<BattleEntityActionEventPacket>(0x38u, BattleEntityActionEventPacketCodec)
|
||||
|
||||
c2s<BattleUseItemPacket>(0x39u, BattleUseItemPacketCodec)
|
||||
s2c<BattleLabeledMoveEventPacket>(0x39u, BattleLabeledMoveEventPacketCodec)
|
||||
|
||||
c2s<SetBattleMonsterAppearancePacket>(0x3Au, SetBattleMonsterAppearancePacketCodec)
|
||||
s2c<BattleEnumPairEventPacket>(0x3Au, BattleEnumPairEventPacketCodec)
|
||||
|
||||
c2s<PrismaticPearlTransferPacket>(0x3Bu, PrismaticPearlTransferPacketCodec)
|
||||
s2c<BattleEmptyEventPacket>(0x3Bu, BattleEmptyEventPacketCodec)
|
||||
|
||||
c2s<SetActiveMovesetPacket>(0x3Cu, SetActiveMovesetPacketCodec)
|
||||
s2c<ServerChatTemplate5002Packet>(0x3Cu, ServerChatTemplate5002PacketCodec)
|
||||
|
||||
c2s<BattleCancelRequestPacket>(0x3Du, BattleCancelRequestPacketCodec)
|
||||
s2c<ServerChatTemplate5003Packet>(0x3Du, ServerChatTemplate5003PacketCodec)
|
||||
|
||||
s2c<BattleSlotSwitchEventPacket>(0x3Eu, BattleSlotSwitchEventPacketCodec)
|
||||
|
||||
c2s<BattleSimulationRequestPacket>(0x3Fu, BattleSimulationRequestPacketCodec)
|
||||
s2c<BattleMoveDisableUpdatePacket>(0x3Fu, BattleMoveDisableUpdatePacketCodec)
|
||||
|
||||
c2s<SubmitBreedingPartyPacket>(0x40u, SubmitBreedingPartyPacketCodec)
|
||||
s2c<BattleSidePartyPacket>(0x40u, BattleSidePartyPacketCodec)
|
||||
|
||||
c2s<MonsterFavoriteTogglePacket>(0x41u, MonsterFavoriteTogglePacketCodec)
|
||||
s2c<BattlePokemonSpritePacket>(0x41u, BattlePokemonSpritePacketCodec)
|
||||
|
||||
c2s<LeaveChatChannelPacket>(0x42u, LeaveChatChannelPacketCodec)
|
||||
s2c<BattleSideAddPokemonPacket>(0x42u, BattleSideAddPokemonPacketCodec)
|
||||
|
||||
c2s<SetChatUserIgnoredPacket>(0x43u, SetChatUserIgnoredPacketCodec)
|
||||
s2c<BattleSideRemovePokemonPacket>(0x43u, BattleSideRemovePokemonPacketCodec)
|
||||
|
||||
c2s<TournamentTeleportAcceptPacket>(0x44u, TournamentTeleportAcceptPacketCodec)
|
||||
s2c<BattlePokemonStatusPacket>(0x44u, BattlePokemonStatusPacketCodec)
|
||||
|
||||
c2s<NpcDialogueChoicePacket>(0x45u, NpcDialogueChoicePacketCodec)
|
||||
s2c<WorldStateControlPacket>(0x45u, WorldStateControlPacketCodec)
|
||||
|
||||
c2s<BattleReadyPacket>(0x46u, BattleReadyPacketCodec)
|
||||
s2c<BattleControlBytesPacket>(0x46u, BattleControlBytesPacketCodec)
|
||||
|
||||
c2s<LeaveMatchmakingQueuePacket>(0x47u, LeaveMatchmakingQueuePacketCodec)
|
||||
s2c<BattleScreenOpenPacket>(0x47u, BattleScreenOpenPacketCodec)
|
||||
|
||||
c2s<BattleActionSubmitPacket>(0x48u, BattleActionSubmitPacketCodec)
|
||||
s2c<BattleActionResultPacket>(0x48u, BattleActionResultPacketCodec)
|
||||
|
||||
c2s<JoinMatchmakingQueuePacket>(0x49u, JoinMatchmakingQueuePacketCodec)
|
||||
s2c<BattleMoveSelectionCancelPacket>(0x49u, BattleMoveSelectionCancelPacketCodec)
|
||||
|
||||
c2s<BattleTierSelectPacket>(0x4Au, BattleTierSelectPacketCodec)
|
||||
s2c<BattleRatingBulkPacket>(0x4Au, BattleRatingBulkPacketCodec)
|
||||
|
||||
c2s<BattleChatMessagePacket>(0x4Bu, BattleChatMessagePacketCodec)
|
||||
s2c<BattleRatingUpdatePacket>(0x4Bu, BattleRatingUpdatePacketCodec)
|
||||
|
||||
c2s<MatchmakingActionPacket>(0x4Cu, MatchmakingActionPacketCodec)
|
||||
s2c<BattleMoveTargetsPacket>(0x4Cu, BattleMoveTargetsPacketCodec)
|
||||
|
||||
c2s<MarketListingsRequestPacket>(0x4Du, MarketListingsRequestPacketCodec)
|
||||
s2c<BattleStateBytePacket>(0x4Du, BattleStateBytePacketCodec)
|
||||
|
||||
s2c<BattleMoveListPacket>(0x4Eu, BattleMoveListPacketCodec)
|
||||
|
||||
c2s<MarketSearchFilterPacket>(0x4Fu, MarketSearchFilterPacketCodec)
|
||||
s2c<ChannelAssignmentsPacket>(0x4Fu, ChannelAssignmentsPacketCodec)
|
||||
|
||||
c2s<TradeActionPacket>(0x50u, TradeActionPacketCodec)
|
||||
s2c<DuelInvitePacket>(0x50u, DuelInvitePacketCodec)
|
||||
|
||||
c2s<StringCommandPacket>(0x51u, StringCommandPacketCodec)
|
||||
s2c<DuelInviteOutcomePacket>(0x51u, DuelInviteOutcomePacketCodec)
|
||||
|
||||
c2s<TradeSelectMonPacket>(0x52u, TradeSelectMonPacketCodec)
|
||||
s2c<TradeListEntryPacket>(0x52u, TradeListEntryPacketCodec)
|
||||
|
||||
c2s<BattlePartySlotSelectPacket>(0x53u, BattlePartySlotSelectPacketCodec)
|
||||
s2c<BattleStateSlotIntPacket>(0x53u, BattleStateSlotIntPacketCodec)
|
||||
|
||||
s2c<BattleBoardCellPacket>(0x54u, BattleBoardCellPacketCodec)
|
||||
|
||||
s2c<SpatialGroupSnapshotPacket>(0x55u, SpatialGroupSnapshotPacketCodec)
|
||||
|
||||
s2c<SpatialGroupInsertPacket>(0x56u, SpatialGroupInsertPacketCodec)
|
||||
|
||||
s2c<SpatialGroupDeletePacket>(0x57u, SpatialGroupDeletePacketCodec)
|
||||
|
||||
s2c<MenuVisibilityPacket>(0x58u, MenuVisibilityPacketCodec)
|
||||
|
||||
s2c<MenuPagePayloadPacket>(0x59u, MenuPagePayloadPacketCodec)
|
||||
|
||||
s2c<EntityNameChoicesPacket>(0x5Au, EntityNameChoicesPacketCodec)
|
||||
|
||||
s2c<OptionListWindowPacket>(0x5Bu, OptionListWindowPacketCodec)
|
||||
|
||||
s2c<ListWindowPagePacket>(0x5Cu, ListWindowPagePacketCodec)
|
||||
|
||||
s2c<MarketBoardPagePacket>(0x5Du, MarketBoardPagePacketCodec)
|
||||
|
||||
s2c<SceneObjectStatesPacket>(0x5Eu, SceneObjectStatesPacketCodec)
|
||||
|
||||
s2c<StorageInventoryPacket>(0x5Fu, StorageInventoryPacketCodec)
|
||||
|
||||
c2s<BlockPlayerPacket>(0x60u, BlockPlayerPacketCodec)
|
||||
s2c<StorageContextWindowPacket>(0x60u, StorageContextWindowPacketCodec)
|
||||
|
||||
c2s<UnblockPlayerPacket>(0x61u, UnblockPlayerPacketCodec)
|
||||
s2c<EntityCoordSyncPacket>(0x61u, EntityCoordSyncPacketCodec)
|
||||
|
||||
c2s<RemoveFriendPacket>(0x62u, RemoveFriendPacketCodec)
|
||||
s2c<SocialActionOutcomePacket>(0x62u, SocialActionOutcomePacketCodec)
|
||||
|
||||
c2s<SetPlayerTitlePacket>(0x63u, SetPlayerTitlePacketCodec)
|
||||
s2c<ContactRosterPacket>(0x63u, ContactRosterPacketCodec)
|
||||
|
||||
c2s<FriendProfileRequestPacket>(0x64u, FriendProfileRequestPacketCodec)
|
||||
s2c<ContactInsertPacket>(0x64u, ContactInsertPacketCodec)
|
||||
|
||||
s2c<ContactDeletePacket>(0x65u, ContactDeletePacketCodec)
|
||||
|
||||
s2c<ContactOnlineStatePacket>(0x66u, ContactOnlineStatePacketCodec)
|
||||
|
||||
s2c<PartyRosterPacket>(0x67u, PartyRosterPacketCodec)
|
||||
|
||||
s2c<PartyMemberJoinPacket>(0x68u, PartyMemberJoinPacketCodec)
|
||||
|
||||
s2c<PartyMemberLeavePacket>(0x69u, PartyMemberLeavePacketCodec)
|
||||
|
||||
c2s<InstanceReadyCheckPacket>(0x6Au, InstanceReadyCheckPacketCodec)
|
||||
|
||||
c2s<CancelMatchmakingSearchPacket>(0x6Bu, CancelMatchmakingSearchPacketCodec)
|
||||
s2c<ActiveBattleSidePacket>(0x6Bu, ActiveBattleSidePacketCodec)
|
||||
|
||||
c2s<MatchmakingLanguagePrefsPacket>(0x6Cu, MatchmakingLanguagePrefsPacketCodec)
|
||||
s2c<MountMoveCooldownPacket>(0x6Cu, MountMoveCooldownPacketCodec)
|
||||
|
||||
s2c<ClientCookieUpdatePacket>(0x6Du, ClientCookieUpdatePacketCodec)
|
||||
|
||||
s2c<WorldToggleFlagsPacket>(0x6Eu, WorldToggleFlagsPacketCodec)
|
||||
|
||||
s2c<NamedCategoryEntriesPacket>(0x6Fu, NamedCategoryEntriesPacketCodec)
|
||||
|
||||
c2s<StorageBoxRequestPacket>(0x70u, StorageBoxRequestPacketCodec)
|
||||
s2c<GtlMarketListingsPacket>(0x70u, GtlMarketListingsPacketCodec)
|
||||
|
||||
c2s<GtlPurchaseListingPacket>(0x71u, GtlPurchaseListingPacketCodec)
|
||||
s2c<MatchmakingRentalsPacket>(0x71u, MatchmakingRentalsPacketCodec)
|
||||
|
||||
s2c<WorldStateValuePacket>(0x72u, WorldStateValuePacketCodec)
|
||||
|
||||
c2s<AssignBreedingSlotPacket>(0x73u, AssignBreedingSlotPacketCodec)
|
||||
s2c<BreedingForecastPacket>(0x73u, BreedingForecastPacketCodec)
|
||||
|
||||
c2s<LeaderboardViewRequestPacket>(0x74u, LeaderboardViewRequestPacketCodec)
|
||||
s2c<ServerNoticePacket>(0x74u, ServerNoticePacketCodec)
|
||||
|
||||
c2s<TourneyRegistrationPacket>(0x75u, TourneyRegistrationPacketCodec)
|
||||
s2c<MatchmakingSideTeamPacket>(0x75u, MatchmakingSideTeamPacketCodec)
|
||||
|
||||
c2s<NpcInteractionChoicePacket>(0x76u, NpcInteractionChoicePacketCodec)
|
||||
s2c<ActivePokemonSummaryPacket>(0x76u, ActivePokemonSummaryPacketCodec)
|
||||
|
||||
c2s<BattleTargetPickPacket>(0x77u, BattleTargetPickPacketCodec)
|
||||
s2c<StreamChunkPacket>(0x77u, StreamChunkPacketCodec)
|
||||
|
||||
s2c<MatchmakingMemberProgressPacket>(0x78u, MatchmakingMemberProgressPacketCodec)
|
||||
|
||||
c2s<PcBoxStorePacket>(0x79u, PcBoxStorePacketCodec)
|
||||
s2c<BattleStatCountersPacket>(0x79u, BattleStatCountersPacketCodec)
|
||||
|
||||
c2s<PcBoxRenamePacket>(0x7Au, PcBoxRenamePacketCodec)
|
||||
s2c<LearnedMovesetPacket>(0x7Au, LearnedMovesetPacketCodec)
|
||||
|
||||
c2s<CoopScoreboardRequestPacket>(0x7Bu, CoopScoreboardRequestPacketCodec)
|
||||
s2c<TournamentMatchupsPacket>(0x7Bu, TournamentMatchupsPacketCodec)
|
||||
|
||||
c2s<GtlListingSearchPacket>(0x7Cu, GtlListingSearchPacketCodec)
|
||||
s2c<GtlItemMarketPacket>(0x7Cu, GtlItemMarketPacketCodec)
|
||||
|
||||
s2c<GameShopCatalogPacket>(0x7Du, GameShopCatalogPacketCodec)
|
||||
|
||||
s2c<EggIncubatorSlotsPacket>(0x7Eu, EggIncubatorSlotsPacketCodec)
|
||||
|
||||
s2c<GtlPriceHistoryPacket>(0x7Fu, GtlPriceHistoryPacketCodec)
|
||||
|
||||
c2s<TeamFoundPacket>(0x80u, TeamFoundPacketCodec)
|
||||
s2c<GuildMembershipPacket>(0x80u, GuildMembershipPacketCodec)
|
||||
|
||||
c2s<GuildMotdUpdatePacket>(0x81u, GuildMotdUpdatePacketCodec)
|
||||
s2c<GuildProfileSyncPacket>(0x81u, GuildProfileSyncPacketCodec)
|
||||
|
||||
c2s<GuildDepartPacket>(0x82u, GuildDepartPacketCodec)
|
||||
|
||||
c2s<GuildChatSendPacket>(0x83u, GuildChatSendPacketCodec)
|
||||
s2c<GuildRosterAddPacket>(0x83u, GuildRosterAddPacketCodec)
|
||||
|
||||
c2s<GuildMemberRankAssignPacket>(0x84u, GuildMemberRankAssignPacketCodec)
|
||||
s2c<GuildMemberRankChangePacket>(0x84u, GuildMemberRankChangePacketCodec)
|
||||
|
||||
c2s<GuildMemberExpelPacket>(0x85u, GuildMemberExpelPacketCodec)
|
||||
s2c<GuildRosterRemovePacket>(0x85u, GuildRosterRemovePacketCodec)
|
||||
|
||||
c2s<GuildRankPermissionUpdatePacket>(0x86u, GuildRankPermissionUpdatePacketCodec)
|
||||
s2c<GuildMemberPresencePacket>(0x86u, GuildMemberPresencePacketCodec)
|
||||
|
||||
c2s<GuildDisbandToggleRequestPacket>(0x87u, GuildDisbandToggleRequestPacketCodec)
|
||||
s2c<ContactCategoryGroupPacket>(0x87u, ContactCategoryGroupPacketCodec)
|
||||
|
||||
c2s<GuildRankLabelUpdatePacket>(0x88u, GuildRankLabelUpdatePacketCodec)
|
||||
s2c<GuildRosterBulkPacket>(0x88u, GuildRosterBulkPacketCodec)
|
||||
|
||||
c2s<GuildActivityLogPageRequestPacket>(0x89u, GuildActivityLogPageRequestPacketCodec)
|
||||
s2c<GuildActivityLogPacket>(0x89u, GuildActivityLogPacketCodec)
|
||||
|
||||
c2s<MailAttachmentRequestPacket>(0x8Au, MailAttachmentRequestPacketCodec)
|
||||
|
||||
s2c<MonsterRecordBookPacket>(0x8Bu, MonsterRecordBookPacketCodec)
|
||||
|
||||
s2c<ChatChannelMessagesPacket>(0x8Cu, ChatChannelMessagesPacketCodec)
|
||||
|
||||
s2c<ChatChannelUserListPacket>(0x8Du, ChatChannelUserListPacketCodec)
|
||||
|
||||
s2c<ChannelCountDeltaPacket>(0x8Eu, ChannelCountDeltaPacketCodec)
|
||||
|
||||
s2c<ChatMessageWithdrawPacket>(0x8Fu, ChatMessageWithdrawPacketCodec)
|
||||
|
||||
c2s<OverworldPathToTilePacket>(0x90u, OverworldPathToTilePacketCodec)
|
||||
s2c<EntitySpriteChangePacket>(0x90u, EntitySpriteChangePacketCodec)
|
||||
|
||||
c2s<OverworldStepMovePacket>(0x91u, OverworldStepMovePacketCodec)
|
||||
s2c<OpenAppearanceEditorPacket>(0x91u, OpenAppearanceEditorPacketCodec)
|
||||
|
||||
c2s<BattleTransitionReadyPacket>(0x92u, BattleTransitionReadyPacketCodec)
|
||||
s2c<AppearanceRequestResultPacket>(0x92u, AppearanceRequestResultPacketCodec)
|
||||
|
||||
c2s<PendingRequestCancelPacket>(0x93u, PendingRequestCancelPacketCodec)
|
||||
s2c<BattleStatStagePacket>(0x93u, BattleStatStagePacketCodec)
|
||||
|
||||
c2s<PartyInfoRequestPacket>(0x94u, PartyInfoRequestPacketCodec)
|
||||
s2c<EntityAppearanceSyncPacket>(0x94u, EntityAppearanceSyncPacketCodec)
|
||||
|
||||
c2s<MailComposeSendPacket>(0x95u, MailComposeSendPacketCodec)
|
||||
s2c<BattleSwitchPromptTogglePacket>(0x95u, BattleSwitchPromptTogglePacketCodec)
|
||||
|
||||
c2s<TeamPreviewRevealPickPacket>(0x96u, TeamPreviewRevealPickPacketCodec)
|
||||
s2c<BattleEndDisconnectPacket>(0x96u, BattleEndDisconnectPacketCodec)
|
||||
|
||||
c2s<TeamPreviewSidePickPacket>(0x97u, TeamPreviewSidePickPacketCodec)
|
||||
s2c<BattleTeamPreviewListPacket>(0x97u, BattleTeamPreviewListPacketCodec)
|
||||
|
||||
c2s<TeamPreviewLeadSubmitPacket>(0x98u, TeamPreviewLeadSubmitPacketCodec)
|
||||
s2c<WorldVersionPacket>(0x98u, WorldVersionPacketCodec)
|
||||
|
||||
c2s<BattleTeamPreviewConfirmPacket>(0x99u, BattleTeamPreviewConfirmPacketCodec)
|
||||
s2c<BattleSendOutActivePacket>(0x99u, BattleSendOutActivePacketCodec)
|
||||
|
||||
c2s<CreateMarketListingPacket>(0x9Au, CreateMarketListingPacketCodec)
|
||||
s2c<BattleSlotAnimationResetPacket>(0x9Au, BattleSlotAnimationResetPacketCodec)
|
||||
|
||||
c2s<GtlSellPokemonListingPacket>(0x9Bu, GtlSellPokemonListingPacketCodec)
|
||||
s2c<BattleActionOutcomePacket>(0x9Bu, BattleActionOutcomePacketCodec)
|
||||
|
||||
c2s<GtlConfirmPurchasePacket>(0x9Cu, GtlConfirmPurchasePacketCodec)
|
||||
s2c<BattleDisconnectMessagePacket>(0x9Cu, BattleDisconnectMessagePacketCodec)
|
||||
|
||||
c2s<SelectSinglePokemonPacket>(0x9Du, SelectSinglePokemonPacketCodec)
|
||||
s2c<BattleActionPromptTogglePacket>(0x9Du, BattleActionPromptTogglePacketCodec)
|
||||
|
||||
c2s<SelectPartyPokemonPacket>(0x9Eu, SelectPartyPokemonPacketCodec)
|
||||
s2c<EntityEmoteBubblePacket>(0x9Eu, EntityEmoteBubblePacketCodec)
|
||||
|
||||
c2s<GtlTradeLogRequestPacket>(0x9Fu, GtlTradeLogRequestPacketCodec)
|
||||
|
||||
c2s<PlayerChatInputPacket>(0xA0u, PlayerChatInputPacketCodec)
|
||||
s2c<FriendRosterPacket>(0xA0u, FriendRosterPacketCodec)
|
||||
|
||||
c2s<GtlListingCancelPacket>(0xA1u, GtlListingCancelPacketCodec)
|
||||
s2c<GmPlayerLookupPacket>(0xA1u, GmPlayerLookupPacketCodec)
|
||||
|
||||
c2s<AdminNoteActionPacket>(0xA2u, AdminNoteActionPacketCodec)
|
||||
s2c<GmPanelVariantPacket>(0xA2u, GmPanelVariantPacketCodec)
|
||||
|
||||
c2s<GtlPurchasePacket>(0xA3u, GtlPurchasePacketCodec)
|
||||
s2c<EntityNameVisibilityPacket>(0xA3u, EntityNameVisibilityPacketCodec)
|
||||
|
||||
c2s<GtlListingActionPacket>(0xA4u, GtlListingActionPacketCodec)
|
||||
s2c<HighScoreBoardPacket>(0xA4u, HighScoreBoardPacketCodec)
|
||||
|
||||
c2s<GtlOpenSessionPacket>(0xA5u, GtlOpenSessionPacketCodec)
|
||||
s2c<WorldNoticeSlotPacket>(0xA5u, WorldNoticeSlotPacketCodec)
|
||||
|
||||
c2s<DataDigestSyncResponsePacket>(0xA6u, DataDigestSyncResponsePacketCodec)
|
||||
s2c<DataDigestSyncPacket>(0xA6u, DataDigestSyncPacketCodec)
|
||||
|
||||
c2s<DataContentSyncBatchPacket>(0xA7u, DataContentSyncBatchPacketCodec)
|
||||
s2c<DataDigestSyncBatchedPacket>(0xA7u, DataDigestSyncBatchedPacketCodec)
|
||||
|
||||
c2s<BatchInputEventsPacket>(0xA8u, BatchInputEventsPacketCodec)
|
||||
s2c<SelectionListWindowOpenPacket>(0xA8u, SelectionListWindowOpenPacketCodec)
|
||||
|
||||
c2s<ModerationActionConfirmPacket>(0xA9u, ModerationActionConfirmPacketCodec)
|
||||
s2c<EntityAttributeChangePacket>(0xA9u, EntityAttributeChangePacketCodec)
|
||||
|
||||
s2c<WorldFlagStateUpdatePacket>(0xAAu, WorldFlagStateUpdatePacketCodec)
|
||||
|
||||
s2c<ChunkedTransferBeginPacket>(0xABu, ChunkedTransferBeginPacketCodec)
|
||||
|
||||
s2c<ChunkedTransferAppendPacket>(0xACu, ChunkedTransferAppendPacketCodec)
|
||||
|
||||
s2c<WorldTimedEventStatusPacket>(0xADu, WorldTimedEventStatusPacketCodec)
|
||||
|
||||
s2c<GroupMemberRosterPacket>(0xAEu, GroupMemberRosterPacketCodec)
|
||||
|
||||
s2c<SceneEntityActionDispatchPacket>(0xB0u, SceneEntityActionDispatchPacketCodec)
|
||||
|
||||
s2c<SocialProfileDialogOpenPacket>(0xB1u, SocialProfileDialogOpenPacketCodec)
|
||||
|
||||
bidi<NpcAnimationPacket>(0xB2u, NpcAnimationPacketCodec)
|
||||
|
||||
s2c<MapTileAttributeSetPacket>(0xB3u, MapTileAttributeSetPacketCodec)
|
||||
|
||||
bidi<RenderScreenPacket>(0xB4u, RenderScreenPacketCodec)
|
||||
|
||||
s2c<EntityAppearancePatchPacket>(0xB5u, EntityAppearancePatchPacketCodec)
|
||||
|
||||
s2c<WorldActionDispatchPacket>(0xB6u, WorldActionDispatchPacketCodec)
|
||||
|
||||
s2c<EntityDespawnPacket>(0xB7u, EntityDespawnPacketCodec)
|
||||
|
||||
s2c<MapTileEntityStateSetPacket>(0xB8u, MapTileEntityStateSetPacketCodec)
|
||||
|
||||
bidi<MapTransitionAckPacket>(0xB9u, MapTransitionAckPacketCodec)
|
||||
|
||||
s2c<MapTileObjectSlotSetPacket>(0xBAu, MapTileObjectSlotSetPacketCodec)
|
||||
|
||||
s2c<CameraFollowEntityPacket>(0xBBu, CameraFollowEntityPacketCodec)
|
||||
|
||||
s2c<MapTileObjectRepositionPacket>(0xBCu, MapTileObjectRepositionPacketCodec)
|
||||
|
||||
s2c<WorldEntityStateResetPacket>(0xBDu, WorldEntityStateResetPacketCodec)
|
||||
|
||||
s2c<WorldOverlayObjectSetPacket>(0xBEu, WorldOverlayObjectSetPacketCodec)
|
||||
|
||||
s2c<MapTileAnimationTogglePacket>(0xC0u, MapTileAnimationTogglePacketCodec)
|
||||
|
||||
c2s<TournamentRegistrationPacket>(0xC1u, TournamentRegistrationPacketCodec)
|
||||
s2c<MapWeatherModeSetPacket>(0xC1u, MapWeatherModeSetPacketCodec)
|
||||
|
||||
bidi<KeepAlivePacket>(0xC2u, KeepAlivePacketCodec)
|
||||
|
||||
s2c<FieldMapTilePaletteApplyPacket>(0xC3u, FieldMapTilePaletteApplyPacketCodec)
|
||||
|
||||
s2c<FieldMapBattleSlotTileMapPacket>(0xC4u, FieldMapBattleSlotTileMapPacketCodec)
|
||||
|
||||
s2c<FieldMapBattleSlotMarkerPacket>(0xC5u, FieldMapBattleSlotMarkerPacketCodec)
|
||||
|
||||
s2c<WorldObjectInstanceDespawnPacket>(0xC8u, WorldObjectInstanceDespawnPacketCodec)
|
||||
|
||||
s2c<BattleStartScenePacket>(0xCAu, BattleStartScenePacketCodec)
|
||||
|
||||
c2s<SendChatCommandPacket>(0xD0u, SendChatCommandPacketCodec)
|
||||
s2c<EntityGroupSnapshotPacket>(0xD0u, EntityGroupSnapshotPacketCodec)
|
||||
|
||||
c2s<LinkKickMemberPacket>(0xD1u, LinkKickMemberPacketCodec)
|
||||
s2c<EntityGroupMemberAddPacket>(0xD1u, EntityGroupMemberAddPacketCodec)
|
||||
|
||||
s2c<EntityGroupMemberRemovePacket>(0xD2u, EntityGroupMemberRemovePacketCodec)
|
||||
|
||||
c2s<CancelSocialInteractionPacket>(0xD3u, CancelSocialInteractionPacketCodec)
|
||||
s2c<ObjectiveProgressBulkPacket>(0xD3u, ObjectiveProgressBulkPacketCodec)
|
||||
|
||||
c2s<RequestSocialProfilePacket>(0xD4u, RequestSocialProfilePacketCodec)
|
||||
s2c<ObjectiveProgressPacket>(0xD4u, ObjectiveProgressPacketCodec)
|
||||
|
||||
s2c<TrackedEntitySlotsPacket>(0xD5u, TrackedEntitySlotsPacketCodec)
|
||||
|
||||
s2c<MenuPromptOpenPacket>(0xD6u, MenuPromptOpenPacketCodec)
|
||||
|
||||
s2c<EntityChecklistPromptPacket>(0xD7u, EntityChecklistPromptPacketCodec)
|
||||
|
||||
s2c<MenuPromptClosePacket>(0xD8u, MenuPromptClosePacketCodec)
|
||||
|
||||
s2c<RequestConfirmationPromptPacket>(0xD9u, RequestConfirmationPromptPacketCodec)
|
||||
|
||||
s2c<EntityPanelSelectPacket>(0xDAu, EntityPanelSelectPacketCodec)
|
||||
|
||||
s2c<EntityFramesUpdatePacket>(0xDBu, EntityFramesUpdatePacketCodec)
|
||||
|
||||
s2c<CategoryFlagsPacket>(0xDCu, CategoryFlagsPacketCodec)
|
||||
|
||||
c2s<SaveTemplateEntryPacket>(0xE0u, SaveTemplateEntryPacketCodec)
|
||||
|
||||
c2s<GtlCreateListingPacket>(0xE1u, GtlCreateListingPacketCodec)
|
||||
|
||||
c2s<GtlSearchFilterPacket>(0xE2u, GtlSearchFilterPacketCodec)
|
||||
|
||||
c2s<BattleRewardSelectPacket>(0xE3u, BattleRewardSelectPacketCodec)
|
||||
|
||||
c2s<BattleChallengeRequestPacket>(0xE4u, BattleChallengeRequestPacketCodec)
|
||||
|
||||
s2c<EntityMovePacket>(0xEAu, EntityMovePacketCodec)
|
||||
|
||||
s2c<QueuePositionPacket>(0xF0u, QueuePositionPacketCodec)
|
||||
|
||||
c2s<ChunkedTransferDataPacket>(0xF1u, ChunkedTransferDataPacketCodec)
|
||||
s2c<ViewScalePacket>(0xF1u, ViewScalePacketCodec)
|
||||
|
||||
s2c<SessionExpiryInitPacket>(0xF2u, SessionExpiryInitPacketCodec)
|
||||
|
||||
s2c<LocalPlayerStatePacket>(0xF3u, LocalPlayerStatePacketCodec)
|
||||
|
||||
s2c<CurrencyBalancePacket>(0xF4u, CurrencyBalancePacketCodec)
|
||||
|
||||
s2c<ServerMessagePacket>(0xF5u, ServerMessagePacketCodec)
|
||||
|
||||
s2c<ChunkedImagePacket>(0xF6u, ChunkedImagePacketCodec)
|
||||
|
||||
s2c<GmPanelEntryPacket>(0xF7u, GmPanelEntryPacketCodec)
|
||||
|
||||
s2c<DisconnectNoticePacket>(0xF8u, DisconnectNoticePacketCodec)
|
||||
|
||||
s2c<RosterCooldownPacket>(0xF9u, RosterCooldownPacketCodec)
|
||||
|
||||
s2c<CancelEntityMessagePacket>(0xFAu, CancelEntityMessagePacketCodec)
|
||||
|
||||
s2c<PlayerInputLockPacket>(0xFBu, PlayerInputLockPacketCodec)
|
||||
|
||||
s2c<ServerEndpointListPacket>(0xFCu, ServerEndpointListPacketCodec)
|
||||
|
||||
s2c<GtlListingsPagePacket>(0xFEu, GtlListingsPagePacketCodec)
|
||||
|
||||
s2c<WorldSessionStatePacket>(0xFFu, WorldSessionStatePacketCodec)
|
||||
|
||||
}
|
||||
}
|
||||
+1
-12
@@ -1,17 +1,6 @@
|
||||
package de.fiereu.openmmo.net.game.codecs
|
||||
|
||||
import de.fiereu.bytecodec.Codec
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S16LE
|
||||
import de.fiereu.bytecodec.S32LE
|
||||
import de.fiereu.bytecodec.S64LE
|
||||
import de.fiereu.bytecodec.S8
|
||||
import de.fiereu.bytecodec.U16LE
|
||||
import de.fiereu.bytecodec.U8
|
||||
import de.fiereu.bytecodec.Utf16LeNullTerminated
|
||||
import de.fiereu.bytecodec.bytesPrefixed
|
||||
import de.fiereu.bytecodec.imap
|
||||
import de.fiereu.bytecodec.*
|
||||
import de.fiereu.openmmo.common.CharacterInfo
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneOffset
|
||||
|
||||
@@ -1,23 +1,9 @@
|
||||
package de.fiereu.openmmo.net.game.codecs
|
||||
|
||||
import de.fiereu.bytecodec.Codec
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S16LE
|
||||
import de.fiereu.bytecodec.S32LE
|
||||
import de.fiereu.bytecodec.S64LE
|
||||
import de.fiereu.bytecodec.S8
|
||||
import de.fiereu.bytecodec.U16LE
|
||||
import de.fiereu.bytecodec.U8
|
||||
import de.fiereu.bytecodec.Utf16LeNullTerminated
|
||||
import de.fiereu.bytecodec.bytesPrefixed
|
||||
import de.fiereu.bytecodec.*
|
||||
import de.fiereu.openmmo.common.Pokemon
|
||||
import de.fiereu.openmmo.common.PokemonMove
|
||||
import de.fiereu.openmmo.common.enums.EVs
|
||||
import de.fiereu.openmmo.common.enums.PokemonContainer
|
||||
import de.fiereu.openmmo.common.enums.PokemonRarity
|
||||
import de.fiereu.openmmo.common.enums.compress
|
||||
import de.fiereu.openmmo.common.enums.decompressIVs
|
||||
import de.fiereu.openmmo.common.enums.*
|
||||
|
||||
private val PokemonUnknownBytes: Codec<ByteArray> = bytesPrefixed(U8)
|
||||
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
package de.fiereu.openmmo.net.game.codecs
|
||||
|
||||
import de.fiereu.bytecodec.Codec
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.U16LE
|
||||
import de.fiereu.bytecodec.U8
|
||||
import de.fiereu.bytecodec.*
|
||||
import de.fiereu.openmmo.common.enums.SkinSlot
|
||||
import java.util.EnumMap
|
||||
import java.util.*
|
||||
|
||||
data class Skin(val slot: SkinSlot, val type: UShort?, val color: UByte?)
|
||||
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S8
|
||||
|
||||
data class ActiveBattleSidePacket(
|
||||
val side: Byte,
|
||||
)
|
||||
|
||||
object ActiveBattleSidePacketCodec : PacketCodec<ActiveBattleSidePacket>() {
|
||||
override fun CodecScope<ActiveBattleSidePacket>.body(): ActiveBattleSidePacket {
|
||||
val side = field(S8) { it.side }
|
||||
return ActiveBattleSidePacket(side)
|
||||
}
|
||||
}
|
||||
+214
@@ -0,0 +1,214 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class SummaryRankingEntry(
|
||||
val entityId: Long,
|
||||
val rank: Byte,
|
||||
val flags: Byte,
|
||||
val name: String,
|
||||
val value1: Short,
|
||||
val species: Short,
|
||||
val ribbons: Long,
|
||||
val value2: Byte,
|
||||
val value3: Int,
|
||||
val value4: Byte,
|
||||
val flag1: Boolean,
|
||||
val flag2: Boolean,
|
||||
)
|
||||
|
||||
data class SummaryAppearance(
|
||||
val name: String,
|
||||
val gender: Byte,
|
||||
val formId: Int,
|
||||
val kind: Byte,
|
||||
val palettePack: Byte,
|
||||
val slots: List<Short>,
|
||||
)
|
||||
|
||||
data class SummaryAbility(
|
||||
val slot: Byte,
|
||||
val sourceId: Long,
|
||||
val appearance: SummaryAppearance,
|
||||
)
|
||||
|
||||
data class SummaryMove(
|
||||
val moveId: Byte,
|
||||
val slot: Byte,
|
||||
val locked: Boolean,
|
||||
val intA: Int,
|
||||
val intB: Int,
|
||||
val intC: Int,
|
||||
val shortA: Short,
|
||||
val shortB: Short,
|
||||
val byteA: Byte,
|
||||
val unlockedShort: Short,
|
||||
val boolA: Boolean,
|
||||
val boolB: Boolean,
|
||||
val unlockedByteA: Byte,
|
||||
val boolC: Boolean,
|
||||
val boolD: Boolean,
|
||||
val unlockedByteB: Byte,
|
||||
val unlockedByteC: Byte,
|
||||
val unlockedByteD: Byte,
|
||||
)
|
||||
|
||||
data class ActivePokemonSummaryPacket(
|
||||
val pokemon: SummaryRankingEntry,
|
||||
val abilities: List<SummaryAbility>,
|
||||
val moves: List<SummaryMove>,
|
||||
)
|
||||
|
||||
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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
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 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 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)
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class AdminNoteActionPacket(
|
||||
val actionType: Byte,
|
||||
val targetEntityId: Long?,
|
||||
val noteEntityId: Long?,
|
||||
val noteText: String?,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.Bool
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S64LE
|
||||
|
||||
data class AppearanceRequestResultPacket(
|
||||
val entityId: Long,
|
||||
val accepted: Boolean,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S64LE
|
||||
import de.fiereu.bytecodec.S8
|
||||
|
||||
data class AssignBreedingSlotPacket(
|
||||
val ownPokemonEntityId: Long,
|
||||
val partnerPokemonEntityId: Long,
|
||||
val slotIndex: Byte,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class InputEventSample(
|
||||
val type: Byte,
|
||||
val timestamp: Long,
|
||||
val byteA: Byte,
|
||||
val byteB: Byte,
|
||||
val intA: Int,
|
||||
val shortA: Short,
|
||||
val shortB: Short,
|
||||
val intB: Int,
|
||||
)
|
||||
|
||||
data class BatchInputEventsPacket(
|
||||
val hasEvents: Boolean,
|
||||
val events: List<InputEventSample>,
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
import de.fiereu.openmmo.common.Pokemon
|
||||
import de.fiereu.openmmo.net.game.codecs.PokemonCodec
|
||||
|
||||
data class BattleActionRewardEntry(
|
||||
val itemId: Int,
|
||||
val quantity: Short,
|
||||
)
|
||||
|
||||
data class BattleActionParticipant(
|
||||
val entityId: Long,
|
||||
val kind: Int,
|
||||
val intA: Int,
|
||||
val intB: Int,
|
||||
val intC: Int,
|
||||
val shortA: Short,
|
||||
val critByte: Byte?,
|
||||
val critShort: Short?,
|
||||
val capturedShort: Short?,
|
||||
val capturedByte: Byte?,
|
||||
val xpShort: Short?,
|
||||
val xpByteA: Byte?,
|
||||
val xpByteB: Byte?,
|
||||
val pokemon: Pokemon?,
|
||||
val statStages: List<Short>?,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleActionOutcomePacket(
|
||||
val side: Byte,
|
||||
val category: Int,
|
||||
val value: Short,
|
||||
val extra: Int,
|
||||
val participants: List<BattleActionParticipant>,
|
||||
val rewards: List<BattleActionRewardEntry>?,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleActionPacket(
|
||||
val actionTypeId: Byte,
|
||||
val isSlotTarget: Boolean,
|
||||
val targetSlot: Short?,
|
||||
val targetEntityId: Long?,
|
||||
val extraFlag: Byte,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.Bool
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
|
||||
data class BattleActionPromptTogglePacket(
|
||||
val shown: Boolean,
|
||||
)
|
||||
|
||||
object BattleActionPromptTogglePacketCodec : PacketCodec<BattleActionPromptTogglePacket>() {
|
||||
override fun CodecScope<BattleActionPromptTogglePacket>.body(): BattleActionPromptTogglePacket {
|
||||
val shown = field(Bool) { it.shown }
|
||||
return BattleActionPromptTogglePacket(shown)
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleActionResultPacket(
|
||||
val targetCount: Byte,
|
||||
val targets: List<Byte>,
|
||||
val entityId: Long,
|
||||
val value: Int,
|
||||
val messageType: Byte,
|
||||
val move: Byte?,
|
||||
)
|
||||
|
||||
object BattleActionResultPacketCodec : PacketCodec<BattleActionResultPacket>() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleActionSelectPacket(
|
||||
val slotRefPacked: Byte,
|
||||
val actionKindId: Byte,
|
||||
val payloadVariant: Int,
|
||||
val moveOrItemId: Short,
|
||||
val targetEntityId: Long,
|
||||
val extraFlag: Byte,
|
||||
)
|
||||
|
||||
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 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)
|
||||
}
|
||||
|
||||
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 }
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class TierSlotSelection(val tierIndex: Byte, val slot: Byte)
|
||||
|
||||
sealed class BattleAction
|
||||
|
||||
data class SinglePokemonAction(val pokemonEntityId: Long, val moveSlot: Byte) : BattleAction()
|
||||
|
||||
data class MultiTierAction(val selections: List<TierSlotSelection>) : BattleAction()
|
||||
|
||||
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 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)
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleBoardCellPacket(
|
||||
val row: Byte,
|
||||
val column: Short,
|
||||
val entityId: Long,
|
||||
val valueA: Short,
|
||||
val valueB: Short,
|
||||
val flags: Byte,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
internal sealed class BattleMessageArgPayload
|
||||
|
||||
internal object EmptyArgPayload : BattleMessageArgPayload()
|
||||
|
||||
internal data class LongArgPayload(val value: Long) : BattleMessageArgPayload()
|
||||
|
||||
internal data class IntArgPayload(val value: Int) : BattleMessageArgPayload()
|
||||
|
||||
internal data class StringArgPayload(val value: String) : BattleMessageArgPayload()
|
||||
|
||||
internal data class ShortListArgPayload(val values: List<Short>) : BattleMessageArgPayload()
|
||||
|
||||
internal data class BattleMessageArg(
|
||||
val id: Byte,
|
||||
val type: Byte,
|
||||
val hasExtra: Boolean,
|
||||
val extra: Byte,
|
||||
val payload: BattleMessageArgPayload,
|
||||
)
|
||||
|
||||
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 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
|
||||
|
||||
internal object NullSerializedEntry : BattleSerializedEntry()
|
||||
|
||||
internal data class CreatureDataEntry(val value: Int, val args: List<BattleMessageArg>) :
|
||||
BattleSerializedEntry()
|
||||
|
||||
internal data class CreatureMovesEntry(val value: Byte, val moves: List<Short>) :
|
||||
BattleSerializedEntry()
|
||||
|
||||
internal data class MoveAnimationEntry(val a: Byte, val b: Byte, val moveId: Short) :
|
||||
BattleSerializedEntry()
|
||||
|
||||
internal data class TextCreatureEntry(val a: Byte, val typeId: Byte, val x: Short, val y: Short) :
|
||||
BattleSerializedEntry()
|
||||
|
||||
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) })
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
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 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 EmptyCreatureDataEntry -> throw MalformedPacketException("cannot encode default battle entry")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleBulkStatePacket(
|
||||
val phase: Byte,
|
||||
val firstGroup: List<BattleSerializedEntry>,
|
||||
val secondGroup: List<BattleSerializedEntry>,
|
||||
val valueA: Int,
|
||||
val valueB: Int,
|
||||
val flag: Byte,
|
||||
val thirdGroup: List<BattleSerializedEntry>,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
|
||||
class BattleCancelRequestPacket
|
||||
|
||||
object BattleCancelRequestPacketCodec : PacketCodec<BattleCancelRequestPacket>() {
|
||||
override fun CodecScope<BattleCancelRequestPacket>.body(): BattleCancelRequestPacket {
|
||||
return BattleCancelRequestPacket()
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleChallengeRequestPacket(
|
||||
val flags: Byte,
|
||||
val entryKindId: Byte,
|
||||
val battleFormat: Byte,
|
||||
val levelCap: Short,
|
||||
val allowedSpecies: List<Short>,
|
||||
val ruleSet: Byte,
|
||||
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 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 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,
|
||||
)
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S8
|
||||
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)
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
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 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)
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class MessageArg(
|
||||
val argId: Byte,
|
||||
val type: Int,
|
||||
val hasExtra: Boolean,
|
||||
val extra: Byte,
|
||||
val longValue: Long?,
|
||||
val intValue: Int?,
|
||||
val stringValue: String?,
|
||||
val shortValues: List<Short>?,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleDisconnectMessagePacket(
|
||||
val reason: Byte,
|
||||
val args: List<MessageArg>,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
|
||||
data class BattleEmptyEventPacket(
|
||||
val unit: Unit = Unit,
|
||||
)
|
||||
|
||||
object BattleEmptyEventPacketCodec : PacketCodec<BattleEmptyEventPacket>() {
|
||||
override fun CodecScope<BattleEmptyEventPacket>.body(): BattleEmptyEventPacket {
|
||||
return BattleEmptyEventPacket()
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S8
|
||||
|
||||
data class BattleEndDisconnectPacket(
|
||||
val reason: Byte,
|
||||
)
|
||||
|
||||
object BattleEndDisconnectPacketCodec : PacketCodec<BattleEndDisconnectPacket>() {
|
||||
override fun CodecScope<BattleEndDisconnectPacket>.body(): BattleEndDisconnectPacket {
|
||||
val reason = field(S8) { it.reason }
|
||||
return BattleEndDisconnectPacket(reason)
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S64LE
|
||||
|
||||
data class BattleEntityActionEventPacket(
|
||||
val sourceId: Long,
|
||||
val targetId: Long,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
private val MoveSlotCodec: Codec<Pair<Short, Byte>> = S16LE.then(S8)
|
||||
|
||||
data class BattleEntityDeltaPacket(
|
||||
val entityId: Long,
|
||||
val fieldMask: Int,
|
||||
val experienceLevel: Byte?,
|
||||
val experiencePoints: Int?,
|
||||
val statValues: List<Short>?,
|
||||
val moveSlots: List<Pair<Short, Byte>>?,
|
||||
val ppUps: Byte?,
|
||||
val currentHp: Short?,
|
||||
val faintFlag: Byte?,
|
||||
val speciesId: Short?,
|
||||
val forme: Byte?,
|
||||
val listType: Byte?,
|
||||
val sortKey: Short?,
|
||||
val evValues: List<Short>?,
|
||||
val level: Short?,
|
||||
val happiness: Short?,
|
||||
val shininessSeed: Int?,
|
||||
val experience: Int?,
|
||||
val flagA: Byte?,
|
||||
val flagB: Byte?,
|
||||
val encounterType: Byte?,
|
||||
val statusFlagsValue: Short?,
|
||||
val warnA: Short?,
|
||||
val warnB: Short?,
|
||||
val natureId: Byte?,
|
||||
val ribbons: Long?,
|
||||
val packedIvs: Int?,
|
||||
val effortValues: List<Short>?,
|
||||
val originalSpecies: Long?,
|
||||
val originalTrainerName: String?,
|
||||
val originalTrainerId: Int?,
|
||||
val shininessType: Byte?,
|
||||
val gender: Byte?,
|
||||
val ivs: List<Short>?,
|
||||
val caughtBall: Byte?,
|
||||
val statusFlags2: Short?,
|
||||
val statusList: List<Byte>?,
|
||||
val status: Byte?,
|
||||
)
|
||||
|
||||
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
|
||||
|
||||
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 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,
|
||||
)
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleMoveDataEntry(
|
||||
val entityId: Long,
|
||||
val value: Short,
|
||||
val actionCount: Int,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleEntityMoveEventPacket(
|
||||
val entityId: Long,
|
||||
val value: Short,
|
||||
val kind: Byte,
|
||||
val entries: List<BattleMoveDataEntry>,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S8
|
||||
|
||||
data class BattleEnumPairEventPacket(
|
||||
val eventType: Byte,
|
||||
val first: Byte,
|
||||
val second: Byte,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleLabeledMoveEntry(
|
||||
val entityId: Long,
|
||||
val value: Short,
|
||||
val actionCount: Int,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleLabeledMoveEventPacket(
|
||||
val byte1: Byte,
|
||||
val byte2: Byte,
|
||||
val value: Short,
|
||||
val byte3: Byte,
|
||||
val short2: Short,
|
||||
val label: String,
|
||||
val entries: List<BattleLabeledMoveEntry>,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S16LE
|
||||
import de.fiereu.bytecodec.S8
|
||||
|
||||
data class BattleListEventDetail(
|
||||
val listType: Byte,
|
||||
val value: Short,
|
||||
)
|
||||
|
||||
data class BattleListEventPacket(
|
||||
val kind: Byte,
|
||||
val value: Short,
|
||||
val subKind: Byte,
|
||||
val detail: BattleListEventDetail?,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleMoveDisableEntry(
|
||||
val present: Boolean,
|
||||
val disabled: Boolean,
|
||||
val disableTurns: Short,
|
||||
)
|
||||
|
||||
data class BattleMoveDisableSide(
|
||||
val entries: List<BattleMoveDisableEntry>,
|
||||
)
|
||||
|
||||
data class BattleMoveDisableUpdatePacket(
|
||||
val sides: List<BattleMoveDisableSide>,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
object BattleMoveDisableUpdatePacketCodec : PacketCodec<BattleMoveDisableUpdatePacket>() {
|
||||
override fun CodecScope<BattleMoveDisableUpdatePacket>.body(): BattleMoveDisableUpdatePacket {
|
||||
val sides = field(BattleMoveDisableSideCodec.repeat(2)) { it.sides }
|
||||
return BattleMoveDisableUpdatePacket(sides)
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleMoveAppearance(
|
||||
val name: String,
|
||||
val gender: Byte,
|
||||
val id: Int,
|
||||
val kind: Byte,
|
||||
val palettePack: Byte,
|
||||
val slots: List<Short>,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleMoveEntry(
|
||||
val moveId: Int,
|
||||
val tier: Byte,
|
||||
val int1: Int,
|
||||
val int2: Int,
|
||||
val appearances: List<BattleMoveAppearance>,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleMoveListPacket(
|
||||
val actionId: Short,
|
||||
val slot: Byte,
|
||||
val moves: List<BattleMoveEntry>,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.reserved
|
||||
|
||||
data class BattleMoveSelectionCancelPacket(
|
||||
val unit: Unit = Unit,
|
||||
)
|
||||
|
||||
object BattleMoveSelectionCancelPacketCodec : PacketCodec<BattleMoveSelectionCancelPacket>() {
|
||||
override fun CodecScope<BattleMoveSelectionCancelPacket>.body(): BattleMoveSelectionCancelPacket {
|
||||
reserved(byte = 0)
|
||||
return BattleMoveSelectionCancelPacket()
|
||||
}
|
||||
}
|
||||
+14
@@ -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.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)
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleTargetAppearance(
|
||||
val name: String,
|
||||
val gender: Byte,
|
||||
val id: Int,
|
||||
val kind: Byte,
|
||||
val palettePack: Byte,
|
||||
val slots: List<Short>,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleMoveTargetEntry(
|
||||
val entityId: Long,
|
||||
val weight: Float,
|
||||
val short1: Short,
|
||||
val int1: Int,
|
||||
val int2: Int,
|
||||
val appearance: BattleTargetAppearance,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleMoveTargetsPacket(
|
||||
val actionId: Int,
|
||||
val slot: Byte,
|
||||
val tier: Byte,
|
||||
val targets: List<BattleMoveTargetEntry>,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleMoveUsePacket(
|
||||
val targetEntityId: Long,
|
||||
val moveSlotIndex: Byte,
|
||||
val moveId: Short,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S16LE
|
||||
import de.fiereu.bytecodec.S64LE
|
||||
|
||||
data class BattlePartySlotSelectPacket(
|
||||
val slotIndex: Short,
|
||||
val pokemonEntityId: Long,
|
||||
val contextId: Short,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+14
@@ -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.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)
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S16LE
|
||||
import de.fiereu.bytecodec.S64LE
|
||||
|
||||
data class BattlePokemonSpritePacket(
|
||||
val entityId: Long,
|
||||
val spriteId: Short,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleStatusEffectData(
|
||||
val durationTurns: Int,
|
||||
val effectType: Byte,
|
||||
val sourceSlot: Byte,
|
||||
)
|
||||
|
||||
data class BattlePokemonStatusPacket(
|
||||
val entityId: Long,
|
||||
val statusId: Byte,
|
||||
val statusEffect: BattleStatusEffectData?,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.Bool
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
|
||||
data class BattlePromptSwitchPacket(
|
||||
val enabled: Boolean,
|
||||
)
|
||||
|
||||
object BattlePromptSwitchPacketCodec : PacketCodec<BattlePromptSwitchPacket>() {
|
||||
override fun CodecScope<BattlePromptSwitchPacket>.body(): BattlePromptSwitchPacket {
|
||||
val enabled = field(Bool) { it.enabled }
|
||||
return BattlePromptSwitchPacket(enabled)
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S8
|
||||
|
||||
data class BattleQueuedEventPacket(
|
||||
val packed: Byte,
|
||||
) {
|
||||
val value: Byte
|
||||
get() = (packed.toInt() and 0x7F).toByte()
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleRatingEntry(
|
||||
val entityId: Long,
|
||||
val tier: Byte,
|
||||
val bracket: Byte,
|
||||
val elo: Float,
|
||||
val short1: Short,
|
||||
val byte1: Byte,
|
||||
val int1: Int,
|
||||
val int2: Int,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleRatingBulkPacket(
|
||||
val ratings: List<BattleRatingEntry>,
|
||||
)
|
||||
|
||||
object BattleRatingBulkPacketCodec : PacketCodec<BattleRatingBulkPacket>() {
|
||||
override fun CodecScope<BattleRatingBulkPacket>.body(): BattleRatingBulkPacket {
|
||||
val ratings = field(BattleRatingEntryCodec.listPrefixed(U8)) { it.ratings }
|
||||
return BattleRatingBulkPacket(ratings)
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleRatingUpdatePacket(
|
||||
val entityId: Long,
|
||||
val tier: Byte,
|
||||
val bracket: Byte,
|
||||
val elo: Float,
|
||||
val short1: Short,
|
||||
val byte1: Byte,
|
||||
val int1: Int,
|
||||
val int2: Int,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.Bool
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
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)
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S32LE
|
||||
import de.fiereu.bytecodec.S64LE
|
||||
|
||||
data class BattleRewardSelectPacket(
|
||||
val targetEntityId: Long,
|
||||
val rewardIndex: Int,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleRankingEntry(
|
||||
val entityId: Long,
|
||||
val flag1: Byte,
|
||||
val flag2: Byte,
|
||||
val name: String,
|
||||
val value1: Short,
|
||||
val genderId: Short,
|
||||
val ribbons: Long,
|
||||
val byte1: Byte,
|
||||
val int1: Int,
|
||||
val byte2: Byte,
|
||||
val bool1: Boolean,
|
||||
val bool2: Boolean,
|
||||
)
|
||||
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleTierUpdate(
|
||||
val tierIndex: Byte,
|
||||
val unlocked: Boolean,
|
||||
val expiry: Long,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleMoveTarget(
|
||||
val targetType: Byte,
|
||||
val short1: Short,
|
||||
val short2: Short,
|
||||
val short3: Short,
|
||||
val byte1: Byte,
|
||||
val byte2: Byte,
|
||||
val flag1: Boolean,
|
||||
val flag2: Boolean,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleSelectablePokemon(
|
||||
val int1: Int,
|
||||
val int2: Int,
|
||||
val short1: Short,
|
||||
val short2: Short,
|
||||
val tierIndex: Byte,
|
||||
val targetsA: List<BattleMoveTarget>,
|
||||
val targetsB: List<BattleMoveTarget>,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleStorageItem(
|
||||
val typeByte: Byte,
|
||||
val short1: Short,
|
||||
val short2: Short,
|
||||
val short3: Short,
|
||||
val short4: Short,
|
||||
val byte1: Byte,
|
||||
val pokemonByte: Byte,
|
||||
val boxByte: Byte,
|
||||
)
|
||||
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleScreenOpenPacket(
|
||||
val active: Boolean,
|
||||
val wild: Boolean,
|
||||
val participants: List<BattleRankingEntry>,
|
||||
val tierUpdates: List<BattleTierUpdate>,
|
||||
val pokemon: List<BattleSelectablePokemon>,
|
||||
val storageItems: List<BattleStorageItem>,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleSendOutMember(
|
||||
val entityIdA: Long,
|
||||
val entityIdB: Long,
|
||||
val entityIdC: Long,
|
||||
val speciesByte: Byte,
|
||||
val nickname: String,
|
||||
val ownerName: String,
|
||||
val value: Int,
|
||||
val nameA: String,
|
||||
val nameB: String,
|
||||
val levelByte: Byte,
|
||||
val flag: Boolean,
|
||||
)
|
||||
|
||||
data class BattleSendOutActivePacket(
|
||||
val opponent: Boolean,
|
||||
val member: BattleSendOutMember?,
|
||||
)
|
||||
|
||||
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
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleAddStatusEffect(
|
||||
val durationTurns: Int,
|
||||
val effectType: Byte,
|
||||
val sourceSlot: Byte,
|
||||
)
|
||||
|
||||
data class BattleAddPokemon(
|
||||
val entityId: Long,
|
||||
val frontSpriteId: Short,
|
||||
val backSpriteId: Short,
|
||||
val side: Byte,
|
||||
val slot: Byte,
|
||||
val partyIndex: Byte,
|
||||
val statusEffect: BattleAddStatusEffect?,
|
||||
)
|
||||
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleSideAddPokemonPacket(
|
||||
val side: Byte,
|
||||
val pokemon: BattleAddPokemon,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattlePartyStatusEffect(
|
||||
val durationTurns: Int,
|
||||
val effectType: Byte,
|
||||
val sourceSlot: Byte,
|
||||
)
|
||||
|
||||
data class BattlePartyPokemon(
|
||||
val entityId: Long,
|
||||
val frontSpriteId: Short,
|
||||
val backSpriteId: Short,
|
||||
val side: Byte,
|
||||
val slot: Byte,
|
||||
val partyIndex: Byte,
|
||||
val statusEffect: BattlePartyStatusEffect?,
|
||||
)
|
||||
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleSidePartyPacket(
|
||||
val side: Byte,
|
||||
val replace: Boolean,
|
||||
val pokemon: List<BattlePartyPokemon>,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S64LE
|
||||
import de.fiereu.bytecodec.S8
|
||||
|
||||
data class BattleSideRemovePokemonPacket(
|
||||
val side: Byte,
|
||||
val entityId: Long,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
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 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 hashCode(): Int = simulationConfig.contentHashCode()
|
||||
}
|
||||
|
||||
object BattleSimulationRequestPacketCodec : PacketCodec<BattleSimulationRequestPacket>() {
|
||||
override fun CodecScope<BattleSimulationRequestPacket>.body(): BattleSimulationRequestPacket {
|
||||
val simulationConfig = field(SimulationConfigPayload) { it.simulationConfig }
|
||||
return BattleSimulationRequestPacket(simulationConfig)
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S8
|
||||
|
||||
data class BattleSlotActionPacket(
|
||||
val slotRefPacked: Byte,
|
||||
val actionByte: Byte,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S64LE
|
||||
import de.fiereu.bytecodec.S8
|
||||
|
||||
data class BattleSlotAnimationResetPacket(
|
||||
val entityId: Long,
|
||||
val slot: Byte,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S8
|
||||
|
||||
data class BattleSlotEventEnumPacket(
|
||||
val slot: Byte,
|
||||
val eventType: Byte,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.Bool
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S8
|
||||
|
||||
data class BattleSlotFlagEventPacket(
|
||||
val slot: Byte,
|
||||
val flag: Boolean,
|
||||
val immediate: Boolean,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.Bool
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S8
|
||||
|
||||
data class BattleSlotMoveEventPacket(
|
||||
val slot: Byte,
|
||||
val moveType: Byte,
|
||||
val resolved: Boolean,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.Bool
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S8
|
||||
|
||||
data class BattleSlotSwitchEventPacket(
|
||||
val slot: Byte,
|
||||
val switchType: Byte,
|
||||
val immediate: Boolean,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S8
|
||||
import de.fiereu.bytecodec.U8
|
||||
|
||||
data class BattleStartScenePacket(
|
||||
val battleType: Byte,
|
||||
val doubleBattle: Boolean,
|
||||
val perspective: Byte,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleStatCountersPacket(
|
||||
val entityId: Long,
|
||||
val baseCounter: Int,
|
||||
val counter1: Int?,
|
||||
val counter2: Int?,
|
||||
val counter3: Int?,
|
||||
val counter4: Int?,
|
||||
val counter5: Int?,
|
||||
val counter6: Int?,
|
||||
)
|
||||
|
||||
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,
|
||||
)
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleStatStagePacket(
|
||||
val entityId: Long,
|
||||
val stat: Byte,
|
||||
val value: Short,
|
||||
val stage: Byte,
|
||||
val flags: Byte,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S8
|
||||
|
||||
data class BattleStateBytePacket(
|
||||
val state: Byte,
|
||||
)
|
||||
|
||||
object BattleStateBytePacketCodec : PacketCodec<BattleStateBytePacket>() {
|
||||
override fun CodecScope<BattleStateBytePacket>.body(): BattleStateBytePacket {
|
||||
val state = field(S8) { it.state }
|
||||
return BattleStateBytePacket(state)
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S32LE
|
||||
import de.fiereu.bytecodec.S8
|
||||
|
||||
data class BattleStateSlotIntPacket(
|
||||
val index: Byte,
|
||||
val value: Int,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S16LE
|
||||
import de.fiereu.bytecodec.S8
|
||||
|
||||
data class BattleStatusFlagPacket(
|
||||
val scope: Byte,
|
||||
val flagId: Short,
|
||||
val flagValue: Short,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.Bool
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
|
||||
data class BattleSwitchPromptTogglePacket(
|
||||
val shown: Boolean,
|
||||
)
|
||||
|
||||
object BattleSwitchPromptTogglePacketCodec : PacketCodec<BattleSwitchPromptTogglePacket>() {
|
||||
override fun CodecScope<BattleSwitchPromptTogglePacket>.body(): BattleSwitchPromptTogglePacket {
|
||||
val shown = field(Bool) { it.shown }
|
||||
return BattleSwitchPromptTogglePacket(shown)
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattleSwitchSelectionsPacket(
|
||||
val selectedEntityIds: List<Long>,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S64LE
|
||||
|
||||
data class BattleTargetPickPacket(
|
||||
val targetEntityId: Long,
|
||||
)
|
||||
|
||||
object BattleTargetPickPacketCodec : PacketCodec<BattleTargetPickPacket>() {
|
||||
override fun CodecScope<BattleTargetPickPacket>.body(): BattleTargetPickPacket {
|
||||
val targetEntityId = field(S64LE) { it.targetEntityId }
|
||||
return BattleTargetPickPacket(targetEntityId)
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.Bool
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S16LE
|
||||
|
||||
data class BattleTeamPreviewConfirmPacket(
|
||||
val side: Short,
|
||||
val isOwnTeam: Boolean,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BattlePreviewMember(
|
||||
val entityIdA: Long,
|
||||
val entityIdB: Long,
|
||||
val entityIdC: Long,
|
||||
val speciesByte: Byte,
|
||||
val nickname: String,
|
||||
val ownerName: String,
|
||||
val value: Int,
|
||||
val nameA: String,
|
||||
val nameB: String,
|
||||
val levelByte: Byte,
|
||||
val flag: Boolean,
|
||||
)
|
||||
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class BattleTeamPreviewListPacket(
|
||||
val side: Short,
|
||||
val opponent: Boolean,
|
||||
val members: List<BattlePreviewMember>,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
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)
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
|
||||
class BattleTransitionReadyPacket
|
||||
|
||||
object BattleTransitionReadyPacketCodec : PacketCodec<BattleTransitionReadyPacket>() {
|
||||
override fun CodecScope<BattleTransitionReadyPacket>.body(): BattleTransitionReadyPacket {
|
||||
return BattleTransitionReadyPacket()
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S16LE
|
||||
import de.fiereu.bytecodec.S64LE
|
||||
|
||||
data class BattleUseItemPacket(
|
||||
val pokemonEntityId: Long,
|
||||
val quantity: Short,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
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)
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class BreedingStatContribution(
|
||||
val source: Byte,
|
||||
val weight: Float,
|
||||
val amount: Int,
|
||||
)
|
||||
|
||||
data class BreedingStatEntry(
|
||||
val guaranteed: Boolean,
|
||||
val statId: Short,
|
||||
val contributions: List<BreedingStatContribution>,
|
||||
)
|
||||
|
||||
data class BreedingForecastPacket(
|
||||
val parentA: Long,
|
||||
val parentB: Long,
|
||||
val hasPreview: Boolean,
|
||||
val species: Short,
|
||||
val form: Byte,
|
||||
val statEntries: List<BreedingStatEntry>,
|
||||
val shininessTypes: List<Byte>,
|
||||
val valueIds: List<Short>,
|
||||
val valueSources: List<Byte>,
|
||||
val gender: Byte,
|
||||
val nature: Short,
|
||||
val shiny: Boolean,
|
||||
val cost: Int,
|
||||
val secondaryCost: Int,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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 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)
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
)
|
||||
}
|
||||
}
|
||||
+14
@@ -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.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)
|
||||
}
|
||||
}
|
||||
@@ -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.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)
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S64LE
|
||||
|
||||
data class CameraFollowEntityPacket(
|
||||
val entityId: Long,
|
||||
)
|
||||
|
||||
object CameraFollowEntityPacketCodec : PacketCodec<CameraFollowEntityPacket>() {
|
||||
override fun CodecScope<CameraFollowEntityPacket>.body(): CameraFollowEntityPacket {
|
||||
val entityId = field(S64LE) { it.entityId }
|
||||
return CameraFollowEntityPacket(entityId)
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S64LE
|
||||
|
||||
data class CancelEntityMessagePacket(
|
||||
val entityId: Long,
|
||||
)
|
||||
|
||||
object CancelEntityMessagePacketCodec : PacketCodec<CancelEntityMessagePacket>() {
|
||||
override fun CodecScope<CancelEntityMessagePacket>.body(): CancelEntityMessagePacket {
|
||||
val entityId = field(S64LE) { it.entityId }
|
||||
return CancelEntityMessagePacket(entityId)
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
|
||||
class CancelMatchmakingSearchPacket
|
||||
|
||||
object CancelMatchmakingSearchPacketCodec : PacketCodec<CancelMatchmakingSearchPacket>() {
|
||||
override fun CodecScope<CancelMatchmakingSearchPacket>.body(): CancelMatchmakingSearchPacket {
|
||||
return CancelMatchmakingSearchPacket()
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
|
||||
class CancelSocialInteractionPacket
|
||||
|
||||
object CancelSocialInteractionPacketCodec : PacketCodec<CancelSocialInteractionPacket>() {
|
||||
override fun CodecScope<CancelSocialInteractionPacket>.body(): CancelSocialInteractionPacket {
|
||||
return CancelSocialInteractionPacket()
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class CategoryFlagsPacket(
|
||||
val entryKind: Int,
|
||||
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 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)
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class ChannelTypeBinding(val chatType: Short, val channel: Byte)
|
||||
|
||||
data class ChannelGroupBinding(val channel: Byte, val members: List<Short>)
|
||||
|
||||
data class ChannelAssignmentsPacket(
|
||||
val typeBindings: List<ChannelTypeBinding>,
|
||||
val groupBindings: List<ChannelGroupBinding>,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class ChannelCountEntry(
|
||||
val channelId: Short,
|
||||
val flag: Boolean,
|
||||
)
|
||||
|
||||
data class ChannelCountDeltaPacket(
|
||||
val category: Byte,
|
||||
val entries: List<ChannelCountEntry>,
|
||||
val delta: Byte,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.Bool
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
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)
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class AppearanceMoveEntry(val slot: Int, val packedMove: Short, val ppUp: Byte?)
|
||||
|
||||
data class AppearanceMoveSet(val categoryByte: Byte, val moves: List<AppearanceMoveEntry>)
|
||||
|
||||
data class CharacterAppearanceApplyPacket(
|
||||
val characterName: String,
|
||||
val appearanceTypeA: Byte,
|
||||
val appearanceTypeB: Byte,
|
||||
val creatureMoves: AppearanceMoveSet,
|
||||
)
|
||||
|
||||
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 }
|
||||
|
||||
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))
|
||||
}
|
||||
}
|
||||
return CharacterAppearanceApplyPacket(
|
||||
characterName,
|
||||
appearanceTypeA,
|
||||
appearanceTypeB,
|
||||
AppearanceMoveSet(categoryByte, moves),
|
||||
)
|
||||
}
|
||||
}
|
||||
+2
-15
@@ -1,22 +1,9 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.Bool
|
||||
import de.fiereu.bytecodec.Codec
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.ReadBuffer
|
||||
import de.fiereu.bytecodec.S32LE
|
||||
import de.fiereu.bytecodec.U8
|
||||
import de.fiereu.bytecodec.Utf16LeNullTerminated
|
||||
import de.fiereu.bytecodec.WriteBuffer
|
||||
import de.fiereu.bytecodec.*
|
||||
import de.fiereu.openmmo.common.CharacterInfo
|
||||
import de.fiereu.openmmo.common.Pokemon
|
||||
import de.fiereu.openmmo.net.game.codecs.CharacterInfoCodecLong
|
||||
import de.fiereu.openmmo.net.game.codecs.CharacterInfoCodecShort
|
||||
import de.fiereu.openmmo.net.game.codecs.DefaultSkinSetCodec
|
||||
import de.fiereu.openmmo.net.game.codecs.PokemonCodec
|
||||
import de.fiereu.openmmo.net.game.codecs.SkinSet
|
||||
import de.fiereu.openmmo.net.game.codecs.SkinSetCodecNoLeading
|
||||
import de.fiereu.openmmo.net.game.codecs.*
|
||||
|
||||
data class CharacterEntry(
|
||||
val characterInfo: CharacterInfo,
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class ChatChannelMessagesPacket(
|
||||
val channelType: Byte,
|
||||
val clear: Boolean,
|
||||
val refresh: Boolean,
|
||||
val messageCount: Int,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class ChatChannelUser(
|
||||
val channelId: Short,
|
||||
val rank: Byte,
|
||||
)
|
||||
|
||||
data class ChatChannelUserListPacket(
|
||||
val channelType: Byte,
|
||||
val clear: Boolean,
|
||||
val refresh: Boolean,
|
||||
val unreadCount: Int,
|
||||
val unreadMentionCount: Int,
|
||||
val users: List<ChatChannelUser>,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
)
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S16LE
|
||||
import de.fiereu.bytecodec.S8
|
||||
|
||||
data class ChatLocalePreferencesPacket(
|
||||
val languageId: Byte,
|
||||
val chatChannelMask: Short,
|
||||
val languageFilterMask: Short,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+1
-7
@@ -1,12 +1,6 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.MalformedPacketException
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S64LE
|
||||
import de.fiereu.bytecodec.S8
|
||||
import de.fiereu.bytecodec.U8
|
||||
import de.fiereu.bytecodec.Utf16LeNullTerminated
|
||||
import de.fiereu.bytecodec.*
|
||||
import de.fiereu.openmmo.common.enums.ChatType
|
||||
import de.fiereu.openmmo.common.enums.Language
|
||||
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S8
|
||||
import de.fiereu.bytecodec.Utf16LeNullTerminated
|
||||
|
||||
data class ChatMessageSendPacket(
|
||||
val mode: Byte,
|
||||
val target: String,
|
||||
val message: String?,
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.S64LE
|
||||
|
||||
data class ChatMessageWithdrawPacket(
|
||||
val authorId: Long,
|
||||
)
|
||||
|
||||
object ChatMessageWithdrawPacketCodec : PacketCodec<ChatMessageWithdrawPacket>() {
|
||||
override fun CodecScope<ChatMessageWithdrawPacket>.body(): ChatMessageWithdrawPacket {
|
||||
val authorId = field(S64LE) { it.authorId }
|
||||
return ChatMessageWithdrawPacket(authorId)
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class ChunkedImagePacket(
|
||||
val controlType: Byte,
|
||||
val imageType: Byte?,
|
||||
val chunkIndex: Int?,
|
||||
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 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)
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.CodecScope
|
||||
import de.fiereu.bytecodec.PacketCodec
|
||||
import de.fiereu.bytecodec.U16LE
|
||||
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 hashCode(): Int = data.contentHashCode()
|
||||
}
|
||||
|
||||
object ChunkedTransferAppendPacketCodec : PacketCodec<ChunkedTransferAppendPacket>() {
|
||||
override fun CodecScope<ChunkedTransferAppendPacket>.body(): ChunkedTransferAppendPacket {
|
||||
val data = field(bytesPrefixed(U16LE)) { it.data }
|
||||
return ChunkedTransferAppendPacket(data)
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class ChunkedTransferBeginPacket(
|
||||
val transferId: Long,
|
||||
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 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)
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class ChunkedTransferDataPacket(
|
||||
val transferId: Long,
|
||||
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 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 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)
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
data class CookieNamedValue(val key: Byte, val value: String)
|
||||
|
||||
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 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 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)
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package de.fiereu.openmmo.net.game.packets
|
||||
|
||||
import de.fiereu.bytecodec.*
|
||||
|
||||
private val LocalIpBytes = fixedBytes(4)
|
||||
|
||||
data class ClientDiagnosticsPacket(
|
||||
val worldStateFlags: Int,
|
||||
val renderMetric0: Byte,
|
||||
val renderMetric1: Byte,
|
||||
val renderMetric2: Byte,
|
||||
val renderMetric3: Byte,
|
||||
val knownEntityCount: Short,
|
||||
val timestampMillis: Long,
|
||||
val timestampNanos: Long,
|
||||
val localIp: ByteArray,
|
||||
val trackedEntityIds: List<Long>,
|
||||
) {
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is ClientDiagnosticsPacket &&
|
||||
worldStateFlags == other.worldStateFlags &&
|
||||
renderMetric0 == other.renderMetric0 &&
|
||||
renderMetric1 == other.renderMetric1 &&
|
||||
renderMetric2 == other.renderMetric2 &&
|
||||
renderMetric3 == other.renderMetric3 &&
|
||||
knownEntityCount == other.knownEntityCount &&
|
||||
timestampMillis == other.timestampMillis &&
|
||||
timestampNanos == other.timestampNanos &&
|
||||
localIp.contentEquals(other.localIp) &&
|
||||
trackedEntityIds == other.trackedEntityIds
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var r = worldStateFlags
|
||||
r = r * 31 + renderMetric0
|
||||
r = r * 31 + renderMetric1
|
||||
r = r * 31 + renderMetric2
|
||||
r = r * 31 + renderMetric3
|
||||
r = r * 31 + knownEntityCount
|
||||
r = r * 31 + timestampMillis.hashCode()
|
||||
r = r * 31 + timestampNanos.hashCode()
|
||||
r = r * 31 + localIp.contentHashCode()
|
||||
r = r * 31 + trackedEntityIds.hashCode()
|
||||
return r
|
||||
}
|
||||
}
|
||||
|
||||
object ClientDiagnosticsPacketCodec : PacketCodec<ClientDiagnosticsPacket>() {
|
||||
override fun CodecScope<ClientDiagnosticsPacket>.body(): ClientDiagnosticsPacket {
|
||||
val worldStateFlags = field(S32LE) { it.worldStateFlags }
|
||||
val renderMetric0 = field(S8) { it.renderMetric0 }
|
||||
val renderMetric1 = field(S8) { it.renderMetric1 }
|
||||
val renderMetric2 = field(S8) { it.renderMetric2 }
|
||||
val renderMetric3 = field(S8) { it.renderMetric3 }
|
||||
val knownEntityCount = field(S16LE) { it.knownEntityCount }
|
||||
val timestampMillis = field(S64LE) { it.timestampMillis }
|
||||
val timestampNanos = field(S64LE) { it.timestampNanos }
|
||||
val localIp = field(LocalIpBytes) { it.localIp }
|
||||
val trackedEntityIds = field(S64LE.listPrefixed(U8)) { it.trackedEntityIds }
|
||||
return ClientDiagnosticsPacket(
|
||||
worldStateFlags,
|
||||
renderMetric0,
|
||||
renderMetric1,
|
||||
renderMetric2,
|
||||
renderMetric3,
|
||||
knownEntityCount,
|
||||
timestampMillis,
|
||||
timestampNanos,
|
||||
localIp,
|
||||
trackedEntityIds,
|
||||
)
|
||||
}
|
||||
}
|
||||
+14
@@ -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.S32LE
|
||||
|
||||
data class ClientSettingUpdatePacket(val settingsValue: Int)
|
||||
|
||||
object ClientSettingUpdatePacketCodec : PacketCodec<ClientSettingUpdatePacket>() {
|
||||
override fun CodecScope<ClientSettingUpdatePacket>.body(): ClientSettingUpdatePacket {
|
||||
val settingsValue = field(S32LE) { it.settingsValue }
|
||||
return ClientSettingUpdatePacket(settingsValue)
|
||||
}
|
||||
}
|
||||
Loaded 100 of 366 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user