You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
226 lines
5.7 KiB
C++
226 lines
5.7 KiB
C++
#include "ActorList.hpp"
|
|
#include "Main.hpp"
|
|
#include "Networking.hpp"
|
|
#include "LocalPlayer.hpp"
|
|
|
|
#include <components/openmw-mp/Log.hpp>
|
|
|
|
using namespace mwmp;
|
|
using namespace std;
|
|
|
|
ActorList::ActorList()
|
|
{
|
|
|
|
}
|
|
|
|
ActorList::~ActorList()
|
|
{
|
|
|
|
}
|
|
|
|
Networking *ActorList::getNetworking()
|
|
{
|
|
return mwmp::Main::get().getNetworking();
|
|
}
|
|
|
|
void ActorList::reset()
|
|
{
|
|
cell.blank();
|
|
baseActors.clear();
|
|
positionActors.clear();
|
|
animFlagsActors.clear();
|
|
animPlayActors.clear();
|
|
speechActors.clear();
|
|
statsDynamicActors.clear();
|
|
deathActors.clear();
|
|
equipmentActors.clear();
|
|
attackActors.clear();
|
|
cellChangeActors.clear();
|
|
guid = mwmp::Main::get().getNetworking()->getLocalPlayer()->guid;
|
|
}
|
|
|
|
void ActorList::addActor(BaseActor baseActor)
|
|
{
|
|
baseActors.push_back(baseActor);
|
|
}
|
|
|
|
void ActorList::addActor(LocalActor localActor)
|
|
{
|
|
baseActors.push_back(localActor);
|
|
}
|
|
|
|
void ActorList::addPositionActor(LocalActor localActor)
|
|
{
|
|
positionActors.push_back(localActor);
|
|
}
|
|
|
|
void ActorList::addAnimFlagsActor(LocalActor localActor)
|
|
{
|
|
animFlagsActors.push_back(localActor);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
void ActorList::addDeathActor(LocalActor localActor)
|
|
{
|
|
deathActors.push_back(localActor);
|
|
}
|
|
|
|
void ActorList::addEquipmentActor(LocalActor localActor)
|
|
{
|
|
equipmentActors.push_back(localActor);
|
|
}
|
|
|
|
void ActorList::addAttackActor(LocalActor localActor)
|
|
{
|
|
attackActors.push_back(localActor);
|
|
}
|
|
|
|
void ActorList::addCellChangeActor(LocalActor localActor)
|
|
{
|
|
cellChangeActors.push_back(localActor);
|
|
}
|
|
|
|
void ActorList::sendPositionActors()
|
|
{
|
|
if (positionActors.size() > 0)
|
|
{
|
|
baseActors = positionActors;
|
|
Main::get().getNetworking()->getActorPacket(ID_ACTOR_POSITION)->setActorList(this);
|
|
Main::get().getNetworking()->getActorPacket(ID_ACTOR_POSITION)->Send();
|
|
}
|
|
}
|
|
|
|
void ActorList::sendAnimFlagsActors()
|
|
{
|
|
if (animFlagsActors.size() > 0)
|
|
{
|
|
baseActors = animFlagsActors;
|
|
Main::get().getNetworking()->getActorPacket(ID_ACTOR_ANIM_FLAGS)->setActorList(this);
|
|
Main::get().getNetworking()->getActorPacket(ID_ACTOR_ANIM_FLAGS)->Send();
|
|
}
|
|
}
|
|
|
|
void ActorList::sendAnimPlayActors()
|
|
{
|
|
if (animPlayActors.size() > 0)
|
|
{
|
|
baseActors = animPlayActors;
|
|
Main::get().getNetworking()->getActorPacket(ID_ACTOR_ANIM_PLAY)->setActorList(this);
|
|
Main::get().getNetworking()->getActorPacket(ID_ACTOR_ANIM_PLAY)->Send();
|
|
}
|
|
}
|
|
|
|
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)
|
|
{
|
|
baseActors = statsDynamicActors;
|
|
Main::get().getNetworking()->getActorPacket(ID_ACTOR_STATS_DYNAMIC)->setActorList(this);
|
|
Main::get().getNetworking()->getActorPacket(ID_ACTOR_STATS_DYNAMIC)->Send();
|
|
}
|
|
}
|
|
|
|
void ActorList::sendDeathActors()
|
|
{
|
|
if (deathActors.size() > 0)
|
|
{
|
|
baseActors = deathActors;
|
|
Main::get().getNetworking()->getActorPacket(ID_ACTOR_DEATH)->setActorList(this);
|
|
Main::get().getNetworking()->getActorPacket(ID_ACTOR_DEATH)->Send();
|
|
}
|
|
}
|
|
|
|
void ActorList::sendEquipmentActors()
|
|
{
|
|
if (equipmentActors.size() > 0)
|
|
{
|
|
baseActors = equipmentActors;
|
|
Main::get().getNetworking()->getActorPacket(ID_ACTOR_EQUIPMENT)->setActorList(this);
|
|
Main::get().getNetworking()->getActorPacket(ID_ACTOR_EQUIPMENT)->Send();
|
|
}
|
|
}
|
|
|
|
void ActorList::sendAttackActors()
|
|
{
|
|
if (attackActors.size() > 0)
|
|
{
|
|
baseActors = attackActors;
|
|
Main::get().getNetworking()->getActorPacket(ID_ACTOR_ATTACK)->setActorList(this);
|
|
Main::get().getNetworking()->getActorPacket(ID_ACTOR_ATTACK)->Send();
|
|
}
|
|
}
|
|
|
|
void ActorList::sendCellChangeActors()
|
|
{
|
|
if (cellChangeActors.size() > 0)
|
|
{
|
|
baseActors = cellChangeActors;
|
|
Main::get().getNetworking()->getActorPacket(ID_ACTOR_CELL_CHANGE)->setActorList(this);
|
|
Main::get().getNetworking()->getActorPacket(ID_ACTOR_CELL_CHANGE)->Send();
|
|
}
|
|
}
|
|
|
|
void ActorList::sendActorsInCell(MWWorld::CellStore* cellStore)
|
|
{
|
|
reset();
|
|
cell = *cellStore->getCell();
|
|
action = BaseActorList::SET;
|
|
|
|
for (auto &ref : cellStore->getNpcs()->mList)
|
|
{
|
|
MWWorld::Ptr ptr(&ref, 0);
|
|
|
|
// If this Ptr is lacking a unique index, ignore it
|
|
if (ptr.getCellRef().getRefNum().mIndex == 0 && ptr.getCellRef().getMpNum() == 0) continue;
|
|
|
|
BaseActor actor;
|
|
actor.refId = ptr.getCellRef().getRefId();
|
|
actor.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
|
|
actor.mpNum = ptr.getCellRef().getMpNum();
|
|
|
|
addActor(actor);
|
|
}
|
|
|
|
for (auto &ref : cellStore->getCreatures()->mList)
|
|
{
|
|
MWWorld::Ptr ptr(&ref, 0);
|
|
|
|
// If this Ptr is lacking a unique index, ignore it
|
|
if (ptr.getCellRef().getRefNum().mIndex == 0 && ptr.getCellRef().getMpNum() == 0) continue;
|
|
|
|
BaseActor actor;
|
|
actor.refId = ptr.getCellRef().getRefId();
|
|
actor.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
|
|
actor.mpNum = ptr.getCellRef().getMpNum();
|
|
|
|
addActor(actor);
|
|
}
|
|
|
|
mwmp::Main::get().getNetworking()->getActorPacket(ID_ACTOR_LIST)->setActorList(this);
|
|
mwmp::Main::get().getNetworking()->getActorPacket(ID_ACTOR_LIST)->Send();
|
|
}
|