2021-11-27 00:53:57 +01:00
|
|
|
#pragma once
|
2023-02-02 02:30:31 -03:00
|
|
|
|
2019-03-08 15:34:38 +01:00
|
|
|
#include <Network/GamePacket.h>
|
2017-12-08 23:27:59 +01:00
|
|
|
#include "Actor/Player.h"
|
2023-01-17 12:54:42 +01:00
|
|
|
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
2017-12-08 23:27:59 +01:00
|
|
|
#include "Forwards.h"
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
namespace Sapphire::Network::Packets::WorldPackets::Server
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
/**
|
|
|
|
* @brief Packet sent to set a players state, this impacts which actions he can perform.
|
|
|
|
*/
|
2023-02-20 15:25:57 +01:00
|
|
|
class ConditionPacket : public ZoneChannelPacket< FFXIVIpcCondition >
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
2018-10-28 21:53:21 +01:00
|
|
|
public:
|
2023-02-20 15:25:57 +01:00
|
|
|
ConditionPacket( Entity::Player& player ) :
|
|
|
|
ZoneChannelPacket< FFXIVIpcCondition >( player.getId(), player.getId() )
|
2018-10-28 21:53:21 +01:00
|
|
|
{
|
2023-02-20 16:41:04 +01:00
|
|
|
initialize( player.getConditions().data() );
|
2018-10-28 21:53:21 +01:00
|
|
|
}
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2023-02-20 15:25:57 +01:00
|
|
|
ConditionPacket( Entity::Player& player, std::vector< Common::PlayerCondition > flags ) :
|
|
|
|
ZoneChannelPacket< FFXIVIpcCondition >( player.getId(), player.getId() )
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
2023-02-20 15:25:57 +01:00
|
|
|
uint8_t newFlags[ 12 ];
|
2018-10-28 21:53:21 +01:00
|
|
|
memset( newFlags, 0, 12 );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
for( auto& flag : flags )
|
|
|
|
{
|
|
|
|
int32_t iFlag = static_cast< uint32_t >( flag );
|
|
|
|
uint8_t index = iFlag / 8;
|
|
|
|
uint8_t bitIndex = iFlag % 8;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
uint8_t value = 1 << bitIndex;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
newFlags[ index ] |= value;
|
|
|
|
}
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
initialize( newFlags );
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void initialize( const uint8_t* flags )
|
|
|
|
{
|
|
|
|
memcpy( m_data.flags, flags, 12 );
|
|
|
|
};
|
2018-08-29 21:40:59 +02:00
|
|
|
};
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
}
|