Hey guys.
I've got this code where I set an iterator to point to the end of a vector so that a loop will end. I debugged it and it sets the iterator to the end because it points to 0xcdcdcdcd, but the for loop check doesn't seem to notice that the iterator points to the end because it tries to increment it and I get an error:
I can't see anything wrong with my code, but maybe someone else can...Code:void Tile_Palette::Update(const SDL_Event* event_) { if(!event_) return; if(event_->type == SDL_MOUSEBUTTONUP) { const SDL_Rect mouse = {event_->motion.x, event_->motion.y}; ptile_it it = camera_tiles.begin(); for(; it != camera_tiles.end(); ++it) { if(SDL_Tools::mouse_over_rect(mouse, (*it)->Get_Position())) { // Changed tile pen. tile_pen = *(*it); it = camera_tiles.end(); } } } }![]()
Oh, and camera_tiles looks like this:Cheers.Code:std::vector<XTile*> camera_tiles;





Reply With Quote