Jump to content

Variable size lists/vectors in the code?


Go to solution Solved by Raz0r,

Recommended Posts

Posted

Or if you're crazy, build your own :P

 

On a serious note, there's pretty much no reason not to make use std::vector

JKG Developer

Posted

Or if you're crazy, build your own :P

 

On a serious note, there's pretty much no reason not to make use std::vector

Except when the situation isn't ideal for it. OP, what are you using the vector for?
Posted

I built my own linked list data structure. Better than that though, I think I'll just use arrays with special values to indicate empty slots.

 

What I was using it for is to have NPCs maintain several lists of weapons they have for multi-weapon support like all weapons possessed, heavy weapons, blaster weapons, etc. That way when they have their weapon taken or they cycle between multiple weapons (like Boba) they can make a proper decision of what to switch to without the AI expecting them to possess certain weapons.

Asgarath83 likes this
Posted

The way that's generally handled (with <= 32 weapons) is just a single uint32_t weapons, if the nth bit is set, it owns the nth weapon.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...