Jump to content

[patch] Trade items


Recommended Posts

Posted

new thread as Vladimir want

some info about TRADE

example:

1) 1 player place all items in free bag which it want to trade and 1 player must have 1 free bag

2) 1 player init trade with 2 player

3) 1 player place all items from bag , 2 player place money

4) 1 player swap bags .. as items it trade save position..

   _player->tradeItems[tradeSlot] = pos;

if(Item* item  =_player->GetItemByPos( _player->tradeItems[i] ))

not passing..

   for(int i=0; i<TRADE_SLOT_TRADED_COUNT; ++i)
   {
       if(_player->tradeItems[i] != NULL_SLOT )
       {
           if(Item* item  =_player->GetItemByPos( _player->tradeItems[i] ))
           {
               if(!item->CanBeTraded())
               {
                   SendTradeStatus(TRADE_STATUS_TRADE_CANCELED);
                   return;
               }
           }
       }
       if(_player->pTrader->tradeItems[i] != NULL_SLOT)
       {
           if(Item* item  =_player->pTrader->GetItemByPos( _player->pTrader->tradeItems[i]) )
           {
               if(!item->CanBeTraded())
               {
                   SendTradeStatus(TRADE_STATUS_TRADE_CANCELED);
                   return;
               }
           }
       }
   }

possible fix.. not allow swap items which containes trade items..

or send cancel trade.. if item is not found

2 possible fix

   for (int i=0; i<TRADE_SLOT_TRADED_COUNT; ++i)
   {
       if(_player->tradeItems[i] != NULL_SLOT )
       {
           Item* item  =_player->GetItemByPos( _player->tradeItems[i] );
           if(!item || !item->CanBeTraded())
           {
               SendTradeStatus(TRADE_STATUS_TRADE_CANCELED);
               return;
           }
       }
       if(_player->pTrader->tradeItems[i] != NULL_SLOT)
       {
           Item* item  =_player->pTrader->GetItemByPos( _player->pTrader->tradeItems[i]);
           if(!item || !item->CanBeTraded())
           {
               SendTradeStatus(TRADE_STATUS_TRADE_CANCELED);
               return;
           }
       }
   }

5. as a result 1 player get money 2 player get nothing.

  • 3 weeks later...
Posted

problem is tradeItems contain position of item. after replace bags you make invalid pos. and

Item* item =_player->pTrader->GetItemByPos( _player->pTrader->tradeItems); return NULL

right variant may be store slot and bool inbag..

but 2 fix work for me.

Posted

currently we have not function like Item* GetItemByGuid. i implement it in rewrite items operations

when you place item in buy tabs, code move it from bag/inventory to tab.. i think need to store slot uint8 + bool per item or uint64 if guid..

  • 1 year later...
×
×
  • 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