[General] Add ActorPosition packet

0.6.1
David Cernat 8 years ago
parent b6c3830ea0
commit 742d6f653a

@ -27,6 +27,7 @@
#include "ActorProcessor.hpp"
#include "processors/actor/ProcessorActorList.hpp"
#include "processors/actor/ProcessorActorAuthority.hpp"
#include "processors/actor/ProcessorActorPosition.hpp"
#include "processors/actor/ProcessorActorTest.hpp"
#include "WorldProcessor.hpp"
#include "processors/world/ProcessorContainer.hpp"
@ -73,6 +74,7 @@ void ProcessorInitializer()
ActorProcessor::AddProcessor(new ProcessorActorList());
ActorProcessor::AddProcessor(new ProcessorActorAuthority());
ActorProcessor::AddProcessor(new ProcessorActorPosition());
ActorProcessor::AddProcessor(new ProcessorActorTest());
WorldProcessor::AddProcessor(new ProcessorContainer());

@ -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

@ -167,7 +167,8 @@ add_component_dir (openmw-mp
Packets/Player/PacketGUIBoxes Packets/Player/PacketTime
Packets/Actor/PacketActorList Packets/Actor/PacketActorAuthority Packets/Actor/PacketActorTest
Packets/Actor/PacketActorList Packets/Actor/PacketActorAuthority Packets/Actor/PacketActorPosition
Packets/Actor/PacketActorTest
Packets/World/PacketObjectDelete Packets/World/PacketObjectPlace Packets/World/PacketObjectScale
Packets/World/PacketObjectLock Packets/World/PacketObjectUnlock Packets/World/PacketObjectMove

@ -4,6 +4,7 @@
#include "../Packets/Actor/PacketActorList.hpp"
#include "../Packets/Actor/PacketActorAuthority.hpp"
#include "../Packets/Actor/PacketActorPosition.hpp"
#include "../Packets/Actor/PacketActorTest.hpp"
#include "ActorPacketController.hpp"
@ -20,6 +21,7 @@ mwmp::ActorPacketController::ActorPacketController(RakNet::RakPeerInterface *pee
{
AddPacket<PacketActorList>(&packets, peer);
AddPacket<PacketActorAuthority>(&packets, peer);
AddPacket<PacketActorPosition>(&packets, peer);
AddPacket<PacketActorTest>(&packets, peer);
}

@ -41,6 +41,7 @@ enum GameMessages
ID_ACTOR_LIST,
ID_ACTOR_AUTHORITY,
ID_ACTOR_POSITION,
ID_ACTOR_TEST,
ID_OBJECT_PLACE,

@ -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…
Cancel
Save