2017-01-26 11:49:20 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
#include "PacketPlayerCellState.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
mwmp::PacketPlayerCellState::PacketPlayerCellState(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
|
|
|
{
|
|
|
|
packetID = ID_PLAYER_CELL_STATE;
|
|
|
|
priority = IMMEDIATE_PRIORITY;
|
|
|
|
reliability = RELIABLE_ORDERED;
|
|
|
|
}
|
|
|
|
|
2017-03-06 09:44:08 +00:00
|
|
|
void mwmp::PacketPlayerCellState::Packet(RakNet::BitStream *bs, bool send)
|
2017-01-26 11:49:20 +00:00
|
|
|
{
|
2017-03-06 09:44:08 +00:00
|
|
|
PlayerPacket::Packet(bs, send);
|
2017-01-26 11:49:20 +00:00
|
|
|
|
|
|
|
if (!send)
|
2017-02-03 18:27:40 +00:00
|
|
|
player->cellStateChanges.cellStates.clear();
|
2017-01-26 11:49:20 +00:00
|
|
|
else
|
2017-02-03 18:27:40 +00:00
|
|
|
player->cellStateChanges.count = (unsigned int)(player->cellStateChanges.cellStates.size());
|
2017-01-26 11:49:20 +00:00
|
|
|
|
|
|
|
RW(player->cellStateChanges.count, send);
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < player->cellStateChanges.count; i++)
|
|
|
|
{
|
2017-02-03 18:27:40 +00:00
|
|
|
CellState cellState;
|
2017-01-26 11:49:20 +00:00
|
|
|
|
|
|
|
if (send)
|
|
|
|
{
|
2017-02-05 17:01:06 +00:00
|
|
|
cellState = player->cellStateChanges.cellStates.at(i);
|
2017-01-26 11:49:20 +00:00
|
|
|
}
|
2017-02-03 18:27:40 +00:00
|
|
|
|
|
|
|
RW(cellState.type, send);
|
|
|
|
RW(cellState.cell.mData.mFlags, send);
|
|
|
|
RW(cellState.cell.mData.mX, send);
|
|
|
|
RW(cellState.cell.mData.mY, send);
|
|
|
|
RW(cellState.cell.mName, send);
|
2017-01-26 11:49:20 +00:00
|
|
|
|
|
|
|
if (!send)
|
|
|
|
{
|
2017-02-03 18:27:40 +00:00
|
|
|
player->cellStateChanges.cellStates.push_back(cellState);
|
2017-01-26 11:49:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|