mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 09:06:46 +00:00
Basic item summoning, fix for saving not working 100 pct, deletion works, cursor queue should work too.
This commit is contained in:
+19
-1
@@ -818,13 +818,28 @@ public:
|
||||
void QSSwapItemAuditor(MoveItemOld_Struct* move_in, bool postaction_call = false);
|
||||
void PutLootInInventory(int16 slot_id, const ItemInst &inst, ServerLootItem_Struct** bag_item_data = 0);
|
||||
bool AutoPutLootInInventory(ItemInst& inst, bool try_worn = false, bool try_cursor = true, ServerLootItem_Struct** bag_item_data = 0);
|
||||
bool SummonItem(uint32 item_id, int16 charges = -1, uint32 aug1 = 0, uint32 aug2 = 0, uint32 aug3 = 0, uint32 aug4 = 0, uint32 aug5 = 0, uint32 aug6 = 0, bool attuned = false, uint16 to_slot = MainCursor, uint32 ornament_icon = 0, uint32 ornament_idfile = 0, uint32 ornament_hero_model = 0);
|
||||
bool SummonItem(uint32 item_id, int16 charges = -1,
|
||||
uint32 aug1 = 0, uint32 aug2 = 0, uint32 aug3 = 0, uint32 aug4 = 0, uint32 aug5 = 0, uint32 aug6 = 0, bool attuned = false,
|
||||
uint16 to_slot = MainCursor, uint32 ornament_icon = 0, uint32 ornament_idfile = 0, uint32 ornament_hero_model = 0);
|
||||
void SetStats(uint8 type,int16 set_val);
|
||||
void IncStats(uint8 type,int16 increase_val);
|
||||
void DropItem(int16 slot_id);
|
||||
|
||||
//New Inventory
|
||||
bool SwapItem(const EQEmu::InventorySlot &src, const EQEmu::InventorySlot &dest, int number_in_stack);
|
||||
bool SummonItem(uint32 item_id,
|
||||
int16 charges,
|
||||
const EQEmu::InventorySlot &slot,
|
||||
uint32 aug1 = 0,
|
||||
uint32 aug2 = 0,
|
||||
uint32 aug3 = 0,
|
||||
uint32 aug4 = 0,
|
||||
uint32 aug5 = 0,
|
||||
uint32 aug6 = 0,
|
||||
bool attuned = false,
|
||||
uint32 ornament_icon = 0,
|
||||
uint32 ornament_idfile = 0,
|
||||
uint32 ornament_hero_model = 0);
|
||||
|
||||
//
|
||||
// class Client::TextLink
|
||||
@@ -881,6 +896,9 @@ public:
|
||||
bool IsValidSlot(uint32 slot);
|
||||
bool IsBankSlot(uint32 slot);
|
||||
|
||||
//inv2
|
||||
void SendItemPacket(const EQEmu::InventorySlot &slot, std::shared_ptr<EQEmu::ItemInstance> inst, ItemPacketType packet_type);
|
||||
|
||||
inline bool IsTrader() const { return(Trader); }
|
||||
inline bool IsBuyer() const { return(Buyer); }
|
||||
eqFilterMode GetFilter(eqFilterType filter_id) const { return ClientFilters[filter_id]; }
|
||||
|
||||
@@ -1722,14 +1722,11 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
|
||||
*/
|
||||
if (loaditems) { /* Dont load if a length error occurs */
|
||||
BulkSendInventoryItems();
|
||||
// /* Send stuff on the cursor which isnt sent in bulk */
|
||||
// for (auto iter = m_inv.cursor_cbegin(); iter != m_inv.cursor_cend(); ++iter) {
|
||||
// /* First item cursor is sent in bulk inventory packet */
|
||||
// if (iter == m_inv.cursor_cbegin())
|
||||
// continue;
|
||||
// const ItemInst *inst = *iter;
|
||||
// SendItemPacket(MainCursor, inst, ItemPacketSummonItem);
|
||||
// }
|
||||
EQEmu::InventorySlot slot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotCursor);
|
||||
auto cursor = m_inventory.Get(slot);
|
||||
if(cursor) {
|
||||
SendItemPacket(slot, cursor, ItemPacketSummonItem);
|
||||
}
|
||||
}
|
||||
|
||||
/* Task Packets */
|
||||
|
||||
+9
-8
@@ -5418,24 +5418,25 @@ void command_summonitem(Client *c, const Seperator *sep)
|
||||
item_status = static_cast<int16>(item->MinStatus);
|
||||
}
|
||||
|
||||
EQEmu::InventorySlot cursor(EQEmu::InvTypePersonal, EQEmu::PersonalSlotCursor);
|
||||
if (item_status > c->Admin())
|
||||
c->Message(13, "Error: Insufficient status to summon this item.");
|
||||
else if (sep->argnum==2 && sep->IsNumber(2))
|
||||
c->SummonItem(itemid, atoi(sep->arg[2]));
|
||||
c->SummonItem(itemid, atoi(sep->arg[2]), cursor);
|
||||
else if (sep->argnum==3)
|
||||
c->SummonItem(itemid, atoi(sep->arg[2]), atoi(sep->arg[3]));
|
||||
c->SummonItem(itemid, atoi(sep->arg[2]), cursor, atoi(sep->arg[3]));
|
||||
else if (sep->argnum==4)
|
||||
c->SummonItem(itemid, atoi(sep->arg[2]), atoi(sep->arg[3]), atoi(sep->arg[4]));
|
||||
c->SummonItem(itemid, atoi(sep->arg[2]), cursor, atoi(sep->arg[3]), atoi(sep->arg[4]));
|
||||
else if (sep->argnum==5)
|
||||
c->SummonItem(itemid, atoi(sep->arg[2]), atoi(sep->arg[3]), atoi(sep->arg[4]), atoi(sep->arg[5]));
|
||||
c->SummonItem(itemid, atoi(sep->arg[2]), cursor, atoi(sep->arg[3]), atoi(sep->arg[4]), atoi(sep->arg[5]));
|
||||
else if (sep->argnum==6)
|
||||
c->SummonItem(itemid, atoi(sep->arg[2]), atoi(sep->arg[3]), atoi(sep->arg[4]), atoi(sep->arg[5]), atoi(sep->arg[6]));
|
||||
c->SummonItem(itemid, atoi(sep->arg[2]), cursor, atoi(sep->arg[3]), atoi(sep->arg[4]), atoi(sep->arg[5]), atoi(sep->arg[6]));
|
||||
else if (sep->argnum==7)
|
||||
c->SummonItem(itemid, atoi(sep->arg[2]), atoi(sep->arg[3]), atoi(sep->arg[4]), atoi(sep->arg[5]), atoi(sep->arg[6]), atoi(sep->arg[7]));
|
||||
c->SummonItem(itemid, atoi(sep->arg[2]), cursor, atoi(sep->arg[3]), atoi(sep->arg[4]), atoi(sep->arg[5]), atoi(sep->arg[6]), atoi(sep->arg[7]));
|
||||
else if (sep->argnum==8)
|
||||
c->SummonItem(itemid, atoi(sep->arg[2]), atoi(sep->arg[3]), atoi(sep->arg[4]), atoi(sep->arg[5]), atoi(sep->arg[6]), atoi(sep->arg[7]), atoi(sep->arg[8]));
|
||||
c->SummonItem(itemid, atoi(sep->arg[2]), cursor, atoi(sep->arg[3]), atoi(sep->arg[4]), atoi(sep->arg[5]), atoi(sep->arg[6]), atoi(sep->arg[7]), atoi(sep->arg[8]));
|
||||
else {
|
||||
c->SummonItem(itemid);
|
||||
c->SummonItem(itemid, -1, cursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+156
-38
@@ -2427,52 +2427,74 @@ uint32 Client::GetEquipmentColor(uint8 material_slot) const
|
||||
// Send an item packet (including all subitems of the item)
|
||||
void Client::SendItemPacket(int16 slot_id, const ItemInst* inst, ItemPacketType packet_type)
|
||||
{
|
||||
if (!inst)
|
||||
// if (!inst)
|
||||
// return;
|
||||
//
|
||||
// // Serialize item into |-delimited string
|
||||
// std::string packet = inst->Serialize(slot_id);
|
||||
//
|
||||
// EmuOpcode opcode = OP_Unknown;
|
||||
// EQApplicationPacket* outapp = nullptr;
|
||||
// ItemPacket_Struct* itempacket = nullptr;
|
||||
//
|
||||
// // Construct packet
|
||||
// opcode = (packet_type==ItemPacketViewLink) ? OP_ItemLinkResponse : OP_ItemPacket;
|
||||
// outapp = new EQApplicationPacket(opcode, packet.length()+sizeof(ItemPacket_Struct));
|
||||
// itempacket = (ItemPacket_Struct*)outapp->pBuffer;
|
||||
// memcpy(itempacket->SerializedItem, packet.c_str(), packet.length());
|
||||
// itempacket->PacketType = packet_type;
|
||||
//
|
||||
//#if EQDEBUG >= 9
|
||||
// DumpPacket(outapp);
|
||||
//#endif
|
||||
// FastQueuePacket(&outapp);
|
||||
}
|
||||
|
||||
void Client::SendItemPacket(const EQEmu::InventorySlot &slot, std::shared_ptr<EQEmu::ItemInstance> inst, ItemPacketType packet_type) {
|
||||
if(!inst) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Serialize item into |-delimited string
|
||||
std::string packet = inst->Serialize(slot_id);
|
||||
|
||||
EQEmu::MemoryBuffer item;
|
||||
EmuOpcode opcode = OP_Unknown;
|
||||
EQApplicationPacket* outapp = nullptr;
|
||||
ItemPacket_Struct* itempacket = nullptr;
|
||||
opcode = (packet_type == ItemPacketViewLink) ? OP_ItemLinkResponse : OP_ItemPacket;
|
||||
|
||||
// Construct packet
|
||||
opcode = (packet_type==ItemPacketViewLink) ? OP_ItemLinkResponse : OP_ItemPacket;
|
||||
outapp = new EQApplicationPacket(opcode, packet.length()+sizeof(ItemPacket_Struct));
|
||||
itempacket = (ItemPacket_Struct*)outapp->pBuffer;
|
||||
memcpy(itempacket->SerializedItem, packet.c_str(), packet.length());
|
||||
itempacket->PacketType = packet_type;
|
||||
|
||||
#if EQDEBUG >= 9
|
||||
DumpPacket(outapp);
|
||||
#endif
|
||||
FastQueuePacket(&outapp);
|
||||
item.Write<int32>((int32)packet_type);
|
||||
item.Write<int32>(slot.Type());
|
||||
item.Write<int32>(slot.Slot());
|
||||
item.Write<int32>(slot.BagIndex());
|
||||
item.Write<int32>(slot.AugIndex());
|
||||
item.Write<void*>(inst.get());
|
||||
|
||||
EQApplicationPacket outapp(opcode, item.Size());
|
||||
memcpy(outapp.pBuffer, item, item.Size());
|
||||
QueuePacket(&outapp);
|
||||
}
|
||||
|
||||
EQApplicationPacket* Client::ReturnItemPacket(int16 slot_id, const ItemInst* inst, ItemPacketType packet_type)
|
||||
{
|
||||
if (!inst)
|
||||
return nullptr;
|
||||
|
||||
// Serialize item into |-delimited string
|
||||
std::string packet = inst->Serialize(slot_id);
|
||||
|
||||
EmuOpcode opcode = OP_Unknown;
|
||||
EQApplicationPacket* outapp = nullptr;
|
||||
BulkItemPacket_Struct* itempacket = nullptr;
|
||||
|
||||
// Construct packet
|
||||
opcode = OP_ItemPacket;
|
||||
outapp = new EQApplicationPacket(opcode, packet.length()+1);
|
||||
itempacket = (BulkItemPacket_Struct*)outapp->pBuffer;
|
||||
memcpy(itempacket->SerializedItem, packet.c_str(), packet.length());
|
||||
|
||||
#if EQDEBUG >= 9
|
||||
DumpPacket(outapp);
|
||||
#endif
|
||||
|
||||
return outapp;
|
||||
return nullptr;
|
||||
// if (!inst)
|
||||
// return nullptr;
|
||||
//
|
||||
// // Serialize item into |-delimited string
|
||||
// std::string packet = inst->Serialize(slot_id);
|
||||
//
|
||||
// EmuOpcode opcode = OP_Unknown;
|
||||
// EQApplicationPacket* outapp = nullptr;
|
||||
// BulkItemPacket_Struct* itempacket = nullptr;
|
||||
//
|
||||
// // Construct packet
|
||||
// opcode = OP_ItemPacket;
|
||||
// outapp = new EQApplicationPacket(opcode, packet.length()+1);
|
||||
// itempacket = (BulkItemPacket_Struct*)outapp->pBuffer;
|
||||
// memcpy(itempacket->SerializedItem, packet.c_str(), packet.length());
|
||||
//
|
||||
//#if EQDEBUG >= 9
|
||||
// DumpPacket(outapp);
|
||||
//#endif
|
||||
//
|
||||
// return outapp;
|
||||
}
|
||||
|
||||
static int16 BandolierSlotToWeaponSlot(int BandolierSlot)
|
||||
@@ -3143,7 +3165,16 @@ bool Client::SwapItem(const EQEmu::InventorySlot &src, const EQEmu::InventorySlo
|
||||
} else {
|
||||
Message(0, "Swap failure!\n");
|
||||
//should kick the player here...
|
||||
}
|
||||
|
||||
EQEmu::InventorySlot cursor(EQEmu::InvTypePersonal, EQEmu::PersonalSlotCursor);
|
||||
if(!m_inventory.Get(cursor)) {
|
||||
if(m_inventory.PopFromCursorBuffer()) {
|
||||
auto c_inst = m_inventory.Get(cursor);
|
||||
if(c_inst) {
|
||||
SendItemPacket(EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotCursor), c_inst, ItemPacketSummonItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(auto_attack && res && recalc_weapon_speed) {
|
||||
@@ -3157,3 +3188,90 @@ bool Client::SwapItem(const EQEmu::InventorySlot &src, const EQEmu::InventorySlo
|
||||
return res;
|
||||
}
|
||||
|
||||
bool Client::SummonItem(uint32 item_id,
|
||||
int16 charges,
|
||||
const EQEmu::InventorySlot &slot,
|
||||
uint32 aug1,
|
||||
uint32 aug2,
|
||||
uint32 aug3,
|
||||
uint32 aug4,
|
||||
uint32 aug5,
|
||||
uint32 aug6,
|
||||
bool attuned,
|
||||
uint32 ornament_icon,
|
||||
uint32 ornament_idfile,
|
||||
uint32 ornament_hero_model)
|
||||
{
|
||||
std::shared_ptr<EQEmu::ItemInstance> inst = database.CreateItem(item_id, charges);
|
||||
if(!inst)
|
||||
return false;
|
||||
|
||||
if(inst->GetBaseItem()->ItemClass == ItemClassCommon) {
|
||||
if(aug1) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug1);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
if(!inst->Put(0, aug)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(aug2) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug2);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
if(!inst->Put(1, aug)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(aug3) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug3);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
if(!inst->Put(2, aug)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(aug4) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug4);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
if(!inst->Put(3, aug)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(aug5) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug5);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
if(!inst->Put(4, aug)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(aug6) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug6);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
if(!inst->Put(5, aug)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto res = m_inventory.Summon(slot, inst);
|
||||
if(res) {
|
||||
SendItemPacket(slot, inst, ItemPacketSummonItem);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user