Fix for Corpse Slot Population and Power Source Auto-Inventory
This patch addresses the issue of corpse window slots not being fully populated and power source items not being auto-inventoried.
In the corpse slots, I adjusted the translators to allow relevent enumerated client slots to be accessed. The SoF translator was off by one already and that's
where that weird clicking issue I was having came from. I also tweaked Corpse::QueryLoot, accessed through '#corpse inspectloot,' to display accordingly
as well.
The other issue was with auto-looting a power source item. It never went into the power source slot. The looting procedure didn't include this slot and I added
it to the check with a client verifier to avoid possible titanium crashes.
These should work with at least SoD and UF clients since they use the same slot assignments. It tested ok with SoF, but really should be tested with the other
three clients as well.
[CorpseLoot-PowerSource.patch]
Code:
Index: common/patches/SoD.cpp
===================================================================
--- common/patches/SoD.cpp (revision 2267)
+++ common/patches/SoD.cpp (working copy)
@@ -108,7 +108,7 @@
static inline int32 TitaniumToSoDSlot(int32 TitaniumSlot) {
int32 SoDSlot = 0;
- if(TitaniumSlot >= 21 && TitaniumSlot <= 51) // Cursor/Ammo/Power Source and Normal Inventory Slots
+ if(TitaniumSlot >= 21 && TitaniumSlot <= 53) // Cursor/Ammo/Power Source and Normal Inventory Slots
{
SoDSlot = TitaniumSlot + 1;
}
@@ -140,7 +140,7 @@
static inline int32 SoDToTitaniumSlot(int32 SoDSlot) {
int32 TitaniumSlot = 0;
- if(SoDSlot >= 22 && SoDSlot <= 51) // Cursor/Ammo/Power Source and Normal Inventory Slots
+ if(SoDSlot >= 22 && SoDSlot <= 54) // Cursor/Ammo/Power Source and Normal Inventory Slots
{
TitaniumSlot = SoDSlot - 1;
}
Index: common/patches/SoF.cpp
===================================================================
--- common/patches/SoF.cpp (revision 2267)
+++ common/patches/SoF.cpp (working copy)
@@ -108,7 +108,7 @@
static inline int32 TitaniumToSoFSlot(int32 TitaniumSlot) {
int32 SoFSlot = 0;
- if(TitaniumSlot >= 21 && TitaniumSlot <= 50) // Cursor/Ammo/Power Source and Normal Inventory Slots
+ if(TitaniumSlot >= 21 && TitaniumSlot <= 53) // Cursor/Ammo/Power Source and Normal Inventory Slots
{
SoFSlot = TitaniumSlot + 1;
}
@@ -140,7 +140,7 @@
static inline int32 SoFToTitaniumSlot(int32 SoFSlot) {
int32 TitaniumSlot = 0;
- if(SoFSlot >= 22 && SoFSlot <= 51) // Cursor/Ammo/Power Source and Normal Inventory Slots
+ if(SoFSlot >= 22 && SoFSlot <= 54) // Cursor/Ammo/Power Source and Normal Inventory Slots
{
TitaniumSlot = SoFSlot - 1;
}
Index: common/patches/Underfoot.cpp
===================================================================
--- common/patches/Underfoot.cpp (revision 2267)
+++ common/patches/Underfoot.cpp (working copy)
@@ -109,7 +109,7 @@
static inline int32 TitaniumToUnderfootSlot(int32 TitaniumSlot) {
int32 UnderfootSlot = 0;
- if(TitaniumSlot >= 21 && TitaniumSlot <= 51) // Cursor/Ammo/Power Source and Normal Inventory Slots
+ if(TitaniumSlot >= 21 && TitaniumSlot <= 53) // Cursor/Ammo/Power Source and Normal Inventory Slots
{
UnderfootSlot = TitaniumSlot + 1;
}
@@ -141,7 +141,7 @@
static inline int32 UnderfootToTitaniumSlot(int32 UnderfootSlot) {
int32 TitaniumSlot = 0;
- if(UnderfootSlot >= 22 && UnderfootSlot <= 51) // Cursor/Ammo/Power Source and Normal Inventory Slots
+ if(UnderfootSlot >= 22 && UnderfootSlot <= 54) // Cursor/Ammo/Power Source and Normal Inventory Slots
{
TitaniumSlot = UnderfootSlot - 1;
}
Index: zone/inventory.cpp
===================================================================
--- zone/inventory.cpp (revision 2267)
+++ zone/inventory.cpp (working copy)
@@ -580,8 +580,13 @@
// #1: Try to auto equip
if (try_worn && inst.IsEquipable(GetBaseRace(), GetClass()) && inst.GetItem()->ReqLevel<=level && !inst.GetItem()->Attuneable && inst.GetItem()->ItemType != ItemTypeAugment)
{
- for (sint16 i = 0; i < 22; i++)
+ for (sint16 i = 0; i < 9999; i++) // originally (i < 22)
{
+ if (i == 22) {
+ if(this->GetClientVersion() >= EQClientSoF) { i = 9999; } // added power source check for SoF+ clients
+ else { break; }
+ }
+
if (!m_inv[i])
{
if( i == SLOT_PRIMARY && inst.IsWeapon() ) // If item is primary slot weapon
Index: zone/PlayerCorpse.cpp
===================================================================
--- zone/PlayerCorpse.cpp (revision 2267)
+++ zone/PlayerCorpse.cpp (working copy)
@@ -366,8 +366,12 @@
// worn + inventory + cursor
std::list<uint32> removed_list;
bool cursor = false;
- for(i = 0; i <= 30; i++)
+ for(i = 0; i <= 31; i++)
{
+ if(i == 31) {
+ if(client->GetClientVersion() >= EQClientSoF) { i = 9999; }
+ else { break; }
+ }
item = client->GetInv().GetItem(i);
if((item && (!client->IsBecomeNPC())) || (item && client->IsBecomeNPC() && !item->GetItem()->NoRent))
{
@@ -445,7 +449,7 @@
// Qualified bag slot iterations. processing bag slots that don't exist is probably not a good idea.
if(item->IsType(ItemClassContainer) && ((equipslot >= 22 && equipslot <=30))) // Limit the bag check to inventory and cursor slots.
{
- for(bagindex = 0; bagindex <= 10; bagindex++)
+ for(bagindex = 0; bagindex <= 9; bagindex++)
{
// For empty bags in cursor queue, slot was previously being resolved as SLOT_INVALID (-1)
interior_slot = Inventory::CalcSlotId(equipslot, bagindex);
@@ -454,7 +458,7 @@
if(interior_item)
{
AddItem(interior_item->GetItem()->ID, interior_item->GetCharges(), interior_slot, interior_item->GetAugmentItemID(0), interior_item->GetAugmentItemID(1), interior_item->GetAugmentItemID(2), interior_item->GetAugmentItemID(3), interior_item->GetAugmentItemID(4));
- returnlist.push_back(Inventory::CalcSlotId(equipslot, bagindex));
+ returnlist.push_back(Inventory::CalcSlotId(equipslot, bagindex));
client->DeleteItemInInventory(interior_slot, 0, true, false);
}
}
@@ -1004,27 +1008,11 @@
cur = itemlist.begin();
end = itemlist.end();
- int corpselootlimit = 30; // 30 is the original value // con check value in QueryLoot needs to reflect this value
+ int corpselootlimit;
- /* need actual corpse limit values per client (or client range)..if always 30, then these con checks are unneeded
- // enumeration shouldn't be needed unless someone finds a use for this info elsewhere
-
- if (client->GetClientVersion()>=EQClientVoA)
- corpselootlimit=30;
- else if (client->GetClientVersion()>=EQClientHoT)
- corpselootlimit=30;
- else if (client->GetClientVersion()>=EQClientUnderfoot)
- corpselootlimit=30;
- else if (client->GetClientVersion()>=EQClientSoD)
- corpselootlimit=30;
- else if (client->GetClientVersion()>=EQClientSoF) // SoF has 32 visible slots..change untested
- corpselootlimit=30;
- else if (client->GetClientVersion()>=EQClientTitanium)
- corpselootlimit=30;
- else if (client->GetClientVersion()>=EQClient62)
- corpselootlimit=30;
- else
- corpselootlimit=30; // */
+ if (client->GetClientVersion() >= EQClientSoF) { corpselootlimit = 32; }
+ else if (client->GetClientVersion() == EQClientTitanium) { corpselootlimit = 31; }
+ else { corpselootlimit = 30; }
for(; cur != end; cur++) {
ServerLootItem_Struct* item_data = *cur;
@@ -1033,10 +1021,11 @@
// Dont display the item if it's in a bag
// Added cursor queue slots to corpse item visibility list. Nothing else should be making it to corpse.
- if(!IsPlayerCorpse() || item_data->equipSlot <= 30 || tCanLoot>=3 ||
+ // A Power Source item viewed on a corpse by a Titanium client hopefully won't crash it.
+ if(!IsPlayerCorpse() || item_data->equipSlot <= 30 || item_data->equipSlot == 9999 || tCanLoot>=3 ||
(item_data->equipSlot >= 8000 && item_data->equipSlot <= 8999))
{
- if (i < corpselootlimit) // < 30 (0 - 29)
+ if (i < corpselootlimit)
{
item = database.GetItem(item_data->item_id);
if (client && item)
@@ -1050,15 +1039,15 @@
item_data->lootslot = i;
}
}
- else if (i == corpselootlimit) // = 30
+ else if (i == corpselootlimit)
{
- client->Message(13, "*** This corpse contains more items than can be displayed! ***");
+ client->Message(15, "*** This corpse contains more items than can be displayed! ***");
client->Message(0, "Remove items and re-loot corpse to access remaining inventory.");
}
i++;
}
}
- if (i > corpselootlimit) // > 30 (remember 'i' is increased again after the last iteration, so no '=')
+ if (i > corpselootlimit) // (remember 'i' is increased again after the last iteration, so no '=')
client->Message(0, "(%s contains %i additional %s.)", GetName(), (i-corpselootlimit), (i-corpselootlimit)==1?"item":"items");
if (IsPlayerCorpse() && i == 0 && itemlist.size() > 0) { // somehow, corpse contains items, but client doesn't see them...
@@ -1355,12 +1344,20 @@
}
void Corpse::QueryLoot(Client* to) {
- int x = 0, y = 0; // x = visible items, y = total items
- to->Message(0, "Coin: %ip %ig %is %ic", platinum, gold, silver, copper);
+ int x = 0, y = 0; // x = visible items, y = total items
+ to->Message(0, "Coin: %ip, %ig, %is, %ic", platinum, gold, silver, copper);
+
ItemList::iterator cur,end;
cur = itemlist.begin();
end = itemlist.end();
+
+ int corpselootlimit;
+
+ if (to->GetClientVersion() >= EQClientSoF) { corpselootlimit = 32; }
+ else if (to->GetClientVersion() == EQClientTitanium) { corpselootlimit = 31; }
+ else { corpselootlimit = 30; }
+
for(; cur != end; cur++) {
ServerLootItem_Struct* sitem = *cur;
@@ -1368,14 +1365,14 @@
if (sitem->equipSlot >= 251 && sitem->equipSlot <= 340)
sitem->lootslot = 0xFFFF;
else
- x < 30 ? sitem->lootslot = x : sitem->lootslot = 0xFFFF; // this con value needs to reflect corpselootlimit in MakeLootRequestPackets
+ x < corpselootlimit ? sitem->lootslot = x : sitem->lootslot = 0xFFFF;
const Item_Struct* item = database.GetItem(sitem->item_id);
if (item)
- to->Message((sitem->lootslot == 0xFFFF), " LootSlot: %i (EquipSlot: %i) Item: %s (%d) with %i %s", sitem->lootslot, sitem->equipSlot, item->Name, item->ID, sitem->charges, sitem->charges==1?"charge":"charges");
+ to->Message((sitem->lootslot == 0xFFFF), "LootSlot: %i (EquipSlot: %i) Item: %s (%d), Count: %i", static_cast<sint16>(sitem->lootslot), sitem->equipSlot, item->Name, item->ID, sitem->charges);
else
- to->Message((sitem->lootslot == 0xFFFF), " Error: 0x%04x", sitem->item_id);
+ to->Message((sitem->lootslot == 0xFFFF), "Error: 0x%04x", sitem->item_id);
if (sitem->lootslot != 0xFFFF)
x++;
@@ -1387,9 +1384,9 @@
const Item_Struct* item = database.GetItem(sitem->item_id);
if (item)
- to->Message(0, " LootSlot: %i Item: %s (%d) with %i %s", sitem->lootslot, item->Name, item->ID, sitem->charges, sitem->charges==1?"charge":"charges");
+ to->Message(0, "LootSlot: %i Item: %s (%d), Count: %i", sitem->lootslot, item->Name, item->ID, sitem->charges);
else
- to->Message(0, " Error: 0x%04x", sitem->item_id);
+ to->Message(0, "Error: 0x%04x", sitem->item_id);
y++;
}
__________________
Uleat of Bertoxxulous
Compilin' Dirty
|