mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-15 15:49:56 +00:00
27d35d73a2
Many interactions between players and objects now have their sounds sent to other players.
37 lines
940 B
C++
37 lines
940 B
C++
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
#include "PacketObjectSound.hpp"
|
|
|
|
using namespace mwmp;
|
|
|
|
PacketObjectSound::PacketObjectSound(RakNet::RakPeerInterface *peer) : ObjectPacket(peer)
|
|
{
|
|
packetID = ID_OBJECT_SOUND;
|
|
hasCellData = true;
|
|
}
|
|
|
|
void PacketObjectSound::Packet(RakNet::BitStream *newBitstream, bool send)
|
|
{
|
|
if (!PacketHeader(newBitstream, send))
|
|
return;
|
|
|
|
BaseObject baseObject;
|
|
for (unsigned int i = 0; i < objectList->baseObjectCount; i++)
|
|
{
|
|
if (send)
|
|
baseObject = objectList->baseObjects.at(i);
|
|
|
|
RW(baseObject.isPlayer, send);
|
|
|
|
if (baseObject.isPlayer)
|
|
RW(baseObject.guid, send);
|
|
else
|
|
Object(baseObject, send);
|
|
|
|
RW(baseObject.soundId, send, true);
|
|
RW(baseObject.volume, send);
|
|
RW(baseObject.pitch, send);
|
|
|
|
if (!send)
|
|
objectList->baseObjects.push_back(baseObject);
|
|
}
|
|
}
|