[General] Implement PlayerSpeech packet

0.6.2
David Cernat 7 years ago
parent 605b06c303
commit be25decee2

@ -68,3 +68,15 @@ void DialogueFunctions::PlayAnimation(unsigned short pid, const char* groupname,
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_ANIM_PLAY)->Send(false);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_ANIM_PLAY)->Send(true);
}
void DialogueFunctions::PlaySpeech(unsigned short pid, const char* sound) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
player->sound = sound;
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SPEECH)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SPEECH)->Send(false);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SPEECH)->Send(true);
}

@ -12,7 +12,8 @@
\
{"SendTopicChanges", DialogueFunctions::SendTopicChanges},\
\
{"PlayAnimation", DialogueFunctions::PlayAnimation}
{"PlayAnimation", DialogueFunctions::PlayAnimation},\
{"PlaySpeech", DialogueFunctions::PlaySpeech}
class DialogueFunctions
{
@ -65,6 +66,7 @@ public:
static void SendTopicChanges(unsigned short pid, bool toOthers = false) noexcept;
static void PlayAnimation(unsigned short pid, const char* groupname, int mode = 0, int count = 1, bool persist = false) noexcept;
static void PlaySpeech(unsigned short pid, const char* sound) noexcept;
private:

@ -7,11 +7,14 @@
#include <apps/openmw/mwmechanics/steering.hpp>
#include "../mwbase/environment.hpp"
#include "../mwgui/windowmanagerimp.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwclass/npc.hpp"
#include "../mwdialogue/dialoguemanagerimp.hpp"
#include "../mwgui/windowmanagerimp.hpp"
#include "../mwinput/inputmanagerimp.hpp"
#include "../mwmechanics/actor.hpp"
@ -289,6 +292,15 @@ void DedicatedPlayer::playAnimation()
animation.groupname, animation.mode, animation.count, animation.persist);
}
void DedicatedPlayer::playSpeech()
{
MWBase::Environment::get().getSoundManager()->say(getPtr(), sound);
MWBase::WindowManager *winMgr = MWBase::Environment::get().getWindowManager();
if (winMgr->getSubtitlesEnabled())
winMgr->messageBox(MWBase::Environment::get().getDialogueManager()->getVoiceCaption(sound), MWGui::ShowInDialogueMode_Never);
}
MWWorld::Ptr DedicatedPlayer::getPtr()
{
return ptr;

@ -44,6 +44,7 @@ namespace mwmp
void setMarkerState(bool state);
void playAnimation();
void playSpeech();
MWWorld::Ptr getPtr();
MWWorld::Ptr getLiveCellPtr();

@ -7,6 +7,7 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/journal.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwclass/creature.hpp"
#include "../mwclass/npc.hpp"
@ -1452,3 +1453,12 @@ void LocalPlayer::playAnimation()
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(getPlayerPtr(),
animation.groupname, animation.mode, animation.count, animation.persist);
}
void LocalPlayer::playSpeech()
{
MWBase::Environment::get().getSoundManager()->say(getPlayerPtr(), sound);
MWBase::WindowManager *winMgr = MWBase::Environment::get().getWindowManager();
if (winMgr->getSubtitlesEnabled())
winMgr->messageBox(MWBase::Environment::get().getDialogueManager()->getVoiceCaption(sound), MWGui::ShowInDialogueMode_Never);
}

@ -91,6 +91,7 @@ namespace mwmp
void storeCurrentContainer(const MWWorld::Ptr& container, bool loot);
void playAnimation();
void playSpeech();
private:
Networking *getNetworking();

@ -15,7 +15,13 @@ namespace mwmp
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
// Placeholder to be filled in later
if (isLocal())
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_SPEECH about LocalPlayer from server");
static_cast<LocalPlayer*>(player)->playSpeech();
}
else if (player != 0)
static_cast<DedicatedPlayer*>(player)->playSpeech();
}
};
}

@ -271,6 +271,7 @@ namespace mwmp
CGStage charGenStage;
std::string passw;
std::string sound;
Animation animation;
bool isWerewolf;

@ -10,5 +10,5 @@ void mwmp::PacketPlayerSpeech::Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
// Placeholder to be filled in later
RW(player->sound, send);
}

Loading…
Cancel
Save