forked from mirror/openmw-tes3mp
[General] Add and use PlayerBounty packet and matching script functions
parent
6658531713
commit
7b07d6651f
@ -0,0 +1,24 @@
|
||||
#ifndef OPENMW_PROCESSORPLAYERBOUNTY_HPP
|
||||
#define OPENMW_PROCESSORPLAYERBOUNTY_HPP
|
||||
|
||||
|
||||
#include "apps/openmw-mp/PlayerProcessor.hpp"
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class ProcessorPlayerBounty : public PlayerProcessor
|
||||
{
|
||||
public:
|
||||
ProcessorPlayerBounty()
|
||||
{
|
||||
BPP_INIT(ID_PLAYER_BOUNTY)
|
||||
}
|
||||
|
||||
void Do(PlayerPacket &packet, Player &player) override
|
||||
{
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerBountyChange")>(player.getId());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PROCESSORPLAYERBOUNTY_HPP
|
@ -0,0 +1,38 @@
|
||||
#ifndef OPENMW_PROCESSORPLAYERBOUNTY_HPP
|
||||
#define OPENMW_PROCESSORPLAYERBOUNTY_HPP
|
||||
|
||||
|
||||
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class ProcessorPlayerBounty : public PlayerProcessor
|
||||
{
|
||||
public:
|
||||
ProcessorPlayerBounty()
|
||||
{
|
||||
BPP_INIT(ID_PLAYER_BOUNTY)
|
||||
}
|
||||
|
||||
virtual void Do(PlayerPacket &packet, BasePlayer *player)
|
||||
{
|
||||
if (isLocal())
|
||||
{
|
||||
if(isRequest())
|
||||
static_cast<LocalPlayer *>(player)->updateBounty(true);
|
||||
else
|
||||
static_cast<LocalPlayer *>(player)->setBounty();
|
||||
}
|
||||
else if (player != 0)
|
||||
{
|
||||
MWWorld::Ptr ptrPlayer = static_cast<DedicatedPlayer *>(player)->getPtr();
|
||||
MWMechanics::NpcStats *ptrNpcStats = &ptrPlayer.getClass().getNpcStats(ptrPlayer);
|
||||
|
||||
ptrNpcStats->setBounty(player->npcStats.mBounty);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif //OPENMW_PROCESSORPLAYERBOUNTY_HPP
|
@ -0,0 +1,16 @@
|
||||
#include "PacketPlayerBounty.hpp"
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
|
||||
using namespace mwmp;
|
||||
|
||||
PacketPlayerBounty::PacketPlayerBounty(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
||||
{
|
||||
packetID = ID_PLAYER_BOUNTY;
|
||||
}
|
||||
|
||||
void PacketPlayerBounty::Packet(RakNet::BitStream *bs, bool send)
|
||||
{
|
||||
PlayerPacket::Packet(bs, send);
|
||||
|
||||
RW(player->npcStats.mBounty, send);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#ifndef OPENMW_PACKETPLAYERBOUNTY_HPP
|
||||
#define OPENMW_PACKETPLAYERBOUNTY_HPP
|
||||
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class PacketPlayerBounty : public PlayerPacket
|
||||
{
|
||||
public:
|
||||
PacketPlayerBounty(RakNet::RakPeerInterface *peer);
|
||||
|
||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PACKETPLAYERBOUNTY_HPP
|
Loading…
Reference in New Issue