cant figure out why keep crashing

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
std::vector<Tower> t;
std::vector<Enemy> en;

for ( int a = 0; a < en.size(); a++ )
        {
            if ( !en[a].isAlive() )
            {
                bool hasBulletLocked = false;
                for ( std::size_t b = 0; b < t.size(); b++ )
                {
                   if ( t[a].getBullets().size() > 0 )
                   {
                       const std::vector<Bullet>& bullets = t[a].getBullets();
                       for ( std::size_t cc = 0; cc < bullets.size(); cc++ )
                       {
                           if ( bullets[cc].index == a && bullets[cc].isHit() )
                           {
                               hasBulletLocked = true;
                               break;
                           }
                       }
                       if ( hasBulletLocked )
                            break;
                   }
                }
                if ( !hasBulletLocked )
                {

                }
            }
        }


heres is the screenshot of watches: http://imgur.com/a/QvXGn
as you can see on the screenshot, theres nothing fishy on the watches
i dont know why but in debugger, it stops and yellow arrow pointing to this line
 
if ( bullets[cc].index == a && bullets[cc].isHit() )


as you can see in the code, theres no modification of any data there, its just looping through those vectors, except
 
hasBulletLocked 
which is imposible to be the problem

edit:
heres another screenshot of watches: http://imgur.com/a/xuXGH


Last edited on
Every time you access t you use a as the index instead of b.
@helios damn it, been debugging for 5 hours !! thanks ! you are the one who answered the last thread i read before posting here lol
Topic archived. No new replies allowed.