Jump to content

[patch] Trade items


Guest zhenya``

Recommended Posts

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.

Link to comment
Share on other sites

  • 3 weeks later...
  • 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