From cd7c7c9aa76cc0258bce837fba17089e0b674294 Mon Sep 17 00:00:00 2001 From: Fiereu Date: Fri, 12 Jun 2026 14:53:05 +0200 Subject: [PATCH] feat(game): add game protocol packets (100% ai slop) --- .../fiereu/openmmo/net/game/GameProtocol.kt | 668 +++++++++++++++--- .../net/game/codecs/CharacterInfoCodec.kt | 151 ++-- .../openmmo/net/game/codecs/PokemonCodec.kt | 184 +++-- .../openmmo/net/game/codecs/SkinCodec.kt | 62 +- .../openmmo/net/game/codecs/Tile2DCodec.kt | 10 +- .../game/packets/ActiveBattleSidePacket.kt | 16 + .../packets/ActivePokemonSummaryPacket.kt | 214 ++++++ .../net/game/packets/AdminNoteActionPacket.kt | 43 ++ .../packets/AppearanceRequestResultPacket.kt | 19 + .../game/packets/AssignBreedingSlotPacket.kt | 21 + .../game/packets/BatchInputEventsPacket.kt | 151 ++++ .../game/packets/BattleActionOutcomePacket.kt | 110 +++ .../net/game/packets/BattleActionPacket.kt | 22 + .../packets/BattleActionPromptTogglePacket.kt | 16 + .../game/packets/BattleActionResultPacket.kt | 31 + .../game/packets/BattleActionSelectPacket.kt | 48 ++ .../game/packets/BattleActionSubmitPacket.kt | 65 ++ .../net/game/packets/BattleBoardCellPacket.kt | 24 + .../net/game/packets/BattleBulkStatePacket.kt | 186 +++++ .../game/packets/BattleCancelRequestPacket.kt | 12 + .../packets/BattleChallengeRequestPacket.kt | 81 +++ .../game/packets/BattleChatMessagePacket.kt | 16 + .../game/packets/BattleControlBytesPacket.kt | 23 + .../packets/BattleDisconnectMessagePacket.kt | 54 ++ .../game/packets/BattleEmptyEventPacket.kt | 14 + .../game/packets/BattleEndDisconnectPacket.kt | 16 + .../packets/BattleEntityActionEventPacket.kt | 18 + .../game/packets/BattleEntityDeltaPacket.kt | 135 ++++ .../packets/BattleEntityMoveEventPacket.kt | 36 + .../game/packets/BattleEnumPairEventPacket.kt | 20 + .../packets/BattleLabeledMoveEventPacket.kt | 42 ++ .../net/game/packets/BattleListEventPacket.kt | 33 + .../packets/BattleMoveDisableUpdatePacket.kt | 46 ++ .../net/game/packets/BattleMoveListPacket.kt | 60 ++ .../BattleMoveSelectionCancelPacket.kt | 16 + .../packets/BattleMoveSlotChoicePacket.kt | 14 + .../game/packets/BattleMoveTargetsPacket.kt | 64 ++ .../net/game/packets/BattleMoveUsePacket.kt | 18 + .../packets/BattlePartySlotSelectPacket.kt | 21 + .../game/packets/BattlePartySwitchPacket.kt | 14 + .../game/packets/BattlePokemonSpritePacket.kt | 19 + .../game/packets/BattlePokemonStatusPacket.kt | 31 + .../game/packets/BattlePromptSwitchPacket.kt | 16 + .../game/packets/BattleQueuedEventPacket.kt | 22 + .../game/packets/BattleRatingBulkPacket.kt | 40 ++ .../game/packets/BattleRatingUpdatePacket.kt | 28 + .../net/game/packets/BattleReadyPacket.kt | 14 + .../game/packets/BattleRewardSelectPacket.kt | 19 + .../game/packets/BattleScreenOpenPacket.kt | 186 +++++ .../game/packets/BattleSendOutActivePacket.kt | 48 ++ .../packets/BattleSideAddPokemonPacket.kt | 62 ++ .../net/game/packets/BattleSidePartyPacket.kt | 66 ++ .../packets/BattleSideRemovePokemonPacket.kt | 19 + .../packets/BattleSimulationRequestPacket.kt | 30 + .../game/packets/BattleSlotActionPacket.kt | 18 + .../packets/BattleSlotAnimationResetPacket.kt | 19 + .../game/packets/BattleSlotEventEnumPacket.kt | 18 + .../game/packets/BattleSlotFlagEventPacket.kt | 21 + .../game/packets/BattleSlotMoveEventPacket.kt | 21 + .../packets/BattleSlotSwitchEventPacket.kt | 21 + .../game/packets/BattleStartScenePacket.kt | 21 + .../game/packets/BattleStatCountersPacket.kt | 46 ++ .../net/game/packets/BattleStatStagePacket.kt | 22 + .../net/game/packets/BattleStateBytePacket.kt | 16 + .../game/packets/BattleStateSlotIntPacket.kt | 19 + .../game/packets/BattleStatusFlagPacket.kt | 21 + .../packets/BattleSwitchPromptTogglePacket.kt | 16 + .../packets/BattleSwitchSelectionsPacket.kt | 16 + .../game/packets/BattleTargetPickPacket.kt | 16 + .../packets/BattleTeamPreviewConfirmPacket.kt | 19 + .../packets/BattleTeamPreviewListPacket.kt | 57 ++ .../game/packets/BattleTierSelectPacket.kt | 15 + .../packets/BattleTransitionReadyPacket.kt | 12 + .../net/game/packets/BattleUseItemPacket.kt | 19 + .../net/game/packets/BlockPlayerPacket.kt | 15 + .../game/packets/BreedingForecastPacket.kt | 120 ++++ .../net/game/packets/ByteArgumentPacket.kt | 14 + .../net/game/packets/ByteChoicePacket.kt | 14 + .../game/packets/CameraFollowEntityPacket.kt | 16 + .../game/packets/CancelEntityMessagePacket.kt | 16 + .../packets/CancelMatchmakingSearchPacket.kt | 12 + .../packets/CancelSocialInteractionPacket.kt | 12 + .../net/game/packets/CategoryFlagsPacket.kt | 31 + .../game/packets/ChannelAssignmentsPacket.kt | 38 + .../game/packets/ChannelCountDeltaPacket.kt | 33 + .../net/game/packets/ChannelSwitchPacket.kt | 16 + .../packets/CharacterAppearanceApplyPacket.kt | 51 ++ .../net/game/packets/CharactersListPacket.kt | 87 +-- .../game/packets/ChatChannelMessagesPacket.kt | 20 + .../game/packets/ChatChannelUserListPacket.kt | 46 ++ .../packets/ChatLocalePreferencesPacket.kt | 21 + .../net/game/packets/ChatMessagePacket.kt | 68 +- .../net/game/packets/ChatMessageSendPacket.kt | 22 + .../game/packets/ChatMessageWithdrawPacket.kt | 16 + .../net/game/packets/ChunkedImagePacket.kt | 41 ++ .../packets/ChunkedTransferAppendPacket.kt | 22 + .../packets/ChunkedTransferBeginPacket.kt | 31 + .../game/packets/ChunkedTransferDataPacket.kt | 46 ++ .../game/packets/ClientCookieUpdatePacket.kt | 57 ++ .../game/packets/ClientDiagnosticsPacket.kt | 72 ++ .../game/packets/ClientSettingUpdatePacket.kt | 14 + .../packets/ContactCategoryGroupPacket.kt | 18 + .../net/game/packets/ContactDeletePacket.kt | 16 + .../net/game/packets/ContactInsertPacket.kt | 42 ++ .../game/packets/ContactOnlineStatePacket.kt | 19 + .../net/game/packets/ContactRosterPacket.kt | 56 ++ .../packets/CoopScoreboardRequestPacket.kt | 12 + .../net/game/packets/CreateCharacterPacket.kt | 8 +- .../game/packets/CreateMarketListingPacket.kt | 20 + .../net/game/packets/CurrencyBalancePacket.kt | 18 + .../game/packets/CustomizationAcceptPacket.kt | 15 + .../CustomizeCharacterAppearancePacket.kt | 65 ++ .../packets/DataContentSyncBatchPacket.kt | 36 + .../packets/DataDigestSyncBatchedPacket.kt | 28 + .../net/game/packets/DataDigestSyncPacket.kt | 28 + .../packets/DataDigestSyncResponsePacket.kt | 36 + .../net/game/packets/DialogActionPacket.kt | 152 ++++ .../net/game/packets/DialogChoicePacket.kt | 10 +- .../net/game/packets/DialogDataPacket.kt | 68 +- .../net/game/packets/DialogResponsePacket.kt | 19 + .../game/packets/DisconnectNoticePacket.kt | 23 + .../net/game/packets/DuelChallengePacket.kt | 84 +++ .../game/packets/DuelInviteOutcomePacket.kt | 16 + .../net/game/packets/DuelInvitePacket.kt | 21 + .../game/packets/EggIncubatorSlotsPacket.kt | 39 + .../game/packets/EntityActionRequestPacket.kt | 23 + .../packets/EntityAppearancePatchPacket.kt | 70 ++ .../packets/EntityAppearanceSyncPacket.kt | 38 + .../packets/EntityAttributeChangePacket.kt | 42 ++ .../packets/EntityChecklistPromptPacket.kt | 33 + .../net/game/packets/EntityCoordSyncPacket.kt | 21 + .../net/game/packets/EntityDespawnPacket.kt | 18 + .../game/packets/EntityEmoteBubblePacket.kt | 24 + .../net/game/packets/EntityFaceTurnPacket.kt | 19 + .../game/packets/EntityFramesUpdatePacket.kt | 38 + .../packets/EntityGroupMemberAddPacket.kt | 59 ++ .../packets/EntityGroupMemberRemovePacket.kt | 18 + .../game/packets/EntityGroupSnapshotPacket.kt | 92 +++ .../net/game/packets/EntityInteractPacket.kt | 10 +- .../packets/EntityInteractRequestPacket.kt | 36 + .../packets/EntityInteractionFlagPacket.kt | 19 + .../net/game/packets/EntityLeavePacket.kt | 8 +- .../net/game/packets/EntityMovePacket.kt | 28 +- .../net/game/packets/EntityMovePpPacket.kt | 21 + .../game/packets/EntityNameChoicesPacket.kt | 29 + .../packets/EntityNameVisibilityPacket.kt | 23 + .../game/packets/EntityPanelSelectPacket.kt | 16 + .../net/game/packets/EntityPresencePacket.kt | 19 + .../net/game/packets/EntityRenamePacket.kt | 19 + .../game/packets/EntitySpriteChangePacket.kt | 22 + .../net/game/packets/EntityTitleTagPacket.kt | 19 + .../game/packets/EventOverlayStatePacket.kt | 133 ++++ .../packets/EvolutionPromptResponsePacket.kt | 16 + .../game/packets/ExchangeItemRequestPacket.kt | 21 + .../net/game/packets/FaceDirectionPacket.kt | 10 +- .../packets/FieldMapBattleSlotMarkerPacket.kt | 21 + .../FieldMapBattleSlotTileMapPacket.kt | 30 + .../packets/FieldMapTilePaletteApplyPacket.kt | 35 + .../net/game/packets/FollowerAdvancePacket.kt | 20 + .../packets/FriendProfileRequestPacket.kt | 14 + .../game/packets/FriendRosterDeltaPacket.kt | 16 + .../net/game/packets/FriendRosterPacket.kt | 30 + .../game/packets/GameHandshakeHelloPacket.kt | 168 +++++ .../net/game/packets/GameShopCatalogPacket.kt | 52 ++ .../net/game/packets/GmPanelEntryPacket.kt | 20 + .../net/game/packets/GmPanelVariantPacket.kt | 16 + .../net/game/packets/GmPlayerLookupPacket.kt | 175 +++++ .../game/packets/GroupMemberRosterPacket.kt | 75 ++ .../game/packets/GtlConfirmPurchasePacket.kt | 19 + .../game/packets/GtlCreateListingPacket.kt | 54 ++ .../net/game/packets/GtlItemMarketPacket.kt | 48 ++ .../game/packets/GtlListingActionPacket.kt | 19 + .../game/packets/GtlListingCancelPacket.kt | 16 + .../game/packets/GtlListingSearchPacket.kt | 16 + .../net/game/packets/GtlListingsPagePacket.kt | 59 ++ .../game/packets/GtlMarketListingsPacket.kt | 104 +++ .../net/game/packets/GtlOpenSessionPacket.kt | 19 + .../net/game/packets/GtlPriceHistoryPacket.kt | 44 ++ .../game/packets/GtlPurchaseListingPacket.kt | 21 + .../net/game/packets/GtlPurchasePacket.kt | 22 + .../net/game/packets/GtlSearchFilterPacket.kt | 16 + .../packets/GtlSellPokemonListingPacket.kt | 45 ++ .../game/packets/GtlTradeLogRequestPacket.kt | 12 + .../game/packets/GuildActivityLogPacket.kt | 46 ++ .../GuildActivityLogPageRequestPacket.kt | 17 + .../net/game/packets/GuildChatSendPacket.kt | 16 + .../net/game/packets/GuildDepartPacket.kt | 12 + .../GuildDisbandToggleRequestPacket.kt | 19 + .../game/packets/GuildMemberExpelPacket.kt | 16 + .../game/packets/GuildMemberPresencePacket.kt | 19 + .../packets/GuildMemberRankAssignPacket.kt | 19 + .../packets/GuildMemberRankChangePacket.kt | 20 + .../net/game/packets/GuildMembershipPacket.kt | 66 ++ .../net/game/packets/GuildMotdUpdatePacket.kt | 16 + .../game/packets/GuildProfileSyncPacket.kt | 53 ++ .../packets/GuildRankLabelUpdatePacket.kt | 19 + .../GuildRankPermissionUpdatePacket.kt | 30 + .../net/game/packets/GuildRosterAddPacket.kt | 43 ++ .../net/game/packets/GuildRosterBulkPacket.kt | 48 ++ .../game/packets/GuildRosterRemovePacket.kt | 17 + .../game/packets/HeartbeatRequestPacket.kt | 12 + .../net/game/packets/HighScoreBoardPacket.kt | 59 ++ .../packets/InGameChallengeResponsePacket.kt | 16 + .../game/packets/InstanceReadyCheckPacket.kt | 14 + .../net/game/packets/InteractivePacket.kt | 27 +- .../game/packets/InteractiveResponsePacket.kt | 10 +- .../packets/JoinMatchmakingQueuePacket.kt | 12 + .../openmmo/net/game/packets/JoinPacket.kt | 227 +++--- .../net/game/packets/JoinResponsePacket.kt | 92 ++- .../net/game/packets/KeepAlivePacket.kt | 43 +- .../packets/LeaderboardViewRequestPacket.kt | 16 + .../net/game/packets/LearnedMovesetPacket.kt | 66 ++ .../net/game/packets/LeaveBattlePacket.kt | 12 + .../game/packets/LeaveChatChannelPacket.kt | 12 + .../packets/LeaveMatchmakingQueuePacket.kt | 12 + .../net/game/packets/LinkKickMemberPacket.kt | 16 + .../net/game/packets/ListWindowPagePacket.kt | 54 ++ .../net/game/packets/LoadEntityPacket.kt | 99 ++- .../openmmo/net/game/packets/LoadMapPacket.kt | 284 ++++---- .../game/packets/LocalCharacterDeltaPacket.kt | 76 ++ .../game/packets/LocalPlayerStatePacket.kt | 81 +++ .../packets/MailAttachmentRequestPacket.kt | 16 + .../net/game/packets/MailComposeSendPacket.kt | 60 ++ .../net/game/packets/MapCellTilesetPacket.kt | 23 + .../net/game/packets/MapLoadedAckPacket.kt | 12 + .../net/game/packets/MapReadySignalPacket.kt | 12 + .../packets/MapTileAnimationTogglePacket.kt | 21 + .../game/packets/MapTileAttributeSetPacket.kt | 22 + .../packets/MapTileEntityStateSetPacket.kt | 23 + .../packets/MapTileObjectRepositionPacket.kt | 29 + .../packets/MapTileObjectSlotSetPacket.kt | 32 + .../net/game/packets/MapTransitionPacket.kt | 6 +- .../game/packets/MapWeatherModeSetPacket.kt | 19 + .../net/game/packets/MarketBoardPagePacket.kt | 48 ++ .../packets/MarketListingsRequestPacket.kt | 15 + .../game/packets/MarketSearchFilterPacket.kt | 21 + .../game/packets/MatchmakingActionPacket.kt | 79 +++ .../packets/MatchmakingLanguagePrefsPacket.kt | 12 + .../MatchmakingMemberProgressPacket.kt | 21 + .../game/packets/MatchmakingRentalsPacket.kt | 69 ++ .../game/packets/MatchmakingSideTeamPacket.kt | 83 +++ .../net/game/packets/MenuPagePayloadPacket.kt | 38 + .../net/game/packets/MenuPromptClosePacket.kt | 16 + .../net/game/packets/MenuPromptOpenPacket.kt | 64 ++ .../net/game/packets/MenuVisibilityPacket.kt | 19 + .../packets/ModerationActionConfirmPacket.kt | 16 + .../packets/MonsterFavoriteTogglePacket.kt | 16 + .../game/packets/MonsterFormActionPacket.kt | 16 + .../packets/MonsterInspectRequestPacket.kt | 21 + .../game/packets/MonsterRecordBookPacket.kt | 29 + .../net/game/packets/MonsterRenamePacket.kt | 16 + .../packets/MonsterStatusConditionPacket.kt | 16 + .../game/packets/MountMoveCooldownPacket.kt | 20 + .../net/game/packets/MovementPacket.kt | 14 +- .../packets/NamedCategoryEntriesPacket.kt | 61 ++ .../net/game/packets/NpcAnimationPacket.kt | 10 +- .../game/packets/NpcDialogResponsePacket.kt | 19 + .../game/packets/NpcDialogueChoicePacket.kt | 26 + .../packets/NpcInteractionChoicePacket.kt | 16 + .../net/game/packets/NpcPanelTogglePacket.kt | 25 + .../net/game/packets/NpcSpawnPacket.kt | 41 +- .../net/game/packets/NpcUpdatePacket.kt | 28 +- .../openmmo/net/game/packets/NullPacket.kt | 22 +- .../packets/ObjectiveProgressBulkPacket.kt | 30 + .../game/packets/ObjectiveProgressPacket.kt | 18 + .../packets/OpenAppearanceEditorPacket.kt | 16 + .../game/packets/OptionListWindowPacket.kt | 42 ++ .../packets/OverworldParticleSpawnPacket.kt | 25 + .../game/packets/OverworldPathToTilePacket.kt | 21 + .../game/packets/OverworldStepMovePacket.kt | 18 + .../packets/OverworldWeatherControlPacket.kt | 58 ++ .../game/packets/PartyInfoRequestPacket.kt | 12 + .../net/game/packets/PartyMemberJoinPacket.kt | 20 + .../game/packets/PartyMemberLeavePacket.kt | 16 + .../game/packets/PartyMemberSelectPacket.kt | 16 + .../net/game/packets/PartyRosterPacket.kt | 34 + .../net/game/packets/PcBoxRenamePacket.kt | 19 + .../net/game/packets/PcBoxStorePacket.kt | 21 + .../packets/PendingRequestCancelPacket.kt | 16 + .../net/game/packets/PlayerChatInputPacket.kt | 16 + .../game/packets/PlayerFacingChangePacket.kt | 14 + .../net/game/packets/PlayerInputLockPacket.kt | 16 + .../packets/PlayerPositionUpdatePacket.kt | 32 + .../game/packets/PlayerStopMovingPacket.kt | 12 + .../game/packets/PokedexSpeciesResetPacket.kt | 14 + .../packets/PokedexSpeciesUnlockPacket.kt | 16 + .../game/packets/PokemonContainerPacket.kt | 69 +- .../game/packets/PokemonFlagsUpdatePacket.kt | 16 + .../net/game/packets/PokemonListAddPacket.kt | 18 + .../openmmo/net/game/packets/PongPacket.kt | 24 + .../packets/PrismaticPearlTransferPacket.kt | 18 + .../net/game/packets/QueuePositionPacket.kt | 18 + .../net/game/packets/RemoveFriendPacket.kt | 14 + .../net/game/packets/RenderScreenPacket.kt | 8 +- .../game/packets/RequestCharactersPacket.kt | 2 +- .../RequestConfirmationPromptPacket.kt | 22 + .../packets/RequestEntityInteractionPacket.kt | 18 + .../RequestNextBattleSequencePacket.kt | 12 + .../net/game/packets/RequestPlayerPacket.kt | 2 +- .../packets/RequestSocialProfilePacket.kt | 16 + .../net/game/packets/RosterCooldownPacket.kt | 16 + .../game/packets/SaveTemplateEntryPacket.kt | 35 + .../SceneEntityActionDispatchPacket.kt | 19 + .../game/packets/SceneObjectStatesPacket.kt | 48 ++ .../net/game/packets/SelectCharacterPacket.kt | 10 +- .../game/packets/SelectPartyPokemonPacket.kt | 14 + .../game/packets/SelectSinglePokemonPacket.kt | 16 + .../game/packets/SelectedCharacterPacket.kt | 8 +- .../packets/SelectionListWindowOpenPacket.kt | 119 ++++ .../net/game/packets/SendChatCommandPacket.kt | 16 + .../game/packets/SendDirectMessagePacket.kt | 18 + .../packets/ServerChatTemplate5002Packet.kt | 18 + .../packets/ServerChatTemplate5003Packet.kt | 18 + .../game/packets/ServerEndpointListPacket.kt | 64 ++ .../net/game/packets/ServerMessagePacket.kt | 63 ++ .../net/game/packets/ServerNoticePacket.kt | 18 + .../game/packets/SessionExpiryInitPacket.kt | 19 + .../packets/SessionInitAcknowledgePacket.kt | 12 + .../game/packets/SetActiveMovesetPacket.kt | 44 ++ .../SetBattleMonsterAppearancePacket.kt | 39 + .../game/packets/SetCharacterNamePacket.kt | 19 + .../game/packets/SetChatUserIgnoredPacket.kt | 18 + .../net/game/packets/SetPlayerTitlePacket.kt | 14 + .../net/game/packets/ShopPriceTablePacket.kt | 18 + .../net/game/packets/ShopSellRequestPacket.kt | 19 + .../game/packets/SocialActionOutcomePacket.kt | 22 + .../game/packets/SocialEntryFlagSetPacket.kt | 18 + .../game/packets/SocialEntryPresencePacket.kt | 18 + .../game/packets/SocialEntryRenamePacket.kt | 18 + .../game/packets/SocialListEntryAddPacket.kt | 17 + .../packets/SocialListEntryRemovePacket.kt | 19 + .../packets/SocialProfileDialogOpenPacket.kt | 20 + .../game/packets/SpatialGroupDeletePacket.kt | 19 + .../game/packets/SpatialGroupInsertPacket.kt | 23 + .../packets/SpatialGroupSnapshotPacket.kt | 32 + .../net/game/packets/SpectateRequestPacket.kt | 16 + .../net/game/packets/StorageBoxClosePacket.kt | 12 + .../packets/StorageBoxEntriesRequestPacket.kt | 18 + .../game/packets/StorageBoxFilterPacket.kt | 40 ++ .../game/packets/StorageBoxRequestPacket.kt | 12 + .../packets/StorageContextWindowPacket.kt | 44 ++ .../game/packets/StorageInventoryPacket.kt | 56 ++ .../net/game/packets/StreamChunkPacket.kt | 33 + .../net/game/packets/StringCommandPacket.kt | 14 + .../game/packets/SubmitBreedingPartyPacket.kt | 44 ++ .../game/packets/SwapInventorySlotsPacket.kt | 30 + .../net/game/packets/TeamFoundPacket.kt | 18 + .../net/game/packets/TeamNameChangePacket.kt | 20 + .../packets/TeamPreviewLeadSubmitPacket.kt | 71 ++ .../packets/TeamPreviewRevealPickPacket.kt | 16 + .../game/packets/TeamPreviewSidePickPacket.kt | 19 + .../net/game/packets/TextArgumentPacket.kt | 14 + .../net/game/packets/TokenPayloadPacket.kt | 36 +- .../game/packets/TournamentMatchupsPacket.kt | 49 ++ .../packets/TournamentRegistrationPacket.kt | 16 + .../packets/TournamentTeleportAcceptPacket.kt | 12 + .../game/packets/TourneyRegistrationPacket.kt | 18 + .../game/packets/TrackedEntitySlotsPacket.kt | 28 + .../net/game/packets/TradeActionPacket.kt | 14 + .../net/game/packets/TradeListEntryPacket.kt | 17 + .../net/game/packets/TradeSelectMonPacket.kt | 14 + .../net/game/packets/TypedBinaryDataPacket.kt | 25 + .../net/game/packets/UnblockPlayerPacket.kt | 14 + .../net/game/packets/ViewScalePacket.kt | 16 + .../game/packets/WarpTileInteractPacket.kt | 18 + .../game/packets/WorldActionDispatchPacket.kt | 18 + .../game/packets/WorldEntityInteractPacket.kt | 22 + .../packets/WorldEntityStateResetPacket.kt | 16 + .../net/game/packets/WorldFlagSetPacket.kt | 21 + .../packets/WorldFlagStateUpdatePacket.kt | 21 + .../game/packets/WorldFlagTableResetPacket.kt | 27 + .../game/packets/WorldJoinConfirmPacket.kt | 25 + .../net/game/packets/WorldNoticeSlotPacket.kt | 71 ++ .../WorldObjectInstanceDespawnPacket.kt | 16 + .../packets/WorldOverlayObjectSetPacket.kt | 32 + .../game/packets/WorldSessionStatePacket.kt | 36 + .../game/packets/WorldStateControlPacket.kt | 19 + .../net/game/packets/WorldStateValuePacket.kt | 16 + .../packets/WorldTimedEventStatusPacket.kt | 22 + .../game/packets/WorldToggleFlagsPacket.kt | 40 ++ .../net/game/packets/WorldVersionPacket.kt | 20 + 381 files changed, 12453 insertions(+), 1035 deletions(-) create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ActiveBattleSidePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ActivePokemonSummaryPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/AdminNoteActionPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/AppearanceRequestResultPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/AssignBreedingSlotPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BatchInputEventsPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionOutcomePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionPromptTogglePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionResultPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionSelectPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionSubmitPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleBoardCellPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleBulkStatePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleCancelRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleChallengeRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleChatMessagePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleControlBytesPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleDisconnectMessagePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEmptyEventPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEndDisconnectPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEntityActionEventPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEntityDeltaPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEntityMoveEventPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEnumPairEventPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleLabeledMoveEventPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleListEventPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveDisableUpdatePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveListPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveSelectionCancelPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveSlotChoicePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveTargetsPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveUsePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePartySlotSelectPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePartySwitchPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePokemonSpritePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePokemonStatusPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePromptSwitchPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleQueuedEventPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleRatingBulkPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleRatingUpdatePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleReadyPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleRewardSelectPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleScreenOpenPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSendOutActivePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSideAddPokemonPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSidePartyPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSideRemovePokemonPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSimulationRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotActionPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotAnimationResetPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotEventEnumPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotFlagEventPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotMoveEventPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotSwitchEventPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStartScenePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStatCountersPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStatStagePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStateBytePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStateSlotIntPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStatusFlagPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSwitchPromptTogglePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSwitchSelectionsPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTargetPickPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTeamPreviewConfirmPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTeamPreviewListPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTierSelectPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTransitionReadyPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleUseItemPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BlockPlayerPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BreedingForecastPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ByteArgumentPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ByteChoicePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CameraFollowEntityPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CancelEntityMessagePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CancelMatchmakingSearchPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CancelSocialInteractionPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CategoryFlagsPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChannelAssignmentsPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChannelCountDeltaPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChannelSwitchPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CharacterAppearanceApplyPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatChannelMessagesPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatChannelUserListPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatLocalePreferencesPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatMessageSendPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatMessageWithdrawPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChunkedImagePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChunkedTransferAppendPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChunkedTransferBeginPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChunkedTransferDataPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ClientCookieUpdatePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ClientDiagnosticsPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ClientSettingUpdatePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactCategoryGroupPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactDeletePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactInsertPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactOnlineStatePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactRosterPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CoopScoreboardRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CreateMarketListingPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CurrencyBalancePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CustomizationAcceptPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CustomizeCharacterAppearancePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DataContentSyncBatchPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DataDigestSyncBatchedPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DataDigestSyncPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DataDigestSyncResponsePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DialogActionPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DialogResponsePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DisconnectNoticePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DuelChallengePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DuelInviteOutcomePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DuelInvitePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EggIncubatorSlotsPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityActionRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityAppearancePatchPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityAppearanceSyncPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityAttributeChangePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityChecklistPromptPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityCoordSyncPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityDespawnPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityEmoteBubblePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityFaceTurnPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityFramesUpdatePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityGroupMemberAddPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityGroupMemberRemovePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityGroupSnapshotPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityInteractRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityInteractionFlagPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityMovePpPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityNameChoicesPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityNameVisibilityPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityPanelSelectPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityPresencePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityRenamePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntitySpriteChangePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityTitleTagPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EventOverlayStatePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EvolutionPromptResponsePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ExchangeItemRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FieldMapBattleSlotMarkerPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FieldMapBattleSlotTileMapPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FieldMapTilePaletteApplyPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FollowerAdvancePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FriendProfileRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FriendRosterDeltaPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FriendRosterPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GameHandshakeHelloPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GameShopCatalogPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GmPanelEntryPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GmPanelVariantPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GmPlayerLookupPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GroupMemberRosterPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlConfirmPurchasePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlCreateListingPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlItemMarketPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlListingActionPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlListingCancelPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlListingSearchPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlListingsPagePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlMarketListingsPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlOpenSessionPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlPriceHistoryPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlPurchaseListingPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlPurchasePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlSearchFilterPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlSellPokemonListingPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlTradeLogRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildActivityLogPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildActivityLogPageRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildChatSendPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildDepartPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildDisbandToggleRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMemberExpelPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMemberPresencePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMemberRankAssignPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMemberRankChangePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMembershipPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMotdUpdatePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildProfileSyncPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRankLabelUpdatePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRankPermissionUpdatePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRosterAddPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRosterBulkPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRosterRemovePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/HeartbeatRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/HighScoreBoardPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/InGameChallengeResponsePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/InstanceReadyCheckPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/JoinMatchmakingQueuePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LeaderboardViewRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LearnedMovesetPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LeaveBattlePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LeaveChatChannelPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LeaveMatchmakingQueuePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LinkKickMemberPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ListWindowPagePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LocalCharacterDeltaPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LocalPlayerStatePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MailAttachmentRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MailComposeSendPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapCellTilesetPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapLoadedAckPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapReadySignalPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileAnimationTogglePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileAttributeSetPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileEntityStateSetPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileObjectRepositionPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileObjectSlotSetPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapWeatherModeSetPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MarketBoardPagePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MarketListingsRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MarketSearchFilterPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingActionPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingLanguagePrefsPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingMemberProgressPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingRentalsPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingSideTeamPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MenuPagePayloadPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MenuPromptClosePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MenuPromptOpenPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MenuVisibilityPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ModerationActionConfirmPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterFavoriteTogglePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterFormActionPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterInspectRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterRecordBookPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterRenamePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterStatusConditionPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MountMoveCooldownPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NamedCategoryEntriesPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcDialogResponsePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcDialogueChoicePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcInteractionChoicePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcPanelTogglePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ObjectiveProgressBulkPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ObjectiveProgressPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OpenAppearanceEditorPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OptionListWindowPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OverworldParticleSpawnPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OverworldPathToTilePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OverworldStepMovePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OverworldWeatherControlPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyInfoRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyMemberJoinPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyMemberLeavePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyMemberSelectPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyRosterPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PcBoxRenamePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PcBoxStorePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PendingRequestCancelPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerChatInputPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerFacingChangePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerInputLockPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerPositionUpdatePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerStopMovingPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokedexSpeciesResetPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokedexSpeciesUnlockPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokemonFlagsUpdatePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokemonListAddPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PongPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PrismaticPearlTransferPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/QueuePositionPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RemoveFriendPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestConfirmationPromptPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestEntityInteractionPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestNextBattleSequencePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestSocialProfilePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RosterCooldownPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SaveTemplateEntryPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SceneEntityActionDispatchPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SceneObjectStatesPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectPartyPokemonPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectSinglePokemonPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectionListWindowOpenPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SendChatCommandPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SendDirectMessagePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerChatTemplate5002Packet.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerChatTemplate5003Packet.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerEndpointListPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerMessagePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerNoticePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SessionExpiryInitPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SessionInitAcknowledgePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetActiveMovesetPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetBattleMonsterAppearancePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetCharacterNamePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetChatUserIgnoredPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetPlayerTitlePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ShopPriceTablePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ShopSellRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialActionOutcomePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialEntryFlagSetPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialEntryPresencePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialEntryRenamePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialListEntryAddPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialListEntryRemovePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialProfileDialogOpenPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SpatialGroupDeletePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SpatialGroupInsertPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SpatialGroupSnapshotPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SpectateRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageBoxClosePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageBoxEntriesRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageBoxFilterPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageBoxRequestPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageContextWindowPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageInventoryPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StreamChunkPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StringCommandPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SubmitBreedingPartyPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SwapInventorySlotsPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamFoundPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamNameChangePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamPreviewLeadSubmitPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamPreviewRevealPickPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamPreviewSidePickPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TextArgumentPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TournamentMatchupsPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TournamentRegistrationPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TournamentTeleportAcceptPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TourneyRegistrationPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TrackedEntitySlotsPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TradeActionPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TradeListEntryPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TradeSelectMonPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TypedBinaryDataPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/UnblockPlayerPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ViewScalePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WarpTileInteractPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldActionDispatchPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldEntityInteractPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldEntityStateResetPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldFlagSetPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldFlagStateUpdatePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldFlagTableResetPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldJoinConfirmPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldNoticeSlotPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldObjectInstanceDespawnPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldOverlayObjectSetPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldSessionStatePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldStateControlPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldStateValuePacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldTimedEventStatusPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldToggleFlagsPacket.kt create mode 100644 protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldVersionPacket.kt diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/GameProtocol.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/GameProtocol.kt index 74e4427..006d47f 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/GameProtocol.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/GameProtocol.kt @@ -4,126 +4,596 @@ 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 + override val compressed: Boolean = true - init { - c2s(0x01u, JoinPacketCodec) - s2c(0x01u, JoinResponsePacketCodec) + init { + c2s(0x01u, JoinPacketCodec) + s2c(0x01u, JoinResponsePacketCodec) - c2s(0x02u, RequestCharactersPacketCodec) - s2c(0x02u, CharactersListPacketCodec) + c2s(0x02u, RequestCharactersPacketCodec) + s2c(0x02u, CharactersListPacketCodec) - c2s(0x03u, CreateCharacterPacketCodec) + c2s(0x03u, CreateCharacterPacketCodec) + s2c(0x03u, FriendRosterDeltaPacketCodec) - c2s(0x04u, SelectCharacterPacketCodec) - s2c(0x04u, SelectedCharacterPacketCodec) + c2s(0x04u, SelectCharacterPacketCodec) + s2c(0x04u, SelectedCharacterPacketCodec) - c2s(0x05u, RequestPlayerPacketCodec) - s2c(0x05u, LoadEntityPacketCodec) + c2s(0x05u, RequestPlayerPacketCodec) + s2c(0x05u, LoadEntityPacketCodec) - c2s(0x06u, MovementPacketCodec) + c2s(0x06u, MovementPacketCodec) - c2s(0x07u, FaceDirectionPacketCodec) + c2s(0x07u, FaceDirectionPacketCodec) + s2c(0x07u, EntityFaceTurnPacketCodec) - s2c(0x08u, EntityLeavePacketCodec) + c2s(0x08u, ChatMessageSendPacketCodec) + s2c(0x08u, EntityLeavePacketCodec) - bidi(0x09u, ChatMessagePacketCodec) + bidi(0x09u, ChatMessagePacketCodec) - bidi(0x0Du, DialogDataPacketCodec) - bidi(0x0Eu, DialogStatePacketCodec) + c2s(0x0Au, BattleMoveUsePacketCodec) + s2c(0x0Au, WorldFlagTableResetPacketCodec) - bidi(0x10u, LoadMapPacketCodec) + c2s(0x0Bu, EvolutionPromptResponsePacketCodec) + s2c(0x0Bu, WorldFlagSetPacketCodec) - s2c(0x11u, NpcUpdatePacketCodec) + c2s(0x0Cu, BattlePartySwitchPacketCodec) + s2c(0x0Cu, LocalCharacterDeltaPacketCodec) - bidi(0x12u, NpcSpawnPacketCodec) + bidi(0x0Du, DialogDataPacketCodec) - bidi(0x13u, PokemonContainerPacketCodec) + bidi(0x0Eu, DialogStatePacketCodec) - bidi(0x1Bu, MapTransitionPacketCodec) + c2s(0x0Fu, PokemonListAddPacketCodec) + s2c(0x0Fu, EntityPresencePacketCodec) - c2s(0x20u, NullPacketCodec) - s2c(0x20u, TokenPayloadPacketCodec) + bidi(0x10u, LoadMapPacketCodec) - s2c(0x21u, InteractivePacketCodec) - c2s(0x21u, InteractiveResponsePacketCodec) + c2s(0x11u, PartyMemberSelectPacketCodec) + s2c(0x11u, NpcUpdatePacketCodec) - bidi(0x22u, EntityInteractPacketCodec) + bidi(0x12u, NpcSpawnPacketCodec) - bidi(0x25u, DialogChoicePacketCodec) - bidi(0x26u, DialogOptionPacketCodec) + bidi(0x13u, PokemonContainerPacketCodec) - bidi(0xB2u, NpcAnimationPacketCodec) - bidi(0xB4u, RenderScreenPacketCodec) - bidi(0xB9u, MapTransitionAckPacketCodec) - bidi(0xC2u, KeepAlivePacketCodec) + c2s(0x14u, EntityActionRequestPacketCodec) + s2c(0x14u, SocialListEntryAddPacketCodec) - s2c(0xEAu, EntityMovePacketCodec) - } + c2s(0x15u, ChatLocalePreferencesPacketCodec) + s2c(0x15u, SocialListEntryRemovePacketCodec) + + c2s(0x16u, InGameChallengeResponsePacketCodec) + s2c(0x16u, BattleEntityDeltaPacketCodec) + + c2s(0x17u, StorageBoxClosePacketCodec) + s2c(0x17u, SocialEntryFlagSetPacketCodec) + + c2s(0x18u, MonsterStatusConditionPacketCodec) + s2c(0x18u, SocialEntryPresencePacketCodec) + + c2s(0x19u, MonsterFormActionPacketCodec) + s2c(0x19u, SocialEntryRenamePacketCodec) + + s2c(0x1Au, EntityMovePpPacketCodec) + + bidi(0x1Bu, MapTransitionPacketCodec) + + c2s(0x1Cu, StorageBoxFilterPacketCodec) + s2c(0x1Cu, PokedexSpeciesResetPacketCodec) + + c2s(0x1Du, PokemonFlagsUpdatePacketCodec) + s2c(0x1Du, PokedexSpeciesUnlockPacketCodec) + + s2c(0x1Eu, OverworldWeatherControlPacketCodec) + + s2c(0x1Fu, OverworldParticleSpawnPacketCodec) + + c2s(0x20u, NullPacketCodec) + s2c(0x20u, TokenPayloadPacketCodec) + + c2s(0x21u, WarpTileInteractPacketCodec) + s2c(0x21u, DialogActionPacketCodec) + + bidi(0x22u, EntityInteractPacketCodec) + + c2s(0x23u, ExchangeItemRequestPacketCodec) + s2c(0x23u, EventOverlayStatePacketCodec) + + c2s(0x24u, ShopSellRequestPacketCodec) + s2c(0x24u, NpcPanelTogglePacketCodec) + + bidi(0x25u, DialogChoicePacketCodec) + + bidi(0x26u, DialogOptionPacketCodec) + + c2s(0x27u, PlayerStopMovingPacketCodec) + s2c(0x27u, BattlePromptSwitchPacketCodec) + + c2s(0x28u, TypedBinaryDataPacketCodec) + s2c(0x28u, EntityInteractionFlagPacketCodec) + + c2s(0x29u, CustomizeCharacterAppearancePacketCodec) + s2c(0x29u, ShopPriceTablePacketCodec) + + c2s(0x2Au, TeamNameChangePacketCodec) + s2c(0x2Au, BattleStatusFlagPacketCodec) + + c2s(0x2Bu, SetCharacterNamePacketCodec) + s2c(0x2Bu, FollowerAdvancePacketCodec) + + c2s(0x2Cu, NpcDialogResponsePacketCodec) + s2c(0x2Cu, EntityTitleTagPacketCodec) + + c2s(0x2Du, EntityInteractRequestPacketCodec) + s2c(0x2Du, MapCellTilesetPacketCodec) + + c2s(0x2Eu, SendDirectMessagePacketCodec) + s2c(0x2Eu, EntityRenamePacketCodec) + + c2s(0x2Fu, DialogResponsePacketCodec) + s2c(0x2Fu, WorldJoinConfirmPacketCodec) + + c2s(0x30u, BattleActionPacketCodec) + + s2c(0x31u, BattleBulkStatePacketCodec) + + c2s(0x32u, BattleActionSelectPacketCodec) + s2c(0x32u, BattleQueuedEventPacketCodec) + + c2s(0x33u, MapLoadedAckPacketCodec) + s2c(0x33u, BattleEntityMoveEventPacketCodec) + + c2s(0x34u, SpectateRequestPacketCodec) + s2c(0x34u, BattleSlotEventEnumPacketCodec) + + c2s(0x35u, LeaveBattlePacketCodec) + s2c(0x35u, BattleSlotMoveEventPacketCodec) + + c2s(0x36u, RequestNextBattleSequencePacketCodec) + s2c(0x36u, BattleSlotFlagEventPacketCodec) + + c2s(0x37u, BattleSlotActionPacketCodec) + s2c(0x37u, BattleListEventPacketCodec) + + c2s(0x38u, BattleSwitchSelectionsPacketCodec) + s2c(0x38u, BattleEntityActionEventPacketCodec) + + c2s(0x39u, BattleUseItemPacketCodec) + s2c(0x39u, BattleLabeledMoveEventPacketCodec) + + c2s(0x3Au, SetBattleMonsterAppearancePacketCodec) + s2c(0x3Au, BattleEnumPairEventPacketCodec) + + c2s(0x3Bu, PrismaticPearlTransferPacketCodec) + s2c(0x3Bu, BattleEmptyEventPacketCodec) + + c2s(0x3Cu, SetActiveMovesetPacketCodec) + s2c(0x3Cu, ServerChatTemplate5002PacketCodec) + + c2s(0x3Du, BattleCancelRequestPacketCodec) + s2c(0x3Du, ServerChatTemplate5003PacketCodec) + + s2c(0x3Eu, BattleSlotSwitchEventPacketCodec) + + c2s(0x3Fu, BattleSimulationRequestPacketCodec) + s2c(0x3Fu, BattleMoveDisableUpdatePacketCodec) + + c2s(0x40u, SubmitBreedingPartyPacketCodec) + s2c(0x40u, BattleSidePartyPacketCodec) + + c2s(0x41u, MonsterFavoriteTogglePacketCodec) + s2c(0x41u, BattlePokemonSpritePacketCodec) + + c2s(0x42u, LeaveChatChannelPacketCodec) + s2c(0x42u, BattleSideAddPokemonPacketCodec) + + c2s(0x43u, SetChatUserIgnoredPacketCodec) + s2c(0x43u, BattleSideRemovePokemonPacketCodec) + + c2s(0x44u, TournamentTeleportAcceptPacketCodec) + s2c(0x44u, BattlePokemonStatusPacketCodec) + + c2s(0x45u, NpcDialogueChoicePacketCodec) + s2c(0x45u, WorldStateControlPacketCodec) + + c2s(0x46u, BattleReadyPacketCodec) + s2c(0x46u, BattleControlBytesPacketCodec) + + c2s(0x47u, LeaveMatchmakingQueuePacketCodec) + s2c(0x47u, BattleScreenOpenPacketCodec) + + c2s(0x48u, BattleActionSubmitPacketCodec) + s2c(0x48u, BattleActionResultPacketCodec) + + c2s(0x49u, JoinMatchmakingQueuePacketCodec) + s2c(0x49u, BattleMoveSelectionCancelPacketCodec) + + c2s(0x4Au, BattleTierSelectPacketCodec) + s2c(0x4Au, BattleRatingBulkPacketCodec) + + c2s(0x4Bu, BattleChatMessagePacketCodec) + s2c(0x4Bu, BattleRatingUpdatePacketCodec) + + c2s(0x4Cu, MatchmakingActionPacketCodec) + s2c(0x4Cu, BattleMoveTargetsPacketCodec) + + c2s(0x4Du, MarketListingsRequestPacketCodec) + s2c(0x4Du, BattleStateBytePacketCodec) + + s2c(0x4Eu, BattleMoveListPacketCodec) + + c2s(0x4Fu, MarketSearchFilterPacketCodec) + s2c(0x4Fu, ChannelAssignmentsPacketCodec) + + c2s(0x50u, TradeActionPacketCodec) + s2c(0x50u, DuelInvitePacketCodec) + + c2s(0x51u, StringCommandPacketCodec) + s2c(0x51u, DuelInviteOutcomePacketCodec) + + c2s(0x52u, TradeSelectMonPacketCodec) + s2c(0x52u, TradeListEntryPacketCodec) + + c2s(0x53u, BattlePartySlotSelectPacketCodec) + s2c(0x53u, BattleStateSlotIntPacketCodec) + + s2c(0x54u, BattleBoardCellPacketCodec) + + s2c(0x55u, SpatialGroupSnapshotPacketCodec) + + s2c(0x56u, SpatialGroupInsertPacketCodec) + + s2c(0x57u, SpatialGroupDeletePacketCodec) + + s2c(0x58u, MenuVisibilityPacketCodec) + + s2c(0x59u, MenuPagePayloadPacketCodec) + + s2c(0x5Au, EntityNameChoicesPacketCodec) + + s2c(0x5Bu, OptionListWindowPacketCodec) + + s2c(0x5Cu, ListWindowPagePacketCodec) + + s2c(0x5Du, MarketBoardPagePacketCodec) + + s2c(0x5Eu, SceneObjectStatesPacketCodec) + + s2c(0x5Fu, StorageInventoryPacketCodec) + + c2s(0x60u, BlockPlayerPacketCodec) + s2c(0x60u, StorageContextWindowPacketCodec) + + c2s(0x61u, UnblockPlayerPacketCodec) + s2c(0x61u, EntityCoordSyncPacketCodec) + + c2s(0x62u, RemoveFriendPacketCodec) + s2c(0x62u, SocialActionOutcomePacketCodec) + + c2s(0x63u, SetPlayerTitlePacketCodec) + s2c(0x63u, ContactRosterPacketCodec) + + c2s(0x64u, FriendProfileRequestPacketCodec) + s2c(0x64u, ContactInsertPacketCodec) + + s2c(0x65u, ContactDeletePacketCodec) + + s2c(0x66u, ContactOnlineStatePacketCodec) + + s2c(0x67u, PartyRosterPacketCodec) + + s2c(0x68u, PartyMemberJoinPacketCodec) + + s2c(0x69u, PartyMemberLeavePacketCodec) + + c2s(0x6Au, InstanceReadyCheckPacketCodec) + + c2s(0x6Bu, CancelMatchmakingSearchPacketCodec) + s2c(0x6Bu, ActiveBattleSidePacketCodec) + + c2s(0x6Cu, MatchmakingLanguagePrefsPacketCodec) + s2c(0x6Cu, MountMoveCooldownPacketCodec) + + s2c(0x6Du, ClientCookieUpdatePacketCodec) + + s2c(0x6Eu, WorldToggleFlagsPacketCodec) + + s2c(0x6Fu, NamedCategoryEntriesPacketCodec) + + c2s(0x70u, StorageBoxRequestPacketCodec) + s2c(0x70u, GtlMarketListingsPacketCodec) + + c2s(0x71u, GtlPurchaseListingPacketCodec) + s2c(0x71u, MatchmakingRentalsPacketCodec) + + s2c(0x72u, WorldStateValuePacketCodec) + + c2s(0x73u, AssignBreedingSlotPacketCodec) + s2c(0x73u, BreedingForecastPacketCodec) + + c2s(0x74u, LeaderboardViewRequestPacketCodec) + s2c(0x74u, ServerNoticePacketCodec) + + c2s(0x75u, TourneyRegistrationPacketCodec) + s2c(0x75u, MatchmakingSideTeamPacketCodec) + + c2s(0x76u, NpcInteractionChoicePacketCodec) + s2c(0x76u, ActivePokemonSummaryPacketCodec) + + c2s(0x77u, BattleTargetPickPacketCodec) + s2c(0x77u, StreamChunkPacketCodec) + + s2c(0x78u, MatchmakingMemberProgressPacketCodec) + + c2s(0x79u, PcBoxStorePacketCodec) + s2c(0x79u, BattleStatCountersPacketCodec) + + c2s(0x7Au, PcBoxRenamePacketCodec) + s2c(0x7Au, LearnedMovesetPacketCodec) + + c2s(0x7Bu, CoopScoreboardRequestPacketCodec) + s2c(0x7Bu, TournamentMatchupsPacketCodec) + + c2s(0x7Cu, GtlListingSearchPacketCodec) + s2c(0x7Cu, GtlItemMarketPacketCodec) + + s2c(0x7Du, GameShopCatalogPacketCodec) + + s2c(0x7Eu, EggIncubatorSlotsPacketCodec) + + s2c(0x7Fu, GtlPriceHistoryPacketCodec) + + c2s(0x80u, TeamFoundPacketCodec) + s2c(0x80u, GuildMembershipPacketCodec) + + c2s(0x81u, GuildMotdUpdatePacketCodec) + s2c(0x81u, GuildProfileSyncPacketCodec) + + c2s(0x82u, GuildDepartPacketCodec) + + c2s(0x83u, GuildChatSendPacketCodec) + s2c(0x83u, GuildRosterAddPacketCodec) + + c2s(0x84u, GuildMemberRankAssignPacketCodec) + s2c(0x84u, GuildMemberRankChangePacketCodec) + + c2s(0x85u, GuildMemberExpelPacketCodec) + s2c(0x85u, GuildRosterRemovePacketCodec) + + c2s(0x86u, GuildRankPermissionUpdatePacketCodec) + s2c(0x86u, GuildMemberPresencePacketCodec) + + c2s(0x87u, GuildDisbandToggleRequestPacketCodec) + s2c(0x87u, ContactCategoryGroupPacketCodec) + + c2s(0x88u, GuildRankLabelUpdatePacketCodec) + s2c(0x88u, GuildRosterBulkPacketCodec) + + c2s(0x89u, GuildActivityLogPageRequestPacketCodec) + s2c(0x89u, GuildActivityLogPacketCodec) + + c2s(0x8Au, MailAttachmentRequestPacketCodec) + + s2c(0x8Bu, MonsterRecordBookPacketCodec) + + s2c(0x8Cu, ChatChannelMessagesPacketCodec) + + s2c(0x8Du, ChatChannelUserListPacketCodec) + + s2c(0x8Eu, ChannelCountDeltaPacketCodec) + + s2c(0x8Fu, ChatMessageWithdrawPacketCodec) + + c2s(0x90u, OverworldPathToTilePacketCodec) + s2c(0x90u, EntitySpriteChangePacketCodec) + + c2s(0x91u, OverworldStepMovePacketCodec) + s2c(0x91u, OpenAppearanceEditorPacketCodec) + + c2s(0x92u, BattleTransitionReadyPacketCodec) + s2c(0x92u, AppearanceRequestResultPacketCodec) + + c2s(0x93u, PendingRequestCancelPacketCodec) + s2c(0x93u, BattleStatStagePacketCodec) + + c2s(0x94u, PartyInfoRequestPacketCodec) + s2c(0x94u, EntityAppearanceSyncPacketCodec) + + c2s(0x95u, MailComposeSendPacketCodec) + s2c(0x95u, BattleSwitchPromptTogglePacketCodec) + + c2s(0x96u, TeamPreviewRevealPickPacketCodec) + s2c(0x96u, BattleEndDisconnectPacketCodec) + + c2s(0x97u, TeamPreviewSidePickPacketCodec) + s2c(0x97u, BattleTeamPreviewListPacketCodec) + + c2s(0x98u, TeamPreviewLeadSubmitPacketCodec) + s2c(0x98u, WorldVersionPacketCodec) + + c2s(0x99u, BattleTeamPreviewConfirmPacketCodec) + s2c(0x99u, BattleSendOutActivePacketCodec) + + c2s(0x9Au, CreateMarketListingPacketCodec) + s2c(0x9Au, BattleSlotAnimationResetPacketCodec) + + c2s(0x9Bu, GtlSellPokemonListingPacketCodec) + s2c(0x9Bu, BattleActionOutcomePacketCodec) + + c2s(0x9Cu, GtlConfirmPurchasePacketCodec) + s2c(0x9Cu, BattleDisconnectMessagePacketCodec) + + c2s(0x9Du, SelectSinglePokemonPacketCodec) + s2c(0x9Du, BattleActionPromptTogglePacketCodec) + + c2s(0x9Eu, SelectPartyPokemonPacketCodec) + s2c(0x9Eu, EntityEmoteBubblePacketCodec) + + c2s(0x9Fu, GtlTradeLogRequestPacketCodec) + + c2s(0xA0u, PlayerChatInputPacketCodec) + s2c(0xA0u, FriendRosterPacketCodec) + + c2s(0xA1u, GtlListingCancelPacketCodec) + s2c(0xA1u, GmPlayerLookupPacketCodec) + + c2s(0xA2u, AdminNoteActionPacketCodec) + s2c(0xA2u, GmPanelVariantPacketCodec) + + c2s(0xA3u, GtlPurchasePacketCodec) + s2c(0xA3u, EntityNameVisibilityPacketCodec) + + c2s(0xA4u, GtlListingActionPacketCodec) + s2c(0xA4u, HighScoreBoardPacketCodec) + + c2s(0xA5u, GtlOpenSessionPacketCodec) + s2c(0xA5u, WorldNoticeSlotPacketCodec) + + c2s(0xA6u, DataDigestSyncResponsePacketCodec) + s2c(0xA6u, DataDigestSyncPacketCodec) + + c2s(0xA7u, DataContentSyncBatchPacketCodec) + s2c(0xA7u, DataDigestSyncBatchedPacketCodec) + + c2s(0xA8u, BatchInputEventsPacketCodec) + s2c(0xA8u, SelectionListWindowOpenPacketCodec) + + c2s(0xA9u, ModerationActionConfirmPacketCodec) + s2c(0xA9u, EntityAttributeChangePacketCodec) + + s2c(0xAAu, WorldFlagStateUpdatePacketCodec) + + s2c(0xABu, ChunkedTransferBeginPacketCodec) + + s2c(0xACu, ChunkedTransferAppendPacketCodec) + + s2c(0xADu, WorldTimedEventStatusPacketCodec) + + s2c(0xAEu, GroupMemberRosterPacketCodec) + + s2c(0xB0u, SceneEntityActionDispatchPacketCodec) + + s2c(0xB1u, SocialProfileDialogOpenPacketCodec) + + bidi(0xB2u, NpcAnimationPacketCodec) + + s2c(0xB3u, MapTileAttributeSetPacketCodec) + + bidi(0xB4u, RenderScreenPacketCodec) + + s2c(0xB5u, EntityAppearancePatchPacketCodec) + + s2c(0xB6u, WorldActionDispatchPacketCodec) + + s2c(0xB7u, EntityDespawnPacketCodec) + + s2c(0xB8u, MapTileEntityStateSetPacketCodec) + + bidi(0xB9u, MapTransitionAckPacketCodec) + + s2c(0xBAu, MapTileObjectSlotSetPacketCodec) + + s2c(0xBBu, CameraFollowEntityPacketCodec) + + s2c(0xBCu, MapTileObjectRepositionPacketCodec) + + s2c(0xBDu, WorldEntityStateResetPacketCodec) + + s2c(0xBEu, WorldOverlayObjectSetPacketCodec) + + s2c(0xC0u, MapTileAnimationTogglePacketCodec) + + c2s(0xC1u, TournamentRegistrationPacketCodec) + s2c(0xC1u, MapWeatherModeSetPacketCodec) + + bidi(0xC2u, KeepAlivePacketCodec) + + s2c(0xC3u, FieldMapTilePaletteApplyPacketCodec) + + s2c(0xC4u, FieldMapBattleSlotTileMapPacketCodec) + + s2c(0xC5u, FieldMapBattleSlotMarkerPacketCodec) + + s2c(0xC8u, WorldObjectInstanceDespawnPacketCodec) + + s2c(0xCAu, BattleStartScenePacketCodec) + + c2s(0xD0u, SendChatCommandPacketCodec) + s2c(0xD0u, EntityGroupSnapshotPacketCodec) + + c2s(0xD1u, LinkKickMemberPacketCodec) + s2c(0xD1u, EntityGroupMemberAddPacketCodec) + + s2c(0xD2u, EntityGroupMemberRemovePacketCodec) + + c2s(0xD3u, CancelSocialInteractionPacketCodec) + s2c(0xD3u, ObjectiveProgressBulkPacketCodec) + + c2s(0xD4u, RequestSocialProfilePacketCodec) + s2c(0xD4u, ObjectiveProgressPacketCodec) + + s2c(0xD5u, TrackedEntitySlotsPacketCodec) + + s2c(0xD6u, MenuPromptOpenPacketCodec) + + s2c(0xD7u, EntityChecklistPromptPacketCodec) + + s2c(0xD8u, MenuPromptClosePacketCodec) + + s2c(0xD9u, RequestConfirmationPromptPacketCodec) + + s2c(0xDAu, EntityPanelSelectPacketCodec) + + s2c(0xDBu, EntityFramesUpdatePacketCodec) + + s2c(0xDCu, CategoryFlagsPacketCodec) + + c2s(0xE0u, SaveTemplateEntryPacketCodec) + + c2s(0xE1u, GtlCreateListingPacketCodec) + + c2s(0xE2u, GtlSearchFilterPacketCodec) + + c2s(0xE3u, BattleRewardSelectPacketCodec) + + c2s(0xE4u, BattleChallengeRequestPacketCodec) + + s2c(0xEAu, EntityMovePacketCodec) + + s2c(0xF0u, QueuePositionPacketCodec) + + c2s(0xF1u, ChunkedTransferDataPacketCodec) + s2c(0xF1u, ViewScalePacketCodec) + + s2c(0xF2u, SessionExpiryInitPacketCodec) + + s2c(0xF3u, LocalPlayerStatePacketCodec) + + s2c(0xF4u, CurrencyBalancePacketCodec) + + s2c(0xF5u, ServerMessagePacketCodec) + + s2c(0xF6u, ChunkedImagePacketCodec) + + s2c(0xF7u, GmPanelEntryPacketCodec) + + s2c(0xF8u, DisconnectNoticePacketCodec) + + s2c(0xF9u, RosterCooldownPacketCodec) + + s2c(0xFAu, CancelEntityMessagePacketCodec) + + s2c(0xFBu, PlayerInputLockPacketCodec) + + s2c(0xFCu, ServerEndpointListPacketCodec) + + s2c(0xFEu, GtlListingsPagePacketCodec) + + s2c(0xFFu, WorldSessionStatePacketCodec) + + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/codecs/CharacterInfoCodec.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/codecs/CharacterInfoCodec.kt index 5c07dc4..193740f 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/codecs/CharacterInfoCodec.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/codecs/CharacterInfoCodec.kt @@ -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 @@ -25,75 +14,75 @@ internal val EpochSecondsS32LE: Codec = private val TrailingBytes = bytesPrefixed(U16LE) class CharacterInfoCodec(private val withExtraLong: Boolean) : PacketCodec() { - override fun CodecScope.body(): CharacterInfo { - val id = field(S64LE, CharacterInfo::id) - val name = field(Utf16LeNullTerminated, CharacterInfo::name) - val namePrefix = field(Utf16LeNullTerminated) { "" } - val userId = field(S32LE, CharacterInfo::userId) - val rivalSex = field(S8, CharacterInfo::rivalSex) - val lastLogin = field(EpochSecondsS32LE, CharacterInfo::lastLogin) - if (withExtraLong) field(S64LE) { 0L } - val createdAt = field(EpochSecondsS32LE, CharacterInfo::createdAt) - field(S32LE) { 0 } - field(S8) { 0 } - field(S32LE) { 0 } - val money = field(S32LE, CharacterInfo::money) - field(S16LE) { 0 } - field(S32LE) { 0 } - val permissions = field(U8) { it.permissions and 0xFF } - field(S8) { 0 } - field(S8) { 0 } - field(S32LE) { 0 } - repeat(8) { field(S8) { 0 } } - val remainingSafariSteps = field(S16LE, CharacterInfo::remainingSafariSteps) - val remainingSafariBalls = field(S8, CharacterInfo::remainingSafariBalls) - field(S32LE) { 0 } - val pcExtraSlots = field(S8, CharacterInfo::pcExtraSlots) - val battleBoxExtraSlots = field(S8, CharacterInfo::battleBoxExtraSlots) - val templateAmount = field(S8, CharacterInfo::templateAmount) - field(S8) { 0 } - field(S8) { 0 } - field(S8) { 0 } - val positionRegionId = field(S8, CharacterInfo::positionRegionId) - val positionBankId = field(S8, CharacterInfo::positionBankId) - val positionMapId = field(S8, CharacterInfo::positionMapId) - field(S8) { 0 } - val positionX = field(S16LE, CharacterInfo::positionX) - val positionY = field(S16LE, CharacterInfo::positionY) - field(S8) { 0 } - field(S8) { 0 } - val repelLeft = field(S16LE, CharacterInfo::repelLeft) - val repelItemId = field(S16LE, CharacterInfo::repelItemId) - field(S8) { 0 } - val lureItemId = field(S16LE, CharacterInfo::lureItemId) - val lureLeft = field(S16LE, CharacterInfo::lureLeft) - field(TrailingBytes) { ByteArray(0) } - return CharacterInfo( - id = id, - name = name, - namePrefix = namePrefix, - userId = userId, - rivalSex = rivalSex, - lastLogin = lastLogin, - createdAt = createdAt, - money = money, - permissions = permissions, - remainingSafariSteps = remainingSafariSteps, - remainingSafariBalls = remainingSafariBalls, - pcExtraSlots = pcExtraSlots, - battleBoxExtraSlots = battleBoxExtraSlots, - templateAmount = templateAmount, - positionRegionId = positionRegionId, - positionBankId = positionBankId, - positionMapId = positionMapId, - positionX = positionX, - positionY = positionY, - repelLeft = repelLeft, - repelItemId = repelItemId, - lureLeft = lureLeft, - lureItemId = lureItemId, - ) - } + override fun CodecScope.body(): CharacterInfo { + val id = field(S64LE, CharacterInfo::id) + val name = field(Utf16LeNullTerminated, CharacterInfo::name) + val namePrefix = field(Utf16LeNullTerminated) { "" } + val userId = field(S32LE, CharacterInfo::userId) + val rivalSex = field(S8, CharacterInfo::rivalSex) + val lastLogin = field(EpochSecondsS32LE, CharacterInfo::lastLogin) + if (withExtraLong) field(S64LE) { 0L } + val createdAt = field(EpochSecondsS32LE, CharacterInfo::createdAt) + field(S32LE) { 0 } + field(S8) { 0 } + field(S32LE) { 0 } + val money = field(S32LE, CharacterInfo::money) + field(S16LE) { 0 } + field(S32LE) { 0 } + val permissions = field(U8) { it.permissions and 0xFF } + field(S8) { 0 } + field(S8) { 0 } + field(S32LE) { 0 } + repeat(8) { field(S8) { 0 } } + val remainingSafariSteps = field(S16LE, CharacterInfo::remainingSafariSteps) + val remainingSafariBalls = field(S8, CharacterInfo::remainingSafariBalls) + field(S32LE) { 0 } + val pcExtraSlots = field(S8, CharacterInfo::pcExtraSlots) + val battleBoxExtraSlots = field(S8, CharacterInfo::battleBoxExtraSlots) + val templateAmount = field(S8, CharacterInfo::templateAmount) + field(S8) { 0 } + field(S8) { 0 } + field(S8) { 0 } + val positionRegionId = field(S8, CharacterInfo::positionRegionId) + val positionBankId = field(S8, CharacterInfo::positionBankId) + val positionMapId = field(S8, CharacterInfo::positionMapId) + field(S8) { 0 } + val positionX = field(S16LE, CharacterInfo::positionX) + val positionY = field(S16LE, CharacterInfo::positionY) + field(S8) { 0 } + field(S8) { 0 } + val repelLeft = field(S16LE, CharacterInfo::repelLeft) + val repelItemId = field(S16LE, CharacterInfo::repelItemId) + field(S8) { 0 } + val lureItemId = field(S16LE, CharacterInfo::lureItemId) + val lureLeft = field(S16LE, CharacterInfo::lureLeft) + field(TrailingBytes) { ByteArray(0) } + return CharacterInfo( + id = id, + name = name, + namePrefix = namePrefix, + userId = userId, + rivalSex = rivalSex, + lastLogin = lastLogin, + createdAt = createdAt, + money = money, + permissions = permissions, + remainingSafariSteps = remainingSafariSteps, + remainingSafariBalls = remainingSafariBalls, + pcExtraSlots = pcExtraSlots, + battleBoxExtraSlots = battleBoxExtraSlots, + templateAmount = templateAmount, + positionRegionId = positionRegionId, + positionBankId = positionBankId, + positionMapId = positionMapId, + positionX = positionX, + positionY = positionY, + repelLeft = repelLeft, + repelItemId = repelItemId, + lureLeft = lureLeft, + lureItemId = lureItemId, + ) + } } val CharacterInfoCodecShort: Codec = CharacterInfoCodec(withExtraLong = false) diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/codecs/PokemonCodec.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/codecs/PokemonCodec.kt index 66d330b..cfc4ac4 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/codecs/PokemonCodec.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/codecs/PokemonCodec.kt @@ -1,108 +1,94 @@ 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 = bytesPrefixed(U8) object PokemonCodec : PacketCodec() { - override fun CodecScope.body(): Pokemon { - val id = field(S64LE, Pokemon::id) - field(S8) { 0 } - field(S64LE) { 0L } - field(S64LE) { 0L } - val container = PokemonContainer.entries[field(U8) { it.container.ordinal }] - val containerSlot = field(S16LE, Pokemon::containerSlot) - val dexId = field(U16LE, Pokemon::dexId) - val seed = field(S32LE, Pokemon::seed) - field(S64LE) { 0L } - val ot = field(Utf16LeNullTerminated, Pokemon::ot) - val nickname = field(Utf16LeNullTerminated, Pokemon::nickname) - field(S8) { 0 } - field(S8) { 0 } - val level = field(S8, Pokemon::level) - val currentHp = field(S16LE, Pokemon::hp) - field(S16LE) { 0 } - val xp = field(S32LE, Pokemon::xp) - field(S8) { 0 } - field(S16LE) { 0 } - val moveIds = List(4) { i -> field(S16LE) { it.moves[i].id } } - val movePps = List(4) { i -> field(S8) { it.moves[i].pp } } - val moves = List(4) { PokemonMove(moveIds[it], movePps[it]) } - repeat(4) { field(S16LE) { 0 } } - val eVs = - EVs().apply { - hp = field(U8) { it.eVs.hp } - atk = field(U8) { it.eVs.atk } - def = field(U8) { it.eVs.def } - spd = field(U8) { it.eVs.spd } - spAtk = field(U8) { it.eVs.spAtk } - spDef = field(U8) { it.eVs.spDef } - } - repeat(11) { field(S8) { 0 } } - val iVs = decompressIVs(field(S32LE) { it.iVs.compress() }) - field(S8) { 0 } - field(S64LE) { 0L } - val rarityMask = - field(U16LE) { - var m = 0 - if (it.isShiny) m = m or (1 shl PokemonRarity.SHINY.ordinal) - if (it.hasHiddenAbility) m = m or (1 shl PokemonRarity.HIDDEN_ABILITY.ordinal) - if (it.isAlpha) m = m or (1 shl PokemonRarity.ALPHA.ordinal) - if (it.isSecret) m = m or (1 shl PokemonRarity.SECRET.ordinal) - if (it.isFatefulEncounter) m = m or (1 shl PokemonRarity.FATEFUL_ENCOUNTER.ordinal) - if (it.isRaidEncounter) m = m or (1 shl PokemonRarity.RAID_ENCOUNTER.ordinal) - m - } - val isShiny = (rarityMask and (1 shl PokemonRarity.SHINY.ordinal)) != 0 - val hasHiddenAbility = (rarityMask and (1 shl PokemonRarity.HIDDEN_ABILITY.ordinal)) != 0 - val isAlpha = (rarityMask and (1 shl PokemonRarity.ALPHA.ordinal)) != 0 - val isSecret = (rarityMask and (1 shl PokemonRarity.SECRET.ordinal)) != 0 - val isFatefulEncounter = (rarityMask and (1 shl PokemonRarity.FATEFUL_ENCOUNTER.ordinal)) != 0 - val isRaidEncounter = (rarityMask and (1 shl PokemonRarity.RAID_ENCOUNTER.ordinal)) != 0 - val caughtAt = field(EpochSecondsS32LE, Pokemon::caughtAt) - field(S16LE) { 0 } - field(S8) { 0 } - field(S8) { 0 } - field(PokemonUnknownBytes) { ByteArray(0) } - repeat(12) { field(S8) { 0 } } - return Pokemon( - id, - container, - containerSlot, - dexId, - seed, - ot, - nickname, - level, - currentHp, - xp, - eVs, - iVs, - moves, - isShiny, - hasHiddenAbility, - isAlpha, - isSecret, - isFatefulEncounter, - isRaidEncounter, - caughtAt, - ) - } + override fun CodecScope.body(): Pokemon { + val id = field(S64LE, Pokemon::id) + field(S8) { 0 } + field(S64LE) { 0L } + field(S64LE) { 0L } + val container = PokemonContainer.entries[field(U8) { it.container.ordinal }] + val containerSlot = field(S16LE, Pokemon::containerSlot) + val dexId = field(U16LE, Pokemon::dexId) + val seed = field(S32LE, Pokemon::seed) + field(S64LE) { 0L } + val ot = field(Utf16LeNullTerminated, Pokemon::ot) + val nickname = field(Utf16LeNullTerminated, Pokemon::nickname) + field(S8) { 0 } + field(S8) { 0 } + val level = field(S8, Pokemon::level) + val currentHp = field(S16LE, Pokemon::hp) + field(S16LE) { 0 } + val xp = field(S32LE, Pokemon::xp) + field(S8) { 0 } + field(S16LE) { 0 } + val moveIds = List(4) { i -> field(S16LE) { it.moves[i].id } } + val movePps = List(4) { i -> field(S8) { it.moves[i].pp } } + val moves = List(4) { PokemonMove(moveIds[it], movePps[it]) } + repeat(4) { field(S16LE) { 0 } } + val eVs = + EVs().apply { + hp = field(U8) { it.eVs.hp } + atk = field(U8) { it.eVs.atk } + def = field(U8) { it.eVs.def } + spd = field(U8) { it.eVs.spd } + spAtk = field(U8) { it.eVs.spAtk } + spDef = field(U8) { it.eVs.spDef } + } + repeat(11) { field(S8) { 0 } } + val iVs = decompressIVs(field(S32LE) { it.iVs.compress() }) + field(S8) { 0 } + field(S64LE) { 0L } + val rarityMask = + field(U16LE) { + var m = 0 + if (it.isShiny) m = m or (1 shl PokemonRarity.SHINY.ordinal) + if (it.hasHiddenAbility) m = m or (1 shl PokemonRarity.HIDDEN_ABILITY.ordinal) + if (it.isAlpha) m = m or (1 shl PokemonRarity.ALPHA.ordinal) + if (it.isSecret) m = m or (1 shl PokemonRarity.SECRET.ordinal) + if (it.isFatefulEncounter) m = m or (1 shl PokemonRarity.FATEFUL_ENCOUNTER.ordinal) + if (it.isRaidEncounter) m = m or (1 shl PokemonRarity.RAID_ENCOUNTER.ordinal) + m + } + val isShiny = (rarityMask and (1 shl PokemonRarity.SHINY.ordinal)) != 0 + val hasHiddenAbility = (rarityMask and (1 shl PokemonRarity.HIDDEN_ABILITY.ordinal)) != 0 + val isAlpha = (rarityMask and (1 shl PokemonRarity.ALPHA.ordinal)) != 0 + val isSecret = (rarityMask and (1 shl PokemonRarity.SECRET.ordinal)) != 0 + val isFatefulEncounter = (rarityMask and (1 shl PokemonRarity.FATEFUL_ENCOUNTER.ordinal)) != 0 + val isRaidEncounter = (rarityMask and (1 shl PokemonRarity.RAID_ENCOUNTER.ordinal)) != 0 + val caughtAt = field(EpochSecondsS32LE, Pokemon::caughtAt) + field(S16LE) { 0 } + field(S8) { 0 } + field(S8) { 0 } + field(PokemonUnknownBytes) { ByteArray(0) } + repeat(12) { field(S8) { 0 } } + return Pokemon( + id, + container, + containerSlot, + dexId, + seed, + ot, + nickname, + level, + currentHp, + xp, + eVs, + iVs, + moves, + isShiny, + hasHiddenAbility, + isAlpha, + isSecret, + isFatefulEncounter, + isRaidEncounter, + caughtAt, + ) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/codecs/SkinCodec.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/codecs/SkinCodec.kt index 471635f..5da75e8 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/codecs/SkinCodec.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/codecs/SkinCodec.kt @@ -1,52 +1,48 @@ 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?) class SkinSet : EnumMap(SkinSlot::class.java) { - fun put(skin: Skin) { - this[skin.slot] = skin - } + fun put(skin: Skin) { + this[skin.slot] = skin + } - override fun put(key: SkinSlot, value: Skin): Skin? { - require(key == value.slot) { "Slot mismatch: $key != ${value.slot}" } - return super.put(key, value) - } + override fun put(key: SkinSlot, value: Skin): Skin? { + require(key == value.slot) { "Slot mismatch: $key != ${value.slot}" } + return super.put(key, value) + } } class SkinSetCodec( private val slots: List = SkinSlot.entries, private val withLeadingByte: Boolean = true, ) : PacketCodec() { - override fun CodecScope.body(): SkinSet { - if (withLeadingByte) field(U8) { 0 } - val mask = field(U16LE) { slots.fold(0) { acc, slot -> acc or (1 shl slot.ordinal) } } - val skins = SkinSet() - slots.forEach { slot -> - if ((mask and (1 shl slot.ordinal)) != 0) { - val compressed = - field(U16LE) { - val skin = it[slot] ?: Skin(slot, 0u, 0u) - val type = skin.type ?: 0x3FFFu - val color = skin.color ?: 0x3Fu - require(type <= 0x3FFFu) { "Skin type too large: ${skin.type}" } - require(color <= 0x3Fu) { "Skin color too large: ${skin.color}" } - (type and 0x3FFFu).toInt() or ((color and 0x3Fu).toInt() shl 10) + override fun CodecScope.body(): SkinSet { + if (withLeadingByte) field(U8) { 0 } + val mask = field(U16LE) { slots.fold(0) { acc, slot -> acc or (1 shl slot.ordinal) } } + val skins = SkinSet() + slots.forEach { slot -> + if ((mask and (1 shl slot.ordinal)) != 0) { + val compressed = + field(U16LE) { + val skin = it[slot] ?: Skin(slot, 0u, 0u) + val type = skin.type ?: 0x3FFFu + val color = skin.color ?: 0x3Fu + require(type <= 0x3FFFu) { "Skin type too large: ${skin.type}" } + require(color <= 0x3Fu) { "Skin color too large: ${skin.color}" } + (type and 0x3FFFu).toInt() or ((color and 0x3Fu).toInt() shl 10) + } + val type = (compressed and 0x3FFF).toUShort() + val color = ((compressed shr 10) and 0x3F).toUByte() + skins.put(Skin(slot, type, color)) } - val type = (compressed and 0x3FFF).toUShort() - val color = ((compressed shr 10) and 0x3F).toUByte() - skins.put(Skin(slot, type, color)) - } + } + return skins } - return skins - } } val DefaultSkinSetCodec: Codec = SkinSetCodec() diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/codecs/Tile2DCodec.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/codecs/Tile2DCodec.kt index 29df5fb..90dc927 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/codecs/Tile2DCodec.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/codecs/Tile2DCodec.kt @@ -8,12 +8,12 @@ import de.fiereu.openmmo.common.Tile2D val Tile2DCodec: Codec = U16LE.imap( decode = { raw -> - Tile2D( - material = (raw and 0x3FF).toShort(), - collision = ((raw shr 10) and 0x3F).toByte(), - ) + Tile2D( + material = (raw and 0x3FF).toShort(), + collision = ((raw shr 10) and 0x3F).toByte(), + ) }, encode = { tile -> - ((tile.collision.toInt() and 0x3F) shl 10) or (tile.material.toInt() and 0x3FF) + ((tile.collision.toInt() and 0x3F) shl 10) or (tile.material.toInt() and 0x3FF) }, ) diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ActiveBattleSidePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ActiveBattleSidePacket.kt new file mode 100644 index 0000000..bbee91c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ActiveBattleSidePacket.kt @@ -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() { + override fun CodecScope.body(): ActiveBattleSidePacket { + val side = field(S8) { it.side } + return ActiveBattleSidePacket(side) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ActivePokemonSummaryPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ActivePokemonSummaryPacket.kt new file mode 100644 index 0000000..47fa0cf --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ActivePokemonSummaryPacket.kt @@ -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, +) + +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, + val moves: List, +) + +private object SummaryRankingEntryCodec : PacketCodec() { + override fun CodecScope.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() { + override fun CodecScope.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() { + override fun CodecScope.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() { + override fun CodecScope.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> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { SummaryAbilityCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { SummaryAbilityCodec.write(buf, it) } + } + } + +private val SummaryMoveListPrefixedU8: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { SummaryMoveCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { SummaryMoveCodec.write(buf, it) } + } + } + +object ActivePokemonSummaryPacketCodec : PacketCodec() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/AdminNoteActionPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/AdminNoteActionPacket.kt new file mode 100644 index 0000000..c063c62 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/AdminNoteActionPacket.kt @@ -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() { + override fun CodecScope.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) + } + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/AppearanceRequestResultPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/AppearanceRequestResultPacket.kt new file mode 100644 index 0000000..d3c544b --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/AppearanceRequestResultPacket.kt @@ -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() { + override fun CodecScope.body(): AppearanceRequestResultPacket { + val entityId = field(S64LE) { it.entityId } + val accepted = field(Bool) { it.accepted } + return AppearanceRequestResultPacket(entityId, accepted) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/AssignBreedingSlotPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/AssignBreedingSlotPacket.kt new file mode 100644 index 0000000..2b3a11f --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/AssignBreedingSlotPacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BatchInputEventsPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BatchInputEventsPacket.kt new file mode 100644 index 0000000..6e0ea35 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BatchInputEventsPacket.kt @@ -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, +) + +private val EventsCodec: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val count = S16LE.read(buf).toInt() + if (count == 0) return emptyList() + var previous = S64LE.read(buf) + val result = ArrayList(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) { + 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() { + override fun CodecScope.body(): BatchInputEventsPacket { + val hasEvents = field(Bool) { it.hasEvents } + val events = field(EventsCodec) { it.events } + return BatchInputEventsPacket(hasEvents, events) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionOutcomePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionOutcomePacket.kt new file mode 100644 index 0000000..fa9a7ff --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionOutcomePacket.kt @@ -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?, +) + +private val BattleRewardEntryCodec: Codec = + object : PacketCodec() { + override fun CodecScope.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() { + override fun CodecScope.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? = 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, + val rewards: List?, +) + +object BattleActionOutcomePacketCodec : PacketCodec() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionPacket.kt new file mode 100644 index 0000000..de7b2d2 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionPacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionPromptTogglePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionPromptTogglePacket.kt new file mode 100644 index 0000000..40e3423 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionPromptTogglePacket.kt @@ -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() { + override fun CodecScope.body(): BattleActionPromptTogglePacket { + val shown = field(Bool) { it.shown } + return BattleActionPromptTogglePacket(shown) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionResultPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionResultPacket.kt new file mode 100644 index 0000000..abcced0 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionResultPacket.kt @@ -0,0 +1,31 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class BattleActionResultPacket( + val targetCount: Byte, + val targets: List, + val entityId: Long, + val value: Int, + val messageType: Byte, + val move: Byte?, +) + +object BattleActionResultPacketCodec : PacketCodec() { + private const val MESSAGE_TYPE_WITH_MOVE: Int = 0 + + override fun CodecScope.body(): BattleActionResultPacket { + val targetCount = field(S8) { it.targetCount } + val targets = ArrayList() + 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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionSelectPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionSelectPacket.kt new file mode 100644 index 0000000..99129ff --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionSelectPacket.kt @@ -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 = + object : Codec { + 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() { + override fun CodecScope.body(): BattleActionSelectPacket { + return field(BattleActionSelectBody) { it } + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionSubmitPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionSubmitPacket.kt new file mode 100644 index 0000000..fd41425 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleActionSubmitPacket.kt @@ -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) : BattleAction() + +private val BattleActionCodec: Codec = + object : Codec { + 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(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() { + override fun CodecScope.body(): BattleActionSubmitPacket { + val action = field(BattleActionCodec) { it.action } + return BattleActionSubmitPacket(action) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleBoardCellPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleBoardCellPacket.kt new file mode 100644 index 0000000..b79be5a --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleBoardCellPacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleBulkStatePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleBulkStatePacket.kt new file mode 100644 index 0000000..75fe9d1 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleBulkStatePacket.kt @@ -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) : BattleMessageArgPayload() + +internal data class BattleMessageArg( + val id: Byte, + val type: Byte, + val hasExtra: Boolean, + val extra: Byte, + val payload: BattleMessageArgPayload, +) + +internal val BattleMessageArgCodec: Codec = + object : Codec { + 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) : + BattleSerializedEntry() + +internal data class CreatureMovesEntry(val value: Byte, val moves: List) : + 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 = + object : Codec { + 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, + val secondGroup: List, + val valueA: Int, + val valueB: Int, + val flag: Byte, + val thirdGroup: List, +) + +object BattleBulkStatePacketCodec : PacketCodec() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleCancelRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleCancelRequestPacket.kt new file mode 100644 index 0000000..04de2cd --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleCancelRequestPacket.kt @@ -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() { + override fun CodecScope.body(): BattleCancelRequestPacket { + return BattleCancelRequestPacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleChallengeRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleChallengeRequestPacket.kt new file mode 100644 index 0000000..a41bb68 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleChallengeRequestPacket.kt @@ -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, + 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 = + object : Codec { + 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() { + override fun CodecScope.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, + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleChatMessagePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleChatMessagePacket.kt new file mode 100644 index 0000000..0156000 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleChatMessagePacket.kt @@ -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() { + override fun CodecScope.body(): BattleChatMessagePacket { + val channelOrSlot = field(S8) { it.channelOrSlot } + val message = field(Utf16LeNullTerminated) { it.message } + return BattleChatMessagePacket(channelOrSlot, message) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleControlBytesPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleControlBytesPacket.kt new file mode 100644 index 0000000..33195bc --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleControlBytesPacket.kt @@ -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() { + override fun CodecScope.body(): BattleControlBytesPacket { + val controlBytes = field(ControlBytes) { it.controlBytes } + return BattleControlBytesPacket(controlBytes) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleDisconnectMessagePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleDisconnectMessagePacket.kt new file mode 100644 index 0000000..0591ced --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleDisconnectMessagePacket.kt @@ -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?, +) + +internal val MessageArgCodec: Codec = + object : PacketCodec() { + override fun CodecScope.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? = 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, +) + +object BattleDisconnectMessagePacketCodec : PacketCodec() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEmptyEventPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEmptyEventPacket.kt new file mode 100644 index 0000000..c104b9f --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEmptyEventPacket.kt @@ -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() { + override fun CodecScope.body(): BattleEmptyEventPacket { + return BattleEmptyEventPacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEndDisconnectPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEndDisconnectPacket.kt new file mode 100644 index 0000000..c64cdc2 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEndDisconnectPacket.kt @@ -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() { + override fun CodecScope.body(): BattleEndDisconnectPacket { + val reason = field(S8) { it.reason } + return BattleEndDisconnectPacket(reason) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEntityActionEventPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEntityActionEventPacket.kt new file mode 100644 index 0000000..3524997 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEntityActionEventPacket.kt @@ -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() { + override fun CodecScope.body(): BattleEntityActionEventPacket { + val sourceId = field(S64LE) { it.sourceId } + val targetId = field(S64LE) { it.targetId } + return BattleEntityActionEventPacket(sourceId, targetId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEntityDeltaPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEntityDeltaPacket.kt new file mode 100644 index 0000000..9e7ca08 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEntityDeltaPacket.kt @@ -0,0 +1,135 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +private val MoveSlotCodec: Codec> = S16LE.then(S8) + +data class BattleEntityDeltaPacket( + val entityId: Long, + val fieldMask: Int, + val experienceLevel: Byte?, + val experiencePoints: Int?, + val statValues: List?, + val moveSlots: List>?, + val ppUps: Byte?, + val currentHp: Short?, + val faintFlag: Byte?, + val speciesId: Short?, + val forme: Byte?, + val listType: Byte?, + val sortKey: Short?, + val evValues: List?, + 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?, + val originalSpecies: Long?, + val originalTrainerName: String?, + val originalTrainerId: Int?, + val shininessType: Byte?, + val gender: Byte?, + val ivs: List?, + val caughtBall: Byte?, + val statusFlags2: Short?, + val statusList: List?, + val status: Byte?, +) + +object BattleEntityDeltaPacketCodec : PacketCodec() { + override fun CodecScope.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, + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEntityMoveEventPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEntityMoveEventPacket.kt new file mode 100644 index 0000000..19d3ad2 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEntityMoveEventPacket.kt @@ -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 = + object : PacketCodec() { + override fun CodecScope.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, +) + +object BattleEntityMoveEventPacketCodec : PacketCodec() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEnumPairEventPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEnumPairEventPacket.kt new file mode 100644 index 0000000..1c6db12 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleEnumPairEventPacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleLabeledMoveEventPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleLabeledMoveEventPacket.kt new file mode 100644 index 0000000..cf1797f --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleLabeledMoveEventPacket.kt @@ -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 = + object : PacketCodec() { + override fun CodecScope.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, +) + +object BattleLabeledMoveEventPacketCodec : PacketCodec() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleListEventPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleListEventPacket.kt new file mode 100644 index 0000000..16c33cf --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleListEventPacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveDisableUpdatePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveDisableUpdatePacket.kt new file mode 100644 index 0000000..cce4aea --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveDisableUpdatePacket.kt @@ -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, +) + +data class BattleMoveDisableUpdatePacket( + val sides: List, +) + +private val BattleMoveDisableEntryCodec: Codec = + object : PacketCodec() { + override fun CodecScope.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 = + object : PacketCodec() { + override fun CodecScope.body(): BattleMoveDisableSide { + val entries = field(BattleMoveDisableEntryCodec.listPrefixed(U8)) { it.entries } + return BattleMoveDisableSide(entries) + } + } + +object BattleMoveDisableUpdatePacketCodec : PacketCodec() { + override fun CodecScope.body(): BattleMoveDisableUpdatePacket { + val sides = field(BattleMoveDisableSideCodec.repeat(2)) { it.sides } + return BattleMoveDisableUpdatePacket(sides) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveListPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveListPacket.kt new file mode 100644 index 0000000..690cbf1 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveListPacket.kt @@ -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, +) + +private val BattleMoveAppearanceCodec: Codec = + object : PacketCodec() { + override fun CodecScope.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, +) + +private val BattleMoveEntryCodec: Codec = + object : PacketCodec() { + override fun CodecScope.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, +) + +object BattleMoveListPacketCodec : PacketCodec() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveSelectionCancelPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveSelectionCancelPacket.kt new file mode 100644 index 0000000..c21b64b --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveSelectionCancelPacket.kt @@ -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() { + override fun CodecScope.body(): BattleMoveSelectionCancelPacket { + reserved(byte = 0) + return BattleMoveSelectionCancelPacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveSlotChoicePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveSlotChoicePacket.kt new file mode 100644 index 0000000..1104000 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveSlotChoicePacket.kt @@ -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() { + override fun CodecScope.body(): BattleMoveSlotChoicePacket { + val moveSlotIndex = field(S8) { it.moveSlotIndex } + return BattleMoveSlotChoicePacket(moveSlotIndex) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveTargetsPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveTargetsPacket.kt new file mode 100644 index 0000000..35bec77 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveTargetsPacket.kt @@ -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, +) + +private val BattleTargetAppearanceCodec: Codec = + object : PacketCodec() { + override fun CodecScope.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 = + object : PacketCodec() { + override fun CodecScope.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, +) + +object BattleMoveTargetsPacketCodec : PacketCodec() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveUsePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveUsePacket.kt new file mode 100644 index 0000000..6b2dec9 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleMoveUsePacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePartySlotSelectPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePartySlotSelectPacket.kt new file mode 100644 index 0000000..850a877 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePartySlotSelectPacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePartySwitchPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePartySwitchPacket.kt new file mode 100644 index 0000000..a4900aa --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePartySwitchPacket.kt @@ -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() { + override fun CodecScope.body(): BattlePartySwitchPacket { + val monsterEntityId = field(S64LE) { it.monsterEntityId } + return BattlePartySwitchPacket(monsterEntityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePokemonSpritePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePokemonSpritePacket.kt new file mode 100644 index 0000000..48f8998 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePokemonSpritePacket.kt @@ -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() { + override fun CodecScope.body(): BattlePokemonSpritePacket { + val entityId = field(S64LE) { it.entityId } + val spriteId = field(S16LE) { it.spriteId } + return BattlePokemonSpritePacket(entityId, spriteId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePokemonStatusPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePokemonStatusPacket.kt new file mode 100644 index 0000000..5778fc2 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePokemonStatusPacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePromptSwitchPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePromptSwitchPacket.kt new file mode 100644 index 0000000..62ca430 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattlePromptSwitchPacket.kt @@ -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() { + override fun CodecScope.body(): BattlePromptSwitchPacket { + val enabled = field(Bool) { it.enabled } + return BattlePromptSwitchPacket(enabled) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleQueuedEventPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleQueuedEventPacket.kt new file mode 100644 index 0000000..e85a577 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleQueuedEventPacket.kt @@ -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() { + override fun CodecScope.body(): BattleQueuedEventPacket { + val packed = field(S8) { it.packed } + return BattleQueuedEventPacket(packed) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleRatingBulkPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleRatingBulkPacket.kt new file mode 100644 index 0000000..43fdf3f --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleRatingBulkPacket.kt @@ -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 = + object : PacketCodec() { + override fun CodecScope.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, +) + +object BattleRatingBulkPacketCodec : PacketCodec() { + override fun CodecScope.body(): BattleRatingBulkPacket { + val ratings = field(BattleRatingEntryCodec.listPrefixed(U8)) { it.ratings } + return BattleRatingBulkPacket(ratings) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleRatingUpdatePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleRatingUpdatePacket.kt new file mode 100644 index 0000000..fadf9f2 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleRatingUpdatePacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleReadyPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleReadyPacket.kt new file mode 100644 index 0000000..882646c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleReadyPacket.kt @@ -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() { + override fun CodecScope.body(): BattleReadyPacket { + val ready = field(Bool) { it.ready } + return BattleReadyPacket(ready) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleRewardSelectPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleRewardSelectPacket.kt new file mode 100644 index 0000000..10cf0e7 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleRewardSelectPacket.kt @@ -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() { + override fun CodecScope.body(): BattleRewardSelectPacket { + val targetEntityId = field(S64LE) { it.targetEntityId } + val rewardIndex = field(S32LE) { it.rewardIndex } + return BattleRewardSelectPacket(targetEntityId, rewardIndex) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleScreenOpenPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleScreenOpenPacket.kt new file mode 100644 index 0000000..1f63763 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleScreenOpenPacket.kt @@ -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 = + object : PacketCodec() { + override fun CodecScope.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 = + object : PacketCodec() { + override fun CodecScope.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 = + object : PacketCodec() { + override fun CodecScope.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, + val targetsB: List, +) + +private val BattleSelectablePokemonCodec: Codec = + object : PacketCodec() { + override fun CodecScope.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 = + object : PacketCodec() { + override fun CodecScope.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, + val tierUpdates: List, + val pokemon: List, + val storageItems: List, +) + +object BattleScreenOpenPacketCodec : PacketCodec() { + override fun CodecScope.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() + var tierUpdates = emptyList() + var pokemon = emptyList() + 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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSendOutActivePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSendOutActivePacket.kt new file mode 100644 index 0000000..41e4e30 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSendOutActivePacket.kt @@ -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() { + override fun CodecScope.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 + ) + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSideAddPokemonPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSideAddPokemonPacket.kt new file mode 100644 index 0000000..b95b8f6 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSideAddPokemonPacket.kt @@ -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 = + object : PacketCodec() { + override fun CodecScope.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() { + override fun CodecScope.body(): BattleSideAddPokemonPacket { + val side = field(S8) { it.side } + val pokemon = field(BattleAddPokemonCodec) { it.pokemon } + return BattleSideAddPokemonPacket(side, pokemon) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSidePartyPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSidePartyPacket.kt new file mode 100644 index 0000000..ee5b53b --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSidePartyPacket.kt @@ -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 = + object : PacketCodec() { + override fun CodecScope.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, +) + +object BattleSidePartyPacketCodec : PacketCodec() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSideRemovePokemonPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSideRemovePokemonPacket.kt new file mode 100644 index 0000000..6c23773 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSideRemovePokemonPacket.kt @@ -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() { + override fun CodecScope.body(): BattleSideRemovePokemonPacket { + val side = field(S8) { it.side } + val entityId = field(S64LE) { it.entityId } + return BattleSideRemovePokemonPacket(side, entityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSimulationRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSimulationRequestPacket.kt new file mode 100644 index 0000000..dba47ac --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSimulationRequestPacket.kt @@ -0,0 +1,30 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +private val SimulationConfigPayload: Codec = + object : Codec { + 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() { + override fun CodecScope.body(): BattleSimulationRequestPacket { + val simulationConfig = field(SimulationConfigPayload) { it.simulationConfig } + return BattleSimulationRequestPacket(simulationConfig) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotActionPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotActionPacket.kt new file mode 100644 index 0000000..f3cb9be --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotActionPacket.kt @@ -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() { + override fun CodecScope.body(): BattleSlotActionPacket { + val slotRefPacked = field(S8) { it.slotRefPacked } + val actionByte = field(S8) { it.actionByte } + return BattleSlotActionPacket(slotRefPacked, actionByte) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotAnimationResetPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotAnimationResetPacket.kt new file mode 100644 index 0000000..0b5b85d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotAnimationResetPacket.kt @@ -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() { + override fun CodecScope.body(): BattleSlotAnimationResetPacket { + val entityId = field(S64LE) { it.entityId } + val slot = field(S8) { it.slot } + return BattleSlotAnimationResetPacket(entityId, slot) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotEventEnumPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotEventEnumPacket.kt new file mode 100644 index 0000000..50b8a2e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotEventEnumPacket.kt @@ -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() { + override fun CodecScope.body(): BattleSlotEventEnumPacket { + val slot = field(S8) { it.slot } + val eventType = field(S8) { it.eventType } + return BattleSlotEventEnumPacket(slot, eventType) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotFlagEventPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotFlagEventPacket.kt new file mode 100644 index 0000000..1deb01d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotFlagEventPacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotMoveEventPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotMoveEventPacket.kt new file mode 100644 index 0000000..29602a8 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotMoveEventPacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotSwitchEventPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotSwitchEventPacket.kt new file mode 100644 index 0000000..3e925f1 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSlotSwitchEventPacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStartScenePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStartScenePacket.kt new file mode 100644 index 0000000..f8e3368 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStartScenePacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStatCountersPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStatCountersPacket.kt new file mode 100644 index 0000000..750b49e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStatCountersPacket.kt @@ -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() { + override fun CodecScope.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, + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStatStagePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStatStagePacket.kt new file mode 100644 index 0000000..c2d02ef --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStatStagePacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStateBytePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStateBytePacket.kt new file mode 100644 index 0000000..9a49f16 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStateBytePacket.kt @@ -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() { + override fun CodecScope.body(): BattleStateBytePacket { + val state = field(S8) { it.state } + return BattleStateBytePacket(state) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStateSlotIntPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStateSlotIntPacket.kt new file mode 100644 index 0000000..260e5be --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStateSlotIntPacket.kt @@ -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() { + override fun CodecScope.body(): BattleStateSlotIntPacket { + val index = field(S8) { it.index } + val value = field(S32LE) { it.value } + return BattleStateSlotIntPacket(index, value) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStatusFlagPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStatusFlagPacket.kt new file mode 100644 index 0000000..9fdb90a --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleStatusFlagPacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSwitchPromptTogglePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSwitchPromptTogglePacket.kt new file mode 100644 index 0000000..5d06a82 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSwitchPromptTogglePacket.kt @@ -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() { + override fun CodecScope.body(): BattleSwitchPromptTogglePacket { + val shown = field(Bool) { it.shown } + return BattleSwitchPromptTogglePacket(shown) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSwitchSelectionsPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSwitchSelectionsPacket.kt new file mode 100644 index 0000000..f93d9cf --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleSwitchSelectionsPacket.kt @@ -0,0 +1,16 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class BattleSwitchSelectionsPacket( + val selectedEntityIds: List, +) + +private val SelectedEntityIdsCodec = S64LE.listPrefixed(U8) + +object BattleSwitchSelectionsPacketCodec : PacketCodec() { + override fun CodecScope.body(): BattleSwitchSelectionsPacket { + val selectedEntityIds = field(SelectedEntityIdsCodec) { it.selectedEntityIds } + return BattleSwitchSelectionsPacket(selectedEntityIds) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTargetPickPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTargetPickPacket.kt new file mode 100644 index 0000000..6dc4c88 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTargetPickPacket.kt @@ -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() { + override fun CodecScope.body(): BattleTargetPickPacket { + val targetEntityId = field(S64LE) { it.targetEntityId } + return BattleTargetPickPacket(targetEntityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTeamPreviewConfirmPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTeamPreviewConfirmPacket.kt new file mode 100644 index 0000000..5e9a57c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTeamPreviewConfirmPacket.kt @@ -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() { + override fun CodecScope.body(): BattleTeamPreviewConfirmPacket { + val side = field(S16LE) { it.side } + val isOwnTeam = field(Bool) { it.isOwnTeam } + return BattleTeamPreviewConfirmPacket(side, isOwnTeam) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTeamPreviewListPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTeamPreviewListPacket.kt new file mode 100644 index 0000000..3f57552 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTeamPreviewListPacket.kt @@ -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() { + override fun CodecScope.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, +) + +object BattleTeamPreviewListPacketCodec : PacketCodec() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTierSelectPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTierSelectPacket.kt new file mode 100644 index 0000000..8ad2e7b --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTierSelectPacket.kt @@ -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() { + override fun CodecScope.body(): BattleTierSelectPacket { + val pokemonSlotIndex = field(S8) { it.pokemonSlotIndex } + val tierIndex = field(S8) { it.tierIndex } + return BattleTierSelectPacket(pokemonSlotIndex, tierIndex) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTransitionReadyPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTransitionReadyPacket.kt new file mode 100644 index 0000000..7c208e6 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleTransitionReadyPacket.kt @@ -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() { + override fun CodecScope.body(): BattleTransitionReadyPacket { + return BattleTransitionReadyPacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleUseItemPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleUseItemPacket.kt new file mode 100644 index 0000000..2cdc55d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BattleUseItemPacket.kt @@ -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() { + override fun CodecScope.body(): BattleUseItemPacket { + val pokemonEntityId = field(S64LE) { it.pokemonEntityId } + val quantity = field(S16LE) { it.quantity } + return BattleUseItemPacket(pokemonEntityId, quantity) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BlockPlayerPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BlockPlayerPacket.kt new file mode 100644 index 0000000..c926e79 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BlockPlayerPacket.kt @@ -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() { + override fun CodecScope.body(): BlockPlayerPacket { + val username = field(Utf16LeNullTerminated) { it.username } + val reason = field(Utf16LeNullTerminated) { it.reason } + return BlockPlayerPacket(username, reason) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BreedingForecastPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BreedingForecastPacket.kt new file mode 100644 index 0000000..0d97bec --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/BreedingForecastPacket.kt @@ -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, +) + +data class BreedingForecastPacket( + val parentA: Long, + val parentB: Long, + val hasPreview: Boolean, + val species: Short, + val form: Byte, + val statEntries: List, + val shininessTypes: List, + val valueIds: List, + val valueSources: List, + val gender: Byte, + val nature: Short, + val shiny: Boolean, + val cost: Int, + val secondaryCost: Int, +) + +private object BreedingStatContributionCodec : PacketCodec() { + override fun CodecScope.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> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { BreedingStatContributionCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { BreedingStatContributionCodec.write(buf, it) } + } + } + +private object BreedingStatEntryCodec : PacketCodec() { + override fun CodecScope.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() { + override fun CodecScope.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, + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ByteArgumentPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ByteArgumentPacket.kt new file mode 100644 index 0000000..8e85e5f --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ByteArgumentPacket.kt @@ -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() { + override fun CodecScope.body(): ByteArgumentPacket { + val value = field(S8) { it.value } + return ByteArgumentPacket(value) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ByteChoicePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ByteChoicePacket.kt new file mode 100644 index 0000000..dbbc782 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ByteChoicePacket.kt @@ -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() { + override fun CodecScope.body(): ByteChoicePacket { + val value = field(S8) { it.value } + return ByteChoicePacket(value) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CameraFollowEntityPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CameraFollowEntityPacket.kt new file mode 100644 index 0000000..1912b7f --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CameraFollowEntityPacket.kt @@ -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() { + override fun CodecScope.body(): CameraFollowEntityPacket { + val entityId = field(S64LE) { it.entityId } + return CameraFollowEntityPacket(entityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CancelEntityMessagePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CancelEntityMessagePacket.kt new file mode 100644 index 0000000..aa90375 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CancelEntityMessagePacket.kt @@ -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() { + override fun CodecScope.body(): CancelEntityMessagePacket { + val entityId = field(S64LE) { it.entityId } + return CancelEntityMessagePacket(entityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CancelMatchmakingSearchPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CancelMatchmakingSearchPacket.kt new file mode 100644 index 0000000..c047299 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CancelMatchmakingSearchPacket.kt @@ -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() { + override fun CodecScope.body(): CancelMatchmakingSearchPacket { + return CancelMatchmakingSearchPacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CancelSocialInteractionPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CancelSocialInteractionPacket.kt new file mode 100644 index 0000000..7e117cf --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CancelSocialInteractionPacket.kt @@ -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() { + override fun CodecScope.body(): CancelSocialInteractionPacket { + return CancelSocialInteractionPacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CategoryFlagsPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CategoryFlagsPacket.kt new file mode 100644 index 0000000..0adaf48 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CategoryFlagsPacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChannelAssignmentsPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChannelAssignmentsPacket.kt new file mode 100644 index 0000000..7cd3471 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChannelAssignmentsPacket.kt @@ -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) + +data class ChannelAssignmentsPacket( + val typeBindings: List, + val groupBindings: List, +) + +private val ChannelTypeBindingCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): ChannelTypeBinding { + val chatType = field(S16LE) { it.chatType } + val channel = field(S8) { it.channel } + return ChannelTypeBinding(chatType, channel) + } + } + +private val ChannelGroupBindingCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): ChannelGroupBinding { + val channel = field(S8) { it.channel } + val members = field(S16LE.listPrefixed(U16LE)) { it.members } + return ChannelGroupBinding(channel, members) + } + } + +object ChannelAssignmentsPacketCodec : PacketCodec() { + override fun CodecScope.body(): ChannelAssignmentsPacket { + val typeBindings = field(ChannelTypeBindingCodec.listPrefixed(U16LE)) { it.typeBindings } + val groupBindings = field(ChannelGroupBindingCodec.listPrefixed(U8)) { it.groupBindings } + return ChannelAssignmentsPacket(typeBindings, groupBindings) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChannelCountDeltaPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChannelCountDeltaPacket.kt new file mode 100644 index 0000000..7594d03 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChannelCountDeltaPacket.kt @@ -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, + val delta: Byte, +) + +private val ChannelCountEntryCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): ChannelCountEntry { + val channelId = field(S16LE) { it.channelId } + val flag = field(Bool) { it.flag } + return ChannelCountEntry(channelId, flag) + } + } + +object ChannelCountDeltaPacketCodec : PacketCodec() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChannelSwitchPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChannelSwitchPacket.kt new file mode 100644 index 0000000..3a6cce2 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChannelSwitchPacket.kt @@ -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() { + override fun CodecScope.body(): ChannelSwitchPacket { + val channelId = field(S8) { it.channelId } + val silent = field(Bool) { it.silent } + return ChannelSwitchPacket(channelId, silent) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CharacterAppearanceApplyPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CharacterAppearanceApplyPacket.kt new file mode 100644 index 0000000..a9a6173 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CharacterAppearanceApplyPacket.kt @@ -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) + +data class CharacterAppearanceApplyPacket( + val characterName: String, + val appearanceTypeA: Byte, + val appearanceTypeB: Byte, + val creatureMoves: AppearanceMoveSet, +) + +object CharacterAppearanceApplyPacketCodec : PacketCodec() { + override fun CodecScope.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() + 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), + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CharactersListPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CharactersListPacket.kt index 3ba33ef..e82569a 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CharactersListPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CharactersListPacket.kt @@ -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, @@ -24,57 +11,57 @@ data class CharacterEntry( val guildId: Int? = null, val pokemon: List, ) { - init { - require(pokemon.size <= 6) { "Party size can't be more than 6 pokemon" } - } + init { + require(pokemon.size <= 6) { "Party size can't be more than 6 pokemon" } + } } data class CharactersListPacket(val characters: List) private val CharacterInfoAsymmetric: Codec = object : Codec { - override fun read(buf: ReadBuffer): CharacterInfo = CharacterInfoCodecLong.read(buf) + override fun read(buf: ReadBuffer): CharacterInfo = CharacterInfoCodecLong.read(buf) - override fun write(buf: WriteBuffer, value: CharacterInfo) { - CharacterInfoCodecShort.write(buf, value) - } + override fun write(buf: WriteBuffer, value: CharacterInfo) { + CharacterInfoCodecShort.write(buf, value) + } } private object CharacterEntryCodec : PacketCodec() { - override fun CodecScope.body(): CharacterEntry { - val info = field(CharacterInfoAsymmetric, CharacterEntry::characterInfo) - val skin = field(DefaultSkinSetCodec, CharacterEntry::skinSet) - field(SkinSetCodecNoLeading, CharacterEntry::skinSet) - val hasGuild = field(Bool) { it.guildId != null } - val guildId = - if (hasGuild) { - field(Utf16LeNullTerminated) { "" } - field(S32LE) { it.guildId!! } - } else { - null - } - val partySize = field(U8) { it.pokemon.size } - val party = List(partySize) { field(PokemonCodec) { entry -> entry.pokemon[it] } } - return CharacterEntry(info, skin, guildId, party) - } + override fun CodecScope.body(): CharacterEntry { + val info = field(CharacterInfoAsymmetric, CharacterEntry::characterInfo) + val skin = field(DefaultSkinSetCodec, CharacterEntry::skinSet) + field(SkinSetCodecNoLeading, CharacterEntry::skinSet) + val hasGuild = field(Bool) { it.guildId != null } + val guildId = + if (hasGuild) { + field(Utf16LeNullTerminated) { "" } + field(S32LE) { it.guildId!! } + } else { + null + } + val partySize = field(U8) { it.pokemon.size } + val party = List(partySize) { field(PokemonCodec) { entry -> entry.pokemon[it] } } + return CharacterEntry(info, skin, guildId, party) + } } private val CharacterEntryListPrefixedU8: Codec> = object : Codec> { - override fun read(buf: ReadBuffer): List { - val n = U8.read(buf) - return List(n) { CharacterEntryCodec.read(buf) } - } + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { CharacterEntryCodec.read(buf) } + } - override fun write(buf: WriteBuffer, value: List) { - U8.write(buf, value.size) - value.forEach { CharacterEntryCodec.write(buf, it) } - } + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { CharacterEntryCodec.write(buf, it) } + } } object CharactersListPacketCodec : PacketCodec() { - override fun CodecScope.body() = - CharactersListPacket( - characters = field(CharacterEntryListPrefixedU8, CharactersListPacket::characters), - ) + override fun CodecScope.body() = + CharactersListPacket( + characters = field(CharacterEntryListPrefixedU8, CharactersListPacket::characters), + ) } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatChannelMessagesPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatChannelMessagesPacket.kt new file mode 100644 index 0000000..6edc70a --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatChannelMessagesPacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatChannelUserListPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatChannelUserListPacket.kt new file mode 100644 index 0000000..f67aa00 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatChannelUserListPacket.kt @@ -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, +) + +private val ChatChannelUserCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): ChatChannelUser { + val channelId = field(S16LE) { it.channelId } + val rank = field(S8) { it.rank } + return ChatChannelUser(channelId, rank) + } + } + +object ChatChannelUserListPacketCodec : PacketCodec() { + override fun CodecScope.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, + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatLocalePreferencesPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatLocalePreferencesPacket.kt new file mode 100644 index 0000000..b922ad5 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatLocalePreferencesPacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatMessagePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatMessagePacket.kt index 3c3aa3b..7ed35d1 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatMessagePacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatMessagePacket.kt @@ -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 @@ -18,35 +12,35 @@ data class ChatMessagePacket( ) object ChatMessagePacketCodec : PacketCodec() { - override fun CodecScope.body(): ChatMessagePacket { - val type = ChatType.entries[field(U8) { it.type.ordinal }] - return if (type == ChatType.TEAM) { - ChatMessagePacket( - type = type, - language = null, - message = field(Utf16LeNullTerminated, ChatMessagePacket::message), - sender = null, - ) - } else { - field(S64LE) { 0L } - val sender = - field(Utf16LeNullTerminated) { - it.sender ?: throw MalformedPacketException("sender must not be null") - } - val language = - Language.entries[ - field(U8) { - (it.language ?: throw MalformedPacketException("language must not be null")) - .ordinal - }] - field(S8) { -1 } - val message = field(Utf16LeNullTerminated, ChatMessagePacket::message) - ChatMessagePacket( - type = type, - language = language, - message = message, - sender = sender, - ) + override fun CodecScope.body(): ChatMessagePacket { + val type = ChatType.entries[field(U8) { it.type.ordinal }] + return if (type == ChatType.TEAM) { + ChatMessagePacket( + type = type, + language = null, + message = field(Utf16LeNullTerminated, ChatMessagePacket::message), + sender = null, + ) + } else { + field(S64LE) { 0L } + val sender = + field(Utf16LeNullTerminated) { + it.sender ?: throw MalformedPacketException("sender must not be null") + } + val language = + Language.entries[ + field(U8) { + (it.language ?: throw MalformedPacketException("language must not be null")) + .ordinal + }] + field(S8) { -1 } + val message = field(Utf16LeNullTerminated, ChatMessagePacket::message) + ChatMessagePacket( + type = type, + language = language, + message = message, + sender = sender, + ) + } } - } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatMessageSendPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatMessageSendPacket.kt new file mode 100644 index 0000000..8502ed5 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatMessageSendPacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatMessageWithdrawPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatMessageWithdrawPacket.kt new file mode 100644 index 0000000..b8f33c1 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChatMessageWithdrawPacket.kt @@ -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() { + override fun CodecScope.body(): ChatMessageWithdrawPacket { + val authorId = field(S64LE) { it.authorId } + return ChatMessageWithdrawPacket(authorId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChunkedImagePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChunkedImagePacket.kt new file mode 100644 index 0000000..2214d1d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChunkedImagePacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChunkedTransferAppendPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChunkedTransferAppendPacket.kt new file mode 100644 index 0000000..14a8e08 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChunkedTransferAppendPacket.kt @@ -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() { + override fun CodecScope.body(): ChunkedTransferAppendPacket { + val data = field(bytesPrefixed(U16LE)) { it.data } + return ChunkedTransferAppendPacket(data) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChunkedTransferBeginPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChunkedTransferBeginPacket.kt new file mode 100644 index 0000000..6ed384c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChunkedTransferBeginPacket.kt @@ -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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChunkedTransferDataPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChunkedTransferDataPacket.kt new file mode 100644 index 0000000..e14e09e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ChunkedTransferDataPacket.kt @@ -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 = + object : Codec { + 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() { + override fun CodecScope.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) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ClientCookieUpdatePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ClientCookieUpdatePacket.kt new file mode 100644 index 0000000..58884d8 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ClientCookieUpdatePacket.kt @@ -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?, +) { + 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 = + (S8.then(Utf16LeNullTerminated)).let { pair -> + object : Codec { + 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() { + override fun CodecScope.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? = + if (flags.toInt() and 2 != 0) + field(CookieNamedValueCodec.listPrefixed(U8)) { it.namedValues!! } + else null + return ClientCookieUpdatePacket(blob, namedValues) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ClientDiagnosticsPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ClientDiagnosticsPacket.kt new file mode 100644 index 0000000..29d473f --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ClientDiagnosticsPacket.kt @@ -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, +) { + 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() { + override fun CodecScope.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, + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ClientSettingUpdatePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ClientSettingUpdatePacket.kt new file mode 100644 index 0000000..489b25f --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ClientSettingUpdatePacket.kt @@ -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() { + override fun CodecScope.body(): ClientSettingUpdatePacket { + val settingsValue = field(S32LE) { it.settingsValue } + return ClientSettingUpdatePacket(settingsValue) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactCategoryGroupPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactCategoryGroupPacket.kt new file mode 100644 index 0000000..b4cf1ae --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactCategoryGroupPacket.kt @@ -0,0 +1,18 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class ContactCategoryGroupPacket( + val category: Byte, + val name: String, + val memberIds: List, +) + +object ContactCategoryGroupPacketCodec : PacketCodec() { + override fun CodecScope.body(): ContactCategoryGroupPacket { + val category = field(S8, ContactCategoryGroupPacket::category) + val name = field(Utf16LeNullTerminated, ContactCategoryGroupPacket::name) + val memberIds = field(S64LE.repeat(6), ContactCategoryGroupPacket::memberIds) + return ContactCategoryGroupPacket(category, name, memberIds) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactDeletePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactDeletePacket.kt new file mode 100644 index 0000000..e3665d1 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactDeletePacket.kt @@ -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 ContactDeletePacket( + val entityId: Long, +) + +object ContactDeletePacketCodec : PacketCodec() { + override fun CodecScope.body(): ContactDeletePacket { + val entityId = field(S64LE) { it.entityId } + return ContactDeletePacket(entityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactInsertPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactInsertPacket.kt new file mode 100644 index 0000000..08c7ed6 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactInsertPacket.kt @@ -0,0 +1,42 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class ContactInsertAppearance( + val name: String, + val valueA: Byte, + val valueB: Int, + val kind: Byte, + val packedSlots: Byte, + val spriteData: List, +) + +data class ContactInsertPacket( + val player: Long, + val value: Int, + val online: Boolean, + val appearance: ContactInsertAppearance, +) + +private val ContactInsertAppearanceCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): ContactInsertAppearance { + val name = field(Utf16LeNullTerminated) { it.name } + val valueA = field(S8) { it.valueA } + val valueB = field(S32LE) { it.valueB } + val kind = field(S8) { it.kind } + val packedSlots = field(S8) { it.packedSlots } + val spriteData = field(S16LE.repeat(12)) { it.spriteData } + return ContactInsertAppearance(name, valueA, valueB, kind, packedSlots, spriteData) + } + } + +object ContactInsertPacketCodec : PacketCodec() { + override fun CodecScope.body(): ContactInsertPacket { + val player = field(S64LE) { it.player } + val value = field(S32LE) { it.value } + val online = field(U8) { if (it.online) 1 else 0 } == 1 + val appearance = field(ContactInsertAppearanceCodec) { it.appearance } + return ContactInsertPacket(player, value, online, appearance) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactOnlineStatePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactOnlineStatePacket.kt new file mode 100644 index 0000000..ffb862c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactOnlineStatePacket.kt @@ -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.U8 + +data class ContactOnlineStatePacket( + val contactId: Long, + val online: Boolean, +) + +object ContactOnlineStatePacketCodec : PacketCodec() { + override fun CodecScope.body(): ContactOnlineStatePacket { + val contactId = field(S64LE) { it.contactId } + val online = field(U8) { if (it.online) 1 else 0 } == 1 + return ContactOnlineStatePacket(contactId, online) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactRosterPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactRosterPacket.kt new file mode 100644 index 0000000..7e90303 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ContactRosterPacket.kt @@ -0,0 +1,56 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class ContactAppearance( + val name: String, + val valueA: Byte, + val valueB: Int, + val kind: Byte, + val packedSlots: Byte, + val spriteData: List, +) + +data class ContactRosterEntry( + val player: Long, + val value: Int, + val online: Boolean, + val appearance: ContactAppearance, +) + +data class ContactRosterPacket( + val mode: Int, + val entries: List, +) + +private val ContactAppearanceCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): ContactAppearance { + val name = field(Utf16LeNullTerminated) { it.name } + val valueA = field(S8) { it.valueA } + val valueB = field(S32LE) { it.valueB } + val kind = field(S8) { it.kind } + val packedSlots = field(S8) { it.packedSlots } + val spriteData = field(S16LE.repeat(12)) { it.spriteData } + return ContactAppearance(name, valueA, valueB, kind, packedSlots, spriteData) + } + } + +private val ContactRosterEntryCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): ContactRosterEntry { + val player = field(S64LE) { it.player } + val value = field(S32LE) { it.value } + val online = field(U8) { if (it.online) 1 else 0 } == 1 + val appearance = field(ContactAppearanceCodec) { it.appearance } + return ContactRosterEntry(player, value, online, appearance) + } + } + +object ContactRosterPacketCodec : PacketCodec() { + override fun CodecScope.body(): ContactRosterPacket { + val mode = field(U8) { it.mode } + val entries = field(ContactRosterEntryCodec.listPrefixed(U8)) { it.entries } + return ContactRosterPacket(mode, entries) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CoopScoreboardRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CoopScoreboardRequestPacket.kt new file mode 100644 index 0000000..a88ff38 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CoopScoreboardRequestPacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec + +class CoopScoreboardRequestPacket + +object CoopScoreboardRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): CoopScoreboardRequestPacket { + return CoopScoreboardRequestPacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CreateCharacterPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CreateCharacterPacket.kt index 02e50bd..6547345 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CreateCharacterPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CreateCharacterPacket.kt @@ -7,8 +7,8 @@ import de.fiereu.bytecodec.Utf16LeNullTerminated data class CreateCharacterPacket(val name: String) object CreateCharacterPacketCodec : PacketCodec() { - override fun CodecScope.body(): CreateCharacterPacket { - val name = field(Utf16LeNullTerminated) { it.name } - return CreateCharacterPacket(name) - } + override fun CodecScope.body(): CreateCharacterPacket { + val name = field(Utf16LeNullTerminated) { it.name } + return CreateCharacterPacket(name) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CreateMarketListingPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CreateMarketListingPacket.kt new file mode 100644 index 0000000..7dc1623 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CreateMarketListingPacket.kt @@ -0,0 +1,20 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class CreateMarketListingPacket( + val entryKind: Byte, + val entityId: Long, + val price: Int, + val quantity: Short, +) + +object CreateMarketListingPacketCodec : PacketCodec() { + override fun CodecScope.body(): CreateMarketListingPacket { + val entryKind = field(S8) { it.entryKind } + val entityId = field(S64LE) { it.entityId } + val price = field(S32LE) { it.price } + val quantity = field(S16LE) { it.quantity } + return CreateMarketListingPacket(entryKind, entityId, price, quantity) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CurrencyBalancePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CurrencyBalancePacket.kt new file mode 100644 index 0000000..cd8501d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CurrencyBalancePacket.kt @@ -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.S32LE + +data class CurrencyBalancePacket( + val primaryBalance: Int, + val secondaryBalance: Int, +) + +object CurrencyBalancePacketCodec : PacketCodec() { + override fun CodecScope.body(): CurrencyBalancePacket { + val primaryBalance = field(S32LE) { it.primaryBalance } + val secondaryBalance = field(S32LE) { it.secondaryBalance } + return CurrencyBalancePacket(primaryBalance, secondaryBalance) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CustomizationAcceptPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CustomizationAcceptPacket.kt new file mode 100644 index 0000000..9577f99 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CustomizationAcceptPacket.kt @@ -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.S64LE + +data class CustomizationAcceptPacket(val entityId: Long, val verificationToken: Long) + +object CustomizationAcceptPacketCodec : PacketCodec() { + override fun CodecScope.body(): CustomizationAcceptPacket { + val entityId = field(S64LE) { it.entityId } + val verificationToken = field(S64LE) { it.verificationToken } + return CustomizationAcceptPacket(entityId, verificationToken) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CustomizeCharacterAppearancePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CustomizeCharacterAppearancePacket.kt new file mode 100644 index 0000000..19fc36a --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/CustomizeCharacterAppearancePacket.kt @@ -0,0 +1,65 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class CreatureMoveEntry( + val packed: Short, + val extra: Byte?, +) + +data class CreatureMoveset( + val headerByte: Byte, + val moveMask: Short, + val moves: List, +) + +private val CreatureMovesetCodec: Codec = + object : Codec { + override fun read(buf: ReadBuffer): CreatureMoveset { + val headerByte = S8.read(buf) + val moveMask = S16LE.read(buf) + val hasExtra = (moveMask.toInt() and 0x8000) != 0 + val moves = ArrayList() + for (slot in 0 until 15) { + if ((moveMask.toInt() and (1 shl slot)) != 0) { + val packed = S16LE.read(buf) + val extra = if (hasExtra) S8.read(buf) else null + moves.add(CreatureMoveEntry(packed, extra)) + } + } + return CreatureMoveset(headerByte, moveMask, moves) + } + + override fun write(buf: WriteBuffer, value: CreatureMoveset) { + S8.write(buf, value.headerByte) + S16LE.write(buf, value.moveMask) + val hasExtra = (value.moveMask.toInt() and 0x8000) != 0 + for (move in value.moves) { + S16LE.write(buf, move.packed) + if (hasExtra && move.extra != null) S8.write(buf, move.extra) + } + } + } + +data class CustomizeCharacterAppearancePacket( + val entityId: Long, + val colorCategoryId: Byte, + val colorSlot: Byte, + val moveSet: CreatureMoveset, + val paletteIndex: Byte, +) + +object CustomizeCharacterAppearancePacketCodec : + PacketCodec() { + override fun CodecScope.body(): + CustomizeCharacterAppearancePacket { + val entityId = field(S64LE) { it.entityId } + val colorCategoryId = field(S8) { it.colorCategoryId } + val colorSlot = field(S8) { it.colorSlot } + val moveSet = field(CreatureMovesetCodec) { it.moveSet } + val paletteIndex = field(S8) { it.paletteIndex } + return CustomizeCharacterAppearancePacket( + entityId, colorCategoryId, colorSlot, moveSet, paletteIndex + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DataContentSyncBatchPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DataContentSyncBatchPacket.kt new file mode 100644 index 0000000..e305847 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DataContentSyncBatchPacket.kt @@ -0,0 +1,36 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class DataContentSyncBatchPacket( + val count: Int, + val recordsData: ByteArray, +) { + override fun equals(other: Any?): Boolean = + other is DataContentSyncBatchPacket && + count == other.count && + recordsData.contentEquals(other.recordsData) + + override fun hashCode(): Int = count * 31 + recordsData.contentHashCode() +} + +private val ContentRecordsBytes: Codec = + object : Codec { + 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 DataContentSyncBatchPacketCodec : PacketCodec() { + override fun CodecScope.body(): DataContentSyncBatchPacket { + val count = field(U8) { it.count } + val recordsData = field(ContentRecordsBytes) { it.recordsData } + return DataContentSyncBatchPacket(count, recordsData) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DataDigestSyncBatchedPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DataDigestSyncBatchedPacket.kt new file mode 100644 index 0000000..4f73a18 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DataDigestSyncBatchedPacket.kt @@ -0,0 +1,28 @@ +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 DataDigestSyncBatchedPacket( + val bitCount: Int, + val digest: ByteArray, +) { + override fun equals(other: Any?): Boolean = + other is DataDigestSyncBatchedPacket && + bitCount == other.bitCount && + digest.contentEquals(other.digest) + + override fun hashCode(): Int = bitCount * 31 + digest.contentHashCode() +} + +private val DigestBytes = bytesPrefixed(U16LE) + +object DataDigestSyncBatchedPacketCodec : PacketCodec() { + override fun CodecScope.body(): DataDigestSyncBatchedPacket { + val bitCount = field(U16LE) { it.bitCount } + val digest = field(DigestBytes) { it.digest } + return DataDigestSyncBatchedPacket(bitCount, digest) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DataDigestSyncPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DataDigestSyncPacket.kt new file mode 100644 index 0000000..6aab452 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DataDigestSyncPacket.kt @@ -0,0 +1,28 @@ +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 DataDigestSyncPacket( + val bitCount: Int, + val digest: ByteArray, +) { + override fun equals(other: Any?): Boolean = + other is DataDigestSyncPacket && + bitCount == other.bitCount && + digest.contentEquals(other.digest) + + override fun hashCode(): Int = bitCount * 31 + digest.contentHashCode() +} + +private val DigestBytes = bytesPrefixed(U16LE) + +object DataDigestSyncPacketCodec : PacketCodec() { + override fun CodecScope.body(): DataDigestSyncPacket { + val bitCount = field(U16LE) { it.bitCount } + val digest = field(DigestBytes) { it.digest } + return DataDigestSyncPacket(bitCount, digest) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DataDigestSyncResponsePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DataDigestSyncResponsePacket.kt new file mode 100644 index 0000000..b7e808d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DataDigestSyncResponsePacket.kt @@ -0,0 +1,36 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class DataDigestSyncResponsePacket( + val count: Int, + val entriesData: ByteArray, +) { + override fun equals(other: Any?): Boolean = + other is DataDigestSyncResponsePacket && + count == other.count && + entriesData.contentEquals(other.entriesData) + + override fun hashCode(): Int = count * 31 + entriesData.contentHashCode() +} + +private val DigestEntriesBytes: Codec = + object : Codec { + 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 DataDigestSyncResponsePacketCodec : PacketCodec() { + override fun CodecScope.body(): DataDigestSyncResponsePacket { + val count = field(U8) { it.count } + val entriesData = field(DigestEntriesBytes) { it.entriesData } + return DataDigestSyncResponsePacket(count, entriesData) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DialogActionPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DialogActionPacket.kt new file mode 100644 index 0000000..f5a50d6 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DialogActionPacket.kt @@ -0,0 +1,152 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +sealed class DialogMessageArg + +object NullMessageArg : DialogMessageArg() + +data class CreatureDataArg(val value: Int, val args: List) : DialogMessageArg() + +data class CreatureMovesArg(val team: Byte, val moveIds: List) : DialogMessageArg() { + override fun equals(other: Any?): Boolean = + other is CreatureMovesArg && team == other.team && moveIds == other.moveIds + + override fun hashCode(): Int = team * 31 + moveIds.hashCode() +} + +data class MoveAnimationArg(val sourceSlot: Byte, val targetSlot: Byte, val moveId: Short) : + DialogMessageArg() + +data class TextCreatureArg( + val slot: Byte, + val statusId: Byte, + val value1: Short, + val value2: Short, +) : DialogMessageArg() + +private val DialogMessageArgCodec: Codec = + object : Codec { + override fun read(buf: ReadBuffer): DialogMessageArg = + when (val tag = buf.readByte().toInt()) { + -1 -> NullMessageArg + 0 -> { + val value = S32LE.read(buf) + val count = U8.read(buf) + CreatureDataArg(value, List(count) { read(buf) }) + } + + 1 -> { + val team = buf.readByte() + val count = U8.read(buf) + CreatureMovesArg(team, List(count) { S16LE.read(buf) }) + } + + 2 -> { + val moveId = S16LE.read(buf) + MoveAnimationArg(buf.readByte(), buf.readByte(), moveId) + } + + 3 -> TextCreatureArg(buf.readByte(), buf.readByte(), S16LE.read(buf), S16LE.read(buf)) + else -> throw MalformedPacketException("unknown dialog message arg tag $tag") + } + + override fun write(buf: WriteBuffer, value: DialogMessageArg) { + when (value) { + is NullMessageArg -> buf.writeByte((-1).toByte()) + is CreatureDataArg -> { + buf.writeByte(0) + S32LE.write(buf, value.value) + U8.write(buf, value.args.size) + value.args.forEach { write(buf, it) } + } + + is CreatureMovesArg -> { + buf.writeByte(1) + buf.writeByte(value.team) + U8.write(buf, value.moveIds.size) + value.moveIds.forEach { S16LE.write(buf, it) } + } + + is MoveAnimationArg -> { + buf.writeByte(2) + S16LE.write(buf, value.moveId) + buf.writeByte(value.sourceSlot) + buf.writeByte(value.targetSlot) + } + + is TextCreatureArg -> { + buf.writeByte(3) + buf.writeByte(value.slot) + buf.writeByte(value.statusId) + S16LE.write(buf, value.value1) + S16LE.write(buf, value.value2) + } + } + } + } + +private val DialogActionDetail: Codec = + object : Codec { + 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) + } + } + +data class DialogActionPacket( + val flags: Byte, + val actionType: Byte, + val textId: Int, + val entityId: Long, + val contextValue: Int, + val messageArgs: List, + val detail: ByteArray, +) { + override fun equals(other: Any?): Boolean = + other is DialogActionPacket && + flags == other.flags && + actionType == other.actionType && + textId == other.textId && + entityId == other.entityId && + contextValue == other.contextValue && + messageArgs == other.messageArgs && + detail.contentEquals(other.detail) + + override fun hashCode(): Int { + var r = flags.toInt() + r = r * 31 + actionType + r = r * 31 + textId + r = r * 31 + entityId.hashCode() + r = r * 31 + contextValue + r = r * 31 + messageArgs.hashCode() + r = r * 31 + detail.contentHashCode() + return r + } +} + +object DialogActionPacketCodec : PacketCodec() { + override fun CodecScope.body(): DialogActionPacket { + val flags = field(S8) { it.flags } + val actionType = field(S8) { it.actionType } + val textId = field(S32LE) { it.textId } + val entityId = field(S64LE) { it.entityId } + val contextValue = field(S32LE) { it.contextValue } + val messageArgs = field(DialogMessageArgCodec.listPrefixed(U8)) { it.messageArgs } + val detail = field(DialogActionDetail) { it.detail } + return DialogActionPacket( + flags = flags, + actionType = actionType, + textId = textId, + entityId = entityId, + contextValue = contextValue, + messageArgs = messageArgs, + detail = detail, + ) + } +} \ No newline at end of file diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DialogChoicePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DialogChoicePacket.kt index b3ef395..c660907 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DialogChoicePacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DialogChoicePacket.kt @@ -8,9 +8,9 @@ import de.fiereu.bytecodec.U8 data class DialogChoicePacket(val unk1: Int, val unk2: Int) object DialogChoicePacketCodec : PacketCodec() { - override fun CodecScope.body(): DialogChoicePacket { - val unk1 = field(U8) { it.unk1 } - val unk2 = field(U16LE) { it.unk2 } - return DialogChoicePacket(unk1, unk2) - } + override fun CodecScope.body(): DialogChoicePacket { + val unk1 = field(U8) { it.unk1 } + val unk2 = field(U16LE) { it.unk2 } + return DialogChoicePacket(unk1, unk2) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DialogDataPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DialogDataPacket.kt index 8c5f039..2ff8581 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DialogDataPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DialogDataPacket.kt @@ -1,12 +1,6 @@ package de.fiereu.openmmo.net.game.packets -import de.fiereu.bytecodec.Codec -import de.fiereu.bytecodec.CodecScope -import de.fiereu.bytecodec.PacketCodec -import de.fiereu.bytecodec.ReadBuffer -import de.fiereu.bytecodec.S64LE -import de.fiereu.bytecodec.U8 -import de.fiereu.bytecodec.WriteBuffer +import de.fiereu.bytecodec.* data class DialogDataPacket( val entityId: Long, @@ -14,41 +8,41 @@ data class DialogDataPacket( val type: Int, val data: ByteArray, ) { - override fun equals(other: Any?): Boolean = - other is DialogDataPacket && - entityId == other.entityId && - unk1 == other.unk1 && - type == other.type && - data.contentEquals(other.data) + override fun equals(other: Any?): Boolean = + other is DialogDataPacket && + entityId == other.entityId && + unk1 == other.unk1 && + type == other.type && + data.contentEquals(other.data) - override fun hashCode(): Int { - var result = entityId.hashCode() - result = 31 * result + unk1 - result = 31 * result + type - result = 31 * result + data.contentHashCode() - return result - } + override fun hashCode(): Int { + var result = entityId.hashCode() + result = 31 * result + unk1 + result = 31 * result + type + result = 31 * result + data.contentHashCode() + return result + } } -private object RemainingBytes : Codec { - override fun read(buf: ReadBuffer): ByteArray { - val n = buf.remaining() - val arr = ByteArray(n) - if (n > 0) buf.readBytes(arr) - return arr - } +object RemainingBytes : Codec { + override fun read(buf: ReadBuffer): ByteArray { + val n = buf.remaining() + val arr = ByteArray(n) + if (n > 0) buf.readBytes(arr) + return arr + } - override fun write(buf: WriteBuffer, value: ByteArray) { - if (value.isNotEmpty()) buf.writeBytes(value) - } + override fun write(buf: WriteBuffer, value: ByteArray) { + if (value.isNotEmpty()) buf.writeBytes(value) + } } object DialogDataPacketCodec : PacketCodec() { - override fun CodecScope.body(): DialogDataPacket { - val entityId = field(S64LE) { it.entityId } - val unk1 = field(U8) { it.unk1 } - val type = field(U8) { it.type } - val data = field(RemainingBytes) { it.data } - return DialogDataPacket(entityId, unk1, type, data) - } + override fun CodecScope.body(): DialogDataPacket { + val entityId = field(S64LE) { it.entityId } + val unk1 = field(U8) { it.unk1 } + val type = field(U8) { it.type } + val data = field(RemainingBytes) { it.data } + return DialogDataPacket(entityId, unk1, type, data) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DialogResponsePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DialogResponsePacket.kt new file mode 100644 index 0000000..c92ae41 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DialogResponsePacket.kt @@ -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 DialogResponsePacket( + val accepted: Boolean, + val dialogActionId: Short, +) + +object DialogResponsePacketCodec : PacketCodec() { + override fun CodecScope.body(): DialogResponsePacket { + val accepted = field(Bool) { it.accepted } + val dialogActionId = field(S16LE) { it.dialogActionId } + return DialogResponsePacket(accepted, dialogActionId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DisconnectNoticePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DisconnectNoticePacket.kt new file mode 100644 index 0000000..03e8fb4 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DisconnectNoticePacket.kt @@ -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.S8 +import de.fiereu.bytecodec.U8 + +data class DisconnectNoticePacket( + val buildInfo: Byte?, + val reasonMode: Byte?, + val forced: Boolean, +) + +object DisconnectNoticePacketCodec : PacketCodec() { + override fun CodecScope.body(): DisconnectNoticePacket { + val hasBuildInfo = field(U8) { if (it.buildInfo != null) 1 else 0 } == 1 + val buildInfo = if (hasBuildInfo) field(S8) { it.buildInfo!! } else null + val hasReasonMode = field(U8) { if (it.reasonMode != null) 1 else 0 } == 1 + val reasonMode = if (hasReasonMode) field(S8) { it.reasonMode!! } else null + val forced = field(U8) { if (it.forced) 1 else 0 } == 1 + return DisconnectNoticePacket(buildInfo, reasonMode, forced) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DuelChallengePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DuelChallengePacket.kt new file mode 100644 index 0000000..a998f13 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DuelChallengePacket.kt @@ -0,0 +1,84 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class DuelItemRestriction( + val typeId: Byte, + val extra: Byte?, +) + +data class DuelChallengePacket( + val targetPlayerName: String, + val battleTypeId: Byte, + val timed: Boolean, + val battleFormat: Byte, + val typeRestriction: Byte, + val natureRestriction: Byte, + val allowedFormat: Byte, + val itemLevelCap: Byte?, + val natureCap: Byte?, + val items: List?, + val tier: Byte?, +) + +private val DuelItemRestrictionCodec: Codec = + object : Codec { + override fun read(buf: ReadBuffer): DuelItemRestriction { + val typeId = S8.read(buf) + return DuelItemRestriction(typeId, null) + } + + override fun write(buf: WriteBuffer, value: DuelItemRestriction) { + S8.write(buf, value.typeId) + if (value.extra != null) S8.write(buf, value.extra) + } + } + +object DuelChallengePacketCodec : PacketCodec() { + override fun CodecScope.body(): DuelChallengePacket { + val targetPlayerName = field(Utf16LeNullTerminated) { it.targetPlayerName } + val battleTypeId = field(S8) { it.battleTypeId } + val flags = + field(U8) { v -> + var f = 0 + if (v.timed) f = f or 1 + if (v.itemLevelCap != null) f = f or 8 + if (v.natureCap != null) f = f or 16 + if (v.items != null) f = f or 32 + if (v.tier != null) f = f or 64 + f + } + val battleFormat = field(S8) { it.battleFormat } + val typeRestriction = field(S8) { it.typeRestriction } + val natureRestriction = field(S8) { it.natureRestriction } + val allowedFormat = field(S8) { it.allowedFormat } + val timed = flags and 1 != 0 + val itemLevelCap: Byte? = if (flags and 8 != 0) field(S8) { it.itemLevelCap!! } else null + val natureCap: Byte? = if (flags and 16 != 0) field(S8) { it.natureCap!! } else null + val items: List? = + if (flags and 32 != 0) { + val count = field(U8) { it.items!!.size } + val list = ArrayList(count) + var i = 0 + while (i < count) { + list.add(field(DuelItemRestrictionCodec) { v -> v.items!![list.size] }) + i++ + } + list + } else null + val tier: Byte? = if (flags and 64 != 0) field(S8) { it.tier!! } else null + return DuelChallengePacket( + targetPlayerName = targetPlayerName, + battleTypeId = battleTypeId, + timed = timed, + battleFormat = battleFormat, + typeRestriction = typeRestriction, + natureRestriction = natureRestriction, + allowedFormat = allowedFormat, + itemLevelCap = itemLevelCap, + natureCap = natureCap, + items = items, + tier = tier, + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DuelInviteOutcomePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DuelInviteOutcomePacket.kt new file mode 100644 index 0000000..6e555c3 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DuelInviteOutcomePacket.kt @@ -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 DuelInviteOutcomePacket( + val packed: Byte, +) + +object DuelInviteOutcomePacketCodec : PacketCodec() { + override fun CodecScope.body(): DuelInviteOutcomePacket { + val packed = field(S8) { it.packed } + return DuelInviteOutcomePacket(packed) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DuelInvitePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DuelInvitePacket.kt new file mode 100644 index 0000000..d797ace --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/DuelInvitePacket.kt @@ -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.Utf16LeNullTerminated + +data class DuelInvitePacket( + val flags: Byte, + val requestType: Byte, + val name: String, +) + +object DuelInvitePacketCodec : PacketCodec() { + override fun CodecScope.body(): DuelInvitePacket { + val flags = field(S8) { it.flags } + val requestType = field(S8) { it.requestType } + val name = field(Utf16LeNullTerminated) { it.name } + return DuelInvitePacket(flags, requestType, name) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EggIncubatorSlotsPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EggIncubatorSlotsPacket.kt new file mode 100644 index 0000000..d751dee --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EggIncubatorSlotsPacket.kt @@ -0,0 +1,39 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class EggIncubatorSlot( + val value: Short, +) + +data class EggIncubatorSlotsPacket( + val slots: List, +) + +private object EggIncubatorSlotCodec : PacketCodec() { + override fun CodecScope.body(): EggIncubatorSlot { + field(S64LE) { 0L } + val value = field(S16LE, EggIncubatorSlot::value) + return EggIncubatorSlot(value) + } +} + +private val EggIncubatorSlotListPrefixedU8: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { EggIncubatorSlotCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { EggIncubatorSlotCodec.write(buf, it) } + } + } + +object EggIncubatorSlotsPacketCodec : PacketCodec() { + override fun CodecScope.body(): EggIncubatorSlotsPacket { + val slots = field(EggIncubatorSlotListPrefixedU8, EggIncubatorSlotsPacket::slots) + return EggIncubatorSlotsPacket(slots) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityActionRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityActionRequestPacket.kt new file mode 100644 index 0000000..566920c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityActionRequestPacket.kt @@ -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.S16LE +import de.fiereu.bytecodec.S64LE + +data class EntityActionRequestPacket( + val targetEntityId: Long, + val actionType: Short, + val sourceEntityId: Long, + val entityId: Long, +) + +object EntityActionRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityActionRequestPacket { + val targetEntityId = field(S64LE) { it.targetEntityId } + val actionType = field(S16LE) { it.actionType } + val sourceEntityId = field(S64LE) { it.sourceEntityId } + val entityId = field(S64LE) { it.entityId } + return EntityActionRequestPacket(targetEntityId, actionType, sourceEntityId, entityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityAppearancePatchPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityAppearancePatchPacket.kt new file mode 100644 index 0000000..2136c9c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityAppearancePatchPacket.kt @@ -0,0 +1,70 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class EntityAppearance( + val name: String, + val gender: Byte, + val formId: Int, + val kind: Byte, + val palettePack: Byte, + val slots: List, +) + +private val EntityAppearanceCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): EntityAppearance { + val name = field(Utf16LeNullTerminated) { it.name } + val gender = field(S8) { it.gender } + val formId = field(S32LE) { it.formId } + val kind = field(S8) { it.kind } + val palettePack = field(S8) { it.palettePack } + val slots = field(S16LE.repeat(4)) { it.slots } + return EntityAppearance(name, gender, formId, kind, palettePack, slots) + } + } + +data class EntityCosmetic( + val cosmeticId: Short, + val cosmeticValue: Byte, +) + +data class EntityAppearancePatchPacket( + val entityId: Long, + val spriteId: Short, + val direction: Byte?, + val animation: Short?, + val appearance: EntityAppearance?, + val cosmetics: List?, +) + +object EntityAppearancePatchPacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityAppearancePatchPacket { + val entityId = field(S64LE) { it.entityId } + val spriteId = field(S16LE) { it.spriteId } + val flags = + field(S8) { v -> + ((if (v.direction != null) 1 else 0) or + (if (v.animation != null) 2 else 0) or + (if (v.appearance != null) 4 else 0) or + (if (v.cosmetics != null) 8 else 0)) + .toByte() + } + val flagsInt = flags.toInt() + val direction = if (flagsInt and 1 != 0) field(S8) { it.direction!! } else null + val animation = if (flagsInt and 2 != 0) field(S16LE) { it.animation!! } else null + val appearance = if (flagsInt and 4 != 0) field(EntityAppearanceCodec) { it.appearance!! } else null + val cosmetics = + if (flagsInt and 8 != 0) { + val count = field(S8) { it.cosmetics!!.size.toByte() }.toInt() + (0 until count).map { i -> + val cosmeticId = field(S16LE) { it.cosmetics!![i].cosmeticId } + val cosmeticValue = field(S8) { it.cosmetics!![i].cosmeticValue } + EntityCosmetic(cosmeticId, cosmeticValue) + } + } else null + return EntityAppearancePatchPacket( + entityId, spriteId, direction, animation, appearance, cosmetics + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityAppearanceSyncPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityAppearanceSyncPacket.kt new file mode 100644 index 0000000..61caf42 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityAppearanceSyncPacket.kt @@ -0,0 +1,38 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class EntitySpriteAppearance( + val name: String, + val gender: Byte, + val id: Int, + val kind: Byte, + val palettePack: Byte, + val slots: List, +) + +data class EntityAppearanceSyncPacket( + val entityId: Long, + val appearance: EntitySpriteAppearance, +) + +private val EntitySpriteAppearanceCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): EntitySpriteAppearance { + val name = field(de.fiereu.bytecodec.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 EntitySpriteAppearance(name, gender, id, kind, palettePack, slots) + } + } + +object EntityAppearanceSyncPacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityAppearanceSyncPacket { + val entityId = field(S64LE) { it.entityId } + val appearance = field(EntitySpriteAppearanceCodec) { it.appearance } + return EntityAppearanceSyncPacket(entityId, appearance) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityAttributeChangePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityAttributeChangePacket.kt new file mode 100644 index 0000000..98afe5c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityAttributeChangePacket.kt @@ -0,0 +1,42 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +const val ENTITY_ATTRIBUTE_TYPE_NAME: Int = 0 +const val ENTITY_ATTRIBUTE_TYPE_ITEM: Int = 1 +const val ENTITY_ATTRIBUTE_TYPE_INT_TEXT_A: Int = 2 +const val ENTITY_ATTRIBUTE_TYPE_INT_TEXT_B: Int = 3 + +data class EntityAttributeChangePacket( + val entityId: Long, + val type: Byte, + val text: String?, + val item: Byte?, + val value: Int?, +) + +object EntityAttributeChangePacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityAttributeChangePacket { + val entityId = field(S64LE) { it.entityId } + val type = field(S8) { it.type } + var text: String? = null + var item: Byte? = null + var value: Int? = null + when (type.toInt()) { + ENTITY_ATTRIBUTE_TYPE_NAME -> { + text = field(Utf16LeNullTerminated) { it.text!! } + } + + ENTITY_ATTRIBUTE_TYPE_ITEM -> { + item = field(S8) { it.item!! } + } + + ENTITY_ATTRIBUTE_TYPE_INT_TEXT_A, + ENTITY_ATTRIBUTE_TYPE_INT_TEXT_B -> { + value = field(S32LE) { it.value!! } + text = field(Utf16LeNullTerminated) { it.text!! } + } + } + return EntityAttributeChangePacket(entityId, type, text, item, value) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityChecklistPromptPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityChecklistPromptPacket.kt new file mode 100644 index 0000000..ee90b9b --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityChecklistPromptPacket.kt @@ -0,0 +1,33 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class EntityChecklistItem( + val entityId: Long, + val checked: Boolean, +) + +data class EntityChecklistPromptPacket( + val titleId: Int, + val kind: Byte?, + val items: List?, +) + +private val EntityChecklistItemCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): EntityChecklistItem { + val entityId = field(S64LE) { it.entityId } + val checked = field(U8) { if (it.checked) 1 else 0 } == 1 + return EntityChecklistItem(entityId, checked) + } + } + +object EntityChecklistPromptPacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityChecklistPromptPacket { + val titleId = field(S32LE) { it.titleId } + val kind = if (titleId > 0) field(S8) { it.kind!! } else null + val items = + if (titleId > 0) field(EntityChecklistItemCodec.listPrefixed(U8)) { it.items!! } else null + return EntityChecklistPromptPacket(titleId, kind, items) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityCoordSyncPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityCoordSyncPacket.kt new file mode 100644 index 0000000..9b7573f --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityCoordSyncPacket.kt @@ -0,0 +1,21 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class EntityCoordSyncPacket( + val entityId: Long, + val valueA: Int, + val flag: Boolean, + val valueB: Int, +) + +object EntityCoordSyncPacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityCoordSyncPacket { + val entityId = field(S64LE) { it.entityId } + val valueA = field(S32LE) { it.valueA } + val flag = field(U8) { if (it.flag) 1 else 0 } == 1 + field(S8) { 0 } + val valueB = field(S32LE) { it.valueB } + return EntityCoordSyncPacket(entityId, valueA, flag, valueB) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityDespawnPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityDespawnPacket.kt new file mode 100644 index 0000000..287fcc3 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityDespawnPacket.kt @@ -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.S16LE +import de.fiereu.bytecodec.reserved + +data class EntityDespawnPacket( + val entityId: Short, +) + +object EntityDespawnPacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityDespawnPacket { + reserved(byte = 0) + val entityId = field(S16LE) { it.entityId } + return EntityDespawnPacket(entityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityEmoteBubblePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityEmoteBubblePacket.kt new file mode 100644 index 0000000..2c76337 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityEmoteBubblePacket.kt @@ -0,0 +1,24 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class EntityEmoteBubblePacket( + val entityId: Long, + val icon: Byte, + val param: Short?, +) + +object EntityEmoteBubblePacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityEmoteBubblePacket { + val entityId = field(S64LE) { it.entityId } + val icon = field(S8) { it.icon } + val param = + if (icon != (-1).toByte()) { + val p = field(S16LE) { it.param!! } + field(S8) { 0 } + field(S8) { 0 } + p + } else null + return EntityEmoteBubblePacket(entityId, icon, param) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityFaceTurnPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityFaceTurnPacket.kt new file mode 100644 index 0000000..7d3868f --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityFaceTurnPacket.kt @@ -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 EntityFaceTurnPacket( + val entityId: Long, + val facing: Byte, +) + +object EntityFaceTurnPacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityFaceTurnPacket { + val entityId = field(S64LE) { it.entityId } + val facing = field(S8) { it.facing } + return EntityFaceTurnPacket(entityId, facing) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityFramesUpdatePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityFramesUpdatePacket.kt new file mode 100644 index 0000000..fe5eea0 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityFramesUpdatePacket.kt @@ -0,0 +1,38 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class EntityFramesUpdatePacket( + val entityId: Long, + val frames: GroupListFrameSet, +) + +private val FramesFrameCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): GroupListFrame { + val typeId = field(S16LE) { it.typeId } + val packed = field(S16LE) { it.packed } + val byteA = field(S8) { it.byteA } + val byteB = field(S8) { it.byteB } + val packed2 = field(S16LE) { it.packed2 } + return GroupListFrame(typeId, packed, byteA, byteB, packed2) + } + } + +private val FramesSetCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): GroupListFrameSet { + val count = field(U8) { it.frames.size } + val listType = if (count >= 1) field(S8) { it.listType ?: 0 } else null + val frames = (0 until count).map { i -> field(FramesFrameCodec) { it.frames[i] } } + return GroupListFrameSet(listType, frames) + } + } + +object EntityFramesUpdatePacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityFramesUpdatePacket { + val entityId = field(S64LE) { it.entityId } + val frames = field(FramesSetCodec) { it.frames } + return EntityFramesUpdatePacket(entityId, frames) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityGroupMemberAddPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityGroupMemberAddPacket.kt new file mode 100644 index 0000000..763a591 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityGroupMemberAddPacket.kt @@ -0,0 +1,59 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class EntityGroupMemberAddPacket( + val member: EntityGroupMember, +) + +private val AddAppearanceCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): EntityAppearanceInfo { + val name = field(Utf16LeNullTerminated) { it.name } + val gender = field(S8) { it.gender } + val formId = field(S32LE) { it.formId } + val kind = field(S8) { it.kind } + val palettePack = field(S8) { it.palettePack } + val slots = field(S16LE.repeat(4)) { it.slots } + return EntityAppearanceInfo(name, gender, formId, kind, palettePack, slots) + } + } + +private val AddFrameCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): GroupListFrame { + val typeId = field(S16LE) { it.typeId } + val packed = field(S16LE) { it.packed } + val byteA = field(S8) { it.byteA } + val byteB = field(S8) { it.byteB } + val packed2 = field(S16LE) { it.packed2 } + return GroupListFrame(typeId, packed, byteA, byteB, packed2) + } + } + +private val AddFrameSetCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): GroupListFrameSet { + val count = field(U8) { it.frames.size } + val listType = if (count >= 1) field(S8) { it.listType ?: 0 } else null + val frames = (0 until count).map { i -> field(AddFrameCodec) { it.frames[i] } } + return GroupListFrameSet(listType, frames) + } + } + +private val AddMemberCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): EntityGroupMember { + val entityId = field(S64LE) { it.entityId } + val appearance = field(AddAppearanceCodec) { it.appearance } + val frames = field(AddFrameSetCodec) { it.frames } + return EntityGroupMember(entityId, appearance, frames) + } + } + +object EntityGroupMemberAddPacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityGroupMemberAddPacket { + val member = field(AddMemberCodec) { it.member } + return EntityGroupMemberAddPacket(member) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityGroupMemberRemovePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityGroupMemberRemovePacket.kt new file mode 100644 index 0000000..4cdf912 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityGroupMemberRemovePacket.kt @@ -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 EntityGroupMemberRemovePacket( + val removedId: Long, + val leaderId: Long, +) + +object EntityGroupMemberRemovePacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityGroupMemberRemovePacket { + val removedId = field(S64LE) { it.removedId } + val leaderId = field(S64LE) { it.leaderId } + return EntityGroupMemberRemovePacket(removedId, leaderId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityGroupSnapshotPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityGroupSnapshotPacket.kt new file mode 100644 index 0000000..875d311 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityGroupSnapshotPacket.kt @@ -0,0 +1,92 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class EntityAppearanceInfo( + val name: String, + val gender: Byte, + val formId: Int, + val kind: Byte, + val palettePack: Byte, + val slots: List, +) + +data class GroupListFrame( + val typeId: Short, + val packed: Short, + val byteA: Byte, + val byteB: Byte, + val packed2: Short, +) + +data class GroupListFrameSet( + val listType: Byte?, + val frames: List, +) + +data class EntityGroupMember( + val entityId: Long, + val appearance: EntityAppearanceInfo, + val frames: GroupListFrameSet, +) + +data class EntityGroupSnapshotPacket( + val present: Boolean, + val leaderId: Long?, + val members: List?, +) + +private val EntityAppearanceInfoCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): EntityAppearanceInfo { + val name = field(Utf16LeNullTerminated) { it.name } + val gender = field(S8) { it.gender } + val formId = field(S32LE) { it.formId } + val kind = field(S8) { it.kind } + val palettePack = field(S8) { it.palettePack } + val slots = field(S16LE.repeat(4)) { it.slots } + return EntityAppearanceInfo(name, gender, formId, kind, palettePack, slots) + } + } + +private val GroupListFrameCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): GroupListFrame { + val typeId = field(S16LE) { it.typeId } + val packed = field(S16LE) { it.packed } + val byteA = field(S8) { it.byteA } + val byteB = field(S8) { it.byteB } + val packed2 = field(S16LE) { it.packed2 } + return GroupListFrame(typeId, packed, byteA, byteB, packed2) + } + } + +private val GroupListFrameSetCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): GroupListFrameSet { + val count = field(U8) { it.frames.size } + val listType = if (count >= 1) field(S8) { it.listType ?: 0 } else null + val frames = (0 until count).map { i -> field(GroupListFrameCodec) { it.frames[i] } } + return GroupListFrameSet(listType, frames) + } + } + +private val EntityGroupMemberCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): EntityGroupMember { + val entityId = field(S64LE) { it.entityId } + val appearance = field(EntityAppearanceInfoCodec) { it.appearance } + val frames = field(GroupListFrameSetCodec) { it.frames } + return EntityGroupMember(entityId, appearance, frames) + } + } + +object EntityGroupSnapshotPacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityGroupSnapshotPacket { + val present = field(U8) { if (it.present) 1 else 0 } == 1 + val leaderId = if (present) field(S64LE) { it.leaderId!! } else null + val members = + if (present) field(EntityGroupMemberCodec.listPrefixed(U8)) { it.members!! } else null + return EntityGroupSnapshotPacket(present, leaderId, members) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityInteractPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityInteractPacket.kt index f658f4e..f214b67 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityInteractPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityInteractPacket.kt @@ -7,9 +7,9 @@ import de.fiereu.bytecodec.S64LE data class EntityInteractPacket(val entityId: Long, val token: Long) object EntityInteractPacketCodec : PacketCodec() { - override fun CodecScope.body(): EntityInteractPacket { - val entityId = field(S64LE) { it.entityId } - val token = field(S64LE) { it.token } - return EntityInteractPacket(entityId, token) - } + override fun CodecScope.body(): EntityInteractPacket { + val entityId = field(S64LE) { it.entityId } + val token = field(S64LE) { it.token } + return EntityInteractPacket(entityId, token) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityInteractRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityInteractRequestPacket.kt new file mode 100644 index 0000000..aa0dd55 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityInteractRequestPacket.kt @@ -0,0 +1,36 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class EntityInteractRequestPacket( + val interactionType: Byte, + val primaryEntityId: Long, + val primaryX: Short, + val primaryY: Short, + val secondaryEntityId: Long?, + val secondaryX: Short?, + val secondaryY: Short?, +) + +object EntityInteractRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityInteractRequestPacket { + val interactionType = field(S8) { it.interactionType } + val hasSecondEntity = field(Bool) { it.secondaryEntityId != null } + val primaryEntityId = field(S64LE) { it.primaryEntityId } + val primaryX = field(S16LE) { it.primaryX } + val primaryY = field(S16LE) { it.primaryY } + val secondaryEntityId: Long? = + if (hasSecondEntity) field(S64LE) { it.secondaryEntityId!! } else null + val secondaryX: Short? = if (hasSecondEntity) field(S16LE) { it.secondaryX!! } else null + val secondaryY: Short? = if (hasSecondEntity) field(S16LE) { it.secondaryY!! } else null + return EntityInteractRequestPacket( + interactionType, + primaryEntityId, + primaryX, + primaryY, + secondaryEntityId, + secondaryX, + secondaryY, + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityInteractionFlagPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityInteractionFlagPacket.kt new file mode 100644 index 0000000..18f9050 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityInteractionFlagPacket.kt @@ -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 EntityInteractionFlagPacket( + val entityId: Long, + val flag: Byte, +) + +object EntityInteractionFlagPacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityInteractionFlagPacket { + val entityId = field(S64LE) { it.entityId } + val flag = field(S8) { it.flag } + return EntityInteractionFlagPacket(entityId, flag) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityLeavePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityLeavePacket.kt index 1489228..1e71d7a 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityLeavePacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityLeavePacket.kt @@ -7,8 +7,8 @@ import de.fiereu.bytecodec.S64BE data class EntityLeavePacket(val entityId: Long) object EntityLeavePacketCodec : PacketCodec() { - override fun CodecScope.body(): EntityLeavePacket { - val entityId = field(S64BE) { it.entityId } - return EntityLeavePacket(entityId) - } + override fun CodecScope.body(): EntityLeavePacket { + val entityId = field(S64BE) { it.entityId } + return EntityLeavePacket(entityId) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityMovePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityMovePacket.kt index 8c2b80c..c6d488b 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityMovePacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityMovePacket.kt @@ -1,10 +1,6 @@ package de.fiereu.openmmo.net.game.packets -import de.fiereu.bytecodec.CodecScope -import de.fiereu.bytecodec.PacketCodec -import de.fiereu.bytecodec.S64BE -import de.fiereu.bytecodec.S8 -import de.fiereu.bytecodec.enumByOrdinalByte +import de.fiereu.bytecodec.* import de.fiereu.openmmo.common.enums.Direction data class EntityMovePacket( @@ -18,16 +14,16 @@ data class EntityMovePacket( ) object EntityMovePacketCodec : PacketCodec() { - private val DirectionCodec = enumByOrdinalByte() + private val DirectionCodec = enumByOrdinalByte() - override fun CodecScope.body(): EntityMovePacket { - val entityId = field(S64BE) { it.entityId } - val marker = field(S8) { it.marker } - val subtype = field(S8) { it.subtype } - val seq = field(S8) { it.seq } - val x = field(S8) { it.x } - val y = field(S8) { it.y } - val direction = field(DirectionCodec) { it.direction } - return EntityMovePacket(entityId, marker, subtype, seq, x, y, direction) - } + override fun CodecScope.body(): EntityMovePacket { + val entityId = field(S64BE) { it.entityId } + val marker = field(S8) { it.marker } + val subtype = field(S8) { it.subtype } + val seq = field(S8) { it.seq } + val x = field(S8) { it.x } + val y = field(S8) { it.y } + val direction = field(DirectionCodec) { it.direction } + return EntityMovePacket(entityId, marker, subtype, seq, x, y, direction) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityMovePpPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityMovePpPacket.kt new file mode 100644 index 0000000..45fb3fc --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityMovePpPacket.kt @@ -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 EntityMovePpPacket( + val entityId: Long, + val moveSlot: Byte, + val ppValue: Byte, +) + +object EntityMovePpPacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityMovePpPacket { + val entityId = field(S64LE) { it.entityId } + val moveSlot = field(S8) { it.moveSlot } + val ppValue = field(S8) { it.ppValue } + return EntityMovePpPacket(entityId, moveSlot, ppValue) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityNameChoicesPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityNameChoicesPacket.kt new file mode 100644 index 0000000..bb51843 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityNameChoicesPacket.kt @@ -0,0 +1,29 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class NamedEntityChoice(val entityId: Long, val name: String) + +data class EntityNameChoicesPacket( + val kind: Byte, + val flag: Boolean, + val choices: List, +) + +private val NamedEntityChoiceCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): NamedEntityChoice { + val entityId = field(S64LE) { it.entityId } + val name = field(Utf16LeNullTerminated) { it.name } + return NamedEntityChoice(entityId, name) + } + } + +object EntityNameChoicesPacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityNameChoicesPacket { + val kind = field(S8) { it.kind } + val flag = field(U8) { if (it.flag) 1 else 0 } == 1 + val choices = field(NamedEntityChoiceCodec.listPrefixed(U8)) { it.choices } + return EntityNameChoicesPacket(kind, flag, choices) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityNameVisibilityPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityNameVisibilityPacket.kt new file mode 100644 index 0000000..c5f23ae --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityNameVisibilityPacket.kt @@ -0,0 +1,23 @@ +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 EntityNameVisibilityPacket( + val entityId: Long, + val hidden: Boolean, + val gmMode: Boolean, + val marked: Boolean, +) + +object EntityNameVisibilityPacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityNameVisibilityPacket { + val entityId = field(S64LE) { it.entityId } + val hidden = field(Bool) { it.hidden } + val gmMode = field(Bool) { it.gmMode } + val marked = field(Bool) { it.marked } + return EntityNameVisibilityPacket(entityId, hidden, gmMode, marked) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityPanelSelectPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityPanelSelectPacket.kt new file mode 100644 index 0000000..dea6a42 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityPanelSelectPacket.kt @@ -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 EntityPanelSelectPacket( + val entityId: Long, +) + +object EntityPanelSelectPacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityPanelSelectPacket { + val entityId = field(S64LE) { it.entityId } + return EntityPanelSelectPacket(entityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityPresencePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityPresencePacket.kt new file mode 100644 index 0000000..4c0b72d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityPresencePacket.kt @@ -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 EntityPresencePacket( + val entityId: Long, + val status: Byte, +) + +object EntityPresencePacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityPresencePacket { + val entityId = field(S64LE) { it.entityId } + val status = field(S8) { it.status } + return EntityPresencePacket(entityId, status) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityRenamePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityRenamePacket.kt new file mode 100644 index 0000000..76fb83a --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityRenamePacket.kt @@ -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.Utf16LeNullTerminated + +data class EntityRenamePacket( + val entityId: Long, + val name: String, +) + +object EntityRenamePacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityRenamePacket { + val entityId = field(S64LE) { it.entityId } + val name = field(Utf16LeNullTerminated) { it.name } + return EntityRenamePacket(entityId, name) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntitySpriteChangePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntitySpriteChangePacket.kt new file mode 100644 index 0000000..e695261 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntitySpriteChangePacket.kt @@ -0,0 +1,22 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* +import de.fiereu.openmmo.net.game.codecs.DefaultSkinSetCodec +import de.fiereu.openmmo.net.game.codecs.SkinSet + +data class EntitySpriteChangePacket( + val entityId: Long, + val facingFront: Boolean, + val appearance: SkinSet, + val direction: Byte, +) + +object EntitySpriteChangePacketCodec : PacketCodec() { + override fun CodecScope.body(): EntitySpriteChangePacket { + val entityId = field(S64LE) { it.entityId } + val facingFront = field(Bool) { it.facingFront } + val appearance = field(DefaultSkinSetCodec) { it.appearance } + val direction = field(S8) { it.direction } + return EntitySpriteChangePacket(entityId, facingFront, appearance, direction) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityTitleTagPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityTitleTagPacket.kt new file mode 100644 index 0000000..9e0d108 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EntityTitleTagPacket.kt @@ -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.Utf16LeNullTerminated + +data class EntityTitleTagPacket( + val entityId: Long, + val nameTag: String, +) + +object EntityTitleTagPacketCodec : PacketCodec() { + override fun CodecScope.body(): EntityTitleTagPacket { + val entityId = field(S64LE) { it.entityId } + val nameTag = field(Utf16LeNullTerminated) { it.nameTag } + return EntityTitleTagPacket(entityId, nameTag) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EventOverlayStatePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EventOverlayStatePacket.kt new file mode 100644 index 0000000..8f868b7 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EventOverlayStatePacket.kt @@ -0,0 +1,133 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +private const val GRID_OVERLAY_TYPE: Int = 1 + +data class OverlayGridPoint(val x: Short, val y: Short) + +data class OverlayRegion( + val regionId: Short, + val secondary: Short, + val gridPoints: List?, + val value: Int?, +) + +data class OverlayHole(val regionId: Short, val secondary: Short) + +data class EventOverlayStatePacket( + val active: Boolean, + val overlayType: Byte, + val flagBits: Byte, + val ignoredEnum: Byte, + val timeRemaining: Int?, + val valueA: Int?, + val valueB: Int?, + val anchorEntityId: Long?, + val regions: List, + val holes: List, +) + +object EventOverlayStatePacketCodec : PacketCodec() { + override fun CodecScope.body(): EventOverlayStatePacket { + val codec = EventOverlayStateCodec + return field(codec) { it } + } +} + +private val EventOverlayStateCodec: Codec = + object : Codec { + override fun read(buf: ReadBuffer): EventOverlayStatePacket { + val typeByte = S8.read(buf) + val active = typeByte.toInt() != -1 + if (!active) { + return EventOverlayStatePacket( + active = false, + overlayType = typeByte, + flagBits = 0, + ignoredEnum = 0, + timeRemaining = null, + valueA = null, + valueB = null, + anchorEntityId = null, + regions = emptyList(), + holes = emptyList(), + ) + } + val grid = typeByte.toInt() == GRID_OVERLAY_TYPE + val flagBits = S8.read(buf) + val fb = flagBits.toInt() + val ignoredEnum = S8.read(buf) + val timeRemaining = if (fb and 32 != 0) S32LE.read(buf) else null + val valueA = if (fb and 8 != 0) S32LE.read(buf) else null + val valueB = if (fb and 16 != 0) S32LE.read(buf) else null + val anchorEntityId = if (fb and 64 != 0) S64LE.read(buf) else null + val regionCount = U16LE.read(buf) + val regions = ArrayList(regionCount) + repeat(regionCount) { + val regionId = S16LE.read(buf) + val secondary = S16LE.read(buf) + if (grid) { + val n = U8.read(buf) + val points = ArrayList(n) + repeat(n) { points.add(OverlayGridPoint(S16LE.read(buf), S16LE.read(buf))) } + regions.add(OverlayRegion(regionId, secondary, points, null)) + } else { + val v = S32LE.read(buf) + regions.add(OverlayRegion(regionId, secondary, null, v)) + } + } + val holes = ArrayList() + if (grid && fb and 4 != 0) { + val holeCount = U16LE.read(buf) + repeat(holeCount) { holes.add(OverlayHole(S16LE.read(buf), S16LE.read(buf))) } + } + return EventOverlayStatePacket( + active = true, + overlayType = typeByte, + flagBits = flagBits, + ignoredEnum = ignoredEnum, + timeRemaining = timeRemaining, + valueA = valueA, + valueB = valueB, + anchorEntityId = anchorEntityId, + regions = regions, + holes = holes, + ) + } + + override fun write(buf: WriteBuffer, value: EventOverlayStatePacket) { + S8.write(buf, value.overlayType) + if (!value.active) return + val grid = value.overlayType.toInt() == GRID_OVERLAY_TYPE + S8.write(buf, value.flagBits) + val fb = value.flagBits.toInt() + S8.write(buf, value.ignoredEnum) + if (fb and 32 != 0) S32LE.write(buf, value.timeRemaining!!) + if (fb and 8 != 0) S32LE.write(buf, value.valueA!!) + if (fb and 16 != 0) S32LE.write(buf, value.valueB!!) + if (fb and 64 != 0) S64LE.write(buf, value.anchorEntityId!!) + U16LE.write(buf, value.regions.size) + for (r in value.regions) { + S16LE.write(buf, r.regionId) + S16LE.write(buf, r.secondary) + if (grid) { + val points = r.gridPoints ?: throw MalformedPacketException("grid overlay region missing points") + U8.write(buf, points.size) + for (p in points) { + S16LE.write(buf, p.x) + S16LE.write(buf, p.y) + } + } else { + S32LE.write(buf, r.value!!) + } + } + if (grid && fb and 4 != 0) { + U16LE.write(buf, value.holes.size) + for (h in value.holes) { + S16LE.write(buf, h.regionId) + S16LE.write(buf, h.secondary) + } + } + } + } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EvolutionPromptResponsePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EvolutionPromptResponsePacket.kt new file mode 100644 index 0000000..2672a09 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/EvolutionPromptResponsePacket.kt @@ -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.S64LE + +data class EvolutionPromptResponsePacket(val pokemonEntityId: Long, val accepted: Boolean) + +object EvolutionPromptResponsePacketCodec : PacketCodec() { + override fun CodecScope.body(): EvolutionPromptResponsePacket { + val pokemonEntityId = field(S64LE) { it.pokemonEntityId } + val accepted = field(Bool) { it.accepted } + return EvolutionPromptResponsePacket(pokemonEntityId, accepted) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ExchangeItemRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ExchangeItemRequestPacket.kt new file mode 100644 index 0000000..2230e24 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ExchangeItemRequestPacket.kt @@ -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 ExchangeItemRequestPacket( + val itemEntityRef: Short, + val quantity: Short, + val exchangeTypeIndex: Byte, +) + +object ExchangeItemRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): ExchangeItemRequestPacket { + val itemEntityRef = field(S16LE) { it.itemEntityRef } + val quantity = field(S16LE) { it.quantity } + val exchangeTypeIndex = field(S8) { it.exchangeTypeIndex } + return ExchangeItemRequestPacket(itemEntityRef, quantity, exchangeTypeIndex) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FaceDirectionPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FaceDirectionPacket.kt index 0c262b9..b3bf3e0 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FaceDirectionPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FaceDirectionPacket.kt @@ -8,10 +8,10 @@ import de.fiereu.openmmo.common.enums.Direction data class FaceDirectionPacket(val direction: Direction) object FaceDirectionPacketCodec : PacketCodec() { - private val DirectionCodec = enumByOrdinalByte() + private val DirectionCodec = enumByOrdinalByte() - override fun CodecScope.body(): FaceDirectionPacket { - val direction = field(DirectionCodec) { it.direction } - return FaceDirectionPacket(direction) - } + override fun CodecScope.body(): FaceDirectionPacket { + val direction = field(DirectionCodec) { it.direction } + return FaceDirectionPacket(direction) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FieldMapBattleSlotMarkerPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FieldMapBattleSlotMarkerPacket.kt new file mode 100644 index 0000000..bafef2e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FieldMapBattleSlotMarkerPacket.kt @@ -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 FieldMapBattleSlotMarkerPacket( + val slot: Byte, + val markerType: Byte, + val value: Short, +) + +object FieldMapBattleSlotMarkerPacketCodec : PacketCodec() { + override fun CodecScope.body(): FieldMapBattleSlotMarkerPacket { + val slot = field(S8) { it.slot } + val markerType = field(S8) { it.markerType } + val value = field(S16LE) { it.value } + return FieldMapBattleSlotMarkerPacket(slot, markerType, value) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FieldMapBattleSlotTileMapPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FieldMapBattleSlotTileMapPacket.kt new file mode 100644 index 0000000..085b24d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FieldMapBattleSlotTileMapPacket.kt @@ -0,0 +1,30 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class BattleSlotTile( + val slot: Byte, + val value: Byte, +) + +data class FieldMapBattleSlotTileMapPacket( + val groupId: Short, + val slotTiles: List?, +) + +object FieldMapBattleSlotTileMapPacketCodec : PacketCodec() { + override fun CodecScope.body(): FieldMapBattleSlotTileMapPacket { + val groupId = field(S16LE) { it.groupId } + val present = field(U8) { if (it.slotTiles != null) 1 else 0 } == 1 + val slotTiles = + if (present) { + val count = field(S8) { it.slotTiles!!.size.toByte() }.toInt() + (0 until count).map { i -> + val slot = field(S8) { it.slotTiles!![i].slot } + val value = field(S8) { it.slotTiles!![i].value } + BattleSlotTile(slot, value) + } + } else null + return FieldMapBattleSlotTileMapPacket(groupId, slotTiles) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FieldMapTilePaletteApplyPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FieldMapTilePaletteApplyPacket.kt new file mode 100644 index 0000000..d051122 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FieldMapTilePaletteApplyPacket.kt @@ -0,0 +1,35 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class FieldMapTilePaletteApplyPacket( + val layer: Byte, + val keys: ByteArray, + val values: ByteArray, + val tiles: List, +) { + override fun equals(other: Any?): Boolean = + other is FieldMapTilePaletteApplyPacket && + layer == other.layer && + keys.contentEquals(other.keys) && + values.contentEquals(other.values) && + tiles == other.tiles + + override fun hashCode(): Int { + var r = layer.toInt() + r = r * 31 + keys.contentHashCode() + r = r * 31 + values.contentHashCode() + r = r * 31 + tiles.hashCode() + return r + } +} + +object FieldMapTilePaletteApplyPacketCodec : PacketCodec() { + override fun CodecScope.body(): FieldMapTilePaletteApplyPacket { + val layer = field(S8) { it.layer } + val keys = field(bytesPrefixed(U8)) { it.keys } + val values = field(bytesPrefixed(U8)) { it.values } + val tiles = field(S16LE.listPrefixed(U8)) { it.tiles } + return FieldMapTilePaletteApplyPacket(layer, keys, values, tiles) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FollowerAdvancePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FollowerAdvancePacket.kt new file mode 100644 index 0000000..7c6fec4 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FollowerAdvancePacket.kt @@ -0,0 +1,20 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class FollowerAdvancePacket( + val entityId: Long, + val step: Short, + val direction: Byte, + val flag: Boolean, +) + +object FollowerAdvancePacketCodec : PacketCodec() { + override fun CodecScope.body(): FollowerAdvancePacket { + val entityId = field(S64LE) { it.entityId } + val step = field(S16LE) { it.step } + val direction = field(S8) { it.direction } + val flag = field(Bool) { it.flag } + return FollowerAdvancePacket(entityId, step, direction, flag) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FriendProfileRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FriendProfileRequestPacket.kt new file mode 100644 index 0000000..89c11ea --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FriendProfileRequestPacket.kt @@ -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 FriendProfileRequestPacket(val targetEntityId: Long) + +object FriendProfileRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): FriendProfileRequestPacket { + val targetEntityId = field(S64LE) { it.targetEntityId } + return FriendProfileRequestPacket(targetEntityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FriendRosterDeltaPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FriendRosterDeltaPacket.kt new file mode 100644 index 0000000..ff1ed71 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FriendRosterDeltaPacket.kt @@ -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 FriendRosterDeltaPacket( + val action: Byte, +) + +object FriendRosterDeltaPacketCodec : PacketCodec() { + override fun CodecScope.body(): FriendRosterDeltaPacket { + val action = field(S8) { it.action } + return FriendRosterDeltaPacket(action) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FriendRosterPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FriendRosterPacket.kt new file mode 100644 index 0000000..d15faaa --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/FriendRosterPacket.kt @@ -0,0 +1,30 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class FriendRosterEntry( + val name: String, + val online: Boolean, +) + +data class FriendRosterPacket( + val friends: List, +) + +private val FriendRosterEntryCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): FriendRosterEntry { + field(S64LE) { 0L } + val name = field(Utf16LeNullTerminated) { it.name } + val online = field(Bool) { it.online } + return FriendRosterEntry(name, online) + } + } + +object FriendRosterPacketCodec : PacketCodec() { + override fun CodecScope.body(): FriendRosterPacket { + val count = field(U8) { it.friends.size } + val friends = (0 until count).map { i -> field(FriendRosterEntryCodec) { it.friends[i] } } + return FriendRosterPacket(friends) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GameHandshakeHelloPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GameHandshakeHelloPacket.kt new file mode 100644 index 0000000..8199727 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GameHandshakeHelloPacket.kt @@ -0,0 +1,168 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +sealed class HelloAuthData + +data class ReconnectHelloAuth(val entityId: Long, val sessionToken: ByteArray) : HelloAuthData() { + override fun equals(other: Any?): Boolean = + other is ReconnectHelloAuth && + entityId == other.entityId && + sessionToken.contentEquals(other.sessionToken) + + override fun hashCode(): Int = entityId.hashCode() * 31 + sessionToken.contentHashCode() +} + +data class NewHelloAuth(val userId: Int, val sessionToken: ByteArray) : HelloAuthData() { + override fun equals(other: Any?): Boolean = + other is NewHelloAuth && userId == other.userId && sessionToken.contentEquals(other.sessionToken) + + override fun hashCode(): Int = userId * 31 + sessionToken.contentHashCode() +} + +data class LanguagePackEntry(val name: String, val version: Byte, val kind: Byte) + +data class GraphicsModeEntry(val id: Byte, val name: String) + +data class GameHandshakeHelloPacket( + val authData: HelloAuthData, + val localIp: ByteArray, + val magic: Int, + val clientRevision: Int, + val languageId: Byte, + val chatChannelMask: Short, + val languageFilterMask: Short, + val languagePackMask: Byte, + val languagePacks: List, + val graphicsModes: List, + val mapDataState: Byte, + val platformOrdinal: Byte, + val osOrdinal: Byte, + val capabilityFlagA: Byte, + val capabilityFlagB: Byte, +) { + override fun equals(other: Any?): Boolean = + other is GameHandshakeHelloPacket && + authData == other.authData && + localIp.contentEquals(other.localIp) && + magic == other.magic && + clientRevision == other.clientRevision && + languageId == other.languageId && + chatChannelMask == other.chatChannelMask && + languageFilterMask == other.languageFilterMask && + languagePackMask == other.languagePackMask && + languagePacks == other.languagePacks && + graphicsModes == other.graphicsModes && + mapDataState == other.mapDataState && + platformOrdinal == other.platformOrdinal && + osOrdinal == other.osOrdinal && + capabilityFlagA == other.capabilityFlagA && + capabilityFlagB == other.capabilityFlagB + + override fun hashCode(): Int { + var r = authData.hashCode() + r = r * 31 + localIp.contentHashCode() + r = r * 31 + magic + r = r * 31 + clientRevision + r = r * 31 + languageId + r = r * 31 + chatChannelMask + r = r * 31 + languageFilterMask + r = r * 31 + languagePackMask + r = r * 31 + languagePacks.hashCode() + r = r * 31 + graphicsModes.hashCode() + r = r * 31 + mapDataState + r = r * 31 + platformOrdinal + r = r * 31 + osOrdinal + r = r * 31 + capabilityFlagA + r = r * 31 + capabilityFlagB + return r + } +} + +private val HelloToken = bytesPrefixed(U8) +private val HelloLocalIp = fixedBytes(4) + +private object NewHelloAuthCodec : PacketCodec() { + override fun CodecScope.body(): NewHelloAuth { + val userId = field(S32LE) { it.userId } + val sessionToken = field(HelloToken) { it.sessionToken } + return NewHelloAuth(userId, sessionToken) + } +} + +private object ReconnectHelloAuthCodec : PacketCodec() { + override fun CodecScope.body(): ReconnectHelloAuth { + val entityId = field(S64LE) { it.entityId } + val sessionToken = field(HelloToken) { it.sessionToken } + return ReconnectHelloAuth(entityId, sessionToken) + } +} + +private val HelloAuthCodec: Codec = + choose( + tag = U8, + identify = { data -> + when (data) { + is NewHelloAuth -> 0x00 + is ReconnectHelloAuth -> 0x01 + } + }, + 0x00 to NewHelloAuthCodec, + 0x01 to ReconnectHelloAuthCodec, + ) + +private val LanguagePackEntryCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): LanguagePackEntry { + val name = field(Utf16LeNullTerminated) { it.name } + val version = field(S8) { it.version } + val kind = field(S8) { it.kind } + return LanguagePackEntry(name, version, kind) + } + } + +private val GraphicsModeEntryCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): GraphicsModeEntry { + val id = field(S8) { it.id } + val name = field(Utf16LeNullTerminated) { it.name } + return GraphicsModeEntry(id, name) + } + } + +object GameHandshakeHelloPacketCodec : PacketCodec() { + override fun CodecScope.body(): GameHandshakeHelloPacket { + val authData = field(HelloAuthCodec) { it.authData } + val localIp = field(HelloLocalIp) { it.localIp } + val magic = field(S32LE) { it.magic } + val clientRevision = field(S32LE) { it.clientRevision } + val languageId = field(S8) { it.languageId } + val chatChannelMask = field(S16LE) { it.chatChannelMask } + val languageFilterMask = field(S16LE) { it.languageFilterMask } + val languagePackMask = field(S8) { it.languagePackMask } + val languagePacks = field(LanguagePackEntryCodec.listPrefixed(U8)) { it.languagePacks } + val graphicsModes = field(GraphicsModeEntryCodec.listPrefixed(U8)) { it.graphicsModes } + val mapDataState = field(S8) { it.mapDataState } + val platformOrdinal = field(S8) { it.platformOrdinal } + val osOrdinal = field(S8) { it.osOrdinal } + val capabilityFlagA = field(S8) { it.capabilityFlagA } + val capabilityFlagB = field(S8) { it.capabilityFlagB } + return GameHandshakeHelloPacket( + authData, + localIp, + magic, + clientRevision, + languageId, + chatChannelMask, + languageFilterMask, + languagePackMask, + languagePacks, + graphicsModes, + mapDataState, + platformOrdinal, + osOrdinal, + capabilityFlagA, + capabilityFlagB, + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GameShopCatalogPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GameShopCatalogPacket.kt new file mode 100644 index 0000000..4a0210d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GameShopCatalogPacket.kt @@ -0,0 +1,52 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class GameShopItem( + val itemId: Long, + val value1: Int, + val value2: Int, + val category: Byte, + val cost: Int, +) + +data class GameShopCatalogPacket( + val points: Int, + val items: List, +) + +private object GameShopItemCodec : PacketCodec() { + override fun CodecScope.body(): GameShopItem { + field(S64LE) { 0L } + field(S32LE) { 0 } + val itemId = field(S64LE, GameShopItem::itemId) + val value1 = field(S32LE, GameShopItem::value1) + val value2 = field(S32LE, GameShopItem::value2) + reserved(byte = 0) + val category = field(S8, GameShopItem::category) + val cost = field(S32LE, GameShopItem::cost) + field(S32LE) { 0 } + return GameShopItem(itemId, value1, value2, category, cost) + } +} + +private val GameShopItemListPrefixedU8: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { GameShopItemCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { GameShopItemCodec.write(buf, it) } + } + } + +object GameShopCatalogPacketCodec : PacketCodec() { + override fun CodecScope.body(): GameShopCatalogPacket { + val points = field(S32LE, GameShopCatalogPacket::points) + val items = field(GameShopItemListPrefixedU8, GameShopCatalogPacket::items) + return GameShopCatalogPacket(points, items) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GmPanelEntryPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GmPanelEntryPacket.kt new file mode 100644 index 0000000..14be342 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GmPanelEntryPacket.kt @@ -0,0 +1,20 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class GmPanelEntryPacket( + val clearFlag: Byte, + val label: String?, + val value: String?, + val count: Int?, +) + +object GmPanelEntryPacketCodec : PacketCodec() { + override fun CodecScope.body(): GmPanelEntryPacket { + val clearFlag = field(S8) { it.clearFlag } + val label = if (clearFlag.toInt() == 0) field(Utf16LeNullTerminated) { it.label!! } else null + val value = if (clearFlag.toInt() == 0) field(Utf16LeNullTerminated) { it.value!! } else null + val count = if (clearFlag.toInt() == 0) field(S32LE) { it.count!! } else null + return GmPanelEntryPacket(clearFlag, label, value, count) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GmPanelVariantPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GmPanelVariantPacket.kt new file mode 100644 index 0000000..96b73f2 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GmPanelVariantPacket.kt @@ -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 GmPanelVariantPacket( + val variant: Byte, +) + +object GmPanelVariantPacketCodec : PacketCodec() { + override fun CodecScope.body(): GmPanelVariantPacket { + val variant = field(S8) { it.variant } + return GmPanelVariantPacket(variant) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GmPlayerLookupPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GmPlayerLookupPacket.kt new file mode 100644 index 0000000..a04333d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GmPlayerLookupPacket.kt @@ -0,0 +1,175 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class GmCharacterSession( + val entityId: Long, + val name: String, + val secondaryName: String, + val intA: Int, + val byteA: Byte, + val intB: Int, + val longA: Long, + val intC: Int, + val intD: Int, + val intE: Int, + val shortA: Short, + val intF: Int, + val byteB: Byte, + val byteC: Byte, + val byteD: Byte, + val shortB: Short, + val byteE: Byte, + val intG: Int, + val byteF: Byte, + val byteG: Byte, + val byteH: Byte, + val byteI: Byte, + val byteJ: Byte, + val shortC: Short, + val shortD: Short, + val shortE: Short, + val statusByte: Byte, + val shortF: Short, + val shortG: Short, + val statusList: List, +) + +private val GmCharacterSessionCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): GmCharacterSession { + val entityId = field(S64LE) { it.entityId } + val name = field(Utf16LeNullTerminated) { it.name } + val secondaryName = field(Utf16LeNullTerminated) { it.secondaryName } + val intA = field(S32LE) { it.intA } + val byteA = field(S8) { it.byteA } + val intB = field(S32LE) { it.intB } + val longA = field(S64LE) { it.longA } + val intC = field(S32LE) { it.intC } + field(S32LE) { 0 } + field(S8) { 0 } + val intD = field(S32LE) { it.intD } + val intE = field(S32LE) { it.intE } + val shortA = field(S16LE) { it.shortA } + val intF = field(S32LE) { it.intF } + val byteB = field(S8) { it.byteB } + val byteC = field(S8) { it.byteC } + field(S8) { 0 } + val byteD = field(S8) { it.byteD } + field(S32LE) { 0 } + field(S8) { 0 } + field(S8) { 0 } + field(S8) { 0 } + field(S8) { 0 } + field(S8) { 0 } + field(S8) { 0 } + field(S8) { 0 } + field(S8) { 0 } + val shortB = field(S16LE) { it.shortB } + val byteE = field(S8) { it.byteE } + val intG = field(S32LE) { it.intG } + val byteF = field(S8) { it.byteF } + val byteG = field(S8) { it.byteG } + val byteH = field(S8) { it.byteH } + field(S8) { 0 } + field(S8) { 0 } + field(S8) { 0 } + val byteI = field(S8) { it.byteI } + val byteJ = field(S8) { it.byteJ } + field(S8) { 0 } + val shortC = field(S16LE) { it.shortC } + val shortD = field(S16LE) { it.shortD } + field(S8) { 0 } + field(S8) { 0 } + val shortE = field(S16LE) { it.shortE } + val statusByte = field(S8) { it.statusByte } + val shortF = field(S16LE) { it.shortF } + val shortG = field(S16LE) { it.shortG } + val statusCount = field(U8) { it.statusList.size } + val statusList = (0 until statusCount).map { i -> field(S8) { it.statusList[i] } } + return GmCharacterSession( + entityId, name, secondaryName, intA, byteA, intB, longA, intC, intD, intE, shortA, intF, + byteB, byteC, byteD, shortB, byteE, intG, byteF, byteG, byteH, byteI, byteJ, shortC, + shortD, shortE, statusByte, shortF, shortG, statusList + ) + } + } + +data class GmCharacterListing( + val entityId: Long, + val value: Int, + val name: String, +) + +private val GmCharacterListingCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): GmCharacterListing { + val entityId = field(S64LE) { it.entityId } + val value = field(S32LE) { it.value } + val name = field(Utf16LeNullTerminated) { it.name } + return GmCharacterListing(entityId, value, name) + } + } + +data class GmAccountInfo( + val rankExtraA: Byte, + val rankExtraB: Byte, + val rankExtraC: Byte, + val ipAddress: String, + val playtime: Long, + val accountId: Int, + val stringA: String, + val stringB: String, + val stringC: String, +) + +data class GmExtraDetail( + val value: Int, + val text: String, +) + +data class GmPlayerLookupPacket( + val found: Boolean, + val session: GmCharacterSession?, + val rank: Byte, + val account: GmAccountInfo?, + val extra: GmExtraDetail?, + val characters: List, +) + +object GmPlayerLookupPacketCodec : PacketCodec() { + override fun CodecScope.body(): GmPlayerLookupPacket { + val foundByte = field(U8) { if (it.found) 1 else 0 } + if (foundByte != 1) { + return GmPlayerLookupPacket(false, null, 0, null, null, emptyList()) + } + val session = field(GmCharacterSessionCodec) { it.session!! } + val rank = field(S8) { it.rank } + val account = + if (rank > 0) { + val rankExtraA = field(S8) { it.account!!.rankExtraA } + val rankExtraB = field(S8) { it.account!!.rankExtraB } + val rankExtraC = field(S8) { it.account!!.rankExtraC } + val ipAddress = field(Utf16LeNullTerminated) { it.account!!.ipAddress } + val playtime = field(S64LE) { it.account!!.playtime } + val accountId = field(S32LE) { it.account!!.accountId } + val stringA = field(Utf16LeNullTerminated) { it.account!!.stringA } + val stringB = field(Utf16LeNullTerminated) { it.account!!.stringB } + val stringC = field(Utf16LeNullTerminated) { it.account!!.stringC } + GmAccountInfo( + rankExtraA, rankExtraB, rankExtraC, ipAddress, playtime, accountId, stringA, stringB, + stringC + ) + } else null + val extraByte = field(U8) { if (it.extra != null) 1 else 0 } + val extra = + if (extraByte == 1) { + val value = field(S32LE) { it.extra!!.value } + val text = field(Utf16LeNullTerminated) { it.extra!!.text } + GmExtraDetail(value, text) + } else null + val charCount = field(U16LE) { it.characters.size } + val characters = (0 until charCount).map { i -> field(GmCharacterListingCodec) { it.characters[i] } } + return GmPlayerLookupPacket(true, session, rank, account, extra, characters) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GroupMemberRosterPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GroupMemberRosterPacket.kt new file mode 100644 index 0000000..92535c2 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GroupMemberRosterPacket.kt @@ -0,0 +1,75 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class GroupMemberAppearance( + val name: String, + val gender: Byte, + val formId: Int, + val kind: Byte, + val palettePack: Byte, + val slots: List, +) + +private val GroupMemberAppearanceCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): GroupMemberAppearance { + val name = field(Utf16LeNullTerminated) { it.name } + val gender = field(S8) { it.gender } + val formId = field(S32LE) { it.formId } + val kind = field(S8) { it.kind } + val palettePack = field(S8) { it.palettePack } + val slots = field(S16LE.repeat(4)) { it.slots } + return GroupMemberAppearance(name, gender, formId, kind, palettePack, slots) + } + } + +data class GroupMemberTrackedEntity( + val entityId: Long, + val appearance: GroupMemberAppearance, +) + +private val GroupMemberTrackedEntityCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): GroupMemberTrackedEntity { + val entityId = field(S64LE) { it.entityId } + val appearance = field(GroupMemberAppearanceCodec) { it.appearance } + return GroupMemberTrackedEntity(entityId, appearance) + } + } + +data class GroupRosterMember( + val entityId: Long, + val name: String, + val guildName: String, + val trackedEntities: List, +) + +private val GroupRosterMemberCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): GroupRosterMember { + val entityId = field(S64LE) { it.entityId } + val name = field(Utf16LeNullTerminated) { it.name } + val guildName = field(Utf16LeNullTerminated) { it.guildName } + val trackedEntities = + field(GroupMemberTrackedEntityCodec.listPrefixed(U8)) { it.trackedEntities } + return GroupRosterMember(entityId, name, guildName, trackedEntities) + } + } + +data class GroupMemberRosterPacket( + val reset: Boolean, + val updateState: Boolean, + val state: Byte, + val members: List, +) + +object GroupMemberRosterPacketCodec : PacketCodec() { + override fun CodecScope.body(): GroupMemberRosterPacket { + val reset = field(U8) { if (it.reset) 1 else 0 } == 1 + val updateState = field(U8) { if (it.updateState) 1 else 0 } == 1 + val state = field(S8) { it.state } + val members = field(GroupRosterMemberCodec.listPrefixed(U8)) { it.members } + return GroupMemberRosterPacket(reset, updateState, state, members) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlConfirmPurchasePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlConfirmPurchasePacket.kt new file mode 100644 index 0000000..ac48552 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlConfirmPurchasePacket.kt @@ -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 GtlConfirmPurchasePacket( + val listingEntityId: Long, + val quantity: Short, +) + +object GtlConfirmPurchasePacketCodec : PacketCodec() { + override fun CodecScope.body(): GtlConfirmPurchasePacket { + val listingEntityId = field(S64LE) { it.listingEntityId } + val quantity = field(S16LE) { it.quantity } + return GtlConfirmPurchasePacket(listingEntityId, quantity) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlCreateListingPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlCreateListingPacket.kt new file mode 100644 index 0000000..76721f4 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlCreateListingPacket.kt @@ -0,0 +1,54 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class GtlCreateListingPacket( + val categoryIndex: Byte, + val listingCount: Byte, + val itemKind: Byte, + val priceShort: Short, + val filterCriteria: ByteArray, +) { + override fun equals(other: Any?): Boolean = + other is GtlCreateListingPacket && + categoryIndex == other.categoryIndex && + listingCount == other.listingCount && + itemKind == other.itemKind && + priceShort == other.priceShort && + filterCriteria.contentEquals(other.filterCriteria) + + override fun hashCode(): Int { + var r = categoryIndex.toInt() + r = r * 31 + listingCount + r = r * 31 + itemKind + r = r * 31 + priceShort + r = r * 31 + filterCriteria.contentHashCode() + return r + } +} + +private val FilterCriteriaBytes: Codec = + object : Codec { + 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 GtlCreateListingPacketCodec : PacketCodec() { + override fun CodecScope.body(): GtlCreateListingPacket { + val categoryIndex = field(S8) { it.categoryIndex } + val listingCount = field(S8) { it.listingCount } + val itemKind = field(S8) { it.itemKind } + val priceShort = field(S16LE) { it.priceShort } + val filterCriteria = field(FilterCriteriaBytes) { it.filterCriteria } + return GtlCreateListingPacket( + categoryIndex, listingCount, itemKind, priceShort, filterCriteria + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlItemMarketPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlItemMarketPacket.kt new file mode 100644 index 0000000..f676b70 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlItemMarketPacket.kt @@ -0,0 +1,48 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class GtlMarketEntry( + val price: Int, + val quantity: Long, +) + +data class GtlItemMarketPacket( + val itemType: Int, + val variant: Short, + val count: Int, + val quantities: List, + val entries: List, +) + +private object GtlMarketEntryCodec : PacketCodec() { + override fun CodecScope.body(): GtlMarketEntry { + val price = field(S32LE, GtlMarketEntry::price) + val quantity = field(S64LE, GtlMarketEntry::quantity) + return GtlMarketEntry(price, quantity) + } +} + +private val GtlMarketEntryListPrefixedU8: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { GtlMarketEntryCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { GtlMarketEntryCodec.write(buf, it) } + } + } + +object GtlItemMarketPacketCodec : PacketCodec() { + override fun CodecScope.body(): GtlItemMarketPacket { + val itemType = field(U8, GtlItemMarketPacket::itemType) + val variant = field(S16LE, GtlItemMarketPacket::variant) + val count = field(S32LE, GtlItemMarketPacket::count) + val quantities = field(S32LE.repeat(3), GtlItemMarketPacket::quantities) + val entries = field(GtlMarketEntryListPrefixedU8, GtlItemMarketPacket::entries) + return GtlItemMarketPacket(itemType, variant, count, quantities, entries) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlListingActionPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlListingActionPacket.kt new file mode 100644 index 0000000..142f675 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlListingActionPacket.kt @@ -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.S8 + +data class GtlListingActionPacket( + val entryKindId: Byte, + val itemId: Short, +) + +object GtlListingActionPacketCodec : PacketCodec() { + override fun CodecScope.body(): GtlListingActionPacket { + val entryKindId = field(S8) { it.entryKindId } + val itemId = field(S16LE) { it.itemId } + return GtlListingActionPacket(entryKindId, itemId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlListingCancelPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlListingCancelPacket.kt new file mode 100644 index 0000000..be2215d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlListingCancelPacket.kt @@ -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.Utf16LeNullTerminated + +data class GtlListingCancelPacket( + val listingId: String, +) + +object GtlListingCancelPacketCodec : PacketCodec() { + override fun CodecScope.body(): GtlListingCancelPacket { + val listingId = field(Utf16LeNullTerminated) { it.listingId } + return GtlListingCancelPacket(listingId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlListingSearchPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlListingSearchPacket.kt new file mode 100644 index 0000000..8378bb0 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlListingSearchPacket.kt @@ -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.S32LE + +data class GtlListingSearchPacket( + val searchId: Int, +) + +object GtlListingSearchPacketCodec : PacketCodec() { + override fun CodecScope.body(): GtlListingSearchPacket { + val searchId = field(S32LE) { it.searchId } + return GtlListingSearchPacket(searchId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlListingsPagePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlListingsPagePacket.kt new file mode 100644 index 0000000..d61d04e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlListingsPagePacket.kt @@ -0,0 +1,59 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class TradeListingEntry( + val a: Int, + val b: Int, + val c: Long, +) + +data class TradeListing( + val typeId: Short, + val price: Int, + val fieldB: Int, + val fieldC: Int, + val fieldD: Int, + val entries: List, +) + +data class GtlListingsPagePacket( + val page: Byte, + val entryKind: Int, + val totalCount: Int, + val listings: List, +) + +private val TradeListingEntryCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): TradeListingEntry { + val a = field(S32LE) { it.a } + val b = field(S32LE) { it.b } + val c = field(S64LE) { it.c } + return TradeListingEntry(a, b, c) + } + } + +private val TradeListingCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): TradeListing { + val typeId = field(S16LE) { it.typeId } + val price = field(S32LE) { it.price } + val fieldB = field(S32LE) { it.fieldB } + val fieldC = field(S32LE) { it.fieldC } + val fieldD = field(S32LE) { it.fieldD } + val entries = field(TradeListingEntryCodec.listPrefixed(U8)) { it.entries } + return TradeListing(typeId, price, fieldB, fieldC, fieldD, entries) + } + } + +object GtlListingsPagePacketCodec : PacketCodec() { + override fun CodecScope.body(): GtlListingsPagePacket { + val page = field(S8) { it.page } + val entryKind = field(U8) { it.entryKind } + field(S16LE) { 0 } + val totalCount = field(S32LE) { it.totalCount } + val listings = field(TradeListingCodec.listPrefixed(U8)) { it.listings } + return GtlListingsPagePacket(page, entryKind, totalCount, listings) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlMarketListingsPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlMarketListingsPacket.kt new file mode 100644 index 0000000..5c01881 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlMarketListingsPacket.kt @@ -0,0 +1,104 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class GtlMarketListing( + val listingId: Int, + val typeId: Byte, + val sellerId: Byte, + val speciesId: Short, + val value1: Int, + val value2: Int, + val value3: Int, + val ownListing: Boolean, + val value4: Int, + val value5: Int, + val value6: Int, + val value7: Int, + val form: Byte, + val rowIndex: Int, +) + +data class GtlMarketListingsPacket( + val fullReset: Boolean, + val applyToBoards: Boolean, + val referenceData: ByteArray?, + val listings: List, +) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is GtlMarketListingsPacket) return false + return fullReset == other.fullReset && + applyToBoards == other.applyToBoards && + (referenceData?.contentEquals(other.referenceData) ?: (other.referenceData == null)) && + listings == other.listings + } + + override fun hashCode(): Int { + var result = fullReset.hashCode() + result = 31 * result + applyToBoards.hashCode() + result = 31 * result + (referenceData?.contentHashCode() ?: 0) + result = 31 * result + listings.hashCode() + return result + } +} + +private object GtlMarketListingCodec : PacketCodec() { + override fun CodecScope.body(): GtlMarketListing { + val listingId = field(S32LE, GtlMarketListing::listingId) + val typeId = field(S8, GtlMarketListing::typeId) + val sellerId = field(S8, GtlMarketListing::sellerId) + val speciesId = field(S16LE, GtlMarketListing::speciesId) + val value1 = field(S32LE, GtlMarketListing::value1) + val value2 = field(S32LE, GtlMarketListing::value2) + val value3 = field(S32LE, GtlMarketListing::value3) + val ownListing = field(Bool, GtlMarketListing::ownListing) + val value4 = field(S32LE, GtlMarketListing::value4) + val value5 = field(S32LE, GtlMarketListing::value5) + val value6 = field(S32LE, GtlMarketListing::value6) + val value7 = field(S32LE, GtlMarketListing::value7) + val form = field(S8, GtlMarketListing::form) + reserved(byte = 0) + val rowIndex = field(S32LE, GtlMarketListing::rowIndex) + return GtlMarketListing( + listingId, + typeId, + sellerId, + speciesId, + value1, + value2, + value3, + ownListing, + value4, + value5, + value6, + value7, + form, + rowIndex, + ) + } +} + +private val GtlMarketListingListPrefixedU8: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { GtlMarketListingCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { GtlMarketListingCodec.write(buf, it) } + } + } + +object GtlMarketListingsPacketCodec : PacketCodec() { + override fun CodecScope.body(): GtlMarketListingsPacket { + val fullReset = field(Bool, GtlMarketListingsPacket::fullReset) + val applyToBoards = field(Bool, GtlMarketListingsPacket::applyToBoards) + val referenceData = + if (fullReset) field(bytesPrefixed(U8)) { it.referenceData ?: ByteArray(0) } else null + val listings = field(GtlMarketListingListPrefixedU8, GtlMarketListingsPacket::listings) + return GtlMarketListingsPacket(fullReset, applyToBoards, referenceData, listings) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlOpenSessionPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlOpenSessionPacket.kt new file mode 100644 index 0000000..9ffc21f --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlOpenSessionPacket.kt @@ -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 GtlOpenSessionPacket( + val entryKindId: Byte, + val sessionTimestamp: Long, +) + +object GtlOpenSessionPacketCodec : PacketCodec() { + override fun CodecScope.body(): GtlOpenSessionPacket { + val entryKindId = field(S8) { it.entryKindId } + val sessionTimestamp = field(S64LE) { it.sessionTimestamp } + return GtlOpenSessionPacket(entryKindId, sessionTimestamp) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlPriceHistoryPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlPriceHistoryPacket.kt new file mode 100644 index 0000000..187123c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlPriceHistoryPacket.kt @@ -0,0 +1,44 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class GtlPriceHistoryPoint( + val timestampSeconds: Int, + val price: Int, +) + +data class GtlPriceHistoryPacket( + val itemType: Int, + val variant: Short, + val points: List, +) + +private object GtlPriceHistoryPointCodec : PacketCodec() { + override fun CodecScope.body(): GtlPriceHistoryPoint { + val timestampSeconds = field(S32LE, GtlPriceHistoryPoint::timestampSeconds) + val price = field(S32LE, GtlPriceHistoryPoint::price) + return GtlPriceHistoryPoint(timestampSeconds, price) + } +} + +private val GtlPriceHistoryPointListPrefixedU16: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U16LE.read(buf) + return List(n) { GtlPriceHistoryPointCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U16LE.write(buf, value.size) + value.forEach { GtlPriceHistoryPointCodec.write(buf, it) } + } + } + +object GtlPriceHistoryPacketCodec : PacketCodec() { + override fun CodecScope.body(): GtlPriceHistoryPacket { + val itemType = field(U8, GtlPriceHistoryPacket::itemType) + val variant = field(S16LE, GtlPriceHistoryPacket::variant) + val points = field(GtlPriceHistoryPointListPrefixedU16, GtlPriceHistoryPacket::points) + return GtlPriceHistoryPacket(itemType, variant, points) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlPurchaseListingPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlPurchaseListingPacket.kt new file mode 100644 index 0000000..8a9036b --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlPurchaseListingPacket.kt @@ -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.S32LE +import de.fiereu.bytecodec.S8 + +data class GtlPurchaseListingPacket( + val listingId: Int, + val price: Int, + val action: Byte, +) + +object GtlPurchaseListingPacketCodec : PacketCodec() { + override fun CodecScope.body(): GtlPurchaseListingPacket { + val listingId = field(S32LE) { it.listingId } + val price = field(S32LE) { it.price } + val action = field(S8) { it.action } + return GtlPurchaseListingPacket(listingId, price, action) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlPurchasePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlPurchasePacket.kt new file mode 100644 index 0000000..ca9fa0e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlPurchasePacket.kt @@ -0,0 +1,22 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class GtlPurchasePacket( + val entryKindId: Byte, + val itemTypeId: Short, + val quantity: Short, + val totalPrice: Int, + val listingFlag: Byte, +) + +object GtlPurchasePacketCodec : PacketCodec() { + override fun CodecScope.body(): GtlPurchasePacket { + val entryKindId = field(S8) { it.entryKindId } + val itemTypeId = field(S16LE) { it.itemTypeId } + val quantity = field(S16LE) { it.quantity } + val totalPrice = field(S32LE) { it.totalPrice } + val listingFlag = field(S8) { it.listingFlag } + return GtlPurchasePacket(entryKindId, itemTypeId, quantity, totalPrice, listingFlag) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlSearchFilterPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlSearchFilterPacket.kt new file mode 100644 index 0000000..eac0c6c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlSearchFilterPacket.kt @@ -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 GtlSearchFilterPacket( + val filterState: Byte, +) + +object GtlSearchFilterPacketCodec : PacketCodec() { + override fun CodecScope.body(): GtlSearchFilterPacket { + val filterState = field(S8) { it.filterState } + return GtlSearchFilterPacket(filterState) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlSellPokemonListingPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlSellPokemonListingPacket.kt new file mode 100644 index 0000000..75d0b80 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlSellPokemonListingPacket.kt @@ -0,0 +1,45 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class GtlSellPokemonListingPacket( + val listingType: Byte, + val entryKindId: Byte, + val listingCategory: Byte, + val itemTypeId: Short, + val criteriaCount: Int, + val criteriaData: ByteArray, +) { + override fun equals(other: Any?): Boolean = + other is GtlSellPokemonListingPacket && + listingType == other.listingType && + entryKindId == other.entryKindId && + listingCategory == other.listingCategory && + itemTypeId == other.itemTypeId && + criteriaCount == other.criteriaCount && + criteriaData.contentEquals(other.criteriaData) + + override fun hashCode(): Int { + var r = listingType.toInt() + r = r * 31 + entryKindId + r = r * 31 + listingCategory + r = r * 31 + itemTypeId + r = r * 31 + criteriaCount + r = r * 31 + criteriaData.contentHashCode() + return r + } +} + +object GtlSellPokemonListingPacketCodec : PacketCodec() { + override fun CodecScope.body(): GtlSellPokemonListingPacket { + val listingType = field(S8) { it.listingType } + val entryKindId = field(S8) { it.entryKindId } + val listingCategory = field(S8) { it.listingCategory } + val itemTypeId = field(S16LE) { it.itemTypeId } + val criteriaCount = field(U8) { it.criteriaCount } + val criteriaData = field(RemainingBytes) { it.criteriaData } + return GtlSellPokemonListingPacket( + listingType, entryKindId, listingCategory, itemTypeId, criteriaCount, criteriaData + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlTradeLogRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlTradeLogRequestPacket.kt new file mode 100644 index 0000000..dfae39b --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GtlTradeLogRequestPacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec + +class GtlTradeLogRequestPacket + +object GtlTradeLogRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): GtlTradeLogRequestPacket { + return GtlTradeLogRequestPacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildActivityLogPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildActivityLogPacket.kt new file mode 100644 index 0000000..322c7fb --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildActivityLogPacket.kt @@ -0,0 +1,46 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class GuildActivityLogEntry( + val type: Int, + val actor: String, + val target: String, + val timestamp: Int, +) + +data class GuildActivityLogPacket( + val totalCount: Short, + val entries: List, +) + +private object GuildActivityLogEntryCodec : PacketCodec() { + override fun CodecScope.body(): GuildActivityLogEntry { + val type = field(U8, GuildActivityLogEntry::type) + val actor = field(Utf16LeNullTerminated, GuildActivityLogEntry::actor) + val target = field(Utf16LeNullTerminated, GuildActivityLogEntry::target) + val timestamp = field(S32LE, GuildActivityLogEntry::timestamp) + return GuildActivityLogEntry(type, actor, target, timestamp) + } +} + +private val GuildActivityLogEntryListPrefixedU8: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { GuildActivityLogEntryCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { GuildActivityLogEntryCodec.write(buf, it) } + } + } + +object GuildActivityLogPacketCodec : PacketCodec() { + override fun CodecScope.body(): GuildActivityLogPacket { + val totalCount = field(S16LE, GuildActivityLogPacket::totalCount) + val entries = field(GuildActivityLogEntryListPrefixedU8, GuildActivityLogPacket::entries) + return GuildActivityLogPacket(totalCount, entries) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildActivityLogPageRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildActivityLogPageRequestPacket.kt new file mode 100644 index 0000000..c7fc284 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildActivityLogPageRequestPacket.kt @@ -0,0 +1,17 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec +import de.fiereu.bytecodec.S16LE + +data class GuildActivityLogPageRequestPacket( + val pageIndex: Short, +) + +object GuildActivityLogPageRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): + GuildActivityLogPageRequestPacket { + val pageIndex = field(S16LE) { it.pageIndex } + return GuildActivityLogPageRequestPacket(pageIndex) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildChatSendPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildChatSendPacket.kt new file mode 100644 index 0000000..e27abf6 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildChatSendPacket.kt @@ -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.Utf16LeNullTerminated + +data class GuildChatSendPacket( + val message: String, +) + +object GuildChatSendPacketCodec : PacketCodec() { + override fun CodecScope.body(): GuildChatSendPacket { + val message = field(Utf16LeNullTerminated) { it.message } + return GuildChatSendPacket(message) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildDepartPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildDepartPacket.kt new file mode 100644 index 0000000..e78b0f5 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildDepartPacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec + +class GuildDepartPacket + +object GuildDepartPacketCodec : PacketCodec() { + override fun CodecScope.body(): GuildDepartPacket { + return GuildDepartPacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildDisbandToggleRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildDisbandToggleRequestPacket.kt new file mode 100644 index 0000000..ff0495a --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildDisbandToggleRequestPacket.kt @@ -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 GuildDisbandToggleRequestPacket( + val initiate: Boolean, + val ownerEntityId: Long, +) + +object GuildDisbandToggleRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): GuildDisbandToggleRequestPacket { + val initiate = field(Bool) { it.initiate } + val ownerEntityId = field(S64LE) { it.ownerEntityId } + return GuildDisbandToggleRequestPacket(initiate, ownerEntityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMemberExpelPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMemberExpelPacket.kt new file mode 100644 index 0000000..c99026b --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMemberExpelPacket.kt @@ -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 GuildMemberExpelPacket( + val targetEntityId: Long, +) + +object GuildMemberExpelPacketCodec : PacketCodec() { + override fun CodecScope.body(): GuildMemberExpelPacket { + val targetEntityId = field(S64LE) { it.targetEntityId } + return GuildMemberExpelPacket(targetEntityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMemberPresencePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMemberPresencePacket.kt new file mode 100644 index 0000000..43b4bc3 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMemberPresencePacket.kt @@ -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 GuildMemberPresencePacket( + val memberId: Long, + val online: Boolean, +) + +object GuildMemberPresencePacketCodec : PacketCodec() { + override fun CodecScope.body(): GuildMemberPresencePacket { + val memberId = field(S64LE, GuildMemberPresencePacket::memberId) + val online = field(Bool, GuildMemberPresencePacket::online) + return GuildMemberPresencePacket(memberId, online) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMemberRankAssignPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMemberRankAssignPacket.kt new file mode 100644 index 0000000..9188613 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMemberRankAssignPacket.kt @@ -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.U8 + +data class GuildMemberRankAssignPacket( + val memberEntityId: Long, + val rankOrdinal: Int, +) + +object GuildMemberRankAssignPacketCodec : PacketCodec() { + override fun CodecScope.body(): GuildMemberRankAssignPacket { + val memberEntityId = field(S64LE) { it.memberEntityId } + val rankOrdinal = field(U8) { it.rankOrdinal } + return GuildMemberRankAssignPacket(memberEntityId, rankOrdinal) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMemberRankChangePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMemberRankChangePacket.kt new file mode 100644 index 0000000..edb07f1 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMemberRankChangePacket.kt @@ -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.S64LE +import de.fiereu.bytecodec.S8 + +data class GuildMemberRankChangePacket( + val memberId: Long, + val rank: Byte, +) + +object GuildMemberRankChangePacketCodec : PacketCodec() { + override fun CodecScope.body(): GuildMemberRankChangePacket { + field(S64LE) { 0L } + val memberId = field(S64LE, GuildMemberRankChangePacket::memberId) + val rank = field(S8, GuildMemberRankChangePacket::rank) + return GuildMemberRankChangePacket(memberId, rank) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMembershipPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMembershipPacket.kt new file mode 100644 index 0000000..ee786b4 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMembershipPacket.kt @@ -0,0 +1,66 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class GuildProfileData( + val guildId: Long, + val name: String, + val tag: String, + val memberCount: Int, + val description: String, + val motd: Int, + val value1: Short, + val value2: Short, + val value3: Short, + val value4: Short, + val value5: Short, + val value6: Int, + val rankNames: List, +) + +data class GuildMembershipPacket( + val inGuild: Boolean, + val profile: GuildProfileData?, +) + +private object GuildProfileDataCodec : PacketCodec() { + override fun CodecScope.body(): GuildProfileData { + val guildId = field(S64LE, GuildProfileData::guildId) + val name = field(Utf16LeNullTerminated, GuildProfileData::name) + val tag = field(Utf16LeNullTerminated, GuildProfileData::tag) + val memberCount = field(S32LE, GuildProfileData::memberCount) + val description = field(Utf16LeNullTerminated, GuildProfileData::description) + val motd = field(S32LE, GuildProfileData::motd) + val value1 = field(S16LE, GuildProfileData::value1) + val value2 = field(S16LE, GuildProfileData::value2) + val value3 = field(S16LE, GuildProfileData::value3) + val value4 = field(S16LE, GuildProfileData::value4) + val value5 = field(S16LE, GuildProfileData::value5) + val value6 = field(S32LE, GuildProfileData::value6) + val rankCount = field(S8) { it.rankNames.size.toByte() } + val rankNames = List(rankCount.toInt()) { i -> field(Utf16LeNullTerminated) { it.rankNames[i] } } + return GuildProfileData( + guildId, + name, + tag, + memberCount, + description, + motd, + value1, + value2, + value3, + value4, + value5, + value6, + rankNames, + ) + } +} + +object GuildMembershipPacketCodec : PacketCodec() { + override fun CodecScope.body(): GuildMembershipPacket { + val inGuild = field(Bool, GuildMembershipPacket::inGuild) + val profile = if (inGuild) field(GuildProfileDataCodec) { it.profile!! } else null + return GuildMembershipPacket(inGuild, profile) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMotdUpdatePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMotdUpdatePacket.kt new file mode 100644 index 0000000..f71a0da --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildMotdUpdatePacket.kt @@ -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.Utf16LeNullTerminated + +data class GuildMotdUpdatePacket( + val motdText: String, +) + +object GuildMotdUpdatePacketCodec : PacketCodec() { + override fun CodecScope.body(): GuildMotdUpdatePacket { + val motdText = field(Utf16LeNullTerminated) { it.motdText } + return GuildMotdUpdatePacket(motdText) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildProfileSyncPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildProfileSyncPacket.kt new file mode 100644 index 0000000..72b1a58 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildProfileSyncPacket.kt @@ -0,0 +1,53 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class GuildProfileSyncPacket( + val guildId: Long, + val name: String, + val tag: String, + val memberCount: Int, + val description: String, + val motd: Int, + val value1: Short, + val value2: Short, + val value3: Short, + val value4: Short, + val value5: Short, + val value6: Int, + val rankNames: List, +) + +object GuildProfileSyncPacketCodec : PacketCodec() { + override fun CodecScope.body(): GuildProfileSyncPacket { + val guildId = field(S64LE, GuildProfileSyncPacket::guildId) + val name = field(Utf16LeNullTerminated, GuildProfileSyncPacket::name) + val tag = field(Utf16LeNullTerminated, GuildProfileSyncPacket::tag) + val memberCount = field(S32LE, GuildProfileSyncPacket::memberCount) + val description = field(Utf16LeNullTerminated, GuildProfileSyncPacket::description) + val motd = field(S32LE, GuildProfileSyncPacket::motd) + val value1 = field(S16LE, GuildProfileSyncPacket::value1) + val value2 = field(S16LE, GuildProfileSyncPacket::value2) + val value3 = field(S16LE, GuildProfileSyncPacket::value3) + val value4 = field(S16LE, GuildProfileSyncPacket::value4) + val value5 = field(S16LE, GuildProfileSyncPacket::value5) + val value6 = field(S32LE, GuildProfileSyncPacket::value6) + val rankCount = field(S8) { it.rankNames.size.toByte() } + val rankNames = List(rankCount.toInt()) { i -> field(Utf16LeNullTerminated) { it.rankNames[i] } } + return GuildProfileSyncPacket( + guildId, + name, + tag, + memberCount, + description, + motd, + value1, + value2, + value3, + value4, + value5, + value6, + rankNames, + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRankLabelUpdatePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRankLabelUpdatePacket.kt new file mode 100644 index 0000000..267707e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRankLabelUpdatePacket.kt @@ -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.U8 +import de.fiereu.bytecodec.Utf16LeNullTerminated + +data class GuildRankLabelUpdatePacket( + val rankOrdinal: Int, + val rankLabel: String, +) + +object GuildRankLabelUpdatePacketCodec : PacketCodec() { + override fun CodecScope.body(): GuildRankLabelUpdatePacket { + val rankOrdinal = field(U8) { it.rankOrdinal } + val rankLabel = field(Utf16LeNullTerminated) { it.rankLabel } + return GuildRankLabelUpdatePacket(rankOrdinal, rankLabel) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRankPermissionUpdatePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRankPermissionUpdatePacket.kt new file mode 100644 index 0000000..cfdcaab --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRankPermissionUpdatePacket.kt @@ -0,0 +1,30 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec +import de.fiereu.bytecodec.S16LE + +data class GuildRankPermissionUpdatePacket( + val permCategory1: Short, + val permCategory2: Short, + val permCategory3: Short, + val permCategory4: Short, + val permCategory5: Short, +) + +object GuildRankPermissionUpdatePacketCodec : PacketCodec() { + override fun CodecScope.body(): GuildRankPermissionUpdatePacket { + val permCategory1 = field(S16LE) { it.permCategory1 } + val permCategory2 = field(S16LE) { it.permCategory2 } + val permCategory3 = field(S16LE) { it.permCategory3 } + val permCategory4 = field(S16LE) { it.permCategory4 } + val permCategory5 = field(S16LE) { it.permCategory5 } + return GuildRankPermissionUpdatePacket( + permCategory1, + permCategory2, + permCategory3, + permCategory4, + permCategory5, + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRosterAddPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRosterAddPacket.kt new file mode 100644 index 0000000..21242c8 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRosterAddPacket.kt @@ -0,0 +1,43 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class GuildMemberAppearance( + val name: String, + val gender: Byte, + val formId: Int, + val kind: Byte, + val palettePack: Byte, + val slots: List, +) + +data class GuildRosterAddPacket( + val rank: Byte, + val entityId: Long, + val value: Int, + val appearance: GuildMemberAppearance, + val leader: Boolean, +) + +internal object GuildMemberAppearanceCodec : PacketCodec() { + override fun CodecScope.body(): GuildMemberAppearance { + val name = field(Utf16LeNullTerminated, GuildMemberAppearance::name) + val gender = field(S8, GuildMemberAppearance::gender) + val formId = field(S32LE, GuildMemberAppearance::formId) + val kind = field(S8, GuildMemberAppearance::kind) + val palettePack = field(S8, GuildMemberAppearance::palettePack) + val slots = field(S16LE.repeat(4), GuildMemberAppearance::slots) + return GuildMemberAppearance(name, gender, formId, kind, palettePack, slots) + } +} + +object GuildRosterAddPacketCodec : PacketCodec() { + override fun CodecScope.body(): GuildRosterAddPacket { + val rank = field(S8, GuildRosterAddPacket::rank) + val entityId = field(S64LE, GuildRosterAddPacket::entityId) + val value = field(S32LE, GuildRosterAddPacket::value) + val appearance = field(GuildMemberAppearanceCodec, GuildRosterAddPacket::appearance) + val leader = field(Bool, GuildRosterAddPacket::leader) + return GuildRosterAddPacket(rank, entityId, value, appearance, leader) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRosterBulkPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRosterBulkPacket.kt new file mode 100644 index 0000000..9fdc1ef --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRosterBulkPacket.kt @@ -0,0 +1,48 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class GuildRosterMember( + val rank: Byte, + val entityId: Long, + val value: Int, + val appearance: GuildMemberAppearance, + val leader: Boolean, +) + +data class GuildRosterBulkPacket( + val replace: Boolean, + val members: List, +) + +private object GuildRosterMemberCodec : PacketCodec() { + override fun CodecScope.body(): GuildRosterMember { + val rank = field(S8, GuildRosterMember::rank) + val entityId = field(S64LE, GuildRosterMember::entityId) + val value = field(S32LE, GuildRosterMember::value) + val appearance = field(GuildMemberAppearanceCodec, GuildRosterMember::appearance) + val leader = field(Bool, GuildRosterMember::leader) + return GuildRosterMember(rank, entityId, value, appearance, leader) + } +} + +private val GuildRosterMemberListPrefixedU8: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { GuildRosterMemberCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { GuildRosterMemberCodec.write(buf, it) } + } + } + +object GuildRosterBulkPacketCodec : PacketCodec() { + override fun CodecScope.body(): GuildRosterBulkPacket { + val replace = field(Bool, GuildRosterBulkPacket::replace) + val members = field(GuildRosterMemberListPrefixedU8, GuildRosterBulkPacket::members) + return GuildRosterBulkPacket(replace, members) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRosterRemovePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRosterRemovePacket.kt new file mode 100644 index 0000000..75a7ec0 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/GuildRosterRemovePacket.kt @@ -0,0 +1,17 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec +import de.fiereu.bytecodec.S64LE + +data class GuildRosterRemovePacket( + val memberId: Long, +) + +object GuildRosterRemovePacketCodec : PacketCodec() { + override fun CodecScope.body(): GuildRosterRemovePacket { + field(S64LE) { 0L } + val memberId = field(S64LE, GuildRosterRemovePacket::memberId) + return GuildRosterRemovePacket(memberId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/HeartbeatRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/HeartbeatRequestPacket.kt new file mode 100644 index 0000000..46aedf5 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/HeartbeatRequestPacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec + +data class HeartbeatRequestPacket(val placeholder: Unit = Unit) + +object HeartbeatRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): HeartbeatRequestPacket { + return HeartbeatRequestPacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/HighScoreBoardPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/HighScoreBoardPacket.kt new file mode 100644 index 0000000..5015d01 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/HighScoreBoardPacket.kt @@ -0,0 +1,59 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class HighScoreAppearance( + val name: String, + val gender: Byte, + val id: Int, + val kind: Byte, + val palettePack: Byte, + val slots: List, +) + +data class HighScoreEntry( + val entityId: Long, + val rank: Int, + val score: Int, + val appearances: List, +) + +data class HighScoreBoardPacket( + val category: Byte, + val entries: List, +) + +private val HighScoreAppearanceCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): HighScoreAppearance { + 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 HighScoreAppearance(name, gender, id, kind, palettePack, slots) + } + } + +private val HighScoreEntryCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): HighScoreEntry { + val entityId = field(S64LE) { it.entityId } + val rank = field(S32LE) { it.rank } + val score = field(S32LE) { it.score } + val count = field(U8) { it.appearances.size } + val appearances = (0 until count).map { i -> field(HighScoreAppearanceCodec) { it.appearances[i] } } + return HighScoreEntry(entityId, rank, score, appearances) + } + } + +object HighScoreBoardPacketCodec : PacketCodec() { + override fun CodecScope.body(): HighScoreBoardPacket { + val category = field(S8) { it.category } + field(S32LE) { 0 } + val count = field(S32LE) { it.entries.size } + val entries = (0 until count).map { i -> field(HighScoreEntryCodec) { it.entries[i] } } + return HighScoreBoardPacket(category, entries) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/InGameChallengeResponsePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/InGameChallengeResponsePacket.kt new file mode 100644 index 0000000..30288ad --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/InGameChallengeResponsePacket.kt @@ -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.U8 +import de.fiereu.bytecodec.Utf16LeNullTerminated + +data class InGameChallengeResponsePacket(val accepted: Boolean, val responseText: String) + +object InGameChallengeResponsePacketCodec : PacketCodec() { + override fun CodecScope.body(): InGameChallengeResponsePacket { + val declined = field(U8) { if (it.accepted) 0 else 1 } + val responseText = field(Utf16LeNullTerminated) { it.responseText } + return InGameChallengeResponsePacket(declined == 0, responseText) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/InstanceReadyCheckPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/InstanceReadyCheckPacket.kt new file mode 100644 index 0000000..eaf91f8 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/InstanceReadyCheckPacket.kt @@ -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 InstanceReadyCheckPacket(val isReady: Boolean) + +object InstanceReadyCheckPacketCodec : PacketCodec() { + override fun CodecScope.body(): InstanceReadyCheckPacket { + val isReady = field(Bool) { it.isReady } + return InstanceReadyCheckPacket(isReady) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/InteractivePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/InteractivePacket.kt index 6f98824..e749469 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/InteractivePacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/InteractivePacket.kt @@ -1,11 +1,6 @@ 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 -import de.fiereu.bytecodec.U16LE -import de.fiereu.bytecodec.U8 +import de.fiereu.bytecodec.* data class InteractivePacket( val id: Int, @@ -18,14 +13,14 @@ data class InteractivePacket( ) object InteractivePacketCodec : PacketCodec() { - override fun CodecScope.body(): InteractivePacket { - val id = field(U8) { it.id } - val type = field(U8) { it.type } - val unk1 = field(S32LE) { it.unk1 } - val unk2 = field(S32LE) { it.unk2 } - val targetEntityId = field(S64LE) { it.targetEntityId } - val unk3 = field(U16LE) { it.unk3 } - val unk4 = field(U16LE) { it.unk4 } - return InteractivePacket(id, type, unk1, unk2, targetEntityId, unk3, unk4) - } + override fun CodecScope.body(): InteractivePacket { + val id = field(U8) { it.id } + val type = field(U8) { it.type } + val unk1 = field(S32LE) { it.unk1 } + val unk2 = field(S32LE) { it.unk2 } + val targetEntityId = field(S64LE) { it.targetEntityId } + val unk3 = field(U16LE) { it.unk3 } + val unk4 = field(U16LE) { it.unk4 } + return InteractivePacket(id, type, unk1, unk2, targetEntityId, unk3, unk4) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/InteractiveResponsePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/InteractiveResponsePacket.kt index 8467366..11babb9 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/InteractiveResponsePacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/InteractiveResponsePacket.kt @@ -7,9 +7,9 @@ import de.fiereu.bytecodec.U8 data class InteractiveResponsePacket(val id: Int, val unk: Int) object InteractiveResponsePacketCodec : PacketCodec() { - override fun CodecScope.body(): InteractiveResponsePacket { - val id = field(U8) { it.id } - val unk = field(U8) { it.unk } - return InteractiveResponsePacket(id, unk) - } + override fun CodecScope.body(): InteractiveResponsePacket { + val id = field(U8) { it.id } + val unk = field(U8) { it.unk } + return InteractiveResponsePacket(id, unk) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/JoinMatchmakingQueuePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/JoinMatchmakingQueuePacket.kt new file mode 100644 index 0000000..9802ef6 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/JoinMatchmakingQueuePacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec + +class JoinMatchmakingQueuePacket + +object JoinMatchmakingQueuePacketCodec : PacketCodec() { + override fun CodecScope.body(): JoinMatchmakingQueuePacket { + return JoinMatchmakingQueuePacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/JoinPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/JoinPacket.kt index 9d21929..4c1417d 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/JoinPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/JoinPacket.kt @@ -1,21 +1,6 @@ package de.fiereu.openmmo.net.game.packets -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.U8 -import de.fiereu.bytecodec.Utf16LeNullTerminated -import de.fiereu.bytecodec.bytesPrefixed -import de.fiereu.bytecodec.choose -import de.fiereu.bytecodec.enumByOrdinalByte -import de.fiereu.bytecodec.fixedBytes -import de.fiereu.bytecodec.imap -import de.fiereu.bytecodec.listPrefixed -import de.fiereu.bytecodec.then +import de.fiereu.bytecodec.* import de.fiereu.openmmo.common.enums.Arch import de.fiereu.openmmo.common.enums.Bitness import de.fiereu.openmmo.common.enums.Platform @@ -26,19 +11,19 @@ sealed class GameAuthenticationData data class ReconnectAuthData(val sessionId: Long, val sessionKey: ByteArray) : GameAuthenticationData() { - override fun equals(other: Any?): Boolean = - other is ReconnectAuthData && - sessionId == other.sessionId && - sessionKey.contentEquals(other.sessionKey) + override fun equals(other: Any?): Boolean = + other is ReconnectAuthData && + sessionId == other.sessionId && + sessionKey.contentEquals(other.sessionKey) - override fun hashCode(): Int = sessionId.hashCode() * 31 + sessionKey.contentHashCode() + override fun hashCode(): Int = sessionId.hashCode() * 31 + sessionKey.contentHashCode() } data class NewAuthData(val userId: Int, val sessionKey: ByteArray) : GameAuthenticationData() { - override fun equals(other: Any?): Boolean = - other is NewAuthData && userId == other.userId && sessionKey.contentEquals(other.sessionKey) + override fun equals(other: Any?): Boolean = + other is NewAuthData && userId == other.userId && sessionKey.contentEquals(other.sessionKey) - override fun hashCode(): Int = userId * 31 + sessionKey.contentHashCode() + override fun hashCode(): Int = userId * 31 + sessionKey.contentHashCode() } data class JoinPacket( @@ -58,70 +43,70 @@ data class JoinPacket( val unk1: ByteArray, val unk2: ByteArray, ) { - override fun equals(other: Any?): Boolean = - other is JoinPacket && - authData == other.authData && - mac.contentEquals(other.mac) && - clientRevision == other.clientRevision && - installationRevision == other.installationRevision && - currentChatLanguage == other.currentChatLanguage && - chatLanguages == other.chatLanguages && - matchmakingLanguages == other.matchmakingLanguages && - romMask == other.romMask && - roms == other.roms && - clientInfo == other.clientInfo && - platform == other.platform && - arch == other.arch && - bitness == other.bitness && - unk1.contentEquals(other.unk1) && - unk2.contentEquals(other.unk2) + override fun equals(other: Any?): Boolean = + other is JoinPacket && + authData == other.authData && + mac.contentEquals(other.mac) && + clientRevision == other.clientRevision && + installationRevision == other.installationRevision && + currentChatLanguage == other.currentChatLanguage && + chatLanguages == other.chatLanguages && + matchmakingLanguages == other.matchmakingLanguages && + romMask == other.romMask && + roms == other.roms && + clientInfo == other.clientInfo && + platform == other.platform && + arch == other.arch && + bitness == other.bitness && + unk1.contentEquals(other.unk1) && + unk2.contentEquals(other.unk2) - override fun hashCode(): Int { - var r = authData.hashCode() - r = r * 31 + mac.contentHashCode() - r = r * 31 + clientRevision - r = r * 31 + installationRevision - r = r * 31 + currentChatLanguage - r = r * 31 + chatLanguages - r = r * 31 + matchmakingLanguages - r = r * 31 + romMask - r = r * 31 + roms.hashCode() - r = r * 31 + clientInfo.hashCode() - r = r * 31 + platform.hashCode() - r = r * 31 + arch.hashCode() - r = r * 31 + bitness.hashCode() - r = r * 31 + unk1.contentHashCode() - r = r * 31 + unk2.contentHashCode() - return r - } + override fun hashCode(): Int { + var r = authData.hashCode() + r = r * 31 + mac.contentHashCode() + r = r * 31 + clientRevision + r = r * 31 + installationRevision + r = r * 31 + currentChatLanguage + r = r * 31 + chatLanguages + r = r * 31 + matchmakingLanguages + r = r * 31 + romMask + r = r * 31 + roms.hashCode() + r = r * 31 + clientInfo.hashCode() + r = r * 31 + platform.hashCode() + r = r * 31 + arch.hashCode() + r = r * 31 + bitness.hashCode() + r = r * 31 + unk1.contentHashCode() + r = r * 31 + unk2.contentHashCode() + return r + } } private val SessionKey = bytesPrefixed(U8) private object NewAuthDataCodec : PacketCodec() { - override fun CodecScope.body(): NewAuthData { - val userId = field(S32LE) { it.userId } - val sessionKey = field(SessionKey) { it.sessionKey } - return NewAuthData(userId, sessionKey) - } + override fun CodecScope.body(): NewAuthData { + val userId = field(S32LE) { it.userId } + val sessionKey = field(SessionKey) { it.sessionKey } + return NewAuthData(userId, sessionKey) + } } private object ReconnectAuthDataCodec : PacketCodec() { - override fun CodecScope.body(): ReconnectAuthData { - val sessionId = field(S64LE) { it.sessionId } - val sessionKey = field(SessionKey) { it.sessionKey } - return ReconnectAuthData(sessionId, sessionKey) - } + override fun CodecScope.body(): ReconnectAuthData { + val sessionId = field(S64LE) { it.sessionId } + val sessionKey = field(SessionKey) { it.sessionKey } + return ReconnectAuthData(sessionId, sessionKey) + } } private val AuthDataCodec: Codec = choose( tag = U8, identify = { data -> - when (data) { - is NewAuthData -> 0x00 - is ReconnectAuthData -> 0x01 - } + when (data) { + is NewAuthData -> 0x00 + is ReconnectAuthData -> 0x01 + } }, 0x00 to NewAuthDataCodec, 0x01 to ReconnectAuthDataCodec, @@ -131,14 +116,14 @@ private val PlatformCodec: Codec = U8.imap( decode = { Platform.from(it) }, encode = { p -> - when (p) { - Platform.WINDOWS -> 0x00 - Platform.LINUX -> 0x01 - Platform.MACOS -> 0x02 - Platform.IOS -> 0x03 - Platform.ANDROID -> 0x04 - Platform.UNKNOWN -> 0xFF - } + when (p) { + Platform.WINDOWS -> 0x00 + Platform.LINUX -> 0x01 + Platform.MACOS -> 0x02 + Platform.IOS -> 0x03 + Platform.ANDROID -> 0x04 + Platform.UNKNOWN -> 0xFF + } }, ) @@ -147,12 +132,12 @@ private val BitnessCodec: Codec = enumByOrdinalByte() private val RomInfoCodec: Codec = object : PacketCodec() { - override fun CodecScope.body(): RomInfo { - val code = field(Utf16LeNullTerminated) { it.code } - val id = field(S8) { it.id } - val type = field(S8) { it.type } - return RomInfo(code, id, type) - } + override fun CodecScope.body(): RomInfo { + val code = field(Utf16LeNullTerminated) { it.code } + val id = field(S8) { it.id } + val type = field(S8) { it.type } + return RomInfo(code, id, type) + } } private val ClientInfoEntryCodec: Codec> = S8.then(Utf16LeNullTerminated) @@ -166,38 +151,38 @@ private val Unk1Bytes = bytesPrefixed(U8) private val Unk2Bytes = fixedBytes(32) object JoinPacketCodec : PacketCodec() { - override fun CodecScope.body(): JoinPacket { - val authData = field(AuthDataCodec) { it.authData } - val mac = field(MacBytes) { it.mac } - val clientRevision = field(S32LE) { it.clientRevision } - val installationRevision = field(S32LE) { it.installationRevision } - val currentChatLanguage = field(S8) { it.currentChatLanguage } - val chatLanguages = field(S16LE) { it.chatLanguages } - val matchmakingLanguages = field(S16LE) { it.matchmakingLanguages } - val romMask = field(S8) { it.romMask } - val roms = field(RomInfoCodec.listPrefixed(U8)) { it.roms } - val clientInfo = field(ClientInfoMapCodec) { it.clientInfo } - val platform = field(PlatformCodec) { it.platform } - val arch = field(ArchCodec) { it.arch } - val bitness = field(BitnessCodec) { it.bitness } - val unk1 = field(Unk1Bytes) { it.unk1 } - val unk2 = field(Unk2Bytes) { it.unk2 } - return JoinPacket( - authData = authData, - mac = mac, - clientRevision = clientRevision, - installationRevision = installationRevision, - currentChatLanguage = currentChatLanguage, - chatLanguages = chatLanguages, - matchmakingLanguages = matchmakingLanguages, - romMask = romMask, - roms = roms, - clientInfo = clientInfo, - platform = platform, - arch = arch, - bitness = bitness, - unk1 = unk1, - unk2 = unk2, - ) - } + override fun CodecScope.body(): JoinPacket { + val authData = field(AuthDataCodec) { it.authData } + val mac = field(MacBytes) { it.mac } + val clientRevision = field(S32LE) { it.clientRevision } + val installationRevision = field(S32LE) { it.installationRevision } + val currentChatLanguage = field(S8) { it.currentChatLanguage } + val chatLanguages = field(S16LE) { it.chatLanguages } + val matchmakingLanguages = field(S16LE) { it.matchmakingLanguages } + val romMask = field(S8) { it.romMask } + val roms = field(RomInfoCodec.listPrefixed(U8)) { it.roms } + val clientInfo = field(ClientInfoMapCodec) { it.clientInfo } + val platform = field(PlatformCodec) { it.platform } + val arch = field(ArchCodec) { it.arch } + val bitness = field(BitnessCodec) { it.bitness } + val unk1 = field(Unk1Bytes) { it.unk1 } + val unk2 = field(Unk2Bytes) { it.unk2 } + return JoinPacket( + authData = authData, + mac = mac, + clientRevision = clientRevision, + installationRevision = installationRevision, + currentChatLanguage = currentChatLanguage, + chatLanguages = chatLanguages, + matchmakingLanguages = matchmakingLanguages, + romMask = romMask, + roms = roms, + clientInfo = clientInfo, + platform = platform, + arch = arch, + bitness = bitness, + unk1 = unk1, + unk2 = unk2, + ) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/JoinResponsePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/JoinResponsePacket.kt index 28d1653..bb0c5e8 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/JoinResponsePacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/JoinResponsePacket.kt @@ -1,12 +1,6 @@ package de.fiereu.openmmo.net.game.packets -import de.fiereu.bytecodec.Bool -import de.fiereu.bytecodec.CodecScope -import de.fiereu.bytecodec.MalformedPacketException -import de.fiereu.bytecodec.PacketCodec -import de.fiereu.bytecodec.S32LE -import de.fiereu.bytecodec.S8 -import de.fiereu.bytecodec.Utf16LeNullTerminated +import de.fiereu.bytecodec.* import java.time.LocalDate import java.time.ZoneId @@ -15,26 +9,26 @@ data class JoinResponsePacket( val stats: GameStats? = null, val time: TimeInfo? = null, ) { - data class GameStats(val playtime: Int, val rewardPoints: Int, val balance: Int) + data class GameStats(val playtime: Int, val rewardPoints: Int, val balance: Int) - data class TimeInfo(val serverDayStartSecond: Int, val serverCurrentSecond: Int) + data class TimeInfo(val serverDayStartSecond: Int, val serverCurrentSecond: Int) - companion object { - fun reject(): JoinResponsePacket = JoinResponsePacket(false) + companion object { + fun reject(): JoinResponsePacket = JoinResponsePacket(false) - fun accept(stats: GameStats, time: TimeInfo? = null): JoinResponsePacket = - JoinResponsePacket(true, stats, time) + fun accept(stats: GameStats, time: TimeInfo? = null): JoinResponsePacket = + JoinResponsePacket(true, stats, time) - fun acceptNow(playtime: Int, rewardPoints: Int, balance: Int): JoinResponsePacket { - val dayStart = LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toEpochSecond().toInt() - val now = (System.currentTimeMillis() / 1000).toInt() - return JoinResponsePacket( - canJoin = true, - stats = GameStats(playtime, rewardPoints, balance), - time = TimeInfo(dayStart, now), - ) + fun acceptNow(playtime: Int, rewardPoints: Int, balance: Int): JoinResponsePacket { + val dayStart = LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toEpochSecond().toInt() + val now = (System.currentTimeMillis() / 1000).toInt() + return JoinResponsePacket( + canJoin = true, + stats = GameStats(playtime, rewardPoints, balance), + time = TimeInfo(dayStart, now), + ) + } } - } } private fun nowTimeInfo(): JoinResponsePacket.TimeInfo = @@ -45,31 +39,31 @@ private fun nowTimeInfo(): JoinResponsePacket.TimeInfo = ) object JoinResponsePacketCodec : PacketCodec() { - override fun CodecScope.body(): JoinResponsePacket { - val canJoin = field(Bool, JoinResponsePacket::canJoin) - if (!canJoin) return JoinResponsePacket(false) - field(Utf16LeNullTerminated) { "" } - field(S8) { 0 } - val playtime = - field(S32LE) { - (it.stats - ?: throw MalformedPacketException("stats must be provided when canJoin is true")) - .playtime - } - val rewardPoints = field(S32LE) { it.stats!!.rewardPoints } - val balance = field(S32LE) { it.stats!!.balance } - var resolvedTime: JoinResponsePacket.TimeInfo? = null - val dayStart = - field(S32LE) { - val t = it.time ?: nowTimeInfo() - resolvedTime = t - t.serverDayStartSecond - } - val now = field(S32LE) { resolvedTime!!.serverCurrentSecond } - return JoinResponsePacket( - canJoin = true, - stats = JoinResponsePacket.GameStats(playtime, rewardPoints, balance), - time = JoinResponsePacket.TimeInfo(dayStart, now), - ) - } + override fun CodecScope.body(): JoinResponsePacket { + val canJoin = field(Bool, JoinResponsePacket::canJoin) + if (!canJoin) return JoinResponsePacket(false) + field(Utf16LeNullTerminated) { "" } + field(S8) { 0 } + val playtime = + field(S32LE) { + (it.stats + ?: throw MalformedPacketException("stats must be provided when canJoin is true")) + .playtime + } + val rewardPoints = field(S32LE) { it.stats!!.rewardPoints } + val balance = field(S32LE) { it.stats!!.balance } + var resolvedTime: JoinResponsePacket.TimeInfo? = null + val dayStart = + field(S32LE) { + val t = it.time ?: nowTimeInfo() + resolvedTime = t + t.serverDayStartSecond + } + val now = field(S32LE) { resolvedTime!!.serverCurrentSecond } + return JoinResponsePacket( + canJoin = true, + stats = JoinResponsePacket.GameStats(playtime, rewardPoints, balance), + time = JoinResponsePacket.TimeInfo(dayStart, now), + ) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/KeepAlivePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/KeepAlivePacket.kt index d391c55..eeae76a 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/KeepAlivePacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/KeepAlivePacket.kt @@ -1,38 +1,33 @@ 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.WriteBuffer +import de.fiereu.bytecodec.* data class KeepAlivePacket(val canJoin: Boolean, val sessionData: ByteArray) { - override fun equals(other: Any?): Boolean = - other is KeepAlivePacket && - canJoin == other.canJoin && - sessionData.contentEquals(other.sessionData) + override fun equals(other: Any?): Boolean = + other is KeepAlivePacket && + canJoin == other.canJoin && + sessionData.contentEquals(other.sessionData) - override fun hashCode(): Int = canJoin.hashCode() * 31 + sessionData.contentHashCode() + override fun hashCode(): Int = canJoin.hashCode() * 31 + sessionData.contentHashCode() } private val KeepAliveSessionDataBytes: Codec = object : Codec { - override fun read(buf: ReadBuffer): ByteArray { - val data = ByteArray(buf.remaining()) - if (data.isNotEmpty()) buf.readBytes(data) - return data - } + override fun read(buf: ReadBuffer): ByteArray { + val data = ByteArray(buf.remaining()) + if (data.isNotEmpty()) buf.readBytes(data) + return data + } - override fun write(buf: WriteBuffer, value: ByteArray) { - if (value.isNotEmpty()) buf.writeBytes(value) - } + override fun write(buf: WriteBuffer, value: ByteArray) { + if (value.isNotEmpty()) buf.writeBytes(value) + } } object KeepAlivePacketCodec : PacketCodec() { - override fun CodecScope.body() = - KeepAlivePacket( - canJoin = field(Bool, KeepAlivePacket::canJoin), - sessionData = field(KeepAliveSessionDataBytes, KeepAlivePacket::sessionData), - ) + override fun CodecScope.body() = + KeepAlivePacket( + canJoin = field(Bool, KeepAlivePacket::canJoin), + sessionData = field(KeepAliveSessionDataBytes, KeepAlivePacket::sessionData), + ) } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LeaderboardViewRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LeaderboardViewRequestPacket.kt new file mode 100644 index 0000000..8c7d52a --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LeaderboardViewRequestPacket.kt @@ -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 LeaderboardViewRequestPacket( + val categoryId: Byte, +) + +object LeaderboardViewRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): LeaderboardViewRequestPacket { + val categoryId = field(S8) { it.categoryId } + return LeaderboardViewRequestPacket(categoryId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LearnedMovesetPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LearnedMovesetPacket.kt new file mode 100644 index 0000000..3f6cc57 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LearnedMovesetPacket.kt @@ -0,0 +1,66 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class LearnedMoveAppearance( + val name: String, + val gender: Byte, + val formId: Int, + val kind: Byte, + val palettePack: Byte, + val slots: List, +) + +data class LearnedMoveSlot( + val moveId: Short, + val sourceId: Long?, + val appearance: LearnedMoveAppearance?, +) + +data class LearnedMovesetPacket( + val moves: List, +) + +private object LearnedMoveAppearanceCodec : PacketCodec() { + override fun CodecScope.body(): LearnedMoveAppearance { + val name = field(Utf16LeNullTerminated, LearnedMoveAppearance::name) + val gender = field(S8, LearnedMoveAppearance::gender) + val formId = field(S32LE, LearnedMoveAppearance::formId) + val kind = field(S8, LearnedMoveAppearance::kind) + val palettePack = field(S8, LearnedMoveAppearance::palettePack) + val slots = field(S16LE.repeat(4), LearnedMoveAppearance::slots) + return LearnedMoveAppearance(name, gender, formId, kind, palettePack, slots) + } +} + +private object LearnedMoveSlotCodec : PacketCodec() { + override fun CodecScope.body(): LearnedMoveSlot { + val moveId = field(S16LE, LearnedMoveSlot::moveId) + if (moveId < 0) { + return LearnedMoveSlot(moveId, null, null) + } + val sourceId = field(S64LE) { it.sourceId!! } + val appearance = field(LearnedMoveAppearanceCodec) { it.appearance!! } + return LearnedMoveSlot(moveId, sourceId, appearance) + } +} + +private val LearnedMoveSlotListPrefixedU8: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { LearnedMoveSlotCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { LearnedMoveSlotCodec.write(buf, it) } + } + } + +object LearnedMovesetPacketCodec : PacketCodec() { + override fun CodecScope.body(): LearnedMovesetPacket { + val moves = field(LearnedMoveSlotListPrefixedU8, LearnedMovesetPacket::moves) + return LearnedMovesetPacket(moves) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LeaveBattlePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LeaveBattlePacket.kt new file mode 100644 index 0000000..9218643 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LeaveBattlePacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec + +class LeaveBattlePacket + +object LeaveBattlePacketCodec : PacketCodec() { + override fun CodecScope.body(): LeaveBattlePacket { + return LeaveBattlePacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LeaveChatChannelPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LeaveChatChannelPacket.kt new file mode 100644 index 0000000..dad660c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LeaveChatChannelPacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec + +class LeaveChatChannelPacket + +object LeaveChatChannelPacketCodec : PacketCodec() { + override fun CodecScope.body(): LeaveChatChannelPacket { + return LeaveChatChannelPacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LeaveMatchmakingQueuePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LeaveMatchmakingQueuePacket.kt new file mode 100644 index 0000000..fc6648e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LeaveMatchmakingQueuePacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec + +class LeaveMatchmakingQueuePacket + +object LeaveMatchmakingQueuePacketCodec : PacketCodec() { + override fun CodecScope.body(): LeaveMatchmakingQueuePacket { + return LeaveMatchmakingQueuePacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LinkKickMemberPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LinkKickMemberPacket.kt new file mode 100644 index 0000000..745e366 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LinkKickMemberPacket.kt @@ -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 LinkKickMemberPacket( + val targetEntityId: Long, +) + +object LinkKickMemberPacketCodec : PacketCodec() { + override fun CodecScope.body(): LinkKickMemberPacket { + val targetEntityId = field(S64LE) { it.targetEntityId } + return LinkKickMemberPacket(targetEntityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ListWindowPagePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ListWindowPagePacket.kt new file mode 100644 index 0000000..a6525fa --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ListWindowPagePacket.kt @@ -0,0 +1,54 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class ListWindowRow( + val rowType: Byte, + val valueA: Short, + val valueB: Short, + val valueC: Short, + val valueD: Short, + val valueE: Short, + val label: String, + val valueF: Short, +) + +data class ListWindowPagePacket( + val windowId: Int, + val firstPage: Boolean, + val lastPage: Boolean, + val headerA: Byte, + val headerB: Byte, + val headerC: Byte, + val rows: List, +) + +private val ListWindowRowCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): ListWindowRow { + val rowType = field(S8) { it.rowType } + val valueA = field(S16LE) { it.valueA } + val valueB = field(S16LE) { it.valueB } + val valueC = field(S16LE) { it.valueC } + val valueD = field(S16LE) { it.valueD } + val valueE = field(S16LE) { it.valueE } + val label = field(Utf16LeNullTerminated) { it.label } + val valueF = field(S16LE) { it.valueF } + return ListWindowRow(rowType, valueA, valueB, valueC, valueD, valueE, label, valueF) + } + } + +object ListWindowPagePacketCodec : PacketCodec() { + override fun CodecScope.body(): ListWindowPagePacket { + val windowId = field(S32LE) { it.windowId } + val firstPage = field(U8) { if (it.firstPage) 1 else 0 } == 1 + val lastPage = field(U8) { if (it.lastPage) 1 else 0 } == 1 + val headerA = field(S8) { it.headerA } + val headerB = field(S8) { it.headerB } + val headerC = field(S8) { it.headerC } + val rows = field(ListWindowRowCodec.listPrefixed(U16LE)) { it.rows } + return ListWindowPagePacket( + windowId, firstPage, lastPage, headerA, headerB, headerC, rows + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LoadEntityPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LoadEntityPacket.kt index 5a46f3b..4750d22 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LoadEntityPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LoadEntityPacket.kt @@ -1,15 +1,6 @@ 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.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.reserved +import de.fiereu.bytecodec.* import de.fiereu.openmmo.common.enums.Direction import de.fiereu.openmmo.common.enums.EntityStatus import de.fiereu.openmmo.net.game.codecs.DefaultSkinSetCodec @@ -34,49 +25,49 @@ data class LoadEntityPacket( ) object LoadEntityPacketCodec : PacketCodec() { - override fun CodecScope.body(): LoadEntityPacket { - val entityId = field(S64LE, LoadEntityPacket::entityId) - reserved(byte = 0) - val skin = field(DefaultSkinSetCodec, LoadEntityPacket::skin) - val name = field(Utf16LeNullTerminated, LoadEntityPacket::name) - val regionId = field(U8, LoadEntityPacket::regionId) - val bankId = field(U8, LoadEntityPacket::bankId) - val mapId = field(U8, LoadEntityPacket::mapId) - val x = field(S16LE) { it.x.toShort() }.toInt() - val y = field(S16LE) { it.y.toShort() }.toInt() - val z = field(U8, LoadEntityPacket::z) - val facing = Direction.entries[field(U8) { it.facing.ordinal }] - val transportation = field(U8, LoadEntityPacket::transportation) - val entityNameplateType = field(U8, LoadEntityPacket::entityNameplateType) - val flags = field(U16LE) { if (it.hasFollower) 0x04 else 0 } - if (flags and 0x01 != 0) field(S8) { 0 } - if (flags and 0x02 != 0) { - field(S8) { 0 } - field(U16LE) { 0 } + override fun CodecScope.body(): LoadEntityPacket { + val entityId = field(S64LE, LoadEntityPacket::entityId) + reserved(byte = 0) + val skin = field(DefaultSkinSetCodec, LoadEntityPacket::skin) + val name = field(Utf16LeNullTerminated, LoadEntityPacket::name) + val regionId = field(U8, LoadEntityPacket::regionId) + val bankId = field(U8, LoadEntityPacket::bankId) + val mapId = field(U8, LoadEntityPacket::mapId) + val x = field(S16LE) { it.x.toShort() }.toInt() + val y = field(S16LE) { it.y.toShort() }.toInt() + val z = field(U8, LoadEntityPacket::z) + val facing = Direction.entries[field(U8) { it.facing.ordinal }] + val transportation = field(U8, LoadEntityPacket::transportation) + val entityNameplateType = field(U8, LoadEntityPacket::entityNameplateType) + val flags = field(U16LE) { if (it.hasFollower) 0x04 else 0 } + if (flags and 0x01 != 0) field(S8) { 0 } + if (flags and 0x02 != 0) { + field(S8) { 0 } + field(U16LE) { 0 } + } + val hasFollower = (flags and 0x04) != 0 + val followerDexId: Short = if (hasFollower) field(S16LE, LoadEntityPacket::followerDexId) else 0 + if (flags and 0x08 != 0) field(S8) { 0 } + if (flags and 0x10 != 0) { + field(S32LE) { 0 } + field(Utf16LeNullTerminated) { "" } + } + return LoadEntityPacket( + entityId = entityId, + skin = skin, + name = name, + regionId = regionId, + bankId = bankId, + mapId = mapId, + x = x, + y = y, + z = z, + facing = facing, + transportation = transportation, + entityNameplateType = entityNameplateType, + status = EntityStatus.NONE, + hasFollower = hasFollower, + followerDexId = followerDexId, + ) } - val hasFollower = (flags and 0x04) != 0 - val followerDexId: Short = if (hasFollower) field(S16LE, LoadEntityPacket::followerDexId) else 0 - if (flags and 0x08 != 0) field(S8) { 0 } - if (flags and 0x10 != 0) { - field(S32LE) { 0 } - field(Utf16LeNullTerminated) { "" } - } - return LoadEntityPacket( - entityId = entityId, - skin = skin, - name = name, - regionId = regionId, - bankId = bankId, - mapId = mapId, - x = x, - y = y, - z = z, - facing = facing, - transportation = transportation, - entityNameplateType = entityNameplateType, - status = EntityStatus.NONE, - hasFollower = hasFollower, - followerDexId = followerDexId, - ) - } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LoadMapPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LoadMapPacket.kt index 003debf..a508125 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LoadMapPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LoadMapPacket.kt @@ -1,18 +1,6 @@ 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.MalformedPacketException -import de.fiereu.bytecodec.PacketCodec -import de.fiereu.bytecodec.ReadBuffer -import de.fiereu.bytecodec.S16LE -import de.fiereu.bytecodec.S32LE -import de.fiereu.bytecodec.S64LE -import de.fiereu.bytecodec.S8 -import de.fiereu.bytecodec.U8 -import de.fiereu.bytecodec.Utf16LeNullTerminated -import de.fiereu.bytecodec.WriteBuffer +import de.fiereu.bytecodec.* import de.fiereu.openmmo.common.Tile2D import de.fiereu.openmmo.common.enums.EncounterType import de.fiereu.openmmo.common.enums.Lighting @@ -23,39 +11,39 @@ import de.fiereu.openmmo.common.utils.isNdsRegion import de.fiereu.openmmo.net.game.codecs.Tile2DCodec sealed interface MapData { - data class NdsMapData(val lighting: Lighting, val weather: Weather, val mapType: MapType) : - MapData + data class NdsMapData(val lighting: Lighting, val weather: Weather, val mapType: MapType) : + MapData - data class GbaConnection( - val direction: Int, - val unknown: Int, - val targetBank: Int, - val targetMap: Int, - ) + data class GbaConnection( + val direction: Int, + val unknown: Int, + val targetBank: Int, + val targetMap: Int, + ) - data class GbaMapData( - val width: Int, - val height: Int, - val paletteIdx1: Int, - val paletteIdx2: Int, - val borderWidth: Int, - val borderHeight: Int, - val unknownShort: Int = 0, - val unknownByte: Int = 0, - val borderTiles: List, - val lighting: Lighting, - val weather: Weather, - val mapType: MapType, - val encounterType: EncounterType, - val connections: List = emptyList(), - ) : MapData { - init { - require(borderWidth * borderHeight == borderTiles.size) { - "borderTiles size doesnt match dimensions" - } - require(borderWidth * borderHeight > 0) { "BorderWidth & Height must be greater than zero" } + data class GbaMapData( + val width: Int, + val height: Int, + val paletteIdx1: Int, + val paletteIdx2: Int, + val borderWidth: Int, + val borderHeight: Int, + val unknownShort: Int = 0, + val unknownByte: Int = 0, + val borderTiles: List, + val lighting: Lighting, + val weather: Weather, + val mapType: MapType, + val encounterType: EncounterType, + val connections: List = emptyList(), + ) : MapData { + init { + require(borderWidth * borderHeight == borderTiles.size) { + "borderTiles size doesnt match dimensions" + } + require(borderWidth * borderHeight > 0) { "BorderWidth & Height must be greater than zero" } + } } - } } data class LoadMapPacket( @@ -66,126 +54,126 @@ data class LoadMapPacket( val mapId: Int, val mapData: MapData, ) { - init { - when (mapData) { - is MapData.NdsMapData -> require(isNdsRegion(regionId)) { "MapData is invalid" } - is MapData.GbaMapData -> require(!isNdsRegion(regionId)) { "MapData is invalid" } + init { + when (mapData) { + is MapData.NdsMapData -> require(isNdsRegion(regionId)) { "MapData is invalid" } + is MapData.GbaMapData -> require(!isNdsRegion(regionId)) { "MapData is invalid" } + } } - } } private object GbaConnectionCodec : PacketCodec() { - override fun CodecScope.body() = - MapData.GbaConnection( - direction = field(U8, MapData.GbaConnection::direction), - unknown = field(S32LE, MapData.GbaConnection::unknown), - targetBank = field(U8, MapData.GbaConnection::targetBank), - targetMap = field(U8, MapData.GbaConnection::targetMap), - ) + override fun CodecScope.body() = + MapData.GbaConnection( + direction = field(U8, MapData.GbaConnection::direction), + unknown = field(S32LE, MapData.GbaConnection::unknown), + targetBank = field(U8, MapData.GbaConnection::targetBank), + targetMap = field(U8, MapData.GbaConnection::targetMap), + ) } private val GbaConnectionListPrefixedU8: Codec> = object : Codec> { - override fun read(buf: ReadBuffer): List { - val n = U8.read(buf) - return List(n) { GbaConnectionCodec.read(buf) } - } + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { GbaConnectionCodec.read(buf) } + } - override fun write(buf: WriteBuffer, value: List) { - U8.write(buf, value.size) - value.forEach { GbaConnectionCodec.write(buf, it) } - } + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { GbaConnectionCodec.write(buf, it) } + } } object LoadMapPacketCodec : PacketCodec() { - override fun CodecScope.body(): LoadMapPacket { - val flags = - field(U8) { - var f = 0 - if (it.deleteCache) f = f or 1 - if (it.reloadPlayer) f = f or 2 - f - } - val deleteCache = (flags and 1) != 0 - val reloadPlayer = (flags and 2) != 0 - val regionId = field(U8, LoadMapPacket::regionId) - val bankId = field(U8, LoadMapPacket::bankId) - val mapId = field(U8, LoadMapPacket::mapId) - field(S8) { 0 } - val mapData: MapData = - if (isNdsRegion(regionId)) { - field(S16LE) { 0 } - field(U8) { 0 } - val lighting = - Lighting.entries[field(U8) { (it.mapData as MapData.NdsMapData).lighting.ordinal }] - val weather = - Weather.entries[field(U8) { (it.mapData as MapData.NdsMapData).weather.ordinal }] - val mapType = - MapType.entries[field(U8) { (it.mapData as MapData.NdsMapData).mapType.ordinal }] - MapData.NdsMapData(lighting, weather, mapType) - } else { - val getGba: (LoadMapPacket) -> MapData.GbaMapData = { - it.mapData as? MapData.GbaMapData - ?: throw MalformedPacketException("expected GbaMapData for region $regionId") - } - val width = field(S32LE) { getGba(it).width } - val height = field(S32LE) { getGba(it).height } - val paletteIdx1 = field(S32LE) { getGba(it).paletteIdx1 } - val paletteIdx2 = field(S32LE) { getGba(it).paletteIdx2 } - val borderWidth = field(U8) { getGba(it).borderWidth } - val borderHeight = field(U8) { getGba(it).borderHeight } - val unknownShort = field(S16LE) { getGba(it).unknownShort.toShort() }.toInt() - val unknownByte = field(U8) { getGba(it).unknownByte } - val lighting = Lighting.entries[field(U8) { getGba(it).lighting.ordinal }] - val weather = Weather.entries[field(U8) { getGba(it).weather.ordinal }] - val mapType = MapType.entries[field(U8) { getGba(it).mapType.ordinal }] - val encounterType = EncounterType.entries[field(U8) { getGba(it).encounterType.ordinal }] - val borderTiles = - List(borderWidth * borderHeight) { - field(Tile2DCodec) { entry -> getGba(entry).borderTiles[it] } - } - val hasCompressed = field(Bool) { false } - if (hasCompressed) { - val size = field(S32LE) { 0 } - val compressed = field(FixedReadBytes(size)) { ByteArray(0) } - compressed.gzipDecompress() - } - val connections = field(GbaConnectionListPrefixedU8) { getGba(it).connections } - val hasTrailer = field(Bool) { false } - if (hasTrailer) { - field(S64LE) { 0L } - field(Utf16LeNullTerminated) { "" } - } - MapData.GbaMapData( - width = width, - height = height, - paletteIdx1 = paletteIdx1, - paletteIdx2 = paletteIdx2, - borderWidth = borderWidth, - borderHeight = borderHeight, - unknownShort = unknownShort, - unknownByte = unknownByte, - borderTiles = borderTiles, - lighting = lighting, - weather = weather, - mapType = mapType, - encounterType = encounterType, - connections = connections, - ) - } - return LoadMapPacket(reloadPlayer, deleteCache, regionId, bankId, mapId, mapData) - } + override fun CodecScope.body(): LoadMapPacket { + val flags = + field(U8) { + var f = 0 + if (it.deleteCache) f = f or 1 + if (it.reloadPlayer) f = f or 2 + f + } + val deleteCache = (flags and 1) != 0 + val reloadPlayer = (flags and 2) != 0 + val regionId = field(U8, LoadMapPacket::regionId) + val bankId = field(U8, LoadMapPacket::bankId) + val mapId = field(U8, LoadMapPacket::mapId) + field(S8) { 0 } + val mapData: MapData = + if (isNdsRegion(regionId)) { + field(S16LE) { 0 } + field(U8) { 0 } + val lighting = + Lighting.entries[field(U8) { (it.mapData as MapData.NdsMapData).lighting.ordinal }] + val weather = + Weather.entries[field(U8) { (it.mapData as MapData.NdsMapData).weather.ordinal }] + val mapType = + MapType.entries[field(U8) { (it.mapData as MapData.NdsMapData).mapType.ordinal }] + MapData.NdsMapData(lighting, weather, mapType) + } else { + val getGba: (LoadMapPacket) -> MapData.GbaMapData = { + it.mapData as? MapData.GbaMapData + ?: throw MalformedPacketException("expected GbaMapData for region $regionId") + } + val width = field(S32LE) { getGba(it).width } + val height = field(S32LE) { getGba(it).height } + val paletteIdx1 = field(S32LE) { getGba(it).paletteIdx1 } + val paletteIdx2 = field(S32LE) { getGba(it).paletteIdx2 } + val borderWidth = field(U8) { getGba(it).borderWidth } + val borderHeight = field(U8) { getGba(it).borderHeight } + val unknownShort = field(S16LE) { getGba(it).unknownShort.toShort() }.toInt() + val unknownByte = field(U8) { getGba(it).unknownByte } + val lighting = Lighting.entries[field(U8) { getGba(it).lighting.ordinal }] + val weather = Weather.entries[field(U8) { getGba(it).weather.ordinal }] + val mapType = MapType.entries[field(U8) { getGba(it).mapType.ordinal }] + val encounterType = EncounterType.entries[field(U8) { getGba(it).encounterType.ordinal }] + val borderTiles = + List(borderWidth * borderHeight) { + field(Tile2DCodec) { entry -> getGba(entry).borderTiles[it] } + } + val hasCompressed = field(Bool) { false } + if (hasCompressed) { + val size = field(S32LE) { 0 } + val compressed = field(FixedReadBytes(size)) { ByteArray(0) } + compressed.gzipDecompress() + } + val connections = field(GbaConnectionListPrefixedU8) { getGba(it).connections } + val hasTrailer = field(Bool) { false } + if (hasTrailer) { + field(S64LE) { 0L } + field(Utf16LeNullTerminated) { "" } + } + MapData.GbaMapData( + width = width, + height = height, + paletteIdx1 = paletteIdx1, + paletteIdx2 = paletteIdx2, + borderWidth = borderWidth, + borderHeight = borderHeight, + unknownShort = unknownShort, + unknownByte = unknownByte, + borderTiles = borderTiles, + lighting = lighting, + weather = weather, + mapType = mapType, + encounterType = encounterType, + connections = connections, + ) + } + return LoadMapPacket(reloadPlayer, deleteCache, regionId, bankId, mapId, mapData) + } } private fun FixedReadBytes(n: Int): Codec = object : Codec { - override fun read(buf: ReadBuffer): ByteArray { - val arr = ByteArray(n) - if (n > 0) buf.readBytes(arr) - return arr - } + override fun read(buf: ReadBuffer): ByteArray { + val arr = ByteArray(n) + if (n > 0) buf.readBytes(arr) + return arr + } - override fun write(buf: WriteBuffer, value: ByteArray) { - error("FixedReadBytes is read-only") - } + override fun write(buf: WriteBuffer, value: ByteArray) { + error("FixedReadBytes is read-only") + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LocalCharacterDeltaPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LocalCharacterDeltaPacket.kt new file mode 100644 index 0000000..ec879e5 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LocalCharacterDeltaPacket.kt @@ -0,0 +1,76 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class LocalCharacterDeltaPacket( + val mask: Short, + val money: Int?, + val mapId: Short?, + val mapFlag: Byte?, + val value4: Short?, + val value8a: Byte?, + val value8b: Byte?, + val value8c: Byte?, + val value16a: Short?, + val value16b: Short?, + val value32: Int?, + val value64Enum: Byte?, + val value64a: Short?, + val value64b: Short?, + val statusConditions: List?, + val value256: Byte?, +) + +object LocalCharacterDeltaPacketCodec : PacketCodec() { + override fun CodecScope.body(): LocalCharacterDeltaPacket { + val mask = field(S16LE) { it.mask } + val m = mask.toInt() + val money = if (m and 1 != 0) field(S32LE) { it.money!! } else null + val mapId = if (m and 2 != 0) field(S16LE) { it.mapId!! } else null + val mapFlag = if (m and 2 != 0) field(S8) { it.mapFlag!! } else null + val value4 = if (m and 4 != 0) field(S16LE) { it.value4!! } else null + val value8a = if (m and 8 != 0) field(S8) { it.value8a!! } else null + val value8b = if (m and 8 != 0) field(S8) { it.value8b!! } else null + val value8c = if (m and 8 != 0) field(S8) { it.value8c!! } else null + val value16a = if (m and 16 != 0) field(S16LE) { it.value16a!! } else null + val value16b = if (m and 16 != 0) field(S16LE) { it.value16b!! } else null + val value32 = if (m and 32 != 0) field(S32LE) { it.value32!! } else null + val value64Enum: Byte? + val value64a: Short? + val value64b: Short? + if (m and 64 != 0) { + value64Enum = field(S8) { it.value64Enum!! } + if (value64Enum.toInt() != 0) { + value64a = field(S16LE) { it.value64a!! } + value64b = field(S16LE) { it.value64b!! } + } else { + value64a = null + value64b = null + } + } else { + value64Enum = null + value64a = null + value64b = null + } + val statusConditions = if (m and 128 != 0) field(S8.listPrefixed(U8)) { it.statusConditions!! } else null + val value256 = if (m and 256 != 0) field(S8) { it.value256!! } else null + return LocalCharacterDeltaPacket( + mask = mask, + money = money, + mapId = mapId, + mapFlag = mapFlag, + value4 = value4, + value8a = value8a, + value8b = value8b, + value8c = value8c, + value16a = value16a, + value16b = value16b, + value32 = value32, + value64Enum = value64Enum, + value64a = value64a, + value64b = value64b, + statusConditions = statusConditions, + value256 = value256, + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LocalPlayerStatePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LocalPlayerStatePacket.kt new file mode 100644 index 0000000..43617c2 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/LocalPlayerStatePacket.kt @@ -0,0 +1,81 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class PlayerVariableEntry( + val key: Byte, + val value: Short, +) + +data class LocalPlayerStatePacket( + val region: Byte, + val mapId: Short, + val moveSpeed: Float, + val x: Short, + val y: Short, + val z: Short, + val money: Int, + val gender: Byte, + val skinTone: Short, + val hairColor: Short, + val playtime: Double, + val flags: Byte, + val partyDex: List, + val partyForms: List, + val pokedexSeen: List, + val pokedexCaught: List, + val badges: List, + val variables: List, +) + +private val PlayerVariableEntryCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): PlayerVariableEntry { + val key = field(S8) { it.key } + val value = field(S16LE) { it.value } + return PlayerVariableEntry(key, value) + } + } + +object LocalPlayerStatePacketCodec : PacketCodec() { + override fun CodecScope.body(): LocalPlayerStatePacket { + val region = field(S8) { it.region } + val mapId = field(S16LE) { it.mapId } + val moveSpeed = field(F32LE) { it.moveSpeed } + val x = field(S16LE) { it.x } + val y = field(S16LE) { it.y } + val z = field(S16LE) { it.z } + val money = field(S32LE) { it.money } + val gender = field(S8) { it.gender } + val skinTone = field(S16LE) { it.skinTone } + val hairColor = field(S16LE) { it.hairColor } + val playtime = field(F64LE) { it.playtime } + val flags = field(S8) { it.flags } + val partyDex = field(S16LE.listPrefixed(U16LE)) { it.partyDex } + val partyForms = field(S8.listPrefixed(U8)) { it.partyForms } + val pokedexSeen = field(S16LE.listPrefixed(U16LE)) { it.pokedexSeen } + val pokedexCaught = field(S16LE.listPrefixed(U16LE)) { it.pokedexCaught } + val badges = field(S16LE.listPrefixed(U8)) { it.badges } + val variables = field(PlayerVariableEntryCodec.listPrefixed(U16LE)) { it.variables } + return LocalPlayerStatePacket( + region, + mapId, + moveSpeed, + x, + y, + z, + money, + gender, + skinTone, + hairColor, + playtime, + flags, + partyDex, + partyForms, + pokedexSeen, + pokedexCaught, + badges, + variables, + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MailAttachmentRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MailAttachmentRequestPacket.kt new file mode 100644 index 0000000..feffccf --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MailAttachmentRequestPacket.kt @@ -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 MailAttachmentRequestPacket( + val targetId: Long, +) + +object MailAttachmentRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): MailAttachmentRequestPacket { + val targetId = field(S64LE) { it.targetId } + return MailAttachmentRequestPacket(targetId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MailComposeSendPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MailComposeSendPacket.kt new file mode 100644 index 0000000..5d73834 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MailComposeSendPacket.kt @@ -0,0 +1,60 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +sealed class MailAttachment { + abstract val typeByte: Byte +} + +data class ItemMailAttachment( + override val typeByte: Byte, + val itemId: Int, +) : MailAttachment() + +data class PokemonQuantityMailAttachment( + override val typeByte: Byte, + val pokemonEntityId: Long, + val quantity: Short, +) : MailAttachment() + +data class PokemonMailAttachment( + override val typeByte: Byte, + val pokemonEntityId: Long, +) : MailAttachment() + +private val MailAttachmentCodec: Codec = + object : Codec { + override fun read(buf: ReadBuffer): MailAttachment { + throw MalformedPacketException("MailComposeSendPacket is a client-encoded packet") + } + + override fun write(buf: WriteBuffer, value: MailAttachment) { + S8.write(buf, value.typeByte) + when (value) { + is ItemMailAttachment -> S32LE.write(buf, value.itemId) + is PokemonQuantityMailAttachment -> { + S64LE.write(buf, value.pokemonEntityId) + S16LE.write(buf, value.quantity) + } + + is PokemonMailAttachment -> S64LE.write(buf, value.pokemonEntityId) + } + } + } + +data class MailComposeSendPacket( + val recipientName: String, + val subject: String, + val body: String, + val attachments: List, +) + +object MailComposeSendPacketCodec : PacketCodec() { + override fun CodecScope.body(): MailComposeSendPacket { + val recipientName = field(Utf16LeNullTerminated) { it.recipientName } + val subject = field(Utf16LeNullTerminated) { it.subject } + val body = field(Utf16LeNullTerminated) { it.body } + val attachments = field(MailAttachmentCodec.listPrefixed(U8)) { it.attachments } + return MailComposeSendPacket(recipientName, subject, body, attachments) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapCellTilesetPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapCellTilesetPacket.kt new file mode 100644 index 0000000..b0f4602 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapCellTilesetPacket.kt @@ -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.S16LE +import de.fiereu.bytecodec.S8 + +data class MapCellTilesetPacket( + val chunkX: Byte, + val chunkY: Byte, + val chunkLevel: Byte, + val tilesetIndex: Short, +) + +object MapCellTilesetPacketCodec : PacketCodec() { + override fun CodecScope.body(): MapCellTilesetPacket { + val chunkX = field(S8) { it.chunkX } + val chunkY = field(S8) { it.chunkY } + val chunkLevel = field(S8) { it.chunkLevel } + val tilesetIndex = field(S16LE) { it.tilesetIndex } + return MapCellTilesetPacket(chunkX, chunkY, chunkLevel, tilesetIndex) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapLoadedAckPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapLoadedAckPacket.kt new file mode 100644 index 0000000..1184eda --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapLoadedAckPacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec + +class MapLoadedAckPacket + +object MapLoadedAckPacketCodec : PacketCodec() { + override fun CodecScope.body(): MapLoadedAckPacket { + return MapLoadedAckPacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapReadySignalPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapReadySignalPacket.kt new file mode 100644 index 0000000..297d6e6 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapReadySignalPacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec + +data class MapReadySignalPacket(val placeholder: Unit = Unit) + +object MapReadySignalPacketCodec : PacketCodec() { + override fun CodecScope.body(): MapReadySignalPacket { + return MapReadySignalPacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileAnimationTogglePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileAnimationTogglePacket.kt new file mode 100644 index 0000000..164cdf9 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileAnimationTogglePacket.kt @@ -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.U8 + +data class MapTileAnimationTogglePacket( + val x: Short, + val y: Short, + val enabled: Boolean, +) + +object MapTileAnimationTogglePacketCodec : PacketCodec() { + override fun CodecScope.body(): MapTileAnimationTogglePacket { + val x = field(S16LE) { it.x } + val y = field(S16LE) { it.y } + val enabled = field(U8) { if (it.enabled) 1 else 0 } == 1 + return MapTileAnimationTogglePacket(x, y, enabled) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileAttributeSetPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileAttributeSetPacket.kt new file mode 100644 index 0000000..116d76e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileAttributeSetPacket.kt @@ -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 MapTileAttributeSetPacket( + val blockX: Byte, + val blockY: Byte, + val blockZ: Byte, + val attribute: Byte, +) + +object MapTileAttributeSetPacketCodec : PacketCodec() { + override fun CodecScope.body(): MapTileAttributeSetPacket { + val blockX = field(S8) { it.blockX } + val blockY = field(S8) { it.blockY } + val blockZ = field(S8) { it.blockZ } + val attribute = field(S8) { it.attribute } + return MapTileAttributeSetPacket(blockX, blockY, blockZ, attribute) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileEntityStateSetPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileEntityStateSetPacket.kt new file mode 100644 index 0000000..a59886d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileEntityStateSetPacket.kt @@ -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.S16LE +import de.fiereu.bytecodec.S8 + +data class MapTileEntityStateSetPacket( + val mode: Byte, + val entityId: Short, + val value: Short, + val key: Short?, +) + +object MapTileEntityStateSetPacketCodec : PacketCodec() { + override fun CodecScope.body(): MapTileEntityStateSetPacket { + val mode = field(S8) { it.mode } + val entityId = field(S16LE) { it.entityId } + val value = field(S16LE) { it.value } + val key = if (mode.toInt() == 0) field(S16LE) { it.key!! } else null + return MapTileEntityStateSetPacket(mode, entityId, value, key) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileObjectRepositionPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileObjectRepositionPacket.kt new file mode 100644 index 0000000..8fd031c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileObjectRepositionPacket.kt @@ -0,0 +1,29 @@ +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 MapTileObjectRepositionPacket( + val chunkX: Byte, + val chunkY: Byte, + val chunkZ: Byte, + val tileX: Short, + val tileY: Short, + val tileZ: Byte, + val objectIndex: Byte, +) + +object MapTileObjectRepositionPacketCodec : PacketCodec() { + override fun CodecScope.body(): MapTileObjectRepositionPacket { + val chunkX = field(S8) { it.chunkX } + val chunkY = field(S8) { it.chunkY } + val chunkZ = field(S8) { it.chunkZ } + val tileX = field(S16LE) { it.tileX } + val tileY = field(S16LE) { it.tileY } + val tileZ = field(S8) { it.tileZ } + val objectIndex = field(S8) { it.objectIndex } + return MapTileObjectRepositionPacket(chunkX, chunkY, chunkZ, tileX, tileY, tileZ, objectIndex) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileObjectSlotSetPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileObjectSlotSetPacket.kt new file mode 100644 index 0000000..de475df --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTileObjectSlotSetPacket.kt @@ -0,0 +1,32 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class MapTileObjectSlotSetPacket( + val blockX: Byte, + val blockY: Byte, + val blockZ: Byte, + val slot: Byte, + val present: Boolean, + val objectX: Short?, + val objectY: Short?, + val objectZ: Byte?, + val relative: Boolean?, +) + +object MapTileObjectSlotSetPacketCodec : PacketCodec() { + override fun CodecScope.body(): MapTileObjectSlotSetPacket { + val blockX = field(S8) { it.blockX } + val blockY = field(S8) { it.blockY } + val blockZ = field(S8) { it.blockZ } + val slot = field(S8) { it.slot } + val present = field(U8) { if (it.present) 1 else 0 } == 1 + val objectX = if (present) field(S16LE) { it.objectX!! } else null + val objectY = if (present) field(S16LE) { it.objectY!! } else null + val objectZ = if (present) field(S8) { it.objectZ!! } else null + val relative = if (present) field(U8) { if (it.relative == true) 1 else 0 } == 1 else null + return MapTileObjectSlotSetPacket( + blockX, blockY, blockZ, slot, present, objectX, objectY, objectZ, relative + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTransitionPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTransitionPacket.kt index 6844d52..9d8a164 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTransitionPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapTransitionPacket.kt @@ -4,11 +4,11 @@ import de.fiereu.bytecodec.CodecScope import de.fiereu.bytecodec.PacketCodec class MapTransitionPacket { - override fun equals(other: Any?): Boolean = other is MapTransitionPacket + override fun equals(other: Any?): Boolean = other is MapTransitionPacket - override fun hashCode(): Int = MapTransitionPacket::class.hashCode() + override fun hashCode(): Int = MapTransitionPacket::class.hashCode() } object MapTransitionPacketCodec : PacketCodec() { - override fun CodecScope.body() = MapTransitionPacket() + override fun CodecScope.body() = MapTransitionPacket() } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapWeatherModeSetPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapWeatherModeSetPacket.kt new file mode 100644 index 0000000..1215925 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MapWeatherModeSetPacket.kt @@ -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.S8 +import de.fiereu.bytecodec.U8 + +data class MapWeatherModeSetPacket( + val mode: Byte, + val enabled: Boolean, +) + +object MapWeatherModeSetPacketCodec : PacketCodec() { + override fun CodecScope.body(): MapWeatherModeSetPacket { + val mode = field(S8) { it.mode } + val enabled = field(U8) { if (it.enabled) 1 else 0 } == 1 + return MapWeatherModeSetPacket(mode, enabled) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MarketBoardPagePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MarketBoardPagePacket.kt new file mode 100644 index 0000000..147d43a --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MarketBoardPagePacket.kt @@ -0,0 +1,48 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class MarketBoardEntry( + val itemId: Short, + val valueA: Int, + val valueB: Int, + val rank: Byte?, +) + +data class MarketBoardPagePacket( + val hasData: Byte, + val page: Byte?, + val category: Byte?, + val total: Int?, + val expiryOffsetMillis: Long?, + val count: Int?, + val categoryRanked: Boolean, + val entries: List, +) + +object MarketBoardPagePacketCodec : PacketCodec() { + override fun CodecScope.body(): MarketBoardPagePacket { + val hasData = field(S8) { it.hasData } + if (hasData < 1) { + return MarketBoardPagePacket(hasData, null, null, null, null, null, false, emptyList()) + } + val page = field(S8) { it.page!! } + val category = field(S8) { it.category!! } + val total = field(S32LE) { it.total!! } + val expiryOffsetMillis = field(S64LE) { it.expiryOffsetMillis!! } + val count = field(S32LE) { it.count!! } + val categoryRanked = false + val entryCount = field(S16LE) { it.entries.size.toShort() }.toInt() + val entries = ArrayList(entryCount) + repeat(entryCount) { i -> + val itemId = field(S16LE) { it.entries[i].itemId } + val valueA = field(S32LE) { it.entries[i].valueA } + val valueB = field(S32LE) { it.entries[i].valueB } + val rank: Byte? = if (categoryRanked) field(S8) { it.entries[i].rank ?: 0 } else null + entries.add(MarketBoardEntry(itemId, valueA, valueB, rank)) + } + return MarketBoardPagePacket( + hasData, page, category, total, expiryOffsetMillis, count, categoryRanked, entries + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MarketListingsRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MarketListingsRequestPacket.kt new file mode 100644 index 0000000..3a119ea --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MarketListingsRequestPacket.kt @@ -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 MarketListingsRequestPacket(val tab: Byte, val categoryId: Byte) + +object MarketListingsRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): MarketListingsRequestPacket { + val tab = field(S8) { it.tab } + val categoryId = field(S8) { it.categoryId } + return MarketListingsRequestPacket(tab, categoryId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MarketSearchFilterPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MarketSearchFilterPacket.kt new file mode 100644 index 0000000..31544a5 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MarketSearchFilterPacket.kt @@ -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 MarketSearchFilterPacket( + val tab: Byte, + val categoryId: Byte, + val speciesFilter: Short, +) + +object MarketSearchFilterPacketCodec : PacketCodec() { + override fun CodecScope.body(): MarketSearchFilterPacket { + val tab = field(S8) { it.tab } + val categoryId = field(S8) { it.categoryId } + val speciesFilter = field(S16LE) { it.speciesFilter } + return MarketSearchFilterPacket(tab, categoryId, speciesFilter) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingActionPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingActionPacket.kt new file mode 100644 index 0000000..f8bfe74 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingActionPacket.kt @@ -0,0 +1,79 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +sealed class MatchmakingActionKind { + abstract val actionId: Byte +} + +data class TeleportAction(override val actionId: Byte) : MatchmakingActionKind() + +data class SelectTierAction(override val actionId: Byte, val tierId: Int) : MatchmakingActionKind() + +data class SelectTargetAction( + override val actionId: Byte, + val targetEntityId: Long, + val targetSlot: Short, +) : MatchmakingActionKind() + +private val MatchmakingActionCodec: Codec = + object : Codec { + override fun read(buf: ReadBuffer): MatchmakingActionKind { + val actionId = buf.readByte() + return when (actionId.toInt()) { + 1 -> { + var v = 0 + for (i in 0 until 4) { + v = v or ((buf.readByte().toInt() and 0xFF) shl (i * 8)) + } + SelectTierAction(actionId, v) + } + + 2 -> { + var id = 0L + for (i in 0 until 8) { + id = id or ((buf.readByte().toLong() and 0xFF) shl (i * 8)) + } + val lo = buf.readByte().toInt() and 0xFF + val hi = buf.readByte().toInt() and 0xFF + SelectTargetAction(actionId, id, ((hi shl 8) or lo).toShort()) + } + + else -> TeleportAction(actionId) + } + } + + override fun write(buf: WriteBuffer, value: MatchmakingActionKind) { + buf.writeByte(value.actionId) + when (value) { + is TeleportAction -> {} + is SelectTierAction -> { + var v = value.tierId + for (i in 0 until 4) { + buf.writeByte((v and 0xFF).toByte()) + v = v ushr 8 + } + } + + is SelectTargetAction -> { + var id = value.targetEntityId + for (i in 0 until 8) { + buf.writeByte((id and 0xFF).toByte()) + id = id ushr 8 + } + val s = value.targetSlot.toInt() + buf.writeByte((s and 0xFF).toByte()) + buf.writeByte(((s ushr 8) and 0xFF).toByte()) + } + } + } + } + +data class MatchmakingActionPacket(val action: MatchmakingActionKind) + +object MatchmakingActionPacketCodec : PacketCodec() { + override fun CodecScope.body(): MatchmakingActionPacket { + val action = field(MatchmakingActionCodec) { it.action } + return MatchmakingActionPacket(action) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingLanguagePrefsPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingLanguagePrefsPacket.kt new file mode 100644 index 0000000..03e752e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingLanguagePrefsPacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class MatchmakingLanguagePrefsPacket(val languageIds: List) + +object MatchmakingLanguagePrefsPacketCodec : PacketCodec() { + override fun CodecScope.body(): MatchmakingLanguagePrefsPacket { + val languageIds = field(S8.listPrefixed(U8)) { it.languageIds } + return MatchmakingLanguagePrefsPacket(languageIds) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingMemberProgressPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingMemberProgressPacket.kt new file mode 100644 index 0000000..fe8234b --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingMemberProgressPacket.kt @@ -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 MatchmakingMemberProgressPacket( + val entityId: Long, + val current: Short, + val total: Short, +) + +object MatchmakingMemberProgressPacketCodec : PacketCodec() { + override fun CodecScope.body(): MatchmakingMemberProgressPacket { + val entityId = field(S64LE, MatchmakingMemberProgressPacket::entityId) + val current = field(S16LE, MatchmakingMemberProgressPacket::current) + val total = field(S16LE, MatchmakingMemberProgressPacket::total) + return MatchmakingMemberProgressPacket(entityId, current, total) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingRentalsPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingRentalsPacket.kt new file mode 100644 index 0000000..776ee70 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingRentalsPacket.kt @@ -0,0 +1,69 @@ +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 MatchmakingRentalPreview( + val speciesId: Short, + val level: Short, +) + +data class MatchmakingRentalsPacket( + val mode: Byte, + val param1: Byte, + val param2: Byte, + val param3: Byte, + val previews: List?, + val pokemon: List?, +) + +private object MatchmakingRentalPreviewCodec : PacketCodec() { + override fun CodecScope.body(): MatchmakingRentalPreview { + val speciesId = field(S16LE, MatchmakingRentalPreview::speciesId) + val level = field(S16LE, MatchmakingRentalPreview::level) + return MatchmakingRentalPreview(speciesId, level) + } +} + +private val MatchmakingRentalPreviewListPrefixedU8: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { MatchmakingRentalPreviewCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { MatchmakingRentalPreviewCodec.write(buf, it) } + } + } + +private val PokemonListPrefixedU8: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { PokemonCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { PokemonCodec.write(buf, it) } + } + } + +object MatchmakingRentalsPacketCodec : PacketCodec() { + override fun CodecScope.body(): MatchmakingRentalsPacket { + val mode = field(S8, MatchmakingRentalsPacket::mode) + val param1 = field(S8, MatchmakingRentalsPacket::param1) + val param2 = field(S8, MatchmakingRentalsPacket::param2) + val param3 = field(S8, MatchmakingRentalsPacket::param3) + val previews = + if (mode.toInt() == 2) + field(MatchmakingRentalPreviewListPrefixedU8) { it.previews ?: emptyList() } + else null + val pokemon = + if (mode.toInt() == 0) field(PokemonListPrefixedU8) { it.pokemon ?: emptyList() } else null + return MatchmakingRentalsPacket(mode, param1, param2, param3, previews, pokemon) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingSideTeamPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingSideTeamPacket.kt new file mode 100644 index 0000000..f0e962f --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MatchmakingSideTeamPacket.kt @@ -0,0 +1,83 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class MatchmakingRankingEntry( + 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 MatchmakingSideTeamPacket( + val sessionId: Byte, + val opponentSide: Boolean, + val page: Short, + val slot: Int, + val team: List, +) + +private object MatchmakingRankingEntryCodec : PacketCodec() { + override fun CodecScope.body(): MatchmakingRankingEntry { + val entityId = field(S64LE, MatchmakingRankingEntry::entityId) + val rank = field(S8, MatchmakingRankingEntry::rank) + val flags = field(S8, MatchmakingRankingEntry::flags) + val name = field(Utf16LeNullTerminated, MatchmakingRankingEntry::name) + val value1 = field(S16LE, MatchmakingRankingEntry::value1) + val species = field(S16LE, MatchmakingRankingEntry::species) + reserved(byte = 0) + val ribbons = field(S64LE, MatchmakingRankingEntry::ribbons) + val value2 = field(S8, MatchmakingRankingEntry::value2) + val value3 = field(S32LE, MatchmakingRankingEntry::value3) + val value4 = field(S8, MatchmakingRankingEntry::value4) + val flag1 = field(Bool, MatchmakingRankingEntry::flag1) + val flag2 = field(Bool, MatchmakingRankingEntry::flag2) + reserved(byte = 0) + return MatchmakingRankingEntry( + entityId, + rank, + flags, + name, + value1, + species, + ribbons, + value2, + value3, + value4, + flag1, + flag2, + ) + } +} + +private val MatchmakingRankingEntryListPrefixedU8: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { MatchmakingRankingEntryCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { MatchmakingRankingEntryCodec.write(buf, it) } + } + } + +object MatchmakingSideTeamPacketCodec : PacketCodec() { + override fun CodecScope.body(): MatchmakingSideTeamPacket { + val sessionId = field(S8, MatchmakingSideTeamPacket::sessionId) + val opponentSide = field(Bool, MatchmakingSideTeamPacket::opponentSide) + val page = field(S16LE, MatchmakingSideTeamPacket::page) + val slot = field(S32LE, MatchmakingSideTeamPacket::slot) + val team = field(MatchmakingRankingEntryListPrefixedU8, MatchmakingSideTeamPacket::team) + return MatchmakingSideTeamPacket(sessionId, opponentSide, page, slot, team) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MenuPagePayloadPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MenuPagePayloadPacket.kt new file mode 100644 index 0000000..57ecefa --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MenuPagePayloadPacket.kt @@ -0,0 +1,38 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class MenuPagePayloadPacket( + val menuType: Byte, + val page: ByteArray?, +) { + override fun equals(other: Any?): Boolean { + if (other !is MenuPagePayloadPacket) return false + if (menuType != other.menuType) return false + if (page == null) return other.page == null + return other.page != null && page.contentEquals(other.page) + } + + override fun hashCode(): Int { + var r = menuType.toInt() + r = r * 31 + (page?.contentHashCode() ?: 0) + return r + } +} + +private val MenuPageBlob = bytesPrefixed(U16LE) + +object MenuPagePayloadPacketCodec : PacketCodec() { + override fun CodecScope.body(): MenuPagePayloadPacket { + val menuType = field(S8) { it.menuType } + val present = field(U8) { if (it.page != null) 1 else 0 } == 1 + val page: ByteArray? = + if (present) { + field(S64LE) { 0L } + field(S8) { 0 } + field(S8) { 0 } + field(MenuPageBlob) { it.page!! } + } else null + return MenuPagePayloadPacket(menuType, page) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MenuPromptClosePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MenuPromptClosePacket.kt new file mode 100644 index 0000000..6b0b53a --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MenuPromptClosePacket.kt @@ -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 MenuPromptClosePacket( + val promptType: Byte, +) + +object MenuPromptClosePacketCodec : PacketCodec() { + override fun CodecScope.body(): MenuPromptClosePacket { + val promptType = field(S8) { it.promptType } + return MenuPromptClosePacket(promptType) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MenuPromptOpenPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MenuPromptOpenPacket.kt new file mode 100644 index 0000000..221e23e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MenuPromptOpenPacket.kt @@ -0,0 +1,64 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class EntityRelationStat( + val stat: Byte, + val value: Byte, + val relatedIds: List, +) + +data class EntityRelation( + val entityId: Long, + val stats: List, +) + +data class MenuPromptOpenPacket( + val menuKind: Byte, + val promptType: Byte?, + val value: Short?, + val relations: List?, +) + +private val EntityRelationStatCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): EntityRelationStat { + val stat = field(S8) { it.stat } + val value = field(S8) { it.value } + val relatedIds = field(S64LE.listPrefixed(U8)) { it.relatedIds } + return EntityRelationStat(stat, value, relatedIds) + } + } + +private val EntityRelationCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): EntityRelation { + val entityId = field(S64LE) { it.entityId } + val stats = field(EntityRelationStatCodec.listPrefixed(U8)) { it.stats } + return EntityRelation(entityId, stats) + } + } + +object MenuPromptOpenPacketCodec : PacketCodec() { + override fun CodecScope.body(): MenuPromptOpenPacket { + val menuKind = field(S8) { it.menuKind } + var promptType: Byte? = null + var value: Short? = null + var relations: List? = null + when { + menuKind.toInt() == 6 -> { + relations = field(EntityRelationCodec.listPrefixed(U8)) { it.relations!! } + } + + menuKind.toInt() in 3..5 -> { + promptType = field(S8) { it.promptType!! } + value = field(S16LE) { it.value!! } + } + + menuKind.toInt() in 1..2 -> { + promptType = field(S8) { it.promptType!! } + } + } + return MenuPromptOpenPacket(menuKind, promptType, value, relations) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MenuVisibilityPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MenuVisibilityPacket.kt new file mode 100644 index 0000000..036cb3e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MenuVisibilityPacket.kt @@ -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.S8 +import de.fiereu.bytecodec.U8 + +data class MenuVisibilityPacket( + val enabled: Boolean, + val menuType: Byte?, +) + +object MenuVisibilityPacketCodec : PacketCodec() { + override fun CodecScope.body(): MenuVisibilityPacket { + val enabled = field(U8) { if (it.enabled) 1 else 0 } == 1 + val menuType: Byte? = if (enabled) field(S8) { it.menuType!! } else null + return MenuVisibilityPacket(enabled, menuType) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ModerationActionConfirmPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ModerationActionConfirmPacket.kt new file mode 100644 index 0000000..6f6c7b9 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ModerationActionConfirmPacket.kt @@ -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 ModerationActionConfirmPacket( + val targetEntityId: Long, +) + +object ModerationActionConfirmPacketCodec : PacketCodec() { + override fun CodecScope.body(): ModerationActionConfirmPacket { + val targetEntityId = field(S64LE) { it.targetEntityId } + return ModerationActionConfirmPacket(targetEntityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterFavoriteTogglePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterFavoriteTogglePacket.kt new file mode 100644 index 0000000..170055d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterFavoriteTogglePacket.kt @@ -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.S64LE + +data class MonsterFavoriteTogglePacket(val pokemonEntityId: Long, val favorite: Boolean) + +object MonsterFavoriteTogglePacketCodec : PacketCodec() { + override fun CodecScope.body(): MonsterFavoriteTogglePacket { + val pokemonEntityId = field(S64LE) { it.pokemonEntityId } + val favorite = field(Bool) { it.favorite } + return MonsterFavoriteTogglePacket(pokemonEntityId, favorite) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterFormActionPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterFormActionPacket.kt new file mode 100644 index 0000000..b390a11 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterFormActionPacket.kt @@ -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.S16LE +import de.fiereu.bytecodec.S64LE + +data class MonsterFormActionPacket(val monsterEntityId: Long, val stateValue: Short) + +object MonsterFormActionPacketCodec : PacketCodec() { + override fun CodecScope.body(): MonsterFormActionPacket { + val monsterEntityId = field(S64LE) { it.monsterEntityId } + val stateValue = field(S16LE) { it.stateValue } + return MonsterFormActionPacket(monsterEntityId, stateValue) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterInspectRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterInspectRequestPacket.kt new file mode 100644 index 0000000..7345579 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterInspectRequestPacket.kt @@ -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 MonsterInspectRequestPacket( + val entityId: Long, + val contextType: Byte, + val viewMode: Byte, +) + +object MonsterInspectRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): MonsterInspectRequestPacket { + val entityId = field(S64LE) { it.entityId } + val contextType = field(S8) { it.contextType } + val viewMode = field(S8) { it.viewMode } + return MonsterInspectRequestPacket(entityId, contextType, viewMode) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterRecordBookPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterRecordBookPacket.kt new file mode 100644 index 0000000..1d161de --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterRecordBookPacket.kt @@ -0,0 +1,29 @@ +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 MonsterRecordBookPacket( + val records: List, +) + +private val PokemonRecordListPrefixedU8: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { PokemonCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { PokemonCodec.write(buf, it) } + } + } + +object MonsterRecordBookPacketCodec : PacketCodec() { + override fun CodecScope.body(): MonsterRecordBookPacket { + val records = field(PokemonRecordListPrefixedU8, MonsterRecordBookPacket::records) + return MonsterRecordBookPacket(records) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterRenamePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterRenamePacket.kt new file mode 100644 index 0000000..6e2e18c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterRenamePacket.kt @@ -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 +import de.fiereu.bytecodec.Utf16LeNullTerminated + +data class MonsterRenamePacket(val pokemonEntityId: Long, val nickname: String) + +object MonsterRenamePacketCodec : PacketCodec() { + override fun CodecScope.body(): MonsterRenamePacket { + val pokemonEntityId = field(S64LE) { it.pokemonEntityId } + val nickname = field(Utf16LeNullTerminated) { it.nickname } + return MonsterRenamePacket(pokemonEntityId, nickname) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterStatusConditionPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterStatusConditionPacket.kt new file mode 100644 index 0000000..33c861c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MonsterStatusConditionPacket.kt @@ -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 +import de.fiereu.bytecodec.S8 + +data class MonsterStatusConditionPacket(val targetId: Long, val statusCondition: Byte) + +object MonsterStatusConditionPacketCodec : PacketCodec() { + override fun CodecScope.body(): MonsterStatusConditionPacket { + val targetId = field(S64LE) { it.targetId } + val statusCondition = field(S8) { it.statusCondition } + return MonsterStatusConditionPacket(targetId, statusCondition) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MountMoveCooldownPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MountMoveCooldownPacket.kt new file mode 100644 index 0000000..c1b149e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MountMoveCooldownPacket.kt @@ -0,0 +1,20 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class MountMoveCooldownPacket( + val entityId: Long, + val category: Byte, + val moveId: Short, + val playAudio: Boolean, +) + +object MountMoveCooldownPacketCodec : PacketCodec() { + override fun CodecScope.body(): MountMoveCooldownPacket { + val entityId = field(S64LE) { it.entityId } + val category = field(S8) { it.category } + val moveId = field(S16LE) { it.moveId } + val playAudio = field(U8) { if (it.playAudio) 1 else 0 } == 1 + return MountMoveCooldownPacket(entityId, category, moveId, playAudio) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MovementPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MovementPacket.kt index 4ddbbcb..390aac7 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MovementPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/MovementPacket.kt @@ -9,12 +9,12 @@ import de.fiereu.openmmo.common.enums.Direction data class MovementPacket(val x: Int, val y: Int, val direction: Direction) object MovementPacketCodec : PacketCodec() { - private val DirectionCodec = enumByOrdinalByte() + private val DirectionCodec = enumByOrdinalByte() - override fun CodecScope.body(): MovementPacket { - val x = field(S16LE) { it.x.toShort() } - val y = field(S16LE) { it.y.toShort() } - val direction = field(DirectionCodec) { it.direction } - return MovementPacket(x.toInt(), y.toInt(), direction) - } + override fun CodecScope.body(): MovementPacket { + val x = field(S16LE) { it.x.toShort() } + val y = field(S16LE) { it.y.toShort() } + val direction = field(DirectionCodec) { it.direction } + return MovementPacket(x.toInt(), y.toInt(), direction) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NamedCategoryEntriesPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NamedCategoryEntriesPacket.kt new file mode 100644 index 0000000..04f0fe1 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NamedCategoryEntriesPacket.kt @@ -0,0 +1,61 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class NamedCategoryEntry( + val category: Byte, + val name: String, + val kind: Byte, + val payload: ByteArray, +) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is NamedCategoryEntry) return false + return category == other.category && + name == other.name && + kind == other.kind && + payload.contentEquals(other.payload) + } + + override fun hashCode(): Int { + var result = category.toInt() + result = 31 * result + name.hashCode() + result = 31 * result + kind.toInt() + result = 31 * result + payload.contentHashCode() + return result + } +} + +data class NamedCategoryEntriesPacket( + val entries: List, +) + +private object NamedCategoryEntryCodec : PacketCodec() { + override fun CodecScope.body(): NamedCategoryEntry { + val category = field(S8, NamedCategoryEntry::category) + val name = field(Utf16LeNullTerminated, NamedCategoryEntry::name) + val kind = field(S8, NamedCategoryEntry::kind) + val payload = field(bytesPrefixed(U8), NamedCategoryEntry::payload) + return NamedCategoryEntry(category, name, kind, payload) + } +} + +private val NamedCategoryEntryListPrefixedU8: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { NamedCategoryEntryCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { NamedCategoryEntryCodec.write(buf, it) } + } + } + +object NamedCategoryEntriesPacketCodec : PacketCodec() { + override fun CodecScope.body(): NamedCategoryEntriesPacket { + val entries = field(NamedCategoryEntryListPrefixedU8, NamedCategoryEntriesPacket::entries) + return NamedCategoryEntriesPacket(entries) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcAnimationPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcAnimationPacket.kt index ebee33f..de6bc6c 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcAnimationPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcAnimationPacket.kt @@ -8,9 +8,9 @@ import de.fiereu.bytecodec.U8 data class NpcAnimationPacket(val entityId: Long, val animation: Int) object NpcAnimationPacketCodec : PacketCodec() { - override fun CodecScope.body(): NpcAnimationPacket { - val entityId = field(S64LE) { it.entityId } - val animation = field(U8) { it.animation } - return NpcAnimationPacket(entityId, animation) - } + override fun CodecScope.body(): NpcAnimationPacket { + val entityId = field(S64LE) { it.entityId } + val animation = field(U8) { it.animation } + return NpcAnimationPacket(entityId, animation) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcDialogResponsePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcDialogResponsePacket.kt new file mode 100644 index 0000000..f298684 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcDialogResponsePacket.kt @@ -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.S8 +import de.fiereu.bytecodec.Utf16LeNullTerminated + +data class NpcDialogResponsePacket( + val dialogType: Byte, + val responseText: String, +) + +object NpcDialogResponsePacketCodec : PacketCodec() { + override fun CodecScope.body(): NpcDialogResponsePacket { + val dialogType = field(S8) { it.dialogType } + val responseText = field(Utf16LeNullTerminated) { it.responseText } + return NpcDialogResponsePacket(dialogType, responseText) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcDialogueChoicePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcDialogueChoicePacket.kt new file mode 100644 index 0000000..88fd932 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcDialogueChoicePacket.kt @@ -0,0 +1,26 @@ +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 NpcDialogueChoicePacket( + val dialogueType: Byte, + val choiceIndex: Byte, + val subOption: Short?, +) + +object NpcDialogueChoicePacketCodec : PacketCodec() { + override fun CodecScope.body(): NpcDialogueChoicePacket { + val dialogueType = field(S8) { it.dialogueType } + val choiceIndex = field(S8) { it.choiceIndex } + val subOption = + if (choiceIndex != 0.toByte() && dialogueType == BRANCHING_DIALOGUE_TYPE) + field(S16LE) { it.subOption ?: 0 } + else null + return NpcDialogueChoicePacket(dialogueType, choiceIndex, subOption) + } + + private const val BRANCHING_DIALOGUE_TYPE: Byte = 1 +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcInteractionChoicePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcInteractionChoicePacket.kt new file mode 100644 index 0000000..17d68d3 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcInteractionChoicePacket.kt @@ -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 NpcInteractionChoicePacket( + val targetId: Long, +) + +object NpcInteractionChoicePacketCodec : PacketCodec() { + override fun CodecScope.body(): NpcInteractionChoicePacket { + val targetId = field(S64LE) { it.targetId } + return NpcInteractionChoicePacket(targetId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcPanelTogglePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcPanelTogglePacket.kt new file mode 100644 index 0000000..949f7f5 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcPanelTogglePacket.kt @@ -0,0 +1,25 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class NpcPanelTogglePacket( + val npcId: Short, + val npcType: Byte?, + val visible: Boolean?, +) + +object NpcPanelTogglePacketCodec : PacketCodec() { + override fun CodecScope.body(): NpcPanelTogglePacket { + val npcId = field(S16LE) { it.npcId } + val npcType: Byte? + val visible: Boolean? + if (npcId > 0) { + npcType = field(S8) { it.npcType!! } + visible = field(Bool) { it.visible!! } + } else { + npcType = null + visible = null + } + return NpcPanelTogglePacket(npcId, npcType, visible) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcSpawnPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcSpawnPacket.kt index c13345e..2299560 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcSpawnPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcSpawnPacket.kt @@ -1,10 +1,6 @@ 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.U16LE -import de.fiereu.bytecodec.U8 +import de.fiereu.bytecodec.* data class NpcSpawnPacket( val entityId: Long, @@ -23,21 +19,22 @@ data class NpcSpawnPacket( ) object NpcSpawnPacketCodec : PacketCodec() { - override fun CodecScope.body(): NpcSpawnPacket { - val entityId = field(S64LE) { it.entityId } - val unk1 = field(U8) { it.unk1 } - val unk2 = field(U16LE) { it.unk2 } - val unk3 = field(U16LE) { it.unk3 } - val unk4 = field(U16LE) { it.unk4 } - val regionId = field(U8) { it.regionId } - val bankId = field(U8) { it.bankId } - val mapId = field(U8) { it.mapId } - val x = field(U16LE) { it.x } - val y = field(U16LE) { it.y } - val unk5 = field(U8) { it.unk5 } - val facing = field(U8) { it.facing } - val unk6 = field(U16LE) { it.unk6 } - return NpcSpawnPacket( - entityId, unk1, unk2, unk3, unk4, regionId, bankId, mapId, x, y, facing, unk5, unk6) - } + override fun CodecScope.body(): NpcSpawnPacket { + val entityId = field(S64LE) { it.entityId } + val unk1 = field(U8) { it.unk1 } + val unk2 = field(U16LE) { it.unk2 } + val unk3 = field(U16LE) { it.unk3 } + val unk4 = field(U16LE) { it.unk4 } + val regionId = field(U8) { it.regionId } + val bankId = field(U8) { it.bankId } + val mapId = field(U8) { it.mapId } + val x = field(U16LE) { it.x } + val y = field(U16LE) { it.y } + val unk5 = field(U8) { it.unk5 } + val facing = field(U8) { it.facing } + val unk6 = field(U16LE) { it.unk6 } + return NpcSpawnPacket( + entityId, unk1, unk2, unk3, unk4, regionId, bankId, mapId, x, y, facing, unk5, unk6 + ) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcUpdatePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcUpdatePacket.kt index 4dd532f..957c46d 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcUpdatePacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NpcUpdatePacket.kt @@ -1,10 +1,6 @@ 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.U16LE -import de.fiereu.bytecodec.U8 +import de.fiereu.bytecodec.* data class NpcUpdatePacket( val entityId: Long, @@ -18,15 +14,15 @@ data class NpcUpdatePacket( ) object NpcUpdatePacketCodec : PacketCodec() { - override fun CodecScope.body(): NpcUpdatePacket { - val entityId = field(S64LE) { it.entityId } - val regionId = field(U8) { it.regionId } - val bankId = field(U8) { it.bankId } - val mapId = field(U8) { it.mapId } - val x = field(U16LE) { it.x } - val y = field(U16LE) { it.y } - val facing = field(U8) { it.facing } - val unk = field(U8) { it.unk } - return NpcUpdatePacket(entityId, regionId, bankId, mapId, x, y, facing, unk) - } + override fun CodecScope.body(): NpcUpdatePacket { + val entityId = field(S64LE) { it.entityId } + val regionId = field(U8) { it.regionId } + val bankId = field(U8) { it.bankId } + val mapId = field(U8) { it.mapId } + val x = field(U16LE) { it.x } + val y = field(U16LE) { it.y } + val facing = field(U8) { it.facing } + val unk = field(U8) { it.unk } + return NpcUpdatePacket(entityId, regionId, bankId, mapId, x, y, facing, unk) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NullPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NullPacket.kt index c97b02a..401d0e2 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NullPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/NullPacket.kt @@ -1,24 +1,20 @@ package de.fiereu.openmmo.net.game.packets -import de.fiereu.bytecodec.Codec -import de.fiereu.bytecodec.CodecScope -import de.fiereu.bytecodec.PacketCodec -import de.fiereu.bytecodec.ReadBuffer -import de.fiereu.bytecodec.WriteBuffer +import de.fiereu.bytecodec.* class NullPacket private object DrainRemaining : Codec { - override fun read(buf: ReadBuffer) { - if (buf.remaining() > 0) buf.skip(buf.remaining()) - } + override fun read(buf: ReadBuffer) { + if (buf.remaining() > 0) buf.skip(buf.remaining()) + } - override fun write(buf: WriteBuffer, value: Unit) {} + override fun write(buf: WriteBuffer, value: Unit) {} } object NullPacketCodec : PacketCodec() { - override fun CodecScope.body(): NullPacket { - structural(DrainRemaining) - return NullPacket() - } + override fun CodecScope.body(): NullPacket { + structural(DrainRemaining) + return NullPacket() + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ObjectiveProgressBulkPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ObjectiveProgressBulkPacket.kt new file mode 100644 index 0000000..086edd0 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ObjectiveProgressBulkPacket.kt @@ -0,0 +1,30 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class ObjectiveProgressEntry( + val id: Byte, + val value: Int, + val count: Short, +) + +data class ObjectiveProgressBulkPacket( + val entries: List, +) + +private val ObjectiveProgressEntryCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): ObjectiveProgressEntry { + val id = field(S8) { it.id } + val value = field(S32LE) { it.value } + val count = field(S16LE) { it.count } + return ObjectiveProgressEntry(id, value, count) + } + } + +object ObjectiveProgressBulkPacketCodec : PacketCodec() { + override fun CodecScope.body(): ObjectiveProgressBulkPacket { + val entries = field(ObjectiveProgressEntryCodec.listPrefixed(U8)) { it.entries } + return ObjectiveProgressBulkPacket(entries) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ObjectiveProgressPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ObjectiveProgressPacket.kt new file mode 100644 index 0000000..1eb9a7c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ObjectiveProgressPacket.kt @@ -0,0 +1,18 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class ObjectiveProgressPacket( + val id: Byte, + val value: Int, + val count: Short, +) + +object ObjectiveProgressPacketCodec : PacketCodec() { + override fun CodecScope.body(): ObjectiveProgressPacket { + val id = field(S8) { it.id } + val value = field(S32LE) { it.value } + val count = field(S16LE) { it.count } + return ObjectiveProgressPacket(id, value, count) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OpenAppearanceEditorPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OpenAppearanceEditorPacket.kt new file mode 100644 index 0000000..9ca64fd --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OpenAppearanceEditorPacket.kt @@ -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 OpenAppearanceEditorPacket( + val entityId: Long, +) + +object OpenAppearanceEditorPacketCodec : PacketCodec() { + override fun CodecScope.body(): OpenAppearanceEditorPacket { + val entityId = field(S64LE) { it.entityId } + return OpenAppearanceEditorPacket(entityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OptionListWindowPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OptionListWindowPacket.kt new file mode 100644 index 0000000..6428c51 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OptionListWindowPacket.kt @@ -0,0 +1,42 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class OptionMenuEntry( + val typeId: Byte, + val subType: Byte, + val valueA: Short, + val valueB: Short, + val valueC: Short, + val valueD: Short, + val valueE: Short, +) + +data class OptionListWindowPacket( + val kind: Byte, + val options: List, +) + +private val OptionMenuEntryCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): OptionMenuEntry { + field(S64LE) { 0L } + field(S8) { 0 } + val typeId = field(S8) { it.typeId } + val subType = field(S8) { it.subType } + val valueA = field(S16LE) { it.valueA } + val valueB = field(S16LE) { it.valueB } + val valueC = field(S16LE) { it.valueC } + val valueD = field(S16LE) { it.valueD } + val valueE = field(S16LE) { it.valueE } + return OptionMenuEntry(typeId, subType, valueA, valueB, valueC, valueD, valueE) + } + } + +object OptionListWindowPacketCodec : PacketCodec() { + override fun CodecScope.body(): OptionListWindowPacket { + val kind = field(S8) { it.kind } + val options = field(OptionMenuEntryCodec.listPrefixed(U8)) { it.options } + return OptionListWindowPacket(kind, options) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OverworldParticleSpawnPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OverworldParticleSpawnPacket.kt new file mode 100644 index 0000000..b723946 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OverworldParticleSpawnPacket.kt @@ -0,0 +1,25 @@ +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 OverworldParticleSpawnPacket( + val effectType: Byte, + val x: Short, + val y: Short, + val z: Short, + val variant: Short, +) + +object OverworldParticleSpawnPacketCodec : PacketCodec() { + override fun CodecScope.body(): OverworldParticleSpawnPacket { + val effectType = field(S8) { it.effectType } + val x = field(S16LE) { it.x } + val y = field(S16LE) { it.y } + val z = field(S16LE) { it.z } + val variant = field(S16LE) { it.variant } + return OverworldParticleSpawnPacket(effectType, x, y, z, variant) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OverworldPathToTilePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OverworldPathToTilePacket.kt new file mode 100644 index 0000000..477a560 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OverworldPathToTilePacket.kt @@ -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 OverworldPathToTilePacket( + val zoneId: Short, + val targetX: Byte, + val targetY: Byte, +) + +object OverworldPathToTilePacketCodec : PacketCodec() { + override fun CodecScope.body(): OverworldPathToTilePacket { + val zoneId = field(S16LE) { it.zoneId } + val targetX = field(S8) { it.targetX } + val targetY = field(S8) { it.targetY } + return OverworldPathToTilePacket(zoneId, targetX, targetY) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OverworldStepMovePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OverworldStepMovePacket.kt new file mode 100644 index 0000000..c9ab0c1 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OverworldStepMovePacket.kt @@ -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 OverworldStepMovePacket( + val targetX: Byte, + val targetY: Byte, +) + +object OverworldStepMovePacketCodec : PacketCodec() { + override fun CodecScope.body(): OverworldStepMovePacket { + val targetX = field(S8) { it.targetX } + val targetY = field(S8) { it.targetY } + return OverworldStepMovePacket(targetX, targetY) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OverworldWeatherControlPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OverworldWeatherControlPacket.kt new file mode 100644 index 0000000..bf844a2 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/OverworldWeatherControlPacket.kt @@ -0,0 +1,58 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class OverworldWeatherControlPacket( + val effectType: Byte, + val skyId: Short?, + val skyVariant: Short?, + val particleId: Short?, + val particleVariant: Short?, + val paramA: Float?, + val paramB: Float?, + val paramC: Float?, + val paramD: Float?, + val duration: Short?, +) + +object OverworldWeatherControlPacketCodec : PacketCodec() { + override fun CodecScope.body(): OverworldWeatherControlPacket { + val effectType = field(S8) { it.effectType } + val t = effectType.toInt() + var skyId: Short? = null + var skyVariant: Short? = null + var particleId: Short? = null + var particleVariant: Short? = null + var paramA: Float? = null + var paramB: Float? = null + var paramC: Float? = null + var paramD: Float? = null + var duration: Short? = null + if (t == 0) { + skyId = field(S16LE) { it.skyId!! } + skyVariant = field(S16LE) { it.skyVariant!! } + } else if (t == 4) { + particleId = field(S16LE) { it.particleId!! } + particleVariant = field(S16LE) { it.particleVariant!! } + paramA = field(F32LE) { it.paramA!! } + paramB = field(F32LE) { it.paramB!! } + paramC = field(F32LE) { it.paramC!! } + paramD = field(F32LE) { it.paramD!! } + duration = field(S16LE) { it.duration!! } + } else if (t == 5) { + duration = field(S16LE) { it.duration!! } + } + return OverworldWeatherControlPacket( + effectType = effectType, + skyId = skyId, + skyVariant = skyVariant, + particleId = particleId, + particleVariant = particleVariant, + paramA = paramA, + paramB = paramB, + paramC = paramC, + paramD = paramD, + duration = duration, + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyInfoRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyInfoRequestPacket.kt new file mode 100644 index 0000000..814fcb0 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyInfoRequestPacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec + +class PartyInfoRequestPacket + +object PartyInfoRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): PartyInfoRequestPacket { + return PartyInfoRequestPacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyMemberJoinPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyMemberJoinPacket.kt new file mode 100644 index 0000000..7460c1e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyMemberJoinPacket.kt @@ -0,0 +1,20 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class PartyMemberJoinPacket( + val player: Long, + val name: String, + val secondaryName: String, + val value: Int, +) + +object PartyMemberJoinPacketCodec : PacketCodec() { + override fun CodecScope.body(): PartyMemberJoinPacket { + val player = field(S64LE) { it.player } + val name = field(Utf16LeNullTerminated) { it.name } + val secondaryName = field(Utf16LeNullTerminated) { it.secondaryName } + val value = field(S32LE) { it.value } + return PartyMemberJoinPacket(player, name, secondaryName, value) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyMemberLeavePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyMemberLeavePacket.kt new file mode 100644 index 0000000..e0205ea --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyMemberLeavePacket.kt @@ -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 PartyMemberLeavePacket( + val memberId: Long, +) + +object PartyMemberLeavePacketCodec : PacketCodec() { + override fun CodecScope.body(): PartyMemberLeavePacket { + val memberId = field(S64LE) { it.memberId } + return PartyMemberLeavePacket(memberId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyMemberSelectPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyMemberSelectPacket.kt new file mode 100644 index 0000000..f68ddef --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyMemberSelectPacket.kt @@ -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 +import de.fiereu.bytecodec.S8 + +data class PartyMemberSelectPacket(val selectionType: Byte, val entityId: Long) + +object PartyMemberSelectPacketCodec : PacketCodec() { + override fun CodecScope.body(): PartyMemberSelectPacket { + val selectionType = field(S8) { it.selectionType } + val entityId = field(S64LE) { it.entityId } + return PartyMemberSelectPacket(selectionType, entityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyRosterPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyRosterPacket.kt new file mode 100644 index 0000000..3e343d4 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PartyRosterPacket.kt @@ -0,0 +1,34 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class PartyMember( + val player: Long, + val name: String, + val secondaryName: String, + val value: Int, +) + +data class PartyRosterPacket( + val mergeMode: Int, + val members: List, +) + +private val PartyMemberCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): PartyMember { + val player = field(S64LE) { it.player } + val name = field(Utf16LeNullTerminated) { it.name } + val secondaryName = field(Utf16LeNullTerminated) { it.secondaryName } + val value = field(S32LE) { it.value } + return PartyMember(player, name, secondaryName, value) + } + } + +object PartyRosterPacketCodec : PacketCodec() { + override fun CodecScope.body(): PartyRosterPacket { + val mergeMode = field(U8) { it.mergeMode } + val members = field(PartyMemberCodec.listPrefixed(U8)) { it.members } + return PartyRosterPacket(mergeMode, members) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PcBoxRenamePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PcBoxRenamePacket.kt new file mode 100644 index 0000000..96d735b --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PcBoxRenamePacket.kt @@ -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.S8 +import de.fiereu.bytecodec.Utf16LeNullTerminated + +data class PcBoxRenamePacket( + val boxIndex: Byte, + val newName: String, +) + +object PcBoxRenamePacketCodec : PacketCodec() { + override fun CodecScope.body(): PcBoxRenamePacket { + val boxIndex = field(S8) { it.boxIndex } + val newName = field(Utf16LeNullTerminated) { it.newName } + return PcBoxRenamePacket(boxIndex, newName) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PcBoxStorePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PcBoxStorePacket.kt new file mode 100644 index 0000000..5065516 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PcBoxStorePacket.kt @@ -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 PcBoxStorePacket( + val boxId: Byte, + val slotIndex: Byte, + val pokemonId: Long, +) + +object PcBoxStorePacketCodec : PacketCodec() { + override fun CodecScope.body(): PcBoxStorePacket { + val boxId = field(S8) { it.boxId } + val slotIndex = field(S8) { it.slotIndex } + val pokemonId = field(S64LE) { it.pokemonId } + return PcBoxStorePacket(boxId, slotIndex, pokemonId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PendingRequestCancelPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PendingRequestCancelPacket.kt new file mode 100644 index 0000000..0ff2124 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PendingRequestCancelPacket.kt @@ -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 PendingRequestCancelPacket( + val requestEntityId: Long, +) + +object PendingRequestCancelPacketCodec : PacketCodec() { + override fun CodecScope.body(): PendingRequestCancelPacket { + val requestEntityId = field(S64LE) { it.requestEntityId } + return PendingRequestCancelPacket(requestEntityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerChatInputPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerChatInputPacket.kt new file mode 100644 index 0000000..4963e8b --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerChatInputPacket.kt @@ -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.Utf16LeNullTerminated + +data class PlayerChatInputPacket( + val message: String, +) + +object PlayerChatInputPacketCodec : PacketCodec() { + override fun CodecScope.body(): PlayerChatInputPacket { + val message = field(Utf16LeNullTerminated) { it.message } + return PlayerChatInputPacket(message) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerFacingChangePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerFacingChangePacket.kt new file mode 100644 index 0000000..424a541 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerFacingChangePacket.kt @@ -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 PlayerFacingChangePacket(val facingDirection: Byte) + +object PlayerFacingChangePacketCodec : PacketCodec() { + override fun CodecScope.body(): PlayerFacingChangePacket { + val facingDirection = field(S8) { it.facingDirection } + return PlayerFacingChangePacket(facingDirection) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerInputLockPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerInputLockPacket.kt new file mode 100644 index 0000000..6703a5b --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerInputLockPacket.kt @@ -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.U8 + +data class PlayerInputLockPacket( + val inputEnabled: Boolean, +) + +object PlayerInputLockPacketCodec : PacketCodec() { + override fun CodecScope.body(): PlayerInputLockPacket { + val inputEnabled = field(U8) { if (it.inputEnabled) 1 else 0 } == 1 + return PlayerInputLockPacket(inputEnabled) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerPositionUpdatePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerPositionUpdatePacket.kt new file mode 100644 index 0000000..495dcf5 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerPositionUpdatePacket.kt @@ -0,0 +1,32 @@ +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.U8 + +data class PlayerPositionUpdatePacket( + val x: Short, + val y: Short, + val facing: Byte, + val isRunning: Boolean, + val isOnBike: Boolean, +) + +object PlayerPositionUpdatePacketCodec : PacketCodec() { + override fun CodecScope.body(): PlayerPositionUpdatePacket { + val x = field(S16LE) { it.x } + val y = field(S16LE) { it.y } + val packedFacing = + field(U8) { + var f = it.facing.toInt() and 0xFF + if (it.isRunning) f = f or 0x80 + if (it.isOnBike) f = f or 0x40 + f + } + val isRunning = (packedFacing and 0x80) != 0 + val isOnBike = (packedFacing and 0x40) != 0 + val facing = (packedFacing and 0x3F).toByte() + return PlayerPositionUpdatePacket(x, y, facing, isRunning, isOnBike) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerStopMovingPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerStopMovingPacket.kt new file mode 100644 index 0000000..8614c2a --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PlayerStopMovingPacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec + +class PlayerStopMovingPacket + +object PlayerStopMovingPacketCodec : PacketCodec() { + override fun CodecScope.body(): PlayerStopMovingPacket { + return PlayerStopMovingPacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokedexSpeciesResetPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokedexSpeciesResetPacket.kt new file mode 100644 index 0000000..b1f9f5e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokedexSpeciesResetPacket.kt @@ -0,0 +1,14 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class PokedexSpeciesResetPacket( + val speciesIds: List, +) + +object PokedexSpeciesResetPacketCodec : PacketCodec() { + override fun CodecScope.body(): PokedexSpeciesResetPacket { + val speciesIds = field(S16LE.listPrefixed(U16LE)) { it.speciesIds } + return PokedexSpeciesResetPacket(speciesIds) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokedexSpeciesUnlockPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokedexSpeciesUnlockPacket.kt new file mode 100644 index 0000000..7a895b3 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokedexSpeciesUnlockPacket.kt @@ -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.S16LE + +data class PokedexSpeciesUnlockPacket( + val speciesId: Short, +) + +object PokedexSpeciesUnlockPacketCodec : PacketCodec() { + override fun CodecScope.body(): PokedexSpeciesUnlockPacket { + val speciesId = field(S16LE) { it.speciesId } + return PokedexSpeciesUnlockPacket(speciesId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokemonContainerPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokemonContainerPacket.kt index 249e909..cdd7479 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokemonContainerPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokemonContainerPacket.kt @@ -1,11 +1,6 @@ package de.fiereu.openmmo.net.game.packets -import de.fiereu.bytecodec.Codec -import de.fiereu.bytecodec.CodecScope -import de.fiereu.bytecodec.PacketCodec -import de.fiereu.bytecodec.ReadBuffer -import de.fiereu.bytecodec.U8 -import de.fiereu.bytecodec.WriteBuffer +import de.fiereu.bytecodec.* import de.fiereu.openmmo.common.Pokemon import de.fiereu.openmmo.common.enums.PokemonContainer import de.fiereu.openmmo.net.game.codecs.PokemonCodec @@ -16,45 +11,45 @@ data class PokemonContainerPacket( val delete: Boolean, val pokemon: List, ) { - init { - if (delete) - require(hasChange) { - "Pokemon container cannot be deleted if the packet doesn't change anything" - } - if (delete) - require(pokemon.isEmpty()) { "Deleting a Pokemon container shouldn't have any pokemon" } - } + init { + if (delete) + require(hasChange) { + "Pokemon container cannot be deleted if the packet doesn't change anything" + } + if (delete) + require(pokemon.isEmpty()) { "Deleting a Pokemon container shouldn't have any pokemon" } + } } private val PokemonListPrefixedU8: Codec> = object : Codec> { - override fun read(buf: ReadBuffer): List { - val n = U8.read(buf) - return List(n) { PokemonCodec.read(buf) } - } + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { PokemonCodec.read(buf) } + } - override fun write(buf: WriteBuffer, value: List) { - U8.write(buf, value.size) - value.forEach { PokemonCodec.write(buf, it) } - } + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { PokemonCodec.write(buf, it) } + } } object PokemonContainerPacketCodec : PacketCodec() { - override fun CodecScope.body(): PokemonContainerPacket { - val container = PokemonContainer.entries[field(U8) { it.container.ordinal }] - val flags = - field(U8) { - var f = 0 - if (it.hasChange) f = f or 1 - if (it.delete) f = f or 2 - f + override fun CodecScope.body(): PokemonContainerPacket { + val container = PokemonContainer.entries[field(U8) { it.container.ordinal }] + val flags = + field(U8) { + var f = 0 + if (it.hasChange) f = f or 1 + if (it.delete) f = f or 2 + f + } + val hasChange = (flags and 1) != 0 + val delete = (flags and 2) != 0 + if (delete) { + return PokemonContainerPacket(container, hasChange, true, emptyList()) } - val hasChange = (flags and 1) != 0 - val delete = (flags and 2) != 0 - if (delete) { - return PokemonContainerPacket(container, hasChange, true, emptyList()) + val pokemon = field(PokemonListPrefixedU8, PokemonContainerPacket::pokemon) + return PokemonContainerPacket(container, hasChange, false, pokemon) } - val pokemon = field(PokemonListPrefixedU8, PokemonContainerPacket::pokemon) - return PokemonContainerPacket(container, hasChange, false, pokemon) - } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokemonFlagsUpdatePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokemonFlagsUpdatePacket.kt new file mode 100644 index 0000000..a829dc8 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokemonFlagsUpdatePacket.kt @@ -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 +import de.fiereu.bytecodec.S8 + +data class PokemonFlagsUpdatePacket(val entityId: Long, val flags: Byte) + +object PokemonFlagsUpdatePacketCodec : PacketCodec() { + override fun CodecScope.body(): PokemonFlagsUpdatePacket { + val entityId = field(S64LE) { it.entityId } + val flags = field(S8) { it.flags } + return PokemonFlagsUpdatePacket(entityId, flags) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokemonListAddPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokemonListAddPacket.kt new file mode 100644 index 0000000..db08ba7 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PokemonListAddPacket.kt @@ -0,0 +1,18 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class PokemonListAddPacket( + val entityId: Long, + val slot: Short, + val listType: Byte, +) + +object PokemonListAddPacketCodec : PacketCodec() { + override fun CodecScope.body(): PokemonListAddPacket { + val entityId = field(S64LE) { it.entityId } + val slot = field(S16LE) { it.slot } + val listType = field(S8) { it.listType } + return PokemonListAddPacket(entityId, slot, listType) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PongPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PongPacket.kt new file mode 100644 index 0000000..8f2345e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PongPacket.kt @@ -0,0 +1,24 @@ +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 PongPacket( + val isServerPong: Boolean, + val timestamp: Long, +) + +object PongPacketCodec : PacketCodec() { + override fun CodecScope.body(): PongPacket { + val isServerPong = field(Bool) { it.isServerPong } + val timestamp = + if (isServerPong) { + field(S64LE) { it.timestamp } + } else { + field(S64LE) { if (it.timestamp == -1L) System.currentTimeMillis() else it.timestamp } + } + return PongPacket(isServerPong, timestamp) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PrismaticPearlTransferPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PrismaticPearlTransferPacket.kt new file mode 100644 index 0000000..94b037e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/PrismaticPearlTransferPacket.kt @@ -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 PrismaticPearlTransferPacket( + val sourceEntityId: Long, + val targetEntityId: Long, +) + +object PrismaticPearlTransferPacketCodec : PacketCodec() { + override fun CodecScope.body(): PrismaticPearlTransferPacket { + val sourceEntityId = field(S64LE) { it.sourceEntityId } + val targetEntityId = field(S64LE) { it.targetEntityId } + return PrismaticPearlTransferPacket(sourceEntityId, targetEntityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/QueuePositionPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/QueuePositionPacket.kt new file mode 100644 index 0000000..d1d8be0 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/QueuePositionPacket.kt @@ -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.S16LE + +data class QueuePositionPacket( + val position: Short, + val total: Short, +) + +object QueuePositionPacketCodec : PacketCodec() { + override fun CodecScope.body(): QueuePositionPacket { + val position = field(S16LE) { it.position } + val total = field(S16LE) { it.total } + return QueuePositionPacket(position, total) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RemoveFriendPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RemoveFriendPacket.kt new file mode 100644 index 0000000..77069f0 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RemoveFriendPacket.kt @@ -0,0 +1,14 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec +import de.fiereu.bytecodec.Utf16LeNullTerminated + +data class RemoveFriendPacket(val username: String) + +object RemoveFriendPacketCodec : PacketCodec() { + override fun CodecScope.body(): RemoveFriendPacket { + val username = field(Utf16LeNullTerminated) { it.username } + return RemoveFriendPacket(username) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RenderScreenPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RenderScreenPacket.kt index 5cc0312..d1e1bde 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RenderScreenPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RenderScreenPacket.kt @@ -7,8 +7,8 @@ import de.fiereu.bytecodec.PacketCodec data class RenderScreenPacket(val renderScreen: Boolean) object RenderScreenPacketCodec : PacketCodec() { - override fun CodecScope.body(): RenderScreenPacket { - val renderScreen = field(Bool) { it.renderScreen } - return RenderScreenPacket(renderScreen) - } + override fun CodecScope.body(): RenderScreenPacket { + val renderScreen = field(Bool) { it.renderScreen } + return RenderScreenPacket(renderScreen) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestCharactersPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestCharactersPacket.kt index 62b45ce..4af0c95 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestCharactersPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestCharactersPacket.kt @@ -6,5 +6,5 @@ import de.fiereu.bytecodec.PacketCodec class RequestCharactersPacket object RequestCharactersPacketCodec : PacketCodec() { - override fun CodecScope.body() = RequestCharactersPacket() + override fun CodecScope.body() = RequestCharactersPacket() } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestConfirmationPromptPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestConfirmationPromptPacket.kt new file mode 100644 index 0000000..13990b9 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestConfirmationPromptPacket.kt @@ -0,0 +1,22 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class RequestConfirmationPromptPacket( + val visible: Boolean, + val entityId: Long?, + val requestTimeoutSeconds: Int?, + val responseTimeoutSeconds: Int?, +) + +object RequestConfirmationPromptPacketCodec : PacketCodec() { + override fun CodecScope.body(): RequestConfirmationPromptPacket { + val visible = field(U8) { if (it.visible) 1 else 0 } == 1 + val entityId = if (visible) field(S64LE) { it.entityId!! } else null + val requestTimeoutSeconds = if (visible) field(U16LE) { it.requestTimeoutSeconds!! } else null + val responseTimeoutSeconds = if (visible) field(U16LE) { it.responseTimeoutSeconds!! } else null + return RequestConfirmationPromptPacket( + visible, entityId, requestTimeoutSeconds, responseTimeoutSeconds + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestEntityInteractionPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestEntityInteractionPacket.kt new file mode 100644 index 0000000..9e550bc --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestEntityInteractionPacket.kt @@ -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 RequestEntityInteractionPacket( + val entityId: Long, + val checksum: Long, +) + +object RequestEntityInteractionPacketCodec : PacketCodec() { + override fun CodecScope.body(): RequestEntityInteractionPacket { + val entityId = field(S64LE) { it.entityId } + val checksum = field(S64LE) { it.checksum } + return RequestEntityInteractionPacket(entityId, checksum) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestNextBattleSequencePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestNextBattleSequencePacket.kt new file mode 100644 index 0000000..2922168 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestNextBattleSequencePacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec + +class RequestNextBattleSequencePacket + +object RequestNextBattleSequencePacketCodec : PacketCodec() { + override fun CodecScope.body(): RequestNextBattleSequencePacket { + return RequestNextBattleSequencePacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestPlayerPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestPlayerPacket.kt index b3f6f5c..2e0357f 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestPlayerPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestPlayerPacket.kt @@ -6,5 +6,5 @@ import de.fiereu.bytecodec.PacketCodec class RequestPlayerPacket object RequestPlayerPacketCodec : PacketCodec() { - override fun CodecScope.body() = RequestPlayerPacket() + override fun CodecScope.body() = RequestPlayerPacket() } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestSocialProfilePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestSocialProfilePacket.kt new file mode 100644 index 0000000..aeab71e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RequestSocialProfilePacket.kt @@ -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 RequestSocialProfilePacket( + val targetId: Long, +) + +object RequestSocialProfilePacketCodec : PacketCodec() { + override fun CodecScope.body(): RequestSocialProfilePacket { + val targetId = field(S64LE) { it.targetId } + return RequestSocialProfilePacket(targetId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RosterCooldownPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RosterCooldownPacket.kt new file mode 100644 index 0000000..78d8d77 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/RosterCooldownPacket.kt @@ -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.S32LE + +data class RosterCooldownPacket( + val cooldownOffsetSeconds: Int, +) + +object RosterCooldownPacketCodec : PacketCodec() { + override fun CodecScope.body(): RosterCooldownPacket { + val cooldownOffsetSeconds = field(S32LE) { it.cooldownOffsetSeconds } + return RosterCooldownPacket(cooldownOffsetSeconds) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SaveTemplateEntryPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SaveTemplateEntryPacket.kt new file mode 100644 index 0000000..9ff94b2 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SaveTemplateEntryPacket.kt @@ -0,0 +1,35 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class SaveTemplateEntryPacket( + val templateSlot: Byte, + val name: String, + val entryKindId: Byte, + val data: ByteArray, +) { + override fun equals(other: Any?): Boolean = + other is SaveTemplateEntryPacket && + templateSlot == other.templateSlot && + name == other.name && + entryKindId == other.entryKindId && + data.contentEquals(other.data) + + override fun hashCode(): Int { + var r = templateSlot.toInt() + r = r * 31 + name.hashCode() + r = r * 31 + entryKindId + r = r * 31 + data.contentHashCode() + return r + } +} + +object SaveTemplateEntryPacketCodec : PacketCodec() { + override fun CodecScope.body(): SaveTemplateEntryPacket { + val templateSlot = field(S8) { it.templateSlot } + val name = field(Utf16LeNullTerminated) { it.name } + val entryKindId = field(S8) { it.entryKindId } + val data = field(bytesPrefixed(U8)) { it.data } + return SaveTemplateEntryPacket(templateSlot, name, entryKindId, data) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SceneEntityActionDispatchPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SceneEntityActionDispatchPacket.kt new file mode 100644 index 0000000..7af7eda --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SceneEntityActionDispatchPacket.kt @@ -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 SceneEntityActionDispatchPacket( + val entityId: Long, + val action: Byte, +) + +object SceneEntityActionDispatchPacketCodec : PacketCodec() { + override fun CodecScope.body(): SceneEntityActionDispatchPacket { + val entityId = field(S64LE) { it.entityId } + val action = field(S8) { it.action } + return SceneEntityActionDispatchPacket(entityId, action) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SceneObjectStatesPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SceneObjectStatesPacket.kt new file mode 100644 index 0000000..fbdd506 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SceneObjectStatesPacket.kt @@ -0,0 +1,48 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class SceneObjectFrame( + val valueA: Short, + val valueB: Short, + val valueC: Int, + val flag: Boolean, +) + +data class SceneObjectState( + val objectId: Long, + val type: Byte, + val frames: List, +) + +data class SceneObjectStatesPacket( + val objects: List, +) + +private val SceneObjectFrameCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): SceneObjectFrame { + val valueA = field(S16LE) { it.valueA } + val valueB = field(S16LE) { it.valueB } + val valueC = field(S32LE) { it.valueC } + val flag = field(U8) { if (it.flag) 1 else 0 } == 1 + return SceneObjectFrame(valueA, valueB, valueC, flag) + } + } + +private val SceneObjectStateCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): SceneObjectState { + val objectId = field(S64LE) { it.objectId } + val type = field(S8) { it.type } + val frames = field(SceneObjectFrameCodec.listPrefixed(U8)) { it.frames } + return SceneObjectState(objectId, type, frames) + } + } + +object SceneObjectStatesPacketCodec : PacketCodec() { + override fun CodecScope.body(): SceneObjectStatesPacket { + val objects = field(SceneObjectStateCodec.listPrefixed(U8)) { it.objects } + return SceneObjectStatesPacket(objects) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectCharacterPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectCharacterPacket.kt index a090376..1e96938 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectCharacterPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectCharacterPacket.kt @@ -7,9 +7,9 @@ import de.fiereu.bytecodec.S64LE data class SelectCharacterPacket(val characterId: Long, val characterIdHash: Long) object SelectCharacterPacketCodec : PacketCodec() { - override fun CodecScope.body(): SelectCharacterPacket { - val characterId = field(S64LE) { it.characterId } - val characterIdHash = field(S64LE) { it.characterIdHash } - return SelectCharacterPacket(characterId, characterIdHash) - } + override fun CodecScope.body(): SelectCharacterPacket { + val characterId = field(S64LE) { it.characterId } + val characterIdHash = field(S64LE) { it.characterIdHash } + return SelectCharacterPacket(characterId, characterIdHash) + } } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectPartyPokemonPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectPartyPokemonPacket.kt new file mode 100644 index 0000000..c1e3945 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectPartyPokemonPacket.kt @@ -0,0 +1,14 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class SelectPartyPokemonPacket( + val entityIds: List, +) + +object SelectPartyPokemonPacketCodec : PacketCodec() { + override fun CodecScope.body(): SelectPartyPokemonPacket { + val entityIds = field(S64LE.listPrefixed(U8)) { it.entityIds } + return SelectPartyPokemonPacket(entityIds) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectSinglePokemonPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectSinglePokemonPacket.kt new file mode 100644 index 0000000..b8cd195 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectSinglePokemonPacket.kt @@ -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 SelectSinglePokemonPacket( + val entityId: Long, +) + +object SelectSinglePokemonPacketCodec : PacketCodec() { + override fun CodecScope.body(): SelectSinglePokemonPacket { + val entityId = field(S64LE) { it.entityId } + return SelectSinglePokemonPacket(entityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectedCharacterPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectedCharacterPacket.kt index 01ea582..86c819d 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectedCharacterPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectedCharacterPacket.kt @@ -11,8 +11,8 @@ data class SelectedCharacterPacket(val character: CharacterInfo?) private val OptionalCharacterInfo = CharacterInfoCodecShort.optional() object SelectedCharacterPacketCodec : PacketCodec() { - override fun CodecScope.body() = - SelectedCharacterPacket( - character = field(OptionalCharacterInfo, SelectedCharacterPacket::character), - ) + override fun CodecScope.body() = + SelectedCharacterPacket( + character = field(OptionalCharacterInfo, SelectedCharacterPacket::character), + ) } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectionListWindowOpenPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectionListWindowOpenPacket.kt new file mode 100644 index 0000000..72dbce9 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SelectionListWindowOpenPacket.kt @@ -0,0 +1,119 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +sealed class ListWindowMessageArg { + abstract val argId: Byte + abstract val typeTag: Byte + abstract val hasExtra: Boolean + abstract val extra: Byte +} + +data class ListWindowByteArg( + override val argId: Byte, + override val typeTag: Byte, + override val hasExtra: Boolean, + override val extra: Byte, +) : ListWindowMessageArg() + +data class ListWindowLongArg( + override val argId: Byte, + override val typeTag: Byte, + override val hasExtra: Boolean, + override val extra: Byte, + val value: Long, +) : ListWindowMessageArg() + +data class ListWindowIntArg( + override val argId: Byte, + override val typeTag: Byte, + override val hasExtra: Boolean, + override val extra: Byte, + val value: Int, +) : ListWindowMessageArg() + +data class ListWindowStringArg( + override val argId: Byte, + override val typeTag: Byte, + override val hasExtra: Boolean, + override val extra: Byte, + val text: String, +) : ListWindowMessageArg() + +data class ListWindowShortsArg( + override val argId: Byte, + override val typeTag: Byte, + override val hasExtra: Boolean, + override val extra: Byte, + val values: List, +) : ListWindowMessageArg() + +internal val ListWindowMessageArgCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): ListWindowMessageArg { + val argId = field(S8) { it.argId } + val rawType = + field(S8) { v -> if (v.hasExtra) (v.typeTag.toInt() or 128).toByte() else v.typeTag } + val hasExtra = (rawType.toInt() and 128) != 0 + val typeTag = if (hasExtra) (rawType.toInt() and 127).toByte() else rawType + val extra: Byte = if (hasExtra) field(S8) { it.extra } else 0 + return when (typeTag.toInt()) { + 28 -> ListWindowByteArg(argId, typeTag, hasExtra, extra) + 30 -> { + val value = field(S64LE) { (it as ListWindowLongArg).value } + ListWindowLongArg(argId, typeTag, hasExtra, extra, value) + } + + 9, + 10, + 17 -> { + val value = field(S32LE) { (it as ListWindowIntArg).value } + ListWindowIntArg(argId, typeTag, hasExtra, extra, value) + } + + 5, + 18 -> { + val text = field(Utf16LeNullTerminated) { (it as ListWindowStringArg).text } + ListWindowStringArg(argId, typeTag, hasExtra, extra, text) + } + + else -> { + val count = field(U8) { (it as ListWindowShortsArg).values.size } + val values = + (0 until count).map { i -> field(S16LE) { (it as ListWindowShortsArg).values[i] } } + ListWindowShortsArg(argId, typeTag, hasExtra, extra, values) + } + } + } + } + +data class ListWindowEntry( + val id: Int, + val value: Int, + val arg: ListWindowMessageArg?, +) + +data class SelectionListWindowOpenPacket( + val windowId: Int, + val type: Byte, + val flag: Boolean, + val entries: List, +) + +object SelectionListWindowOpenPacketCodec : PacketCodec() { + override fun CodecScope.body(): SelectionListWindowOpenPacket { + val windowId = field(S32LE) { it.windowId } + val type = field(S8) { it.type } + val flag = field(U8) { if (it.flag) 1 else 0 } == 1 + val count = field(S8) { it.entries.size.toByte() }.toInt() + val entries = + (0 until count).map { i -> + val id = field(S32LE) { it.entries[i].id } + val value = field(S32LE) { it.entries[i].value } + val present = field(U8) { if (it.entries[i].arg != null) 1 else 0 } == 1 + val arg = if (present) field(ListWindowMessageArgCodec) { it.entries[i].arg!! } else null + ListWindowEntry(id, value, arg) + } + return SelectionListWindowOpenPacket(windowId, type, flag, entries) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SendChatCommandPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SendChatCommandPacket.kt new file mode 100644 index 0000000..a4df2f3 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SendChatCommandPacket.kt @@ -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.Utf16LeNullTerminated + +data class SendChatCommandPacket( + val message: String, +) + +object SendChatCommandPacketCodec : PacketCodec() { + override fun CodecScope.body(): SendChatCommandPacket { + val message = field(Utf16LeNullTerminated) { it.message } + return SendChatCommandPacket(message) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SendDirectMessagePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SendDirectMessagePacket.kt new file mode 100644 index 0000000..f4e8a5c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SendDirectMessagePacket.kt @@ -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 SendDirectMessagePacket( + val senderContextId: Long, + val recipientId: Long, +) + +object SendDirectMessagePacketCodec : PacketCodec() { + override fun CodecScope.body(): SendDirectMessagePacket { + val senderContextId = field(S64LE) { it.senderContextId } + val recipientId = field(S64LE) { it.recipientId } + return SendDirectMessagePacket(senderContextId, recipientId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerChatTemplate5002Packet.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerChatTemplate5002Packet.kt new file mode 100644 index 0000000..76c413d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerChatTemplate5002Packet.kt @@ -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 +import de.fiereu.bytecodec.Utf16LeNullTerminated + +data class ServerChatTemplate5002Packet( + val argument: String, +) + +object ServerChatTemplate5002PacketCodec : PacketCodec() { + override fun CodecScope.body(): ServerChatTemplate5002Packet { + field(S64LE) { 0L } + val argument = field(Utf16LeNullTerminated) { it.argument } + return ServerChatTemplate5002Packet(argument) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerChatTemplate5003Packet.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerChatTemplate5003Packet.kt new file mode 100644 index 0000000..caf868e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerChatTemplate5003Packet.kt @@ -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 +import de.fiereu.bytecodec.Utf16LeNullTerminated + +data class ServerChatTemplate5003Packet( + val argument: String, +) + +object ServerChatTemplate5003PacketCodec : PacketCodec() { + override fun CodecScope.body(): ServerChatTemplate5003Packet { + field(S64LE) { 0L } + val argument = field(Utf16LeNullTerminated) { it.argument } + return ServerChatTemplate5003Packet(argument) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerEndpointListPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerEndpointListPacket.kt new file mode 100644 index 0000000..e3500f1 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerEndpointListPacket.kt @@ -0,0 +1,64 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class NetAddress( + val tag: Int, + val handle: Int?, + val idHigh: Long?, + val idLow: Long?, +) + +data class GameServerEndpoint( + val publicAddress: NetAddress, + val privateAddress: NetAddress, + val port: Short, + val flags: Byte, +) + +data class ServerEndpointListPacket( + val digest: ByteArray, + val endpoints: List, +) { + override fun equals(other: Any?): Boolean = + other is ServerEndpointListPacket && + digest.contentEquals(other.digest) && + endpoints == other.endpoints + + override fun hashCode(): Int = digest.contentHashCode() * 31 + endpoints.hashCode() +} + +private val NetAddressCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): NetAddress { + val tag = field(U8) { it.tag } + return if (tag == 4) { + val handle = field(S32LE) { it.handle!! } + NetAddress(tag, handle, null, null) + } else { + val idHigh = field(S64LE) { it.idHigh!! } + val idLow = field(S64LE) { it.idLow!! } + NetAddress(tag, null, idHigh, idLow) + } + } + } + +private val GameServerEndpointCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): GameServerEndpoint { + field(S8) { 0 } + val publicAddress = field(NetAddressCodec) { it.publicAddress } + val privateAddress = field(NetAddressCodec) { it.privateAddress } + val port = field(S16LE) { it.port } + val flags = field(S8) { it.flags } + return GameServerEndpoint(publicAddress, privateAddress, port, flags) + } + } + +object ServerEndpointListPacketCodec : PacketCodec() { + override fun CodecScope.body(): ServerEndpointListPacket { + val digest = field(bytesPrefixed(U8)) { it.digest } + val endpoints = field(GameServerEndpointCodec.listPrefixed(U8)) { it.endpoints } + return ServerEndpointListPacket(digest, endpoints) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerMessagePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerMessagePacket.kt new file mode 100644 index 0000000..5b0017c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerMessagePacket.kt @@ -0,0 +1,63 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class ServerMessageArg( + val argId: Byte, + val type: Int, + val hasExtra: Boolean, + val extra: Byte, + val longValue: Long?, + val intValue: Int?, + val stringValue: String?, + val shortValues: List?, +) + +data class ServerMessagePacket( + val stringId: Int, + val args: List, + val showOnMap: Boolean, + val mode: Byte?, +) + +private val ServerMessageArgCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): ServerMessageArg { + val argId = field(S8) { it.argId } + val typeRaw = field(U8) { if (it.hasExtra) it.type or 128 else it.type } + val hasExtra = (typeRaw and 128) != 0 + val type = if (hasExtra) typeRaw and 127 else typeRaw + 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? = null + when { + type == 5 || type == 18 -> stringValue = field(Utf16LeNullTerminated) { it.stringValue!! } + type == 28 -> {} + type == 30 -> longValue = field(S64LE) { it.longValue!! } + type == 9 || type == 10 || type == 17 -> intValue = field(S32LE) { it.intValue!! } + else -> shortValues = field(S16LE.listPrefixed(U8)) { it.shortValues!! } + } + return ServerMessageArg( + argId, type, hasExtra, extra, longValue, intValue, stringValue, shortValues + ) + } + } + +object ServerMessagePacketCodec : PacketCodec() { + override fun CodecScope.body(): ServerMessagePacket { + val stringId = field(S32LE) { it.stringId } + val flags = + field(U8) { + (it.args.size and 63) or + (if (it.showOnMap) 64 else 0) or + (if (it.mode != null) 128 else 0) + } + val count = flags and 63 + val args = (0 until count).map { i -> field(ServerMessageArgCodec) { it.args[i] } } + val showOnMap = (flags and 64) != 0 + val mode = if (flags and 128 != 0) field(S8) { it.mode!! } else null + return ServerMessagePacket(stringId, args, showOnMap, mode) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerNoticePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerNoticePacket.kt new file mode 100644 index 0000000..3a828c3 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ServerNoticePacket.kt @@ -0,0 +1,18 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class ServerNoticePacket( + val type: Short, + val id: Int, + val message: String, +) + +object ServerNoticePacketCodec : PacketCodec() { + override fun CodecScope.body(): ServerNoticePacket { + val type = field(S16LE, ServerNoticePacket::type) + val id = field(S32LE, ServerNoticePacket::id) + val message = field(Utf16LeNullTerminated, ServerNoticePacket::message) + return ServerNoticePacket(type, id, message) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SessionExpiryInitPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SessionExpiryInitPacket.kt new file mode 100644 index 0000000..072e512 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SessionExpiryInitPacket.kt @@ -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.S8 + +data class SessionExpiryInitPacket( + val tileSessionByte: Byte, + val expirySeconds: Short, +) + +object SessionExpiryInitPacketCodec : PacketCodec() { + override fun CodecScope.body(): SessionExpiryInitPacket { + val tileSessionByte = field(S8) { it.tileSessionByte } + val expirySeconds = field(S16LE) { it.expirySeconds } + return SessionExpiryInitPacket(tileSessionByte, expirySeconds) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SessionInitAcknowledgePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SessionInitAcknowledgePacket.kt new file mode 100644 index 0000000..6336652 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SessionInitAcknowledgePacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec + +data class SessionInitAcknowledgePacket(val placeholder: Unit = Unit) + +object SessionInitAcknowledgePacketCodec : PacketCodec() { + override fun CodecScope.body(): SessionInitAcknowledgePacket { + return SessionInitAcknowledgePacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetActiveMovesetPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetActiveMovesetPacket.kt new file mode 100644 index 0000000..e114e01 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetActiveMovesetPacket.kt @@ -0,0 +1,44 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class SetActiveMovesetPacket( + val partySlot: Short, + val pokemonEntityId: Long, + val moveIds: ByteArray, +) { + override fun equals(other: Any?): Boolean = + other is SetActiveMovesetPacket && + partySlot == other.partySlot && + pokemonEntityId == other.pokemonEntityId && + moveIds.contentEquals(other.moveIds) + + override fun hashCode(): Int { + var r = partySlot.toInt() + r = r * 31 + pokemonEntityId.hashCode() + r = r * 31 + moveIds.contentHashCode() + return r + } +} + +private val MoveIdsCodec: Codec = + object : Codec { + 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 SetActiveMovesetPacketCodec : PacketCodec() { + override fun CodecScope.body(): SetActiveMovesetPacket { + val partySlot = field(S16LE) { it.partySlot } + val pokemonEntityId = field(S64LE) { it.pokemonEntityId } + val moveIds = field(MoveIdsCodec) { it.moveIds } + return SetActiveMovesetPacket(partySlot, pokemonEntityId, moveIds) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetBattleMonsterAppearancePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetBattleMonsterAppearancePacket.kt new file mode 100644 index 0000000..1e8d85d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetBattleMonsterAppearancePacket.kt @@ -0,0 +1,39 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class SetBattleMonsterAppearancePacket( + val partySlot: Short, + val pokemonEntityId: Long, + val shininessType: Byte, + val colorPalette: List, +) + +private val ColorPaletteCodec: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val list = ArrayList() + while (buf.remaining() >= 2) { + list.add(S16LE.read(buf)) + } + return list + } + + override fun write(buf: WriteBuffer, value: List) { + for (entry in value) S16LE.write(buf, entry) + } + } + +object SetBattleMonsterAppearancePacketCodec : + PacketCodec() { + override fun CodecScope.body(): + SetBattleMonsterAppearancePacket { + val partySlot = field(S16LE) { it.partySlot } + val pokemonEntityId = field(S64LE) { it.pokemonEntityId } + val shininessType = field(S8) { it.shininessType } + val colorPalette = field(ColorPaletteCodec) { it.colorPalette } + return SetBattleMonsterAppearancePacket( + partySlot, pokemonEntityId, shininessType, colorPalette + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetCharacterNamePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetCharacterNamePacket.kt new file mode 100644 index 0000000..86b699b --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetCharacterNamePacket.kt @@ -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.Utf16LeNullTerminated + +data class SetCharacterNamePacket( + val characterEntityId: Long, + val newName: String, +) + +object SetCharacterNamePacketCodec : PacketCodec() { + override fun CodecScope.body(): SetCharacterNamePacket { + val characterEntityId = field(S64LE) { it.characterEntityId } + val newName = field(Utf16LeNullTerminated) { it.newName } + return SetCharacterNamePacket(characterEntityId, newName) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetChatUserIgnoredPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetChatUserIgnoredPacket.kt new file mode 100644 index 0000000..809822d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetChatUserIgnoredPacket.kt @@ -0,0 +1,18 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class SetChatUserIgnoredPacket( + val channelType: Byte, + val userId: Short, + val ignored: Boolean, +) + +object SetChatUserIgnoredPacketCodec : PacketCodec() { + override fun CodecScope.body(): SetChatUserIgnoredPacket { + val channelType = field(S8) { it.channelType } + val userId = field(S16LE) { it.userId } + val ignored = field(Bool) { it.ignored } + return SetChatUserIgnoredPacket(channelType, userId, ignored) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetPlayerTitlePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetPlayerTitlePacket.kt new file mode 100644 index 0000000..d5770f5 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SetPlayerTitlePacket.kt @@ -0,0 +1,14 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec +import de.fiereu.bytecodec.Utf16LeNullTerminated + +data class SetPlayerTitlePacket(val titleText: String) + +object SetPlayerTitlePacketCodec : PacketCodec() { + override fun CodecScope.body(): SetPlayerTitlePacket { + val titleText = field(Utf16LeNullTerminated) { it.titleText } + return SetPlayerTitlePacket(titleText) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ShopPriceTablePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ShopPriceTablePacket.kt new file mode 100644 index 0000000..b60f7ab --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ShopPriceTablePacket.kt @@ -0,0 +1,18 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class ShopPriceTablePacket( + val category: Byte, + val prices: List>, +) + +private val PriceEntryCodec: Codec> = S16LE.then(S16LE) + +object ShopPriceTablePacketCodec : PacketCodec() { + override fun CodecScope.body(): ShopPriceTablePacket { + val category = field(S8) { it.category } + val prices = field(PriceEntryCodec.listPrefixed(U16LE)) { it.prices } + return ShopPriceTablePacket(category, prices) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ShopSellRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ShopSellRequestPacket.kt new file mode 100644 index 0000000..12a4bf5 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ShopSellRequestPacket.kt @@ -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 ShopSellRequestPacket( + val itemEntityId: Long, + val quantity: Short, +) + +object ShopSellRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): ShopSellRequestPacket { + val itemEntityId = field(S64LE) { it.itemEntityId } + val quantity = field(S16LE) { it.quantity } + return ShopSellRequestPacket(itemEntityId, quantity) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialActionOutcomePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialActionOutcomePacket.kt new file mode 100644 index 0000000..f0e37e3 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialActionOutcomePacket.kt @@ -0,0 +1,22 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class SocialActionOutcomePacket( + val action: Int, + val entityId: Long?, + val value: Short?, +) + +object SocialActionOutcomePacketCodec : PacketCodec() { + override fun CodecScope.body(): SocialActionOutcomePacket { + val action = field(U8) { it.action } + val entityId: Long? = + if (resolveKind(action) == 1) field(S64LE) { it.entityId!! } else null + val value: Short? = + if (resolveKind(action) == 2) field(S16LE) { it.value!! } else null + return SocialActionOutcomePacket(action, entityId, value) + } + + private fun resolveKind(action: Int): Int = 0 +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialEntryFlagSetPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialEntryFlagSetPacket.kt new file mode 100644 index 0000000..02aa5ff --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialEntryFlagSetPacket.kt @@ -0,0 +1,18 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class SocialEntryFlagSetPacket( + val playerId: Long, + val flag: Byte, + val value: Short, +) + +object SocialEntryFlagSetPacketCodec : PacketCodec() { + override fun CodecScope.body(): SocialEntryFlagSetPacket { + val playerId = field(S64LE) { it.playerId } + val flag = field(S8) { it.flag } + val value = field(S16LE) { it.value } + return SocialEntryFlagSetPacket(playerId, flag, value) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialEntryPresencePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialEntryPresencePacket.kt new file mode 100644 index 0000000..ed1956a --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialEntryPresencePacket.kt @@ -0,0 +1,18 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class SocialEntryPresencePacket( + val playerId: Long, + val status: Short, + val online: Boolean, +) + +object SocialEntryPresencePacketCodec : PacketCodec() { + override fun CodecScope.body(): SocialEntryPresencePacket { + val playerId = field(S64LE) { it.playerId } + val status = field(S16LE) { it.status } + val online = field(Bool) { it.online } + return SocialEntryPresencePacket(playerId, status, online) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialEntryRenamePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialEntryRenamePacket.kt new file mode 100644 index 0000000..b95fb1f --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialEntryRenamePacket.kt @@ -0,0 +1,18 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class SocialEntryRenamePacket( + val playerId: Long, + val errorCode: Byte, + val name: String?, +) + +object SocialEntryRenamePacketCodec : PacketCodec() { + override fun CodecScope.body(): SocialEntryRenamePacket { + val playerId = field(S64LE) { it.playerId } + val errorCode = field(S8) { it.errorCode } + val name = if (errorCode.toInt() == 0) field(Utf16LeNullTerminated) { it.name!! } else null + return SocialEntryRenamePacket(playerId, errorCode, name) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialListEntryAddPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialListEntryAddPacket.kt new file mode 100644 index 0000000..f8f66d8 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialListEntryAddPacket.kt @@ -0,0 +1,17 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec +import de.fiereu.openmmo.common.Pokemon +import de.fiereu.openmmo.net.game.codecs.PokemonCodec + +data class SocialListEntryAddPacket( + val pokemon: Pokemon, +) + +object SocialListEntryAddPacketCodec : PacketCodec() { + override fun CodecScope.body(): SocialListEntryAddPacket { + val pokemon = field(PokemonCodec) { it.pokemon } + return SocialListEntryAddPacket(pokemon) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialListEntryRemovePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialListEntryRemovePacket.kt new file mode 100644 index 0000000..f5f8d5d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialListEntryRemovePacket.kt @@ -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 SocialListEntryRemovePacket( + val listType: Byte, + val entityId: Long, +) + +object SocialListEntryRemovePacketCodec : PacketCodec() { + override fun CodecScope.body(): SocialListEntryRemovePacket { + val listType = field(S8) { it.listType } + val entityId = field(S64LE) { it.entityId } + return SocialListEntryRemovePacket(listType, entityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialProfileDialogOpenPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialProfileDialogOpenPacket.kt new file mode 100644 index 0000000..d003d14 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SocialProfileDialogOpenPacket.kt @@ -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 +import de.fiereu.openmmo.common.Pokemon +import de.fiereu.openmmo.net.game.codecs.PokemonCodec + +data class SocialProfileDialogOpenPacket( + val status: Byte, + val content: Pokemon?, +) + +object SocialProfileDialogOpenPacketCodec : PacketCodec() { + override fun CodecScope.body(): SocialProfileDialogOpenPacket { + val status = field(S8) { it.status } + val content = if (status.toInt() == 0) field(PokemonCodec) { it.content!! } else null + return SocialProfileDialogOpenPacket(status, content) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SpatialGroupDeletePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SpatialGroupDeletePacket.kt new file mode 100644 index 0000000..0fb0b37 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SpatialGroupDeletePacket.kt @@ -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.U8 + +data class SpatialGroupDeletePacket( + val group: Int, + val entityId: Long, +) + +object SpatialGroupDeletePacketCodec : PacketCodec() { + override fun CodecScope.body(): SpatialGroupDeletePacket { + val group = field(U8) { it.group } + val entityId = field(S64LE) { it.entityId } + return SpatialGroupDeletePacket(group, entityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SpatialGroupInsertPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SpatialGroupInsertPacket.kt new file mode 100644 index 0000000..f9bc354 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SpatialGroupInsertPacket.kt @@ -0,0 +1,23 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class SpatialGroupInsertPacket( + val group: Int, + val entityId: Long, + val value: Short, + val extraCoordPresent: Boolean, + val extraValue: Short?, +) + +object SpatialGroupInsertPacketCodec : PacketCodec() { + override fun CodecScope.body(): SpatialGroupInsertPacket { + val group = field(U8) { it.group } + val entityId = field(S64LE) { it.entityId } + val value = field(S16LE) { it.value } + val extraCoordPresent = false + val extraValue: Short? = + if (extraCoordPresent) field(S16LE) { it.extraValue ?: 0 } else null + return SpatialGroupInsertPacket(group, entityId, value, extraCoordPresent, extraValue) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SpatialGroupSnapshotPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SpatialGroupSnapshotPacket.kt new file mode 100644 index 0000000..c732669 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SpatialGroupSnapshotPacket.kt @@ -0,0 +1,32 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class SpatialGroupEntry( + val entityId: Long, + val value: Short, + val extraValue: Short?, +) + +data class SpatialGroupSnapshotPacket( + val group: Int, + val extraCoordPresent: Boolean, + val entries: List, +) + +object SpatialGroupSnapshotPacketCodec : PacketCodec() { + override fun CodecScope.body(): SpatialGroupSnapshotPacket { + val group = field(U8) { it.group } + val extraCoordPresent = false + val count = field(U16LE) { it.entries.size } + val entries = ArrayList(count) + repeat(count) { i -> + val entityId = field(S64LE) { it.entries[i].entityId } + val value = field(S16LE) { it.entries[i].value } + val extraValue: Short? = + if (extraCoordPresent) field(S16LE) { it.entries[i].extraValue ?: 0 } else null + entries.add(SpatialGroupEntry(entityId, value, extraValue)) + } + return SpatialGroupSnapshotPacket(group, extraCoordPresent, entries) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SpectateRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SpectateRequestPacket.kt new file mode 100644 index 0000000..1aa2997 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SpectateRequestPacket.kt @@ -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 SpectateRequestPacket( + val targetEntityId: Long, +) + +object SpectateRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): SpectateRequestPacket { + val targetEntityId = field(S64LE) { it.targetEntityId } + return SpectateRequestPacket(targetEntityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageBoxClosePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageBoxClosePacket.kt new file mode 100644 index 0000000..b786d8f --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageBoxClosePacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec + +data class StorageBoxClosePacket(val placeholder: Unit = Unit) + +object StorageBoxClosePacketCodec : PacketCodec() { + override fun CodecScope.body(): StorageBoxClosePacket { + return StorageBoxClosePacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageBoxEntriesRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageBoxEntriesRequestPacket.kt new file mode 100644 index 0000000..ddf3c99 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageBoxEntriesRequestPacket.kt @@ -0,0 +1,18 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class StorageBoxEntriesRequestPacket( + val listType: Byte, + val itemIds: List, + val flags: Short, +) + +object StorageBoxEntriesRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): StorageBoxEntriesRequestPacket { + val listType = field(S8) { it.listType } + val itemIds = field(S32LE.listPrefixed(U8)) { it.itemIds } + val flags = field(S16LE) { it.flags } + return StorageBoxEntriesRequestPacket(listType, itemIds, flags) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageBoxFilterPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageBoxFilterPacket.kt new file mode 100644 index 0000000..5fa6804 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageBoxFilterPacket.kt @@ -0,0 +1,40 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class StorageBoxFilterPacket( + val listTypeIndex: Byte?, + val boxName: String?, + val cookieData: ByteArray?, +) { + override fun equals(other: Any?): Boolean = + other is StorageBoxFilterPacket && + listTypeIndex == other.listTypeIndex && + boxName == other.boxName && + (cookieData?.contentEquals(other.cookieData ?: ByteArray(0)) ?: (other.cookieData == null)) + + override fun hashCode(): Int { + var r = listTypeIndex?.hashCode() ?: 0 + r = r * 31 + (boxName?.hashCode() ?: 0) + r = r * 31 + (cookieData?.contentHashCode() ?: 0) + return r + } +} + +private val CookieBytes = bytesPrefixed(U8) + +object StorageBoxFilterPacketCodec : PacketCodec() { + override fun CodecScope.body(): StorageBoxFilterPacket { + val typeFlags = + field(U8) { + (if (it.boxName != null) 1 else 0) or (if (it.cookieData != null) 2 else 0) + } + val listTypeIndex: Byte? = + if (typeFlags and 1 != 0) field(S8) { it.listTypeIndex ?: 0 } else null + val boxName: String? = + if (typeFlags and 1 != 0) field(Utf16LeNullTerminated) { it.boxName ?: "" } else null + val cookieData: ByteArray? = + if (typeFlags and 2 != 0) field(CookieBytes) { it.cookieData ?: ByteArray(0) } else null + return StorageBoxFilterPacket(listTypeIndex, boxName, cookieData) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageBoxRequestPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageBoxRequestPacket.kt new file mode 100644 index 0000000..277aa25 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageBoxRequestPacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec + +class StorageBoxRequestPacket + +object StorageBoxRequestPacketCodec : PacketCodec() { + override fun CodecScope.body(): StorageBoxRequestPacket { + return StorageBoxRequestPacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageContextWindowPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageContextWindowPacket.kt new file mode 100644 index 0000000..07cfb7c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageContextWindowPacket.kt @@ -0,0 +1,44 @@ +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 StorageBoxItem( + val slot: Byte, + val valueA: Short, + val valueB: Short, + val valueC: Short, + val valueD: Short, + val quantity: Byte, + val ball: Byte, + val location: Byte, +) + +data class StorageContextWindowPacket( + val kind: Byte, + val items: List, +) + +object StorageContextWindowPacketCodec : PacketCodec() { + override fun CodecScope.body(): StorageContextWindowPacket { + val kind = field(S8) { it.kind } + val count = field(S8) { it.items.size.toByte() }.toInt() + val items = ArrayList(if (count > 0) count else 0) + repeat(if (count > 0) count else 0) { i -> + val slot = field(S8) { it.items[i].slot } + val valueA = field(S16LE) { it.items[i].valueA } + val valueB = field(S16LE) { it.items[i].valueB } + val valueC = field(S16LE) { it.items[i].valueC } + val valueD = field(S16LE) { it.items[i].valueD } + val quantity = field(S8) { it.items[i].quantity } + val ball = field(S8) { it.items[i].ball } + val location = field(S8) { it.items[i].location } + items.add( + StorageBoxItem(slot, valueA, valueB, valueC, valueD, quantity, ball, location) + ) + } + return StorageContextWindowPacket(kind, items) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageInventoryPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageInventoryPacket.kt new file mode 100644 index 0000000..7551103 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StorageInventoryPacket.kt @@ -0,0 +1,56 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class StorageQuantity(val id: Short, val count: Int) + +data class StorageByteQuantity(val id: Byte, val count: Int) + +data class StorageInventoryPacket( + val header: Short, + val totalA: Int, + val totalB: Int, + val valueC: Int, + val usedA: Int, + val usedB: Int, + val listA: List, + val listB: List, + val listC: List, + val listD: List, +) + +private val StorageQuantityCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): StorageQuantity { + val id = field(S16LE) { it.id } + val count = field(S32LE) { it.count } + return StorageQuantity(id, count) + } + } + +private val StorageByteQuantityCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): StorageByteQuantity { + val id = field(S8) { it.id } + val count = field(S32LE) { it.count } + return StorageByteQuantity(id, count) + } + } + +object StorageInventoryPacketCodec : PacketCodec() { + override fun CodecScope.body(): StorageInventoryPacket { + val header = field(S16LE) { it.header } + val totalA = field(S32LE) { it.totalA } + val totalB = field(S32LE) { it.totalB } + val valueC = field(S32LE) { it.valueC } + val usedA = field(S32LE) { it.usedA } + val usedB = field(S32LE) { it.usedB } + val listA = field(StorageQuantityCodec.listPrefixed(U8)) { it.listA } + val listB = field(StorageByteQuantityCodec.listPrefixed(U8)) { it.listB } + val listC = field(StorageQuantityCodec.listPrefixed(U8)) { it.listC } + val listD = field(StorageQuantityCodec.listPrefixed(U8)) { it.listD } + return StorageInventoryPacket( + header, totalA, totalB, valueC, usedA, usedB, listA, listB, listC, listD + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StreamChunkPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StreamChunkPacket.kt new file mode 100644 index 0000000..d029eaa --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StreamChunkPacket.kt @@ -0,0 +1,33 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class StreamChunkPacket( + val streamId: Long, + val finalChunk: Boolean, + val chunk: ByteArray, +) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is StreamChunkPacket) return false + return streamId == other.streamId && + finalChunk == other.finalChunk && + chunk.contentEquals(other.chunk) + } + + override fun hashCode(): Int { + var result = streamId.hashCode() + result = 31 * result + finalChunk.hashCode() + result = 31 * result + chunk.contentHashCode() + return result + } +} + +object StreamChunkPacketCodec : PacketCodec() { + override fun CodecScope.body(): StreamChunkPacket { + val streamId = field(S64LE, StreamChunkPacket::streamId) + val finalChunk = field(Bool, StreamChunkPacket::finalChunk) + val chunk = field(bytesPrefixed(U16LE), StreamChunkPacket::chunk) + return StreamChunkPacket(streamId, finalChunk, chunk) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StringCommandPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StringCommandPacket.kt new file mode 100644 index 0000000..a166c8f --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/StringCommandPacket.kt @@ -0,0 +1,14 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec +import de.fiereu.bytecodec.Utf16LeNullTerminated + +data class StringCommandPacket(val command: String) + +object StringCommandPacketCodec : PacketCodec() { + override fun CodecScope.body(): StringCommandPacket { + val command = field(Utf16LeNullTerminated) { it.command } + return StringCommandPacket(command) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SubmitBreedingPartyPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SubmitBreedingPartyPacket.kt new file mode 100644 index 0000000..e6a7b6c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SubmitBreedingPartyPacket.kt @@ -0,0 +1,44 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +private val BreedingPartyEntityIds: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val count = (buf.remaining() - 2) / 8 + val result = ArrayList(count) + repeat(count) { + var v = 0L + for (i in 0 until 8) { + v = v or ((buf.readByte().toLong() and 0xFF) shl (i * 8)) + } + result.add(v) + } + return result + } + + override fun write(buf: WriteBuffer, value: List) { + for (id in value) { + for (i in 0 until 8) { + buf.writeByte(((id shr (i * 8)) and 0xFF).toByte()) + } + } + } + } + +data class SubmitBreedingPartyPacket( + val sessionId: Byte, + val pokemonEntityIds: List, + val slotIndex: Byte, + val stateFlag: Byte, +) + +object SubmitBreedingPartyPacketCodec : PacketCodec() { + override fun CodecScope.body(): SubmitBreedingPartyPacket { + val sessionId = field(S8) { it.sessionId } + val pokemonEntityIds = field(BreedingPartyEntityIds) { it.pokemonEntityIds } + val slotIndex = field(S8) { it.slotIndex } + val stateFlag = field(S8) { it.stateFlag } + return SubmitBreedingPartyPacket(sessionId, pokemonEntityIds, slotIndex, stateFlag) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SwapInventorySlotsPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SwapInventorySlotsPacket.kt new file mode 100644 index 0000000..c8468f8 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/SwapInventorySlotsPacket.kt @@ -0,0 +1,30 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class SlotSwap( + val sourceListType: Byte, + val sourceSlot: Short, + val destinationListType: Byte, + val destinationSlot: Short, +) + +private val SlotSwapCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): SlotSwap { + val sourceListType = field(S8) { it.sourceListType } + val sourceSlot = field(S16LE) { it.sourceSlot } + val destinationListType = field(S8) { it.destinationListType } + val destinationSlot = field(S16LE) { it.destinationSlot } + return SlotSwap(sourceListType, sourceSlot, destinationListType, destinationSlot) + } + } + +data class SwapInventorySlotsPacket(val swaps: List) + +object SwapInventorySlotsPacketCodec : PacketCodec() { + override fun CodecScope.body(): SwapInventorySlotsPacket { + val swaps = field(SlotSwapCodec.listPrefixed(U8)) { it.swaps } + return SwapInventorySlotsPacket(swaps) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamFoundPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamFoundPacket.kt new file mode 100644 index 0000000..6dc5962 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamFoundPacket.kt @@ -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.Utf16LeNullTerminated + +data class TeamFoundPacket( + val teamName: String, + val teamTag: String, +) + +object TeamFoundPacketCodec : PacketCodec() { + override fun CodecScope.body(): TeamFoundPacket { + val teamName = field(Utf16LeNullTerminated) { it.teamName } + val teamTag = field(Utf16LeNullTerminated) { it.teamTag } + return TeamFoundPacket(teamName, teamTag) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamNameChangePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamNameChangePacket.kt new file mode 100644 index 0000000..1ff3b80 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamNameChangePacket.kt @@ -0,0 +1,20 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class TeamNameChangePacket( + val checkOnly: Boolean, + val teamId: Short, + val teamName: String, + val teamTag: String, +) + +object TeamNameChangePacketCodec : PacketCodec() { + override fun CodecScope.body(): TeamNameChangePacket { + val checkOnly = field(Bool) { it.checkOnly } + val teamId = field(S16LE) { it.teamId } + val teamName = field(Utf16LeNullTerminated) { it.teamName } + val teamTag = field(Utf16LeNullTerminated) { it.teamTag } + return TeamNameChangePacket(checkOnly, teamId, teamName, teamTag) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamPreviewLeadSubmitPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamPreviewLeadSubmitPacket.kt new file mode 100644 index 0000000..1a28b9f --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamPreviewLeadSubmitPacket.kt @@ -0,0 +1,71 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class RibbonEntry( + val ribbonId: Byte, + val value: Byte, +) + +private val RibbonEntryCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): RibbonEntry { + val ribbonId = field(S8) { it.ribbonId } + val value = field(S8) { it.value } + return RibbonEntry(ribbonId, value) + } + } + +data class TeamPreviewAppearance( + val kind: Byte, + val shinyTypeId: Byte?, + val form: Byte?, + val moveIds: List?, + val ribbons: List?, + val simpleForm: Byte?, +) + +private val AppearanceCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): TeamPreviewAppearance { + val kind = field(S8) { it.kind } + if (kind.toInt() == 1) { + val shinyTypeId = field(S8) { it.shinyTypeId ?: -1 } + val form = field(S8) { it.form ?: 0 } + val moveIds = field(S16LE.listPrefixed(U8)) { it.moveIds ?: emptyList() } + val ribbons = field(RibbonEntryCodec.listPrefixed(U8)) { it.ribbons ?: emptyList() } + return TeamPreviewAppearance(kind, shinyTypeId, form, moveIds, ribbons, null) + } else if (kind.toInt() == 6) { + val simpleForm = field(S8) { it.simpleForm ?: 0 } + return TeamPreviewAppearance(kind, null, null, null, null, simpleForm) + } + return TeamPreviewAppearance(kind, null, null, null, null, null) + } + } + +data class TeamPreviewLeadSubmitPacket( + val pokemonEntityId: Long, + val battleSlot: Byte, + val appearance: TeamPreviewAppearance?, + val teamSide: Short, + val reserved: Byte, +) + +object TeamPreviewLeadSubmitPacketCodec : PacketCodec() { + override fun CodecScope.body(): TeamPreviewLeadSubmitPacket { + val pokemonEntityId = field(S64LE) { it.pokemonEntityId } + val battleSlot = field(S8) { it.battleSlot } + val present = field(U8) { if (it.appearance != null) 1 else 0 } + val appearance = + if (present != 0) field(AppearanceCodec) { it.appearance!! } else null + val teamSide = field(S16LE) { it.teamSide } + val reserved = field(S8) { it.reserved } + return TeamPreviewLeadSubmitPacket( + pokemonEntityId, + battleSlot, + appearance, + teamSide, + reserved, + ) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamPreviewRevealPickPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamPreviewRevealPickPacket.kt new file mode 100644 index 0000000..f5b30b9 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamPreviewRevealPickPacket.kt @@ -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 TeamPreviewRevealPickPacket( + val entityId: Long, +) + +object TeamPreviewRevealPickPacketCodec : PacketCodec() { + override fun CodecScope.body(): TeamPreviewRevealPickPacket { + val entityId = field(S64LE) { it.entityId } + return TeamPreviewRevealPickPacket(entityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamPreviewSidePickPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamPreviewSidePickPacket.kt new file mode 100644 index 0000000..f081198 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TeamPreviewSidePickPacket.kt @@ -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 TeamPreviewSidePickPacket( + val pokemonEntityId: Long, + val side: Short, +) + +object TeamPreviewSidePickPacketCodec : PacketCodec() { + override fun CodecScope.body(): TeamPreviewSidePickPacket { + val pokemonEntityId = field(S64LE) { it.pokemonEntityId } + val side = field(S16LE) { it.side } + return TeamPreviewSidePickPacket(pokemonEntityId, side) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TextArgumentPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TextArgumentPacket.kt new file mode 100644 index 0000000..c0d0919 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TextArgumentPacket.kt @@ -0,0 +1,14 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec +import de.fiereu.bytecodec.Utf16LeNullTerminated + +data class TextArgumentPacket(val text: String) + +object TextArgumentPacketCodec : PacketCodec() { + override fun CodecScope.body(): TextArgumentPacket { + val text = field(Utf16LeNullTerminated) { it.text } + return TextArgumentPacket(text) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TokenPayloadPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TokenPayloadPacket.kt index 513aba2..21ad7d3 100644 --- a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TokenPayloadPacket.kt +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TokenPayloadPacket.kt @@ -1,34 +1,30 @@ package de.fiereu.openmmo.net.game.packets -import de.fiereu.bytecodec.Codec -import de.fiereu.bytecodec.CodecScope -import de.fiereu.bytecodec.PacketCodec -import de.fiereu.bytecodec.ReadBuffer -import de.fiereu.bytecodec.WriteBuffer +import de.fiereu.bytecodec.* data class TokenPayloadPacket(val payload: ByteArray) { - override fun equals(other: Any?): Boolean = - other is TokenPayloadPacket && payload.contentEquals(other.payload) + override fun equals(other: Any?): Boolean = + other is TokenPayloadPacket && payload.contentEquals(other.payload) - override fun hashCode(): Int = payload.contentHashCode() + override fun hashCode(): Int = payload.contentHashCode() } private val TokenPayloadBytes: Codec = object : Codec { - override fun read(buf: ReadBuffer): ByteArray { - val data = ByteArray(buf.remaining()) - if (data.isNotEmpty()) buf.readBytes(data) - return data - } + override fun read(buf: ReadBuffer): ByteArray { + val data = ByteArray(buf.remaining()) + if (data.isNotEmpty()) buf.readBytes(data) + return data + } - override fun write(buf: WriteBuffer, value: ByteArray) { - if (value.isNotEmpty()) buf.writeBytes(value) - } + override fun write(buf: WriteBuffer, value: ByteArray) { + if (value.isNotEmpty()) buf.writeBytes(value) + } } object TokenPayloadPacketCodec : PacketCodec() { - override fun CodecScope.body() = - TokenPayloadPacket( - payload = field(TokenPayloadBytes, TokenPayloadPacket::payload), - ) + override fun CodecScope.body() = + TokenPayloadPacket( + payload = field(TokenPayloadBytes, TokenPayloadPacket::payload), + ) } diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TournamentMatchupsPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TournamentMatchupsPacket.kt new file mode 100644 index 0000000..20b0081 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TournamentMatchupsPacket.kt @@ -0,0 +1,49 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class TournamentMatchup( + val value: Short, + val type: Byte, + val entityId: Long, + val moveRefA: Short?, + val moveRefB: Short?, +) + +data class TournamentMatchupsPacket( + val matchups: List, +) + +private object TournamentMatchupCodec : PacketCodec() { + override fun CodecScope.body(): TournamentMatchup { + val value = field(S16LE, TournamentMatchup::value) + val type = field(S8, TournamentMatchup::type) + val entityId = field(S64LE, TournamentMatchup::entityId) + if (type.toInt() != 0) { + val moveRefA = field(S16LE) { it.moveRefA!! } + val moveRefB = field(S16LE) { it.moveRefB!! } + return TournamentMatchup(value, type, entityId, moveRefA, moveRefB) + } + return TournamentMatchup(value, type, entityId, null, null) + } +} + +private val TournamentMatchupListPrefixedU16: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U16LE.read(buf) + return List(n) { TournamentMatchupCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U16LE.write(buf, value.size) + value.forEach { TournamentMatchupCodec.write(buf, it) } + } + } + +object TournamentMatchupsPacketCodec : PacketCodec() { + override fun CodecScope.body(): TournamentMatchupsPacket { + val matchups = field(TournamentMatchupListPrefixedU16, TournamentMatchupsPacket::matchups) + return TournamentMatchupsPacket(matchups) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TournamentRegistrationPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TournamentRegistrationPacket.kt new file mode 100644 index 0000000..88584dc --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TournamentRegistrationPacket.kt @@ -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 TournamentRegistrationPacket( + val register: Boolean, +) + +object TournamentRegistrationPacketCodec : PacketCodec() { + override fun CodecScope.body(): TournamentRegistrationPacket { + val register = field(Bool) { it.register } + return TournamentRegistrationPacket(register) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TournamentTeleportAcceptPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TournamentTeleportAcceptPacket.kt new file mode 100644 index 0000000..3251394 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TournamentTeleportAcceptPacket.kt @@ -0,0 +1,12 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec + +class TournamentTeleportAcceptPacket + +object TournamentTeleportAcceptPacketCodec : PacketCodec() { + override fun CodecScope.body(): TournamentTeleportAcceptPacket { + return TournamentTeleportAcceptPacket() + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TourneyRegistrationPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TourneyRegistrationPacket.kt new file mode 100644 index 0000000..61d36df --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TourneyRegistrationPacket.kt @@ -0,0 +1,18 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class TourneyRegistrationPacket( + val tournamentId: Byte, + val isActive: Boolean, + val tabIndex: Short, +) + +object TourneyRegistrationPacketCodec : PacketCodec() { + override fun CodecScope.body(): TourneyRegistrationPacket { + val tournamentId = field(S8) { it.tournamentId } + val isActive = field(Bool) { it.isActive } + val tabIndex = field(S16LE) { it.tabIndex } + return TourneyRegistrationPacket(tournamentId, isActive, tabIndex) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TrackedEntitySlotsPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TrackedEntitySlotsPacket.kt new file mode 100644 index 0000000..1e20866 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TrackedEntitySlotsPacket.kt @@ -0,0 +1,28 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class TrackedEntitySlot( + val count: Short, + val entityId: Long, +) + +data class TrackedEntitySlotsPacket( + val slots: List, +) + +private val TrackedEntitySlotCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): TrackedEntitySlot { + val count = field(S16LE) { it.count } + val entityId = field(S64LE) { it.entityId } + return TrackedEntitySlot(count, entityId) + } + } + +object TrackedEntitySlotsPacketCodec : PacketCodec() { + override fun CodecScope.body(): TrackedEntitySlotsPacket { + val slots = field(TrackedEntitySlotCodec.listPrefixed(U8)) { it.slots } + return TrackedEntitySlotsPacket(slots) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TradeActionPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TradeActionPacket.kt new file mode 100644 index 0000000..322f7a4 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TradeActionPacket.kt @@ -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 TradeActionPacket(val action: Byte) + +object TradeActionPacketCodec : PacketCodec() { + override fun CodecScope.body(): TradeActionPacket { + val action = field(S8) { it.action } + return TradeActionPacket(action) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TradeListEntryPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TradeListEntryPacket.kt new file mode 100644 index 0000000..6315ca9 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TradeListEntryPacket.kt @@ -0,0 +1,17 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec +import de.fiereu.openmmo.common.Pokemon +import de.fiereu.openmmo.net.game.codecs.PokemonCodec + +data class TradeListEntryPacket( + val pokemon: Pokemon, +) + +object TradeListEntryPacketCodec : PacketCodec() { + override fun CodecScope.body(): TradeListEntryPacket { + val pokemon = field(PokemonCodec) { it.pokemon } + return TradeListEntryPacket(pokemon) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TradeSelectMonPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TradeSelectMonPacket.kt new file mode 100644 index 0000000..deda549 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TradeSelectMonPacket.kt @@ -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 TradeSelectMonPacket(val slotIndex: Int) + +object TradeSelectMonPacketCodec : PacketCodec() { + override fun CodecScope.body(): TradeSelectMonPacket { + val slotIndex = field(S32LE) { it.slotIndex } + return TradeSelectMonPacket(slotIndex) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TypedBinaryDataPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TypedBinaryDataPacket.kt new file mode 100644 index 0000000..78a49f8 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/TypedBinaryDataPacket.kt @@ -0,0 +1,25 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class TypedBinaryDataPacket( + val dataType: Byte, + val data: ByteArray, +) { + override fun equals(other: Any?): Boolean = + other is TypedBinaryDataPacket && + dataType == other.dataType && + data.contentEquals(other.data) + + override fun hashCode(): Int = dataType * 31 + data.contentHashCode() +} + +private val TypedBinaryDataBytes = bytesPrefixed(U8) + +object TypedBinaryDataPacketCodec : PacketCodec() { + override fun CodecScope.body(): TypedBinaryDataPacket { + val dataType = field(S8) { it.dataType } + val data = field(TypedBinaryDataBytes) { it.data } + return TypedBinaryDataPacket(dataType, data) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/UnblockPlayerPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/UnblockPlayerPacket.kt new file mode 100644 index 0000000..72d740e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/UnblockPlayerPacket.kt @@ -0,0 +1,14 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.CodecScope +import de.fiereu.bytecodec.PacketCodec +import de.fiereu.bytecodec.Utf16LeNullTerminated + +data class UnblockPlayerPacket(val username: String) + +object UnblockPlayerPacketCodec : PacketCodec() { + override fun CodecScope.body(): UnblockPlayerPacket { + val username = field(Utf16LeNullTerminated) { it.username } + return UnblockPlayerPacket(username) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ViewScalePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ViewScalePacket.kt new file mode 100644 index 0000000..84b8120 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/ViewScalePacket.kt @@ -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 ViewScalePacket( + val viewScale: Byte, +) + +object ViewScalePacketCodec : PacketCodec() { + override fun CodecScope.body(): ViewScalePacket { + val viewScale = field(S8) { it.viewScale } + return ViewScalePacket(viewScale) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WarpTileInteractPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WarpTileInteractPacket.kt new file mode 100644 index 0000000..2113869 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WarpTileInteractPacket.kt @@ -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 WarpTileInteractPacket( + val floorId: Byte, + val warpMode: Byte, +) + +object WarpTileInteractPacketCodec : PacketCodec() { + override fun CodecScope.body(): WarpTileInteractPacket { + val floorId = field(S8) { it.floorId } + val warpMode = field(S8) { it.warpMode } + return WarpTileInteractPacket(floorId, warpMode) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldActionDispatchPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldActionDispatchPacket.kt new file mode 100644 index 0000000..48af3b3 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldActionDispatchPacket.kt @@ -0,0 +1,18 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class WorldActionDispatchPacket( + val action: Byte, + val subject: Byte, + val args: List, +) + +object WorldActionDispatchPacketCodec : PacketCodec() { + override fun CodecScope.body(): WorldActionDispatchPacket { + val action = field(S8) { it.action } + val subject = field(S8) { it.subject } + val args = field(S16LE.listPrefixed(U8)) { it.args } + return WorldActionDispatchPacket(action, subject, args) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldEntityInteractPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldEntityInteractPacket.kt new file mode 100644 index 0000000..6548b99 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldEntityInteractPacket.kt @@ -0,0 +1,22 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class WorldEntityInteractPacket( + val itemTypeId: Short, + val targetEntityId: Long, + val quantity: Short, + val actionFlag: Byte, + val reserved: Byte, +) + +object WorldEntityInteractPacketCodec : PacketCodec() { + override fun CodecScope.body(): WorldEntityInteractPacket { + val itemTypeId = field(S16LE) { it.itemTypeId } + val targetEntityId = field(S64LE) { it.targetEntityId } + val quantity = field(S16LE) { it.quantity } + val actionFlag = field(S8) { it.actionFlag } + val reserved = field(S8) { it.reserved } + return WorldEntityInteractPacket(itemTypeId, targetEntityId, quantity, actionFlag, reserved) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldEntityStateResetPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldEntityStateResetPacket.kt new file mode 100644 index 0000000..1dcd48d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldEntityStateResetPacket.kt @@ -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.S16LE + +data class WorldEntityStateResetPacket( + val entityType: Short, +) + +object WorldEntityStateResetPacketCodec : PacketCodec() { + override fun CodecScope.body(): WorldEntityStateResetPacket { + val entityType = field(S16LE) { it.entityType } + return WorldEntityStateResetPacket(entityType) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldFlagSetPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldFlagSetPacket.kt new file mode 100644 index 0000000..e858dd0 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldFlagSetPacket.kt @@ -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 WorldFlagSetPacket( + val group: Byte, + val index: Short, + val value: Byte, +) + +object WorldFlagSetPacketCodec : PacketCodec() { + override fun CodecScope.body(): WorldFlagSetPacket { + val group = field(S8) { it.group } + val index = field(S16LE) { it.index } + val value = field(S8) { it.value } + return WorldFlagSetPacket(group, index, value) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldFlagStateUpdatePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldFlagStateUpdatePacket.kt new file mode 100644 index 0000000..897817a --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldFlagStateUpdatePacket.kt @@ -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.S32LE +import de.fiereu.bytecodec.S8 + +data class WorldFlagStateUpdatePacket( + val key: Byte, + val state: Byte, + val value: Int, +) + +object WorldFlagStateUpdatePacketCodec : PacketCodec() { + override fun CodecScope.body(): WorldFlagStateUpdatePacket { + val key = field(S8) { it.key } + val state = field(S8) { it.state } + val value = field(S32LE) { it.value } + return WorldFlagStateUpdatePacket(key, state, value) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldFlagTableResetPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldFlagTableResetPacket.kt new file mode 100644 index 0000000..1a87a5e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldFlagTableResetPacket.kt @@ -0,0 +1,27 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class WorldFlagTableResetPacket( + val flagGroups: List, +) { + override fun equals(other: Any?): Boolean = + other is WorldFlagTableResetPacket && + flagGroups.size == other.flagGroups.size && + flagGroups.indices.all { flagGroups[it].contentEquals(other.flagGroups[it]) } + + override fun hashCode(): Int { + var r = 1 + for (g in flagGroups) r = r * 31 + g.contentHashCode() + return r + } +} + +private val FlagGroupBytes = bytesPrefixed(U16LE) + +object WorldFlagTableResetPacketCodec : PacketCodec() { + override fun CodecScope.body(): WorldFlagTableResetPacket { + val flagGroups = field(FlagGroupBytes.listPrefixed(U8)) { it.flagGroups } + return WorldFlagTableResetPacket(flagGroups) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldJoinConfirmPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldJoinConfirmPacket.kt new file mode 100644 index 0000000..33db47b --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldJoinConfirmPacket.kt @@ -0,0 +1,25 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class WorldJoinConfirmPacket( + val success: Boolean, + val entityId: Long?, + val name: String?, +) + +object WorldJoinConfirmPacketCodec : PacketCodec() { + override fun CodecScope.body(): WorldJoinConfirmPacket { + val success = field(Bool) { it.success } + val entityId: Long? + val name: String? + if (success) { + entityId = field(S64LE) { it.entityId!! } + name = field(Utf16LeNullTerminated) { it.name!! } + } else { + entityId = null + name = null + } + return WorldJoinConfirmPacket(success, entityId, name) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldNoticeSlotPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldNoticeSlotPacket.kt new file mode 100644 index 0000000..b72c7cb --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldNoticeSlotPacket.kt @@ -0,0 +1,71 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class WorldNoticeArg( + val argId: Byte, + val type: Int, + val hasExtra: Boolean, + val extra: Byte, + val longValue: Long?, + val intValue: Int?, + val stringValue: String?, + val shortValues: List?, +) + +private val WorldNoticeArgCodec: Codec = + object : PacketCodec() { + override fun CodecScope.body(): WorldNoticeArg { + 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? = 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 WorldNoticeArg( + argId, type, hasExtra, extra, longValue, intValue, stringValue, shortValues + ) + } + } + +data class WorldNoticeSlotPacket( + val slot: Byte, + val flags: Byte, + val severity: Byte, + val stringId: Int?, + val args: List, + val text: String?, +) + +object WorldNoticeSlotPacketCodec : PacketCodec() { + override fun CodecScope.body(): WorldNoticeSlotPacket { + val slot = field(S8) { it.slot } + val flags = field(S8) { it.flags } + if (flags.toInt() != 0) { + field(S8) { 0 } + val severity = field(S8) { it.severity } + val stringId = if (flags.toInt() and 1 != 0) field(S32LE) { it.stringId!! } else null + val args = + if (flags.toInt() and 2 != 0) { + val count = field(S8) { it.args.size.toByte() }.toInt() + (0 until count).map { i -> field(WorldNoticeArgCodec) { it.args[i] } } + } else emptyList() + val text = if (flags.toInt() and 4 != 0) field(Utf16LeNullTerminated) { it.text!! } else null + return WorldNoticeSlotPacket(slot, flags, severity, stringId, args, text) + } + return WorldNoticeSlotPacket(slot, flags, 0, null, emptyList(), null) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldObjectInstanceDespawnPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldObjectInstanceDespawnPacket.kt new file mode 100644 index 0000000..d6ae71e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldObjectInstanceDespawnPacket.kt @@ -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 WorldObjectInstanceDespawnPacket( + val entityId: Long, +) + +object WorldObjectInstanceDespawnPacketCodec : PacketCodec() { + override fun CodecScope.body(): WorldObjectInstanceDespawnPacket { + val entityId = field(S64LE) { it.entityId } + return WorldObjectInstanceDespawnPacket(entityId) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldOverlayObjectSetPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldOverlayObjectSetPacket.kt new file mode 100644 index 0000000..5228a1a --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldOverlayObjectSetPacket.kt @@ -0,0 +1,32 @@ +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 WorldOverlayObjectSetPacket( + val objectId: Byte, + val action: Byte, + val byteA: Byte?, + val byteB: Byte?, + val typeId: Short?, + val flag: Byte?, + val x: Short?, + val y: Short?, +) + +object WorldOverlayObjectSetPacketCodec : PacketCodec() { + override fun CodecScope.body(): WorldOverlayObjectSetPacket { + val objectId = field(S8) { it.objectId } + val action = field(S8) { it.action } + val present = action.toInt() != 0 + val byteA = if (present) field(S8) { it.byteA!! } else null + val byteB = if (present) field(S8) { it.byteB!! } else null + val typeId = if (present) field(S16LE) { it.typeId!! } else null + val flag = if (present) field(S8) { it.flag!! } else null + val x = if (present) field(S16LE) { it.x!! } else null + val y = if (present) field(S16LE) { it.y!! } else null + return WorldOverlayObjectSetPacket(objectId, action, byteA, byteB, typeId, flag, x, y) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldSessionStatePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldSessionStatePacket.kt new file mode 100644 index 0000000..d0373db --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldSessionStatePacket.kt @@ -0,0 +1,36 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class WorldSessionStatePacket( + val worldState: Int, + val payloadBlocks: List?, +) { + override fun equals(other: Any?): Boolean { + if (other !is WorldSessionStatePacket) return false + if (worldState != other.worldState) return false + val a = payloadBlocks + val b = other.payloadBlocks + if (a == null) return b == null + if (b == null || a.size != b.size) return false + for (i in a.indices) if (!a[i].contentEquals(b[i])) return false + return true + } + + override fun hashCode(): Int { + var r = worldState + payloadBlocks?.forEach { r = r * 31 + it.contentHashCode() } + return r + } +} + +object WorldSessionStatePacketCodec : PacketCodec() { + override fun CodecScope.body(): WorldSessionStatePacket { + val worldState = field(U8) { it.worldState } + val payloadBlocks = + if (worldState == 11) { + field(bytesPrefixed(U8).listPrefixed(U8)) { it.payloadBlocks!! } + } else null + return WorldSessionStatePacket(worldState, payloadBlocks) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldStateControlPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldStateControlPacket.kt new file mode 100644 index 0000000..e3b457e --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldStateControlPacket.kt @@ -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 WorldStateControlPacket( + val actionType: Byte, + val value: Int, +) + +object WorldStateControlPacketCodec : PacketCodec() { + override fun CodecScope.body(): WorldStateControlPacket { + val actionType = field(S8) { it.actionType } + val value = field(S32LE) { it.value } + return WorldStateControlPacket(actionType, value) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldStateValuePacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldStateValuePacket.kt new file mode 100644 index 0000000..d879b3c --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldStateValuePacket.kt @@ -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.S16LE + +data class WorldStateValuePacket( + val value: Short, +) + +object WorldStateValuePacketCodec : PacketCodec() { + override fun CodecScope.body(): WorldStateValuePacket { + val value = field(S16LE, WorldStateValuePacket::value) + return WorldStateValuePacket(value) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldTimedEventStatusPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldTimedEventStatusPacket.kt new file mode 100644 index 0000000..3d21bc8 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldTimedEventStatusPacket.kt @@ -0,0 +1,22 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class WorldTimedEventStatusPacket( + val active: Boolean, + val startTime: Long?, + val endTime: Long?, + val value: Short?, + val shininessType: Byte?, +) + +object WorldTimedEventStatusPacketCodec : PacketCodec() { + override fun CodecScope.body(): WorldTimedEventStatusPacket { + val active = field(U8) { if (it.active) 1 else 0 } == 1 + val startTime = if (active) field(S64LE) { it.startTime!! } else null + val endTime = if (active) field(S64LE) { it.endTime!! } else null + val value = if (active) field(S16LE) { it.value!! } else null + val shininessType = if (active) field(S8) { it.shininessType!! } else null + return WorldTimedEventStatusPacket(active, startTime, endTime, value, shininessType) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldToggleFlagsPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldToggleFlagsPacket.kt new file mode 100644 index 0000000..8da6c44 --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldToggleFlagsPacket.kt @@ -0,0 +1,40 @@ +package de.fiereu.openmmo.net.game.packets + +import de.fiereu.bytecodec.* + +data class WorldToggleFlagsEntry( + val id: Short, + val state: Boolean, +) + +data class WorldToggleFlagsPacket( + val entries: List, +) + +private object WorldToggleFlagsEntryCodec : PacketCodec() { + override fun CodecScope.body(): WorldToggleFlagsEntry { + val id = field(S16LE, WorldToggleFlagsEntry::id) + val state = field(Bool, WorldToggleFlagsEntry::state) + return WorldToggleFlagsEntry(id, state) + } +} + +private val WorldToggleFlagsEntryListPrefixedU8: Codec> = + object : Codec> { + override fun read(buf: ReadBuffer): List { + val n = U8.read(buf) + return List(n) { WorldToggleFlagsEntryCodec.read(buf) } + } + + override fun write(buf: WriteBuffer, value: List) { + U8.write(buf, value.size) + value.forEach { WorldToggleFlagsEntryCodec.write(buf, it) } + } + } + +object WorldToggleFlagsPacketCodec : PacketCodec() { + override fun CodecScope.body(): WorldToggleFlagsPacket { + val entries = field(WorldToggleFlagsEntryListPrefixedU8, WorldToggleFlagsPacket::entries) + return WorldToggleFlagsPacket(entries) + } +} diff --git a/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldVersionPacket.kt b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldVersionPacket.kt new file mode 100644 index 0000000..efb143d --- /dev/null +++ b/protocols.game/src/main/kotlin/de/fiereu/openmmo/net/game/packets/WorldVersionPacket.kt @@ -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.S16LE + +data class WorldVersionPacket( + val major: Short, + val build: Short, + val minor: Short, +) + +object WorldVersionPacketCodec : PacketCodec() { + override fun CodecScope.body(): WorldVersionPacket { + val major = field(S16LE) { it.major } + val build = field(S16LE) { it.build } + val minor = field(S16LE) { it.minor } + return WorldVersionPacket(major, build, minor) + } +}