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>
|
2018-07-08 21:11:22 +10:00
|
|
|
#include <Network/PacketDef/Zone/ClientZoneDef.h>
|
2017-08-17 16:17:25 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Network/GameConnection.h"
|
|
|
|
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
2017-08-17 16:17:25 +02:00
|
|
|
|
2019-07-21 22:33:33 +10:00
|
|
|
#include "Territory/Territory.h"
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Actor/Player.h"
|
2018-03-02 07:22:25 -03:00
|
|
|
|
|
|
|
#include "Session.h"
|
2021-11-27 00:53:57 +01:00
|
|
|
#include "WorldServer.h"
|
|
|
|
#include <Service.h>
|
2018-06-02 15:52:35 +02:00
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
using namespace Sapphire::Common;
|
|
|
|
using namespace Sapphire::Network::Packets;
|
2021-11-27 00:53:57 +01:00
|
|
|
using namespace Sapphire::Network::Packets::WorldPackets::Server;
|
|
|
|
using namespace Sapphire::Network::Packets::WorldPackets::Client;
|
2017-08-17 16:17:25 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
void Sapphire::Network::GameConnection::itemOperation( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
|
|
|
Entity::Player& player )
|
2017-08-17 16:17:25 +02:00
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
auto& server = Common::Service< World::WorldServer >::ref();
|
|
|
|
const auto packet = ZoneChannelPacket< FFXIVIpcClientInventoryItemOperation >( inPacket );
|
|
|
|
|
|
|
|
const auto operationType = packet.data().OperationType;
|
|
|
|
const auto splitCount = packet.data().SrcStack;
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
const auto fromSlot = packet.data().SrcContainerIndex;
|
|
|
|
const auto fromContainer = packet.data().SrcStorageId;
|
|
|
|
const auto toSlot = packet.data().DstContainerIndex;
|
|
|
|
const auto toContainer = packet.data().DstStorageId;
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
const auto contextId = packet.data().ContextId;
|
2017-08-17 16:17:25 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
auto ackPacket = makeZonePacket< FFXIVIpcItemOperationBatch >( player.getId() );
|
|
|
|
ackPacket->data().contextId = contextId;
|
|
|
|
ackPacket->data().operationType = operationType;
|
|
|
|
server.queueForPlayer( player.getCharacterId(), ackPacket );
|
2017-08-17 16:17:25 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
Logger::debug( "OperationType: {0}", operationType );
|
2017-08-17 16:17:25 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
// TODO: other inventory operations need to be implemented
|
2021-11-27 00:53:57 +01:00
|
|
|
switch( operationType )
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
case Common::ITEM_OPERATION_TYPE::ITEM_OPERATION_TYPE_DELETEITEM: // discard item action
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
|
|
|
player.discardItem( fromContainer, fromSlot );
|
|
|
|
}
|
2017-11-28 00:09:36 +01:00
|
|
|
break;
|
2017-08-17 16:17:25 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
case Common::ITEM_OPERATION_TYPE::ITEM_OPERATION_TYPE_MOVEITEM: // move item action
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
|
|
|
player.moveItem( fromContainer, fromSlot, toContainer, toSlot );
|
|
|
|
}
|
2017-11-28 00:09:36 +01:00
|
|
|
break;
|
2017-08-17 16:17:25 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
case ITEM_OPERATION_TYPE::ITEM_OPERATION_TYPE_SWAPITEM: // swap item action
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
|
|
|
player.swapItem( fromContainer, fromSlot, toContainer, toSlot );
|
|
|
|
}
|
2017-11-28 00:09:36 +01:00
|
|
|
break;
|
2017-08-17 16:17:25 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
case ITEM_OPERATION_TYPE::ITEM_OPERATION_TYPE_MERGEITEM: // merge stack action
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
|
|
|
player.mergeItem( fromContainer, fromSlot, toContainer, toSlot );
|
|
|
|
}
|
2017-11-28 00:09:36 +01:00
|
|
|
break;
|
2017-08-17 16:17:25 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
case ITEM_OPERATION_TYPE::ITEM_OPERATION_TYPE_SPLITITEM: // split stack action
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
|
|
|
player.splitItem( fromContainer, fromSlot, toContainer, toSlot, splitCount );
|
|
|
|
}
|
2017-11-28 00:09:36 +01:00
|
|
|
break;
|
2017-08-17 16:17:25 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
default:
|
|
|
|
break;
|
2017-08-17 16:17:25 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
2017-08-17 16:17:25 +02:00
|
|
|
}
|
|
|
|
|