Fixed|Heretic|Hexen: 'ctl-inventory-use-next', inventory crash and logic errors

The inventory navigation in libcommon is very flexible, but also
buggy:
- with ctl-inventory-use-next, wrapping must occur at the leftmost slot
- inventoryMove didn't handle wrapping at all for the fixed/var cursor
- there was a crash when inventory-mode was 1 and inventory-wrap was 1
  and the player had only a few artifacts

Also refactored inventoryMove to be more legible.