[General] Add ActorPosition packet
parent
b6c3830ea0
commit
742d6f653a
@ -0,0 +1,29 @@
|
||||
#ifndef OPENMW_PROCESSORACTORPOSITION_HPP
|
||||
#define OPENMW_PROCESSORACTORPOSITION_HPP
|
||||
|
||||
#include "apps/openmw-mp/ActorProcessor.hpp"
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class ProcessorActorPosition : public ActorProcessor
|
||||
{
|
||||
public:
|
||||
ProcessorActorPosition()
|
||||
{
|
||||
BPP_INIT(ID_ACTOR_POSITION)
|
||||
}
|
||||
|
||||
void Do(ActorPacket &packet, Player &player, BaseActorList &actorList) override
|
||||
{
|
||||
// Send only to players who have the cell loaded
|
||||
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
||||
|
||||
if (serverCell != nullptr)
|
||||
serverCell->sendToLoaded(&packet, &actorList);
|
||||
|
||||
//Script::Call<Script::CallbackIdentity("OnActorPosition")>(player.getId(), actorList.cell.getDescription().c_str());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PROCESSORACTORPOSITION_HPP
|
@ -0,0 +1,47 @@
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
#include <components/openmw-mp/Log.hpp>
|
||||
#include "PacketActorPosition.hpp"
|
||||
|
||||
using namespace mwmp;
|
||||
|
||||
PacketActorPosition::PacketActorPosition(RakNet::RakPeerInterface *peer) : ActorPacket(peer)
|
||||
{
|
||||
packetID = ID_ACTOR_POSITION;
|
||||
}
|
||||
|
||||
void PacketActorPosition::Packet(RakNet::BitStream *bs, bool send)
|
||||
{
|
||||
ActorPacket::Packet(bs, send);
|
||||
|
||||
if (!send)
|
||||
actorList->baseActors.clear();
|
||||
else
|
||||
actorList->count = (unsigned int)(actorList->baseActors.size());
|
||||
|
||||
RW(actorList->count, send);
|
||||
|
||||
RW(actorList->cell.mData.mFlags, send);
|
||||
RW(actorList->cell.mData.mX, send);
|
||||
RW(actorList->cell.mData.mY, send);
|
||||
RW(actorList->cell.mName, send);
|
||||
|
||||
BaseActor actor;
|
||||
|
||||
for (unsigned int i = 0; i < actorList->count; i++)
|
||||
{
|
||||
if (send)
|
||||
{
|
||||
actor = actorList->baseActors.at(i);
|
||||
}
|
||||
|
||||
RW(actor.refId, send);
|
||||
RW(actor.refNumIndex, send);
|
||||
RW(actor.mpNum, send);
|
||||
RW(actor.position, send);
|
||||
|
||||
if (!send)
|
||||
{
|
||||
actorList->baseActors.push_back(actor);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#ifndef OPENMW_PACKETACTORPOSITION_HPP
|
||||
#define OPENMW_PACKETACTORPOSITION_HPP
|
||||
|
||||
#include <components/openmw-mp/Packets/Actor/ActorPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class PacketActorPosition : public ActorPacket
|
||||
{
|
||||
public:
|
||||
PacketActorPosition(RakNet::RakPeerInterface *peer);
|
||||
|
||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PACKETACTORPOSITION_HPP
|
Loading…
Reference in New Issue