forked from mirror/openmw-tes3mp
[General] Add and implement PlayerQuickKeys packet
parent
8c47d63b08
commit
50d5fffb7f
@ -0,0 +1,26 @@
|
||||
#ifndef OPENMW_PROCESSORPLAYERQUICKKEYS_HPP
|
||||
#define OPENMW_PROCESSORPLAYERQUICKKEYS_HPP
|
||||
|
||||
#include "../PlayerProcessor.hpp"
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class ProcessorPlayerQuickKeys : public PlayerProcessor
|
||||
{
|
||||
public:
|
||||
ProcessorPlayerQuickKeys()
|
||||
{
|
||||
BPP_INIT(ID_PLAYER_QUICKKEYS)
|
||||
}
|
||||
|
||||
void Do(PlayerPacket &packet, Player &player) override
|
||||
{
|
||||
DEBUG_PRINTF(strPacketID.c_str());
|
||||
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerQuickKeys")>(player.getId());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif //OPENMW_PROCESSORPLAYERQUICKKEYS_HPP
|
@ -0,0 +1,32 @@
|
||||
#ifndef OPENMW_PROCESSORPLAYERQUICKKEYS_HPP
|
||||
#define OPENMW_PROCESSORPLAYERQUICKKEYS_HPP
|
||||
|
||||
|
||||
#include "../PlayerProcessor.hpp"
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class ProcessorPlayerQuickKeys : public PlayerProcessor
|
||||
{
|
||||
public:
|
||||
ProcessorPlayerQuickKeys()
|
||||
{
|
||||
BPP_INIT(ID_PLAYER_QUICKKEYS)
|
||||
}
|
||||
|
||||
virtual void Do(PlayerPacket &packet, BasePlayer *player)
|
||||
{
|
||||
if (!isLocal()) return;
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_QUICKKEYS about LocalPlayer from server");
|
||||
|
||||
if (!isRequest())
|
||||
{
|
||||
LocalPlayer &localPlayer = static_cast<LocalPlayer&>(*player);
|
||||
localPlayer.setQuickKeys();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PROCESSORPLAYERQUICKKEYS_HPP
|
@ -0,0 +1,40 @@
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
#include "PacketPlayerQuickKeys.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace mwmp;
|
||||
|
||||
PacketPlayerQuickKeys::PacketPlayerQuickKeys(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
||||
{
|
||||
packetID = ID_PLAYER_QUICKKEYS;
|
||||
}
|
||||
|
||||
void PacketPlayerQuickKeys::Packet(RakNet::BitStream *bs, bool send)
|
||||
{
|
||||
PlayerPacket::Packet(bs, send);
|
||||
|
||||
if (send)
|
||||
player->quickKeyChanges.count = (unsigned int) (player->quickKeyChanges.quickKeys.size());
|
||||
else
|
||||
player->quickKeyChanges.quickKeys.clear();
|
||||
|
||||
RW(player->quickKeyChanges.count, send);
|
||||
|
||||
for (unsigned int i = 0; i < player->quickKeyChanges.count; i++)
|
||||
{
|
||||
QuickKey quickKey;
|
||||
|
||||
if (send)
|
||||
quickKey = player->quickKeyChanges.quickKeys.at(i);
|
||||
|
||||
RW(quickKey.type, send);
|
||||
RW(quickKey.slot, send);
|
||||
|
||||
if (quickKey.type != QuickKey::UNASSIGNED)
|
||||
RW(quickKey.itemId, send);
|
||||
|
||||
if (!send)
|
||||
player->quickKeyChanges.quickKeys.push_back(quickKey);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#ifndef OPENMW_PACKETPLAYERQUICKKEYS_HPP
|
||||
#define OPENMW_PACKETPLAYERQUICKKEYS_HPP
|
||||
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class PacketPlayerQuickKeys : public PlayerPacket
|
||||
{
|
||||
public:
|
||||
PacketPlayerQuickKeys(RakNet::RakPeerInterface *peer);
|
||||
|
||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PACKETPLAYERQUICKKEYS_HPP
|
Loading…
Reference in New Issue