From 726b0513253fb15cdc85ff78511a92b7662b023e Mon Sep 17 00:00:00 2001 From: Trevor Flynn Date: Sun, 5 Nov 2017 16:19:59 -0800 Subject: [PATCH 1/3] Add SendPlaySoundMessage and supporting code. --- .../message/impl/SendPlaySoundMessage.java | 67 +++++++++++++++++++ .../r377/SendPlaySoundMessageEncoder.java | 27 ++++++++ 2 files changed, 94 insertions(+) create mode 100644 game/src/main/java/org/apollo/game/message/impl/SendPlaySoundMessage.java create mode 100644 game/src/main/java/org/apollo/game/release/r377/SendPlaySoundMessageEncoder.java diff --git a/game/src/main/java/org/apollo/game/message/impl/SendPlaySoundMessage.java b/game/src/main/java/org/apollo/game/message/impl/SendPlaySoundMessage.java new file mode 100644 index 000000000..9b6a8ee54 --- /dev/null +++ b/game/src/main/java/org/apollo/game/message/impl/SendPlaySoundMessage.java @@ -0,0 +1,67 @@ +package org.apollo.game.message.impl; + +import org.apollo.net.message.Message; + +/** + * A {@link Message} sent to the client to play a sound. + * + * @author tlf30 + */ +public final class SendPlaySoundMessage extends Message { + + /** + * The id of the sound to play. + */ + private final int id; + + /** + * The delay that the client should use before playing the sound. + */ + private final int delay; + + /** + * The type of sound to play. + */ + private final int type; + + /** + * Creates a new send play sound message. + * + * @param id The id of the sound to play. + * @param type The type of the sound to play. + * @param delay The delay before the client plays the sound + */ + public SendPlaySoundMessage(int id, int type, int delay) { + this.id = id; + this.type = type; + this.delay = delay; + } + + /** + * Gets the id of the sound. + * + * @return The id of the sound. + */ + public int getId() { + return id; + } + + /** + * Gets the type of the sound. + * + * @return The type of the sound. + */ + public int getType() { + return type; + } + + /** + * Gets the delay of the sound. + * + * @return The delay of the sound. + */ + public int getDelay() { + return delay; + } + +} \ No newline at end of file diff --git a/game/src/main/java/org/apollo/game/release/r377/SendPlaySoundMessageEncoder.java b/game/src/main/java/org/apollo/game/release/r377/SendPlaySoundMessageEncoder.java new file mode 100644 index 000000000..acb800bdc --- /dev/null +++ b/game/src/main/java/org/apollo/game/release/r377/SendPlaySoundMessageEncoder.java @@ -0,0 +1,27 @@ +package org.apollo.game.release.r377; + +import org.apollo.game.message.impl.SendFriendMessage; +import org.apollo.game.message.impl.SendPlaySoundMessage; +import org.apollo.net.codec.game.DataType; +import org.apollo.net.codec.game.GamePacket; +import org.apollo.net.codec.game.GamePacketBuilder; +import org.apollo.net.release.MessageEncoder; +import org.apollo.util.NameUtil; + +/** + * A {@link MessageEncoder} for the {@link SendPlaySoundMessage}. + * + * @author tlf30 + */ +public final class SendPlaySoundMessageEncoder extends MessageEncoder { + + @Override + public GamePacket encode(SendPlaySoundMessage message) { + GamePacketBuilder builder = new GamePacketBuilder(26); + builder.put(DataType.SHORT, message.getId()); + builder.put(DataType.BYTE, message.getType()); + builder.put(DataType.SHORT, message.getDelay()); + return builder.toGamePacket(); + } + +} \ No newline at end of file From f6bf374c11351b7cec89b8e88a1f9a914bb4d29d Mon Sep 17 00:00:00 2001 From: Trevor Flynn Date: Sun, 5 Nov 2017 16:25:31 -0800 Subject: [PATCH 2/3] Add missing changes to git --- .../apollo/game/release/r377/Release377.java | 51 ++----------------- .../r377/SendPlaySoundMessageEncoder.java | 2 - 2 files changed, 3 insertions(+), 50 deletions(-) diff --git a/game/src/main/java/org/apollo/game/release/r377/Release377.java b/game/src/main/java/org/apollo/game/release/r377/Release377.java index 2b2c1e577..b1843a5f0 100644 --- a/game/src/main/java/org/apollo/game/release/r377/Release377.java +++ b/game/src/main/java/org/apollo/game/release/r377/Release377.java @@ -1,53 +1,6 @@ package org.apollo.game.release.r377; -import org.apollo.game.message.impl.ClearRegionMessage; -import org.apollo.game.message.impl.CloseInterfaceMessage; -import org.apollo.game.message.impl.ConfigMessage; -import org.apollo.game.message.impl.DisplayCrossbonesMessage; -import org.apollo.game.message.impl.DisplayTabInterfaceMessage; -import org.apollo.game.message.impl.EnterAmountMessage; -import org.apollo.game.message.impl.FlashTabInterfaceMessage; -import org.apollo.game.message.impl.ForwardPrivateChatMessage; -import org.apollo.game.message.impl.FriendServerStatusMessage; -import org.apollo.game.message.impl.GroupedRegionUpdateMessage; -import org.apollo.game.message.impl.IdAssignmentMessage; -import org.apollo.game.message.impl.IgnoreListMessage; -import org.apollo.game.message.impl.LogoutMessage; -import org.apollo.game.message.impl.MobHintIconMessage; -import org.apollo.game.message.impl.NpcSynchronizationMessage; -import org.apollo.game.message.impl.OpenDialogueInterfaceMessage; -import org.apollo.game.message.impl.OpenDialogueOverlayMessage; -import org.apollo.game.message.impl.OpenInterfaceMessage; -import org.apollo.game.message.impl.OpenInterfaceSidebarMessage; -import org.apollo.game.message.impl.OpenOverlayMessage; -import org.apollo.game.message.impl.OpenSidebarMessage; -import org.apollo.game.message.impl.PlayerSynchronizationMessage; -import org.apollo.game.message.impl.PositionHintIconMessage; -import org.apollo.game.message.impl.PrivacyOptionMessage; -import org.apollo.game.message.impl.RegionChangeMessage; -import org.apollo.game.message.impl.RemoveObjectMessage; -import org.apollo.game.message.impl.RemoveTileItemMessage; -import org.apollo.game.message.impl.SendFriendMessage; -import org.apollo.game.message.impl.SendObjectMessage; -import org.apollo.game.message.impl.SendProjectileMessage; -import org.apollo.game.message.impl.SendPublicTileItemMessage; -import org.apollo.game.message.impl.SendTileItemMessage; -import org.apollo.game.message.impl.ServerChatMessage; -import org.apollo.game.message.impl.SetPlayerActionMessage; -import org.apollo.game.message.impl.SetUpdatedRegionMessage; -import org.apollo.game.message.impl.SetWidgetItemModelMessage; -import org.apollo.game.message.impl.SetWidgetModelAnimationMessage; -import org.apollo.game.message.impl.SetWidgetNpcModelMessage; -import org.apollo.game.message.impl.SetWidgetPlayerModelMessage; -import org.apollo.game.message.impl.SetWidgetTextMessage; -import org.apollo.game.message.impl.SetWidgetVisibilityMessage; -import org.apollo.game.message.impl.SwitchTabInterfaceMessage; -import org.apollo.game.message.impl.UpdateItemsMessage; -import org.apollo.game.message.impl.UpdateRunEnergyMessage; -import org.apollo.game.message.impl.UpdateSkillMessage; -import org.apollo.game.message.impl.UpdateSlottedItemsMessage; -import org.apollo.game.message.impl.UpdateTileItemMessage; -import org.apollo.game.message.impl.UpdateWeightMessage; +import org.apollo.game.message.impl.*; import org.apollo.net.meta.PacketMetaDataGroup; import org.apollo.net.release.Release; @@ -226,6 +179,8 @@ private void init() { register(OpenSidebarMessage.class, new OpenSidebarMessageEncoder()); register(OpenOverlayMessage.class, new OpenOverlayMessageEncoder()); register(OpenDialogueOverlayMessage.class, new OpenDialogueOverlayMessageEncoder()); + + register(SendPlaySoundMessage.class, new SendPlaySoundMessageEncoder()); } } \ No newline at end of file diff --git a/game/src/main/java/org/apollo/game/release/r377/SendPlaySoundMessageEncoder.java b/game/src/main/java/org/apollo/game/release/r377/SendPlaySoundMessageEncoder.java index acb800bdc..b29286d2e 100644 --- a/game/src/main/java/org/apollo/game/release/r377/SendPlaySoundMessageEncoder.java +++ b/game/src/main/java/org/apollo/game/release/r377/SendPlaySoundMessageEncoder.java @@ -1,12 +1,10 @@ package org.apollo.game.release.r377; -import org.apollo.game.message.impl.SendFriendMessage; import org.apollo.game.message.impl.SendPlaySoundMessage; import org.apollo.net.codec.game.DataType; import org.apollo.net.codec.game.GamePacket; import org.apollo.net.codec.game.GamePacketBuilder; import org.apollo.net.release.MessageEncoder; -import org.apollo.util.NameUtil; /** * A {@link MessageEncoder} for the {@link SendPlaySoundMessage}. From 828cf12ef3648f49997b868cea00dcb04957f043 Mon Sep 17 00:00:00 2001 From: Trevor Flynn Date: Mon, 13 Nov 2017 20:27:20 -0800 Subject: [PATCH 3/3] More explanations in documentation Made documentation explain delay and type. --- .../game/message/impl/SendPlaySoundMessage.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/game/src/main/java/org/apollo/game/message/impl/SendPlaySoundMessage.java b/game/src/main/java/org/apollo/game/message/impl/SendPlaySoundMessage.java index 9b6a8ee54..86a422f06 100644 --- a/game/src/main/java/org/apollo/game/message/impl/SendPlaySoundMessage.java +++ b/game/src/main/java/org/apollo/game/message/impl/SendPlaySoundMessage.java @@ -16,11 +16,13 @@ public final class SendPlaySoundMessage extends Message { /** * The delay that the client should use before playing the sound. + * Deplay is measured in milliseconds. */ private final int delay; /** * The type of sound to play. + * Usually 0. */ private final int type; @@ -28,8 +30,8 @@ public final class SendPlaySoundMessage extends Message { * Creates a new send play sound message. * * @param id The id of the sound to play. - * @param type The type of the sound to play. - * @param delay The delay before the client plays the sound + * @param type The type of the sound to play, usually 0. + * @param delay The delay in milliseconds before the client plays the sound */ public SendPlaySoundMessage(int id, int type, int delay) { this.id = id; @@ -56,12 +58,12 @@ public int getType() { } /** - * Gets the delay of the sound. + * Gets the number of milliseconds for the client to delay before playing the sound. * - * @return The delay of the sound. + * @return The delay of the sound in milliseconds. */ public int getDelay() { return delay; } -} \ No newline at end of file +}