Add and implement ID_MUSIC_PLAY

coverity_scan^2
David Cernat 8 years ago
parent f9ca98498d
commit ae39daf76a

@ -570,6 +570,21 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
break;
}
case ID_MUSIC_PLAY:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_MUSIC_PLAY from %s",
player->Npc()->mName.c_str());
myPacket->Read(event);
LOG_APPEND(Log::LOG_WARN, "- filename: %s",
event->filename.c_str());
myPacket->Send(event, true);
break;
}
case ID_VIDEO_PLAY:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_VIDEO_PLAY from %s",
@ -577,8 +592,8 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
myPacket->Read(event);
LOG_APPEND(Log::LOG_WARN, "- video: %s\n- allowSkipping: %s",
event->video.c_str(),
LOG_APPEND(Log::LOG_WARN, "- filename: %s\n- allowSkipping: %s",
event->filename.c_str(),
event->allowSkipping ? "true" : "false");
myPacket->Send(event, true);

@ -10,6 +10,7 @@
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/cellstore.hpp"
@ -946,14 +947,24 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
break;
}
case ID_MUSIC_PLAY:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_MUSIC_PLAY");
LOG_APPEND(Log::LOG_WARN, "- filename: %s",
event->filename.c_str());
MWBase::Environment::get().getSoundManager()->streamMusic(event->filename);
break;
}
case ID_VIDEO_PLAY:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_VIDEO_PLAY");
LOG_APPEND(Log::LOG_WARN, "- video: %s\n- allowSkipping: %s",
event->video.c_str(),
LOG_APPEND(Log::LOG_WARN, "- filename: %s\n- allowSkipping: %s",
event->filename.c_str(),
event->allowSkipping ? "true" : "false");
MWBase::Environment::get().getWindowManager()->playVideo(event->video, event->allowSkipping);
MWBase::Environment::get().getWindowManager()->playVideo(event->filename, event->allowSkipping);
break;
}

@ -90,7 +90,7 @@ namespace MWScript
// Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->video = name;
event->filename = name;
event->allowSkipping = allowSkipping;
mwmp::Main::get().getNetworking()->getWorldPacket(ID_VIDEO_PLAY)->Send(event);

@ -1,5 +1,8 @@
#include "extensions.hpp"
#include <components/openmw-mp/Base/WorldEvent.hpp>
#include "../mwmp/Main.hpp"
#include <components/compiler/extensions.hpp>
#include <components/compiler/opcodes.hpp>
@ -66,6 +69,11 @@ namespace MWScript
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop();
// Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->filename = sound;
mwmp::Main::get().getNetworking()->getWorldPacket(ID_MUSIC_PLAY)->Send(event);
MWBase::Environment::get().getSoundManager()->streamMusic (sound);
}
};

@ -162,7 +162,7 @@ add_component_dir (openmw-mp
Packets/World/PacketObjectRotate Packets/World/PacketObjectAnimPlay
Packets/World/PacketContainerAdd Packets/World/PacketContainerRemove Packets/World/PacketDoorActivate
Packets/World/PacketVideoPlay
Packets/World/PacketMusicPlay Packets/World/PacketVideoPlay
Packets/World/PacketScriptLocalShort Packets/World/PacketScriptLocalFloat Packets/World/PacketScriptMemberShort
Packets/World/PacketScriptGlobalShort)

@ -32,7 +32,7 @@ namespace mwmp
int lockLevel;
float scale;
std::string video;
std::string filename;
bool allowSkipping;
std::string animGroup;

@ -14,6 +14,7 @@
#include "../Packets/World/PacketContainerAdd.hpp"
#include "../Packets/World/PacketContainerRemove.hpp"
#include "../Packets/World/PacketDoorActivate.hpp"
#include "../Packets/World/PacketMusicPlay.hpp"
#include "../Packets/World/PacketVideoPlay.hpp"
#include "../Packets/World/PacketScriptLocalShort.hpp"
@ -45,6 +46,7 @@ mwmp::WorldPacketController::WorldPacketController(RakNet::RakPeerInterface *pee
AddPacket<PacketContainerAdd>(&packets, peer);
AddPacket<PacketContainerRemove>(&packets, peer);
AddPacket<PacketDoorActivate>(&packets, peer);
AddPacket<PacketMusicPlay>(&packets, peer);
AddPacket<PacketVideoPlay>(&packets, peer);
AddPacket<PacketScriptLocalShort>(&packets, peer);

@ -45,6 +45,7 @@ enum GameMessages
ID_CONTAINER_ADD,
ID_CONTAINER_REMOVE,
ID_DOOR_ACTIVATE,
ID_MUSIC_PLAY,
ID_VIDEO_PLAY,
ID_SCRIPT_LOCAL_SHORT,

@ -0,0 +1,16 @@
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketMusicPlay.hpp"
using namespace mwmp;
PacketMusicPlay::PacketMusicPlay(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
{
packetID = ID_VIDEO_PLAY;
}
void PacketMusicPlay::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send)
{
WorldPacket::Packet(bs, event, send);
RW(event->filename, send);
}

@ -0,0 +1,17 @@
#ifndef OPENMW_PACKETMUSICPLAY_HPP
#define OPENMW_PACKETMUSICPLAY_HPP
#include <components/openmw-mp/Packets/World/WorldPacket.hpp>
namespace mwmp
{
class PacketMusicPlay : public WorldPacket
{
public:
PacketMusicPlay(RakNet::RakPeerInterface *peer);
virtual void Packet(RakNet::BitStream *bs, WorldEvent *event, bool send);
};
}
#endif //OPENMW_PACKETMUSICPLAY_HPP

@ -12,6 +12,6 @@ void PacketVideoPlay::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send
{
WorldPacket::Packet(bs, event, send);
RW(event->video, send);
RW(event->filename, send);
RW(event->allowSkipping, send);
}

Loading…
Cancel
Save