-
an impossible bug
ok, this one has me completely stumped. somehow a variable is getting set by a block of code that doesnt even mention that variable. take a look:
Code:
board[0].x = BoardPosX;
board[1].x = BoardPosX;
for ( int i = 39; i < 53; ++i )
{
deck[i].val = i - 39;
deck[i].suit = 3;
deck[i].X = i * 12;
deck[i].Y = 10;
deck[i].selected = FALSE;
deck[i].played = FALSE;
deck[i].overturned = FALSE;
}
assert ( board[0].x == BoardPosX );
assert ( board[1].x == BoardPosX );
these asserts both fail every time. i explicitly set the values equal to what i want to be, but every time that for loop is run, they get changed. i put some break points and ran it through the debugger, and i watched it magically change the wrong values. somehow on the last run of the for loop, deck[i] ( in this case, deck[52] ) is effecting the first two indexes of board.
is it possible for the OS to screw up and allocate two different arrays in the same chunk of memory? neither of the arrays are dynamic, and my memory usage is normal. i really cant figure this one out...
-
Because deck[52] is indexed by 0..51
> for ( int i = 39; i < 53; ++i )
This indexes deck[52] on the last iteration, and thus probably blows away something you didn't want to
-
oh man, i just realized that i put that in there when i was expecting to have a joker in my deck, but i didnt know how to draw a joker so i left it out for now.
i totally forgot that i did that, thanks for pointing that out.
which leads to another question... does anyone know how to draw a joker with cards.dll?