[Fixed] Trading (Stacking)

Put your bugs you find in osRose here

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

[Fixed] Trading (Stacking)

Postby Rifke on Tue Sep 25, 2007 9:49 pm

Player X has 80 Topaz[4] in inventory
He trades 10 with Player Y

Player X has 70 Topaz[4] in inventory

Player Y trades 5 Topaz[4] to Player X
Player X has 5 Topaz[4] in inventory.

Conclusion:
Items are not counted.
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: Trading (Stacking)

Postby Drakia on Tue Sep 25, 2007 10:55 pm

So, you trade one way, it works, then trade 5 back and it doesn't work?
My favorite skill is scaring new users away.
If you haven't SEARCHED expect me to yell at you.
Image
Drakia
ospRose dev team
ospRose dev team
 
Posts: 1614
Joined: Tue Sep 18, 2007 6:53 am
Location: Nanaimo, BC, Canada

Re: Trading (Stacking)

Postby PurpleYouko on Tue Sep 25, 2007 11:50 pm

What is happening is that if you trade for an item type of which you already have some, the result is that the amount added to your inventory replaces the stuff already there rather than adding to it.

If you have none in the first place then there is no problem it works fine.
If you already have some then you lose whatever you already have and end up with just the amount traded
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: Trading (Stacking)

Postby Terr0risT on Wed Sep 26, 2007 1:12 am

And this only happens during TRADE.

When you buy directly from a shop, it stacks well. meaning if you have 10pcs Apple, and you bought another 5, then all in all you got 15 in your inventory.

BUT if someone trades you another 5 apples and you complete the trade, boom! you look at your inventory and you only have 5 apples (where supposedly you have 20).
User avatar
Terr0risT
Rackie
Rackie
 
Posts: 162
Joined: Sat Aug 11, 2007 10:22 am

Re: Trading (Stacking)

Postby Drakia on Wed Sep 26, 2007 1:43 am

Ok, easy fix for that I'm assuming (There were a lot of cases where this happened, I guess this one wasn't fixed) I'll do it after my lab.
My favorite skill is scaring new users away.
If you haven't SEARCHED expect me to yell at you.
Image
Drakia
ospRose dev team
ospRose dev team
 
Posts: 1614
Joined: Tue Sep 18, 2007 6:53 am
Location: Nanaimo, BC, Canada

Re: Trading (Stacking)

Postby Drakia on Wed Sep 26, 2007 5:20 am

Ok, as I thought it was an easy fix:

That should fix it right up :) If there's any more problems let me know.
My favorite skill is scaring new users away.
If you haven't SEARCHED expect me to yell at you.
Image
Drakia
ospRose dev team
ospRose dev team
 
Posts: 1614
Joined: Tue Sep 18, 2007 6:53 am
Location: Nanaimo, BC, Canada

Re: Trading (Stacking)

Postby Rifke on Wed Sep 26, 2007 12:34 pm

  1.  
  2. Find:
  3. thisclient->items[newslot].count = otherclient->Trade->trade_count[i];
  4. Replace With:
  5. thisclient->items[newslot].count += otherclient->Trade->trade_count[i];
  6.  


I do think it has to be:
thisclient->items[newslot].count -= otherclient->Trade->trade_count[i];

Because it should be substract not added?
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: Trading (Stacking)

Postby Drakia on Wed Sep 26, 2007 3:02 pm

Nope, it has to add, it was subtracting properly (As you could tell from trading 10, having 70 left) it was not adding correctly.
My favorite skill is scaring new users away.
If you haven't SEARCHED expect me to yell at you.
Image
Drakia
ospRose dev team
ospRose dev team
 
Posts: 1614
Joined: Tue Sep 18, 2007 6:53 am
Location: Nanaimo, BC, Canada

Re: Trading (Stacking)

Postby core on Wed Sep 26, 2007 5:48 pm

Drakia wrote:Ok, as I thought it was an easy fix:
  1. WorldPackets.cpp
  2. Find:
  3. otherclient->items[newslot].count = thisclient->Trade->trade_count[i];
  4. Replace With:
  5. otherclient->items[newslot].count += thisclient->Trade->trade_count[i];
  6. Find:
  7. thisclient->items[newslot].count = otherclient->Trade->trade_count[i];
  8. Replace With:
  9. thisclient->items[newslot].count += otherclient->Trade->trade_count[i];
  10.  

That should fix it right up :) If there's any more problems let me know.


I tried to fix it that way before as well and it was not working because the traded mat gets only doubled.

Example: User1 trades 200 twig to User2 who already has 50 twig in his inventory. Result: the 50 twig get overwritten by 400 twigs.
Image
User avatar
core
Pomic
Pomic
 
Posts: 126
Joined: Thu Aug 09, 2007 5:47 pm

Re: [Fixed] Trading (Stacking)

Postby Drakia on Wed Sep 26, 2007 5:59 pm

That's not possible Core.
What this function does is call the GetNewItemSlot function for PlayerA, which goes through the inventory looking for either a blank slot, or one with the same item in it. It then returns this slot number. It takes away the item from PlayerB, checks to see if they have 0 of that item left and if so, deletes it from their inventory. It then sets the item in the slot retrieved from the earlier function call for PlayerA to what PlayerB was trading, adds how many were traded to it (This is what I changed, it used to set it to that amount. Maybe instead of replacing this line before, you had added an addition below it?) Then it sends PlayerA a packet updating their inventory. This is repeated for PlayerB.
There is no way my fix will cause PlayerA to get double of what PlayerB was giving them.
My favorite skill is scaring new users away.
If you haven't SEARCHED expect me to yell at you.
Image
Drakia
ospRose dev team
ospRose dev team
 
Posts: 1614
Joined: Tue Sep 18, 2007 6:53 am
Location: Nanaimo, BC, Canada

Next

Return to Bugs

Who is online

Users browsing this forum: No registered users and 3 guests