Jump to content

[10225][fix] Filter Display items from a vendor(by Faction)


Guest a1ien

Recommended Posts

For example.

http://wowhead.com/npc=32216 this vendor show http://wowhead.com/item=44689 only for Alliance

and show http://wowhead.com/item=44690 only for Horde

diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp
index 41796a7..3d9057e 100644
--- a/src/game/ItemHandler.cpp
+++ b/src/game/ItemHandler.cpp
@@ -756,7 +756,8 @@ void WorldSession::SendListInventory(uint64 vendorguid)
            {
                if((pProto->AllowableClass & _player->getClassMask()) == 0 && pProto->Bonding == BIND_WHEN_PICKED_UP && !_player->isGameMaster())
                    continue;
-
+        if((pProto->AllowableRace & _player->getRaceMask()) == 0 && pProto->Bonding == BIND_WHEN_PICKED_UP && !_player->isGameMaster())
+            continue;
+
                ++count;

                // reputation discount

and another small fix

If after use filters from vendors will not be a single object that he can offer for sale then the vendor will not open the window

diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp
index 41796a7..ce94160 100644
--- a/src/game/ItemHandler.cpp
+++ b/src/game/ItemHandler.cpp
@@ -774,9 +775,11 @@ void WorldSession::SendListInventory(uint64 vendorguid)
        }
    }

-    if ( count == 0 || data.size() != 8 + 1 + size_t(count) * 8 * 4 )
-        return;
-
+    if(data.size() != 8 + 1 + size_t(count) * 8 * 4)
+        return;
+    if ( count == 0 )
+        data << uint8(0);
+       
    data.put<uint8>(count_pos, count);
    SendPacket( &data );
}

+ if ( count == 0 )

+ data << uint8(0);

package from Offy has length of 10 bytes

but we have if vendor does not offer any item for sale, package have length 9 bytes

This actually appends bytes

Link to comment
Share on other sites

Actually, packet structure should be like this:

SMSG_LIST_INVENTORY
uint64 guid;
uint8 count;
if(count)
{
   for(i = 0; i < count; ++i)
   {
       uint32 slot;
       uint32 entry;
       uint32 displayId;
       uint32 itemsCount;
       uint32 price;
       uint32 maxDurability;
       uint32 buyCount;
       uint32 extendedCostId;
   }
}
else
{
   uint8 error;
   // errors:
   // 0 - "Vendor has no inventory"
   // 1 - "I don't think he likes you very much"
   // 2 - "You are too far away"
   // 3 - "Vendor is dead"
   // 4 - "You can't shop while dead."
}

That explains why you need additional byte if vendor has no items.

Link to comment
Share on other sites

  • 1 month later...
Hmm, i check second patch at 3.3.5 client and client open empty vendor list instead show any messages...

in fact in same way as without patch... maybe client now not have error output mode for packet...

It still exist:

signed int __thiscall CGPlayer_C__OnListInventory(void *this, int a2)
{
 int v2; // eax@1
 signed int v3; // ecx@1
 int _packet; // edi@3
 unsigned __int8 v5; // bl@11
 int v6; // esi@12
 WGUID v8; // [sp+0h] [bp-10h]@3
 void *v9; // [sp+8h] [bp-8h]@1
 char error; // [sp+Fh] [bp-1h]@4

 v9 = this;
 v2 = &dword_C9D7D0;
 v3 = 150;
 do
 {
     *v2 = 0;
     v2 += 32;
     --v3;
 }
 while ( v3 );
 _packet = a2;
 CDataStore__GetInt64(a2, &v8);
 CDataStore__GetInt8(_packet, (&a2 + 3));
 if ( BYTE3(a2) > 150u )
     sub_8889B0(&byte_9E14FF, &byte_9E14FF, 0);
 dword_C9EA90 = v8.guid_low;
 dword_C9EA94 = v8.guid_high;
 error = -1;
 if ( BYTE3(a2) )
 {
     v5 = 0;
     if ( !BYTE3(a2) )
         return 1;
     do
     {
         v6 = 32 * v5;
         CDataStore__GetInt32(_packet, (&dword_C9D7D0 + v6));
         CDataStore__GetInt32(_packet, (&dword_C9D7D4 + v6));
         CDataStore__GetInt32(_packet, (&dword_C9D7D8 + v6));
         CDataStore__GetInt32(_packet, (&dword_C9D7DC + v6));
         CDataStore__GetInt32(_packet, (&dword_C9D7E0 + v6));
         CDataStore__GetInt32(_packet, (&dword_C9D7E4 + v6));
         CDataStore__GetInt32(_packet, (&dword_C9D7E8 + v6));
         CDataStore__GetInt32(_packet, (&dword_C9D7EC + v6));
         ++v5;
     }
     while ( v5 < BYTE3(a2) );
 }
 else
 {
     CDataStore__GetInt8(_packet, &error);
     switch ( error )
     {
         case 2:
             ConsoleWrite("You are too far away", 0);
             break;
         case 1:
             ConsoleWrite("I don't think he likes you very much", 0);
             break;
         case 0:
             ConsoleWrite("Vendor has no inventory", 0);
             break;
         case 3:
             ConsoleWrite("Vendor is dead", 0);
             break;
         case 4:
             ConsoleWrite("You can't shop while dead.", 0);
             break;
         default:
             break;
     }
 }
 if ( BYTE3(a2) || !error )
 {
     sub_6D1760(v9);
     sub_584500(v8.guid_low, v8.guid_high, &dword_C9D7D0, BYTE3(a2));
 }
 return 1;
}

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use