Game Inventory System

So I've been trying to decide how I will write my player inventory system and I've tried it several ways, all of which haven't satisfied me. So I would like some feedback on what might be the best approach. Basically the requirements are this:

1. Player carries 2 bags (or more, haven't decided) of a size determined by the bag equipped.
2. Each bag has a predetermined number of inventory "slots."
3. When an item is picked up, the system must automatically seek out the first available inventory slot checking each bag for room and adding the item.
4. A player must be able to examine an inventory slot in either bag and view the attributes of an item.

Now I'm only in the design phase of this and I have my class inheritance down and all the members. I've been thinking about three different ways of doing this:
1. Use an array...
2. Use a vector...
3. My original plan... use a linked list.

Anyone have any ideas on the best approach?
I havnt done much with Inventory or stuff like that, but i sounds like using a Vector would work best, Then output to 2 files for each bag then search each fill for a NULL string. If condition is true then add this item. Your gonna have to play around with it for a while, but i just prefer vectors because i think they are easier to work with.
Since "each bag has a predetermined number of inventory slots" you should use a vector as opposed to a list. There's no point in using an array.
Last edited on
Just have the bag have a max_size unsigned int and a vector, then just compare the vector.size() to the vector (then you can force extra items in later if you want, or make it so you can get a bag upgrade or related stuff).
Ok. I'll focus my efforts on a vector design then. Thank you for your feedback.
Topic archived. No new replies allowed.