1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-07 19:27:45 +00:00
sapphire/src/world/Network/Handlers/InventoryHandler.cpp

87 lines
2.4 KiB
C++
Raw Normal View History

2018-03-06 22:22:19 +01:00
#include <Common.h>
#include <Network/CommonNetwork.h>
2019-03-08 15:34:38 +01:00
#include <Network/GamePacket.h>
2018-03-06 22:22:19 +01:00
#include <Logging/Logger.h>
#include <Network/PacketContainer.h>
#include <Network/PacketDef/Zone/ClientZoneDef.h>
#include "Network/GameConnection.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
2019-07-21 22:33:33 +10:00
#include "Territory/Territory.h"
#include "Territory/ZonePosition.h"
#include "Manager/DebugCommandMgr.h"
#include "Actor/Player.h"
#include "Session.h"
2018-11-20 21:32:13 +01:00
#include "ServerMgr.h"
2018-06-02 15:52:35 +02:00
#include "Framework.h"
using namespace Sapphire::Common;
using namespace Sapphire::Network::Packets;
using namespace Sapphire::Network::Packets::Server;
2018-12-23 03:53:08 +01:00
void Sapphire::Network::GameConnection::inventoryModifyHandler( FrameworkPtr pFw,
const Packets::FFXIVARR_PACKET_RAW& inPacket,
Entity::Player& player )
{
2019-07-29 22:22:45 +10:00
const auto packet = ZoneChannelPacket< Client::FFXIVIpcInventoryModifyHandler >( inPacket );
2018-10-14 23:31:52 +11:00
const auto action = packet.data().action;
const auto splitCount = packet.data().splitCount;
2018-10-14 23:31:52 +11:00
const auto fromSlot = packet.data().fromSlot;
const auto fromContainer = packet.data().fromContainer;
const auto toSlot = packet.data().toSlot;
const auto toContainer = packet.data().toContainer;
2019-07-29 22:22:45 +10:00
auto ackPacket = makeZonePacket< Server::FFXIVIpcInventoryActionAck >( player.getId() );
ackPacket->data().sequence = packet.data().seq;
ackPacket->data().type = 7;
player.queuePacket( ackPacket );
Logger::debug( "InventoryAction: {0}", action );
// TODO: other inventory operations need to be implemented
switch( action )
{
case InventoryOperation::Discard: // discard item action
{
player.discardItem( fromContainer, fromSlot );
}
2017-11-28 00:09:36 +01:00
break;
case InventoryOperation::Move: // move item action
{
player.moveItem( fromContainer, fromSlot, toContainer, toSlot );
}
2017-11-28 00:09:36 +01:00
break;
case InventoryOperation::Swap: // swap item action
{
player.swapItem( fromContainer, fromSlot, toContainer, toSlot );
}
2017-11-28 00:09:36 +01:00
break;
case InventoryOperation::Merge: // merge stack action
{
player.mergeItem( fromContainer, fromSlot, toContainer, toSlot );
}
2017-11-28 00:09:36 +01:00
break;
case InventoryOperation::Split: // split stack action
{
player.splitItem( fromContainer, fromSlot, toContainer, toSlot, splitCount );
}
2017-11-28 00:09:36 +01:00
break;
default:
break;
}
}