1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 15:49:56 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Object/PacketObjectSound.cpp
David Cernat 27d35d73a2 [General] Implement OnObjectSound packet
Many interactions between players and objects now have their sounds sent to other players.
2020-02-29 18:15:41 +02:00

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);
}
}