Jump to content
  • Advertisement
Sign in to follow this  
ninmonkeys

data type for rts-like targets

This topic is 4402 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working on an RTS-like game. I'll have a list of buildings, a list of units, a list of the players selections, and each unit has one target. I'm unsure which data type to use for the pointers to objects for my player selections, and my unit's targets. I've looked at the boost webpage, but I'm not finding much that clarifies (or at least that I understand) the differences between boost::ptr_vector and boost::shared_ptr . Right now I'm using a boost::ptr_vector< Unit > for my unit list, and trying to decide if I should change that type and what types to use for the selections and unit's targets. I'm unsure if I should be using something else, maybe boost::shared_ptr[b/] or whatever else for my unit list. Will that work so I can have another list of boost::weak_ptr ( or boost::ptr_vector or boost::shared_ptr ) to the units in the unit list for my selection? I think the boost::shared_ptr keeps the object alive until all pointers to it are gone. Which I only want the object (unit) alive if it is in the unit list, regardless if there's a selection pointer to it. (If the selection list points to a unit, but it doesn't exist in the unit list because it's dead, it would be invalid.) So maybe boost::shared_ptr for the unit list, and boost::weak_ptr's for the unit's target, and the selection list? thanks,

Share this post


Link to post
Share on other sites
Advertisement
Yes.

Specifically, keep a list of shared pointers in one central spot; use weak pointers everywhere else.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!