Skip to main content
gamedev.net
🔒 Locked

program went nuts

Started by firecast 4 replies 400+ views
Original Post
firecast
firecast
hi, this is something i''ve been debugging for 2 days!! and finally i discovered the problem... i made a struct named CELLINFO which contains another struct CELLSTATE... and other several variables (int, DWORD, etc) but the thing is: i created an array of that structure (CELLINFO) but when i want to set the value: Blocks[0][15].state = USED; //Blocks is a CELLINFO array which contains CELLSTATE (state) but when i want to use the entire array i get that the value Blocks[0][2].state is also USED .....BUT I NEVER DID MODIFY IT i initialize the array with every value at EMPTY. so i want to know how the heck do i get rid of this bug that is freakin'' me out... i want to finish my program ASAP. well thanks in advance...
This really pisses me off!!
C-Junkie
C-Junkie
stop smoking crack.
(translation: show some code?)
firecast
firecast
ok some code...


typedef enum _CELLSTATE_
{
EMPTY,
USED,
PIECE
} CELLSTATE;

typedef struct _CELLINFO_
{
INT x, y;
CELLSTATE state;
DWORD color;
} CELLINFO;



well... no i got the structs, but using them is a headache



void CPiece::Deposit(CELLINFO Cells[9][16])
{
for(int i=0;i<4;i++)
{
int sx = Pieces[i].x; //sx = 0, 1

int sy = Pieces[i].y; //sy = 15, 16

Cells[sx][sy].state = USED;
Cells[sx][sy].color = Pieces[0].color;
}
}



but the problem is there...
someway when i fill Cells[sx][sy].state... the subscript changes
and it fills the Cells[0][2].state as USED, i don''t know why
''cause those that element is never touched or modified, can u tell me what i''m doing wrong??
This really pisses me off!!
Rayno
Rayno
Have you set a breakpoint and that loop and checked if all the values are correct? In other words, are you sure that the Pieces array is set to what you thing it is? Because there is nothing blatantly wrong with that code.
Qw3r7yU10p!
Qw3r7yU10p!
need to show more code

hasta luemos
firecast
firecast
yes, i have set breakpoints, and the value changes when it sets the Cells[0][2] or so, i have checked, but i don't know why it changes...

the Pieces array is completely right.
the program runs as if i had modified the value at Cells[0][2]...

does anyone have any ideas???

[edited by - firecast on January 19, 2004 10:36:32 PM]
This really pisses me off!!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.