[General] Implement PlayerTeam packet
parent
385ef55848
commit
753e310dd4
@ -1,30 +0,0 @@
|
||||
#ifndef OPENMW_PROCESSORPLACEHOLDER_HPP
|
||||
#define OPENMW_PROCESSORPLACEHOLDER_HPP
|
||||
|
||||
#include "../PlayerProcessor.hpp"
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class ProcessorPlayerPlaceholder final: public PlayerProcessor
|
||||
{
|
||||
public:
|
||||
ProcessorPlayerPlaceholder()
|
||||
{
|
||||
BPP_INIT(ID_PLACEHOLDER)
|
||||
}
|
||||
|
||||
virtual void Do(PlayerPacket &packet, BasePlayer *player)
|
||||
{
|
||||
if (isRequest())
|
||||
{
|
||||
// Entire list of topics cannot currently be requested from players
|
||||
}
|
||||
else if (player != 0)
|
||||
{
|
||||
// Placeholder
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PROCESSORPLACEHOLDER_HPP
|
@ -0,0 +1,42 @@
|
||||
#ifndef OPENMW_PROCESSORPLAYERTEAM_HPP
|
||||
#define OPENMW_PROCESSORPLAYERTEAM_HPP
|
||||
|
||||
#include "../PlayerProcessor.hpp"
|
||||
#include "apps/openmw/mwmp/Main.hpp"
|
||||
#include "apps/openmw/mwmp/LocalPlayer.hpp"
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class ProcessorPlayerTeam final: public PlayerProcessor
|
||||
{
|
||||
public:
|
||||
ProcessorPlayerTeam()
|
||||
{
|
||||
BPP_INIT(ID_PLAYER_TEAM)
|
||||
}
|
||||
|
||||
virtual void Do(PlayerPacket &packet, BasePlayer *player)
|
||||
{
|
||||
if (isLocal())
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received ID_PLAYER_TEAM about LocalPlayer from server");
|
||||
|
||||
mwmp::LocalPlayer *localPlayer = mwmp::Main::get().getLocalPlayer();
|
||||
|
||||
for (std::vector<RakNet::RakNetGUID>::iterator iter = localPlayer->teamMembers.begin(); iter != localPlayer->teamMembers.end(); )
|
||||
{
|
||||
DedicatedPlayer *dedicatedPlayer = PlayerList::getPlayer(*iter);
|
||||
|
||||
if (dedicatedPlayer)
|
||||
{
|
||||
LOG_APPEND(TimedLog::LOG_INFO, "- Adding %s to our team members", dedicatedPlayer->npc.mName.c_str());
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PROCESSORPLAYERTEAM_HPP
|
@ -1,12 +0,0 @@
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
#include "PacketPlayerPlaceholder.hpp"
|
||||
|
||||
mwmp::PacketPlayerPlaceholder::PacketPlayerPlaceholder(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
||||
{
|
||||
packetID = ID_PLACEHOLDER;
|
||||
}
|
||||
|
||||
void mwmp::PacketPlayerPlaceholder::Packet(RakNet::BitStream *bs, bool send)
|
||||
{
|
||||
// Placeholder
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
#include "PacketPlayerTeam.hpp"
|
||||
|
||||
mwmp::PacketPlayerTeam::PacketPlayerTeam(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
||||
{
|
||||
packetID = ID_PLAYER_TEAM;
|
||||
}
|
||||
|
||||
void mwmp::PacketPlayerTeam::Packet(RakNet::BitStream *bs, bool send)
|
||||
{
|
||||
PlayerPacket::Packet(bs, send);
|
||||
|
||||
uint32_t count;
|
||||
|
||||
if (send)
|
||||
count = static_cast<uint32_t>(player->teamMembers.size());
|
||||
|
||||
RW(count, send);
|
||||
|
||||
if (!send)
|
||||
{
|
||||
player->teamMembers.clear();
|
||||
player->teamMembers.resize(count);
|
||||
}
|
||||
|
||||
for (auto &&teamPlayerGuid : player->teamMembers)
|
||||
{
|
||||
RW(teamPlayerGuid, send, true);
|
||||
}
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
#ifndef OPENMW_PACKETPLACEHOLDER_HPP
|
||||
#define OPENMW_PACKETPLACEHOLDER_HPP
|
||||
#ifndef OPENMW_PACKETTEAM_HPP
|
||||
#define OPENMW_PACKETTEAM_HPP
|
||||
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class PacketPlayerPlaceholder : public PlayerPacket
|
||||
class PacketPlayerTeam : public PlayerPacket
|
||||
{
|
||||
public:
|
||||
PacketPlayerPlaceholder(RakNet::RakPeerInterface *peer);
|
||||
PacketPlayerTeam(RakNet::RakPeerInterface *peer);
|
||||
|
||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PACKETPLACEHOLDER_HPP
|
||||
#endif //OPENMW_PACKETTEAM_HPP
|
Loading…
Reference in New Issue