Because the database is wrong! That's the problem. The slots need to be in order, that's the correct way of doing things. We're just lucky the code doesn't actually use the slot to place the item, otherwise we'd see gaps on the merchants in-game.
The only reason why it is so bad is because items have been removed over time that do not belong. Now that all of the bogus items from vendors have been removed in PEQ, it has increased the gap problem considerably. Once all merchant's slots are in order starting at 1, we will no longer have a problem. The PEQ Editor, and I'm sure any other editor that works with merchantlists will automatically put any new items in order by slot. It is up to the world builder to make sure this happens.
Of course I'd like to see the code check a slot to make sure it isn't in use first before assigning it, but fixing that and then ignoring the gaps in the database is just plain lazy. If something is going to be done, it needs to be done right.
|