forked from teamnwah/openmw-tes3coop
2d0840cb3a
This commit changes the style of tes3mp serverside scripting mods. Short list of changes: * Break compatibility with old server mods * OOP style lua API * Basic dependency checker, allowing the installation of multiple server mods without changing configs * Remove support for C++ plugins * Change outdated LuaBridge to [sol2](https://github.com/ThePhD/sol2); * Support GCC, Clang and MSVC compilers * New environment variables: "TES3MP_SERVER_DIR" and "TES3MP_SERVER_USERDIR"; * New entity "Command controller" for registering new chat commands; * New Event system * Simplified Timer API * All Lua mods now run in their own environments * Add global namespace - Data that can be used for communicating between mods * Player and Actor inherit base class NetActor
73 lines
No EOL
1.5 KiB
C++
73 lines
No EOL
1.5 KiB
C++
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
#include <PacketPriority.h>
|
|
#include <RakPeer.h>
|
|
#include "ActorPacket.hpp"
|
|
|
|
using namespace mwmp;
|
|
|
|
ActorPacket::ActorPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer)
|
|
{
|
|
packetID = 0;
|
|
priority = HIGH_PRIORITY;
|
|
reliability = RELIABLE_ORDERED;
|
|
orderChannel = CHANNEL_ACTOR;
|
|
this->peer = peer;
|
|
}
|
|
|
|
ActorPacket::~ActorPacket()
|
|
{
|
|
|
|
}
|
|
|
|
void ActorPacket::setActorList(BaseActorList *actorList)
|
|
{
|
|
this->actorList = actorList;
|
|
guid = actorList->guid;
|
|
}
|
|
|
|
void ActorPacket::Packet(RakNet::BitStream *bs, bool send)
|
|
{
|
|
if (!PacketHeader(bs, send))
|
|
return;
|
|
|
|
BaseActor *actor;
|
|
|
|
for (unsigned int i = 0; i < actorList->count; i++)
|
|
{
|
|
if (send)
|
|
actor = actorList->baseActors.at(i).get();
|
|
else
|
|
actor = new BaseActor();
|
|
|
|
RW(actor->refNumIndex, send);
|
|
RW(actor->mpNum, send);
|
|
|
|
Actor(*actor, send);
|
|
|
|
if (!send)
|
|
actorList->baseActors.push_back(std::shared_ptr<BaseActor>(actor));
|
|
}
|
|
}
|
|
|
|
bool ActorPacket::PacketHeader(RakNet::BitStream *bs, bool send)
|
|
{
|
|
BasePacket::Packet(bs, send);
|
|
|
|
RW(actorList->cell.mData, send, 1);
|
|
RW(actorList->cell.mName, send, 1);
|
|
|
|
if (send)
|
|
actorList->count = (unsigned int)(actorList->baseActors.size());
|
|
else
|
|
actorList->baseActors.clear();
|
|
|
|
RW(actorList->count, send);
|
|
|
|
if (actorList->count > maxActors)
|
|
{
|
|
actorList->isValid = false;
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
} |