Feat(Server): Add functions to send music packets to clients

pull/656/head
Dave Corley 8 months ago
parent b50c10b30c
commit 729b9f501d

@ -561,6 +561,11 @@ void ObjectFunctions::SetObjectSound(const char* soundId, double volume, double
tempObject.pitch = pitch;
}
void ObjectFunctions::SetObjectTrack(const char *soundId) noexcept
{
tempObject.musicFilename = soundId;
}
void ObjectFunctions::SetObjectSummonState(bool summonState) noexcept
{
tempObject.isSummon = summonState;
@ -833,6 +838,16 @@ void ObjectFunctions::SendObjectSound(bool sendToOtherPlayers, bool skipAttached
packet->Send(true);
}
void ObjectFunctions::SendObjectTrack(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept {
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_MUSIC_PLAY);
packet->setObjectList(&writeObjectList);
if (!skipAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void ObjectFunctions::SendObjectState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_STATE);

@ -117,6 +117,7 @@
{"SetObjectPosition", ObjectFunctions::SetObjectPosition},\
{"SetObjectRotation", ObjectFunctions::SetObjectRotation},\
{"SetObjectSound", ObjectFunctions::SetObjectSound},\
{"SetObjectTrack", ObjectFunctions::SetObjectTrack},\
\
{"SetObjectSummonState", ObjectFunctions::SetObjectSummonState},\
{"SetObjectSummonEffectId", ObjectFunctions::SetObjectSummonEffectId},\
@ -160,6 +161,7 @@
{"SendObjectTrap", ObjectFunctions::SendObjectTrap},\
{"SendObjectScale", ObjectFunctions::SendObjectScale},\
{"SendObjectSound", ObjectFunctions::SendObjectSound},\
{"SendObjectTrack", ObjectFunctions::SendObjectTrack},\
{"SendObjectState", ObjectFunctions::SendObjectState},\
{"SendObjectMove", ObjectFunctions::SendObjectMove},\
{"SendObjectRotate", ObjectFunctions::SendObjectRotate},\
@ -1087,7 +1089,21 @@ public:
*/
static void SetObjectRotation(double x, double y, double z) noexcept;
static void SetObjectSound(const char* soundId, double volume, double pitch) noexcept;
/**
* \brief Set the Sound of the temporary object stored on the server
*
* \param soundId Sets the refId of the sound to be played on the client
* \param volume Set the volume of the sound to be played on the client
* \param pitch Set the pitch of the sound to be played on the client
*/
static void SetObjectSound(const char *soundId, double volume, double pitch) noexcept;
/**
* \brief Set the Sound of the temporary object stored on the server
*
* \param track Sets the track name to be played on the client
*/
static void SetObjectTrack(const char *soundId) noexcept;
/**
* \brief Set the summon state of the temporary object stored on the server.
@ -1439,6 +1455,17 @@ public:
*/
static void SendObjectSound(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/**
* \brief Send a Music_Play packet.
*
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param skipAttachedPlayer Whether the packet should skip being sent to the player attached
* to the packet (false by default).
* \return void
*/
static void SendObjectTrack(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ObjectState packet.
*

Loading…
Cancel
Save