Item Stacks, Inventory, and Trading

Hey Folks! Late start today due to some site maintenance stuff, but still managed to get a fair amount of inventory and item stuff fixed.

Early in the day, a reported spam post alerted me to a handful of users that slipped through the net. I ended up trawling through the logs to make sure I caught them all. Thanks to all who reported the spam!

Once that was done, I resumed work on fixes to the trade and inventory systems. The first change was to limit trading interactions to NPCs who have an "IsTraderNPC" flag. This way, players won't waste their time starting a trade with an NPC that has no room to store items it buys. In the future, I'll probably split this into "IsSellerNPC" and "IsBuyerNPC" to cover cases where they can do one but not the other.

After that, it was a long list of fixes to item stacking and inventory. Players can now choose whether to pickup a single item vs. a whole stack when using the context menu. And dropping assumes just a single for now, since that's how they are listed in the inventory UI.

That revealed a series of bugs with stacks, however. Taking an item from a stack on a ship caused the stack to break. Adding and removing stacked items from containers would sometimes cause stack accounting errors. And in one random case, removing a partial stack from a container caused a game freeze.

Most of these were easy fixes once I found the problem. And a lot of it amounted to incorrectly assigning new parents, or iterating through the wrong item's stack. And I'm starting to wonder whether I've got the same code in three redundant places: ship, condition owner, and container. They each have specific roles to fill, but a lot of the same code appears in each. This might be a case for cleanup. Either now or later.

Anyway, getting the item management code more stable is always an important step towards playability. People expect an item to continue existing when it changes owner, after all :)