Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    570
  • comments
    2427
  • views
    217196

Untitled

Sign in to follow this  
Mushu

100 views

Why the hell did I not see this sooner -
	void killTileType( TileType type ) {
for ( TileList::iterator i = _tiles.begin(); i != _tiles.end(); ++i ) {
if ( (*i) == type ) {
(*i) = NULL;

} else {
++i;
}
}
}

And I was wondering why my iterator was falling off the edge. LOL!

Needless to say, deleting tiles from a tileset when they are currently in use no longer crashes the whole program. But it will delete those tiles from your map, which may or may not be what you wanted to have done. And thanks to matTd for kindly pointing out that I'm an idiot. Its always appreciated :D
Sign in to follow this  


2 Comments


Recommended Comments

I guess this was a do while loop before hence the stay ++i in the for loop body :OP

Gotta love iterators :O)

Share this comment


Link to comment
I honestly don't remember. I think I was possibly drunk when I wrote that :P

Share this comment


Link to comment

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
  • 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!