The last 8 hours was quite an adventure...
First I found that item stacking as a feature was added on as kind of a hack. Items stack after they're read from the database and paginated. If stacking doesn't play well with pagination, then the whole thing falls apart. Time to add stacking as a part of the database handler. Now a "page with 25 stacks of items" will actually show 25 different items.
Next thing I found was that there's no grouping when items are stacked. 4 items can be found in page 2 while another 5 can be in page 10. When they're finally grouped together, the slot numbers are not grouped together consecutively. Time to write a new sorting function that respects stacking.
There comes a point where I needed to decide what happens if a user gets a an item that he/she already owns. Do the full stack of items now appear at the end of inventory, or would the item join the existing stack, preserving the sort order? I'll probably make that a user defined option later. For now, I'll respect the original sort order. The down side is that when you receive an item, it might not show up at the end of your inventory as it joins an existing stack.
All these things are actually not difficult in concept, but it's the fact that one need to read through someone else's code, spend hours understanding how it works and how not to break it, which is the real effort.
Just when I thought all the back end work is done, I found another bug responsible for placing stacked items in weird places. This time it's the frontend Javascript code again! gonk
I hope to wrap everything up before 3AM so I can answer some PM before heading to bed.
[4AM]
Well turns out the last bug is a backend bug after all. When inserting a stack of items from temp storage, we need to split the inventory to make space for the new items. There was a bug with splitting the inventory properly. Hopefully with this fix, the inventory arranger will work properly. 3nodding
Off to bed! whee
View User's Journal
Lanzer's Journal
User Comments: [15]
User Comments: [15]