My apologies for the condition of that patch. When my hard drive crashed a few weeks ago, my working copy was corrupted and I had to use an older
patch and try to match it up with my notes.
I've since fixed what I can and am back to working on the bank deletion process. (Not all slot ranges are active, but the ones that are do not give
any client-originating 'move item' or 'move item charge' failures.)
The external changes are still pretty much the same, but I've cleaned up ResyncInventory() and added two helper procedures.
Here are the three main procedures controlling the resync:
Code:
void Client::ResyncInventory(bool srvr_call) {
// This method is used to re-sync client and server inventories when a SwapItem() request fails -U
// Ranges not updated: Tribute, Trader, Trader Bags, World Container (Can re-assess later)
// 1) NEED TO DETERMINE ALL CLIENT CURSOR LIMITS (SoF IS 37 {0..36})
// 2) REALLY LEANING TOWARDS CLOSING ALL CONTAINERS - INCLUDING BAGS - CAN'T UPDATE TRADER OR WORLD PROPERLY
// 3) ALL BANK SLOTS DO NOT ACCEPT NORMAL DELETE ITEM REQUESTS - CODE IN PLACE TO HANDLE FIX - FIND FIX!
// 4) CURSOR IS IN-WORK - NEED TO ACCOMPLISH RESYNC WITHOUT SPAMMING CLIENT
Message(0, "Attempting to syncronize %s's inventory... [Stand-by]", GetName());
#if (EQDEBUG>=5)
if (srvr_call) { LogFile->write(EQEMuLog::Debug, "Client::ResyncInventory() server swapitem failure called for resync of %s's inventory", GetName()); }
#endif
const Item_Struct* resync_token = database.GetItem(22292); // 1041 (lore) = 'Worthless Coin' / 22292 (!lore) - 'Copper Coin'
ItemInst* token_inst = database.CreateItem(resync_token, 1);
int cursor_cnt; // Delete Current Cursor Array
/* IN-WORK */ //for(cursor_cnt = 0; cursor_cnt <= 36; cursor_cnt++) { SendItemPacket(SLOT_CURSOR, token_inst, ItemPacketSummonItem); }
/* IN-WORK */ //for(cursor_cnt = 0; cursor_cnt <= 36; cursor_cnt++) { ResyncInvClDelItem(SLOT_CURSOR, NULL); }
ResyncInvProcSlots(0, 21, token_inst); // Sync Worn
ResyncInvProcSlots(22, 29, token_inst); // Sync Personal
ResyncInvProcSlots(251, 330, token_inst, true, true, true); // Sync Personal Bags
/* IN-WORK */ //ResyncInvClDelItem(SLOT_CURSOR, token_inst); // Part of Bank Sync Hack Process
if(GetClientVersion() >= EQClientSoF) {
ResyncInvProcSlots(9999, 9999, token_inst); // Sync Power Source
/* IN-WORK */ ResyncInvProcSlots(2000, 2023, token_inst, false, false, false); // Sync Bank (Deletion Issue with Slot Range)
/* IN-WORK */ ResyncInvProcSlots(2031, 2270, token_inst, false, false, true); // Sync Bank Bags (Deletion Issue with Slot Range)
}
else {
/* IN-WORK */ ResyncInvProcSlots(2000, 2015, token_inst, false, false, false); // Sync Bank (Deletion Issue with Slot Range)
/* IN-WORK */ ResyncInvProcSlots(2031, 2190, token_inst, false, false, true); // Sync Bank Bags (Deletion Issue with Slot Range)
}
/* IN-WORK */ ResyncInvProcSlots(2500, 2501, token_inst, false, false, false); // Sync Shared Bank (Deletion Issue with Slot Range)
/* IN-WORK */ ResyncInvProcSlots(2531, 2550, token_inst, false, false, true); // Sync Shared Bank Bags (Deletion Issue with Slot Range)
/* IN-WORK */ //ResyncInvClDelItem(SLOT_CURSOR); // Part of Bank Sync Hack Process
cursor_cnt = 0; // Sync Cursor Array
/* IN-WORK */ /* for(std::list<ItemInst*>::const_iterator cursor_iter = m_inv.cursor_begin(); cursor_iter != m_inv.cursor_end() && cursor_cnt <=36; cursor_iter++) {
SendItemPacket(SLOT_CURSOR, *cursor_iter, ItemPacketSummonItem);
cursor_cnt++;
} */
ResyncInvProcSlots(331, 340, token_inst, true, true, true); // Sync Cursor Bags
if (cursor_cnt > 36) { Message(15, "Caution: Server cursor count exceeds client limit! Remove cursor items and zone or relog."); }
Message(14, "%s's inventory syncronization complete.", GetName());
}
void Client::ResyncInvProcSlots(sint16 slot_begin, sint16 slot_end, const ItemInst* token_inst, bool update_null, bool reg_delete, bool chk_parent) {
for(sint16 slot_id = slot_begin; slot_id <= slot_end; slot_id++) {
const ItemInst* slot_inst = m_inv[slot_id];
if(chk_parent) {
sint16 parent_slot = m_inv.CalcSlotId(slot_id);
if(parent_slot != SLOT_INVALID && m_inv[parent_slot] && m_inv[parent_slot]->GetItem()->ItemClass == 1) {
if(slot_inst) { SendItemPacket(slot_id, slot_inst, ItemPacketTrade); }
else {
SendItemPacket(slot_id, token_inst, ItemPacketTrade);
if(update_null) { ResyncInvClDelItem(slot_id, token_inst, reg_delete); }
}
}
}
else {
if(slot_inst) { SendItemPacket(slot_id, slot_inst, ItemPacketTrade); }
else {
SendItemPacket(slot_id, token_inst, ItemPacketTrade);
if(update_null) { ResyncInvClDelItem(slot_id, token_inst, reg_delete); }
}
}
}
}
void Client::ResyncInvClDelItem(sint16 slot_id, const ItemInst* token_inst, bool reg_delete) {
if(reg_delete) {
EQApplicationPacket* outapp = new EQApplicationPacket(OP_DeleteItem, sizeof(DeleteItem_Struct));
DeleteItem_Struct* delete_slot = (DeleteItem_Struct*)outapp->pBuffer;
delete_slot->from_slot = slot_id;
delete_slot->to_slot = 0xFFFFFFFF;
delete_slot->number_in_stack = 0xFFFFFFFF;
QueuePacket(outapp);
safe_delete(outapp);
}
else { /* IN-WORK */
EQApplicationPacket* outapp = new EQApplicationPacket(OP_DeleteItem, sizeof(DeleteItem_Struct));
DeleteItem_Struct* delete_slot = (DeleteItem_Struct*)outapp->pBuffer;
delete_slot->from_slot = slot_id;
delete_slot->to_slot = 0xFFFF; // Test value
delete_slot->number_in_stack = 0xFFFF; // Test value
QueuePacket(outapp);
safe_delete(outapp);
}
/* IF CAN FIGURE OUT OP_DeleteItem METHOD FOR ALTERNATE DELETE - REMOVE token_inst FROM ARGUMENTS */
}