mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
[General] Send and read ActorSpeech packets
This commit is contained in:
parent
d2178e5414
commit
f0f0b2dcc9
14 changed files with 127 additions and 5 deletions
|
@ -21,6 +21,18 @@
|
|||
#include <components/interpreter/interpreter.hpp>
|
||||
#include <components/interpreter/defines.hpp>
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Include additional headers for multiplayer purposes
|
||||
*/
|
||||
#include "../mwmp/Main.hpp"
|
||||
#include "../mwmp/CellController.hpp"
|
||||
#include "../mwmp/LocalActor.hpp"
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/journal.hpp"
|
||||
|
@ -646,6 +658,22 @@ namespace MWDialogue
|
|||
winMgr->messageBox(info->mResponse);
|
||||
if (!info->mSound.empty())
|
||||
sndMgr->say(actor, info->mSound);
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
If we are the cell authority over this actor, we need to record this new
|
||||
sound for it
|
||||
*/
|
||||
if (mwmp::Main::get().getCellController()->isLocalActor(actor))
|
||||
{
|
||||
mwmp::LocalActor *localActor = mwmp::Main::get().getCellController()->getLocalActor(actor);
|
||||
localActor->response = info->mResponse;
|
||||
localActor->sound = info->mSound;
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ void ActorList::reset()
|
|||
positionActors.clear();
|
||||
animFlagsActors.clear();
|
||||
animPlayActors.clear();
|
||||
speechActors.clear();
|
||||
statsDynamicActors.clear();
|
||||
guid = mwmp::Main::get().getNetworking()->getLocalPlayer()->guid;
|
||||
}
|
||||
|
@ -59,6 +60,11 @@ void ActorList::addAnimPlayActor(LocalActor localActor)
|
|||
animPlayActors.push_back(localActor);
|
||||
}
|
||||
|
||||
void ActorList::addSpeechActor(LocalActor localActor)
|
||||
{
|
||||
speechActors.push_back(localActor);
|
||||
}
|
||||
|
||||
void ActorList::addStatsDynamicActor(LocalActor localActor)
|
||||
{
|
||||
statsDynamicActors.push_back(localActor);
|
||||
|
@ -94,6 +100,16 @@ void ActorList::sendAnimPlayActors()
|
|||
}
|
||||
}
|
||||
|
||||
void ActorList::sendSpeechActors()
|
||||
{
|
||||
if (speechActors.size() > 0)
|
||||
{
|
||||
baseActors = speechActors;
|
||||
Main::get().getNetworking()->getActorPacket(ID_ACTOR_SPEECH)->setActorList(this);
|
||||
Main::get().getNetworking()->getActorPacket(ID_ACTOR_SPEECH)->Send();
|
||||
}
|
||||
}
|
||||
|
||||
void ActorList::sendStatsDynamicActors()
|
||||
{
|
||||
if (statsDynamicActors.size() > 0)
|
||||
|
|
|
@ -24,11 +24,13 @@ namespace mwmp
|
|||
void addPositionActor(LocalActor localActor);
|
||||
void addAnimFlagsActor(LocalActor localActor);
|
||||
void addAnimPlayActor(LocalActor localActor);
|
||||
void addSpeechActor(LocalActor localActor);
|
||||
void addStatsDynamicActor(LocalActor localActor);
|
||||
|
||||
void sendPositionActors();
|
||||
void sendAnimFlagsActors();
|
||||
void sendAnimPlayActors();
|
||||
void sendSpeechActors();
|
||||
void sendStatsDynamicActors();
|
||||
|
||||
void editActorsInCell(MWWorld::CellStore* cellStore);
|
||||
|
@ -41,6 +43,7 @@ namespace mwmp
|
|||
std::vector<BaseActor> positionActors;
|
||||
std::vector<BaseActor> animFlagsActors;
|
||||
std::vector<BaseActor> animPlayActors;
|
||||
std::vector<BaseActor> speechActors;
|
||||
std::vector<BaseActor> statsDynamicActors;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ void Cell::updateLocal(bool forceUpdate)
|
|||
actorList->sendPositionActors();
|
||||
actorList->sendAnimFlagsActors();
|
||||
actorList->sendAnimPlayActors();
|
||||
actorList->sendSpeechActors();
|
||||
actorList->sendStatsDynamicActors();
|
||||
}
|
||||
|
||||
|
@ -153,6 +154,26 @@ void Cell::readStatsDynamic(ActorList& actorList)
|
|||
}
|
||||
}
|
||||
|
||||
void Cell::readSpeech(ActorList& actorList)
|
||||
{
|
||||
initializeDedicatedActors(actorList);
|
||||
|
||||
BaseActor baseActor;
|
||||
|
||||
for (unsigned int i = 0; i < actorList.count; i++)
|
||||
{
|
||||
baseActor = actorList.baseActors.at(i);
|
||||
std::string mapIndex = Main::get().getCellController()->generateMapIndex(baseActor);
|
||||
|
||||
if (dedicatedActors.count(mapIndex) > 0)
|
||||
{
|
||||
DedicatedActor *actor = dedicatedActors[mapIndex];
|
||||
actor->response = baseActor.response;
|
||||
actor->sound = baseActor.sound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Cell::initializeLocalActors()
|
||||
{
|
||||
ESM::Cell esmCell = *store->getCell();
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace mwmp
|
|||
void readAnimFlags(ActorList& actorList);
|
||||
void readAnimPlay(ActorList& actorList);
|
||||
void readStatsDynamic(ActorList& actorList);
|
||||
void readSpeech(ActorList& actorList);
|
||||
|
||||
void initializeLocalActors();
|
||||
void initializeDedicatedActors(ActorList& actorList);
|
||||
|
|
|
@ -141,6 +141,19 @@ void CellController::readStatsDynamic(ActorList& actorList)
|
|||
}
|
||||
}
|
||||
|
||||
void CellController::readSpeech(ActorList& actorList)
|
||||
{
|
||||
std::string mapIndex = actorList.cell.getDescription();
|
||||
|
||||
initializeCell(actorList.cell);
|
||||
|
||||
// If this now exists, send it the data
|
||||
if (cellsActive.count(mapIndex) > 0)
|
||||
{
|
||||
cellsActive[mapIndex]->readSpeech(actorList);
|
||||
}
|
||||
}
|
||||
|
||||
void CellController::setLocalActorRecord(std::string actorIndex, std::string cellIndex)
|
||||
{
|
||||
localActorsToCells[actorIndex] = cellIndex;
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace mwmp
|
|||
void readAnimFlags(mwmp::ActorList& actorList);
|
||||
void readAnimPlay(mwmp::ActorList& actorList);
|
||||
void readStatsDynamic(mwmp::ActorList& actorList);
|
||||
void readSpeech(mwmp::ActorList& actorList);
|
||||
|
||||
void setLocalActorRecord(std::string actorIndex, std::string cellIndex);
|
||||
void removeLocalActorRecord(std::string actorIndex);
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
#include <components/openmw-mp/Log.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwmechanics/mechanicsmanagerimp.hpp"
|
||||
#include "../mwmechanics/movement.hpp"
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
|
||||
#include "../mwrender/animation.hpp"
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/worldimp.hpp"
|
||||
|
||||
|
@ -18,6 +23,7 @@ DedicatedActor::DedicatedActor()
|
|||
drawState = 0;
|
||||
movementFlags = 0;
|
||||
animation.groupname = "";
|
||||
sound = "";
|
||||
|
||||
creatureStats = new ESM::CreatureStats();
|
||||
creatureStats->blank();
|
||||
|
@ -34,6 +40,7 @@ void DedicatedActor::update(float dt)
|
|||
move(dt);
|
||||
setAnimFlags();
|
||||
playAnimation();
|
||||
playSound();
|
||||
setStatsDynamic();
|
||||
}
|
||||
|
||||
|
@ -80,6 +87,20 @@ void DedicatedActor::playAnimation()
|
|||
}
|
||||
}
|
||||
|
||||
void DedicatedActor::playSound()
|
||||
{
|
||||
if (!sound.empty())
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->say(ptr, sound);
|
||||
|
||||
MWBase::WindowManager *winMgr = MWBase::Environment::get().getWindowManager();
|
||||
if (winMgr->getSubtitlesEnabled())
|
||||
winMgr->messageBox(response);
|
||||
|
||||
sound.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void DedicatedActor::setStatsDynamic()
|
||||
{
|
||||
// Only set dynamic stats if they have valid values
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace mwmp
|
|||
void move(float dt);
|
||||
void setAnimFlags();
|
||||
void playAnimation();
|
||||
void playSound();
|
||||
void setStatsDynamic();
|
||||
|
||||
MWWorld::Ptr getPtr();
|
||||
|
|
|
@ -45,6 +45,7 @@ void LocalActor::update(bool forceUpdate)
|
|||
updatePosition(forceUpdate);
|
||||
updateAnimFlags(forceUpdate);
|
||||
updateAnimPlay();
|
||||
updateSpeech();
|
||||
updateStatsDynamic(forceUpdate);
|
||||
}
|
||||
|
||||
|
@ -130,6 +131,15 @@ void LocalActor::updateAnimPlay()
|
|||
}
|
||||
}
|
||||
|
||||
void LocalActor::updateSpeech()
|
||||
{
|
||||
if (!sound.empty())
|
||||
{
|
||||
mwmp::Main::get().getNetworking()->getActorList()->addSpeechActor(*this);
|
||||
sound.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void LocalActor::updateStatsDynamic(bool forceUpdate)
|
||||
{
|
||||
MWMechanics::CreatureStats *ptrCreatureStats = &ptr.getClass().getCreatureStats(ptr);
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace mwmp
|
|||
void updatePosition(bool forceUpdate);
|
||||
void updateAnimFlags(bool forceUpdate);
|
||||
void updateAnimPlay();
|
||||
void updateSpeech();
|
||||
void updateStatsDynamic(bool forceUpdate);
|
||||
|
||||
MWWorld::Ptr getPtr();
|
||||
|
|
|
@ -890,6 +890,12 @@ void Networking::processActorPacket(RakNet::Packet *packet)
|
|||
|
||||
break;
|
||||
}
|
||||
case ID_ACTOR_SPEECH:
|
||||
{
|
||||
//Main::get().getCellController()->readSpeech(actorList);
|
||||
|
||||
break;
|
||||
}
|
||||
case ID_ACTOR_ATTACK:
|
||||
{
|
||||
break;
|
||||
|
@ -898,10 +904,6 @@ void Networking::processActorPacket(RakNet::Packet *packet)
|
|||
{
|
||||
break;
|
||||
}
|
||||
case ID_ACTOR_SPEECH:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case ID_ACTOR_TEST:
|
||||
{
|
||||
break;
|
||||
|
|
|
@ -34,6 +34,9 @@ namespace mwmp
|
|||
char drawState;
|
||||
bool isFlying;
|
||||
|
||||
std::string response;
|
||||
std::string sound;
|
||||
|
||||
Animation animation;
|
||||
};
|
||||
|
||||
|
|
|
@ -38,7 +38,8 @@ void PacketActorSpeech::Packet(RakNet::BitStream *bs, bool send)
|
|||
RW(actor.refNumIndex, send);
|
||||
RW(actor.mpNum, send);
|
||||
|
||||
// TODO: Fill this in
|
||||
RW(actor.response, send);
|
||||
RW(actor.sound, send);
|
||||
|
||||
if (!send)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue