openmw-tes3coop/components/openmw-mp/Packets/Actor/PacketActorList.cpp
Koncord 2d0840cb3a [General] Modernize Script API
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
2017-08-28 00:15:56 +08:00

40 lines
973 B
C++

#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketActorList.hpp"
using namespace mwmp;
PacketActorList::PacketActorList(RakNet::RakPeerInterface *peer) : ActorPacket(peer)
{
packetID = ID_ACTOR_LIST;
}
void PacketActorList::Packet(RakNet::BitStream *bs, bool send)
{
if (!ActorPacket::PacketHeader(bs, send))
return;
RW(actorList->action, send);
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->refId, send);
RW(actor->refNumIndex, send);
RW(actor->mpNum, send);
if (actor->refId.empty() || (actor->refNumIndex != 0 && actor->mpNum != 0))
{
actorList->isValid = false;
return;
}
if (!send)
actorList->baseActors.push_back(std::shared_ptr<BaseActor>(actor));
}
}