small miracle: bullets into gems

Bugs found for osProse project.

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

small miracle: bullets into gems

Postby PurpleYouko on Mon May 19, 2008 3:47 pm

I have had reports that when a mob drops bean bullets and you pick them up, they become gems. Specifically sapphire(1)
bean bullets and Sapphire(1) have one thing in common. They both have an item number of 321.
That is where the similarity ends though.
Somehow the type (12 for bullets) is being changed on pick up (to 11 for gems)
I am investigating it.

ABE
Found it.
The error is in PlaterFunctions GetNewItemSlot.
this piece of code is the culprit.
  1.  
  2. case 1:case 2://consumible and etc
  3.             {
  4.                 if((items[slot].itemnum == thisitem.itemnum && items[slot].count<999)
  5.                     ||(items[slot].itemnum==0 && items[slot].count<1))
  6.                     return slot;
  7.             }
  8.             break;

It doesn't differentiate between item types 11 and 12 here. so when you pick up some bean bullets and you already have the right kind of gem in your inventory, it will just stack them on top.

try this instead.
  1.  
  2. case 1:case 2://consumible and etc
  3.             {
  4.                 if((items[slot].itemnum == thisitem.itemnum && items[slot].itemtype == thisitem.itemtype && items[slot].count<999)
  5.                     ||(items[slot].itemnum==0 && items[slot].count<1))
  6.                     return slot;
  7.             }
  8.             break;

That should fix it.

In fact, what the heck, why not just replace the entire function with this. It fixes issues items with not stacking also. I developed this for my evo server and since the code is identical in this spot. here it is.
  1.  
  2. // Returns a free slot in the inventory (0xffff if is full)
  3. UINT CPlayer::GetNewItemSlot( CItem thisitem )
  4. {
  5.     UINT tabsize = 30;
  6.     UINT itemtab = 0;
  7.     switch(thisitem.itemtype)
  8.     {
  9.         case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9://equip
  10.             itemtab=0;
  11.         break;
  12.         case 10://consumibles
  13.             itemtab=1;
  14.         break;
  15.         case 11:case 12://etc
  16.             itemtab=2;            
  17.         break;  
  18.         case 14://pat
  19.             itemtab=3;
  20.         break;
  21.         default:
  22.             Log(MSG_WARNING,"unknown itemtype %i", thisitem.itemtype);
  23.             return 0xffff;
  24.          break;      
  25.     }
  26.     //useitems and natural
  27.     //first we try to find a slot that already contains some of this item
  28.     //this way the items will always stack if possible.
  29.     if(itemtab == 1 || itemtab == 2)
  30.     {
  31.         for(int i=0;i<30;i++)
  32.         {
  33.             UINT slot=12;
  34.             slot += (tabsize*itemtab)+i;
  35.             if(items[slot].itemnum == thisitem.itemnum && items[slot].itemtype == thisitem.itemtype)
  36.             {
  37.                 int totcount=thisitem.count + items[slot].count;
  38.                 if(totcount<999)
  39.                     return slot;
  40.             }                                
  41.         }
  42.     }
  43.     //now scan again to find a fully empty slot for mats, useitems and equipable stuff
  44.     //doesn't matter what tab type
  45.     for(int i=0;i<30;i++)
  46.     {
  47.         UINT slot=12;
  48.         slot += (tabsize*itemtab)+i;
  49.         if(items[slot].itemnum==0 &items[slot].count<1)
  50.             return slot;  
  51.     }   
  52.     return 0xffff;
  53. }
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest

cron