1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-23 20:23:52 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Object/PacketClientScriptLocal.cpp
David Cernat 5e6218ad6d [General] Modernize handling of client script local variables in packets
Disable placeholder handling of client script member variables.
2020-06-06 13:58:51 +02:00

39 lines
1.1 KiB
C++

#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketClientScriptLocal.hpp"
using namespace mwmp;
PacketClientScriptLocal::PacketClientScriptLocal(RakNet::RakPeerInterface *peer) : ObjectPacket(peer)
{
packetID = ID_CLIENT_SCRIPT_LOCAL;
hasCellData = true;
}
void PacketClientScriptLocal::Object(BaseObject &baseObject, bool send)
{
ObjectPacket::Object(baseObject, send);
uint32_t clientLocalsCount;
if (send)
clientLocalsCount = static_cast<uint32_t>(baseObject.clientLocals.size());
RW(clientLocalsCount, send);
if (!send)
{
baseObject.clientLocals.clear();
baseObject.clientLocals.resize(clientLocalsCount);
}
for (auto&& clientLocal : baseObject.clientLocals)
{
RW(clientLocal.internalIndex, send);
RW(clientLocal.variableType, send);
if (clientLocal.variableType == mwmp::VARIABLE_TYPE::SHORT || clientLocal.variableType == mwmp::VARIABLE_TYPE::LONG)
RW(clientLocal.intValue, send);
else if (clientLocal.variableType == mwmp::VARIABLE_TYPE::FLOAT)
RW(clientLocal.floatValue, send);
}
}